Skip to content

[Draft][SYCL][E2E] Detect supported aspects at config time #9121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 2 additions & 6 deletions sycl/test-e2e/Basic/half_builtins.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down Expand Up @@ -166,12 +167,7 @@ template <int N> bool check(vec<float, N> a, vec<float, N> b) {
int main() {
queue q;

if (!q.get_device().has(sycl::aspect::fp16)) {
std::cout
<< "Test was skipped because the selected device does not support fp16"
<< std::endl;
return 0;
}
assert(q.get_device().has(sycl::aspect::fp16) && "Requires fp16");

float16 a, b, c, d;
for (int i = 0; i < SZ_max; i++) {
Expand Down
7 changes: 2 additions & 5 deletions sycl/test-e2e/Basic/half_type.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand Down Expand Up @@ -238,11 +239,7 @@ int main() {
constexpr_verify_div();

device dev{default_selector_v};
if (!dev.has(sycl::aspect::fp16)) {
std::cout << "This device doesn't support the extension cl_khr_fp16"
<< std::endl;
return 0;
}
assert(dev.has(sycl::aspect::fp16) && "Requires fp16");

std::vector<half> vec_a(N, 5.0);
std::vector<half> vec_b(N, 2.0);
Expand Down
7 changes: 2 additions & 5 deletions sycl/test-e2e/Basic/image/image_accessor_readwrite_half.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// UNSUPPORTED: cuda || hip || gpu-intel-pvc
// CUDA cannot support SYCL 1.2.1 images.
//
Expand Down Expand Up @@ -148,11 +149,7 @@ int main() {
// Checking if default selected device supports half datatype.
// Same device will be selected in the write/read functions.
s::device Dev{s::default_selector_v};
if (!Dev.has(sycl::aspect::fp16)) {
std::cout << "This device doesn't support the extension cl_khr_fp16"
<< std::endl;
return 0;
}
assert(Dev.has(sycl::aspect::fp16) && "Requires fp16");
// Checking only for dimension=1.
// create image:
char HostPtr[100];
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/Basic/image/image_read_fp16.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// UNSUPPORTED: hip || gpu-intel-pvc
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
Expand All @@ -9,8 +10,7 @@ int main() {
s::queue myQueue(s::default_selector_v);

// Device doesn't support cl_khr_fp16 extension - skip.
if (!myQueue.get_device().has(sycl::aspect::fp16))
return 0;
assert(myQueue.get_device().has(sycl::aspect::fp16) && "Requires fp16");

// Half image
if (!test<s::half4, s::image_channel_type::fp16>(myQueue))
Expand Down
7 changes: 2 additions & 5 deletions sycl/test-e2e/DeviceLib/built-ins/ext_native_math_fp16.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-device-code-split=per_kernel %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand All @@ -15,11 +16,7 @@ int main() {

sycl::queue q;

if (!q.get_device().has(sycl::aspect::fp16)) {
std::cout << "skipping fp16 tests: requires fp16 device aspect."
<< std::endl;
return 0;
}
assert(q.get_device().has(sycl::aspect::fp16) && "Requires fp16");

const sycl::half tv[16] = {-2.0, -1.5, -1.0, 0.0, 2.0, 1.5, 1.0, 0.0,
-1.7, 1.7, -1.2, 1.2, -3.0, 3.0, -10.0, 10.0};
Expand Down
8 changes: 4 additions & 4 deletions sycl/test-e2e/DeviceLib/cmath_fp64_test.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp64
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out
Expand Down Expand Up @@ -162,9 +163,8 @@ template <class T> void device_cmath_test(s::queue &deviceQueue) {

int main() {
s::queue deviceQueue;
if (deviceQueue.get_device().has(sycl::aspect::fp64)) {
device_cmath_test<double>(deviceQueue);
std::cout << "Pass" << std::endl;
}
assert(deviceQueue.get_device().has(sycl::aspect::fp64) && "Requires fp64");
device_cmath_test<double>(deviceQueue);
std::cout << "Pass" << std::endl;
return 0;
}
13 changes: 4 additions & 9 deletions sycl/test-e2e/DeviceLib/imf_double2half.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16 && fp64
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out

Expand All @@ -19,15 +20,9 @@ int main() {
<< device_queue.get_device().get_info<sycl::info::device::name>()
<< "\n";

if (!device_queue.get_device().has(sycl::aspect::fp64)) {
std::cout << "Test skipped on platform without fp64 support." << std::endl;
return 0;
}

if (!device_queue.get_device().has(sycl::aspect::fp16)) {
std::cout << "Test skipped on platform without fp16 support." << std::endl;
return 0;
}
assert(device_queue.get_device().has(sycl::aspect::fp16) &&
device_queue.get_device().has(sycl::aspect::fp64) &&
"Requires fp16 and fp64");

{
std::initializer_list<uint64_t> input_vals = {
Expand Down
6 changes: 2 additions & 4 deletions sycl/test-e2e/DeviceLib/imf_fp16_trivial_test.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out

Expand All @@ -14,10 +15,7 @@ int main(int, char **) {
<< device_queue.get_device().get_info<sycl::info::device::name>()
<< "\n";

if (!device_queue.get_device().has(sycl::aspect::fp16)) {
std::cout << "Test skipped on platform without fp16 support." << std::endl;
return 0;
}
assert(device_queue.get_device().has(sycl::aspect::fp16) && "Requires fp16");

{
std::initializer_list<sycl::half> input_vals1 = {0.5f, -1.125f, 100.5f,
Expand Down
6 changes: 2 additions & 4 deletions sycl/test-e2e/DeviceLib/imf_fp64_test.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp64
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out
Expand Down Expand Up @@ -60,10 +61,7 @@ int main(int, char **) {
std::cout << "Running on "
<< device_queue.get_device().get_info<s::info::device::name>()
<< "\n";
if (!device_queue.get_device().has(sycl::aspect::fp64)) {
std::cout << "Test skipped on platform without fp64 support." << std::endl;
return 0;
}
assert(device_queue.get_device().has(sycl::aspect::fp64) && "Requires fp64");

{
std::initializer_list<double> input_vals = {0.0,
Expand Down
6 changes: 2 additions & 4 deletions sycl/test-e2e/DeviceLib/imf_half_type_cast.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out

Expand Down Expand Up @@ -70,10 +71,7 @@ int main() {
<< device_queue.get_device().get_info<sycl::info::device::name>()
<< "\n";

if (!device_queue.get_device().has(sycl::aspect::fp16)) {
std::cout << "Test skipped on platform without fp16 support." << std::endl;
return 0;
}
assert(device_queue.get_device().has(sycl::aspect::fp16) && "Requires fp16");

// half2int tests
{
Expand Down
8 changes: 4 additions & 4 deletions sycl/test-e2e/DeviceLib/math_fp64_test.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp64
// UNSUPPORTED: hip
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
Expand Down Expand Up @@ -165,9 +166,8 @@ void device_math_test(s::queue &deviceQueue) {

int main() {
s::queue deviceQueue;
if (deviceQueue.get_device().has(sycl::aspect::fp64)) {
device_math_test(deviceQueue);
std::cout << "Pass" << std::endl;
}
assert(deviceQueue.get_device().has(sycl::aspect::fp64) && "Requires fp64");
device_math_test(deviceQueue);
std::cout << "Pass" << std::endl;
return 0;
}
8 changes: 4 additions & 4 deletions sycl/test-e2e/DeviceLib/math_fp64_windows_test.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp64
// UNSUPPORTED: windows
// Disabled on windows due to bug VS 2019 missing math builtins

Expand Down Expand Up @@ -125,9 +126,8 @@ void device_math_test(s::queue &deviceQueue) {

int main() {
s::queue deviceQueue;
if (deviceQueue.get_device().has(sycl::aspect::fp64)) {
device_math_test(deviceQueue);
std::cout << "Pass" << std::endl;
}
assert(deviceQueue.get_device().has(sycl::aspect::fp64) && "Requires fp64");
device_math_test(deviceQueue);
std::cout << "Pass" << std::endl;
return 0;
}
8 changes: 3 additions & 5 deletions sycl/test-e2e/DeviceLib/math_test_marray_vec_fp16.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
Expand All @@ -11,11 +12,8 @@
int main() {
queue deviceQueue;

if (!deviceQueue.get_device().has(sycl::aspect::fp16)) {
std::cout << "skipping fp16 tests: requires fp16 device aspect."
<< std::endl;
return 0;
}
assert(deviceQueue.get_device().has(sycl::aspect::fp16) && "Requires fp16");

math_tests_4<half4>(deviceQueue);
math_tests_4<marray<half, 4>>(deviceQueue);
math_tests_3<half3>(deviceQueue);
Expand Down
8 changes: 4 additions & 4 deletions sycl/test-e2e/DeviceLib/std_complex_math_fp64_test.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp64
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out
Expand Down Expand Up @@ -198,8 +199,7 @@ void device_complex_test(s::queue &deviceQueue) {

int main() {
s::queue deviceQueue;
if (deviceQueue.get_device().has(sycl::aspect::fp64)) {
device_complex_test(deviceQueue);
std::cout << "Pass" << std::endl;
}
assert(deviceQueue.get_device().has(sycl::aspect::fp64) && "Requires fp64");
device_complex_test(deviceQueue);
std::cout << "Pass" << std::endl;
}
9 changes: 2 additions & 7 deletions sycl/test-e2e/ESIMD/vadd_half.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// REQUIRES: gpu
// REQUIRES: gpu && fp16
// UNSUPPORTED: gpu-intel-gen9 && windows
// UNSUPPORTED: cuda || hip
// RUN: %clangxx -fsycl %s -o %t.out
Expand Down Expand Up @@ -60,12 +60,7 @@ int main(int argc, char **argv) {
auto dev = q.get_device();
std::cout << "Running on " << dev.get_info<info::device::name>() << "\n";

if (!dev.has(sycl::aspect::fp16)) {
std::cout << "Test was skipped becasue the selected device does not "
"support sycl::aspect::fp16"
<< std::endl;
return 0;
}
assert(dev.has(sycl::aspect::fp16) && "Requires fp16");

TstT *A = malloc_shared<TstT>(Size, q);
SrcT *B = malloc_shared<SrcT>(Size, q);
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/Regression/fp16-with-unnamed-lambda.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fsycl-unnamed-lambda %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
Expand All @@ -20,8 +21,7 @@ int main() {
sycl::queue Q(AsyncHandler);

sycl::device D = Q.get_device();
if (!D.has(sycl::aspect::fp16))
return 0; // Skip the test if halfs are not supported
assert(D.has(sycl::aspect::fp16) && "Requires fp16");

sycl::buffer<sycl::half> Buf(1);

Expand Down
11 changes: 4 additions & 7 deletions sycl/test-e2e/SubGroup/broadcast_fp64.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp64
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand All @@ -15,12 +16,8 @@

int main() {
queue Queue;
if (Queue.get_device().has(sycl::aspect::fp64)) {
check<double>(Queue);
std::cout << "Test passed." << std::endl;
} else {
std::cout << "Test skipped because device doesn't support aspect::fp64"
<< std::endl;
}
assert(Queue.get_device().has(sycl::aspect::fp64) && "Requires fp64");
check<double>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
}
5 changes: 3 additions & 2 deletions sycl/test-e2e/SubGroup/reduce_fp16.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
//
Expand All @@ -10,11 +11,11 @@

int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device()) ||
!Queue.get_device().has(sycl::aspect::fp16)) {
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
assert(Queue.get_device().has(sycl::aspect::fp16) && "Requires fp16");
check<class KernelName_oMg, sycl::half>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
5 changes: 3 additions & 2 deletions sycl/test-e2e/SubGroup/reduce_fp64.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp64
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
Expand All @@ -9,11 +10,11 @@

int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device()) ||
!Queue.get_device().has(sycl::aspect::fp64)) {
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
assert(Queue.get_device().has(sycl::aspect::fp64) && "Requires fp64");
check<class KernelName_alTnImqzYasRyHjYg, double>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
5 changes: 3 additions & 2 deletions sycl/test-e2e/SubGroup/reduce_spirv13_fp16.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp16
// UNSUPPORTED: hip

// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
Expand All @@ -10,11 +11,11 @@

int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device()) ||
!Queue.get_device().has(sycl::aspect::fp16)) {
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
assert(Queue.get_device().has(sycl::aspect::fp16) && "Requires fp16");
check_mul<class MulHalf, sycl::half>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
5 changes: 3 additions & 2 deletions sycl/test-e2e/SubGroup/reduce_spirv13_fp64.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// REQUIRES: fp64
// UNSUPPORTED: hip

// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
Expand All @@ -12,11 +13,11 @@
#include <iostream>
int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device()) ||
!Queue.get_device().has(sycl::aspect::fp64)) {
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
assert(Queue.get_device().has(sycl::aspect::fp64) && "Requires fp64");
check_mul<class MulDouble, double>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
Loading