Skip to content

Commit 0d56408

Browse files
authored
[SYCL][CUDA] Fix device query for image support (#1299)
Init plugin function table to 0. As the PI plugin function table can grow without the CUDA plugin being adapted, set the whole function pointer table to 0 to trigger crashes on calling functions that are not set. Signed-off-by: Bjoern Knafla <bjoern@codeplay.com>
1 parent 1f3bd3d commit 0d56408

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

sycl/include/CL/sycl/detail/pi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ std::string platformInfoToString(pi_platform_info info);
114114
template <class To, class From> To cast(From value);
115115

116116
// Holds the PluginInformation for the plugin that is bound.
117-
// Currently a global varaible is used to store OpenCL plugin information to be
117+
// Currently a global variable is used to store OpenCL plugin information to be
118118
// used with SYCL Interoperability Constructors.
119119
extern std::shared_ptr<plugin> GlobalPlugin;
120120

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,8 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
917917
pi_uint64{max_alloc});
918918
}
919919
case PI_DEVICE_INFO_IMAGE_SUPPORT: {
920-
return getInfo(param_value_size, param_value, param_value_size_ret, false);
920+
return getInfo(param_value_size, param_value, param_value_size_ret,
921+
PI_FALSE);
921922
}
922923
case PI_DEVICE_INFO_MAX_READ_IMAGE_ARGS: {
923924
return getInfo(param_value_size, param_value, param_value_size_ret, 0);
@@ -3021,6 +3022,11 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
30213022
// PI interface supports higher version or the same version.
30223023
strncpy(PluginInit->PluginVersion, SupportedVersion, 4);
30233024

3025+
// Set whole function table to zero to make it easier to detect if
3026+
// functions are not set up below.
3027+
std::memset(&(PluginInit->PiFunctionTable), 0,
3028+
sizeof(PluginInit->PiFunctionTable));
3029+
30243030
// Forward calls to OpenCL RT.
30253031
#define _PI_CL(pi_api, cuda_api) \
30263032
(PluginInit->PiFunctionTable).pi_api = (decltype(&::pi_api))(&cuda_api);
@@ -3075,6 +3081,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
30753081
_PI_CL(piKernelRetain, cuda_piKernelRetain)
30763082
_PI_CL(piKernelRelease, cuda_piKernelRelease)
30773083
_PI_CL(piKernelSetExecInfo, cuda_piKernelSetExecInfo)
3084+
30783085
// Event
30793086
_PI_CL(piEventCreate, cuda_piEventCreate)
30803087
_PI_CL(piEventGetInfo, cuda_piEventGetInfo)
@@ -3106,6 +3113,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
31063113
_PI_CL(piEnqueueMemImageFill, cuda_piEnqueueMemImageFill)
31073114
_PI_CL(piEnqueueMemBufferMap, cuda_piEnqueueMemBufferMap)
31083115
_PI_CL(piEnqueueMemUnmap, cuda_piEnqueueMemUnmap)
3116+
31093117
_PI_CL(piextKernelSetArgMemObj, cuda_piextKernelSetArgMemObj)
31103118

31113119
#undef _PI_CL

0 commit comments

Comments
 (0)