1
-
2
1
#include < CL/sycl.hpp>
3
2
4
3
#include < helpers/CommonRedefinitions.hpp>
10
9
std::string current_link_options, current_compile_options;
11
10
12
11
class EAMTestKernel ;
13
- const char EAMTestKernelName[] = " EAMTestKernel " ;
12
+ const char EAMTestKernelName[] = " LinkCompileTestKernel " ;
14
13
constexpr unsigned EAMTestKernelNumArgs = 4 ;
15
14
16
15
__SYCL_INLINE_NAMESPACE (cl) {
@@ -33,7 +32,8 @@ template <> struct KernelInfo<EAMTestKernel> {
33
32
} // __SYCL_INLINE_NAMESPACE(cl)
34
33
35
34
template <typename T>
36
- static sycl::unittest::PiImage generateEAMTestKernelImage (std::string _cmplOptions = " " , std::string _lnkOptions = " " ) {
35
+ static sycl::unittest::PiImage
36
+ generateEAMTestKernelImage (std::string _cmplOptions, std::string _lnkOptions) {
37
37
using namespace sycl ::unittest;
38
38
39
39
std::vector<unsigned char > KernelEAM{0b00000101 };
@@ -51,62 +51,165 @@ static sycl::unittest::PiImage generateEAMTestKernelImage(std::string _cmplOptio
51
51
52
52
PiImage Img{PI_DEVICE_BINARY_TYPE_SPIRV, // Format
53
53
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
54
- _cmplOptions, // Compile options
55
- _lnkOptions, // Link options
54
+ _cmplOptions, // Compile options
55
+ _lnkOptions, // Link options
56
56
std::move (Bin),
57
57
std::move (Entries),
58
58
std::move (PropSet)};
59
-
60
59
return Img;
61
60
}
62
61
63
-
64
62
inline pi_result redefinedProgramLink (pi_context, pi_uint32, const pi_device *,
65
- const char * _linkOpts, pi_uint32,
63
+ const char *_linkOpts, pi_uint32,
66
64
const pi_program *,
67
65
void (*)(pi_program, void *), void *,
68
66
pi_program *) {
69
67
assert (_linkOpts != nullptr );
70
68
current_link_options = std::string (_linkOpts);
71
- std::cout << " Passed link options --> " << _linkOpts << std::endl;
69
+ std::cout << " Passed link options --> ' " << _linkOpts << " ' " << std::endl;
72
70
return PI_SUCCESS;
73
71
}
74
72
75
73
inline pi_result redefinedProgramCompile (pi_program, pi_uint32,
76
- const pi_device *, const char * _compileOpts,
77
- pi_uint32, const pi_program * ,
78
- const char **,
74
+ const pi_device *,
75
+ const char *_compileOpts, pi_uint32 ,
76
+ const pi_program *, const char **,
79
77
void (*)(pi_program, void *), void *) {
80
78
assert (_compileOpts != nullptr );
81
79
current_compile_options = std::string (_compileOpts);
82
- std::cout << " Passed compile options --> " << _compileOpts << std::endl;
80
+ std::cout << " Passed compile options --> '" << _compileOpts << " '"
81
+ << std::endl;
83
82
return PI_SUCCESS;
84
83
}
85
84
86
85
TEST (Link_Compile_Options, compile_link_Options_Test_empty) {
87
- sycl::platform Plt{sycl::default_selector ()};
88
- sycl::unittest::PiMock Mock{Plt};
89
- setupDefaultMockAPIs (Mock);
90
- Mock.redefine <sycl::detail::PiApiKind::piProgramCompile>(redefinedProgramCompile);
91
- Mock.redefine <sycl::detail::PiApiKind::piProgramLink>(redefinedProgramLink);
92
-
93
- const sycl::device Dev = Plt.get_devices ()[0 ];
94
-
95
- current_link_options.clear ();
96
- current_compile_options.clear ();
97
- std::string expected_compile_options = " " ;
98
- std::string expected_link_options = " " ;
99
- static sycl::unittest::PiImage DevImage = generateEAMTestKernelImage<EAMTestKernel>(expected_compile_options, expected_link_options);
100
- auto KernelID = sycl::get_kernel_id<EAMTestKernel>();
101
-
102
- sycl::queue Queue{Dev};
103
-
104
- const sycl::context Ctx = Queue.get_context ();
105
- sycl::kernel_bundle KernelBundle =
106
- sycl::get_kernel_bundle<sycl::bundle_state::input>(Ctx, {Dev}, {KernelID});
107
-
108
- auto BundleObj = sycl::compile (KernelBundle);
109
- sycl::link (BundleObj);
110
- EXPECT_EQ (expected_link_options, current_link_options);
111
- EXPECT_EQ (expected_compile_options + " " , current_compile_options);
86
+ sycl::platform Plt{sycl::default_selector ()};
87
+ sycl::unittest::PiMock Mock{Plt};
88
+ setupDefaultMockAPIs (Mock);
89
+ Mock.redefine <sycl::detail::PiApiKind::piProgramCompile>(
90
+ redefinedProgramCompile);
91
+ Mock.redefine <sycl::detail::PiApiKind::piProgramLink>(redefinedProgramLink);
92
+
93
+ const sycl::device Dev = Plt.get_devices ()[0 ];
94
+
95
+ current_link_options.clear ();
96
+ current_compile_options.clear ();
97
+ std::string expected_compile_options = " " ;
98
+ std::string expected_link_options = " " ;
99
+ static sycl::unittest::PiImage DevImage =
100
+ generateEAMTestKernelImage<EAMTestKernel>(expected_compile_options,
101
+ expected_link_options);
102
+ static sycl::unittest::PiImageArray<1 > DevImageArray{&DevImage};
103
+ auto KernelID = sycl::get_kernel_id<EAMTestKernel>();
104
+
105
+ sycl::queue Queue{Dev};
106
+
107
+ const sycl::context Ctx = Queue.get_context ();
108
+ sycl::kernel_bundle KernelBundle =
109
+ sycl::get_kernel_bundle<sycl::bundle_state::input>(Ctx, {Dev},
110
+ {KernelID});
111
+
112
+ auto BundleObj = sycl::compile (KernelBundle);
113
+ sycl::link (BundleObj);
114
+ EXPECT_EQ (expected_link_options, current_link_options);
115
+ EXPECT_EQ (expected_compile_options, current_compile_options);
116
+ }
117
+
118
+ TEST (Link_Compile_Options, one_link_option_Test) {
119
+ sycl::platform Plt{sycl::default_selector ()};
120
+ sycl::unittest::PiMock Mock{Plt};
121
+ setupDefaultMockAPIs (Mock);
122
+ Mock.redefine <sycl::detail::PiApiKind::piProgramCompile>(
123
+ redefinedProgramCompile);
124
+ Mock.redefine <sycl::detail::PiApiKind::piProgramLink>(redefinedProgramLink);
125
+
126
+ const sycl::device Dev = Plt.get_devices ()[0 ];
127
+
128
+ current_link_options.clear ();
129
+ current_compile_options.clear ();
130
+ std::string expected_compile_options = " " ;
131
+ std::string expected_link_options = " -cl-denorms-are-zero" ;
132
+ static sycl::unittest::PiImage DevImage =
133
+ generateEAMTestKernelImage<EAMTestKernel>(expected_compile_options,
134
+ expected_link_options);
135
+ static sycl::unittest::PiImageArray<1 > DevImageArray{&DevImage};
136
+ auto KernelID = sycl::get_kernel_id<EAMTestKernel>();
137
+
138
+ sycl::queue Queue{Dev};
139
+
140
+ const sycl::context Ctx = Queue.get_context ();
141
+ sycl::kernel_bundle KernelBundle =
142
+ sycl::get_kernel_bundle<sycl::bundle_state::input>(Ctx, {Dev},
143
+ {KernelID});
144
+
145
+ auto BundleObj = sycl::compile (KernelBundle);
146
+ sycl::link (BundleObj);
147
+ EXPECT_EQ (expected_link_options, current_link_options);
148
+ EXPECT_EQ (expected_compile_options, current_compile_options);
149
+ }
150
+
151
+ TEST (Link_Compile_Options, one_compile_option_Test) {
152
+ sycl::platform Plt{sycl::default_selector ()};
153
+ sycl::unittest::PiMock Mock{Plt};
154
+ setupDefaultMockAPIs (Mock);
155
+ Mock.redefine <sycl::detail::PiApiKind::piProgramCompile>(
156
+ redefinedProgramCompile);
157
+ Mock.redefine <sycl::detail::PiApiKind::piProgramLink>(redefinedProgramLink);
158
+
159
+ const sycl::device Dev = Plt.get_devices ()[0 ];
160
+
161
+ current_link_options.clear ();
162
+ current_compile_options.clear ();
163
+ std::string expected_compile_options = " -cl-single-precision-constant" ;
164
+ std::string expected_link_options = " " ;
165
+ static sycl::unittest::PiImage DevImage =
166
+ generateEAMTestKernelImage<EAMTestKernel>(expected_compile_options,
167
+ expected_link_options);
168
+ static sycl::unittest::PiImageArray<1 > DevImageArray{&DevImage};
169
+ auto KernelID = sycl::get_kernel_id<EAMTestKernel>();
170
+
171
+ sycl::queue Queue{Dev};
172
+
173
+ const sycl::context Ctx = Queue.get_context ();
174
+ sycl::kernel_bundle KernelBundle =
175
+ sycl::get_kernel_bundle<sycl::bundle_state::input>(Ctx, {Dev},
176
+ {KernelID});
177
+
178
+ auto BundleObj = sycl::compile (KernelBundle);
179
+ sycl::link (BundleObj);
180
+ EXPECT_EQ (expected_link_options, current_link_options);
181
+ EXPECT_EQ (expected_compile_options, current_compile_options);
182
+ }
183
+
184
+ TEST (Link_Compile_Options, one_link_and_compile_option_Test) {
185
+ sycl::platform Plt{sycl::default_selector ()};
186
+ sycl::unittest::PiMock Mock{Plt};
187
+ setupDefaultMockAPIs (Mock);
188
+ Mock.redefine <sycl::detail::PiApiKind::piProgramCompile>(
189
+ redefinedProgramCompile);
190
+ Mock.redefine <sycl::detail::PiApiKind::piProgramLink>(redefinedProgramLink);
191
+
192
+ const sycl::device Dev = Plt.get_devices ()[0 ];
193
+
194
+ current_link_options.clear ();
195
+ current_compile_options.clear ();
196
+ std::string expected_compile_options = " -cl-single-precision-constant" ;
197
+ std::string expected_link_options = " -cl-finite-math-only" ;
198
+ static sycl::unittest::PiImage DevImage =
199
+ generateEAMTestKernelImage<EAMTestKernel>(expected_compile_options,
200
+ expected_link_options);
201
+ static sycl::unittest::PiImageArray<1 > DevImageArray{&DevImage};
202
+ auto KernelID = sycl::get_kernel_id<EAMTestKernel>();
203
+
204
+ sycl::queue Queue{Dev};
205
+
206
+ const sycl::context Ctx = Queue.get_context ();
207
+ sycl::kernel_bundle KernelBundle =
208
+ sycl::get_kernel_bundle<sycl::bundle_state::input>(Ctx, {Dev},
209
+ {KernelID});
210
+
211
+ auto BundleObj = sycl::compile (KernelBundle);
212
+ sycl::link (BundleObj);
213
+ EXPECT_EQ (expected_link_options, current_link_options);
214
+ EXPECT_EQ (expected_compile_options, current_compile_options);
112
215
}
0 commit comments