Skip to content

Commit e6009a3

Browse files
authored
Add image extensions (#257)
* add enum map support * add tracing for clGetImageRequirementsInfoEXT
1 parent 90fff00 commit e6009a3

File tree

5 files changed

+153
-0
lines changed

5 files changed

+153
-0
lines changed

intercept/src/cli_ext.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,36 @@ cl_int CL_API_CALL clGetKernelSuggestedLocalWorkSizeKHR(
829829
#define CL_PARTITION_BY_COUNTS_LIST_END_EXT 0x0
830830
#define CL_PARTITION_BY_NAMES_LIST_END_EXT -1
831831

832+
///////////////////////////////////////////////////////////////////////////////
833+
// cl_ext_image_from_buffer
834+
835+
#define CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT 0x1291
836+
837+
///////////////////////////////////////////////////////////////////////////////
838+
// cl_ext_image_requirements_info
839+
840+
typedef cl_uint cl_image_requirements_info_ext;
841+
842+
#define CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT 0x1290
843+
#define CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT 0x1292
844+
#define CL_IMAGE_REQUIREMENTS_SIZE_EXT 0x12B2
845+
#define CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT 0x12B3
846+
#define CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT 0x12B4
847+
#define CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT 0x12B5
848+
#define CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT 0x12B6
849+
850+
extern CL_API_ENTRY
851+
cl_int CL_API_CALL clGetImageRequirementsInfoEXT(
852+
cl_context context,
853+
const cl_mem_properties* properties,
854+
cl_mem_flags flags,
855+
const cl_image_format* image_format,
856+
const cl_image_desc* image_desc,
857+
cl_image_requirements_info_ext param_name,
858+
size_t param_value_size,
859+
void* param_value,
860+
size_t* param_value_size_ret);
861+
832862
///////////////////////////////////////////////////////////////////////////////
833863
// cl_altera_compiler_mode
834864

intercept/src/dispatch.cpp

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8767,6 +8767,102 @@ CL_API_ENTRY cl_int CL_API_CALL clGetKernelSuggestedLocalWorkSizeKHR(
87678767
NULL_FUNCTION_POINTER_RETURN_ERROR();
87688768
}
87698769

8770+
///////////////////////////////////////////////////////////////////////////////
8771+
//
8772+
// cl_ext_image_requirements_info
8773+
CL_API_ENTRY cl_int CL_API_CALL clGetImageRequirementsInfoEXT(
8774+
cl_context context,
8775+
const cl_mem_properties* properties,
8776+
cl_mem_flags flags,
8777+
const cl_image_format* image_format,
8778+
const cl_image_desc* image_desc,
8779+
cl_image_requirements_info_ext param_name,
8780+
size_t param_value_size,
8781+
void* param_value,
8782+
size_t* param_value_size_ret)
8783+
{
8784+
CLIntercept* pIntercept = GetIntercept();
8785+
8786+
if( pIntercept )
8787+
{
8788+
const auto& dispatchX = pIntercept->dispatchX(context);
8789+
if( dispatchX.clGetImageRequirementsInfoEXT )
8790+
{
8791+
GET_ENQUEUE_COUNTER();
8792+
if( image_desc && image_format )
8793+
{
8794+
std::string propsStr;
8795+
if( pIntercept->config().CallLogging )
8796+
{
8797+
pIntercept->getMemPropertiesString(
8798+
properties,
8799+
propsStr );
8800+
}
8801+
CALL_LOGGING_ENTER(
8802+
"context = %p, "
8803+
"properties = [ %s ], "
8804+
"flags = %s (%llX), "
8805+
"format->channel_order = %s, "
8806+
"format->channel_data_type = %s, "
8807+
"desc->type = %s, "
8808+
"desc->width = %zu, "
8809+
"desc->height = %zu, "
8810+
"desc->depth = %zu, "
8811+
"desc->array_size = %zu, "
8812+
"desc->row_pitch = %zu, "
8813+
"desc->slice_pitch = %zu, "
8814+
"desc->num_mip_levels = %u, "
8815+
"desc->num_samples = %u, "
8816+
"desc->mem_object = %p, "
8817+
"param_name = %s (%08X)",
8818+
context,
8819+
propsStr.c_str(),
8820+
pIntercept->enumName().name_mem_flags( flags ).c_str(),
8821+
flags,
8822+
pIntercept->enumName().name( image_format->image_channel_order ).c_str(),
8823+
pIntercept->enumName().name( image_format->image_channel_data_type ).c_str(),
8824+
pIntercept->enumName().name( image_desc->image_type ).c_str(),
8825+
image_desc->image_width,
8826+
image_desc->image_height,
8827+
image_desc->image_depth,
8828+
image_desc->image_array_size,
8829+
image_desc->image_row_pitch,
8830+
image_desc->image_slice_pitch,
8831+
image_desc->num_mip_levels,
8832+
image_desc->num_samples,
8833+
image_desc->mem_object,
8834+
pIntercept->enumName().name( param_name ).c_str(),
8835+
param_name );
8836+
}
8837+
else
8838+
{
8839+
CALL_LOGGING_ENTER();
8840+
}
8841+
8842+
HOST_PERFORMANCE_TIMING_START();
8843+
8844+
cl_int retVal = dispatchX.clGetImageRequirementsInfoEXT(
8845+
context,
8846+
properties,
8847+
flags,
8848+
image_format,
8849+
image_desc,
8850+
param_name,
8851+
param_value_size,
8852+
param_value,
8853+
param_value_size_ret);
8854+
8855+
HOST_PERFORMANCE_TIMING_END();
8856+
CHECK_ERROR( retVal );
8857+
CALL_LOGGING_EXIT( retVal );
8858+
8859+
return retVal;
8860+
}
8861+
}
8862+
8863+
NULL_FUNCTION_POINTER_RETURN_ERROR();
8864+
}
8865+
87708866
///////////////////////////////////////////////////////////////////////////////
87718867
//
87728868
// Unofficial cl_get_kernel_suggested_local_work_size extension:

intercept/src/dispatch.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,18 @@ struct CLdispatchX
426426
const size_t* global_work_size,
427427
size_t* suggested_local_work_size);
428428

429+
// cl_ext_image_requirements_info
430+
cl_int (CL_API_CALL *clGetImageRequirementsInfoEXT) (
431+
cl_context context,
432+
const cl_mem_properties* properties,
433+
cl_mem_flags flags,
434+
const cl_image_format* image_format,
435+
const cl_image_desc* image_desc,
436+
cl_image_requirements_info_ext param_name,
437+
size_t param_value_size,
438+
void* param_value,
439+
size_t* param_value_size_ret);
440+
429441
// Unofficial MDAPI extension:
430442
cl_command_queue (CL_API_CALL *clCreatePerfCountersCommandQueueINTEL) (
431443
cl_context context,

intercept/src/enummap.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,18 @@ CEnumNameMap::CEnumNameMap()
838838
ADD_ENUM_NAME( m_cl_int, CL_INVALID_PARTITION_COUNT_EXT );
839839
ADD_ENUM_NAME( m_cl_int, CL_INVALID_PARTITION_NAME_EXT );
840840

841+
// cl_ext_image_from_buffer
842+
ADD_ENUM_NAME( m_cl_int, CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT );
843+
844+
// cl_ext_image_requirements_info
845+
ADD_ENUM_NAME( m_cl_int, CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT );
846+
ADD_ENUM_NAME( m_cl_int, CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT );
847+
ADD_ENUM_NAME( m_cl_int, CL_IMAGE_REQUIREMENTS_SIZE_EXT );
848+
ADD_ENUM_NAME( m_cl_int, CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT );
849+
ADD_ENUM_NAME( m_cl_int, CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT );
850+
ADD_ENUM_NAME( m_cl_int, CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT );
851+
ADD_ENUM_NAME( m_cl_int, CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT );
852+
841853
// cl_altera_compiler_mode
842854
ADD_ENUM_NAME( m_cl_int, CL_CONTEXT_COMPILER_MODE_ALTERA );
843855
ADD_ENUM_NAME( m_cl_int, CL_CONTEXT_PROGRAM_EXE_LIBRARY_ROOT_ALTERA );

intercept/src/intercept.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12097,6 +12097,9 @@ void* CLIntercept::getExtensionFunctionAddress(
1209712097
// cl_khr_suggested_local_work_size
1209812098
CHECK_RETURN_EXTENSION_FUNCTION( clGetKernelSuggestedLocalWorkSizeKHR );
1209912099

12100+
// cl_ext_image_requirements_info
12101+
CHECK_RETURN_EXTENSION_FUNCTION( clGetImageRequirementsInfoEXT );
12102+
1210012103
// Unofficial MDAPI extension:
1210112104
CHECK_RETURN_EXTENSION_FUNCTION( clCreatePerfCountersCommandQueueINTEL );
1210212105
CHECK_RETURN_EXTENSION_FUNCTION( clSetPerformanceConfigurationINTEL );

0 commit comments

Comments
 (0)