diff --git a/SYCL/AtomicRef/device_has_aspect_atomic64_cuda_and_hip.cpp b/SYCL/AtomicRef/device_has_aspect_atomic64_cuda_and_hip.cpp new file mode 100644 index 0000000000..7d5092178e --- /dev/null +++ b/SYCL/AtomicRef/device_has_aspect_atomic64_cuda_and_hip.cpp @@ -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 +#include + +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; +} diff --git a/SYCL/AtomicRef/device_has_aspect_atomic64_level_zero.cpp b/SYCL/AtomicRef/device_has_aspect_atomic64_level_zero.cpp new file mode 100644 index 0000000000..3a461ade8d --- /dev/null +++ b/SYCL/AtomicRef/device_has_aspect_atomic64_level_zero.cpp @@ -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 +#include + +using namespace sycl; + +int main() { + queue Queue; + device Dev = Queue.get_device(); + bool Result; + ze_device_module_properties_t Properties; + zeDeviceGetModuleProperties(get_native(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; +} diff --git a/SYCL/AtomicRef/device_has_aspect_atomic64_opencl.cpp b/SYCL/AtomicRef/device_has_aspect_atomic64_opencl.cpp new file mode 100644 index 0000000000..6b8fd12922 --- /dev/null +++ b/SYCL/AtomicRef/device_has_aspect_atomic64_opencl.cpp @@ -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 +#include + +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(Dev), CL_DEVICE_EXTENSIONS, 0, + nullptr, &ExtSize); + std::string ExtStr(ExtSize, '\0'); + + // Collect device extensions into string ExtStr + clGetDeviceInfo(get_native(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; +}