Skip to content

Commit a24a0cc

Browse files
committed
Merge branch 'main' into cl_khr_unified_svm
2 parents b518350 + 47701b2 commit a24a0cc

File tree

10 files changed

+113
-30
lines changed

10 files changed

+113
-30
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ jobs:
3535

3636
strategy:
3737
matrix:
38-
os: [ubuntu-latest, windows-latest, macos-latest]
38+
os: [ubuntu-latest, macos-latest]
39+
include:
40+
- os: windows-latest
41+
windows-arch: x64
42+
- os: windows-latest
43+
windows-arch: Win32
3944

4045
runs-on: ${{matrix.os}}
4146

@@ -48,7 +53,12 @@ jobs:
4853
- name: Run CMake
4954
shell: bash
5055
working-directory: ${{runner.workspace}}/build
51-
run: cmake -DENABLE_CLILOADER=1 -DCMAKE_BUILD_TYPE=$BUILD_TYPE $GITHUB_WORKSPACE
56+
run: |
57+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
58+
cmake -DENABLE_CLILOADER=1 -DCMAKE_BUILD_TYPE=$BUILD_TYPE -A ${{ matrix.windows-arch }} $GITHUB_WORKSPACE
59+
else
60+
cmake -DENABLE_CLILOADER=1 -DCMAKE_BUILD_TYPE=$BUILD_TYPE $GITHUB_WORKSPACE
61+
fi
5262
5363
- name: Build
5464
working-directory: ${{runner.workspace}}/build

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3333

3434
- name: Initialize CodeQL
35-
uses: github/codeql-action/init@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
35+
uses: github/codeql-action/init@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
3636
with:
3737
languages: cpp
3838

@@ -50,4 +50,4 @@ jobs:
5050
run: cmake --build . --parallel 4 --config $BUILD_TYPE
5151

5252
- name: Perform CodeQL Analysis
53-
uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
53+
uses: github/codeql-action/analyze@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16

.github/workflows/release.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ jobs:
1515
release:
1616
strategy:
1717
matrix:
18-
os: [ubuntu-latest, windows-latest]
18+
os: [ubuntu-latest]
19+
include:
20+
- os: windows-latest
21+
windows-arch: x64
22+
- os: windows-latest
23+
windows-arch: Win32
1924

2025
runs-on: ${{matrix.os}}
2126

@@ -42,7 +47,12 @@ jobs:
4247
- name: Run CMake
4348
shell: bash
4449
working-directory: ./build
45-
run: cmake -DENABLE_CLILOADER=1 -DCMAKE_BUILD_TYPE=$BUILD_TYPE $GITHUB_WORKSPACE
50+
run: |
51+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
52+
cmake -DENABLE_CLILOADER=1 -DCMAKE_BUILD_TYPE=$BUILD_TYPE -A ${{ matrix.windows-arch }} $GITHUB_WORKSPACE
53+
else
54+
cmake -DENABLE_CLILOADER=1 -DCMAKE_BUILD_TYPE=$BUILD_TYPE $GITHUB_WORKSPACE
55+
fi
4656
4757
- name: Build
4858
working-directory: ./build
@@ -53,7 +63,7 @@ jobs:
5363
if: |
5464
startsWith(github.ref, 'refs/tags/') &&
5565
matrix.os == 'windows-latest'
56-
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
66+
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
5767
with:
5868
draft: true
5969
files: |
@@ -63,7 +73,7 @@ jobs:
6373
if: |
6474
startsWith(github.ref, 'refs/tags/') &&
6575
matrix.os == 'ubuntu-latest'
66-
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
76+
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
6777
with:
6878
draft: true
6979
files: |

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5-
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
5+
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
66
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
77

88
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
99
set(CMAKE_CXX_STANDARD 11)
1010
#set(CMAKE_VERBOSE_MAKEFILE ON)
1111

12-
project(CLIntercept VERSION 3.0.5 LANGUAGES CXX)
12+
project(CLIntercept VERSION 3.0.6 LANGUAGES CXX)
1313

