Skip to content
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/include/CL/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,9 @@ __SYCL_EXPORT pi_result piProgramRelease(pi_program program);

/// Sets a specialization constant to a specific value.
///
/// Note: Only used when specialization constants are natively supported (SPIR-V
/// binaries), and not when they are emulated (AOT binaries).
///
/// \param prog the program object which will use the value
/// \param spec_id integer ID of the constant
/// \param spec_size size of the value
Expand Down
11 changes: 11 additions & 0 deletions sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3436,6 +3436,15 @@ pi_result cuda_piKernelSetExecInfo(pi_kernel, pi_kernel_exec_info, size_t,
return PI_SUCCESS;
}

pi_result cuda_piextProgramSetSpecializationConstant(pi_program, pi_uint32,
size_t, const void *) {
// This entry point is only used for native specialization constants (SPIR-V),
// and the CUDA plugin is AOT only so this entry point is not supported.
cl::sycl::detail::pi::die(
"Native specialization constants are not supported");
return {};
}

pi_result cuda_piextKernelSetArgPointer(pi_kernel kernel, pi_uint32 arg_index,
size_t arg_size,
const void *arg_value) {
Expand Down Expand Up @@ -5057,6 +5066,8 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
_PI_CL(piKernelRetain, cuda_piKernelRetain)
_PI_CL(piKernelRelease, cuda_piKernelRelease)
_PI_CL(piKernelSetExecInfo, cuda_piKernelSetExecInfo)
_PI_CL(piextProgramSetSpecializationConstant,
cuda_piextProgramSetSpecializationConstant)
_PI_CL(piextKernelSetArgPointer, cuda_piextKernelSetArgPointer)
_PI_CL(piextKernelCreateWithNativeHandle,
cuda_piextKernelCreateWithNativeHandle)
Expand Down
11 changes: 11 additions & 0 deletions sycl/plugins/hip/pi_hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3375,6 +3375,15 @@ pi_result hip_piKernelSetExecInfo(pi_kernel kernel,
return PI_SUCCESS;
}

pi_result hip_piextProgramSetSpecializationConstant(pi_program, pi_uint32,
size_t, const void *) {
// This entry point is only used for native specialization constants (SPIR-V),
// and the HIP plugin is AOT only so this entry point is not supported.
cl::sycl::detail::pi::die(
"Native specialization constants are not supported");
return {};
}

pi_result hip_piextKernelSetArgPointer(pi_kernel kernel, pi_uint32 arg_index,
size_t arg_size, const void *arg_value) {
kernel->set_kernel_arg(arg_index, arg_size, arg_value);
Expand Down Expand Up @@ -4959,6 +4968,8 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
_PI_CL(piKernelRetain, hip_piKernelRetain)
_PI_CL(piKernelRelease, hip_piKernelRelease)
_PI_CL(piKernelSetExecInfo, hip_piKernelSetExecInfo)
_PI_CL(piextProgramSetSpecializationConstant,
hip_piextProgramSetSpecializationConstant)
_PI_CL(piextKernelSetArgPointer, hip_piextKernelSetArgPointer)
// Event
_PI_CL(piEventCreate, hip_piEventCreate)
Expand Down
34 changes: 16 additions & 18 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1855,24 +1855,22 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage,
auto [NativePrg, DeviceCodeWasInCache] = getOrCreatePIProgram(
Img, Context, Devs[0], CompileOpts + LinkOpts, SpecConsts);

if (!DeviceCodeWasInCache) {
if (InputImpl->get_bin_image_ref()->supportsSpecConstants())
enableITTAnnotationsIfNeeded(NativePrg, Plugin);

{
std::lock_guard<std::mutex> Lock{InputImpl->get_spec_const_data_lock()};
const std::map<std::string,
std::vector<device_image_impl::SpecConstDescT>>
&SpecConstData = InputImpl->get_spec_const_data_ref();

for (const auto &DescPair : SpecConstData) {
for (const device_image_impl::SpecConstDescT &SpecIDDesc :
DescPair.second) {
if (SpecIDDesc.IsSet) {
Plugin.call<PiApiKind::piextProgramSetSpecializationConstant>(
NativePrg, SpecIDDesc.ID, SpecIDDesc.Size,
SpecConsts.data() + SpecIDDesc.BlobOffset);
}
if (!DeviceCodeWasInCache &&
InputImpl->get_bin_image_ref()->supportsSpecConstants()) {
enableITTAnnotationsIfNeeded(NativePrg, Plugin);

std::lock_guard<std::mutex> Lock{InputImpl->get_spec_const_data_lock()};
const std::map<std::string,
std::vector<device_image_impl::SpecConstDescT>>
&SpecConstData = InputImpl->get_spec_const_data_ref();

for (const auto &DescPair : SpecConstData) {
for (const device_image_impl::SpecConstDescT &SpecIDDesc :
DescPair.second) {
if (SpecIDDesc.IsSet) {
Plugin.call<PiApiKind::piextProgramSetSpecializationConstant>(
NativePrg, SpecIDDesc.ID, SpecIDDesc.Size,
SpecConsts.data() + SpecIDDesc.BlobOffset);
}
}
}
Expand Down