From fbbabc119db9dbe575c80889aa7f364fa7721f13 Mon Sep 17 00:00:00 2001 From: Bjoern Knafla Date: Wed, 5 Feb 2020 22:15:24 +0000 Subject: [PATCH] [SYCL][CUDA] Multiple fixes Fix device query for image support. Fix typo in comment. 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 --- sycl/include/CL/sycl/detail/pi.hpp | 2 +- sycl/plugins/cuda/pi_cuda.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sycl/include/CL/sycl/detail/pi.hpp b/sycl/include/CL/sycl/detail/pi.hpp index a8105d2cf4acd..2ecf2aebdc679 100644 --- a/sycl/include/CL/sycl/detail/pi.hpp +++ b/sycl/include/CL/sycl/detail/pi.hpp @@ -114,7 +114,7 @@ std::string platformInfoToString(pi_platform_info info); template To cast(From value); // Holds the PluginInformation for the plugin that is bound. -// Currently a global varaible is used to store OpenCL plugin information to be +// Currently a global variable is used to store OpenCL plugin information to be // used with SYCL Interoperability Constructors. extern std::shared_ptr GlobalPlugin; diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 108e7adb176f0..fdc6c78a02e9c 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -893,7 +893,8 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, pi_uint64{max_alloc}); } case PI_DEVICE_INFO_IMAGE_SUPPORT: { - return getInfo(param_value_size, param_value, param_value_size_ret, false); + return getInfo(param_value_size, param_value, param_value_size_ret, + PI_FALSE); } case PI_DEVICE_INFO_MAX_READ_IMAGE_ARGS: { return getInfo(param_value_size, param_value, param_value_size_ret, 0); @@ -2921,6 +2922,11 @@ pi_result piPluginInit(pi_plugin *PluginInit) { // PI interface supports higher version or the same version. strncpy(PluginInit->PluginVersion, SupportedVersion, 4); + // Set whole function table to zero to make it easier to detect if + // functions are not set up below. + std::memset(&(PluginInit->PiFunctionTable), 0, + sizeof(PluginInit->PiFunctionTable)); + // Forward calls to OpenCL RT. #define _PI_CL(pi_api, cuda_api) \ (PluginInit->PiFunctionTable).pi_api = (decltype(&::pi_api))(&cuda_api); @@ -2975,6 +2981,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) { _PI_CL(piKernelRetain, cuda_piKernelRetain) _PI_CL(piKernelRelease, cuda_piKernelRelease) _PI_CL(piKernelSetExecInfo, cuda_piKernelSetExecInfo) + // Event _PI_CL(piEventCreate, cuda_piEventCreate) _PI_CL(piEventGetInfo, cuda_piEventGetInfo) @@ -3006,6 +3013,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) { _PI_CL(piEnqueueMemImageFill, cuda_piEnqueueMemImageFill) _PI_CL(piEnqueueMemBufferMap, cuda_piEnqueueMemBufferMap) _PI_CL(piEnqueueMemUnmap, cuda_piEnqueueMemUnmap) + _PI_CL(piextKernelSetArgMemObj, cuda_piextKernelSetArgMemObj) #undef _PI_CL