90 lines · c
1// REQUIRES: zstd2// 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.bc8 9//10// Generate an empty file to help with the checks of empty files.11//12// RUN: touch %t.empty13 14//15// Generate device binaries to be bundled.16//17// RUN: echo 'Content of device file 1' > %t.tgt118// RUN: echo 'Content of device file 2' > %t.tgt219 20//21// Check compression/decompression of offload bundle.22//23// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \24// RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc -compress -verbose >%t.1.txt 2>&125// RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST %s26// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \27// RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle -verbose >%t.2.txt 2>&128// RUN: cat %t.1.txt %t.2.txt | FileCheck %s29// RUN: diff %t.tgt1 %t.res.tgt130// RUN: diff %t.tgt2 %t.res.tgt231//32// CHECK: Compressed bundle format version: 333// CHECK: Total file size (including headers): [[SIZE:[0-9]*]] bytes34// CHECK: Compression method used: zstd35// CHECK: Compression level: 336// CHECK: Compressed bundle format version: 337// CHECK: Total file size (from header): [[SIZE]] bytes38// CHECK: Decompression method: zstd39// CHECK: Hashes match: Yes40// NOHOST-NOT: host-41// NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx90042// NOHOST-DAG: hip-amdgcn-amd-amdhsa--gfx90643//44 45// Check -compression-level= option46 47// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \48// RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip.bundle.bc -compress -verbose -compression-level=9 2>&1 | \49// RUN: FileCheck -check-prefix=LEVEL %s50// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \51// RUN: -output=%t.res.tgt1 -output=%t.res.tgt2 -input=%t.hip.bundle.bc -unbundle52// RUN: diff %t.tgt1 %t.res.tgt153// RUN: diff %t.tgt2 %t.res.tgt254//55// LEVEL: Compression method used: zstd56// LEVEL: Compression level: 957 58//59// Check -bundle-align option.60//61 62// 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 -compress63// 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 -unbundle64// RUN: diff %t.bc %t.res.bc65// RUN: diff %t.tgt1 %t.res.tgt166// RUN: diff %t.tgt2 %t.res.tgt267 68// Check unbundling archive.69//70// RUN: clang-offload-bundler -type=bc -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \71// RUN: -input=%t.tgt1 -input=%t.tgt2 -output=%t.hip_bundle1.bc -compress72// 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_bundle2.bc -compress74// RUN: rm -f %t.hip_archive.a75// RUN: llvm-ar cr %t.hip_archive.a %t.hip_bundle1.bc %t.hip_bundle2.bc76// RUN: clang-offload-bundler -unbundle -type=a -targets=hip-amdgcn-amd-amdhsa--gfx900,hip-amdgcn-amd-amdhsa--gfx906 \77// RUN: -output=%t.hip_900.a -output=%t.hip_906.a -input=%t.hip_archive.a78// RUN: llvm-ar t %t.hip_900.a | FileCheck -check-prefix=HIP-AR-900 %s79// RUN: llvm-ar t %t.hip_906.a | FileCheck -check-prefix=HIP-AR-906 %s80// HIP-AR-900-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx90081// HIP-AR-900-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx90082// HIP-AR-906-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx90683// HIP-AR-906-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx90684 85// Some code so that we can create a binary out of this file.86int A = 0;87void test_func(void) {88 ++A;89}90