Skip to content

Commit e76c699

Browse files
authored
emulated support for cl_khr_extended_versioning (#126)
* emulated support for cl_khr_extended_versioning * fix enum name in assert
1 parent cb3ddd7 commit e76c699

File tree

6 files changed

+586
-70
lines changed

6 files changed

+586
-70
lines changed

docs/controls.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump
389389

390390
If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump kernel ISA binaries for every kernel, if supported. An ISA binaries can decoded into ISA text with a disassembler. The filename will have the form "CLI\_\<Program Number\>\_\<Unique Program Hash Code\>\_\<Compile Count\>\_\<Unique Build Options Hash Code\>\_\<Device Type\>\_\<Kernel Name\>.isabin".
391391

392+
### Controls for Emulating Features
393+
394+
##### `Emulate_cl_khr_extended_versioning` (bool)
395+
396+
If set to a nonzero value, the Intercept Layer for OpenCL Applications will emulate support for the cl\_khr\_extended\_versioning extension.
397+
392398
### Controls for Automatically Creating SPIR-V Modules
393399

394400
##### `AutoCreateSPIRV` (bool)

intercept/src/cli_ext.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,33 @@ cl_command_queue CL_API_CALL clCreateCommandQueueWithPropertiesKHR(
406406
#define CL_DEVICE_ILS_WITH_VERSION_KHR 0x1061
407407
#define CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR 0x1062
408408

409+
#define CL_VERSION_MAJOR_BITS_KHR (10)
410+
#define CL_VERSION_MINOR_BITS_KHR (10)
411+
#define CL_VERSION_PATCH_BITS_KHR (12)
412+
413+
#define CL_VERSION_MAJOR_MASK_KHR ((1 << CL_VERSION_MAJOR_BITS_KHR) - 1)
414+
#define CL_VERSION_MINOR_MASK_KHR ((1 << CL_VERSION_MINOR_BITS_KHR) - 1)
415+
#define CL_VERSION_PATCH_MASK_KHR ((1 << CL_VERSION_PATCH_BITS_KHR) - 1)
416+
417+
#define CL_VERSION_MAJOR_KHR(version) ((version) >> (CL_VERSION_MINOR_BITS_KHR + CL_VERSION_PATCH_BITS_KHR))
418+
#define CL_VERSION_MINOR_KHR(version) (((version) >> CL_VERSION_PATCH_BITS_KHR) & CL_VERSION_MINOR_MASK_KHR)
419+
#define CL_VERSION_PATCH_KHR(version) ((version) & CL_VERSION_PATCH_MASK_KHR)
420+
421+
#define CL_MAKE_VERSION_KHR(major, minor, patch) \
422+
((((major) & CL_VERSION_MAJOR_MASK_KHR) << (CL_VERSION_MINOR_BITS_KHR + CL_VERSION_PATCH_BITS_KHR)) | \
423+
(((minor) & CL_VERSION_MINOR_MASK_KHR) << CL_VERSION_PATCH_BITS_KHR) | \
424+
((patch) & CL_VERSION_PATCH_MASK_KHR))
425+
426+
typedef cl_uint cl_version_khr;
427+
428+
#define CL_NAME_VERSION_MAX_NAME_SIZE_KHR 64
429+
430+
typedef struct _cl_name_version_khr
431+
{
432+
cl_version_khr version;
433+
char name[CL_NAME_VERSION_MAX_NAME_SIZE_KHR];
434+
} cl_name_version_khr;
435+
409436
// Unofficial MDAPI extension:
410437
extern CL_API_ENTRY
411438
cl_command_queue CL_API_CALL clCreatePerfCountersCommandQueueINTEL(

intercept/src/controls.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ CLI_CONTROL( std::string, AppendBuildOptions, "", "If s
101101
CLI_CONTROL( bool, DumpProgramBuildLogs, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump build logs for every device a program is built for to a separate file. The filename will have the form \"CLI_<Program Number>_<Unique Program Hash Code>_<Compile Count>_<Unique Build Options Hash Code>_<Device Type>_build_log.txt\"." )
102102
CLI_CONTROL( bool, DumpKernelISABinaries, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will dump kernel ISA binaries for every kernel, if supported. An ISA binaries can decoded into ISA text with a disassembler. The filename will have the form \"CLI_<Program Number>_<Unique Program Hash Code>_<Compile Count>_<Unique Build Options Hash Code>_<Device Type>_<Kernel Name>.isabin\"." )
103103

104+
CLI_CONTROL_SEPARATOR( Controls for Emulating Features: )
105+
CLI_CONTROL( bool, Emulate_cl_khr_extended_versioning, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will emulate support for the cl_khr_extended_versioning extension." )
106+
104107
CLI_CONTROL_SEPARATOR( Controls for Automatically Creating SPIR-V Modules: )
105108
CLI_CONTROL( bool, AutoCreateSPIRV, false, "If set to a nonzero value, the Intercept Layer for OpenCL Applications will automatically create SPIR-V modules by invoking CLANG each time a program is built. The filename will have the form \"CLI_<Program Number>_<Unique Program Hash Code>_<Compile Count>_<Unique Build Options Hash Code>.spv\". Because invoking CLANG requires a file containing the OpenCL C source, setting this option implicitly sets DumpProgramSource as well. Additionally, this feature is not available for injected program source." )
106109
CLI_CONTROL( std::string, SPIRVClang, "clang", "The clang executable used to compile an OpenCL C program to a SPIR-V module. This can be an executable in the system path, a relative path, or a full absolute path." )

intercept/src/dispatch.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ CL_API_ENTRY cl_int CL_API_CALL CLIRN(clGetPlatformInfo)(
8989
cl_int retVal = CL_SUCCESS;
9090

9191
if( pIntercept->overrideGetPlatformInfo(
92+
platform,
9293
param_name,
9394
param_value_size,
9495
param_value,

0 commit comments

Comments
 (0)