Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
egrabovskaya committed Oct 30, 2024
1 parent 2052df7 commit b7236d8
Show file tree
Hide file tree
Showing 19 changed files with 400 additions and 570 deletions.
48 changes: 25 additions & 23 deletions test/xpu_api/random/statistics_tests/common_for_distributions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ statistics_check(int nsamples, const std::vector<ScalarRealType>& samples, Scala
return compare_moments(nsamples, samples, tM, tD, tQ);
}

template <class Distr, class UIntType, class... Args>
template <class Distr, class UIntType, class Engine = oneapi::dpl::linear_congruential_engine<UIntType, a, c, m>, class... Args>
int
test(sycl::queue& queue, int nsamples, Args... params)
{
Expand All @@ -131,7 +131,8 @@ test(sycl::queue& queue, int nsamples, Args... params)

cgh.parallel_for<>(sycl::range<1>(nsamples / num_elems), [=](sycl::item<1> idx) {
unsigned long long offset = idx.get_linear_id() * num_elems;
oneapi::dpl::linear_congruential_engine<UIntType, a, c, m> engine(seed, offset);
Engine engine(seed);
engine.discard(offset);
Distr distr(params...);

sycl::vec<Element_type<real_type>, num_elems> res = distr(engine);
Expand All @@ -155,7 +156,7 @@ test(sycl::queue& queue, int nsamples, Args... params)
return err;
}

template <class Distr, class UIntType, class... Args>
template <class Distr, class UIntType, class Engine = oneapi::dpl::linear_congruential_engine<UIntType, a, c, m>, class... Args>
int
test_portion(sycl::queue& queue, int nsamples, unsigned int part, Args... params)
{
Expand All @@ -177,7 +178,8 @@ test_portion(sycl::queue& queue, int nsamples, unsigned int part, Args... params

cgh.parallel_for<>(sycl::range<1>(nsamples / n_elems), [=](sycl::item<1> idx) {
unsigned long long offset = idx.get_linear_id() * n_elems;
oneapi::dpl::linear_congruential_engine<UIntType, a, c, m> engine(seed, offset);
Engine engine(seed);
engine.discard(offset);
Distr distr(params...);

sycl::vec<Element_type<real_type>, num_elems> res = distr(engine, part);
Expand Down Expand Up @@ -237,10 +239,10 @@ tests_set(sycl::queue& queue, int nsamples)
oneapi::dpl::internal::element_type_t<real_type> b_array [nparams] = {1.0, 10.0};

// Test for all non-zero parameters
for(int i = 0; i < nparams; ++i) {
for (int i = 0; i < nparams; ++i) {
std::cout << "extreme_value_distribution test<type>, a = " << a_array[i] << ", b = " << b_array[i] <<
", nsamples = " << nsamples;
if(test<Distr, UIntType>(queue, nsamples, a_array[i], b_array[i])) {
if (test<Distr, UIntType>(queue, nsamples, a_array[i], b_array[i])) {
return 1;
}
}
Expand All @@ -259,7 +261,7 @@ tests_set(sycl::queue& queue, int nsamples)
oneapi::dpl::internal::element_type_t<real_type> stddev_array [nparams] = {1.0, 1000.0};

// Test for all non-zero parameters
for(int i = 0; i < nparams; ++i) {
for (int i = 0; i < nparams; ++i) {
std::cout << "lognormal_distribution test<type>, mean = " << mean_array[i] << ", stddev = " << stddev_array[i] <<
", nsamples = " << nsamples;
if (test<Distr, UIntType>(queue, nsamples, mean_array[i], stddev_array[i])) {
Expand All @@ -282,7 +284,7 @@ tests_set(sycl::queue& queue, int nsamples)
oneapi::dpl::internal::element_type_t<real_type> stddev_array [nparams] = {1.0, 1000.0};

// Test for all non-zero parameters
for(int i = 0; i < nparams; ++i) {
for (int i = 0; i < nparams; ++i) {
std::cout << "normal_distribution test<type>, mean = " << mean_array[i] << ", stddev = " << stddev_array[i] <<
", nsamples = " << nsamples;
if (test<Distr, UIntType>(queue, nsamples, mean_array[i], stddev_array[i])) {
Expand All @@ -293,7 +295,7 @@ tests_set(sycl::queue& queue, int nsamples)
return 0;
}

template <class Distr, class UIntType>
template <class Distr, class UIntType, class Engine = oneapi::dpl::linear_congruential_engine<UIntType, a, c, m>>
std::enable_if_t<std::is_same_v<Distr, oneapi::dpl::uniform_real_distribution<typename Distr::result_type>>, int>
tests_set(sycl::queue& queue, int nsamples)
{
Expand All @@ -305,10 +307,10 @@ tests_set(sycl::queue& queue, int nsamples)
oneapi::dpl::internal::element_type_t<real_type> right_array [nparams] = {1.0, 10.0};

// Test for all non-zero parameters
for(int i = 0; i < nparams; ++i) {
for (int i = 0; i < nparams; ++i) {
std::cout << "uniform_real_distribution test<type>, left = " << left_array[i] << ", right = " << right_array[i] <<
", nsamples = " << nsamples;
if (test<Distr, UIntType>(queue, nsamples, left_array[i], right_array[i])) {
if (test<Distr, UIntType, Engine>(queue, nsamples, left_array[i], right_array[i])) {
return 1;
}
}
Expand All @@ -328,7 +330,7 @@ tests_set(sycl::queue& queue, int nsamples)
oneapi::dpl::internal::element_type_t<real_type> b_array [nparams] = {1.0, 10.0};

// Test for all non-zero parameters
for(int i = 0; i < nparams; ++i) {
for (int i = 0; i < nparams; ++i) {
std::cout << "weibull_distribution test<type>, a = " << a_array[i] << ", b = " << b_array[i] <<
", nsamples = " << nsamples;
if (test<Distr, UIntType>(queue, nsamples, a_array[i], b_array[i])) {
Expand Down Expand Up @@ -374,10 +376,10 @@ tests_set_portion(sycl::queue& queue, std::int32_t nsamples, unsigned int part)
oneapi::dpl::internal::element_type_t<real_type> b_array [nparams] = {1.0, 10.0};

// Test for all non-zero parameters
for(int i = 0; i < nparams; ++i) {
for (int i = 0; i < nparams; ++i) {
std::cout << "extreme_value_distribution test<type>, a = " << a_array[i] << ", b = " << b_array[i] <<
", nsamples = " << nsamples << ", part = " << part;
if(test_portion<Distr, UIntType>(queue, nsamples, part, a_array[i], b_array[i])) {
if (test_portion<Distr, UIntType>(queue, nsamples, part, a_array[i], b_array[i])) {
return 1;
}
}
Expand All @@ -397,10 +399,10 @@ tests_set_portion(sycl::queue& queue, std::int32_t nsamples, unsigned int part)
oneapi::dpl::internal::element_type_t<real_type> stddev_array [nparams] = {1.0, 1000.0};

// Test for all non-zero parameters
for(int i = 0; i < nparams; ++i) {
for (int i = 0; i < nparams; ++i) {
std::cout << "lognormal_distribution test<type>, mean = " << mean_array[i] << ", stddev = " << stddev_array[i] <<
", nsamples = " << nsamples << ", part = "<< part;
if(test_portion<Distr, UIntType>(queue, nsamples, part, mean_array[i], stddev_array[i])) {
if (test_portion<Distr, UIntType>(queue, nsamples, part, mean_array[i], stddev_array[i])) {
return 1;
}
}
Expand All @@ -419,17 +421,17 @@ tests_set_portion(sycl::queue& queue, std::int32_t nsamples, unsigned int part)
oneapi::dpl::internal::element_type_t<real_type> stddev_array [nparams] = {1.0, 1000.0};

// Test for all non-zero parameters
for(int i = 0; i < nparams; ++i) {
for (int i = 0; i < nparams; ++i) {
std::cout << "normal_distribution test<type>, mean = " << mean_array[i] << ", stddev = " << stddev_array[i] <<
", nsamples = " << nsamples << ", part = "<< part;
if(test_portion<Distr, UIntType>(queue, nsamples, part, mean_array[i], stddev_array[i])) {
if (test_portion<Distr, UIntType>(queue, nsamples, part, mean_array[i], stddev_array[i])) {
return 1;
}
}
return 0;
}

template<class Distr, class UIntType>
template<class Distr, class UIntType, class Engine = oneapi::dpl::linear_congruential_engine<UIntType, a, c, m>>
std::enable_if_t<std::is_same_v<Distr, oneapi::dpl::uniform_real_distribution<typename Distr::result_type>>, int>
tests_set_portion(sycl::queue& queue, std::int32_t nsamples, unsigned int part)
{
Expand All @@ -441,10 +443,10 @@ tests_set_portion(sycl::queue& queue, std::int32_t nsamples, unsigned int part)
oneapi::dpl::internal::element_type_t<real_type> right_array [nparams] = {1.0, 10.0};

// Test for all non-zero parameters
for(int i = 0; i < nparams; ++i) {
for (int i = 0; i < nparams; ++i) {
std::cout << "uniform_real_distribution test<type>, left = " << left_array[i] << ", right = " << right_array[i] <<
", nsamples = " << nsamples << ", part = " << part;
if(test_portion<Distr, UIntType>(queue, nsamples, part, left_array[i], right_array[i])) {
if (test_portion<Distr, UIntType, Engine>(queue, nsamples, part, left_array[i], right_array[i])) {
return 1;
}
}
Expand All @@ -463,10 +465,10 @@ tests_set_portion(sycl::queue& queue, std::int32_t nsamples, unsigned int part)
oneapi::dpl::internal::element_type_t<real_type> b_array [nparams] = {1.0, 10.0};

// Test for all non-zero parameters
for(int i = 0; i < nparams; ++i) {
for (int i = 0; i < nparams; ++i) {
std::cout << "weibull_distribution test<type>, a = " << a_array[i] << ", b = " << b_array[i] <<
", nsamples = " << nsamples << ", part = " << part;
if(test_portion<Distr, UIntType>(queue, nsamples, part, a_array[i], b_array[i])) {
if (test_portion<Distr, UIntType>(queue, nsamples, part, a_array[i], b_array[i])) {
return 1;
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// -*- C++ -*-
//===-- exponential_distribution_test.cpp ---------------------------------===//
//===-- exponential_distribution_dp_test.cpp ---------------------------------===//
//
// Copyright (C) Intel Corporation
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// -*- C++ -*-
//===-- exponential_distribution_test.cpp ---------------------------------===//
//===-- exponential_distribution_sp_test.cpp ---------------------------------===//
//
// Copyright (C) Intel Corporation
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// -*- C++ -*-
//===-- extreme_value_distribution_test.cpp ---------------------------------===//
//===-- extreme_value_distribution_dp_tests_set_portion_test.cpp ---------------------------------===//
//
// Copyright (C) Intel Corporation
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// -*- C++ -*-
//===-- extreme_value_distribution_test.cpp ---------------------------------===//
//===-- extreme_value_distribution_dp_tests_set_test.cpp ---------------------------------===//
//
// Copyright (C) Intel Corporation
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// -*- C++ -*-
//===-- extreme_value_distribution_test.cpp ---------------------------------===//
//===-- extreme_value_distribution_sp_test.cpp ---------------------------------===//
//
// Copyright (C) Intel Corporation
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// -*- C++ -*-
//===-- lognormal_distribution_test.cpp ---------------------------------------===//
//===-- lognormal_distribution_dp_tests_set_portion_test.cpp ---------------------------------------===//
//
// Copyright (C) Intel Corporation
//
Expand Down
Loading

0 comments on commit b7236d8

Please sign in to comment.