@@ -1139,16 +1139,16 @@ void CLIntercept::cacheDeviceInfo(
11391139 if ( iter != m_SubDeviceInfoMap.end () )
11401140 {
11411141 deviceInfo.ParentDevice = iter->second .ParentDevice ;
1142+ deviceInfo.PlatformIndex = 0 ;
11421143 deviceInfo.DeviceIndex = iter->second .SubDeviceIndex ;
1143- deviceInfo.DeviceCountInPlatform = 1 ;
11441144 }
11451145 else
11461146 {
11471147 deviceInfo.ParentDevice = NULL ;
1148- getDeviceIndexInPlatform (
1148+ getDeviceIndex (
11491149 device,
1150- deviceInfo.DeviceIndex ,
1151- deviceInfo.DeviceCountInPlatform );
1150+ deviceInfo.PlatformIndex ,
1151+ deviceInfo.DeviceIndex );
11521152 }
11531153
11541154 char * deviceName = NULL ;
@@ -1232,6 +1232,25 @@ void CLIntercept::cacheDeviceInfo(
12321232 }
12331233}
12341234
1235+ // /////////////////////////////////////////////////////////////////////////////
1236+ //
1237+ void CLIntercept::getDeviceIndexString (
1238+ cl_device_id device,
1239+ std::string& str )
1240+ {
1241+ cacheDeviceInfo ( device );
1242+ str = std::to_string (m_DeviceInfoMap[device].DeviceIndex );
1243+
1244+ while ( m_DeviceInfoMap[device].ParentDevice != NULL )
1245+ {
1246+ device = m_DeviceInfoMap[device].ParentDevice ;
1247+ cacheDeviceInfo ( device );
1248+ str = std::to_string (m_DeviceInfoMap[device].DeviceIndex ) + ' .' + str;
1249+ }
1250+
1251+ str = std::to_string (m_DeviceInfoMap[device].PlatformIndex ) + ' .' + str;
1252+ }
1253+
12351254// /////////////////////////////////////////////////////////////////////////////
12361255//
12371256cl_int CLIntercept::getDeviceMajorMinorVersion (
@@ -1304,6 +1323,80 @@ bool CLIntercept::getMajorMinorVersionFromString(
13041323 return true ;
13051324}
13061325
1326+ // /////////////////////////////////////////////////////////////////////////////
1327+ //
1328+ bool CLIntercept::getDeviceIndex (
1329+ cl_device_id device,
1330+ cl_uint& platformIndex,
1331+ cl_uint& deviceIndex ) const
1332+ {
1333+ cl_platform_id platform = getPlatform (device);
1334+
1335+ cl_int errorCode = CL_SUCCESS;
1336+ bool foundPlatform = false ;
1337+ bool foundDevice = false ;
1338+
1339+ if ( errorCode == CL_SUCCESS )
1340+ {
1341+ cl_uint numPlatforms = 0 ;
1342+ errorCode = dispatch ().clGetPlatformIDs (
1343+ 0 ,
1344+ NULL ,
1345+ &numPlatforms );
1346+
1347+ if ( errorCode == CL_SUCCESS )
1348+ {
1349+ std::vector<cl_platform_id> platforms (numPlatforms);
1350+ errorCode = dispatch ().clGetPlatformIDs (
1351+ numPlatforms,
1352+ platforms.data (),
1353+ NULL );
1354+ if ( errorCode == CL_SUCCESS )
1355+ {
1356+ auto it = std::find (platforms.begin (), platforms.end (), platform);
1357+ if ( it != platforms.end () )
1358+ {
1359+ foundPlatform = true ;
1360+ platformIndex = (cl_uint)std::distance (platforms.begin (), it);
1361+ }
1362+ }
1363+ }
1364+ }
1365+
1366+ if ( errorCode == CL_SUCCESS )
1367+ {
1368+ cl_uint numDevices = 0 ;
1369+ errorCode = dispatch ().clGetDeviceIDs (
1370+ platform,
1371+ CL_DEVICE_TYPE_ALL,
1372+ 0 ,
1373+ NULL ,
1374+ &numDevices );
1375+
1376+ if ( errorCode == CL_SUCCESS )
1377+ {
1378+ std::vector<cl_device_id> devices (numDevices);
1379+ errorCode = dispatch ().clGetDeviceIDs (
1380+ platform,
1381+ CL_DEVICE_TYPE_ALL,
1382+ numDevices,
1383+ devices.data (),
1384+ NULL );
1385+ if ( errorCode == CL_SUCCESS )
1386+ {
1387+ auto it = std::find (devices.begin (), devices.end (), device);
1388+ if ( it != devices.end () )
1389+ {
1390+ foundDevice = true ;
1391+ deviceIndex = (cl_uint)std::distance (devices.begin (), it);
1392+ }
1393+ }
1394+ }
1395+ }
1396+
1397+ return foundPlatform && foundDevice;
1398+ }
1399+
13071400// /////////////////////////////////////////////////////////////////////////////
13081401//
13091402bool CLIntercept::checkDeviceForExtension (
@@ -1355,52 +1448,6 @@ bool CLIntercept::checkDeviceForExtension(
13551448 return supported;
13561449}
13571450
1358- // /////////////////////////////////////////////////////////////////////////////
1359- //
1360- bool CLIntercept::getDeviceIndexInPlatform (
1361- cl_device_id device,
1362- size_t & index,
1363- size_t & count ) const
1364- {
1365- cl_int errorCode = CL_SUCCESS;
1366-
1367- cl_platform_id platform = getPlatform (device);
1368-
1369- cl_uint numDevices = 0 ;
1370- errorCode = dispatch ().clGetDeviceIDs (
1371- platform,
1372- CL_DEVICE_TYPE_ALL,
1373- 0 ,
1374- NULL ,
1375- &numDevices );
1376-
1377- bool found = false ;
1378- index = 0 ;
1379- count = numDevices;
1380-
1381- if ( errorCode == CL_SUCCESS )
1382- {
1383- std::vector<cl_device_id> devices (numDevices);
1384- errorCode = dispatch ().clGetDeviceIDs (
1385- platform,
1386- CL_DEVICE_TYPE_ALL,
1387- numDevices,
1388- devices.data (),
1389- NULL );
1390- if ( errorCode == CL_SUCCESS )
1391- {
1392- auto it = std::find (devices.begin (), devices.end (), device);
1393- if ( it != devices.end () )
1394- {
1395- found = true ;
1396- index = std::distance (devices.begin (), it);
1397- }
1398- }
1399- }
1400-
1401- return found;
1402- }
1403-
14041451// /////////////////////////////////////////////////////////////////////////////
14051452//
14061453cl_int CLIntercept::allocateAndGetPlatformInfoString (
@@ -12799,45 +12846,55 @@ void CLIntercept::chromeRegisterCommandQueue(
1279912846
1280012847 if ( properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE )
1280112848 {
12802- trackName += " OOQ " ;
12849+ trackName += " OOQ" ;
1280312850 }
1280412851 else
1280512852 {
12806- trackName += " IOQ " ;
12807- }
12808-
12809- {
12810- CLI_SPRINTF ( m_StringBuffer, CLI_STRING_BUFFER_SIZE, " %p on " , queue );
12811- trackName = trackName + m_StringBuffer;
12853+ trackName += " IOQ" ;
1281212854 }
1281312855
1281412856 cacheDeviceInfo ( device );
1281512857
1281612858 const SDeviceInfo& deviceInfo = m_DeviceInfoMap[device];
1281712859
12818- if ( deviceInfo.ParentDevice == NULL &&
12819- deviceInfo.DeviceCountInPlatform <= 1 )
1282012860 {
12821- CLI_SPRINTF ( m_StringBuffer, CLI_STRING_BUFFER_SIZE, " %s (%s)" ,
12861+ std::string deviceIndexString;
12862+ getDeviceIndexString (
12863+ device,
12864+ deviceIndexString );
12865+ CLI_SPRINTF ( m_StringBuffer, CLI_STRING_BUFFER_SIZE, " %p.%s %s (%s)" ,
12866+ queue,
12867+ deviceIndexString.c_str (),
1282212868 deviceInfo.Name .c_str (),
1282312869 enumName ().name_device_type ( deviceInfo.Type ).c_str () );
1282412870 trackName = trackName + m_StringBuffer;
1282512871 }
12826- else if ( deviceInfo.ParentDevice == NULL )
12827- {
12828- CLI_SPRINTF ( m_StringBuffer, CLI_STRING_BUFFER_SIZE, " %s (%s) [device %zu]" ,
12829- deviceInfo.Name .c_str (),
12830- enumName ().name_device_type ( deviceInfo.Type ).c_str (),
12831- deviceInfo.DeviceIndex );
12832- trackName = trackName + m_StringBuffer;
12833- }
12834- else
12872+
1283512873 {
12836- CLI_SPRINTF ( m_StringBuffer, CLI_STRING_BUFFER_SIZE, " %s (%s) [sub-device %zu]" ,
12837- deviceInfo.Name .c_str (),
12838- enumName ().name_device_type ( deviceInfo.Type ).c_str (),
12839- deviceInfo.DeviceIndex );
12840- trackName = trackName + m_StringBuffer;
12874+ cl_int testError = CL_SUCCESS;
12875+
12876+ cl_uint queueFamily = 0 ;
12877+ cl_uint queueIndex = 0 ;
12878+
12879+ testError |= dispatch ().clGetCommandQueueInfo (
12880+ queue,
12881+ CL_QUEUE_FAMILY_INTEL,
12882+ sizeof (queueFamily),
12883+ &queueFamily,
12884+ NULL );
12885+ testError |= dispatch ().clGetCommandQueueInfo (
12886+ queue,
12887+ CL_QUEUE_INDEX_INTEL,
12888+ sizeof (queueFamily),
12889+ &queueFamily,
12890+ NULL );
12891+ if ( testError == CL_SUCCESS )
12892+ {
12893+ CLI_SPRINTF ( m_StringBuffer, CLI_STRING_BUFFER_SIZE, " (F:%u I:%u)" ,
12894+ queueFamily,
12895+ queueIndex );
12896+ trackName = trackName + m_StringBuffer;
12897+ }
1284112898 }
1284212899
1284312900 uint64_t processId = OS ().GetProcessID ();
0 commit comments