@@ -293,12 +293,9 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
293
293
// (If we wished to preserve the ordering of terms, we could replace `std::map`
294
294
// with `std::queue<std::pair<key_type_t, value_type_t>>` or something similar.)
295
295
auto maybeEnvVarMap = getenv_to_map (" ONEAPI_DEVICE_SELECTOR" , false );
296
- std::cout
297
- << " DEBUG: "
298
- << (maybeEnvVarMap.has_value ()
299
- ? " getenv_to_map parsed env var and produced a map"
300
- : " getenv_to_map parsed env var and failed to produce a map" )
301
- << std::endl;
296
+ logger::debug (
297
+ " getenv_to_map parsed env var and {} a map" ,
298
+ (maybeEnvVarMap.has_value () ? " produced" : " failed to produce" ));
302
299
303
300
// if the ODS env var is not set at all, then pretend it was set to the default
304
301
using EnvVarMap = std::map<std::string, std::vector<std::string>>;
@@ -430,26 +427,23 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
430
427
if (backend
431
428
.empty ()) { // FIXME: never true because getenv_to_map rejects this case
432
429
// malformed term: missing backend -- output ERROR, then continue
433
- // TODO: replace std::cout with URT message output mechanism
434
- std::cout << " ERROR: missing backend, format of filter = "
435
- " '[!]backend:filterStrings'"
436
- << std::endl;
430
+ logger::error (" ERROR: missing backend, format of filter = "
431
+ " '[!]backend:filterStrings'" );
437
432
continue ;
438
433
}
439
434
enum FilterType {
440
435
AcceptFilter,
441
436
DiscardFilter,
442
437
} termType = (backend.front () != ' !' ) ? AcceptFilter : DiscardFilter;
443
- std::cout << " DEBUG: termType is"
444
- << (termType != AcceptFilter ? " DiscardFilter"
445
- : " AcceptFilter" )
446
- << std::endl;
438
+ logger::debug (
439
+ " termType is {}" ,
440
+ (termType != AcceptFilter ? " DiscardFilter" : " AcceptFilter" ));
447
441
auto &deviceList =
448
442
(termType != AcceptFilter) ? discardDeviceList : acceptDeviceList;
449
443
if (termType != AcceptFilter) {
450
- std::cout << " DEBUG: backend was '" << backend << " ' " << std::endl ;
444
+ logger::debug ( " DEBUG: backend was '{}' " , backend) ;
451
445
backend.erase (backend.cbegin ());
452
- std::cout << " DEBUG: backend now '" << backend << " ' " << std::endl ;
446
+ logger::debug ( " DEBUG: backend now '{}' " , backend) ;
453
447
}
454
448
// Note the hPlatform -> platformBackend -> platformBackendName conversion above
455
449
// guarantees minimal sanity for the comparison with backend from the ODS string
@@ -463,39 +457,32 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
463
457
std::tolower (static_cast <unsigned char >(b));
464
458
})) {
465
459
// irrelevant term for current request: different backend -- silently ignore
466
- // TODO: replace std::cout with URT message output mechanism
467
- std::cout << " WARNING: ignoring term with irrelevant backend"
468
- << std::endl;
460
+ logger::warning (" WARNING: ignoring term with irrelevant backend '{}'" , backend);
469
461
continue ;
470
462
}
471
463
if (termPair.second .size () == 0 ) {
472
464
// malformed term: missing filterStrings -- output ERROR, then continue
473
- // TODO: replace std::cout with URT message output mechanism
474
- std::cout << " ERROR missing filterStrings, format of filter = "
475
- " '[!]backend:filterStrings'"
476
- << std::endl;
465
+ logger::error (" ERROR missing filterStrings, format of filter = "
466
+ " '[!]backend:filterStrings'" );
477
467
continue ;
478
468
}
479
469
if (std::find_if (termPair.second .cbegin (), termPair.second .cend (),
480
470
[](const auto &s) { return s.empty (); }) !=
481
471
termPair.second
482
472
.cend ()) { // FIXME: never true because getenv_to_map rejects this case
483
473
// malformed term: missing filterString -- output warning, then continue
484
- // TODO: replace std::cout with URT message output mechanism
485
- std::cout << " WARNING: empty filterString, format of filterStrings "
486
- " = 'filterString[,filterString[,...]]'"
487
- << std::endl;
474
+ logger::warning (
475
+ " WARNING: empty filterString, format of filterStrings "
476
+ " = 'filterString[,filterString[,...]]'" );
488
477
continue ;
489
478
}
490
479
if (std::find_if (termPair.second .cbegin (), termPair.second .cend (),
491
480
[](const auto &s) {
492
481
return std::count (s.cbegin (), s.cend (), ' .' ) > 2 ;
493
482
}) != termPair.second .cend ()) {
494
483
// malformed term: too many dots in filterString -- output warning, then continue
495
- // TODO: replace std::cout with URT message output mechanism
496
- std::cout << " WARNING: too many dots in filterString, format of "
497
- " filterString = 'root[.sub[.subsub]]'"
498
- << std::endl;
484
+ logger::warning (" WARNING: too many dots in filterString, format of "
485
+ " filterString = 'root[.sub[.subsub]]'" );
499
486
continue ;
500
487
}
501
488
if (std::find_if (
@@ -515,10 +502,8 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
515
502
return false ; // no BAD things, so must be okay
516
503
}) != termPair.second .cend ()) {
517
504
// malformed term: star dot no-star in filterString -- output warning, then continue
518
- // TODO: replace std::cout with URT message output mechanism
519
- std::cout
520
- << " WARNING: invalid wildcard in filterString, '*.' => '*.*'"
521
- << std::endl;
505
+ logger::warning (
506
+ " WARNING: invalid wildcard in filterString, '*.' => '*.*'" );
522
507
continue ;
523
508
}
524
509
@@ -576,10 +561,10 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
576
561
DevicePartLevel::ROOT, ::UR_DEVICE_TYPE_ALL, DeviceIdTypeALL});
577
562
}
578
563
579
- std::cout << " DEBUG: size of acceptDeviceList = " << acceptDeviceList. size ()
580
- << std::endl
581
- << " DEBUG: size of discardDeviceList = "
582
- << discardDeviceList.size () << std::endl ;
564
+ logger::debug ( " DEBUG: size of acceptDeviceList = {} " ,
565
+ acceptDeviceList. size ());
566
+ logger::debug ( " DEBUG: size of discardDeviceList = {} " ,
567
+ discardDeviceList.size ()) ;
583
568
584
569
std::vector<DeviceSpec> rootDevices;
585
570
std::vector<DeviceSpec> subDevices;
@@ -710,46 +695,47 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
710
695
// if this is a subsubdevice filter, then it must be '*.*.*'
711
696
matches = (filter.hwType == device.hwType ) ||
712
697
(filter.hwType == DeviceHardwareType::UR_DEVICE_TYPE_ALL);
713
- std::cout << " DEBUG: In ApplyFilter, if block case 1, matches = "
714
- << matches << std::endl;
698
+ logger::debug (
699
+ " DEBUG: In ApplyFilter, if block case 1, matches = {}" ,
700
+ matches);
715
701
} else if (filter.rootId != device.rootId ) {
716
702
// root part in filter is a number but does not match the number in the root part of device
717
703
matches = false ;
718
- std::cout << " DEBUG: In ApplyFilter, if block case 2, matches = "
719
- << matches << std::endl ;
704
+ logger::debug ( " DEBUG: In ApplyFilter, if block case 2, matches = " ,
705
+ matches) ;
720
706
} else if (filter.level == DevicePartLevel::ROOT) {
721
707
// this is a root device filter with a number that matches
722
708
matches = true ;
723
- std::cout << " DEBUG: In ApplyFilter, if block case 3, matches = "
724
- << matches << std::endl ;
709
+ logger::debug ( " DEBUG: In ApplyFilter, if block case 3, matches = " ,
710
+ matches) ;
725
711
} else if (filter.subId == DeviceIdTypeALL) {
726
712
// sub type of star always matches (when root part matches, which we already know here)
727
713
// if this is a subdevice filter, then it must be 'matches.*'
728
714
// if this is a subsubdevice filter, then it must be 'matches.*.*'
729
715
matches = true ;
730
- std::cout << " DEBUG: In ApplyFilter, if block case 4, matches = "
731
- << matches << std::endl ;
716
+ logger::debug ( " DEBUG: In ApplyFilter, if block case 4, matches = " ,
717
+ matches) ;
732
718
} else if (filter.subId != device.subId ) {
733
719
// sub part in filter is a number but does not match the number in the sub part of device
734
720
matches = false ;
735
- std::cout << " DEBUG: In ApplyFilter, if block case 5, matches = "
736
- << matches << std::endl ;
721
+ logger::debug ( " DEBUG: In ApplyFilter, if block case 5, matches = " ,
722
+ matches) ;
737
723
} else if (filter.level == DevicePartLevel::SUB) {
738
724
// this is a sub device number filter, numbers match in both parts
739
725
matches = true ;
740
- std::cout << " DEBUG: In ApplyFilter, if block case 6, matches = "
741
- << matches << std::endl ;
726
+ logger::debug ( " DEBUG: In ApplyFilter, if block case 6, matches = " ,
727
+ matches) ;
742
728
} else if (filter.subsubId == DeviceIdTypeALL) {
743
729
// subsub type of star always matches (when other parts match, which we already know here)
744
730
// this is a subsub device filter, it must be 'matches.matches.*'
745
731
matches = true ;
746
- std::cout << " DEBUG: In ApplyFilter, if block case 7, matches = "
747
- << matches << std::endl ;
732
+ logger::debug ( " DEBUG: In ApplyFilter, if block case 7, matches = " ,
733
+ matches) ;
748
734
} else {
749
735
// this is a subsub device filter, numbers in all three parts match
750
736
matches = (filter.subsubId == device.subsubId );
751
- std::cout << " DEBUG: In ApplyFilter, if block case 8, matches = "
752
- << matches << std::endl ;
737
+ logger::debug ( " DEBUG: In ApplyFilter, if block case 8, matches = " ,
738
+ matches) ;
753
739
}
754
740
return matches;
755
741
};
@@ -817,10 +803,10 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
817
803
subSubDevices.end ());
818
804
}
819
805
if (numAlreadySelected == selectedDevices.size ()) {
820
- std::cout << " WARNING: an accept term was ignored because it "
821
- " does not select any additional devices"
822
- " selectedDevices.size() = "
823
- << selectedDevices.size () << std::endl ;
806
+ logger::warning ( " WARNING: an accept term was ignored because it "
807
+ " does not select any additional devices"
808
+ " selectedDevices.size() = {} " ,
809
+ selectedDevices.size ()) ;
824
810
}
825
811
}
826
812
0 commit comments