brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.4 KiB · 211601c Raw
139 lines · c
1// REQUIRES: zlib && !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: 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 %s27// RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST %s28// 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 %s32// RUN: diff %t.tgt1 %t.res.tgt133// RUN: diff %t.tgt2 %t.res.tgt234 35//36// COMPRESS: Compression method used: zlib37// COMPRESS: Compression level: 638// DECOMPRESS: Decompression method: zlib39// DECOMPRESS: 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/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 %s51// RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST-V3 %s52// 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 %s56// RUN: diff %t.tgt1 %t.res.tgt157// RUN: diff %t.tgt2 %t.res.tgt258//59// COMPRESS-V3: Compressed bundle format version: 360// COMPRESS-V3: Compression method used: zlib61// COMPRESS-V3: Compression level: 662// DECOMPRESS-V3: Compressed bundle format version: 363// DECOMPRESS-V3: Decompression method: zlib64// DECOMPRESS-V3: Hashes match: Yes65// NOHOST-V3-NOT: host-66// NOHOST-V3-DAG: hip-amdgcn-amd-amdhsa--gfx90067// NOHOST-V3-DAG: hip-amdgcn-amd-amdhsa--gfx90668 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 %s75// RUN: clang-offload-bundler -type=bc -list -input=%t.hip.bundle.bc | FileCheck -check-prefix=NOHOST-V2 %s76// 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 %s80// RUN: diff %t.tgt1 %t.res.tgt181// RUN: diff %t.tgt2 %t.res.tgt282//83// COMPRESS-V2: Compressed bundle format version: 284// COMPRESS-V2: Compression method used: zlib85// COMPRESS-V2: Compression level: 686// DECOMPRESS-V2: Compressed bundle format version: 287// DECOMPRESS-V2: Decompression method: zlib88// DECOMPRESS-V2: Hashes match: Yes89// NOHOST-V2-NOT: host-90// NOHOST-V2-DAG: hip-amdgcn-amd-amdhsa--gfx90091// NOHOST-V2-DAG: hip-amdgcn-amd-amdhsa--gfx90692 93// Check -compression-level= option94 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 %s98// 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 -unbundle100// RUN: diff %t.tgt1 %t.res.tgt1101// RUN: diff %t.tgt2 %t.res.tgt2102//103// LEVEL: Compression method used: zlib104// LEVEL: Compression level: 9105 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 -compress111// 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 -unbundle112// RUN: diff %t.bc %t.res.bc113// RUN: diff %t.tgt1 %t.res.tgt1114// RUN: diff %t.tgt2 %t.res.tgt2115 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 -compress121// 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 -compress123// RUN: rm -f %t.hip_archive.a124// RUN: llvm-ar cr %t.hip_archive.a %t.hip_bundle1.bc %t.hip_bundle2.bc125// 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.a127// RUN: llvm-ar t %t.hip_900.a | FileCheck -check-prefix=HIP-AR-900 %s128// RUN: llvm-ar t %t.hip_906.a | FileCheck -check-prefix=HIP-AR-906 %s129// HIP-AR-900-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx900130// HIP-AR-900-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx900131// HIP-AR-906-DAG: hip_bundle1-hip-amdgcn-amd-amdhsa--gfx906132// HIP-AR-906-DAG: hip_bundle2-hip-amdgcn-amd-amdhsa--gfx906133 134// Some code so that we can create a binary out of this file.135int A = 0;136void test_func(void) {137  ++A;138}139