@@ -496,6 +496,100 @@ bool LinuxSysmanImp::getTelemData(uint32_t subDeviceId, std::string &telemDir, s
496
496
return true ;
497
497
}
498
498
499
+ void LinuxSysmanImp::getDeviceUuids (std::vector<std::string> &deviceUuids) {
500
+ constexpr uint32_t rootDeviceCount = 1 ;
501
+ uint32_t totalUuidCountForDevice = this ->getSubDeviceCount () + rootDeviceCount;
502
+ deviceUuids.clear ();
503
+ for (uint32_t index = 0 ; index < totalUuidCountForDevice; index ++) {
504
+ std::array<uint8_t , NEO::ProductHelper::uuidSize> deviceUuid;
505
+ bool uuidValid = this ->getUuidFromSubDeviceInfo (index , deviceUuid);
506
+ if (uuidValid) {
507
+ uint8_t uuid[ZE_MAX_DEVICE_UUID_SIZE] = {};
508
+ std::copy_n (std::begin (deviceUuid), ZE_MAX_DEVICE_UUID_SIZE, std::begin (uuid));
509
+ std::string uuidString (reinterpret_cast <char const *>(uuid));
510
+ deviceUuids.push_back (uuidString);
511
+ }
512
+ }
513
+ }
514
+
515
+ bool LinuxSysmanImp::generateUuidFromPciAndSubDeviceInfo (uint32_t subDeviceID, const NEO::PhysicalDevicePciBusInfo &pciBusInfo, std::array<uint8_t , NEO::ProductHelper::uuidSize> &uuid) {
516
+ if (pciBusInfo.pciDomain != NEO::PhysicalDevicePciBusInfo::invalidValue) {
517
+ uuid.fill (0 );
518
+
519
+ // Device UUID uniquely identifies a device within a system.
520
+ // We generate it based on device information along with PCI information
521
+ // This guarantees uniqueness of UUIDs on a system even when multiple
522
+ // identical Intel GPUs are present.
523
+
524
+ // We want to have UUID matching between different GPU APIs (including outside
525
+ // of compute_runtime project - i.e. other than L0 or OCL). This structure definition
526
+ // has been agreed upon by various Intel driver teams.
527
+ //
528
+ // Consult other driver teams before changing this.
529
+ //
530
+
531
+ struct DeviceUUID {
532
+ uint16_t vendorID;
533
+ uint16_t deviceID;
534
+ uint16_t revisionID;
535
+ uint16_t pciDomain;
536
+ uint8_t pciBus;
537
+ uint8_t pciDev;
538
+ uint8_t pciFunc;
539
+ uint8_t reserved[4 ];
540
+ uint8_t subDeviceID;
541
+ };
542
+
543
+ auto &hwInfo = getParentSysmanDeviceImp ()->getHardwareInfo ();
544
+ DeviceUUID deviceUUID = {};
545
+ deviceUUID.vendorID = 0x8086 ; // Intel
546
+ deviceUUID.deviceID = hwInfo.platform .usDeviceID ;
547
+ deviceUUID.revisionID = hwInfo.platform .usRevId ;
548
+ deviceUUID.pciDomain = static_cast <uint16_t >(pciBusInfo.pciDomain );
549
+ deviceUUID.pciBus = static_cast <uint8_t >(pciBusInfo.pciBus );
550
+ deviceUUID.pciDev = static_cast <uint8_t >(pciBusInfo.pciDevice );
551
+ deviceUUID.pciFunc = static_cast <uint8_t >(pciBusInfo.pciFunction );
552
+ deviceUUID.subDeviceID = subDeviceID;
553
+
554
+ static_assert (sizeof (DeviceUUID) == NEO::ProductHelper::uuidSize);
555
+
556
+ memcpy_s (uuid.data (), NEO::ProductHelper::uuidSize, &deviceUUID, sizeof (DeviceUUID));
557
+
558
+ return true ;
559
+ }
560
+ return false ;
561
+ }
562
+
563
+ bool LinuxSysmanImp::getUuidFromSubDeviceInfo (uint32_t subDeviceID, std::array<uint8_t , NEO::ProductHelper::uuidSize> &uuid) {
564
+ auto subDeviceCount = getSubDeviceCount ();
565
+ if (uuidVec.size () == 0 ) {
566
+ constexpr uint32_t rootDeviceCount = 1 ;
567
+ uuidVec.resize (subDeviceCount + rootDeviceCount);
568
+ }
569
+ if (getParentSysmanDeviceImp ()->getRootDeviceEnvironment ().osInterface != nullptr ) {
570
+ auto driverModel = getParentSysmanDeviceImp ()->getRootDeviceEnvironment ().osInterface ->getDriverModel ();
571
+ auto &gfxCoreHelper = getParentSysmanDeviceImp ()->getRootDeviceEnvironment ().getHelper <NEO::GfxCoreHelper>();
572
+ auto &productHelper = getParentSysmanDeviceImp ()->getRootDeviceEnvironment ().getHelper <NEO::ProductHelper>();
573
+ if (NEO::debugManager.flags .EnableChipsetUniqueUUID .get () != 0 ) {
574
+ if (gfxCoreHelper.isChipsetUniqueUUIDSupported ()) {
575
+ auto hwDeviceId = getSysmanHwDeviceIdInstance ();
576
+ this ->uuidVec [subDeviceID].isValid = productHelper.getUuid (driverModel, subDeviceCount, subDeviceID, this ->uuidVec [subDeviceID].id );
577
+ }
578
+ }
579
+
580
+ if (!this ->uuidVec [subDeviceID].isValid ) {
581
+ NEO::PhysicalDevicePciBusInfo pciBusInfo = driverModel->getPciBusInfo ();
582
+ this ->uuidVec [subDeviceID].isValid = generateUuidFromPciAndSubDeviceInfo (subDeviceID, pciBusInfo, this ->uuidVec [subDeviceID].id );
583
+ }
584
+
585
+ if (this ->uuidVec [subDeviceID].isValid ) {
586
+ uuid = this ->uuidVec [subDeviceID].id ;
587
+ }
588
+ }
589
+
590
+ return this ->uuidVec [subDeviceID].isValid ;
591
+ }
592
+
499
593
OsSysman *OsSysman::create (SysmanDeviceImp *pParentSysmanDeviceImp) {
500
594
LinuxSysmanImp *pLinuxSysmanImp = new LinuxSysmanImp (pParentSysmanDeviceImp);
501
595
return static_cast <OsSysman *>(pLinuxSysmanImp);
0 commit comments