Skip to content

[SYCL] Add check for atomic64 support #5430

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

Merged
merged 9 commits into from
Mar 21, 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
3 changes: 3 additions & 0 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2239,6 +2239,9 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
// std::array<std::byte, 16>. For details about this extension,
// see sycl/doc/extensions/supported/sycl_ext_intel_device_info.md.
return ReturnValue(Device->ZeDeviceProperties->uuid.id);
case PI_DEVICE_INFO_ATOMIC_64:
return ReturnValue(pi_bool{Device->ZeDeviceModuleProperties->flags &
ZE_DEVICE_MODULE_FLAG_INT64_ATOMICS});
case PI_DEVICE_INFO_EXTENSIONS: {
// Convention adopted from OpenCL:
// "Returns a space separated list of extension names (the extension
Expand Down
17 changes: 15 additions & 2 deletions sycl/plugins/opencl/pi_opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,24 @@ pi_result piDeviceGetInfo(pi_device device, pi_device_info paramName,
// For details about Intel UUID extension, see
// sycl/doc/extensions/supported/sycl_ext_intel_device_info.md
case PI_DEVICE_INFO_UUID:
// TODO: Implement.
case PI_DEVICE_INFO_ATOMIC_64:
case PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES:
case PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES:
return PI_INVALID_VALUE;
case PI_DEVICE_INFO_ATOMIC_64: {
size_t extSize;
cl_bool result = clGetDeviceInfo(
cast<cl_device_id>(device), CL_DEVICE_EXTENSIONS, 0, nullptr, &extSize);
std::string extStr(extSize, '\0');
result = clGetDeviceInfo(cast<cl_device_id>(device), CL_DEVICE_EXTENSIONS,
extSize, &extStr.front(), nullptr);
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;
std::memcpy(paramValue, &result, sizeof(cl_bool));
return PI_SUCCESS;
}
case PI_DEVICE_INFO_IMAGE_SRGB: {
cl_bool result = true;
std::memcpy(paramValue, &result, sizeof(cl_bool));
Expand Down
17 changes: 0 additions & 17 deletions sycl/source/detail/device_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,6 @@ template <> struct get_device_info<bool, info::device::queue_profiling> {
}
};

// Specialization for atomic64 that is necessary because
// PI_DEVICE_INFO_ATOMIC_64 is currently only implemented for the cuda backend.
template <> struct get_device_info<bool, info::device::atomic64> {
static bool get(RT::PiDevice dev, const plugin &Plugin) {

bool result = false;

RT::PiResult Err = Plugin.call_nocheck<PiApiKind::piDeviceGetInfo>(
dev, pi::cast<RT::PiDeviceInfo>(info::device::atomic64), sizeof(result),
&result, nullptr);
if (Err != PI_SUCCESS) {
return false;
}
return result;
}
};

// Specialization for atomic_memory_order_capabilities, PI returns a bitfield
template <>
struct get_device_info<std::vector<memory_order>,
Expand Down