Skip to content

Commit 81b08ac

Browse files
[SYCL] Refactor unit-tests to ignore fallback libs (#7534)
Updated default constructor of mock property set to contain a property about devicelib mask so unit-tests depend on one less env variable. This resolves #6945
1 parent d948427 commit 81b08ac

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

sycl/test/Unit/lit.cfg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141

4242
if 'SYCL_DEVICELIB_NO_FALLBACK' in os.environ:
4343
config.environment['SYCL_DEVICELIB_NO_FALLBACK'] = os.environ['SYCL_DEVICELIB_NO_FALLBACK']
44-
else:
45-
# Disable device library fallback for unit tests by default.
46-
config.environment['SYCL_DEVICELIB_NO_FALLBACK'] = "1"
44+
# We do not have any default for SYCL_DEVICELIB_NO_FALLBACK, which means that
45+
# env variable won't be defined. That is ok, because we expect tests to pass
46+
# even without it.
4747

4848
# Propagate path to symbolizer for ASan/MSan.
4949
for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:

sycl/unittests/helpers/PiImage.hpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,27 @@ template <typename T> class PiArray {
160160
/// Convenience wrapper for pi_device_binary_property_set.
161161
class PiPropertySet {
162162
public:
163-
PiPropertySet() = default;
163+
PiPropertySet() {
164+
// Most of unit-tests are statically linked with SYCL RT. On Linux and Mac
165+
// systems that causes incorrect RT installation directory detection, which
166+
// prevents proper loading of fallback libraries. See intel/llvm#6945
167+
//
168+
// Fallback libraries are automatically loaded and linked into device image
169+
// unless there is a special property attached to it or special env variable
170+
// is set which forces RT to skip fallback libraries.
171+
//
172+
// Setting this property here so unit-tests can be launched under any
173+
// environment.
174+
175+
std::vector<char> Data(/* eight elements */ 8,
176+
/* each element is zero */ 0);
177+
// Name doesn't matter here, it is not used by RT
178+
// Value must be an all-zero 32-bit mask, which would mean that no fallback
179+
// libraries are needed to be loaded.
180+
PiProperty DeviceLibReqMask("", Data, PI_PROPERTY_TYPE_UINT32);
181+
insert(__SYCL_PI_PROPERTY_SET_DEVICELIB_REQ_MASK,
182+
PiArray{DeviceLibReqMask});
183+
}
164184

165185
/// Adds a new array of properties to the set.
166186
///

0 commit comments

Comments
 (0)