Skip to content

Commit

Permalink
[NFC][SYCL] Update tests to reflect new offload model (intel#14539)
Browse files Browse the repository at this point in the history
Update existing SYCL based driver tests to use the new offload model and
retain the equivalent old offloading model tests be creating copies.
These tests use the --offload-new-driver and --no-offload-new-driver
options to force a particular model to follow.
  • Loading branch information
mdtoguchi authored and smanna12 committed Jul 16, 2024
1 parent 94a10a6 commit 5401bac
Show file tree
Hide file tree
Showing 56 changed files with 3,377 additions and 1,771 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,104 +10,104 @@
// In all these tests also ensure functionality with bundled object files still
// works correctly.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Make bundled object with targets:
// sycl-spir64-unknown-unknown
// host-x86_64-unknown-linux-gnu
// RUN: %clangxx -fsycl -c %s -o %t_bundled.o

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Make three distinct BC files
// RUN: %clangxx -fsycl -fsycl-device-only -DTYPE1 %s -o %t1.bc
// RUN: %clangxx -fsycl -fsycl-device-only -DTYPE2 %s -o %t2.bc
// RUN: %clangxx -fsycl -fsycl-device-only -DTYPE3 %s -o %t3.bc

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Bundle BC files to different targets:
// host-spir64-unknown-unknown
// host-spir64_gen
// host-spir64_x86_64
// RUN: clang-offload-bundler -type=bc -targets=host-spir64-unknown-unknown -input=%t1.bc -output=%t1_bundled.bc
// RUN: clang-offload-bundler -type=bc -targets=host-spir64_gen -input=%t2.bc -output=%t2_bundled.bc
// RUN: clang-offload-bundler -type=bc -targets=host-spir64_x86_64 -input=%t3.bc -output=%t3_bundled.bc

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Make archive with bundled BC and o files
// RUN: rm -f %t_bundled.a
// RUN: llvm-ar cr %t_bundled.a %t1_bundled.bc %t2_bundled.bc %t3_bundled.bc %t_bundled.o

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Make bundled object with targets:
// sycl-spir64-unknown-unknown
// host-x86_64-unknown-linux-gnu
// RUN: %clangxx -fsycl --no-offload-new-driver -c %s -o %t_bundled.o

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Make three distinct BC files
// RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-device-only -DTYPE1 %s -o %t1.bc
// RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-device-only -DTYPE2 %s -o %t2.bc
// RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-device-only -DTYPE3 %s -o %t3.bc

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Bundle BC files to different targets:
// host-spir64-unknown-unknown
// host-spir64_gen
// host-spir64_x86_64
// RUN: clang-offload-bundler -type=bc -targets=host-spir64-unknown-unknown -input=%t1.bc -output=%t1_bundled.bc
// RUN: clang-offload-bundler -type=bc -targets=host-spir64_gen -input=%t2.bc -output=%t2_bundled.bc
// RUN: clang-offload-bundler -type=bc -targets=host-spir64_x86_64 -input=%t3.bc -output=%t3_bundled.bc

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Make archive with bundled BC and o files
// RUN: rm -f %t_bundled.a
// RUN: llvm-ar cr %t_bundled.a %t1_bundled.bc %t2_bundled.bc %t3_bundled.bc %t_bundled.o

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TEST1
// Check that -list with various archive types can find all targets
// RUN: clang-offload-bundler -list -type=ao -input=%t_bundled.a > %t_list_ao.txt
// RUN: clang-offload-bundler -list -type=aoo -input=%t_bundled.a > %t_list_aoo.txt
// RUN: FileCheck --check-prefixes=CHECK-LIST < %t_list_ao.txt %s
// RUN: FileCheck --check-prefixes=CHECK-LIST < %t_list_aoo.txt %s

// CHECK-LIST-DAG: sycl-spir64-unknown-unknown
// CHECK-LIST-DAG: host-x86_64-unknown-linux-gnu
// CHECK-LIST-DAG: host-spir64-unknown-unknown
// CHECK-LIST-DAG: host-spir64_gen
// CHECK-LIST-DAG: host-spir64_x86_64

// RUN: wc -l %t_list_ao.txt | FileCheck --check-prefixes=CHECK-LIST-LENGTH %s
// RUN: wc -l %t_list_aoo.txt | FileCheck --check-prefixes=CHECK-LIST-LENGTH %s

// CHECK-LIST-LENGTH: 5

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Check that -list with various archive types can find all targets
// RUN: clang-offload-bundler -list -type=ao -input=%t_bundled.a > %t_list_ao.txt
// RUN: clang-offload-bundler -list -type=aoo -input=%t_bundled.a > %t_list_aoo.txt
// RUN: FileCheck --check-prefixes=CHECK-LIST < %t_list_ao.txt %s
// RUN: FileCheck --check-prefixes=CHECK-LIST < %t_list_aoo.txt %s

// CHECK-LIST-DAG: sycl-spir64-unknown-unknown
// CHECK-LIST-DAG: host-x86_64-unknown-linux-gnu
// CHECK-LIST-DAG: host-spir64-unknown-unknown
// CHECK-LIST-DAG: host-spir64_gen
// CHECK-LIST-DAG: host-spir64_x86_64

// RUN: wc -l %t_list_ao.txt | FileCheck --check-prefixes=CHECK-LIST-LENGTH %s
// RUN: wc -l %t_list_aoo.txt | FileCheck --check-prefixes=CHECK-LIST-LENGTH %s

// CHECK-LIST-LENGTH: 5

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TEST2
// Test -check-section
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64-unknown-unknown
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_gen
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_x86_64
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown-a
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu-b
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64-unknown-unknown-c
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_gen-d
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_x86_64-e
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64-unknown-unknown
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_gen
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_x86_64
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown-a
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu-b
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64-unknown-unknown-c
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_gen-d
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_x86_64-e

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Unbundle object file to use as a reference result
// RUN: clang-offload-bundler -unbundle -type=o -input=%t_bundled.o -targets=sycl-spir64-unknown-unknown -output=%t_unbundled_A.o
// RUN: clang-offload-bundler -unbundle -type=o -input=%t_bundled.o -targets=host-x86_64-unknown-linux-gnu -output=%t_unbundled_B.o

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Test -check-section
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64-unknown-unknown
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_gen
// RUN: clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_x86_64
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown-a
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu-b
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64-unknown-unknown-c
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_gen-d
// RUN: not clang-offload-bundler -check-section -type=ao -input=%t_bundled.a -targets=host-spir64_x86_64-e
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64-unknown-unknown
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_gen
// RUN: clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_x86_64
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown-a
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu-b
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64-unknown-unknown-c
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_gen-d
// RUN: not clang-offload-bundler -check-section -type=aoo -input=%t_bundled.a -targets=host-spir64_x86_64-e

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Unbundle object file to use as a reference result
// RUN: clang-offload-bundler -unbundle -type=o -input=%t_bundled.o -targets=sycl-spir64-unknown-unknown -output=%t_unbundled_A.o
// RUN: clang-offload-bundler -unbundle -type=o -input=%t_bundled.o -targets=host-x86_64-unknown-linux-gnu -output=%t_unbundled_B.o

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TEST3
// Test archive unbundling
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown -output=%t_list1.txt
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu -output=%t_list2.txt
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-spir64-unknown-unknown -output=%t_list3.txt
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-spir64_gen -output=%t_list4.txt
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-spir64_x86_64 -output=%t_list5.txt

// RUN: cmp %t_unbundled_A.o `cat %t_list1.txt`
// RUN: cmp %t_unbundled_B.o `cat %t_list2.txt`
// RUN: cmp %t1.bc `cat %t_list3.txt`
// RUN: cmp %t2.bc `cat %t_list4.txt`
// RUN: cmp %t3.bc `cat %t_list5.txt`

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Test archive unbundling
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown -output=%t_list1.txt
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-x86_64-unknown-linux-gnu -output=%t_list2.txt
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-spir64-unknown-unknown -output=%t_list3.txt
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-spir64_gen -output=%t_list4.txt
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=host-spir64_x86_64 -output=%t_list5.txt

// RUN: cmp %t_unbundled_A.o `cat %t_list1.txt`
// RUN: cmp %t_unbundled_B.o `cat %t_list2.txt`
// RUN: cmp %t1.bc `cat %t_list3.txt`
// RUN: cmp %t2.bc `cat %t_list4.txt`
// RUN: cmp %t3.bc `cat %t_list5.txt`

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TEST4
// Test archive unbundling for multiple targets
// Test archive unbundling for multiple targets
// RUN: clang-offload-bundler -unbundle -type=aoo -input=%t_bundled.a -targets=sycl-spir64-unknown-unknown,host-spir64_gen -output=%t_listA.txt -output=%t_listB.txt

// RUN: cmp %t_unbundled_A.o `cat %t_listA.txt`
// RUN: cmp %t2.bc `cat %t_listB.txt`
// RUN: cmp %t_unbundled_A.o `cat %t_listA.txt`
// RUN: cmp %t2.bc `cat %t_listB.txt`

#include <sycl/sycl.hpp>
#include <sycl/sycl.hpp>

SYCL_EXTERNAL int foo(int x) {

Expand Down
Loading

0 comments on commit 5401bac

Please sign in to comment.