Skip to content

Commit ed4811e

Browse files
committed
Refactor some tests
1 parent cb440dc commit ed4811e

File tree

3 files changed

+15
-71
lines changed

3 files changed

+15
-71
lines changed

sycl/unittests/kernel-and-program/Cache.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#define SYCL2020_DISABLE_DEPRECATION_WARNINGS
1010

1111
#include "CL/sycl/detail/pi.h"
12-
#include "HelperKernelInfo.hpp"
1312
#include "detail/context_impl.hpp"
1413
#include "detail/kernel_program_cache.hpp"
1514
#include "detail/program_impl.hpp"
@@ -38,14 +37,24 @@ class TestKernel2 {
3837
__SYCL_INLINE_NAMESPACE(cl) {
3938
namespace sycl {
4039
namespace detail {
40+
struct MockKernelInfo {
41+
static constexpr unsigned getNumParams() { return 0; }
42+
static const kernel_param_desc_t &getParamDesc(int) {
43+
static kernel_param_desc_t Dummy;
44+
return Dummy;
45+
}
46+
static constexpr const char *getName() { return "TestKernel2"; }
47+
static constexpr bool isESIMD() { return false; }
48+
static constexpr bool callsThisItem() { return false; }
49+
static constexpr bool callsAnyThisFreeFunction() { return false; }
50+
};
51+
4152
template <> struct KernelInfo<TestKernel> : public MockKernelInfo {
4253
static constexpr const char *getName() { return "TestKernel"; }
4354
};
44-
4555
template <> struct KernelInfo<TestKernel2> : public MockKernelInfo {
4656
static constexpr const char *getName() { return "TestKernel2"; }
4757
};
48-
4958
} // namespace detail
5059
} // namespace sycl
5160
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/unittests/kernel-and-program/HelperKernelInfo.hpp

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

sycl/unittests/kernel-and-program/MultipleDevsCache.cpp

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,20 @@
88

99
#define SYCL2020_DISABLE_DEPRECATION_WARNINGS
1010

11-
#include "HelperKernelInfo.hpp"
1211
#include "detail/context_impl.hpp"
1312
#include "detail/kernel_bundle_impl.hpp"
1413
#include "detail/kernel_program_cache.hpp"
15-
#include <CL/sycl.hpp>
1614
#include <helpers/CommonRedefinitions.hpp>
1715
#include <helpers/PiImage.hpp>
1816
#include <helpers/PiMock.hpp>
17+
#include <helpers/TestKernel.hpp>
1918

2019
#include <gtest/gtest.h>
2120

2221
#include <iostream>
2322

2423
using namespace sycl;
2524

26-
class MultTestKernel;
27-
28-
__SYCL_INLINE_NAMESPACE(cl) {
29-
namespace sycl {
30-
namespace detail {
31-
template <> struct KernelInfo<MultTestKernel> : public MockKernelInfo {
32-
static constexpr const char *getName() { return "MultTestKernel"; }
33-
};
34-
} // namespace detail
35-
} // namespace sycl
36-
} // __SYCL_INLINE_NAMESPACE(cl)
37-
38-
static sycl::unittest::PiImage generateDefaultImage() {
39-
using namespace sycl::unittest;
40-
41-
PiPropertySet PropSet;
42-
43-
std::vector<unsigned char> Bin{0, 1, 2, 3, 4, 5}; // Random data
44-
45-
PiArray<PiOffloadEntry> Entries = makeEmptyKernels({"MultTestKernel"});
46-
47-
PiImage Img{PI_DEVICE_BINARY_TYPE_SPIRV, // Format
48-
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
49-
"", // Compile options
50-
"", // Link options
51-
std::move(Bin),
52-
std::move(Entries),
53-
std::move(PropSet)};
54-
55-
return Img;
56-
}
57-
58-
static sycl::unittest::PiImage Img = generateDefaultImage();
59-
static sycl::unittest::PiImageArray<1> ImgArray{&Img};
60-
6125
static pi_result redefinedContextCreate(
6226
const pi_context_properties *properties, pi_uint32 num_devices,
6327
const pi_device *devices,
@@ -188,11 +152,11 @@ TEST_F(MultipleDeviceCacheTest, ProgramRetain) {
188152
auto Bundle = cl::sycl::get_kernel_bundle<sycl::bundle_state::input>(
189153
Queue.get_context());
190154
Queue.submit([&](cl::sycl::handler &cgh) {
191-
cgh.single_task<MultTestKernel>([]() {});
155+
cgh.single_task<TestKernel>([]() {});
192156
});
193157

194158
auto BundleObject = cl::sycl::build(Bundle, Bundle.get_devices());
195-
auto KernelID = cl::sycl::get_kernel_id<MultTestKernel>();
159+
auto KernelID = cl::sycl::get_kernel_id<TestKernel>();
196160
auto Kernel = BundleObject.get_kernel(KernelID);
197161

198162
// Because of emulating 2 devices program is retained for each one in

0 commit comments

Comments
 (0)