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

[SYCL] Test for device.has(aspect::atomic64) #946

Merged
merged 6 commits into from
Sep 6, 2022
Merged
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
19 changes: 19 additions & 0 deletions SYCL/AtomicRef/device_has_aspect_atomic64_cuda_and_hip.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// REQUIRES: cuda || hip
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out

// XFAIL: hip
// Expected failure because hip does not have atomic64 check implementation

#include <CL/sycl.hpp>
#include <iostream>

using namespace sycl;

int main() {
queue Queue;
device Dev = Queue.get_device();
// cout in order to ensure that the query hasn't been optimized out
std::cout << Dev.has(aspect::atomic64) << std::endl;
return 0;
}
25 changes: 25 additions & 0 deletions SYCL/AtomicRef/device_has_aspect_atomic64_level_zero.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// REQUIRES: level_zero, level_zero_dev_kit
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %level_zero_options
// RUN: %GPU_RUN_PLACEHOLDER %t.out

#include <CL/sycl.hpp>
#include <level_zero/ze_api.h>

using namespace sycl;

int main() {
queue Queue;
device Dev = Queue.get_device();
bool Result;
ze_device_module_properties_t Properties;
zeDeviceGetModuleProperties(get_native<backend::ext_oneapi_level_zero>(Dev),
&Properties);
if (Properties.flags & ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS)
Result = true;
else
Result = false;
assert(Dev.has(aspect::atomic64) == Result &&
"The Result value differs from the implemented atomic64 check on "
"the L0 backend.");
return 0;
}
39 changes: 39 additions & 0 deletions SYCL/AtomicRef/device_has_aspect_atomic64_opencl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// REQUIRES: opencl, opencl_icd
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out %opencl_lib
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out

// XFAIL: hip
// Expected failure because hip does not have atomic64 check implementation

#include <CL/cl.h>
#include <CL/sycl.hpp>

using namespace sycl;

int main() {
queue Queue;
device Dev = Queue.get_device();
bool Result;
// Get size for string of extensions
size_t ExtSize;
clGetDeviceInfo(get_native<backend::opencl>(Dev), CL_DEVICE_EXTENSIONS, 0,
nullptr, &ExtSize);
std::string ExtStr(ExtSize, '\0');

// Collect device extensions into string ExtStr
clGetDeviceInfo(get_native<backend::opencl>(Dev), CL_DEVICE_EXTENSIONS,
ExtSize, &ExtStr.front(), nullptr);

// Check that ExtStr has two extensions related to atomic64 support
if (ExtStr.find("cl_khr_int64_base_atomics") == std::string::npos ||
ExtStr.find("cl_khr_int64_extended_atomics") == std::string::npos)
Result = false;
else
Result = true;
assert(Dev.has(aspect::atomic64) == Result &&
"The Result value differs from the implemented atomic64 check on "
"the OpenCL backend.");
return 0;
}