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

[SYCL][ESIMD] Tests on Spec_Const feature for all basic types #135

Merged
merged 41 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5d55ee2
ESIMD: add TPM tests
fveselov Dec 3, 2020
bb7498d
[SYCL][ESIMD] TPM tests stylecheck fix
fveselov Dec 3, 2020
59999ef
[SYCL][ESIMD] clang-format patch
fveselov Dec 4, 2020
68ee5ad
[SYCL][ESIMD] typo fix
fveselov Dec 8, 2020
7408568
[SYCL][ESIMD] improve TPM tests self-check
fveselov Dec 8, 2020
6c817ee
[SYCL][ESIMD] add description to TPM tests; cosmetic changes
fveselov Dec 16, 2020
8823c79
[SYCL][ESIMD] merged tests to one with 3 cases
fveselov Dec 17, 2020
f62acbc
clang-format patch
fveselov Dec 17, 2020
ad93c1a
cosmetic changes
fveselov Dec 17, 2020
51319c8
Update SYCL/ESIMD/tpm_tests.cpp
fveselov Dec 18, 2020
b14db07
reworked and renamed
fveselov Dec 18, 2020
9fe0151
clang-format patch
fveselov Dec 18, 2020
f019b28
[SYCL][ESIMD] evaluate condition on compile-time
fveselov Jan 12, 2021
d958a91
clang-format patch
fveselov Jan 12, 2021
3461c8a
Merge branch 'intel' into intel
vladimirlaz Jan 19, 2021
544ac3f
[SYCL][ESIMD] spec const tests for all basic types
fveselov Feb 4, 2021
10fdec3
Merge branch 'intel' into spec_const_tests
fveselov Feb 4, 2021
d84e3b7
Update pm_access_1.cpp
fveselov Feb 4, 2021
a47856d
Update pm_access_2.cpp
fveselov Feb 4, 2021
309968d
Update pm_access_3.cpp
fveselov Feb 4, 2021
2061249
clang-format patch
fveselov Feb 4, 2021
e6cc0d3
more generalization
fveselov Feb 5, 2021
371dd84
typo fix
fveselov Feb 5, 2021
c0684b9
clang-format patch
fveselov Feb 5, 2021
04a4069
cosmetic changes
fveselov Feb 6, 2021
2772abb
set expect fail
fveselov Feb 8, 2021
59cb60c
enable windows
fveselov Feb 8, 2021
f477d47
disable windows and remove xfail
fveselov Feb 8, 2021
cc71d20
set xfail for level_zero
fveselov Feb 8, 2021
3635f1a
handle synchronous SYCL exceptions; remove unnecessary code; add comment
fveselov Feb 9, 2021
6e482b2
enable windows to run jenkins check(will be reverted)
fveselov Feb 9, 2021
845bd2a
set expect fail for Windows
fveselov Feb 9, 2021
4bc6ca2
comments and C++ re-style
fveselov Feb 9, 2021
cf53dd9
clang-format patch
fveselov Feb 9, 2021
5441b64
std exception handle
fveselov Feb 10, 2021
dc94ab4
move spec const init into try block
fveselov Feb 10, 2021
bdcdc3c
set expect fail and unsupported status
fveselov Feb 10, 2021
63237bd
add unsupported and xfail description
fveselov Feb 11, 2021
dec0836
cosmetic changes
fveselov Feb 11, 2021
3ad7ffe
rename to int64
fveselov Feb 12, 2021
d27ab0d
cosmetic fix
fveselov Feb 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions SYCL/ESIMD/spec_const/Inputs/spec_const_common.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
//==--------------- 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;
// scatter function, that is used in scalar_store, can only process types
// whose size is no more than 4 bytes.
#if (STORE == 0)
// bool
scalar_store(acc, i, val ? 1 : 0);
#elif (STORE == 1)
// block
block_store(acc, i, simd<spec_const_t, 2>{val});
#else
static_assert(STORE == 2, "Unspecified store");
// 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";

std::vector<container_t> etalon = {DEF_VAL, REDEF_VAL};
const size_t n_times = etalon.size();
std::vector<container_t> output(n_times);

bool passed = true;
for (int i = 0; i < n_times; i++) {
try {
sycl::program prg(q.get_context());

// Checking that already initialized constant can be overwritten.
// According to standards proposals:
// A cl::sycl::experimental::spec_constant object is considered
// initialized once the result of a cl::sycl::program::set_spec_constant
// is assigned to it.
// A specialization constant value can be overwritten if the program was
// not built before by recalling set_spec_constant with the same ID and
// the new value. Although the type T of the specialization constant
// must remain the same.
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);

prg.build_with_kernel_type<TestKernel>();

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;
}
30 changes: 30 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_bool.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//==--------------- 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
// On Windows vector compute backend (as a part of IGC) uses llvm-7 and llvm-7
// based spirv translator. This translator doesn't have the ability to overwrite
// the default specialization constant value. That is why the support in Windows
// driver is disabled at all. This feature will start working on Windows when
// the llvm version is switched to 9.
// UNSUPPORTED: windows
// RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// UNSUPPORTED: cuda

#include <cstdint>

#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.
using spec_const_t = bool;
using container_t = uint8_t;

