| 1 |
// REQUIRES: zlib && !zstd |
| 2 |
// UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}, target={{.*}}-zos{{.*}} |
| 3 |
|
| 4 |
// |
| 5 |
// Generate the host binary to be bundled. |
| 6 |
// |
| 7 |
// RUN: %clang -O0 -target %itanium_abi_triple %s -c -emit-llvm -o %t.bc |
| 8 |
|
| 9 |
// |
| 10 |
// Generate an empty file to help with the checks of empty files. |
| 11 |
// |
| 12 |
// RUN: touch %t.empty |
| 13 |
|
| 14 |
// |
| 15 |
// Generate device binaries to be bundled. |
| 16 |
// |
| 17 |
// RUN: echo 'Content of device file 1' > %t.tgt1 |
| 18 |
// RUN: echo 'Content of device file 2' > %t.tgt2 |
| 19 |
|
| 20 |
// |
| 21 |
// Check compression/decompression of offload bundle. |
| 22 |
// |
| 23 |
// RUN: env OFFLOAD_BUNDLER_COMPRESS=1 OFFLOAD_BUNDLER_VERBOSE=1 \ |
| 24 |
// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 25 |
// RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc 2>&1 | \ |
| 26 |
// RUN: FileCheck -check-prefix=COMPRESS %s |
| 27 |
// RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST %s |
| 28 |
// RUN: env OFFLOAD_BUNDLER_VERBOSE=1 \ |
| 29 |
// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 30 |
// RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle 2>&1 | \ |
| 31 |
// RUN: FileCheck -check-prefix=DECOMPRESS %s |
| 32 |
// RUN: diff %t.tgt1 %t.res.tgt1 |
| 33 |
// RUN: diff %t.tgt2 %t.res.tgt2 |
| 34 |
|
| 35 |
// |
| 36 |
// COMPRESS: Compression method used: zlib |
| 37 |
// COMPRESS: Compression level: 6 |
| 38 |
// DECOMPRESS: Decompression method: zlib |
| 39 |
// DECOMPRESS: Hashes match: Yes |
| 40 |
// NOHOST-NOT: host- |
| 41 |
// NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx900 |
| 42 |
// NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx906 |
| 43 |
// |
| 44 |
|
| 45 |
// Check compression/decompression of offload bundle using version 3 format. |
| 46 |
// |
| 47 |
// RUN: env OFFLOAD_BUNDLER_COMPRESS=1 OFFLOAD_BUNDLER_VERBOSE=1 COMPRESSED_BUNDLE_FORMAT_VERSION=3 \ |
| 48 |
// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 49 |
// RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc 2>&1 | \ |
| 50 |
// RUN: FileCheck -check-prefix=COMPRESS-V3 %s |
| 51 |
// RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST-V3 %s |
| 52 |
// RUN: env OFFLOAD_BUNDLER_VERBOSE=1 \ |
| 53 |
// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 54 |
// RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle 2>&1 | \ |
| 55 |
// RUN: FileCheck -check-prefix=DECOMPRESS-V3 %s |
| 56 |
// RUN: diff %t.tgt1 %t.res.tgt1 |
| 57 |
// RUN: diff %t.tgt2 %t.res.tgt2 |
| 58 |
// |
| 59 |
// COMPRESS-V3: Compressed bundle format version: 3 |
| 60 |
// COMPRESS-V3: Compression method used: zlib |
| 61 |
// COMPRESS-V3: Compression level: 6 |
| 62 |
// DECOMPRESS-V3: Compressed bundle format version: 3 |
| 63 |
// DECOMPRESS-V3: Decompression method: zlib |
| 64 |
// DECOMPRESS-V3: Hashes match: Yes |
| 65 |
// NOHOST-V3-NOT: host- |
| 66 |
// NOHOST-V3-DAG: hip-amdgcn-amd-amdhsa--gfx900 |
| 67 |
// NOHOST-V3-DAG: hip-amdgcn-amd-amdhsa--gfx906 |
| 68 |
|
| 69 |
// Check compression/decompression of offload bundle using version 2 format. |
| 70 |
// |
| 71 |
// RUN: env OFFLOAD_BUNDLER_COMPRESS=1 OFFLOAD_BUNDLER_VERBOSE=1 COMPRESSED_BUNDLE_FORMAT_VERSION=2 \ |
| 72 |
// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 73 |
// RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc 2>&1 | \ |
| 74 |
// RUN: FileCheck -check-prefix=COMPRESS-V2 %s |
| 75 |
// RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST-V2 %s |
| 76 |
// RUN: env OFFLOAD_BUNDLER_VERBOSE=1 \ |
| 77 |
// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 78 |
// RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle 2>&1 | \ |
| 79 |
// RUN: FileCheck -check-prefix=DECOMPRESS-V2 %s |
| 80 |
// RUN: diff %t.tgt1 %t.res.tgt1 |
| 81 |
// RUN: diff %t.tgt2 %t.res.tgt2 |
| 82 |
// |
| 83 |
// COMPRESS-V2: Compressed bundle format version: 2 |
| 84 |
// COMPRESS-V2: Compression method used: zlib |
| 85 |
// COMPRESS-V2: Compression level: 6 |
| 86 |
// DECOMPRESS-V2: Compressed bundle format version: 2 |
| 87 |
// DECOMPRESS-V2: Decompression method: zlib |
| 88 |
// DECOMPRESS-V2: Hashes match: Yes |
| 89 |
// NOHOST-V2-NOT: host- |
| 90 |
// NOHOST-V2-DAG: hip-amdgcn-amd-amdhsa--gfx900 |
| 91 |
// NOHOST-V2-DAG: hip-amdgcn-amd-amdhsa--gfx906 |
| 92 |
|
| 93 |
// Check -compression-level= option |
| 94 |
|
| 95 |
// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 96 |
// RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc -compress -verbose -compression-level=9 2>&1 | \ |
| 97 |
// RUN: FileCheck -check-prefix=LEVEL %s |
| 98 |
// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 99 |
// RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle |
| 100 |
// RUN: diff %t.tgt1 %t.res.tgt1 |
| 101 |
// RUN: diff %t.tgt2 %t.res.tgt2 |
| 102 |
// |
| 103 |
// LEVEL: Compression method used: zlib |
| 104 |
// LEVEL: Compression level: 9 |
| 105 |
|
| 106 |
// |
| 107 |
// Check -bundle-align option. |
| 108 |
// |
| 109 |
|
| 110 |
// RUN: clang-offload-bundler -bundle-align=4096 -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.bc -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.bc -compress |
| 111 |
// RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -output=%t.res.bc -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.bundle3.bc -unbundle |
| 112 |
// RUN: diff %t.bc %t.res.bc |
| 113 |
// RUN: diff %t.tgt1 %t.res.tgt1 |
| 114 |
// RUN: diff %t.tgt2 %t.res.tgt2 |
| 115 |
|
| 116 |
// |
| 117 |
// Check unbundling archive. |
| 118 |
// |
| 119 |
// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 120 |
// RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip_bundle1.bc -compress |
| 121 |
// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 122 |
// RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip_bundle2.bc -compress |
| 123 |
// RUN: rm -f %t.hip_archive.a |
| 124 |
// RUN: llvm-ar cr %t.hip_archive.a %t.hip_bundle1.bc %t.hip_bundle2.bc |
| 125 |
// RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ |
| 126 |
// RUN: -output=%t.hip_900.a -output=%t.hip_906.a -input=%t.hip_archive.a |
| 127 |
// RUN: llvm-ar t %t.hip_900.a | FileCheck -check-prefix=HIP-AR-900 %s |
| 128 |
// RUN: llvm-ar t %t.hip_906.a | FileCheck -check-prefix=HIP-AR-906 %s |
| 129 |
// HIP-AR-900-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx900 |
| 130 |
// HIP-AR-900-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx900 |
| 131 |
// HIP-AR-906-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx906 |
| 132 |
// HIP-AR-906-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx906 |
| 133 |
|
| 134 |
// Some code so that we can create a binary out of this file. |
| 135 |
int A = 0; |
| 136 |
void test_func(void) { |
| 137 |
++A; |
| 138 |
} |