Skip to content

[SYCL][CUDA] Allow varying program metadata in CUDA backend #7555

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
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
15 changes: 11 additions & 4 deletions sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,13 +685,20 @@ pi_result _pi_program::set_metadata(const pi_device_binary_property *metadata,
if (get_kernel_metadata(metadataElementName,
__SYCL_PI_PROGRAM_METADATA_TAG_REQD_WORK_GROUP_SIZE,
kernelName)) {
assert(metadataElement->ValSize ==
sizeof(std::uint64_t) + sizeof(std::uint32_t) * 3 &&
size_t MDElemsSize = metadataElement->ValSize - sizeof(std::uint64_t);

// Expect between 1 and 3 32-bit integer values.
assert(MDElemsSize >= sizeof(std::uint32_t) &&
MDElemsSize <= sizeof(std::uint32_t) * 3 &&
"Unexpected size for reqd_work_group_size metadata");

// Get pointer to data, skipping 64-bit size at the start of the data.
const auto *reqdWorkGroupElements =
reinterpret_cast<const std::uint32_t *>(metadataElement->ValAddr) + 2;
const char *ValuePtr =
reinterpret_cast<const char *>(metadataElement->ValAddr) +
sizeof(std::uint64_t);
// Read values and pad with 1's for values not present.
std::uint32_t reqdWorkGroupElements[] = {1, 1, 1};
std::memcpy(reqdWorkGroupElements, ValuePtr, MDElemsSize);
kernelReqdWorkGroupSizeMD_[kernelName] =
std::make_tuple(reqdWorkGroupElements[0], reqdWorkGroupElements[1],
reqdWorkGroupElements[2]);
Expand Down