Skip to content

Commit d5495b9

Browse files
committed
[SYCL] Replace multi-device kernel_bundle e2e tests with unit test
Replace the following e2e tests with unit test: ProgramManager/multi_device_bundle~device_libs_and_caching.cpp ProgramManager/multi_device_bundle~build_twice.cpp KernelAndProgram/persistent-cache-multi-device.cpp The reason is that the checks performed in those e2e tests (number of UR calls, etc.) can be done more effificently using unit tests, such checks in e2e tests are expensive. Another reson is that e2e tests use NEO-specific CreateMultipleRootDevices=[num] environment variable which is not guaranteed to work, in unit tests we can emulate as many devices as we want.
1 parent be88160 commit d5495b9

File tree

7 files changed

+638
-276
lines changed

7 files changed

+638
-276
lines changed

sycl/source/detail/config.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,34 @@ template <ConfigID Config> class SYCLConfig {
127127
}
128128
};
129129

130+
template <> class SYCLConfig<SYCL_DEVICELIB_NO_FALLBACK> {
131+
using BaseT = SYCLConfigBase<SYCL_DEVICELIB_NO_FALLBACK>;
132+
133+
public:
134+
static const char *get() { return getCachedValue(); }
135+
136+
static void reset() {
137+
(void)getCachedValue(/*ResetCache=*/true, /*UnsetCache=*/false);
138+
}
139+
140+
static const char *getName() { return BaseT::MConfigName; }
141+
142+
static void unset() {
143+
(void)getCachedValue(/*ResetCache=*/false, /*UnsetCache=*/true);
144+
}
145+
146+
private:
147+
static const char *getCachedValue(bool ResetCache = false,
148+
bool UnsetCache = false) {
149+
static const char *ValStr = BaseT::getRawValue();
150+
if (UnsetCache)
151+
ValStr = nullptr;
152+
if (ResetCache)
153+
ValStr = BaseT::getRawValue();
154+
return ValStr;
155+
}
156+
};
157+
130158
template <> class SYCLConfig<SYCL_UR_TRACE> {
131159
using BaseT = SYCLConfigBase<SYCL_UR_TRACE>;
132160

sycl/test-e2e/KernelAndProgram/persistent-cache-multi-device.cpp

Lines changed: 0 additions & 46 deletions
This file was deleted.

sycl/test-e2e/ProgramManager/multi_device_bundle/build_twice.cpp

Lines changed: 0 additions & 62 deletions
This file was deleted.

sycl/test-e2e/ProgramManager/multi_device_bundle/device_libs_and_caching.cpp

Lines changed: 0 additions & 164 deletions
This file was deleted.

sycl/unittests/helpers/MockDeviceImage.hpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ template <typename T> LifetimeExtender(std::vector<T>) -> LifetimeExtender<T>;
161161
/// Convenience wrapper for sycl_device_binary_property_set.
162162
class MockPropertySet {
163163
public:
164-
MockPropertySet() {
164+
MockPropertySet(const std::vector<DeviceLibExt> &DeviceLibExts = {}) {
165165
// Most of unit-tests are statically linked with SYCL RT. On Linux and Mac
166166
// systems that causes incorrect RT installation directory detection, which
167167
// prevents proper loading of fallback libraries. See intel/llvm#6945
@@ -170,11 +170,23 @@ class MockPropertySet {
170170
// unless there is a special property attached to it or special env variable
171171
// is set which forces RT to skip fallback libraries.
172172
//
173-
// Setting this property here so unit-tests can be launched under any
174-
// environment.
173+
// By default, property is set to empty mask here so that unit-tests can be
174+
// launched under any environment. Some unit tests might create dummy
175+
// fallback libaries and require fallback libraries to be loaded, in such
176+
// case input vector will be non-empty.
175177

176-
std::vector<char> Data(/* eight elements */ 8,
178+
std::vector<char> Data(/* four elements */ 4,
177179
/* each element is zero */ 0);
180+
if (!DeviceLibExts.empty()) {
181+
uint32_t DeviceLibReqMask = 0;
182+
for (auto Ext : DeviceLibExts) {
183+
DeviceLibReqMask |= 0x1
184+
<< (static_cast<uint32_t>(Ext) -
185+
static_cast<uint32_t>(
186+
DeviceLibExt::cl_intel_devicelib_assert));
187+
}
188+
std::memcpy(Data.data(), &DeviceLibReqMask, sizeof(DeviceLibReqMask));
189+
}
178190
// Name doesn't matter here, it is not used by RT
179191
// Value must be an all-zero 32-bit mask, which would mean that no fallback
180192
// libraries are needed to be loaded.

sycl/unittests/program_manager/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ add_sycl_unittest(ProgramManagerTests OBJECT
66
SubDevices.cpp
77
passing_link_and_compile_options.cpp
88
Cleanup.cpp
9+
MultipleDevsKernelBundle.cpp
910
)
1011

1112
add_subdirectory(arg_mask)

0 commit comments

Comments
 (0)