================
@@ -0,0 +1,169 @@
+// Check what a -fno-gpu-rdc object carries and when it is registered: build a
+// two translation unit program, check that each object holds its own finalized
+// device binary, then link and run the program to verify that both binaries
+// reach the SYCL runtime.
+// The second translation unit is this same source compiled with -DSECOND_TU.
+// The program provides its own __sycl_register_lib/__sycl_unregister_lib, so
+// -nolibsycl is used and no SYCL runtime or offload device is needed.
+
+// REQUIRES: spirv-registered-target, system-linux, native
+
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clangxx -fsycl -fno-gpu-rdc -c %s -o %t/main.o
+// RUN: %clangxx -fsycl -fno-gpu-rdc -DSECOND_TU -c %s -o %t/second.o
+
+// The section holds an offload binary (magic 0x10FF10AD) whose image is a
+// finalized SPIR-V module (magic 0x07230203), both shown little endian by the
+// hex dump.
+// RUN: llvm-readelf --hex-dump=.sycl_fatbin %t/main.o | FileCheck %s \
+// RUN:   --check-prefix=BINARY
+// RUN: llvm-readelf --hex-dump=.sycl_fatbin %t/second.o | FileCheck %s \
+// RUN:   --check-prefix=BINARY
+// BINARY: 10ff10ad
+// BINARY: 03022307
+
+// Each binary offers the kernels of that translation unit.
+// RUN: llvm-objcopy --dump-section=.sycl_fatbin=%t/main.bin %t/main.o 
/dev/null
+// RUN: llvm-objcopy --dump-section=.sycl_fatbin=%t/second.bin %t/second.o 
/dev/null
+// RUN: FileCheck %s --check-prefix=MAIN-BINARY --input-file=%t/main.bin
+// RUN: FileCheck %s --check-prefix=SECOND-BINARY --input-file=%t/second.bin
+// MAIN-BINARY-DAG: main_tu_kernel_name
+// MAIN-BINARY-DAG: main_tu_other_kernel_name
+// SECOND-BINARY-DAG: second_tu_kernel_name
+
+// The finalized binary holds one entry.
+// RUN: llvm-objdump --offloading %t/main.bin | FileCheck %s \
+// RUN:   --check-prefix=MAIN-ENTRIES
+// MAIN-ENTRIES:      OFFLOADING IMAGE [0]:
+// MAIN-ENTRIES:      kind{{ *}}spir-v
+// MAIN-ENTRIES:      arch{{ *$}}
+// MAIN-ENTRIES-NOT:  OFFLOADING IMAGE
+
+// Splitting a translation unit by kernel gives it an image
+// per kernel, but they are merged into a single offload binary.
+// RUN: %clangxx -fsycl -fno-gpu-rdc -fsycl-device-image-split=kernel -c %s \
+// RUN:   -o %t/main.split.o
+// RUN: llvm-objcopy --dump-section=.sycl_fatbin=%t/main.split.bin \
+// RUN:   %t/main.split.o /dev/null
+// RUN: llvm-objdump --offloading %t/main.split.bin | FileCheck %s \
+// RUN:   --check-prefix=SPLIT-ENTRIES
+// SPLIT-ENTRIES:      OFFLOADING IMAGE [0]:
+// SPLIT-ENTRIES:      OFFLOADING IMAGE [1]:
+// SPLIT-ENTRIES-NOT:  OFFLOADING IMAGE
+
+// Between them the two images still offer both kernels of the translation 
unit,
+// and the split program links and runs as the unsplit one did.
+// RUN: FileCheck %s --check-prefix=MAIN-BINARY --input-file=%t/main.split.bin
+// RUN: %clangxx -fsycl -nolibsycl %t/main.split.o %t/second.o -o 
%t/nordc-split
+// RUN: %t/nordc-split | FileCheck %s --check-prefix=NORDC-OUT
----------------
YuriPlyakhin wrote:

fbe8f926f72fcab3b8de0d6f7d1aa8a090b2fbc3

https://github.com/llvm/llvm-project/pull/218089
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to