Skip to content

Commit f5f6acd

Browse files
romanovvladAlexeySachkovPavel Chupin
authored
[SYCL] Update part of the tests to make double support optional (intel/llvm-test-suite#1190)
Co-authored-by: Alexey Sachkov <[email protected]> Co-authored-by: Pavel Chupin <[email protected]>
1 parent eaf8b95 commit f5f6acd

File tree

9 files changed

+65
-40
lines changed

9 files changed

+65
-40
lines changed

SYCL/AtomicRef/assignment_atomic64.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
1+
// RUN: %clangxx -fsycl -fsycl-device-code-split=per_kernel -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
@@ -10,13 +10,18 @@ using namespace sycl;
1010
int main() {
1111
queue q;
1212

13-
if (!q.get_device().has(aspect::atomic64)) {
13+
device dev = q.get_device();
14+
15+
if (!dev.has(aspect::atomic64)) {
1416
std::cout << "Skipping test\n";
1517
return 0;
1618
}
1719

20+
const bool DoublesSupported = dev.has(sycl::aspect::fp64);
21+
1822
constexpr int N = 32;
19-
assignment_test<double>(q, N);
23+
if (DoublesSupported)
24+
assignment_test<double>(q, N);
2025

2126
// Include long tests if they are 64 bits wide
2227
if constexpr (sizeof(long) == 8) {

SYCL/AtomicRef/assignment_atomic64_generic.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
1+
// RUN: %clangxx -fsycl -fsycl-device-code-split=per_kernel -fsycl-targets=%sycl_triple %s -o %t.out
22
// RUN: %CPU_RUN_PLACEHOLDER %t.out
33
// RUN: %GPU_RUN_PLACEHOLDER %t.out
44
// RUN: %ACC_RUN_PLACEHOLDER %t.out
@@ -13,13 +13,18 @@ using namespace sycl;
1313
int main() {
1414
queue q;
1515

16-
if (!q.get_device().has(aspect::atomic64)) {
16+
device dev = q.get_device();
17+
18+
if (!dev.has(aspect::atomic64)) {
1719
std::cout << "Skipping test\n";
1820
return 0;
1921
}
2022

23+
const bool DoublesSupported = dev.has(sycl::aspect::fp64);
24+
2125
constexpr int N = 32;
22-
assignment_generic_test<double>(q, N);
26+
if (DoublesSupported)
27+
assignment_generic_test<double>(q, N);
2328

2429
// Include long tests if they are 64 bits wide
2530
if constexpr (sizeof(long) == 8) {

SYCL/Basic/buffer/buffer.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,15 @@ int main() {
510510
[](bool *data) { delete[] data; });
511511
std::shared_ptr<int> int_shrd(new int[size],
512512
[](int *data) { delete[] data; });
513-
std::shared_ptr<double> double_shrd(new double[size],
514-
[](double *data) { delete[] data; });
513+
std::shared_ptr<float> float_shrd(new float[size],
514+
[](float *data) { delete[] data; });
515515

516516
std::vector<bool> bool_vector;
517517
std::vector<int> int_vector;
518-
std::vector<double> double_vector;
518+
std::vector<float> float_vector;
519519
bool_vector.reserve(size);
520520
int_vector.reserve(size);
521-
double_vector.reserve(size);
521+
float_vector.reserve(size);
522522

523523
sycl::queue Queue;
524524
std::mutex m;
@@ -529,40 +529,40 @@ int main() {
529529
sycl::buffer<int, dims> buf_int_shrd(
530530
int_shrd, r,
531531
sycl::property_list{sycl::property::buffer::use_mutex(m)});
532-
sycl::buffer<double, dims> buf_double_shrd(
533-
double_shrd, r,
532+
sycl::buffer<float, dims> buf_float_shrd(
533+
float_shrd, r,
534534
sycl::property_list{sycl::property::buffer::use_mutex(m)});
535535
m.lock();
536536
std::fill(bool_shrd.get(), (bool_shrd.get() + size), bool());
537537
std::fill(int_shrd.get(), (int_shrd.get() + size), int());
538-
std::fill(double_shrd.get(), (double_shrd.get() + size), double());
538+
std::fill(float_shrd.get(), (float_shrd.get() + size), float());
539539
m.unlock();
540540

541541
buf_bool_shrd.set_final_data(bool_vector.begin());
542542
buf_int_shrd.set_final_data(int_vector.begin());
543-
buf_double_shrd.set_final_data(double_vector.begin());
543+
buf_float_shrd.set_final_data(float_vector.begin());
544544
buf_bool_shrd.set_write_back(true);
545545
buf_int_shrd.set_write_back(true);
546-
buf_double_shrd.set_write_back(true);
546+
buf_float_shrd.set_write_back(true);
547547

548548
Queue.submit([&](sycl::handler &cgh) {
549549
auto Accessor_bool =
550550
buf_bool_shrd.get_access<sycl::access::mode::write>(cgh);
551551
auto Accessor_int =
552552
buf_int_shrd.get_access<sycl::access::mode::write>(cgh);
553-
auto Accessor_double =
554-
buf_double_shrd.get_access<sycl::access::mode::write>(cgh);
553+
auto Accessor_float =
554+
buf_float_shrd.get_access<sycl::access::mode::write>(cgh);
555555
cgh.parallel_for<class FillBuffer>(r, [=](sycl::id<1> WIid) {
556556
Accessor_bool[WIid] = true;
557557
Accessor_int[WIid] = 3;
558-
Accessor_double[WIid] = 7.5;
558+
Accessor_float[WIid] = 7.5;
559559
});
560560
});
561561
} // Data is copied back
562562

563563
for (size_t i = 0; i < size; i++) {
564564
if (bool_vector[i] != true || int_vector[i] != 3 ||
565-
double_vector[i] != 7.5) {
565+
float_vector[i] != 7.5) {
566566
assert(false && "Data was not copied back");
567567
return 1;
568568
}

SYCL/DeviceLib/built-ins/nan.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -D HALF_IS_SUPPORTED %s -o %t_gpu.out
1+
// RUN: %clangxx -fsycl -fsycl-device-code-split=per_kernel -fsycl-targets=%sycl_triple %s -o %t.out
32
// RUN: %CPU_RUN_PLACEHOLDER %t.out
4-
// RUN: %GPU_RUN_PLACEHOLDER %t_gpu.out
3+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
54
// RUN: %ACC_RUN_PLACEHOLDER %t.out
65

76
#include <iostream>
@@ -59,10 +58,10 @@ int main() {
5958
}
6059
}
6160
});
62-
#ifdef HALF_IS_SUPPORTED
61+
6362
if (Queue.get_device().has(sycl::aspect::fp16))
6463
check_nan<unsigned short, s::half>(Queue);
65-
#endif
64+
6665
check_nan<unsigned int, float>(Queue);
6766
if (Queue.get_device().has(sycl::aspect::fp64)) {
6867
check_nan<unsigned long, double>(Queue);

SYCL/ESIMD/api/replicate_smoke.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88
// REQUIRES: gpu
99
// UNSUPPORTED: cuda || hip
10-
// RUN: %clangxx -fsycl %s -o %t.out
10+
// RUN: %clangxx -fsycl -fsycl-device-code-split=per_kernel %s -o %t.out
1111
// RUN: %GPU_RUN_PLACEHOLDER %t.out
1212
//
1313
// The test checks main functionality of the esimd::replicate_vs_w_hs function.
@@ -175,6 +175,7 @@ template <class T> bool test(queue q) {
175175
int main(int argc, char **argv) {
176176
queue q(esimd_test::ESIMDSelector{}, esimd_test::createExceptionHandler());
177177
auto dev = q.get_device();
178+
const bool doublesSupported = dev.has(sycl::aspect::fp64);
178179
std::cout << "Running on " << dev.get_info<sycl::info::device::name>()
179180
<< "\n";
180181
bool passed = true;
@@ -187,7 +188,8 @@ int main(int argc, char **argv) {
187188
passed &= test<int>(q);
188189
passed &= test<uint64_t>(q);
189190
passed &= test<float>(q);
190-
passed &= test<double>(q);
191+
if (doublesSupported)
192+
passed &= test<double>(q);
191193

192194
std::cout << (passed ? "Test passed\n" : "Test FAILED\n");
193195
return passed ? 0 : 1;

SYCL/ESIMD/api/saturation_smoke.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// UNSUPPORTED: cuda || hip
1010
// TODO: esimd_emulator fails due to unimplemented 'half' type
1111
// XFAIL: esimd_emulator
12-
// RUN: %clangxx -fsycl %s -o %t.out
12+
// RUN: %clangxx -fsycl-device-code-split=per_kernel -fsycl %s -o %t.out
1313
// RUN: %GPU_RUN_PLACEHOLDER %t.out
1414
//
1515
// The test checks main functionality of esimd::saturate function.
@@ -184,12 +184,14 @@ int main(int argc, char **argv) {
184184
auto dev = q.get_device();
185185
std::cout << "Running on " << dev.get_info<sycl::info::device::name>()
186186
<< "\n";
187+
const bool doublesSupported = dev.has(sycl::aspect::fp64);
187188

188189
bool passed = true;
189190
passed &= test<half, int, FpToInt>(q);
190191
passed &= test<half, unsigned char, FpToInt>(q);
191192
passed &= test<float, int, FpToInt>(q);
192-
passed &= test<double, short, FpToInt>(q);
193+
if (doublesSupported)
194+
passed &= test<double, short, FpToInt>(q);
193195

194196
passed &= test<unsigned char, char, UIntToSameOrNarrowAnyInt>(q);
195197
passed &= test<unsigned short, short, UIntToSameOrNarrowAnyInt>(q);
@@ -206,7 +208,8 @@ int main(int argc, char **argv) {
206208

207209
passed &= test<float, float, FpToFp>(q);
208210
passed &= test<half, half, FpToFp>(q);
209-
passed &= test<double, double, FpToFp>(q);
211+
if (doublesSupported)
212+
passed &= test<double, double, FpToFp>(q);
210213

211214
std::cout << (passed ? "Test passed\n" : "Test FAILED\n");
212215
return passed ? 0 : 1;

SYCL/ESIMD/api/simd_view_select_2d_fp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ int main(int argc, char **argv) {
2424
bool passed = true;
2525
passed &= test<half>(q);
2626
passed &= test<float>(q);
27-
passed &= test<double>(q);
27+
if (dev.has(sycl::aspect::fp64))
28+
passed &= test<double>(q);
2829

2930
std::cout << (passed ? "=== Test passed\n" : "=== Test FAILED\n");
3031
return passed ? 0 : 1;

SYCL/ESIMD/ext_math.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88
// REQUIRES: gpu
99
// UNSUPPORTED: cuda || hip
10-
// RUN: %clangxx -fsycl %s -o %t.out
10+
// RUN: %clangxx -fsycl-device-code-split=per_kernel -fsycl %s -o %t.out
1111
// RUN: %GPU_RUN_PLACEHOLDER %t.out
1212

1313
// This test checks extended math operations. Combinations of
@@ -474,9 +474,11 @@ int main(void) {
474474
Pass &= testSYCL<float, 32>(Q);
475475
}
476476
Pass &= testESIMDSqrtIEEE<float, 16>(Q);
477-
Pass &= testESIMDSqrtIEEE<double, 32>(Q);
477+
if (Dev.has(sycl::aspect::fp64)) {
478+
Pass &= testESIMDSqrtIEEE<double, 32>(Q);
479+
Pass &= testESIMDDivIEEE<double, 32>(Q);
480+
}
478481
Pass &= testESIMDDivIEEE<float, 8>(Q);
479-
Pass &= testESIMDDivIEEE<double, 32>(Q);
480482
Pass &= testESIMDPow<float, 8>(Q);
481483
Pass &= testESIMDPow<half, 32>(Q);
482484
std::cout << (Pass ? "Test Passed\n" : "Test FAILED\n");

SYCL/USM/fill.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t1.out
9+
// RUN: %clangxx -fsycl-device-code-split=per_kernel -fsycl -fsycl-targets=%sycl_triple %s -o %t1.out
1010
// RUN: %CPU_RUN_PLACEHOLDER %t1.out
1111
// RUN: %GPU_RUN_PLACEHOLDER %t1.out
1212
// RUN: %ACC_RUN_PLACEHOLDER %t1.out
@@ -124,6 +124,8 @@ int main() {
124124
auto dev = q.get_device();
125125
auto ctxt = q.get_context();
126126

127+
const bool DoublesSupported = dev.has(sycl::aspect::fp64);
128+
127129
test_struct test_obj{4, 42, 424, 4242, 4.2f, 4.242, 4.24242};
128130

129131
if (dev.get_info<info::device::usm_host_allocations>()) {
@@ -133,8 +135,10 @@ int main() {
133135
runHostTests<long long>(dev, ctxt, q, 4242);
134136
runHostTests<sycl::half>(dev, ctxt, q, sycl::half(4.2f));
135137
runHostTests<float>(dev, ctxt, q, 4.242f);
136-
runHostTests<double>(dev, ctxt, q, 4.24242);
137-
runHostTests<test_struct>(dev, ctxt, q, test_obj);
138+
if (DoublesSupported) {
139+
runHostTests<double>(dev, ctxt, q, 4.24242);
140+
runHostTests<test_struct>(dev, ctxt, q, test_obj);
141+
}
138142
}
139143

140144
if (dev.get_info<info::device::usm_shared_allocations>()) {
@@ -144,8 +148,10 @@ int main() {
144148
runSharedTests<long long>(dev, ctxt, q, 4242);
145149
runSharedTests<sycl::half>(dev, ctxt, q, sycl::half(4.2f));
146150
runSharedTests<float>(dev, ctxt, q, 4.242f);
147-
runSharedTests<double>(dev, ctxt, q, 4.24242);
148-
runSharedTests<test_struct>(dev, ctxt, q, test_obj);
151+
if (DoublesSupported) {
152+
runSharedTests<double>(dev, ctxt, q, 4.24242);
153+
runSharedTests<test_struct>(dev, ctxt, q, test_obj);
154+
}
149155
}
150156

151157
if (dev.get_info<info::device::usm_device_allocations>()) {
@@ -155,8 +161,10 @@ int main() {
155161
runDeviceTests<long long>(dev, ctxt, q, 4242);
156162
runDeviceTests<sycl::half>(dev, ctxt, q, sycl::half(4.2f));
157163
runDeviceTests<float>(dev, ctxt, q, 4.242f);
158-
runDeviceTests<double>(dev, ctxt, q, 4.24242);
159-
runDeviceTests<test_struct>(dev, ctxt, q, test_obj);
164+
if (DoublesSupported) {
165+
runDeviceTests<double>(dev, ctxt, q, 4.24242);
166+
runDeviceTests<test_struct>(dev, ctxt, q, test_obj);
167+
}
160168
}
161169

162170
return 0;

0 commit comments

Comments
 (0)