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-level= option 70 71 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ 72 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc -compress -verbose -compression-level=9 2>&1 | \ 73 // RUN: FileCheck -check-prefix=LEVEL %s 74 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ 75 // RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle 76 // RUN: diff %t.tgt1 %t.res.tgt1 77 // RUN: diff %t.tgt2 %t.res.tgt2 78 // 79 // LEVEL: Compression method used: zlib 80 // LEVEL: Compression level: 9 81 82 // 83 // Check -bundle-align option. 84 // 85 86 // 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 87 // 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 88 // RUN: diff %t.bc %t.res.bc 89 // RUN: diff %t.tgt1 %t.res.tgt1 90 // RUN: diff %t.tgt2 %t.res.tgt2 91 92 // 93 // Check unbundling archive. 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_bundle1.bc -compress 97 // RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ 98 // RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip_bundle2.bc -compress 99 // RUN: rm -f %t.hip_archive.a 100 // RUN: llvm-ar cr %t.hip_archive.a %t.hip_bundle1.bc %t.hip_bundle2.bc 101 // RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \ 102 // RUN: -output=%t.hip_900.a -output=%t.hip_906.a -input=%t.hip_archive.a 103 // RUN: llvm-ar t %t.hip_900.a | FileCheck -check-prefix=HIP-AR-900 %s 104 // RUN: llvm-ar t %t.hip_906.a | FileCheck -check-prefix=HIP-AR-906 %s 105 // HIP-AR-900-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx900 106 // HIP-AR-900-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx900 107 // HIP-AR-906-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx906 108 // HIP-AR-906-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx906 109 110 // Some code so that we can create a binary out of this file. 111 int A = 0; 112 void test_func(void) { 113 ++A; 114 } 115