Skip to content

Commit f33f8b2

Browse files
Merge intel/llvm-test-suite in-tree
2 parents 5569b32 + b0bdf35 commit f33f8b2

File tree

1,467 files changed

+930585
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,467 files changed

+930585
-3
lines changed

sycl/test-e2e/.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BasedOnStyle: LLVM
2+
CommentPragmas: "(RUN|FAIL|REQUIRES|UNSUPPORTED|CHECK[A-Za-z0-9_-]*) *:|expected-"

sycl/test-e2e/AOT/Inputs/aot.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//==--- aot.cpp - Simple vector addition (AOT compilation example) --------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===---------------------------------------------------------------------===//
8+
9+
#include <sycl/sycl.hpp>
10+
11+
#include <array>
12+
#include <iostream>
13+
14+
constexpr sycl::access::mode sycl_read = sycl::access::mode::read;
15+
constexpr sycl::access::mode sycl_write = sycl::access::mode::write;
16+
17+
template <typename T> class SimpleVadd;
18+
19+
template <typename T, size_t N>
20+
void simple_vadd(const std::array<T, N> &VA, const std::array<T, N> &VB,
21+
std::array<T, N> &VC) {
22+
sycl::queue deviceQueue([](sycl::exception_list ExceptionList) {
23+
for (std::exception_ptr ExceptionPtr : ExceptionList) {
24+
try {
25+
std::rethrow_exception(ExceptionPtr);
26+
} catch (sycl::exception &E) {
27+
std::cerr << E.what();
28+
} catch (...) {
29+
std::cerr << "Unknown async exception was caught." << std::endl;
30+
}
31+
}
32+
});
33+
34+
sycl::range<1> numOfItems{N};
35+
sycl::buffer<T, 1> bufferA(VA.data(), numOfItems);
36+
sycl::buffer<T, 1> bufferB(VB.data(), numOfItems);
37+
sycl::buffer<T, 1> bufferC(VC.data(), numOfItems);
38+
39+
deviceQueue.submit([&](sycl::handler &cgh) {
40+
auto accessorA = bufferA.template get_access<sycl_read>(cgh);
41+
auto accessorB = bufferB.template get_access<sycl_read>(cgh);
42+
auto accessorC = bufferC.template get_access<sycl_write>(cgh);
43+
44+
cgh.parallel_for<class SimpleVadd<T>>(numOfItems, [=](sycl::id<1> wiID) {
45+
accessorC[wiID] = accessorA[wiID] + accessorB[wiID];
46+
});
47+
});
48+
49+
deviceQueue.wait_and_throw();
50+
}
51+
52+
int main() {
53+
const size_t array_size = 4;
54+
std::array<int, array_size> A = {{1, 2, 3, 4}}, B = {{1, 2, 3, 4}}, C;
55+
std::array<float, array_size> D = {{1.f, 2.f, 3.f, 4.f}},
56+
E = {{1.f, 2.f, 3.f, 4.f}}, F;
57+
simple_vadd(A, B, C);
58+
simple_vadd(D, E, F);
59+
for (unsigned int i = 0; i < array_size; i++) {
60+
if (C[i] != A[i] + B[i]) {
61+
std::cout << "The results are incorrect (element " << i << " is " << C[i]
62+
<< "!\n";
63+
return 1;
64+
}
65+
if (F[i] != D[i] + E[i]) {
66+
std::cout << "The results are incorrect (element " << i << " is " << F[i]
67+
<< "!\n";
68+
return 1;
69+
}
70+
}
71+
std::cout << "The results are correct!\n";
72+
return 0;
73+
}

sycl/test-e2e/AOT/accelerator.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//=-- accelerator.cpp - compilation for fpga emulator dev using opencl-aot --=//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===---------------------------------------------------------------------===//
8+
9+
// REQUIRES: opencl-aot, accelerator
10+
11+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_fpga %S/Inputs/aot.cpp -o %t.out
12+
// RUN: %ACC_RUN_PLACEHOLDER %t.out

sycl/test-e2e/AOT/cpu.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//==--- cpu.cpp - AOT compilation for cpu devices using opencl-aot --------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===---------------------------------------------------------------------===//
8+
9+
// REQUIRES: opencl-aot, cpu
10+
11+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64 %S/Inputs/aot.cpp -o %t.out
12+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
13+
14+
// Test that opencl-aot can handle multiple build options.
15+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64 %S/Inputs/aot.cpp -Xsycl-target-backend "--bo=-g" -Xsycl-target-backend "--bo=-cl-opt-disable" -o %t2.out

