This repository was archived by the owner on Mar 28, 2023. It is now read-only.
forked from llvm/llvm-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 130
[SYCL] Add one more ESIMD regression test #568
Merged
vladimirlaz
merged 4 commits into
intel:intel
from
AlexeySachkov:private/asachkov/add-regression-test
Dec 2, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <CL/sycl.hpp> | ||
#include <sycl/ext/intel/experimental/esimd.hpp> | ||
|
||
static constexpr const int VL = 4; | ||
|
||
sycl::event add(size_t n, sycl::buffer<int, 1> &buf_a, | ||
sycl::buffer<int, 1> &buf_b, sycl::buffer<int, 1> &buf_c, | ||
sycl::queue &Q) { | ||
auto E = Q.submit([&](sycl::handler &H) { | ||
sycl::accessor acc_a{buf_a, H, sycl::read_only}; | ||
sycl::accessor acc_b{buf_b, H, sycl::read_only}; | ||
sycl::accessor acc_c{buf_c, H, sycl::write_only}; | ||
|
||
H.parallel_for(n, [=](sycl::id<1> i) SYCL_ESIMD_KERNEL { | ||
using namespace sycl::ext::intel::experimental::esimd; | ||
unsigned int offset = i * VL * sizeof(int); | ||
simd<int, VL> va(acc_a, offset); | ||
simd<int, VL> vb(acc_b, offset); | ||
simd<int, VL> vc = va + vb; | ||
vc.copy_to(acc_c, offset); | ||
}); | ||
}); | ||
return E; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <CL/sycl.hpp> | ||
|
||
sycl::event iota(size_t n, sycl::buffer<int, 1> &buf, sycl::queue &Q) { | ||
auto HK = [&](sycl::handler &H) { | ||
sycl::accessor acc_y{buf, H, sycl::write_only}; | ||
auto K = [=](sycl::id<1> id) { | ||
int *y = acc_y.get_pointer(); | ||
size_t i = id.get(0); | ||
y[i] = static_cast<int>(i); | ||
}; | ||
H.parallel_for(n, K); | ||
}; | ||
return Q.submit(HK); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <CL/sycl.hpp> | ||
#include <cstdio> | ||
|
||
sycl::event iota(size_t n, sycl::buffer<int, 1> &d, sycl::queue &Q); | ||
sycl::event add(size_t n, sycl::buffer<int, 1> &buf_a, | ||
sycl::buffer<int, 1> &buf_b, sycl::buffer<int, 1> &buf_c, | ||
sycl::queue &Q); | ||
|
||
int main(int argc, char *argv[]) { | ||
try { | ||
size_t i; | ||
size_t N = 1024; | ||
sycl::device D(sycl::default_selector{}); | ||
sycl::context Ctx(D); | ||
sycl::queue Q(Ctx, D); | ||
|
||
std::vector<int> A(N), B(N), C(N); | ||
{ | ||
sycl::buffer<int, 1> buf_A(A.data(), N); | ||
sycl::buffer<int, 1> buf_B(B.data(), N); | ||
iota(N, buf_A, Q); | ||
iota(N, buf_B, Q); | ||
} | ||
|
||
bool pass = true; | ||
for (i = 0; i < 10; ++i) { | ||
pass = pass && (A[i] == i); | ||
pass = pass && (B[i] == i); | ||
} | ||
|
||
{ | ||
sycl::buffer<int, 1> buf_A(A.data(), N); | ||
sycl::buffer<int, 1> buf_B(B.data(), N); | ||
sycl::buffer<int, 1> buf_C(C.data(), N); | ||
add(N, buf_A, buf_B, buf_C, Q); | ||
} | ||
|
||
for (i = 0; i < 10; ++i) { | ||
pass = pass && (A[i] + B[i] == C[i]); | ||
} | ||
|
||
fprintf(stdout, "%s: %s\n", argv[0], pass ? "PASS" : "FAIL"); | ||
} catch (sycl::exception const &se) { | ||
fprintf(stderr, "%s failed with %s (%d)\n", argv[0], se.what(), | ||
se.code().value()); | ||
|
||
return 1; | ||
} catch (std::exception const &e) { | ||
fprintf(stderr, "failed with %s\n", e.what()); | ||
return 2; | ||
} catch (...) { | ||
fprintf(stderr, "failed\n"); | ||
return -1; | ||
} | ||
return 0; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// This test is intended to check a certain approach of compiling libraries and | ||
// application, when both regular SYCL and ESIMD are used. | ||
// | ||
// We used to have a bug, when under some circumstances compiler created empty | ||
// device images, but at the same time it stated that they contain some kernels. | ||
// More details can be found in intel/llvm#4927. | ||
// | ||
// REQUIRES: linux,gpu | ||
// UNSUPPORTED: cuda || hip | ||
// | ||
// RUN: %clangxx -fsycl -fPIC -O3 %S/Inputs/complex-lib-sycl.cpp -c -o %t-lib-sycl.o | ||
// RUN: %clangxx -fsycl -fPIC -O3 %S/Inputs/complex-lib-esimd.cpp -c -o %t-lib-esimd.o | ||
// RUN: %clangxx -fsycl -fPIC -O3 %S/Inputs/complex-lib-test.cpp -c -o %t-test.o | ||
// | ||
// RUN: ar crsv %t-lib-sycl.a %t-lib-sycl.o | ||
// RUN: ar crsv %t-lib-esimd.a %t-lib-esimd.o | ||
// | ||
// One shared library is built using static libraries | ||
// | ||
// RUN: %clangxx -fsycl -shared %t-lib-sycl.a %t-lib-esimd.a \ | ||
// RUN: -fsycl-device-code-split=per_kernel -Wl,--whole-archive \ | ||
// RUN: %t-lib-sycl.a %t-lib-esimd.a -Wl,--no-whole-archive -Wl,-soname,%S -o %t-lib-a.so | ||
// | ||
// And another one is constructed directly from object files | ||
// | ||
// RUN: %clangxx -fsycl -shared %t-lib-sycl.o %t-lib-esimd.o \ | ||
// RUN: -fsycl-device-code-split=per_kernel -Wl,-soname,%S -o %t-lib-o.so | ||
// | ||
// RUN: %clangxx -fsycl %t-test.o %t-lib-a.so -o %t-a.run | ||
// RUN: %clangxx -fsycl %t-test.o %t-lib-o.so -o %t-o.run | ||
// | ||
// FIXME: is there better way to handle libraries loading than LD_PRELOAD? | ||
// There is no LIT substitution, which would point to a directory, where | ||
// temporary files are located. There is %T, but it is marked as "deprecated, | ||
// do not use" | ||
// RUN: %GPU_RUN_PLACEHOLDER LD_PRELOAD=%t-lib-a.so %t-a.run | ||
// RUN: %GPU_RUN_PLACEHOLDER LD_PRELOAD=%t-lib-o.so %t-o.run |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.