@@ -32,14 +32,13 @@ template <> struct KernelInfo<EAMTestKernel> {
32
32
} // namespace sycl
33
33
} // __SYCL_INLINE_NAMESPACE(cl)
34
34
35
-
35
+ template < typename T>
36
36
static sycl::unittest::PiImage generateEAMTestKernelImage (std::string _cmplOptions = " " , std::string _lnkOptions = " " ) {
37
37
using namespace sycl ::unittest;
38
38
39
- // Eliminated arguments are 1st and 3rd.
40
39
std::vector<unsigned char > KernelEAM{0b00000101 };
41
40
PiProperty EAMKernelPOI = makeKernelParamOptInfo (
42
- EAMTestKernelName , EAMTestKernelNumArgs, KernelEAM);
41
+ sycl::detail::KernelInfo<T>:: getName () , EAMTestKernelNumArgs, KernelEAM);
43
42
PiArray<PiProperty> ImgKPOI{std::move (EAMKernelPOI)};
44
43
45
44
PiPropertySet PropSet;
@@ -52,8 +51,8 @@ static sycl::unittest::PiImage generateEAMTestKernelImage(std::string _cmplOptio
52
51
53
52
PiImage Img{PI_DEVICE_BINARY_TYPE_SPIRV, // Format
54
53
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
55
- _cmplOptions. c_str (), // Compile options
56
- _lnkOptions. c_str (), // Link options
54
+ _cmplOptions, // Compile options
55
+ _lnkOptions, // Link options
57
56
std::move (Bin),
58
57
std::move (Entries),
59
58
std::move (PropSet)};
@@ -62,91 +61,52 @@ static sycl::unittest::PiImage generateEAMTestKernelImage(std::string _cmplOptio
62
61
}
63
62
64
63
65
- static pi_result redefinedProgramLink (pi_context, pi_uint32, const pi_device *,
64
+ inline pi_result redefinedProgramLink (pi_context, pi_uint32, const pi_device *,
66
65
const char * _linkOpts, pi_uint32,
67
66
const pi_program *,
68
67
void (*)(pi_program, void *), void *,
69
68
pi_program *) {
70
- if (_linkOpts) {
71
- current_link_options = std::string (_linkOpts);
72
- }
69
+ assert (_linkOpts != nullptr );
70
+ current_link_options = std::string (_linkOpts);
71
+ std::cout << " Passed link options --> " << _linkOpts << std::endl;
73
72
return PI_SUCCESS;
74
73
}
75
74
76
- static pi_result redefinedProgramCompile (pi_program, pi_uint32,
75
+ inline pi_result redefinedProgramCompile (pi_program, pi_uint32,
77
76
const pi_device *, const char * _compileOpts,
78
77
pi_uint32, const pi_program *,
79
78
const char **,
80
79
void (*)(pi_program, void *), void *) {
81
- if (_compileOpts) {
82
- current_compile_options = std::string (_compileOpts);
83
- }
80
+ assert (_compileOpts != nullptr );
81
+ current_compile_options = std::string (_compileOpts);
82
+ std::cout << " Passed compile options --> " << _compileOpts << std::endl;
84
83
return PI_SUCCESS;
85
84
}
86
85
87
- TEST (Link_Compile_Options, linkOptionsTest_empty ) {
86
+ TEST (Link_Compile_Options, compile_link_Options_Test_empty ) {
88
87
sycl::platform Plt{sycl::default_selector ()};
89
88
sycl::unittest::PiMock Mock{Plt};
90
-
89
+ setupDefaultMockAPIs (Mock);
91
90
Mock.redefine <sycl::detail::PiApiKind::piProgramCompile>(redefinedProgramCompile);
92
91
Mock.redefine <sycl::detail::PiApiKind::piProgramLink>(redefinedProgramLink);
93
-
92
+
93
+ const sycl::device Dev = Plt.get_devices ()[0 ];
94
94
95
95
current_link_options.clear ();
96
96
current_compile_options.clear ();
97
97
std::string expected_compile_options = " " ;
98
98
std::string expected_link_options = " " ;
99
- static sycl::unittest::PiImage DevImage = generateEAMTestKernelImage (expected_compile_options, expected_link_options);
100
- auto BundleObj = sycl::compile (DevImage);
101
- sycl::link (BundleObj);
102
- EXPECT_EQ (expected_link_options, current_link_options);
103
- }
99
+ static sycl::unittest::PiImage DevImage = generateEAMTestKernelImage<EAMTestKernel>(expected_compile_options, expected_link_options);
100
+ auto KernelID = sycl::get_kernel_id<EAMTestKernel>();
104
101
105
- TEST (Link_Compile_Options, linkOptionsTest_one_param) {
106
- sycl::platform Plt{sycl::default_selector ()};
107
- sycl::unittest::PiMock Mock{Plt};
102
+ sycl::queue Queue{Dev};
108
103
109
- Mock.redefine <sycl::detail::PiApiKind::piProgramCompile>(redefinedProgramCompile);
110
- Mock.redefine <sycl::detail::PiApiKind::piProgramLink>(redefinedProgramLink);
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});
111
107
112
- current_link_options.clear ();
113
- current_compile_options.clear ();
114
- std::string expected_compile_options = " " ;
115
- std::string expected_link_options = " -foo" ;
116
- static sycl::unittest::PiImage DevImage = generateEAMTestKernelImage (expected_compile_options, expected_link_options);
117
- auto BundleObj = sycl::compile (DevImage);
108
+ auto BundleObj = sycl::compile (KernelBundle);
118
109
sycl::link (BundleObj);
119
110
EXPECT_EQ (expected_link_options, current_link_options);
120
- }
121
-
122
- TEST (Link_Compile_Options, compileOptionsTest_empty) {
123
- sycl::platform Plt{sycl::default_selector ()};
124
- sycl::unittest::PiMock Mock{Plt};
125
-
126
- Mock.redefine <sycl::detail::PiApiKind::piProgramCompile>(redefinedProgramCompile);
127
- Mock.redefine <sycl::detail::PiApiKind::piProgramLink>(redefinedProgramLink);
128
-
129
- current_link_options.clear ();
130
- current_compile_options.clear ();
131
- std::string expected_compile_options = " " ;
132
- std::string expected_link_options = " " ;
133
- static sycl::unittest::PiImage DevImage = generateEAMTestKernelImage (expected_compile_options, expected_link_options);
134
- auto BundleObj = sycl::compile (DevImage);
135
- EXPECT_EQ (expected_link_options, current_link_options);
136
- }
137
-
138
- TEST (Link_Compile_Options, compileOptionsTest_one_param) {
139
- sycl::platform Plt{sycl::default_selector ()};
140
- sycl::unittest::PiMock Mock{Plt};
141
-
142
- Mock.redefine <sycl::detail::PiApiKind::piProgramCompile>(redefinedProgramCompile);
143
- Mock.redefine <sycl::detail::PiApiKind::piProgramLink>(redefinedProgramLink);
144
-
145
- current_link_options.clear ();
146
- current_compile_options.clear ();
147
- std::string expected_compile_options = " -foo" ;
148
- std::string expected_link_options = " " ;
149
- static sycl::unittest::PiImage DevImage = generateEAMTestKernelImage (expected_compile_options, expected_link_options);
150
- auto BundleObj = sycl::compile (DevImage);
151
- EXPECT_EQ (expected_link_options, current_link_options);
111
+ EXPECT_EQ (expected_compile_options + " " , current_compile_options);
152
112
}
0 commit comments