sycl/test-e2e/AOT/gpu.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//==--- gpu.cpp - AOT compilation for gen devices using GEN compiler ------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===---------------------------------------------------------------------===//
8+
9+
// REQUIRES: ocloc, gpu
10+
// UNSUPPORTED: cuda
11+
// CUDA is not compatible with SPIR.
12+
//
13+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %S/Inputs/aot.cpp -o %t.out
14+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//==-- multiple-devices.cpp - Appropriate AOT-compiled image selection -----==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// REQUIRES: opencl-aot, ocloc, cpu, gpu, accelerator
10+
// UNSUPPORTED: cuda
11+
// CUDA is not compatible with SPIR.
12+
13+
// Produce a fat object for all targets (generic SPIR-V, CPU, GPU, FPGA)
14+
// RUN: %clangxx -fsycl -fsycl-targets=spir64,spir64_x86_64,spir64_gen,spir64_fpga %S/Inputs/aot.cpp -c -o %t.o
15+
16+
// CPU, GPU, FPGA
17+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64,spir64_gen,spir64_fpga -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %t.o -o %t_all_aot.out
18+
// RUN: %CPU_RUN_PLACEHOLDER %t_all_aot.out
19+
// RUN: %GPU_RUN_PLACEHOLDER %t_all_aot.out
20+
// RUN: %ACC_RUN_PLACEHOLDER %t_all_aot.out
21+
22+
// CPU, GPU
23+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %t.o -o %t_cpu_gpu.out
24+
// RUN: %CPU_RUN_PLACEHOLDER %t_cpu_gpu.out
25+
// RUN: %GPU_RUN_PLACEHOLDER %t_cpu_gpu.out
26+
27+
// CPU, FPGA
28+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64,spir64_fpga %t.o -o %t_cpu_fpga.out
29+
// RUN: %CPU_RUN_PLACEHOLDER %t_cpu_fpga.out
30+
// RUN: %ACC_RUN_PLACEHOLDER %t_cpu_fpga.out
31+
32+
// GPU, FPGA
33+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen,spir64_fpga -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %t.o -o %t_gpu_fpga.out
34+
// RUN: %GPU_RUN_PLACEHOLDER %t_gpu_fpga.out
35+
// RUN: %ACC_RUN_PLACEHOLDER %t_gpu_fpga.out
36+
37+
// No AOT-compiled image for CPU
38+
// RUN: %clangxx -fsycl -fsycl-targets=spir64,spir64_gen,spir64_fpga -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %t.o -o %t_spv_gpu_fpga.out
39+
// RUN: %CPU_RUN_PLACEHOLDER %t_spv_gpu_fpga.out
40+
// Check that execution on AOT-compatible devices is unaffected
41+
// RUN: %GPU_RUN_PLACEHOLDER %t_spv_gpu_fpga.out
42+
// RUN: %ACC_RUN_PLACEHOLDER %t_spv_gpu_fpga.out
43+
44+
// No AOT-compiled image for GPU
45+
// RUN: %clangxx -fsycl -fsycl-targets=spir64,spir64_x86_64,spir64_fpga %t.o -o %t_spv_cpu_fpga.out
46+
// RUN: %GPU_RUN_PLACEHOLDER %t_spv_cpu_fpga.out
47+
// Check that execution on AOT-compatible devices is unaffected
48+
// RUN: %CPU_RUN_PLACEHOLDER %t_spv_cpu_fpga.out
49+
// RUN: %ACC_RUN_PLACEHOLDER %t_spv_cpu_fpga.out
50+
51+
// No AOT-compiled image for FPGA
52+
// RUN: %clangxx -fsycl -fsycl-targets=spir64,spir64_x86_64,spir64_gen -Xsycl-target-backend=spir64_gen %gpu_aot_target_opts %t.o -o %t_spv_cpu_gpu.out
53+
// RUN: %ACC_RUN_PLACEHOLDER %t_spv_cpu_gpu.out
54+
// Check that execution on AOT-compatible devices is unaffected
55+
// RUN: %CPU_RUN_PLACEHOLDER %t_spv_cpu_gpu.out
56+
// RUN: %GPU_RUN_PLACEHOLDER %t_spv_cpu_gpu.out

