Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 32 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
89 changes: 89 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,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
// 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};

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);

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;
}
23 changes: 23 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_bool.cpp
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other test cases the same type is used for scalar and container. Is the difference expected. If so could you please add some comment here.

typedef unsigned char container_t;

#include "Inputs/spec_const_common.hpp"
21 changes: 21 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_char.cpp
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"
21 changes: 21 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_double.cpp
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"
21 changes: 21 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_float.cpp
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"
21 changes: 21 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_int.cpp
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"
21 changes: 21 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_long.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//==--------------- spec_const_long.cpp - DPC++ ESIMD on-device test -----===//

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change the test name (int64)

//
// 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;
typedef long container_t;

#include "Inputs/spec_const_common.hpp"
21 changes: 21 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_short.cpp
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why level_zero is XFAIL? please file a bug if it does not work on level_zero

// 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"
21 changes: 21 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_uchar.cpp
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why level_zero is XFAIL? please file a bug if it does not work on level_zero

// 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"
21 changes: 21 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_uint.cpp
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"
21 changes: 21 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_ulong.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//==--------------- spec_const_ulong.cpp - DPC++ ESIMD on-device test ----===//

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change the test name (uint64)

//
// 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;
typedef unsigned long container_t;

#include "Inputs/spec_const_common.hpp"
21 changes: 21 additions & 0 deletions SYCL/ESIMD/spec_const/spec_const_ushort.cpp
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why level_zero is XFAIL? please file a bug if it does not work on level_zero

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests (signed/unsigned char and short types) fail on Level Zero with assert:

/opt/src/build_igc/VectorCompiler/llvm-spirv-vc/lib/SPIRV/SPIRVReader.cpp:1350: llvm::Value* SPIRV::SPIRVToLLVM::transValueWithoutDecoration(SPIRV::SPIRVValue*, llvm::Function*, llvm::BasicBlock*, bool):
Assertion `(BT->getBitWidth() == 64 || (ConstValue >> BT->getBitWidth()) == 0) && "Size of externally provided specialization constant value doesn't" "fit into the specialization constant type"' failed.

According to specification all basic types should be supported, also these tests pass on OpenCL. Ticket

// 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;
typedef unsigned short container_t;

#include "Inputs/spec_const_common.hpp"