Skip to content

Commit 13e5a32

Browse files
[SYCL][NFC] Use common mock kernel info base in unit tests (#8736)
1 parent 10e07a3 commit 13e5a32

File tree

14 files changed

+96
-324
lines changed

14 files changed

+96
-324
lines changed

sycl/unittests/Extensions/DeviceGlobal.cpp

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "detail/context_impl.hpp"
1313
#include "detail/kernel_program_cache.hpp"
1414

15+
#include <helpers/MockKernelInfo.hpp>
1516
#include <helpers/PiImage.hpp>
1617
#include <helpers/PiMock.hpp>
1718

@@ -42,31 +43,17 @@ sycl::ext::oneapi::experimental::device_global<
4243
namespace sycl {
4344
__SYCL_INLINE_VER_NAMESPACE(_V1) {
4445
namespace detail {
45-
template <> struct KernelInfo<DeviceGlobalTestKernel> {
46-
static constexpr unsigned getNumParams() { return 0; }
47-
static const kernel_param_desc_t &getParamDesc(int) {
48-
static kernel_param_desc_t Dummy;
49-
return Dummy;
50-
}
46+
template <>
47+
struct KernelInfo<DeviceGlobalTestKernel>
48+
: public unittest::MockKernelInfoBase {
5149
static constexpr const char *getName() { return DeviceGlobalTestKernelName; }
52-
static constexpr bool isESIMD() { return false; }
53-
static constexpr bool callsThisItem() { return false; }
54-
static constexpr bool callsAnyThisFreeFunction() { return false; }
55-
static constexpr int64_t getKernelSize() { return 1; }
5650
};
57-
template <> struct KernelInfo<DeviceGlobalImgScopeTestKernel> {
58-
static constexpr unsigned getNumParams() { return 0; }
59-
static const kernel_param_desc_t &getParamDesc(int) {
60-
static kernel_param_desc_t Dummy;
61-
return Dummy;
62-
}
51+
template <>
52+
struct KernelInfo<DeviceGlobalImgScopeTestKernel>
53+
: public unittest::MockKernelInfoBase {
6354
static constexpr const char *getName() {
6455
return DeviceGlobalImgScopeTestKernelName;
6556
}
66-
static constexpr bool isESIMD() { return false; }
67-
static constexpr bool callsThisItem() { return false; }
68-
static constexpr bool callsAnyThisFreeFunction() { return false; }
69-
static constexpr int64_t getKernelSize() { return 1; }
7057
};
7158
} // namespace detail
7259
} // __SYCL_INLINE_VER_NAMESPACE(_V1)

sycl/unittests/Extensions/USMMemcpy2D.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <detail/queue_impl.hpp>
1212

13+
#include <helpers/MockKernelInfo.hpp>
1314
#include <helpers/PiImage.hpp>
1415
#include <helpers/PiMock.hpp>
1516

@@ -23,7 +24,9 @@ constexpr const char *USMMemcpyHelperKernelNameChar = "__usmmemcpy2d_char";
2324
namespace sycl {
2425
__SYCL_INLINE_VER_NAMESPACE(_V1) {
2526
namespace detail {
26-
template <> struct KernelInfo<class __usmfill2d<long>> {
27+
template <>
28+
struct KernelInfo<class __usmfill2d<long>>
29+
: public unittest::MockKernelInfoBase {
2730
static constexpr const char *getName() { return USMFillHelperKernelNameLong; }
2831
static constexpr unsigned getNumParams() { return 7; }
2932
static const kernel_param_desc_t &getParamDesc(int Idx) {
@@ -39,15 +42,14 @@ template <> struct KernelInfo<class __usmfill2d<long>> {
3942
};
4043
return DummySignature[Idx];
4144
}
42-
static constexpr bool isESIMD() { return false; }
43-
static constexpr bool callsThisItem() { return false; }
44-
static constexpr bool callsAnyThisFreeFunction() { return false; }
4545
static constexpr int64_t getKernelSize() {
4646
return 2 * sizeof(void *) + 2 * sizeof(sycl::id<2>) + 3 * sizeof(size_t);
4747
}
4848
};
4949

50-
template <> struct KernelInfo<class __usmfill2d<unsigned char>> {
50+
template <>
51+
struct KernelInfo<class __usmfill2d<unsigned char>>
52+
: public unittest::MockKernelInfoBase {
5153
static constexpr const char *getName() { return USMFillHelperKernelNameChar; }
5254
static constexpr unsigned getNumParams() { return 7; }
5355
static const kernel_param_desc_t &getParamDesc(int Idx) {
@@ -63,15 +65,14 @@ template <> struct KernelInfo<class __usmfill2d<unsigned char>> {
6365
};
6466
return DummySignature[Idx];
6567
}
66-
static constexpr bool isESIMD() { return false; }
67-
static constexpr bool callsThisItem() { return false; }
68-
static constexpr bool callsAnyThisFreeFunction() { return false; }
6968
static constexpr int64_t getKernelSize() {
7069
return 2 * sizeof(void *) + 2 * sizeof(sycl::id<2>) + 3 * sizeof(size_t);
7170
}
7271
};
7372

74-
template <> struct KernelInfo<class __usmmemcpy2d<long>> {
73+
template <>
74+
struct KernelInfo<class __usmmemcpy2d<long>>
75+
: public unittest::MockKernelInfoBase {
7576
static constexpr const char *getName() {
7677
return USMMemcpyHelperKernelNameLong;
7778
}
@@ -90,15 +91,14 @@ template <> struct KernelInfo<class __usmmemcpy2d<long>> {
9091
};
9192
return DummySignature[Idx];
9293
}
93-
static constexpr bool isESIMD() { return false; }
94-
static constexpr bool callsThisItem() { return false; }
95-
static constexpr bool callsAnyThisFreeFunction() { return false; }
9694
static constexpr int64_t getKernelSize() {
9795
return 2 * sizeof(void *) + 2 * sizeof(sycl::id<2>) + 4 * sizeof(size_t);
9896
}
9997
};
10098

101-
template <> struct KernelInfo<class __usmmemcpy2d<unsigned char>> {
99+
template <>
100+
struct KernelInfo<class __usmmemcpy2d<unsigned char>>
101+
: public unittest::MockKernelInfoBase {
102102
static constexpr const char *getName() {
103103
return USMMemcpyHelperKernelNameChar;
104104
}
@@ -117,9 +117,6 @@ template <> struct KernelInfo<class __usmmemcpy2d<unsigned char>> {
117117
};
118118
return DummySignature[Idx];
119119
}
120-
static constexpr bool isESIMD() { return false; }
121-
static constexpr bool callsThisItem() { return false; }
122-
static constexpr bool callsAnyThisFreeFunction() { return false; }
123120
static constexpr int64_t getKernelSize() {
124121
return 2 * sizeof(void *) + 2 * sizeof(sycl::id<2>) + 4 * sizeof(size_t);
125122
}

sycl/unittests/SYCL2020/IsCompatible.cpp

Lines changed: 23 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <sycl/sycl.hpp>
22

3+
#include <helpers/MockKernelInfo.hpp>
34
#include <helpers/PiImage.hpp>
45
#include <helpers/PiMock.hpp>
56

@@ -16,141 +17,51 @@ class TestKernelACC;
1617
namespace sycl {
1718
__SYCL_INLINE_VER_NAMESPACE(_V1) {
1819
namespace detail {
19-
template <> struct KernelInfo<TestKernelCPU> {
20-
static constexpr unsigned getNumParams() { return 0; }
21-
static const kernel_param_desc_t &getParamDesc(int) {
22-
static kernel_param_desc_t Dummy;
23-
return Dummy;
24-
}
20+
template <>
21+
struct KernelInfo<TestKernelCPU> : public unittest::MockKernelInfoBase {
2522
static constexpr const char *getName() { return "TestKernelCPU"; }
26-
static constexpr bool isESIMD() { return false; }
27-
static constexpr bool callsThisItem() { return false; }
28-
static constexpr bool callsAnyThisFreeFunction() { return false; }
29-
static constexpr int64_t getKernelSize() { return 1; }
3023
};
3124

32-
} // namespace detail
33-
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
34-
} // namespace sycl
35-
36-
namespace sycl {
37-
__SYCL_INLINE_VER_NAMESPACE(_V1) {
38-
namespace detail {
39-
template <> struct KernelInfo<TestKernelCPUInvalidReqdWGSize1D> {
40-
static constexpr unsigned getNumParams() { return 0; }
41-
static const kernel_param_desc_t &getParamDesc(int) {
42-
static kernel_param_desc_t Dummy;
43-
return Dummy;
25+
template <>
26+
struct KernelInfo<TestKernelCPUInvalidReqdWGSize1D>
27+
: public unittest::MockKernelInfoBase {
28+
static constexpr const char *getName() {
29+
return "TestKernelCPUInvalidReqdWGSize1D";
4430
}
45-
static constexpr const char *getName() { return "TestKernelCPUInvalidReqdWGSize1D"; }
46-
static constexpr bool isESIMD() { return false; }
47-
static constexpr bool callsThisItem() { return false; }
48-
static constexpr bool callsAnyThisFreeFunction() { return false; }
49-
static constexpr int64_t getKernelSize() { return 1; }
5031
};
5132

52-
} // namespace detail
53-
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
54-
} // namespace sycl
55-
56-
namespace sycl {
57-
__SYCL_INLINE_VER_NAMESPACE(_V1) {
58-
namespace detail {
59-
template <> struct KernelInfo<TestKernelCPUInvalidReqdWGSize2D> {
60-
static constexpr unsigned getNumParams() { return 0; }
61-
static const kernel_param_desc_t &getParamDesc(int) {
62-
static kernel_param_desc_t Dummy;
63-
return Dummy;
33+
template <>
34+
struct KernelInfo<TestKernelCPUInvalidReqdWGSize2D>
35+
: public unittest::MockKernelInfoBase {
36+
static constexpr const char *getName() {
37+
return "TestKernelCPUInvalidReqdWGSize2D";
6438
}
65-
static constexpr const char *getName() { return "TestKernelCPUInvalidReqdWGSize2D"; }
66-
static constexpr bool isESIMD() { return false; }
67-
static constexpr bool callsThisItem() { return false; }
68-
static constexpr bool callsAnyThisFreeFunction() { return false; }
69-
static constexpr int64_t getKernelSize() { return 1; }
7039
};
7140

72-
} // namespace detail
73-
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
74-
} // namespace sycl
75-
76-
namespace sycl {
77-
__SYCL_INLINE_VER_NAMESPACE(_V1) {
78-
namespace detail {
79-
template <> struct KernelInfo<TestKernelCPUInvalidReqdWGSize3D> {
80-
static constexpr unsigned getNumParams() { return 0; }
81-
static const kernel_param_desc_t &getParamDesc(int) {
82-
static kernel_param_desc_t Dummy;
83-
return Dummy;
84-
}
41+
template <>
42+
struct KernelInfo<TestKernelCPUInvalidReqdWGSize3D>
43+
: public unittest::MockKernelInfoBase {
8544
static constexpr const char *getName() {
8645
return "TestKernelCPUInvalidReqdWGSize3D";
8746
}
88-
static constexpr bool isESIMD() { return false; }
89-
static constexpr bool callsThisItem() { return false; }
90-
static constexpr bool callsAnyThisFreeFunction() { return false; }
91-
static constexpr int64_t getKernelSize() { return 1; }
9247
};
9348

94-
} // namespace detail
95-
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
96-
} // namespace sycl
97-
98-
namespace sycl {
99-
__SYCL_INLINE_VER_NAMESPACE(_V1) {
100-
namespace detail {
101-
template <> struct KernelInfo<TestKernelCPUValidReqdWGSize3D> {
102-
static constexpr unsigned getNumParams() { return 0; }
103-
static const kernel_param_desc_t &getParamDesc(int) {
104-
static kernel_param_desc_t Dummy;
105-
return Dummy;
106-
}
49+
template <>
50+
struct KernelInfo<TestKernelCPUValidReqdWGSize3D>
51+
: public unittest::MockKernelInfoBase {
10752
static constexpr const char *getName() {
10853
return "TestKernelCPUValidReqdWGSize3D";
10954
}
110-
static constexpr bool isESIMD() { return false; }
111-
static constexpr bool callsThisItem() { return false; }
112-
static constexpr bool callsAnyThisFreeFunction() { return false; }
113-
static constexpr int64_t getKernelSize() { return 1; }
11455
};
11556

116-
} // namespace detail
117-
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
118-
} // namespace sycl
119-
120-
namespace sycl {
121-
__SYCL_INLINE_VER_NAMESPACE(_V1) {
122-
namespace detail {
123-
template <> struct KernelInfo<TestKernelGPU> {
124-
static constexpr unsigned getNumParams() { return 0; }
125-
static const kernel_param_desc_t &getParamDesc(int) {
126-
static kernel_param_desc_t Dummy;
127-
return Dummy;
128-
}
57+
template <>
58+
struct KernelInfo<TestKernelGPU> : public unittest::MockKernelInfoBase {
12959
static constexpr const char *getName() { return "TestKernelGPU"; }
130-
static constexpr bool isESIMD() { return false; }
131-
static constexpr bool callsThisItem() { return false; }
132-
static constexpr bool callsAnyThisFreeFunction() { return false; }
133-
static constexpr int64_t getKernelSize() { return 1; }
13460
};
13561

136-
} // namespace detail
137-
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
138-
} // namespace sycl
139-
140-
namespace sycl {
141-
__SYCL_INLINE_VER_NAMESPACE(_V1) {
142-
namespace detail {
143-
template <> struct KernelInfo<TestKernelACC> {
144-
static constexpr unsigned getNumParams() { return 0; }
145-
static const kernel_param_desc_t &getParamDesc(int) {
146-
static kernel_param_desc_t Dummy;
147-
return Dummy;
148-
}
62+
template <>
63+
struct KernelInfo<TestKernelACC> : public unittest::MockKernelInfoBase {
14964
static constexpr const char *getName() { return "TestKernelACC"; }
150-
static constexpr bool isESIMD() { return false; }
151-
static constexpr bool callsThisItem() { return false; }
152-
static constexpr bool callsAnyThisFreeFunction() { return false; }
153-
static constexpr int64_t getKernelSize() { return 1; }
15465
};
15566

15667
} // namespace detail

sycl/unittests/SYCL2020/KernelBundle.cpp

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <detail/kernel_bundle_impl.hpp>
1111
#include <sycl/sycl.hpp>
1212

13+
#include <helpers/MockKernelInfo.hpp>
1314
#include <helpers/PiImage.hpp>
1415
#include <helpers/PiMock.hpp>
1516

@@ -22,43 +23,19 @@ class TestKernelWithAspects;
2223
namespace sycl {
2324
__SYCL_INLINE_VER_NAMESPACE(_V1) {
2425
namespace detail {
25-
template <> struct KernelInfo<TestKernel> {
26-
static constexpr unsigned getNumParams() { return 0; }
27-
static const kernel_param_desc_t &getParamDesc(int) {
28-
static kernel_param_desc_t Dummy;
29-
return Dummy;
30-
}
26+
template <>
27+
struct KernelInfo<TestKernel> : public unittest::MockKernelInfoBase {
3128
static constexpr const char *getName() { return "TestKernel"; }
32-
static constexpr bool isESIMD() { return false; }
33-
static constexpr bool callsThisItem() { return false; }
34-
static constexpr bool callsAnyThisFreeFunction() { return false; }
35-
static constexpr int64_t getKernelSize() { return 1; }
3629
};
3730

38-
template <> struct KernelInfo<TestKernelExeOnly> {
39-
static constexpr unsigned getNumParams() { return 0; }
40-
static const kernel_param_desc_t &getParamDesc(int) {
41-
static kernel_param_desc_t Dummy;
42-
return Dummy;
43-
}
31+
template <>
32+
struct KernelInfo<TestKernelExeOnly> : public unittest::MockKernelInfoBase {
4433
static constexpr const char *getName() { return "TestKernelExeOnly"; }
45-
static constexpr bool isESIMD() { return false; }
46-
static constexpr bool callsThisItem() { return false; }
47-
static constexpr bool callsAnyThisFreeFunction() { return false; }
48-
static constexpr int64_t getKernelSize() { return 1; }
4934
};
5035

51-
template <> struct KernelInfo<TestKernelWithAspects> {
52-
static constexpr unsigned getNumParams() { return 0; }
53-
static const kernel_param_desc_t &getParamDesc(int) {
54-
static kernel_param_desc_t Dummy;
55-
return Dummy;
56-
}
36+
template <>
37+
struct KernelInfo<TestKernelWithAspects> : public unittest::MockKernelInfoBase {
5738
static constexpr const char *getName() { return "TestKernelWithAspects"; }
58-
static constexpr bool isESIMD() { return false; }
59-
static constexpr bool callsThisItem() { return false; }
60-
static constexpr bool callsAnyThisFreeFunction() { return false; }
61-
static constexpr int64_t getKernelSize() { return 1; }
6239
};
6340

6441
} // namespace detail

0 commit comments

Comments
 (0)