sycl/test-e2e/AOT/with-llvm-bc.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//==----- with-llvm-bc.cpp - SYCL kernel with LLVM IR bitcode as binary ----==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// REQUIRES: cpu, dump_ir
10+
11+
// RUN: %clangxx -fsycl -fsycl-targets=spir64 -c %S/Inputs/aot.cpp -o %t.o
12+
// RUN: %clangxx -fsycl -fsycl-link-targets=spir64 %t.o -o %t.spv
13+
// RUN: llvm-spirv -r %t.spv -o %t.bc
14+
// RUN: %clangxx -fsycl -fsycl-add-targets=spir64:%t.bc %t.o -o %t.out
15+
//
16+
// Only CPU supports LLVM IR bitcode as a binary
17+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "kernels_in_file2.hpp"
2+
3+
#ifdef DEFINE_NDEBUG_INFILE2
4+
#define NDEBUG
5+
#else
6+
#undef NDEBUG
7+
#endif
8+
9+
#include <cassert>
10+
11+
using namespace sycl;
12+
using namespace sycl::access;
13+
14+
int calculus(int X) {
15+
assert(X && "this message from calculus");
16+
return X * 2;
17+
}
18+
19+
void check_nil(int value) { assert(value && "this message from file2"); }
20+
21+
static constexpr size_t BUFFER_SIZE = 4;
22+
23+
void enqueueKernel_1_fromFile2(queue *Q) {
24+
sycl::range<1> numOfItems{BUFFER_SIZE};
25+
sycl::buffer<int, 1> Buf(numOfItems);
26+
27+
Q->submit([&](handler &CGH) {
28+
auto Acc = Buf.template get_access<mode::read_write>(CGH);
29+
30+
CGH.parallel_for<class kernel1_from_separate_file>(
31+
numOfItems, [=](sycl::id<1> wiID) { check_nil(Acc[wiID]); });
32+
});
33+
}
34+
35+
void enqueueKernel_2_fromFile2(queue *Q) {
36+
sycl::range<1> numOfItems{BUFFER_SIZE};
37+
sycl::buffer<int, 1> Buf(numOfItems);
38+
39+
Q->submit([&](handler &CGH) {
40+
auto Acc = Buf.template get_access<mode::read_write>(CGH);
41+
42+
CGH.parallel_for<class kernel2_from_separate_file>(
43+
numOfItems, [=](sycl::id<1> wiID) { check_nil(Acc[wiID]); });
44+
});
45+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <sycl/sycl.hpp>
2+
3+
SYCL_EXTERNAL int calculus(int X);
4+
5+
void enqueueKernel_1_fromFile2(sycl::queue *Q);
6+
7+
void enqueueKernel_2_fromFile2(sycl::queue *Q);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// REQUIRES: linux
2+
3+
// https://github.com/intel/llvm/issues/7634
4+
// UNSUPPORTED: hip
5+
6+
// RUN: %clangxx -DSYCL_FALLBACK_ASSERT=1 -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
7+
// RUN: %CPU_RUN_PLACEHOLDER %t.out &> %t.cpu.txt || true
8+
// RUN: %CPU_RUN_PLACEHOLDER FileCheck %s --input-file %t.cpu.txt
9+
// RUN: %GPU_RUN_PLACEHOLDER %t.out &> %t.gpu.txt || true
10+
// RUN: %GPU_RUN_PLACEHOLDER FileCheck %s --input-file %t.gpu.txt
11+
// Shouldn't fail on ACC as fallback assert isn't enqueued there
12+
// RUN: %ACC_RUN_PLACEHOLDER %t.out &> %t.acc.txt
13+
// RUN: %ACC_RUN_PLACEHOLDER FileCheck %s --check-prefix=CHECK-ACC --input-file %t.acc.txt
14+
//
15+
// CHECK-NOT: One shouldn't see this message
16+
// CHECK: {{.*}}assert_in_kernels.hpp:25: void kernelFunc2(int *, int): {{.*}} [{{[0,2]}},0,0], {{.*}} [0,0,0]
17+
// CHECK-SAME: Assertion `Buf[wiID] == 0 && "from assert statement"` failed.
18+
// CHECK-NOT: test aborts earlier, one shouldn't see this message
19+
// CHECK-NOT: The test ended.
20+
//
21+
// CHECK-ACC-NOT: {{.*}}assert_in_kernels.hpp:25: void kernelFunc2(int *, int): {{.*}} [{{[0,2]}},0,0], {{.*}} [0,0,0]
22+
// CHECK-ACC: The test ended.
23+
24+
#include "assert_in_kernels.hpp"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <cassert>
2+
#include <iostream>
3+
#include <sycl/sycl.hpp>
4+
5+
using namespace sycl;
6+
using namespace sycl::access;
7+
8+
void kernelFunc1(int *Buf, int wiID) {
9+
Buf[wiID] = 9;
10+
assert(Buf[wiID] != 0 && "One shouldn't see this message");
11+
}
12+
13+
void assertTest1(queue &Q, buffer<int, 1> &Buf) {
14+
Q.submit([&](handler &CGH) {
15+
auto Acc = Buf.template get_access<mode::read_write>(CGH);
16+
17+
CGH.parallel_for<class Kernel_1>(
18+
Buf.get_range(), [=](sycl::id<1> wiID) { kernelFunc1(&Acc[0], wiID); });
19+
});
20+
}
21+
22+
void kernelFunc2(int *Buf, int wiID) {
23+
if (wiID % 2 != 0)
24+
Buf[wiID] = 0;
25+
assert(Buf[wiID] == 0 && "from assert statement");
26+
}
27+
28+
void assertTest2(queue &Q, buffer<int, 1> &Buf) {
29+
Q.submit([&](handler &CGH) {
30+
auto Acc = Buf.template get_access<mode::read_write>(CGH);
31+
32+
CGH.parallel_for<class Kernel_2>(
33+
Buf.get_range(), [=](sycl::id<1> wiID) { kernelFunc2(&Acc[0], wiID); });
34+
});
35+
}
36+
37+
void kernelFunc3(int *Buf, int wiID) {
38+
if (wiID == 0)
39+
assert(false && "test aborts earlier, one shouldn't see this message");
40+
Buf[wiID] = 9;
41+
}
42+
43+
void assertTest3(queue &Q, buffer<int, 1> &Buf) {
44+
Q.submit([&](handler &CGH) {
45+
auto Acc = Buf.template get_access<mode::read_write>(CGH);
46+
47+
CGH.parallel_for<class Kernel_3>(
48+
Buf.get_range(), [=](sycl::id<1> wiID) { kernelFunc3(&Acc[0], wiID); });
49+
});
50+
}
51+
52+
int main(int Argc, const char *Argv[]) {
53+
std::array<int, 4> Vec = {1, 2, 3, 4};
54+
sycl::range<1> numOfItems{Vec.size()};
55+
sycl::buffer<int, 1> Buf(Vec.data(), numOfItems);
56+
57+
queue Q;
58+
assertTest1(Q, Buf);
59+
Q.wait();
60+
61+
assertTest2(Q, Buf);
62+
Q.wait();
63+
64+
assertTest3(Q, Buf);
65+
Q.wait();
66+
67+
std::cout << "The test ended." << std::endl;
68+
return 0;
69+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -DNDEBUG %S/assert_in_kernels.cpp -o %t.out
2+
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
3+
// RUN: %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER
4+
// RUN: %ACC_RUN_PLACEHOLDER %t.out %ACC_CHECK_PLACEHOLDER
5+
//
6+
// CHECK-NOT: One shouldn't see this message
7+
// CHECK-NOT: from assert statement
8+
// CHECK-NOT: test aborts earlier, one shouldn't see this message
9+
// CHECK: The test ended.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// REQUIRES: windows
2+
// RUN: %clangxx -DSYCL_FALLBACK_ASSERT=1 -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
3+
// RUN: %CPU_RUN_PLACEHOLDER %t.out &> %t.txt || true
4+
// RUN: %CPU_RUN_PLACEHOLDER FileCheck %s --input-file %t.txt
5+
// RUN: %GPU_RUN_PLACEHOLDER %t.out &> %t.txt || true
6+
// RUN: %GPU_RUN_PLACEHOLDER FileCheck %s --input-file %t.txt
7+
// Shouldn't fail on ACC as fallback assert isn't enqueued there
8+
// RUN: %ACC_RUN_PLACEHOLDER %t.out &> %t.txt
9+
// RUN: %ACC_RUN_PLACEHOLDER FileCheck %s --check-prefix=CHECK-ACC --input-file %t.txt
10+
//
11+
// CHECK-NOT: One shouldn't see this message
12+
// FIXME Windows version prints '(null)' instead of '<unknown func>' once in a
13+
// while for some insane reason.
14+
// CHECK: {{.*}}assert_in_kernels.hpp:25: {{<unknown func>|(null)}}: {{.*}} [{{[0,2]}},0,0], {{.*}} [0,0,0]
15+
// CHECK-SAME: Assertion `Buf[wiID] == 0 && "from assert statement"` failed.
16+
// CHECK-NOT: test aborts earlier, one shouldn't see this message
17+
// CHECK-NOT: The test ended.
18+
//
19+
// CHECK-ACC-NOT: {{.*}}assert_in_kernels.hpp:25: {{<unknown func>|(null)}}: {{.*}} [{{[0,2]}},0,0], {{.*}} [0,0,0]
20+
// CHECK-ACC: The test ended.
21+
22+
#include "assert_in_kernels.hpp"

0 commit comments

Comments
 (0)