@@ -1244,7 +1244,7 @@ void dpnp_rng_uniform_c(void* result, const long low, const long high, const siz
1244
1244
template <typename _DataType>
1245
1245
void dpnp_rng_vonmises_large_kappa_c (void * result, const _DataType mu, const _DataType kappa, const size_t size)
1246
1246
{
1247
- if (!size)
1247
+ if (!size || !result )
1248
1248
{
1249
1249
return ;
1250
1250
}
@@ -1314,20 +1314,23 @@ void dpnp_rng_vonmises_large_kappa_c(void* result, const _DataType mu, const _Da
1314
1314
dpnp_memory_free_c (Uvec);
1315
1315
1316
1316
mkl_rng::uniform<_DataType> uniform_distribution (d_zero, d_one);
1317
- auto event_out = mkl_rng::generate (uniform_distribution, DPNP_RNG_ENGINE, size, Vvec);
1318
- event_out.wait ();
1317
+ auto uniform_distr_event = mkl_rng::generate (uniform_distribution, DPNP_RNG_ENGINE, size, Vvec);
1319
1318
1320
- // TODO
1321
- // kernel
1322
- for (size_t i = 0 ; i < size; i++)
1323
- {
1324
- _DataType mod, resi;
1319
+ cl::sycl::range<1 > gws (size);
1325
1320
1326
- resi = (Vvec[i] < 0.5 ) ? mu - result1[i] : mu + result1[i];
1327
- mod = fabs (resi);
1328
- mod = (fmod (mod + M_PI, 2 * M_PI) - M_PI);
1329
- result1[i] = (resi < 0 ) ? -mod : mod;
1330
- }
1321
+ auto paral_kernel_acceptance = [&](cl::sycl::handler& cgh) {
1322
+ cgh.depends_on ({uniform_distr_event});
1323
+ cgh.parallel_for (gws, [=](cl::sycl::id<1 > global_id) {
1324
+ size_t i = global_id[0 ];
1325
+ double mod, resi;
1326
+ resi = (Vvec[i] < 0.5 ) ? mu - result1[i] : mu + result1[i];
1327
+ mod = cl::sycl::fabs (resi);
1328
+ mod = (cl::sycl::fmod (mod + M_PI, 2 * M_PI) - M_PI);
1329
+ result1[i] = (resi < 0 ) ? -mod : mod;
1330
+ });
1331
+ };
1332
+ auto acceptance_event = DPNP_QUEUE.submit (paral_kernel_acceptance);
1333
+ acceptance_event.wait ();
1331
1334
1332
1335
dpnp_memory_free_c (Vvec);
1333
1336
return ;
@@ -1336,7 +1339,7 @@ void dpnp_rng_vonmises_large_kappa_c(void* result, const _DataType mu, const _Da
1336
1339
template <typename _DataType>
1337
1340
void dpnp_rng_vonmises_small_kappa_c (void * result, const _DataType mu, const _DataType kappa, const size_t size)
1338
1341
{
1339
- if (!size)
1342
+ if (!size || !result )
1340
1343
{
1341
1344
return ;
1342
1345
}
@@ -1391,20 +1394,22 @@ void dpnp_rng_vonmises_small_kappa_c(void* result, const _DataType mu, const _Da
1391
1394
dpnp_memory_free_c (Uvec);
1392
1395
1393
1396
mkl_rng::uniform<_DataType> uniform_distribution (d_zero, d_one);
1394
- auto event_out = mkl_rng::generate (uniform_distribution, DPNP_RNG_ENGINE, size, Vvec);
1395
- event_out.wait ();
1397
+ auto uniform_distr_event = mkl_rng::generate (uniform_distribution, DPNP_RNG_ENGINE, size, Vvec);
1396
1398
1397
- // TODO
1398
- // kernel
1399
- for (size_t i = 0 ; i < size; i++)
1400
- {
1401
- double mod, resi;
1402
-
1403
- resi = (Vvec[i] < 0.5 ) ? mu - result1[i] : mu + result1[i];
1404
- mod = fabs (resi);
1405
- mod = (fmod (mod + M_PI, 2 * M_PI) - M_PI);
1406
- result1[i] = (resi < 0 ) ? -mod : mod;
1407
- }
1399
+ cl::sycl::range<1 > gws (size);
1400
+ auto paral_kernel_acceptance = [&](cl::sycl::handler& cgh) {
1401
+ cgh.depends_on ({uniform_distr_event});
1402
+ cgh.parallel_for (gws, [=](cl::sycl::id<1 > global_id) {
1403
+ size_t i = global_id[0 ];
1404
+ double mod, resi;
1405
+ resi = (Vvec[i] < 0.5 ) ? mu - result1[i] : mu + result1[i];
1406
+ mod = cl::sycl::fabs (resi);
1407
+ mod = (cl::sycl::fmod (mod + M_PI, 2 * M_PI) - M_PI);
1408
+ result1[i] = (resi < 0 ) ? -mod : mod;
1409
+ });
1410
+ };
1411
+ auto acceptance_event = DPNP_QUEUE.submit (paral_kernel_acceptance);
1412
+ acceptance_event.wait ();
1408
1413
1409
1414
dpnp_memory_free_c (Vvec);
1410
1415
return ;
@@ -1423,7 +1428,6 @@ void dpnp_rng_vonmises_c(void* result, const _DataType mu, const _DataType kappa
1423
1428
dpnp_rng_vonmises_large_kappa_c<_DataType>(result, mu, kappa, size);
1424
1429
else
1425
1430
dpnp_rng_vonmises_small_kappa_c<_DataType>(result, mu, kappa, size);
1426
- // TODO case when kappa < kappa < 1e-8 (very small)
1427
1431
}
1428
1432
1429
1433
template <typename _KernelNameSpecialization>
0 commit comments