File tree 1 file changed +16
-3
lines changed
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -874,7 +874,7 @@ namespace dpct
874
874
inline std::string get_preferred_gpu_platform_name() {
875
875
std::string result;
876
876
877
- std::string filter = " level-zero " ;
877
+ std::string filter = " " ;
878
878
char* env = getenv(" ONEAPI_DEVICE_SELECTOR" );
879
879
if (env) {
880
880
if (std::strstr(env, " level_zero" )) {
@@ -892,11 +892,24 @@ namespace dpct
892
892
else {
893
893
throw std::runtime_error(" invalid device filter: " + std::string(env));
894
894
}
895
+ } else {
896
+ auto default_device = sycl::device(sycl::default_selector_v);
897
+ auto default_platform_name = default_device.get_platform().get_info<sycl::info::platform::name>();
898
+
899
+ if (std::strstr(default_platform_name.c_str(), " Level-Zero" ) || default_device.is_cpu()) {
900
+ filter = " level-zero" ;
901
+ }
902
+ else if (std::strstr(default_platform_name.c_str(), " CUDA" )) {
903
+ filter = " cuda" ;
904
+ }
905
+ else if (std::strstr(default_platform_name.c_str(), " HIP" )) {
906
+ filter = " hip" ;
907
+ }
895
908
}
896
909
897
- auto plaform_list = sycl::platform::get_platforms();
910
+ auto platform_list = sycl::platform::get_platforms();
898
911
899
- for (const auto& platform : plaform_list ) {
912
+ for (const auto& platform : platform_list ) {
900
913
auto devices = platform.get_devices();
901
914
auto gpu_dev = std::find_if(devices.begin(), devices.end(), [](const sycl::device& d) {
902
915
return d.is_gpu();
You can’t perform that action at this time.
0 commit comments