-
Notifications
You must be signed in to change notification settings - Fork 130
[SYCL][ESIMD] Tests on Spec_Const feature for all basic types #135
Changes from 32 commits
5d55ee2
bb7498d
59999ef
68ee5ad
7408568
6c817ee
8823c79
f62acbc
ad93c1a
51319c8
b14db07
9fe0151
f019b28
d958a91
3461c8a
544ac3f
10fdec3
d84e3b7
a47856d
309968d
2061249
e6cc0d3
371dd84
c0684b9
04a4069
2772abb
59cb60c
f477d47
cc71d20
3635f1a
6e482b2
845bd2a
4bc6ca2
cf53dd9
5441b64
dc94ab4
bdcdc3c
63237bd
dec0836
3ad7ffe
d27ab0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| //==--------------- spec_const_common.h - DPC++ ESIMD on-device test -----===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // The test checks that ESIMD kernels support specialization constants for all | ||
| // basic types, particularly a specialization constant can be redifined and | ||
| // correct new value is used after redefinition. | ||
|
|
||
| #include "esimd_test_utils.hpp" | ||
|
|
||
| #include <CL/sycl.hpp> | ||
| #include <CL/sycl/INTEL/esimd.hpp> | ||
|
|
||
| #include <iostream> | ||
| #include <vector> | ||
|
|
||
| using namespace cl::sycl; | ||
|
|
||
| template <typename AccessorTy> | ||
| ESIMD_INLINE void do_store(AccessorTy acc, int i, spec_const_t val) { | ||
| using namespace sycl::INTEL::gpu; | ||
| #if STORE == 0 | ||
| // bool | ||
| scalar_store(acc, i, val ? 1 : 0); | ||
| #elif STORE == 1 | ||
kbobrovs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // block | ||
| block_store(acc, i, simd<spec_const_t, 2>{val}); | ||
| #elif STORE == 2 | ||
| // scalar | ||
| scalar_store(acc, i, val); | ||
| #endif | ||
| } | ||
|
|
||
| class ConstID; | ||
| class TestKernel; | ||
|
|
||
| int main(int argc, char **argv) { | ||
| queue q(esimd_test::ESIMDSelector{}, esimd_test::createExceptionHandler()); | ||
|
|
||
| auto dev = q.get_device(); | ||
| std::cout << "Running on " << dev.get_info<info::device::name>() << "\n"; | ||
|
|
||
| const int n_times = 2; | ||
| std::vector<container_t> output(n_times); | ||
| std::vector<container_t> etalon = {DEF_VAL, REDEF_VAL}; | ||
kbobrovs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| bool passed = true; | ||
| for (int i = 0; i < n_times; i++) { | ||
| sycl::program prg(q.get_context()); | ||
|
|
||
| auto spec_const = prg.set_spec_constant<ConstID>((spec_const_t)DEF_VAL); | ||
| if (i % 2 != 0) | ||
| spec_const = prg.set_spec_constant<ConstID>((spec_const_t)REDEF_VAL); | ||
kbobrovs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| prg.build_with_kernel_type<TestKernel>(); | ||
|
|
||
| try { | ||
| sycl::buffer<container_t, 1> buf(output.data(), output.size()); | ||
|
|
||
| q.submit([&](sycl::handler &cgh) { | ||
| auto acc = buf.get_access<sycl::access::mode::write>(cgh); | ||
| cgh.single_task<TestKernel>( | ||
| prg.get_kernel<TestKernel>(), | ||
| [=]() SYCL_ESIMD_KERNEL { do_store(acc, i, spec_const.get()); }); | ||
| }); | ||
| } catch (cl::sycl::exception const &e) { | ||
| std::cout << "SYCL exception caught: " << e.what() << '\n'; | ||
| return e.get_cl_code(); | ||
| } | ||
|
|
||
| if (output[i] != etalon[i]) { | ||
| passed = false; | ||
| std::cout << "comparison error -- case #" << i << " -- "; | ||
| std::cout << "output: " << output[i] << ", "; | ||
| std::cout << "etalon: " << etalon[i] << std::endl; | ||
| } | ||
| } | ||
|
|
||
| if (passed) { | ||
| std::cout << "passed" << std::endl; | ||
| return 0; | ||
| } | ||
|
|
||
| std::cout << "FAILED" << std::endl; | ||
| return 1; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| //==--------------- spec_const_bool.cpp - DPC++ ESIMD on-device test -----===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: windows | ||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL true | ||
| #define REDEF_VAL false | ||
| #define STORE 0 | ||
|
|
||
| // In this case container type is set to unsigned char to be able to use | ||
| // esimd memory interfaces to pollute container. | ||
| typedef bool spec_const_t; | ||
|
||
| typedef unsigned char container_t; | ||
kbobrovs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #include "Inputs/spec_const_common.hpp" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //==--------------- spec_const_char.cpp - DPC++ ESIMD on-device test -----===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: level_zero || windows | ||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL -22 | ||
| #define REDEF_VAL 33 | ||
| #define STORE 2 | ||
|
|
||
| typedef char spec_const_t; | ||
| typedef char container_t; | ||
|
|
||
| #include "Inputs/spec_const_common.hpp" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //==--------------- spec_const_double.cpp - DPC++ ESIMD on-device test ---===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: windows | ||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL 9.1029384756e+11 | ||
| #define REDEF_VAL -1.4432211654e-10 | ||
| #define STORE 1 | ||
|
|
||
| typedef double spec_const_t; | ||
| typedef double container_t; | ||
|
|
||
| #include "Inputs/spec_const_common.hpp" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //==--------------- spec_const_float.cpp - DPC++ ESIMD on-device test ----===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: windows | ||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL -1.456789e-5 | ||
| #define REDEF_VAL 2.9865432e+5 | ||
| #define STORE 2 | ||
|
|
||
| typedef float spec_const_t; | ||
| typedef float container_t; | ||
|
|
||
| #include "Inputs/spec_const_common.hpp" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //==--------------- spec_const_int.cpp - DPC++ ESIMD on-device test ------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: windows | ||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL 100500 | ||
| #define REDEF_VAL -44556677 | ||
| #define STORE 2 | ||
|
|
||
| typedef int spec_const_t; | ||
| typedef int container_t; | ||
|
|
||
| #include "Inputs/spec_const_common.hpp" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //==--------------- spec_const_long.cpp - DPC++ ESIMD on-device test -----===// | ||
|
||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: windows | ||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL -99776644220011 | ||
| #define REDEF_VAL 22001144668855 | ||
| #define STORE 1 | ||
|
|
||
| typedef long spec_const_t; | ||
kbobrovs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| typedef long container_t; | ||
|
|
||
| #include "Inputs/spec_const_common.hpp" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //==--------------- spec_const_short.cpp - DPC++ ESIMD on-device test ----===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: level_zero || windows | ||
|
||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL -30572 | ||
| #define REDEF_VAL 24794 | ||
| #define STORE 2 | ||
|
|
||
| typedef short spec_const_t; | ||
| typedef short container_t; | ||
|
|
||
| #include "Inputs/spec_const_common.hpp" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //==--------------- spec_const_uchar.cpp - DPC++ ESIMD on-device test ----===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: level_zero || windows | ||
|
||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL 128 | ||
| #define REDEF_VAL 33 | ||
| #define STORE 2 | ||
|
|
||
| typedef unsigned char spec_const_t; | ||
| typedef unsigned char container_t; | ||
|
|
||
| #include "Inputs/spec_const_common.hpp" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //==--------------- spec_const_uint.cpp - DPC++ ESIMD on-device test -----===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: windows | ||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL 0xdeadcafe | ||
| #define REDEF_VAL 0x4badbeaf | ||
| #define STORE 2 | ||
|
|
||
| typedef unsigned int spec_const_t; | ||
| typedef unsigned int container_t; | ||
|
|
||
| #include "Inputs/spec_const_common.hpp" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //==--------------- spec_const_ulong.cpp - DPC++ ESIMD on-device test ----===// | ||
|
||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: windows | ||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL 0xdeaddeaf4badbeaf | ||
| #define REDEF_VAL 0x4cafebad00112233 | ||
| #define STORE 1 | ||
|
|
||
| typedef unsigned long spec_const_t; | ||
kbobrovs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| typedef unsigned long container_t; | ||
|
|
||
| #include "Inputs/spec_const_common.hpp" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //==--------------- spec_const_ushort.cpp - DPC++ ESIMD on-device test ---===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // REQUIRES: gpu | ||
| // XFAIL: level_zero || windows | ||
|
||
| // RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out | ||
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // UNSUPPORTED: cuda | ||
|
|
||
| #define DEF_VAL 0xcafe | ||
| #define REDEF_VAL 0xdeaf | ||
| #define STORE 2 | ||
|
|
||
| typedef unsigned short spec_const_t; | ||
kbobrovs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| typedef unsigned short container_t; | ||
|
|
||
| #include "Inputs/spec_const_common.hpp" | ||
Uh oh!
There was an error while loading. Please reload this page.