9696 "LIBCLANG_NOTHREADS" ,
9797 "LIBCLANG_RESOURCE_USAGE" ,
9898 "LIBCLANG_CODE_COMPLETION_LOGGING" ,
99+ "ZE_AFFINITY_MASK" ,
99100]
100101
101102# Names of the Release and Debug versions of the XPTIFW library
@@ -917,12 +918,14 @@ def get_sycl_ls_verbose(sycl_device, env):
917918
918919 env = copy .copy (llvm_config .config .environment )
919920
921+ backend_for_selector = backend .replace ("_v2" , "" ).replace ("_v1" , "" )
922+
920923 # Find all available devices under the backend
921- env ["ONEAPI_DEVICE_SELECTOR" ] = backend + ":*"
924+ env ["ONEAPI_DEVICE_SELECTOR" ] = backend_for_selector + ":*"
922925
923926 detected_architectures = []
924927
925- platform_devices = remove_level_zero_suffix ( backend + ":*" )
928+ platform_devices = backend_for_selector + ":*"
926929
927930 for line in get_sycl_ls_verbose (platform_devices , env ).stdout .splitlines ():
928931 if re .match (r" *Architecture:" , line ):
@@ -948,6 +951,15 @@ def get_sycl_ls_verbose(sycl_device, env):
948951
949952config .sycl_devices = filtered_sycl_devices
950953
954+ # Determine ZE_AFFINITY_MASK for Level Zero devices.
955+ # Sanitizer tests need to set ZE_AFFINITY_MASK to a single device index
956+ config .ze_affinity_mask = None
957+ for sycl_device in remove_level_zero_suffix (config .sycl_devices ):
958+ be , dev = sycl_device .split (":" )
959+ if be == "level_zero" and dev .isdigit ():
960+ config .ze_affinity_mask = dev
961+ break
962+
951963for sycl_device in remove_level_zero_suffix (config .sycl_devices ):
952964 be , dev = sycl_device .split (":" )
953965 config .available_features .add ("any-device-is-" + dev )
@@ -1114,6 +1126,13 @@ def get_sycl_ls_verbose(sycl_device, env):
11141126 features .update (device_family )
11151127
11161128 be , dev = sycl_device .split (":" )
1129+ if dev .isdigit ():
1130+ backend_devices = available_devices .get (be , "gpu" )
1131+ if isinstance (backend_devices , tuple ):
1132+ # arch-selection is typically used to select gpu device
1133+ dev = "gpu"
1134+ else :
1135+ dev = backend_devices
11171136 features .add (dev .replace ("fpga" , "accelerator" ))
11181137 if "level_zero_v2" in full_name :
11191138 features .add ("level_zero_v2_adapter" )
@@ -1146,6 +1165,13 @@ def get_sycl_ls_verbose(sycl_device, env):
11461165 else :
11471166 config .intel_driver_ver [full_name ] = {}
11481167
1168+ # When running with a single device, merge device-specific features into global
1169+ # available_features so that %if conditionals work correctly, even if device is not :gpu or :cpu
1170+ if len (config .sycl_devices ) == 1 :
1171+ single_device = list (config .sycl_dev_features .keys ())[0 ]
1172+ device_features = config .sycl_dev_features [single_device ]
1173+ config .available_features .update (device_features )
1174+
11491175if lit_config .params .get ("compatibility_testing" , "False" ) != "False" :
11501176 config .substitutions .append (("%clangxx" , " true " ))
11511177 config .substitutions .append (("%clang" , " true " ))
0 commit comments