1313 bool operator ()(sycl::queue &Q, cmplx<T> init, \
1414 cmplx<T> ref = cmplx<T>(0 , 0 ), bool use_ref = false) { \
1515 bool pass = true ; \
16- \
1716 auto std_in = init_std_complex (init.re , init.im ); \
1817 experimental::complex <T> cplx_input{init.re , init.im }; \
19- \
20- auto *cplx_out = sycl::malloc_shared<experimental::complex <T>>(1 , Q); \
21- \
18+ sycl::buffer<experimental::complex <T>> cplx_out_buf{sycl::range{1 }}; \
2219 /* Get std::complex output*/ \
2320 std::complex <T> std_out{ref.re , ref.im }; \
2421 if (!use_ref) \
2522 std_out = std::math_func (std_in); \
26- \
2723 /* Check cplx::complex output from device*/ \
28- Q.single_task ([=]() { \
29- cplx_out[0 ] = experimental::math_func<T>(cplx_input); \
30- }).wait (); \
31- \
32- pass &= check_results (cplx_out[0 ], std_out, /* is_device*/ true ); \
24+ Q.submit ([&](sycl::handler &h) { \
25+ sycl::accessor cplx_out{cplx_out_buf, h}; \
26+ h.single_task ( \
27+ [=]() { cplx_out[0 ] = experimental::math_func<T>(cplx_input); }); \
28+ }); \
29+ sycl::host_accessor cplx_out_acc{cplx_out_buf}; \
30+ pass &= check_results (cplx_out_acc[0 ], std_out, /* is_device*/ true ); \
3331 \
3432 /* Check cplx::complex output from host*/ \
35- cplx_out[0 ] = experimental::math_func<T>(cplx_input); \
36- \
37- pass &= check_results (cplx_out[0 ], std_out, /* is_device*/ false ); \
38- \
39- sycl::free (cplx_out, Q); \
33+ cplx_out_acc[0 ] = experimental::math_func<T>(cplx_input); \
4034 \
35+ pass &= check_results (cplx_out_acc[0 ], std_out, /* is_device*/ false ); \
4136 return pass; \
4237 } \
4338 };
@@ -73,28 +68,26 @@ TEST_MATH_OP_TYPE(tanh)
7368 \
7469 auto std_in = init_std_complex (init.re , init.im ); \
7570 experimental::complex <T> cplx_input{init.re , init.im }; \
76- \
77- auto *cplx_out = sycl::malloc_shared<T>(1 , Q); \
71+ sycl::buffer<T> cplx_out_buf{sycl::range{1 }}; \
7872 \
7973 /* Get std::complex output*/ \
8074 T std_out = ref.re ; \
8175 if (!use_ref) \
8276 std_out = std::math_func (std_in); \
8377 \
8478 /* Check cplx::complex output from device*/ \
85- Q.single_task ([=]() { \
86- cplx_out[0 ] = experimental::math_func<T>(cplx_input); \
87- }).wait (); \
88- \
89- pass &= check_results (cplx_out[0 ], std_out, /* is_device*/ true ); \
79+ Q.submit ([&](sycl::handler &h) { \
80+ sycl::accessor cplx_out{cplx_out_buf, h}; \
81+ h.single_task ( \
82+ [=]() { cplx_out[0 ] = experimental::math_func<T>(cplx_input); }); \
83+ }); \
84+ sycl::host_accessor cplx_out_acc{cplx_out_buf}; \
85+ pass &= check_results (cplx_out_acc[0 ], std_out, /* is_device*/ true ); \
9086 \
9187 /* Check cplx::complex output from host*/ \
92- cplx_out[0 ] = experimental::math_func<T>(cplx_input); \
93- \
94- pass &= check_results (cplx_out[0 ], std_out, /* is_device*/ false ); \
95- \
96- sycl::free (cplx_out, Q); \
88+ cplx_out_acc[0 ] = experimental::math_func<T>(cplx_input); \
9789 \
90+ pass &= check_results (cplx_out_acc[0 ], std_out, /* is_device*/ false ); \
9891 return pass; \
9992 } \
10093 };
@@ -121,23 +114,21 @@ TEST_MATH_OP_TYPE(imag)
121114 std::complex <T> std_out = ref; \
122115 if (!use_ref) \
123116 std_out = std::math_func (std_in); \
124- \
125- auto *cplx_out = sycl::malloc_shared<experimental::complex <T>>(1 , Q); \
126- \
117+ sycl::buffer<experimental::complex <T>> cplx_out_buf{sycl::range{1 }}; \
127118 /* Check cplx::complex output from device*/ \
128- Q.single_task ([=]() { \
129- cplx_out[0 ] = experimental::math_func<X>(std_in); \
130- }).wait (); \
119+ Q.submit ([&](sycl::handler &h) { \
120+ sycl::accessor cplx_out{cplx_out_buf, h}; \
121+ h.single_task ( \
122+ [=]() { cplx_out[0 ] = experimental::math_func<X>(std_in); }); \
123+ }); \
124+ sycl::host_accessor cplx_out_acc{cplx_out_buf}; \
131125 \
132- pass &= check_results (cplx_out [0 ], std_out, /* is_device*/ true ); \
126+ pass &= check_results (cplx_out_acc [0 ], std_out, /* is_device*/ true ); \
133127 \
134128 /* Check cplx::complex output from host*/ \
135- cplx_out[0 ] = experimental::math_func<X>(std_in); \
136- \
137- pass &= check_results (cplx_out[0 ], std_out, /* is_device*/ false ); \
138- \
139- sycl::free (cplx_out, Q); \
129+ cplx_out_acc[0 ] = experimental::math_func<X>(std_in); \
140130 \
131+ pass &= check_results (cplx_out_acc[0 ], std_out, /* is_device*/ false ); \
141132 return pass; \
142133 } \
143134 };
@@ -161,23 +152,21 @@ TEST_MATH_OP_TYPE(proj)
161152 T std_out = ref; \
162153 if (!use_ref) \
163154 std_out = std::math_func (std_in); \
164- \
165- auto *cplx_out = sycl::malloc_shared<T>(1 , Q); \
166- \
155+ sycl::buffer<T> cplx_out_buf{sycl::range{1 }}; \
167156 /* Check cplx::complex output from device*/ \
168- Q.single_task ([=]() { \
169- cplx_out[0 ] = experimental::math_func<X>(init); \
170- }).wait (); \
157+ Q.submit ([&](sycl::handler &h) { \
158+ sycl::accessor cplx_out{cplx_out_buf, h}; \
159+ h.single_task ( \
160+ [=]() { cplx_out[0 ] = experimental::math_func<X>(std_in); }); \
161+ }); \
162+ sycl::host_accessor cplx_out_acc{cplx_out_buf}; \
171163 \
172- pass &= check_results (cplx_out [0 ], std_out, /* is_device*/ true ); \
164+ pass &= check_results (cplx_out_acc [0 ], std_out, /* is_device*/ true ); \
173165 \
174166 /* Check cplx::complex output from host*/ \
175- cplx_out[0 ] = experimental::math_func<X>(init); \
176- \
177- pass &= check_results (cplx_out[0 ], std_out, /* is_device*/ false ); \
178- \
179- sycl::free (cplx_out, Q); \
167+ cplx_out_acc[0 ] = experimental::math_func<X>(init); \
180168 \
169+ pass &= check_results (cplx_out_acc[0 ], std_out, /* is_device*/ false ); \
181170 return pass; \
182171 } \
183172 };
@@ -197,26 +186,25 @@ template <typename T> struct test_polar {
197186 bool use_ref = false) {
198187 bool pass = true ;
199188
200- auto *cplx_out = sycl::malloc_shared<experimental::complex <T>>(1 , Q);
201-
189+ sycl::buffer<experimental::complex <T>> cplx_out_buf{sycl::range (1 )};
202190 /* Get std::complex output*/
203191 std::complex <T> std_out{ref.re , ref.im };
204192 if (!use_ref)
205193 std_out = std::polar (init.re , init.im );
206194
207195 /* Check cplx::complex output from device*/
208- Q.single_task ([=]() {
209- cplx_out[0 ] = experimental::polar<T>(init.re , init.im );
210- }).wait ();
211-
212- pass &= check_results (cplx_out[0 ], std_out, /* is_device*/ true );
196+ Q.submit ([&](sycl::handler &h) {
197+ sycl::accessor cplx_out{cplx_out_buf, h};
198+ h.single_task (
199+ [=]() { cplx_out[0 ] = experimental::polar<T>(init.re , init.im ); });
200+ });
201+ sycl::host_accessor cplx_out_acc{cplx_out_buf};
202+ pass &= check_results (cplx_out_acc[0 ], std_out, /* is_device*/ true );
213203
214204 /* Check cplx::complex output from host*/
215- cplx_out[0 ] = experimental::polar<T>(init.re , init.im );
216-
217- pass &= check_results (cplx_out[0 ], std_out, /* is_device*/ false );
205+ cplx_out_acc[0 ] = experimental::polar<T>(init.re , init.im );
218206
219- sycl::free (cplx_out, Q );
207+ pass &= check_results (cplx_out_acc[ 0 ], std_out, /* is_device */ false );
220208
221209 return pass;
222210 }
0 commit comments