#include "Inputs/spec_const_common.hpp"
31 changes: 31 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_char.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//==--------------- 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
// On Windows vector compute backend (as a part of IGC) uses llvm-7 and llvm-7
// based spirv translator. This translator doesn't have the ability to overwrite
// the default specialization constant value. That is why the support in Windows
// driver is disabled at all. This feature will start working on Windows when
// the llvm version is switched to 9.
// UNSUPPORTED: windows
// Linux Level Zero fail with assertion in SPIRV about specialization constant
// type size.
// XFAIL: level_zero
// RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// UNSUPPORTED: cuda

#include <cstdint>

#define DEF_VAL -22
#define REDEF_VAL 33
#define STORE 2

using spec_const_t = int8_t;
using container_t = int8_t;

#include "Inputs/spec_const_common.hpp"
28 changes: 28 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_double.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//==--------------- 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
// On Windows vector compute backend (as a part of IGC) uses llvm-7 and llvm-7
// based spirv translator. This translator doesn't have the ability to overwrite
// the default specialization constant value. That is why the support in Windows
// driver is disabled at all. This feature will start working on Windows when
// the llvm version is switched to 9.
// UNSUPPORTED: windows
// RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// UNSUPPORTED: cuda

#include <cstdint>

#define DEF_VAL 9.1029384756e+11
#define REDEF_VAL -1.4432211654e-10
#define STORE 1

using spec_const_t = double;
using container_t = double;

#include "Inputs/spec_const_common.hpp"
28 changes: 28 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_float.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//==--------------- 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
// On Windows vector compute backend (as a part of IGC) uses llvm-7 and llvm-7
// based spirv translator. This translator doesn't have the ability to overwrite
// the default specialization constant value. That is why the support in Windows
// driver is disabled at all. This feature will start working on Windows when
// the llvm version is switched to 9.
// UNSUPPORTED: windows
// RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// UNSUPPORTED: cuda

#include <cstdint>

#define DEF_VAL -1.456789e-5
#define REDEF_VAL 2.9865432e+5
#define STORE 2

using spec_const_t = float;
using container_t = float;

#include "Inputs/spec_const_common.hpp"
28 changes: 28 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_int.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//==--------------- 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
// On Windows vector compute backend (as a part of IGC) uses llvm-7 and llvm-7
// based spirv translator. This translator doesn't have the ability to overwrite
// the default specialization constant value. That is why the support in Windows
// driver is disabled at all. This feature will start working on Windows when
// the llvm version is switched to 9.
// UNSUPPORTED: windows
// RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// UNSUPPORTED: cuda

#include <cstdint>

#define DEF_VAL 100500
#define REDEF_VAL -44556677
#define STORE 2

using spec_const_t = int32_t;
using container_t = int32_t;

#include "Inputs/spec_const_common.hpp"
28 changes: 28 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_int64.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//==-------------- spec_const_int64.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
// On Windows vector compute backend (as a part of IGC) uses llvm-7 and llvm-7
// based spirv translator. This translator doesn't have the ability to overwrite
// the default specialization constant value. That is why the support in Windows
// driver is disabled at all. This feature will start working on Windows when
// the llvm version is switched to 9.
// UNSUPPORTED: windows
// RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// UNSUPPORTED: cuda

#include <cstdint>

#define DEF_VAL -99776644220011ll
#define REDEF_VAL 22001144668855ll
#define STORE 1

using spec_const_t = int64_t;
using container_t = int64_t;

#include "Inputs/spec_const_common.hpp"
31 changes: 31 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_short.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//==--------------- 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
// On Windows vector compute backend (as a part of IGC) uses llvm-7 and llvm-7
// based spirv translator. This translator doesn't have the ability to overwrite
// the default specialization constant value. That is why the support in Windows
// driver is disabled at all. This feature will start working on Windows when
// the llvm version is switched to 9.
// UNSUPPORTED: windows
// Linux Level Zero fail with assertion in SPIRV about specialization constant
// type size.
// XFAIL: level_zero
// RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// UNSUPPORTED: cuda

#include <cstdint>

#define DEF_VAL -30572
#define REDEF_VAL 24794
#define STORE 2

using spec_const_t = int16_t;
using container_t = int16_t;

#include "Inputs/spec_const_common.hpp"
31 changes: 31 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_uchar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//==--------------- 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
// On Windows vector compute backend (as a part of IGC) uses llvm-7 and llvm-7
// based spirv translator. This translator doesn't have the ability to overwrite
// the default specialization constant value. That is why the support in Windows
// driver is disabled at all. This feature will start working on Windows when
// the llvm version is switched to 9.
// UNSUPPORTED: windows
// Linux Level Zero fail with assertion in SPIRV about specialization constant
// type size.
// XFAIL: level_zero
// RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// UNSUPPORTED: cuda

#include <cstdint>

#define DEF_VAL 128
#define REDEF_VAL 33
#define STORE 2

using spec_const_t = uint8_t;
using container_t = uint8_t;

#include "Inputs/spec_const_common.hpp"
28 changes: 28 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_uint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//==--------------- 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
// On Windows vector compute backend (as a part of IGC) uses llvm-7 and llvm-7
// based spirv translator. This translator doesn't have the ability to overwrite
// the default specialization constant value. That is why the support in Windows
// driver is disabled at all. This feature will start working on Windows when
// the llvm version is switched to 9.
// UNSUPPORTED: windows
// RUN: %clangxx-esimd -fsycl -I%S/.. %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// UNSUPPORTED: cuda

#include <cstdint>

#define DEF_VAL 0xdeadcafe
#define REDEF_VAL 0x4badbeaf
#define STORE 2

using spec_const_t = uint32_t;
using container_t = uint32_t;

#include "Inputs/spec_const_common.hpp"
Loading