Skip to content

Commit 7f0f4f8

Browse files
committed
OpenCL ICD Loader updates for OpenCL 3.1
1 parent b1c5753 commit 7f0f4f8

18 files changed

Lines changed: 192 additions & 11 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ else ()
165165
endif ()
166166

167167
set (OPENCL_COMPILE_DEFINITIONS
168-
CL_TARGET_OPENCL_VERSION=300
168+
CL_TARGET_OPENCL_VERSION=310
169169
CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES
170170
OPENCL_ICD_LOADER_VERSION_MAJOR=3
171171
OPENCL_ICD_LOADER_VERSION_MINOR=0

loader/icd_dispatch_generated.c

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5191,6 +5191,57 @@ static cl_mem CL_API_CALL clCreateImageWithProperties_disp(
51915191

51925192
///////////////////////////////////////////////////////////////////////////////
51935193

5194+
CL_API_ENTRY cl_int CL_API_CALL clGetKernelSuggestedLocalWorkSize(
5195+
cl_command_queue command_queue,
5196+
cl_kernel kernel,
5197+
cl_uint work_dim,
5198+
const size_t* global_work_offset,
5199+
const size_t* global_work_size,
5200+
size_t* suggested_local_work_size)
5201+
{
5202+
#if defined(CL_ENABLE_LAYERS)
5203+
if (khrFirstLayer)
5204+
return khrFirstLayer->dispatch.clGetKernelSuggestedLocalWorkSize(
5205+
command_queue,
5206+
kernel,
5207+
work_dim,
5208+
global_work_offset,
5209+
global_work_size,
5210+
suggested_local_work_size);
5211+
#endif // defined(CL_ENABLE_LAYERS)
5212+
KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE);
5213+
return KHR_ICD2_DISPATCH(command_queue)->clGetKernelSuggestedLocalWorkSize(
5214+
command_queue,
5215+
kernel,
5216+
work_dim,
5217+
global_work_offset,
5218+
global_work_size,
5219+
suggested_local_work_size);
5220+
}
5221+
5222+
///////////////////////////////////////////////////////////////////////////////
5223+
#if defined(CL_ENABLE_LAYERS)
5224+
static cl_int CL_API_CALL clGetKernelSuggestedLocalWorkSize_disp(
5225+
cl_command_queue command_queue,
5226+
cl_kernel kernel,
5227+
cl_uint work_dim,
5228+
const size_t* global_work_offset,
5229+
const size_t* global_work_size,
5230+
size_t* suggested_local_work_size)
5231+
{
5232+
KHR_ICD_VALIDATE_HANDLE_RETURN_ERROR(command_queue, CL_INVALID_COMMAND_QUEUE);
5233+
return KHR_ICD2_DISPATCH(command_queue)->clGetKernelSuggestedLocalWorkSize(
5234+
command_queue,
5235+
kernel,
5236+
work_dim,
5237+
global_work_offset,
5238+
global_work_size,
5239+
suggested_local_work_size);
5240+
}
5241+
#endif // defined(CL_ENABLE_LAYERS)
5242+
5243+
///////////////////////////////////////////////////////////////////////////////
5244+
51945245
// cl_ext_device_fission
51955246

51965247
CL_API_ENTRY cl_int CL_API_CALL clReleaseDeviceEXT(
@@ -7026,7 +7077,10 @@ const struct _cl_icd_dispatch khrMainDispatch = {
70267077
/* OpenCL 3.0 */
70277078
&clCreateBufferWithProperties_disp,
70287079
&clCreateImageWithProperties_disp,
7029-
&clSetContextDestructorCallback_disp
7080+
&clSetContextDestructorCallback_disp,
7081+
7082+
/* OpenCL 3.1 */
7083+
&clGetKernelSuggestedLocalWorkSize_disp,
70307084
}
70317085
;
70327086
#endif // defined(CL_ENABLE_LAYERS)
@@ -8621,6 +8675,22 @@ static cl_mem CL_API_CALL clCreateImageWithProperties_unsupp(
86218675
(void)errcode_ret;
86228676
KHR_ICD_ERROR_RETURN_HANDLE(CL_INVALID_OPERATION);
86238677
}
8678+
static cl_int CL_API_CALL clGetKernelSuggestedLocalWorkSize_unsupp(
8679+
cl_command_queue command_queue,
8680+
cl_kernel kernel,
8681+
cl_uint work_dim,
8682+
const size_t* global_work_offset,
8683+
const size_t* global_work_size,
8684+
size_t* suggested_local_work_size)
8685+
{
8686+
(void)command_queue;
8687+
(void)kernel;
8688+
(void)work_dim;
8689+
(void)global_work_offset;
8690+
(void)global_work_size;
8691+
(void)suggested_local_work_size;
8692+
KHR_ICD_ERROR_RETURN_ERROR(CL_INVALID_OPERATION);
8693+
}
86248694

86258695
///////////////////////////////////////////////////////////////////////////////
86268696
// cl_ext_device_fission
@@ -9373,7 +9443,10 @@ const struct _cl_icd_dispatch khrDeinitDispatch = {
93739443
/* OpenCL 3.0 */
93749444
&clCreateBufferWithProperties_unsupp,
93759445
&clCreateImageWithProperties_unsupp,
9376-
&clSetContextDestructorCallback_unsupp
9446+
&clSetContextDestructorCallback_unsupp,
9447+
9448+
/* OpenCL 3.1 */
9449+
&clGetKernelSuggestedLocalWorkSize_unsupp,
93779450
}
93789451
;
93799452
#endif // defined(CL_ENABLE_LAYERS)
@@ -9728,6 +9801,9 @@ void khrIcd2PopulateDispatchTable(
97289801
dispatch->clCreateImageWithProperties = (clCreateImageWithProperties_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clCreateImageWithProperties");
97299802
if (!dispatch->clCreateImageWithProperties)
97309803
dispatch->clCreateImageWithProperties = &clCreateImageWithProperties_unsupp;
9804+
dispatch->clGetKernelSuggestedLocalWorkSize = (clGetKernelSuggestedLocalWorkSize_t *)(size_t)p_clIcdGetFunctionAddressForPlatform(platform, "clGetKernelSuggestedLocalWorkSize");
9805+
if (!dispatch->clGetKernelSuggestedLocalWorkSize)
9806+
dispatch->clGetKernelSuggestedLocalWorkSize = &clGetKernelSuggestedLocalWorkSize_unsupp;
97319807

97329808
///////////////////////////////////////////////////////////////////////////////
97339809
// cl_ext_device_fission

loader/icd_version.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
#if CL_TARGET_OPENCL_VERSION == 300
5151
#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "3.0"
5252
#endif
53+
#if CL_TARGET_OPENCL_VERSION == 310
54+
#define OPENCL_ICD_LOADER_OCL_VERSION_NUMBER "3.1"
55+
#endif
5356

5457
#define OPENCL_ICD_LOADER_OCL_VERSION_STRING \
5558
"OpenCL " OPENCL_ICD_LOADER_OCL_VERSION_NUMBER

loader/linux/icd_exports.map

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,8 @@ OPENCL_3.0 {
170170
clCreateImageWithProperties;
171171
clSetContextDestructorCallback;
172172
} OPENCL_2.2;
173+
174+
OPENCL_3.1 {
175+
global:
176+
clGetKernelSuggestedLocalWorkSize;
177+
} OPENCL_3.0;

loader/windows/OpenCL-mingw-i686.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,6 @@ clSetProgramSpecializationConstant@16 == clSetProgramSpecializationConstant
160160
clCreateBufferWithProperties@28 == clCreateBufferWithProperties
161161
clCreateImageWithProperties@32 == clCreateImageWithProperties
162162
clSetContextDestructorCallback@12 == clSetContextDestructorCallback
163+
164+
; OpenCL 3.1 API
165+
clGetKernelSuggestedLocalWorkSize@24 == clGetKernelSuggestedLocalWorkSize

loader/windows/OpenCL.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,6 @@ clSetProgramSpecializationConstant
164164
clCreateBufferWithProperties
165165
clCreateImageWithProperties
166166
clSetContextDestructorCallback
167+
168+
; OpenCL 3.1 API
169+
clGetKernelSuggestedLocalWorkSize

scripts/dispatch_table.mako

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,8 @@
200200
/* OpenCL 3.0 */
201201
&clCreateBufferWithProperties_${suffix},
202202
&clCreateImageWithProperties_${suffix},
203-
&clSetContextDestructorCallback_${suffix}
203+
&clSetContextDestructorCallback_${suffix},
204+
205+
/* OpenCL 3.1 */
206+
&clGetKernelSuggestedLocalWorkSize_${suffix},
204207
}

test/driver_stub/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ add_library (OpenCLDriverStub SHARED ${OPENCL_DRIVER_STUB_SOURCES})
99

1010
target_link_libraries (OpenCLDriverStub IcdLog OpenCL::Headers)
1111

12-
target_compile_definitions (OpenCLDriverStub PRIVATE CL_TARGET_OPENCL_VERSION=300)
12+
target_compile_definitions (OpenCLDriverStub PRIVATE CL_TARGET_OPENCL_VERSION=310)
1313

1414
set (OPENCL_DRIVER_STUB_ICD2_SOURCES cl.c cl_ext.c cl_gl.c icd.c)
1515

@@ -21,4 +21,4 @@ add_library (OpenCLDriverStubICD2 SHARED ${OPENCL_DRIVER_STUB_ICD2_SOURCES})
2121

2222
target_link_libraries (OpenCLDriverStubICD2 IcdLog OpenCL::Headers)
2323

24-
target_compile_definitions (OpenCLDriverStubICD2 PRIVATE CL_TARGET_OPENCL_VERSION=300 CL_ENABLE_ICD2=1)
24+
target_compile_definitions (OpenCLDriverStubICD2 PRIVATE CL_TARGET_OPENCL_VERSION=310 CL_ENABLE_ICD2=1)

test/driver_stub/cl.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,27 @@ clGetKernelInfo(cl_kernel kernel ,
10901090
return return_value;
10911091
}
10921092

1093+
CL_API_ENTRY cl_int CL_API_CALL
1094+
clGetKernelSuggestedLocalWorkSize(cl_command_queue command_queue,
1095+
cl_kernel kernel,
1096+
cl_uint work_dim,
1097+
const size_t * global_work_offset,
1098+
const size_t * global_work_size,
1099+
size_t * suggested_local_work_size) CL_API_SUFFIX__VERSION_3_1
1100+
{
1101+
cl_int return_value = CL_OUT_OF_RESOURCES;
1102+
test_icd_stub_log("clGetKernelSuggestedLocalWorkSize(%p, %p, %u, %p, %p, %p)\n",
1103+
command_queue,
1104+
kernel,
1105+
work_dim,
1106+
global_work_offset,
1107+
global_work_size,
1108+
suggested_local_work_size);
1109+
1110+
test_icd_stub_log("Value returned: %d\n", return_value);
1111+
return return_value;
1112+
}
1113+
10931114
CL_API_ENTRY cl_int CL_API_CALL
10941115
clGetKernelArgInfo(cl_kernel kernel ,
10951116
cl_uint arg_indx ,

test/driver_stub/icd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable)
248248
ICD_DISPATCH_TABLE_ENTRY ( clCreateImageWithProperties );
249249
ICD_DISPATCH_TABLE_ENTRY ( clSetContextDestructorCallback );
250250

251+
/* OpenCL 3.1 */
252+
ICD_DISPATCH_TABLE_ENTRY ( clGetKernelSuggestedLocalWorkSize );
253+
251254
// return success
252255
*outDispatchTable = dispatchTable;
253256
return CL_SUCCESS;
@@ -471,6 +474,9 @@ void * CL_API_CALL clIcdGetFunctionAddressForPlatformKHR(
471474
ICD_GET_FUNCTION_ADDRESS ( clCreateImageWithProperties );
472475
ICD_GET_FUNCTION_ADDRESS ( clSetContextDestructorCallback );
473476

477+
/* OpenCL 3.1 */
478+
ICD_GET_FUNCTION_ADDRESS ( clGetKernelSuggestedLocalWorkSize );
479+
474480
return NULL;
475481
}
476482

0 commit comments

Comments
 (0)