Skip to content

Commit ebadda3

Browse files
authored
Merge pull request intel#42 from bb-sycl/xmain
Auto pulldown and update tc files for xmain branch on 20210625
2 parents 6db1c56 + 47053c3 commit ebadda3

20 files changed

+462
-29
lines changed

SYCL/Basic/half_type.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,52 @@ inline bool bitwise_comparison_fp32(const half val, const uint32_t exp) {
192192
return reinterpret_cast<const uint32_t &>(fp32) == exp;
193193
}
194194

195+
constexpr void constexpr_verify_add() {
196+
constexpr half a{5.0}, b{2.0}, ref{7.0};
197+
constexpr half result = a + b;
198+
constexpr half diff = result - ref;
199+
constexpr auto sign = diff < 0 ? -1 : 1;
200+
static_assert(sign * static_cast<float>(diff) <
201+
std::numeric_limits<cl::sycl::half>::epsilon(),
202+
"Constexpr add is wrong");
203+
}
204+
205+
constexpr void constexpr_verify_sub() {
206+
constexpr half a{5.0f}, b{2.0}, ref{3.0};
207+
constexpr half result = a - b;
208+
constexpr half diff = result - ref;
209+
constexpr auto sign = diff < 0 ? -1 : 1;
210+
static_assert(sign * static_cast<float>(diff) <
211+
std::numeric_limits<cl::sycl::half>::epsilon(),
212+
"Constexpr sub is wrong");
213+
}
214+
215+
constexpr void constexpr_verify_mul() {
216+
constexpr half a{5.0f}, b{2.0}, ref{10.0};
217+
constexpr half result = a * b;
218+
constexpr half diff = result - ref;
219+
constexpr auto sign = diff < 0 ? -1 : 1;
220+
static_assert(sign * static_cast<float>(diff) <
221+
std::numeric_limits<cl::sycl::half>::epsilon(),
222+
"Constexpr mul is wrong");
223+
}
224+
225+
constexpr void constexpr_verify_div() {
226+
constexpr half a{5.0f}, b{2.0}, ref{2.5};
227+
constexpr half result = a / b;
228+
constexpr half diff = result - ref;
229+
constexpr auto sign = diff < 0 ? -1 : 1;
230+
static_assert(sign * static_cast<float>(diff) <
231+
std::numeric_limits<cl::sycl::half>::epsilon(),
232+
"Constexpr div is wrong");
233+
}
234+
195235
int main() {
236+
constexpr_verify_add();
237+
constexpr_verify_sub();
238+
constexpr_verify_mul();
239+
constexpr_verify_div();
240+
196241
device dev{default_selector()};
197242
if (!dev.is_host() && !dev.has_extension("cl_khr_fp16")) {
198243
std::cout << "This device doesn't support the extension cl_khr_fp16"

SYCL/ESIMD/dp4a.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// TODO enable on Windows
9-
// REQUIRES: linux && gpu
9+
// REQUIRES: linux && gpu-intel-dg1
1010
// RUN: %clangxx -fsycl %s -o %t.out
1111
// RUN: %GPU_RUN_PLACEHOLDER %t.out
12-
// TODO : Enable test for new GPU device
13-
// XFAIL: *
1412

1513
#include "esimd_test_utils.hpp"
1614

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
//==------ noinline_bypointers_vadd.cpp - DPC++ ESIMD on-device test ------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu
9+
// UNSUPPORTED: cuda
10+
// RUN: %clangxx -fsycl %s -o %t.out
11+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
12+
// XFAIL: *
13+
14+
// Vector BE bug.
15+
// Memory access via a pointer type argument is broken if the function was not
16+
// inlined.
17+
18+
#include "esimd_test_utils.hpp"
19+
20+
#include <CL/sycl.hpp>
21+
#include <sycl/ext/intel/experimental/esimd.hpp>
22+
23+
#include <iostream>
24+
25+
using namespace cl::sycl;
26+
using namespace sycl::ext::intel::experimental::esimd;
27+
28+
using ptr = float *;
29+
static inline constexpr unsigned VL = 32;
30+
31+
SYCL_EXTERNAL ESIMD_NOINLINE void do_add(ptr A, float *B,
32+
ptr C) SYCL_ESIMD_FUNCTION {
33+
simd<float, VL> va;
34+
va.copy_from(A);
35+
simd<float, VL> vb;
36+
vb.copy_from(B);
37+
simd<float, VL> vc = va + vb;
38+
vc.copy_to(C);
39+
}
40+
41+
int main(void) {
42+
constexpr unsigned Size = 1024;
43+
constexpr unsigned GroupSize = 8;
44+
45+
queue q(esimd_test::ESIMDSelector{}, esimd_test::createExceptionHandler());
46+
47+
auto dev = q.get_device();
48+
std::cout << "Running on " << dev.get_info<info::device::name>() << "\n";
49+
auto ctxt = q.get_context();
50+
float *A =
51+
static_cast<float *>(malloc_shared(Size * sizeof(float), dev, ctxt));
52+
float *B =
53+
static_cast<float *>(malloc_shared(Size * sizeof(float), dev, ctxt));
54+
float *C =
55+
static_cast<float *>(malloc_shared(Size * sizeof(float), dev, ctxt));
56+
57+
for (unsigned i = 0; i < Size; ++i) {
58+
A[i] = B[i] = i;
59+
}
60+
61+
// We need that many workitems. Each processes VL elements of data.
62+
cl::sycl::range<1> GlobalRange{Size / VL};
63+
// Number of workitems in each workgroup.
64+
cl::sycl::range<1> LocalRange{GroupSize};
65+
66+
cl::sycl::nd_range<1> Range(GlobalRange, LocalRange);
67+
68+
try {
69+
auto e = q.submit([&](handler &cgh) {
70+
cgh.parallel_for<class Test>(
71+
Range, [=](nd_item<1> ndi) SYCL_ESIMD_KERNEL {
72+
int i = ndi.get_global_id(0);
73+
do_add(ptr{A + i * VL}, B + i * VL, ptr{C + i * VL});
74+
});
75+
});
76+
e.wait();
77+
} catch (cl::sycl::exception const &e) {
78+
std::cout << "SYCL exception caught: " << e.what() << '\n';
79+
80+
free(A, ctxt);
81+
free(B, ctxt);
82+
free(C, ctxt);
83+
84+
return e.get_cl_code();
85+
}
86+
87+
int err_cnt = 0;
88+
89+
for (unsigned i = 0; i < Size; ++i) {
90+
if (A[i] + B[i] != C[i]) {
91+
if (++err_cnt < 10) {
92+
std::cout << "failed at index " << i << ", " << C[i] << " != " << A[i]
93+
<< " + " << B[i] << "\n";
94+
}
95+
}
96+
}
97+
98+
free(A, ctxt);
99+
free(B, ctxt);
100+
free(C, ctxt);
101+
102+
if (err_cnt > 0) {
103+
std::cout << " pass rate: "
104+
<< ((float)(Size - err_cnt) / (float)Size) * 100.0f << "% ("
105+
<< (Size - err_cnt) << "/" << Size << ")\n";
106+
std::cout << "FAILED\n";
107+
return 1;
108+
}
109+
110+
std::cout << "Passed\n";
111+
return 0;
112+
}

SYCL/HierPar/hier_par_wgscope_O0.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
// code and data in the work group scope, and when the test is compiled with
1818
// -O0 switch.
1919

20-
// The test is failing on CUDA after intel/llvm#3779
21-
// XFAIL: cuda
22-
2320
#include "Inputs/hier_par_wgscope_impl.hpp"
2421

2522
int main() { return run(); }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %clangxx -fsycl -g %s -o %t.out
2+
// RUN: %clangxx -fsycl -g -O0 %s -o %t.out
3+
// RUN: %clangxx -fsycl -g -O2 %s -o %t.out
4+
//
5+
// The idea of this test is to make sure that we can compile the following
6+
// simple example without crashes/assertions firing at llvm-spirv step due to
7+
// debug info corrupted by sycl-post-link
8+
9+
#include <sycl/sycl.hpp>
10+
11+
constexpr sycl::specialization_id<int> test_id_1{42};
12+
13+
int main() {
14+
15+
sycl::queue q;
16+
{
17+
sycl::buffer<double, 1> Buf{sycl::range{1}};
18+
q.submit([&](sycl::handler &cgh) {
19+
auto Acc = Buf.get_access<sycl::access::mode::read_write>(cgh);
20+
cgh.set_specialization_constant<test_id_1>(1);
21+
cgh.single_task<class Kernel1>([=](sycl::kernel_handler kh) {
22+
Acc[0] = kh.get_specialization_constant<test_id_1>();
23+
});
24+
});
25+
auto Acc = Buf.get_access<sycl::access::mode::read>();
26+
assert(Acc[0] == 1);
27+
}
28+
return 0;
29+
}

SYCL/Sampler/normalized-clampedge-linear-float.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER
44
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
55
// XFAIL: cuda
6-
// UNSUPPORTED: level_zero && windows
76

87
// CUDA works with image_channel_type::fp32, but not with any 8-bit per channel
98
// type (such as unorm_int8)
109

11-
// LevelZero on Windows hangs with normalized coordinates. Waiting on fix.
12-
1310
/*
1411
This file sets up an image, initializes it with data,
1512
and verifies that the data is sampled correctly with a

SYCL/Sampler/normalized-clampedge-nearest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// RUN: %HOST_RUN_PLACEHOLDER %t.out %HOST_CHECK_PLACEHOLDER
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER
5-
// UNSUPPORTED: level_zero && windows
65

7-
// LevelZero on Windows hangs with normalized coordinates. Waiting on fix.
86

97
/*
108
This file sets up an image, initializes it with data,

SYCL/Sampler/normalized-mirror-linear-float.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
55

66
// XFAIL: cuda
7-
// UNSUPPORTED: level_zero && windows
87

98
// CUDA works with image_channel_type::fp32, but not with any 8-bit per channel
109
// type (such as unorm_int8)
1110

12-
// LevelZero on Windows hangs with normalized coordinates. Waiting on fix.
1311

1412
/*
1513
This file sets up an image, initializes it with data,

SYCL/Sampler/normalized-mirror-nearest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER
55
// XFAIL: cuda
6-
// UNSUPPORTED: level_zero && windows
76

87
// CUDA is not handling repeat or mirror correctly with normalized coordinates.
98
// Waiting on a fix.
10-
// LevelZero on Windows hangs with normalized coordinates. Waiting on fix.
119

1210
/*
1311
This file sets up an image, initializes it with data,

SYCL/Sampler/normalized-none-linear-float.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
55

66
// XFAIL: cuda
7-
// UNSUPPORTED: level_zero && windows
87

98
// CUDA works with image_channel_type::fp32, but not with any 8-bit per channel
109
// type (such as unorm_int8)
1110

12-
// LevelZero on Windows hangs with normalized coordinates. Waiting on fix.
1311

1412
/*
1513
This file sets up an image, initializes it with data,

SYCL/Sampler/normalized-none-nearest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// RUN: %HOST_RUN_PLACEHOLDER %t.out %HOST_CHECK_PLACEHOLDER
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER
5-
// UNSUPPORTED: level_zero && windows
65

7-
// LevelZero on Windows hangs with normalized coordinates. Waiting on fix.
86

97
/*
108
This file sets up an image, initializes it with data,

SYCL/Sampler/normalized-repeat-linear-float.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
55

66
// XFAIL: cuda
7-
// UNSUPPORTED: level_zero && windows
87

98
// CUDA works with image_channel_type::fp32, but not with any 8-bit per channel
109
// type (such as unorm_int8)
1110

12-
// LevelZero on Windows hangs with normalized coordinates. Waiting on fix.
1311

1412
/*
1513
This file sets up an image, initializes it with data,

SYCL/Sampler/normalized-repeat-nearest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
// RUN: %CPU_RUN_PLACEHOLDER %t.out %CPU_CHECK_PLACEHOLDER
44
// RUN: %GPU_RUN_PLACEHOLDER %t.out %GPU_CHECK_PLACEHOLDER
55
// XFAIL: cuda
6-
// UNSUPPORTED: level_zero && windows
76

87
// CUDA is not handling repeat or mirror correctly with normalized coordinates.
98
// Waiting on a fix.
10-
// LevelZero on Windows hangs with normalized coordinates. Waiting on fix.
119

1210
/*
1311
This file sets up an image, initializes it with data,

SYCL/SpecConstants/2020/common.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ inline bool operator!=(const custom_type_nested &lhs,
2929

3030
inline std::ostream &operator<<(std::ostream &out,
3131
const custom_type_nested &v) {
32-
return out << "custom_type_nested { .c = " << v.c << ", .f = " << v.f << "}"
33-
<< std::endl;
32+
return out << "custom_type_nested { .c = " << v.c << ", .f = " << v.f << "}";
3433
}
3534

3635
struct custom_type {
@@ -54,14 +53,15 @@ inline bool operator!=(const custom_type &lhs, const custom_type &rhs) {
5453

5554
inline std::ostream &operator<<(std::ostream &out, const custom_type &v) {
5655
return out << "custom_type { .n = \n\t" << v.n << ",\n .ull = " << v.ull
57-
<< "}" << std::endl;
56+
<< "}";
5857
}
5958

6059
template <typename T>
61-
bool check_value(const T &got, const T &ref, const std::string &variable_name) {
60+
bool check_value(const T &ref, const T &got, const std::string &variable_name) {
6261
if (got != ref) {
6362
std::cout << "Unexpected value of " << variable_name << ": " << got
6463
<< " (got) vs " << ref << " (expected)" << std::endl;
64+
return false;
6565
}
6666

6767
return true;

0 commit comments

Comments
 (0)