Skip to content

Commit e9f7e03

Browse files
committed
[SYCL][PI][CUDA] 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 eb4e8b1 commit e9f7e03

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,6 +2784,11 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
27842784
// PI interface supports higher version or the same version.
27852785
strncpy(PluginInit->PluginVersion, SupportedVersion, 4);
27862786

2787+
// Set whole function table to zero to make it easier to detect if
2788+
// functions are not set up below.
2789+
std::memset(&(PluginInit->PiFunctionTable), 0,
2790+
sizeof(PluginInit->PiFunctionTable));
2791+
27872792
// Forward calls to OpenCL RT.
27882793
#define _PI_CL(pi_api, cuda_api) \
27892794
(PluginInit->PiFunctionTable).pi_api = (decltype(&::pi_api))(&cuda_api);
@@ -2838,6 +2843,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
28382843
_PI_CL(piKernelRetain, cuda_piKernelRetain)
28392844
_PI_CL(piKernelRelease, cuda_piKernelRelease)
28402845
_PI_CL(piKernelSetExecInfo, cuda_piKernelSetExecInfo)
2846+
28412847
// Event
28422848
_PI_CL(piEventCreate, cuda_piEventCreate)
28432849
_PI_CL(piEventGetInfo, cuda_piEventGetInfo)
@@ -2869,6 +2875,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
28692875
_PI_CL(piEnqueueMemImageFill, cuda_piEnqueueMemImageFill)
28702876
_PI_CL(piEnqueueMemBufferMap, cuda_piEnqueueMemBufferMap)
28712877
_PI_CL(piEnqueueMemUnmap, cuda_piEnqueueMemUnmap)
2878+
28722879
_PI_CL(piextKernelSetArgMemObj, cuda_piextKernelSetArgMemObj)
28732880

28742881
#undef _PI_CL

0 commit comments

Comments
 (0)