Skip to content

Commit 4b01d47

Browse files
authored
initial support for cl_ext_buffer_device_address (#405)
* initial support for cl_ext_buffer_device_address * fix clSetKernelArgDevicePointerEXT signature
1 parent 711f81c commit 4b01d47

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed

intercept/src/cli_ext.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,21 @@ cl_int CL_API_CALL clGetKernelSuggestedLocalWorkSizeKHR(
980980

981981
#define CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT 0x4032
982982

983+
///////////////////////////////////////////////////////////////////////////////
984+
// cl_ext_buffer_device_address
985+
986+
typedef cl_ulong cl_mem_device_address_ext;
987+
988+
extern CL_API_ENTRY
989+
cl_int CL_API_CALL clSetKernelArgDevicePointerEXT(
990+
cl_kernel kernel,
991+
cl_uint arg_index,
992+
cl_mem_device_address_ext arg_value);
993+
994+
#define CL_MEM_DEVICE_PRIVATE_ADDRESS_EXT 0x5000
995+
#define CL_MEM_DEVICE_ADDRESS_EXT 0x5001
996+
#define CL_KERNEL_EXEC_INFO_DEVICE_PTRS_EXT 0x5002
997+
983998
///////////////////////////////////////////////////////////////////////////////
984999
// cl_ext_cxx_for_opencl
9851000

intercept/src/dispatch.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8915,6 +8915,46 @@ CL_API_ENTRY cl_int CL_API_CALL clGetKernelSuggestedLocalWorkSizeKHR(
89158915
NULL_FUNCTION_POINTER_RETURN_ERROR(CL_INVALID_COMMAND_QUEUE);
89168916
}
89178917

8918+
///////////////////////////////////////////////////////////////////////////////
8919+
//
8920+
// cl_ext_buffer_device_address
8921+
CL_API_ENTRY cl_int CL_API_CALL clSetKernelArgDevicePointerEXT(
8922+
cl_kernel kernel,
8923+
cl_uint arg_index,
8924+
cl_mem_device_address_ext arg_value)
8925+
{
8926+
CLIntercept* pIntercept = GetIntercept();
8927+
8928+
if( pIntercept )
8929+
{
8930+
const auto& dispatchX = pIntercept->dispatchX(kernel);
8931+
if( dispatchX.clSetKernelArgDevicePointerEXT )
8932+
{
8933+
GET_ENQUEUE_COUNTER();
8934+
CALL_LOGGING_ENTER_KERNEL(
8935+
kernel,
8936+
"kernel = %p, index = %u, value = %" PRIx64,
8937+
kernel,
8938+
arg_index,
8939+
arg_value );
8940+
HOST_PERFORMANCE_TIMING_START();
8941+
8942+
cl_int retVal = dispatchX.clSetKernelArgDevicePointerEXT(
8943+
kernel,
8944+
arg_index,
8945+
arg_value );
8946+
8947+
HOST_PERFORMANCE_TIMING_END();
8948+
CHECK_ERROR( retVal );
8949+
CALL_LOGGING_EXIT( retVal );
8950+
8951+
return retVal;
8952+
}
8953+
}
8954+
8955+
NULL_FUNCTION_POINTER_RETURN_ERROR(CL_INVALID_KERNEL);
8956+
}
8957+
89188958
///////////////////////////////////////////////////////////////////////////////
89198959
//
89208960
// cl_ext_image_requirements_info

intercept/src/dispatch.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,12 @@ struct CLdispatchX
487487
const size_t* global_work_size,
488488
size_t* suggested_local_work_size);
489489

490+
// cl_ext_buffer_device_address
491+
cl_int (CL_API_CALL *clSetKernelArgDevicePointerEXT) (
492+
cl_kernel kernel,
493+
cl_uint arg_index,
494+
cl_mem_device_address_ext arg_value);
495+
490496
// cl_ext_image_requirements_info
491497
cl_int (CL_API_CALL *clGetImageRequirementsInfoEXT) (
492498
cl_context context,

intercept/src/enummap.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,11 @@ CEnumNameMap::CEnumNameMap()
882882
// cl_ext_atomic_counters
883883
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_MAX_ATOMIC_COUNTERS_EXT );
884884

885+
// cl_ext_buffer_device_address
886+
ADD_ENUM_NAME( m_cl_int, CL_MEM_DEVICE_PRIVATE_ADDRESS_EXT );
887+
ADD_ENUM_NAME( m_cl_int, CL_MEM_DEVICE_ADDRESS_EXT );
888+
ADD_ENUM_NAME( m_cl_int, CL_KERNEL_EXEC_INFO_DEVICE_PTRS_EXT );
889+
885890
// cl_ext_cxx_for_opencl
886891
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_CXX_FOR_OPENCL_NUMERIC_VERSION_EXT );
887892

intercept/src/intercept.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,6 +2446,14 @@ void CLIntercept::getMemPropertiesString(
24462446
properties += 2;
24472447
}
24482448
break;
2449+
case CL_MEM_DEVICE_PRIVATE_ADDRESS_EXT:
2450+
{
2451+
auto pb = (const cl_bool*)( properties + 1 );
2452+
cl_bool value = pb[0];
2453+
str += enumName().name_bool( value );
2454+
properties += 2;
2455+
}
2456+
break;
24492457
default:
24502458
{
24512459
CLI_SPRINTF( s, 256, "<Unknown %08X!>", (cl_uint)property );
@@ -13410,6 +13418,9 @@ void* CLIntercept::getExtensionFunctionAddress(
1341013418
// cl_khr_suggested_local_work_size
1341113419
CHECK_RETURN_EXTENSION_FUNCTION( clGetKernelSuggestedLocalWorkSizeKHR );
1341213420

13421+
// cl_ext_buffer_device_address
13422+
CHECK_RETURN_EXTENSION_FUNCTION( clSetKernelArgDevicePointerEXT );
13423+
1341313424
// cl_ext_image_requirements_info
1341413425
CHECK_RETURN_EXTENSION_FUNCTION( clGetImageRequirementsInfoEXT );
1341513426

0 commit comments

Comments
 (0)