Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 3f29110

Browse files
committed
[SYCL] Add one more ESIMD regression test
1 parent 6bb47ee commit 3f29110

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <CL/sycl.hpp>
2+
#include <sycl/ext/intel/experimental/esimd.hpp>
3+
4+
static constexpr const int VL = 4;
5+
6+
sycl::event add(size_t n, sycl::buffer<double, 1> &buf_a,
7+
sycl::buffer<double, 1> &buf_b, sycl::buffer<double, 1> &buf_c,
8+
sycl::queue &Q) {
9+
auto E = Q.submit([&](sycl::handler &H) {
10+
sycl::accessor acc_a{buf_a, H, sycl::read_only};
11+
sycl::accessor acc_b{buf_b, H, sycl::read_only};
12+
sycl::accessor acc_c{buf_c, H, sycl::write_only};
13+
14+
H.parallel_for(n, [=](sycl::id<1> i) SYCL_ESIMD_KERNEL {
15+
using namespace sycl::ext::intel::experimental::esimd;
16+
unsigned int offset = i * VL * sizeof(float);
17+
simd<float, VL> va;
18+
va.copy_from(acc_a, offset);
19+
simd<float, VL> vb;
20+
vb.copy_from(acc_b, offset);
21+
simd<float, VL> vc = va + vb;
22+
vc.copy_to(acc_c, offset);
23+
});
24+
});
25+
return E;
26+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <CL/sycl.hpp>
2+
3+
sycl::event iota(size_t n, sycl::buffer<int, 1> &buf, sycl::queue &Q) {
4+
auto HK = [&](sycl::handler &H) {
5+
sycl::accessor acc_y{buf, H, sycl::write_only};
6+
auto K = [=](sycl::id<1> id) {
7+
int *y = acc_y.get_pointer();
8+
size_t i = id.get(0);
9+
y[i] = i;
10+
};
11+
H.parallel_for(n, K);
12+
};
13+
return Q.submit(HK);
14+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <CL/sycl.hpp>
2+
#include <cstdio>
3+
4+
sycl::event iota(size_t n, sycl::buffer<int, 1> &d, sycl::queue &Q);
5+
6+
const char *name = "with eSIMD";
7+
8+
int main(int argc, char *argv[]) {
9+
try {
10+
size_t i;
11+
size_t N = 1024;
12+
sycl::device D(sycl::default_selector{});
13+
sycl::context C(D);
14+
sycl::queue Q(C, D);
15+
16+
int *y = new int[N];
17+
{
18+
sycl::buffer<int, 1> buf_y(y, N);
19+
iota(N, buf_y, Q);
20+
}
21+
bool pass = true;
22+
for (i = 0; i < 10; ++i) {
23+
pass = pass && (y[i] == i);
24+
}
25+
delete[] y;
26+
fprintf(stdout, "%s: %s\n", argv[0], pass ? "PASS" : "FAIL");
27+
} catch (sycl::exception const &se) {
28+
fprintf(stderr, "%s failed with %s (%d)\n", argv[0], se.what(),
29+
se.code().value());
30+
31+
return 1;
32+
} catch (std::exception const &e) {
33+
fprintf(stderr, "failed with %s\n", e.what());
34+
return 2;
35+
} catch (...) {
36+
fprintf(stderr, "failed\n");
37+
return -1;
38+
}
39+
return 0;
40+
}
41+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// This test is intended to check a certain approach of compiling libraries and
2+
// application, when both regular SYCL and ESIMD are used.
3+
//
4+
// We used to have a bug, when under some circumstances compiler created empty
5+
// device images, but at the same time it stated that they contain some kernels.
6+
// More details can be found in intel/llvm#4927.
7+
//
8+
// REQUIRES: linux && (cpu || gpu)
9+
// UNSUPPORTED: cuda || hip
10+
//
11+
// RUN: %clangxx -fsycl -fPIC -O3 %S/Inputs/complex-lib-sycl.cpp -c -o %t-lib-sycl.o
12+
// RUN: %clangxx -fsycl -fPIC -O3 %S/Inputs/complex-lib-esimd.cpp -c -o %t-lib-esimd.o
13+
// RUN: %clangxx -fsycl -fPIC -O3 %S/Inputs/complex-lib-test.cpp -c -o %t-test.o
14+
//
15+
// RUN: ar crsv %t-lib-sycl.a %t-lib-sycl.o
16+
// RUN: ar crsv %t-lib-esimd.a %t-lib-esimd.o
17+
//
18+
// One shared library is built using static libraries
19+
//
20+
// RUN: %clangxx -fsycl -shared %t-lib-sycl.a %t-lib-esimd.a \
21+
// RUN: -fsycl-device-code-split=per_kernel -Wl,--whole-archive \
22+
// RUN: %t-lib-sycl.a %t-lib-esimd.a -Wl,--no-whole-archive -Wl,-soname,%S -o %t-lib-a.so
23+
//
24+
// And another one is constructed directly from object files
25+
//
26+
// RUN: %clangxx -fsycl -shared %t-lib-sycl.o %t-lib-esimd.o \
27+
// RUN: -fsycl-device-code-split=per_kernel -Wl,-soname,%S -o %t-lib-o.so
28+
//
29+
// RUN: %clangxx -fsycl %t-test.o %t-lib-a.so -o %t-a.run
30+
// RUN: %clangxx -fsycl %t-test.o %t-lib-o.so -o %t-o.run
31+
//
32+
// FIXME: is there better way to handle libraries loading than LD_PRELOAD?
33+
// RUN: %CPU_RUN_PLACEHOLDER LD_PRELOAD=%t-lib-a.so %t-a.run
34+
// RUN: %CPU_RUN_PLACEHOLDER LD_PRELOAD=%t-lib-o.so %t-o.run
35+
// RUN: %GPU_RUN_PLACEHOLDER LD_PRELOAD=%t-lib-a.so %t-a.run
36+
// RUN: %GPU_RUN_PLACEHOLDER LD_PRELOAD=%t-lib-o.so %t-o.run

0 commit comments

Comments
 (0)