@@ -600,7 +600,7 @@ void dpnp_rng_negative_binomial_c(void* result, const double a, const double p,
600
600
template <typename _DataType>
601
601
void dpnp_rng_noncentral_chisquare_c (void * result, const _DataType df, const _DataType nonc, const size_t size)
602
602
{
603
- if (!size)
603
+ if (!size || !result )
604
604
{
605
605
return ;
606
606
}
@@ -614,8 +614,6 @@ void dpnp_rng_noncentral_chisquare_c(void* result, const _DataType df, const _Da
614
614
{
615
615
_DataType shape, loc;
616
616
size_t i;
617
- cl::sycl::event event_out;
618
- cl::sycl::vector_class<cl::sycl::event> no_deps;
619
617
620
618
if (df > 1 )
621
619
{
@@ -624,23 +622,20 @@ void dpnp_rng_noncentral_chisquare_c(void* result, const _DataType df, const _Da
624
622
shape = 0.5 * (df - 1.0 );
625
623
/* res has chi^2 with (df - 1) */
626
624
mkl_rng::gamma<_DataType> gamma_distribution (shape, d_zero, d_two);
627
- event_out = mkl_rng::generate (gamma_distribution, DPNP_RNG_ENGINE, size, result1);
628
- event_out.wait ();
625
+ auto event_gamma_distr = mkl_rng::generate (gamma_distribution, DPNP_RNG_ENGINE, size, result1);
629
626
630
627
nvec = reinterpret_cast <_DataType*>(dpnp_memory_alloc_c (size * sizeof (_DataType)));
631
628
632
629
loc = sqrt (nonc);
633
630
634
631
mkl_rng::gaussian<_DataType> gaussian_distribution (loc, d_one);
635
- event_out = mkl_rng::generate (gaussian_distribution, DPNP_RNG_ENGINE, size, nvec);
636
- event_out.wait ();
632
+ auto event_gaussian_distr = mkl_rng::generate (gaussian_distribution, DPNP_RNG_ENGINE, size, nvec);
637
633
638
634
/* squaring could result in an overflow */
639
- event_out = mkl_vm::sqr (DPNP_QUEUE, size, nvec, nvec, no_deps, mkl_vm::mode::ha);
640
- event_out.wait ();
641
- event_out = mkl_vm::add (DPNP_QUEUE, size, result1, nvec, result1, no_deps, mkl_vm::mode::ha);
635
+ auto event_sqr_out = mkl_vm::sqr (DPNP_QUEUE, size, nvec, nvec, {event_gamma_distr, event_gaussian_distr}, mkl_vm::mode::ha);
636
+ auto event_add_out = mkl_vm::add (DPNP_QUEUE, size, result1, nvec, result1, {event_sqr_out}, mkl_vm::mode::ha);
642
637
dpnp_memory_free_c (nvec);
643
- event_out .wait ();
638
+ event_add_out .wait ();
644
639
}
645
640
else if (df < 1 )
646
641
{
@@ -651,7 +646,7 @@ void dpnp_rng_noncentral_chisquare_c(void* result, const _DataType df, const _Da
651
646
lambda = 0.5 * nonc;
652
647
653
648
mkl_rng::poisson<int > poisson_distribution (lambda);
654
- event_out = mkl_rng::generate (poisson_distribution, DPNP_RNG_ENGINE, size, pvec);
649
+ auto event_out = mkl_rng::generate (poisson_distribution, DPNP_RNG_ENGINE, size, pvec);
655
650
event_out.wait ();
656
651
657
652
shape = 0.5 * df;
@@ -713,9 +708,8 @@ void dpnp_rng_noncentral_chisquare_c(void* result, const _DataType df, const _Da
713
708
/* noncentral_chisquare(1, nonc) ~ (Z + sqrt(nonc))**2 for df == 1 */
714
709
loc = sqrt (nonc);
715
710
mkl_rng::gaussian<_DataType> gaussian_distribution (loc, d_one);
716
- event_out = mkl_rng::generate (gaussian_distribution, DPNP_RNG_ENGINE, size, result1);
717
- event_out.wait ();
718
- event_out = mkl_vm::sqr (DPNP_QUEUE, size, result1, result1, no_deps, mkl_vm::mode::ha);
711
+ auto event_gaussian_distr = mkl_rng::generate (gaussian_distribution, DPNP_RNG_ENGINE, size, result1);
712
+ auto event_out = mkl_vm::sqr (DPNP_QUEUE, size, result1, result1, {event_gaussian_distr}, mkl_vm::mode::ha);
719
713
event_out.wait ();
720
714
}
721
715
}
0 commit comments