Skip to content

Commit e298167

Browse files
authored
add a control to prepend a string to CL_DEVICE_EXTENSIONS (#410)
1 parent 598271f commit e298167

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

docs/controls.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,10 @@ If set to a non-negative value, the clGetDeviceInfo() query for CL\_DEVICE\_PREF
891891

892892
If set to a non-empty string, the clGetDeviceInfo() query for CL\_DRIVER\_VERSION will return this value instead of the true driver version.
893893

894+
##### `PrependDeviceExtensions` (string)
895+
896+
If set to a non-empty string, the clGetDeviceInfo() query for CL\_DEVICE\_EXTENSIONS will return this value followed by the true device extensions string.
897+
894898
### Precompiled Kernel and Builtin Kernel Override Controls
895899

896900
##### `ForceByteBufferOverrides` (bool)

intercept/src/controls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ CLI_CONTROL( cl_uint, DevicePreferredVectorWidthHalf, UINT_MAX, "I
221221
CLI_CONTROL( cl_uint, DevicePreferredVectorWidthFloat, UINT_MAX, "If set to a non-negative value, the clGetDeviceInfo() query for CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT will return this value instead of the true device preferred vector width." )
222222
CLI_CONTROL( cl_uint, DevicePreferredVectorWidthDouble, UINT_MAX, "If set to a non-negative value, the clGetDeviceInfo() query for CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE will return this value instead of the true device preferred vector width." )
223223
CLI_CONTROL( std::string, DriverVersion, "", "If set to a non-empty string, the clGetDeviceInfo() query for CL_DRIVER_VERSION will return this value instead of the true driver version." )
224+
CLI_CONTROL( std::string, PrependDeviceExtensions, "", "If set to a non-empty string, the clGetDeviceInfo() query for CL_DEVICE_EXTENSIONS will return this value followed by the true device extensions string." )
224225

225226
CLI_CONTROL_SEPARATOR( Precompiled Kernel and Builtin Kernel Override Controls: )
226227
CLI_CONTROL( bool, ForceByteBufferOverrides, false, "If set to a nonzero value, each of the buffer functions that are overridden (via one or more of the keys below) will use a byte-wise operation to read/write/copy the buffer (default behavior is to try to copy multiple bytes at a time, if possible). Note: Requires OpenCL 1.1 or the \"byte addressable store\" extension." )

intercept/src/intercept.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11151,7 +11151,7 @@ bool CLIntercept::overrideGetPlatformInfo(
1115111151
switch( param_name )
1115211152
{
1115311153
case CL_PLATFORM_NAME:
11154-
if( m_Config.PlatformName != "" )
11154+
if( !m_Config.PlatformName.empty() )
1115511155
{
1115611156
char* ptr = (char*)param_value;
1115711157
errorCode = writeStringToMemory(
@@ -11163,7 +11163,7 @@ bool CLIntercept::overrideGetPlatformInfo(
1116311163
}
1116411164
break;
1116511165
case CL_PLATFORM_VENDOR:
11166-
if( m_Config.PlatformVendor != "" )
11166+
if( !m_Config.PlatformVendor.empty() )
1116711167
{
1116811168
char* ptr = (char*)param_value;
1116911169
errorCode = writeStringToMemory(
@@ -11175,7 +11175,7 @@ bool CLIntercept::overrideGetPlatformInfo(
1117511175
}
1117611176
break;
1117711177
case CL_PLATFORM_PROFILE:
11178-
if( m_Config.PlatformProfile != "" )
11178+
if( !m_Config.PlatformProfile.empty() )
1117911179
{
1118011180
char* ptr = (char*)param_value;
1118111181
errorCode = writeStringToMemory(
@@ -11187,7 +11187,7 @@ bool CLIntercept::overrideGetPlatformInfo(
1118711187
}
1118811188
break;
1118911189
case CL_PLATFORM_VERSION:
11190-
if( m_Config.PlatformVersion != "" )
11190+
if( !m_Config.PlatformVersion.empty() )
1119111191
{
1119211192
char* ptr = (char*)param_value;
1119311193
errorCode = writeStringToMemory(
@@ -11309,7 +11309,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1130911309
}
1131011310
break;
1131111311
case CL_DEVICE_NAME:
11312-
if( m_Config.DeviceName != "" )
11312+
if( !m_Config.DeviceName.empty() )
1131311313
{
1131411314
char* ptr = (char*)param_value;
1131511315
errorCode = writeStringToMemory(
@@ -11321,7 +11321,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1132111321
}
1132211322
break;
1132311323
case CL_DEVICE_EXTENSIONS:
11324-
if( m_Config.DeviceExtensions != "" )
11324+
if( !m_Config.DeviceExtensions.empty() )
1132511325
{
1132611326
char* ptr = (char*)param_value;
1132711327
errorCode = writeStringToMemory(
@@ -11331,11 +11331,16 @@ bool CLIntercept::overrideGetDeviceInfo(
1133111331
ptr );
1133211332
override = true;
1133311333
}
11334-
else if( m_Config.Emulate_cl_khr_extended_versioning ||
11334+
else if( !m_Config.PrependDeviceExtensions.empty() ||
11335+
m_Config.Emulate_cl_khr_extended_versioning ||
1133511336
m_Config.Emulate_cl_khr_semaphore ||
1133611337
m_Config.Emulate_cl_intel_unified_shared_memory )
1133711338
{
11338-
std::string newExtensions;
11339+
std::string newExtensions(m_Config.PrependDeviceExtensions);
11340+
if( !newExtensions.empty() && newExtensions.back() != ' ' )
11341+
{
11342+
newExtensions.push_back(' ');
11343+
}
1133911344
if( m_Config.Emulate_cl_khr_extended_versioning &&
1134011345
!checkDeviceForExtension( device, "cl_khr_extended_versioning") )
1134111346
{
@@ -11376,7 +11381,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1137611381
}
1137711382
break;
1137811383
case CL_DEVICE_VENDOR:
11379-
if( m_Config.DeviceVendor != "" )
11384+
if( !m_Config.DeviceVendor.empty() )
1138011385
{
1138111386
char* ptr = (char*)param_value;
1138211387
errorCode = writeStringToMemory(
@@ -11388,7 +11393,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1138811393
}
1138911394
break;
1139011395
case CL_DEVICE_PROFILE:
11391-
if( m_Config.DeviceProfile != "" )
11396+
if( !m_Config.DeviceProfile.empty() )
1139211397
{
1139311398
char* ptr = (char*)param_value;
1139411399
errorCode = writeStringToMemory(
@@ -11400,7 +11405,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1140011405
}
1140111406
break;
1140211407
case CL_DEVICE_VERSION:
11403-
if( m_Config.DeviceVersion != "" )
11408+
if( !m_Config.DeviceVersion.empty() )
1140411409
{
1140511410
char* ptr = (char*)param_value;
1140611411
errorCode = writeStringToMemory(
@@ -11412,7 +11417,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1141211417
}
1141311418
break;
1141411419
case CL_DEVICE_OPENCL_C_VERSION:
11415-
if( m_Config.DeviceCVersion != "" )
11420+
if( !m_Config.DeviceCVersion.empty() )
1141611421
{
1141711422
char* ptr = (char*)param_value;
1141811423
errorCode = writeStringToMemory(
@@ -11424,7 +11429,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1142411429
}
1142511430
break;
1142611431
case CL_DEVICE_IL_VERSION:
11427-
if( m_Config.DeviceILVersion != "" )
11432+
if( !m_Config.DeviceILVersion.empty() )
1142811433
{
1142911434
char* ptr = (char*)param_value;
1143011435
errorCode = writeStringToMemory(
@@ -11702,7 +11707,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1170211707
}
1170311708
break;
1170411709
case CL_DRIVER_VERSION:
11705-
if( m_Config.DriverVersion != "" )
11710+
if( !m_Config.DriverVersion.empty() )
1170611711
{
1170711712
char* ptr = (char*)param_value;
1170811713
errorCode = writeStringToMemory(

0 commit comments

Comments
 (0)