1414
if(NOT CMAKE_BUILD_TYPE)
1515
message(STATUS "No build type selected, default to RelWithDebInfo")

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/cli_ext.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,19 @@ cl_int CL_API_CALL clGetImageRequirementsInfoEXT(
11781178

11791179
#define CL_DEVICE_CORE_TEMPERATURE_ALTERA 0x40F3
11801180

1181+
///////////////////////////////////////////////////////////////////////////////
1182+
// cl_amd_command_queue_info
1183+
1184+
#define CL_QUEUE_THREAD_HANDLE_AMD 0x403E
1185+
#define CL_KERNEL_EXEC_INFO_NEW_VCOP_AMD 0x4120
1186+
#define CL_KERNEL_EXEC_INFO_PFPA_VCOP_AMD 0x4121
1187+
1188+
///////////////////////////////////////////////////////////////////////////////
1189+
// cl_amd_copy_buffer_p2p
1190+
1191+
#define CL_DEVICE_NUM_P2P_DEVICES_AMD 0x4088
1192+
#define CL_DEVICE_P2P_DEVICES_AMD 0x4089
1193+
11811194
///////////////////////////////////////////////////////////////////////////////
11821195
// cl_amd_device_attribute_query
11831196

@@ -1189,6 +1202,7 @@ cl_int CL_API_CALL clGetImageRequirementsInfoEXT(
11891202
#define CL_DEVICE_TOPOLOGY_AMD 0x4037
11901203
#define CL_DEVICE_BOARD_NAME_AMD 0x4038
11911204
#define CL_DEVICE_GLOBAL_FREE_MEMORY_AMD 0x4039
1205+
#define CL_DEVICE_MAX_REAL_TIME_COMPUTE_UNITS_GRANULARITY_AMD 0x403A
11921206
#define CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD 0x4040
11931207
#define CL_DEVICE_SIMD_WIDTH_AMD 0x4041
11941208
#define CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD 0x4042
@@ -1202,6 +1216,22 @@ cl_int CL_API_CALL clGetImageRequirementsInfoEXT(
12021216
#define CL_DEVICE_GFXIP_MAJOR_AMD 0x404A
12031217
#define CL_DEVICE_GFXIP_MINOR_AMD 0x404B
12041218
#define CL_DEVICE_AVAILABLE_ASYNC_QUEUES_AMD 0x404C
1219+
#define CL_DEVICE_MAX_REAL_TIME_COMPUTE_QUEUES_AMD 0x404D
1220+
#define CL_DEVICE_MAX_REAL_TIME_COMPUTE_UNITS_AMD 0x404E
1221+
1222+
///////////////////////////////////////////////////////////////////////////////
1223+
// cl_amd_device_memory_flags
1224+
1225+
// note: enum conflict!
1226+
#define CL_MEM_USE_PERSISTENT_MEM_AMD (1 << 6)
1227+
1228+
///////////////////////////////////////////////////////////////////////////////
1229+
// cl_amd_object_metadata
1230+
1231+
// note: enum conflict!
1232+
#define CL_INVALID_OBJECT_AMD 0x403A
1233+
#define CL_INVALID_KEY_AMD 0x403B
1234+
#define CL_PLATFORM_MAX_KEYS_AMD 0x403C
12051235

12061236
///////////////////////////////////////////////////////////////////////////////
12071237
// cl_amd_offline_devices

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/dispatch.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,9 @@ CL_API_ENTRY cl_int CL_API_CALL CLIRN(clReleaseContext)(
625625
{
626626
GET_ENQUEUE_COUNTER();
627627

628-
cl_uint ref_count =
629-
pIntercept->config().CallLogging ?
630-
pIntercept->getRefCount( context ) : 0;
628+
// Note: we use the ref count to for device performance timing checks,
629+
// so get it unconditionally.
630+
cl_uint ref_count = pIntercept->getRefCount( context );
631631
CALL_LOGGING_ENTER( "[ ref count = %d ] context = %p",
632632
ref_count,
633633
context );
@@ -639,7 +639,8 @@ CL_API_ENTRY cl_int CL_API_CALL CLIRN(clReleaseContext)(
639639
HOST_PERFORMANCE_TIMING_END();
640640
CHECK_ERROR( retVal );
641641
ADD_OBJECT_RELEASE( context );
642-
CALL_LOGGING_EXIT( retVal, "[ ref count = %d ]", --ref_count );
642+
--ref_count;
643+
CALL_LOGGING_EXIT( retVal, "[ ref count = %d ]", ref_count );
643644
DEVICE_PERFORMANCE_TIMING_CHECK_CONDITIONAL( ref_count == 0 );
644645
FLUSH_CHROME_TRACE_BUFFERING_CONDITIONAL( ref_count == 0 );
645646

@@ -2563,7 +2564,8 @@ CL_API_ENTRY cl_int CL_API_CALL CLIRN(clGetProgramInfo)(
25632564
if( pIntercept && pIntercept->dispatch().clGetProgramInfo )
25642565
{
25652566
GET_ENQUEUE_COUNTER();
2566-
CALL_LOGGING_ENTER( "param_name = %s (%08X)",
2567+
CALL_LOGGING_ENTER( "program = %p, param_name = %s (%08X)",
2568+
program,
25672569
pIntercept->enumName().name( param_name ).c_str(),
25682570
param_name );
25692571
HOST_PERFORMANCE_TIMING_START();
@@ -2600,7 +2602,8 @@ CL_API_ENTRY cl_int CL_API_CALL CLIRN(clGetProgramBuildInfo)(
26002602
if( pIntercept && pIntercept->dispatch().clGetProgramBuildInfo )
26012603
{
26022604
GET_ENQUEUE_COUNTER();
2603-
CALL_LOGGING_ENTER( "param_name = %s (%08X)",
2605+
CALL_LOGGING_ENTER( "program = %p, param_name = %s (%08X)",
2606+
program,
26042607
pIntercept->enumName().name( param_name ).c_str(),
26052608
param_name );
26062609
HOST_PERFORMANCE_TIMING_START();

intercept/src/enummap.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,15 @@ CEnumNameMap::CEnumNameMap()
950950
// cl_altera_device_temperature
951951
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_CORE_TEMPERATURE_ALTERA );
952952

953+
// cl_amd_command_queue_info
954+
ADD_ENUM_NAME( m_cl_int, CL_QUEUE_THREAD_HANDLE_AMD );
955+
ADD_ENUM_NAME( m_cl_int, CL_KERNEL_EXEC_INFO_NEW_VCOP_AMD );
956+
ADD_ENUM_NAME( m_cl_int, CL_KERNEL_EXEC_INFO_PFPA_VCOP_AMD );
957+
958+
// cl_amd_copy_buffer_p2p
959+
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_NUM_P2P_DEVICES_AMD );
960+
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_P2P_DEVICES_AMD );
961+
953962
// cl_amd_device_attribute_query
954963
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_AMD );
955964
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_MAX_WORK_GROUP_SIZE_AMD );
@@ -959,6 +968,7 @@ CEnumNameMap::CEnumNameMap()
959968
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_TOPOLOGY_AMD );
960969
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_BOARD_NAME_AMD );
961970
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_GLOBAL_FREE_MEMORY_AMD );
971+
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_MAX_REAL_TIME_COMPUTE_UNITS_GRANULARITY_AMD );
962972
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD );
963973
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_SIMD_WIDTH_AMD );
964974
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD );
@@ -972,6 +982,16 @@ CEnumNameMap::CEnumNameMap()
972982
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_GFXIP_MAJOR_AMD );
973983
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_GFXIP_MINOR_AMD );
974984
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_AVAILABLE_ASYNC_QUEUES_AMD );
985+
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_MAX_REAL_TIME_COMPUTE_QUEUES_AMD );
986+
ADD_ENUM_NAME( m_cl_int, CL_DEVICE_MAX_REAL_TIME_COMPUTE_UNITS_AMD );
987+
988+
// cl_amd_device_memory_flags
989+
// enum conflict for CL_MEM_USE_PERSISTENT_MEM_AMD!
990+
991+
// cl_amd_object_metadata
992+
// enum conflict for CL_INVALID_OBJECT_AMD!
993+
ADD_ENUM_NAME( m_cl_int, CL_INVALID_KEY_AMD );
994+
ADD_ENUM_NAME( m_cl_int, CL_PLATFORM_MAX_KEYS_AMD );
975995

