@@ -293,12 +293,9 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
293293 // (If we wished to preserve the ordering of terms, we could replace `std::map`
294294 // with `std::queue<std::pair<key_type_t, value_type_t>>` or something similar.)
295295 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" ));
302299
303300 // if the ODS env var is not set at all, then pretend it was set to the default
304301 using EnvVarMap = std::map<std::string, std::vector<std::string>>;
@@ -430,26 +427,23 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
430427 if (backend
431428 .empty ()) { // FIXME: never true because getenv_to_map rejects this case
432429 // 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'" );
437432 continue ;
438433 }
439434 enum FilterType {
440435 AcceptFilter,
441436 DiscardFilter,
442437 } 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" ));
447441 auto &deviceList =
448442 (termType != AcceptFilter) ? discardDeviceList : acceptDeviceList;
449443 if (termType != AcceptFilter) {
450- std::cout << " DEBUG: backend was '" << backend << " ' " << std::endl ;
444+ logger::debug ( " DEBUG: backend was '{}' " , backend) ;
451445 backend.erase (backend.cbegin ());
452- std::cout << " DEBUG: backend now '" << backend << " ' " << std::endl ;
446+ logger::debug ( " DEBUG: backend now '{}' " , backend) ;
453447 }
454448 // Note the hPlatform -> platformBackend -> platformBackendName conversion above
455449 // 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,
463457 std::tolower (static_cast <unsigned char >(b));
464458 })) {
465459 // 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);
469461 continue ;
470462 }
471463 if (termPair.second .size () == 0 ) {
472464 // 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'" );
477467 continue ;
478468 }
479469 if (std::find_if (termPair.second .cbegin (), termPair.second .cend (),
480470 [](const auto &s) { return s.empty (); }) !=
481471 termPair.second
482472 .cend ()) { // FIXME: never true because getenv_to_map rejects this case
483473 // 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[,...]]'" );
488477 continue ;
489478 }
490479 if (std::find_if (termPair.second .cbegin (), termPair.second .cend (),
491480 [](const auto &s) {
492481 return std::count (s.cbegin (), s.cend (), ' .' ) > 2 ;
493482 }) != termPair.second .cend ()) {
494483 // 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]]'" );
499486 continue ;
500487 }
501488 if (std::find_if (
@@ -515,10 +502,8 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
515502 return false ; // no BAD things, so must be okay
516503 }) != termPair.second .cend ()) {
517504 // 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, '*.' => '*.*'" );
522507 continue ;
523508 }
524509
@@ -576,10 +561,10 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
576561 DevicePartLevel::ROOT, ::UR_DEVICE_TYPE_ALL, DeviceIdTypeALL});
577562 }
578563
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 ()) ;
583568
584569 std::vector<DeviceSpec> rootDevices;
585570 std::vector<DeviceSpec> subDevices;
@@ -710,46 +695,47 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
710695 // if this is a subsubdevice filter, then it must be '*.*.*'
711696 matches = (filter.hwType == device.hwType ) ||
712697 (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);
715701 } else if (filter.rootId != device.rootId ) {
716702 // root part in filter is a number but does not match the number in the root part of device
717703 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) ;
720706 } else if (filter.level == DevicePartLevel::ROOT) {
721707 // this is a root device filter with a number that matches
722708 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) ;
725711 } else if (filter.subId == DeviceIdTypeALL) {
726712 // sub type of star always matches (when root part matches, which we already know here)
727713 // if this is a subdevice filter, then it must be 'matches.*'
728714 // if this is a subsubdevice filter, then it must be 'matches.*.*'
729715 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) ;
732718 } else if (filter.subId != device.subId ) {
733719 // sub part in filter is a number but does not match the number in the sub part of device
734720 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) ;
737723 } else if (filter.level == DevicePartLevel::SUB) {
738724 // this is a sub device number filter, numbers match in both parts
739725 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) ;
742728 } else if (filter.subsubId == DeviceIdTypeALL) {
743729 // subsub type of star always matches (when other parts match, which we already know here)
744730 // this is a subsub device filter, it must be 'matches.matches.*'
745731 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) ;
748734 } else {
749735 // this is a subsub device filter, numbers in all three parts match
750736 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) ;
753739 }
754740 return matches;
755741 };
@@ -817,10 +803,10 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
817803 subSubDevices.end ());
818804 }
819805 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 ()) ;
824810 }
825811 }
826812
0 commit comments