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

Commit 332118a

Browse files
[SYCL] Test for device.has(aspect::atomic64) (#946)
1 parent 6980a70 commit 332118a

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// REQUIRES: cuda || hip
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
3+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
4+
5+
// XFAIL: hip
6+
// Expected failure because hip does not have atomic64 check implementation
7+
8+
#include <CL/sycl.hpp>
9+
#include <iostream>
10+
11+
using namespace sycl;
12+
13+
int main() {
14+
queue Queue;
15+
device Dev = Queue.get_device();
16+
// cout in order to ensure that the query hasn't been optimized out
17+
std::cout << Dev.has(aspect::atomic64) << std::endl;
18+
return 0;
19+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// REQUIRES: level_zero, level_zero_dev_kit
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %level_zero_options
3+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
4+
5+
#include <CL/sycl.hpp>
6+
#include <level_zero/ze_api.h>
7+
8+
using namespace sycl;
9+
10+
int main() {
11+
queue Queue;
12+
device Dev = Queue.get_device();
13+
bool Result;
14+
ze_device_module_properties_t Properties;
15+
zeDeviceGetModuleProperties(get_native<backend::ext_oneapi_level_zero>(Dev),
16+
&Properties);
17+
if (Properties.flags & ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS)
18+
Result = true;
19+
else
20+
Result = false;
21+
assert(Dev.has(aspect::atomic64) == Result &&
22+
"The Result value differs from the implemented atomic64 check on "
23+
"the L0 backend.");
24+
return 0;
25+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// REQUIRES: opencl, opencl_icd
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
3+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
4+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
5+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
6+
7+
// XFAIL: hip
8+
// Expected failure because hip does not have atomic64 check implementation
9+
10+
#include <CL/cl.h>
11+
#include <CL/sycl.hpp>
12+
13+
using namespace sycl;
14+
15+
int main() {
16+
queue Queue;
17+
device Dev = Queue.get_device();
18+
bool Result;
19+
// Get size for string of extensions
20+
size_t ExtSize;
21+
clGetDeviceInfo(get_native<backend::opencl>(Dev), CL_DEVICE_EXTENSIONS, 0,
22+
nullptr, &ExtSize);
23+
std::string ExtStr(ExtSize, '\0');
24+
25+
// Collect device extensions into string ExtStr
26+
clGetDeviceInfo(get_native<backend::opencl>(Dev), CL_DEVICE_EXTENSIONS,
27+
ExtSize, &ExtStr.front(), nullptr);
28+
29+
// Check that ExtStr has two extensions related to atomic64 support
30+
if (ExtStr.find("cl_khr_int64_base_atomics") == std::string::npos ||
31+
ExtStr.find("cl_khr_int64_extended_atomics") == std::string::npos)
32+
Result = false;
33+
else
34+
Result = true;
35+
assert(Dev.has(aspect::atomic64) == Result &&
36+
"The Result value differs from the implemented atomic64 check on "
37+
"the OpenCL backend.");
38+
return 0;
39+
}

0 commit comments

Comments
 (0)