976996
// cl_amd_offline_devices
977997
ADD_ENUM_NAME( m_cl_int, CL_CONTEXT_OFFLINE_DEVICES_AMD );

intercept/src/intercept.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11222,7 +11222,7 @@ bool CLIntercept::overrideGetPlatformInfo(
1122211222
switch( param_name )
1122311223
{
1122411224
case CL_PLATFORM_NAME:
11225-
if( m_Config.PlatformName != "" )
11225+
if( !m_Config.PlatformName.empty() )
1122611226
{
1122711227
char* ptr = (char*)param_value;
1122811228
errorCode = writeStringToMemory(
@@ -11234,7 +11234,7 @@ bool CLIntercept::overrideGetPlatformInfo(
1123411234
}
1123511235
break;
1123611236
case CL_PLATFORM_VENDOR:
11237-
if( m_Config.PlatformVendor != "" )
11237+
if( !m_Config.PlatformVendor.empty() )
1123811238
{
1123911239
char* ptr = (char*)param_value;
1124011240
errorCode = writeStringToMemory(
@@ -11246,7 +11246,7 @@ bool CLIntercept::overrideGetPlatformInfo(
1124611246
}
1124711247
break;
1124811248
case CL_PLATFORM_PROFILE:
11249-
if( m_Config.PlatformProfile != "" )
11249+
if( !m_Config.PlatformProfile.empty() )
1125011250
{
1125111251
char* ptr = (char*)param_value;
1125211252
errorCode = writeStringToMemory(
@@ -11258,7 +11258,7 @@ bool CLIntercept::overrideGetPlatformInfo(
1125811258
}
1125911259
break;
1126011260
case CL_PLATFORM_VERSION:
11261-
if( m_Config.PlatformVersion != "" )
11261+
if( !m_Config.PlatformVersion.empty() )
1126211262
{
1126311263
char* ptr = (char*)param_value;
1126411264
errorCode = writeStringToMemory(
@@ -11380,7 +11380,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1138011380
}
1138111381
break;
1138211382
case CL_DEVICE_NAME:
11383-
if( m_Config.DeviceName != "" )
11383+
if( !m_Config.DeviceName.empty() )
1138411384
{
1138511385
char* ptr = (char*)param_value;
1138611386
errorCode = writeStringToMemory(
@@ -11392,7 +11392,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1139211392
}
1139311393
break;
1139411394
case CL_DEVICE_EXTENSIONS:
11395-
if( m_Config.DeviceExtensions != "" )
11395+
if( !m_Config.DeviceExtensions.empty() )
1139611396
{
1139711397
char* ptr = (char*)param_value;
1139811398
errorCode = writeStringToMemory(
@@ -11402,11 +11402,16 @@ bool CLIntercept::overrideGetDeviceInfo(
1140211402
ptr );
1140311403
override = true;
1140411404
}
11405-
else if( m_Config.Emulate_cl_khr_extended_versioning ||
11405+
else if( !m_Config.PrependDeviceExtensions.empty() ||
11406+
m_Config.Emulate_cl_khr_extended_versioning ||
1140611407
m_Config.Emulate_cl_khr_semaphore ||
1140711408
m_Config.Emulate_cl_intel_unified_shared_memory )
1140811409
{
11409-
std::string newExtensions;
11410+
std::string newExtensions(m_Config.PrependDeviceExtensions);
11411+
if( !newExtensions.empty() && newExtensions.back() != ' ' )
11412+
{
11413+
newExtensions.push_back(' ');
11414+
}
1141011415
if( m_Config.Emulate_cl_khr_extended_versioning &&
1141111416
!checkDeviceForExtension( device, "cl_khr_extended_versioning") )
1141211417
{
@@ -11447,7 +11452,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1144711452
}
1144811453
break;
1144911454
case CL_DEVICE_VENDOR:
11450-
if( m_Config.DeviceVendor != "" )
11455+
if( !m_Config.DeviceVendor.empty() )
1145111456
{
1145211457
char* ptr = (char*)param_value;
1145311458
errorCode = writeStringToMemory(
@@ -11459,7 +11464,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1145911464
}
1146011465
break;
1146111466
case CL_DEVICE_PROFILE:
11462-
if( m_Config.DeviceProfile != "" )
11467+
if( !m_Config.DeviceProfile.empty() )
1146311468
{
1146411469
char* ptr = (char*)param_value;
1146511470
errorCode = writeStringToMemory(
@@ -11471,7 +11476,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1147111476
}
1147211477
break;
1147311478
case CL_DEVICE_VERSION:
11474-
if( m_Config.DeviceVersion != "" )
11479+
if( !m_Config.DeviceVersion.empty() )
1147511480
{
1147611481
char* ptr = (char*)param_value;
1147711482
errorCode = writeStringToMemory(
@@ -11483,7 +11488,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1148311488
}
1148411489
break;
1148511490
case CL_DEVICE_OPENCL_C_VERSION:
11486-
if( m_Config.DeviceCVersion != "" )
11491+
if( !m_Config.DeviceCVersion.empty() )
1148711492
{
1148811493
char* ptr = (char*)param_value;
1148911494
errorCode = writeStringToMemory(
@@ -11495,7 +11500,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1149511500
}
1149611501
break;
1149711502
case CL_DEVICE_IL_VERSION:
11498-
if( m_Config.DeviceILVersion != "" )
11503+
if( !m_Config.DeviceILVersion.empty() )
1149911504
{
1150011505
char* ptr = (char*)param_value;
1150111506
errorCode = writeStringToMemory(
@@ -11773,7 +11778,7 @@ bool CLIntercept::overrideGetDeviceInfo(
1177311778
}
1177411779
break;
1177511780
case CL_DRIVER_VERSION:
11776-
if( m_Config.DriverVersion != "" )
11781+
if( !m_Config.DriverVersion.empty() )
1177711782
{
1177811783
char* ptr = (char*)param_value;
1177911784
errorCode = writeStringToMemory(

0 commit comments

Comments
 (0)