diff --git a/.ci/env/apt.sh b/.ci/env/apt.sh index 591c87b4297..cbf4364983b 100755 --- a/.ci/env/apt.sh +++ b/.ci/env/apt.sh @@ -42,8 +42,6 @@ function install_mkl { function install_clang-format { sudo apt-get install -y clang-format-14 - sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 100 - sudo update-alternatives --set clang-format /usr/bin/clang-format-14 } function install_dev-base { diff --git a/.ci/scripts/clang-format.sh b/.ci/scripts/clang-format.sh index 8ac2c285f46..1cbbb03bf7f 100755 --- a/.ci/scripts/clang-format.sh +++ b/.ci/scripts/clang-format.sh @@ -20,9 +20,11 @@ echo "Starting format check..." RETURN_CODE=0 +CLANG_FORMAT_EXE=${CLANG_FORMAT_EXE:-clang-format-14} + for sources_path in cpp/daal cpp/oneapi examples/oneapi examples/daal samples/oneapi samples/daal; do pushd ${sources_path} || exit 1 - for filename in $(find . -type f | grep -P ".*\.(c|cpp|h|hpp|cl|i)$"); do clang-format -style=file -i "${filename}"; done + for filename in $(find . -type f | grep -P ".*\.(c|cpp|h|hpp|cl|i)$"); do ${CLANG_FORMAT_EXE} -style=file -i "${filename}"; done git status | grep "nothing to commit" > /dev/null diff --git a/.github/workflows/label-enforcement.yml b/.github/workflows/label-enforcement.yml new file mode 100644 index 00000000000..5ad1f6ff8d9 --- /dev/null +++ b/.github/workflows/label-enforcement.yml @@ -0,0 +1,22 @@ +name: Enforce Labels +on: + pull_request: + branches: [ "main" ] + +jobs: + label_checker: + name: Please include labels on your pull request + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: test + run: | + LABELS=`gh api -H "Accept: application/vnd.github+json" /repos/oneapi-src/oneDAL/issues/${{ github.event.pull_request.number }}/labels | jq '[.[].name]'` + echo $LABELS + if [[ $LABELS == "[]" ]] || [[ $LABELS == "[\"RFC\"]" ]]; then + echo "::error::No label set on the pull request" + exit 1 + fi + env: + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/renovate-validation.yml b/.github/workflows/renovate-validation.yml index 83825305388..3d273fcce43 100644 --- a/.github/workflows/renovate-validation.yml +++ b/.github/workflows/renovate-validation.yml @@ -25,6 +25,6 @@ jobs: - name: Checkout uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - name: Validate - uses: suzuki-shunsuke/github-action-renovate-config-validator@v1.0.1 + uses: suzuki-shunsuke/github-action-renovate-config-validator@v1.1.0 with: config_file_path: .github/renovate.json diff --git a/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_predict_dense_default_batch_impl.i b/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_predict_dense_default_batch_impl.i index a6e343efa91..c26f48557f6 100644 --- a/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_predict_dense_default_batch_impl.i +++ b/cpp/daal/src/algorithms/dtrees/forest/classification/df_classification_predict_dense_default_batch_impl.i @@ -1045,7 +1045,9 @@ Status PredictClassificationTask::predictAllPointsByAllTre ReadRows xBD(const_cast(_data), 0, nRowsOfRes); DAAL_CHECK_BLOCK_STATUS(xBD); const algorithmFPType * const aX = xBD.get(); - if (numberOfTrees > _minTreesForThreading) + // TODO: investigate why higher level parallelism for trees causes performance degradation + // (excessive memory and CPU resources usage), especially on systems with high number of cores + if (false) { daal::static_tls tlsData([=]() { return service_scalable_calloc(_nClasses * nRowsOfRes); }); diff --git a/cpp/daal/src/services/compiler/generic/env_detect_features.cpp b/cpp/daal/src/services/compiler/generic/env_detect_features.cpp index 8762b68db79..689dbe2bda0 100644 --- a/cpp/daal/src/services/compiler/generic/env_detect_features.cpp +++ b/cpp/daal/src/services/compiler/generic/env_detect_features.cpp @@ -28,7 +28,8 @@ #if defined(TARGET_X86_64) #include #elif defined(TARGET_ARM) - #include + #include + #include #elif defined(TARGET_RISCV64) // TODO: Include vector if and when we need to use some vector intrinsics in // here @@ -218,6 +219,13 @@ DAAL_EXPORT int __daal_serv_cpu_detect(int enable) return daal::sse2; } #elif defined(TARGET_ARM) +static bool check_sve_features() +{ + unsigned long hwcap = getauxval(AT_HWCAP); + + return (hwcap & HWCAP_SVE) != 0; +} + DAAL_EXPORT bool __daal_serv_cpu_extensions_available() { return 0; @@ -225,7 +233,11 @@ DAAL_EXPORT bool __daal_serv_cpu_extensions_available() DAAL_EXPORT int __daal_serv_cpu_detect(int enable) { - return daal::sve; + if (check_sve_features()) + { + return daal::sve; + } + return -1; } void run_cpuid(uint32_t eax, uint32_t ecx, uint32_t * abcd) diff --git a/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/compute_kernel_csr_impl_dpc.cpp b/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/compute_kernel_csr_impl_dpc.cpp index 3367947d26f..eaffff9b350 100644 --- a/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/compute_kernel_csr_impl_dpc.cpp +++ b/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/compute_kernel_csr_impl_dpc.cpp @@ -354,8 +354,13 @@ result_t compute_kernel_csr_impl::operator()(const bk::context_gpu& ctx, if (row_count != cur_row_count) { auto cur_min = result_data_ptr[stat::min * column_count + col_idx]; auto cur_max = result_data_ptr[stat::max * column_count + col_idx]; +#if __SYCL_COMPILER_VERSION >= 20240715 + result_data_ptr[stat::min * column_count + col_idx] = Float(sycl::fmin(cur_min, 0)); + result_data_ptr[stat::max * column_count + col_idx] = Float(sycl::fmax(cur_max, 0)); +#else result_data_ptr[stat::min * column_count + col_idx] = sycl::min(cur_min, 0); result_data_ptr[stat::max * column_count + col_idx] = sycl::max(cur_max, 0); +#endif cur_sum2_cent += Float(row_count - cur_row_count) * mean_val * mean_val; } result_data_ptr[stat::sum2_cent * column_count + col_idx] = cur_sum2_cent; diff --git a/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/compute_kernel_dense_impl_dpc.cpp b/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/compute_kernel_dense_impl_dpc.cpp index 3eaf2534aa9..4573bd8dff4 100644 --- a/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/compute_kernel_dense_impl_dpc.cpp +++ b/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/compute_kernel_dense_impl_dpc.cpp @@ -696,7 +696,11 @@ inline void merge_blocks_kernel(sycl::nd_item<1> item, if constexpr (!DefferedFin) { Float mrgvariance = mrgsum2cent / (mrgvectors - Float(1)); +#if __SYCL_COMPILER_VERSION >= 20240715 + Float mrgstdev = (Float)sycl::sqrt(mrgvariance); +#else Float mrgstdev = (Float)sqrt(mrgvariance); +#endif if constexpr (check_mask_flag(bs_list::sorm, List)) { rsorm_ptr[group_id] = mrgsum2 / mrgvectors; diff --git a/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/finalize_compute_kernel_dense_impl_dpc.cpp b/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/finalize_compute_kernel_dense_impl_dpc.cpp index e0d3a6aa3a9..429b666279e 100644 --- a/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/finalize_compute_kernel_dense_impl_dpc.cpp +++ b/cpp/oneapi/dal/algo/basic_statistics/backend/gpu/finalize_compute_kernel_dense_impl_dpc.cpp @@ -26,6 +26,8 @@ #include "oneapi/dal/algo/basic_statistics/backend/basic_statistics_interop.hpp" +#ifdef ONEDAL_DATA_PARALLEL + namespace oneapi::dal::basic_statistics::backend { namespace bk = dal::backend; @@ -151,16 +153,21 @@ result_t finalize_compute_kernel_dense_impl::operator()(const descriptor_ const auto nobs_nd = pr::table2ndarray_1d(q, input.get_partial_n_rows()); auto rows_count_global = nobs_nd.get_data()[0]; + auto is_distributed = (comm_.get_rank_count() > 1); { ONEDAL_PROFILER_TASK(allreduce_rows_count_global); - comm_.allreduce(rows_count_global, spmd::reduce_op::sum).wait(); + if (is_distributed) { + comm_.allreduce(rows_count_global, spmd::reduce_op::sum).wait(); + } } if (res_op.test(result_options::min)) { ONEDAL_ASSERT(input.get_partial_min().get_column_count() == column_count); const auto min = pr::table2ndarray_1d(q, input.get_partial_min(), sycl::usm::alloc::device); - { comm_.allreduce(min.flatten(q, {}), spmd::reduce_op::min).wait(); } + if (is_distributed) { + comm_.allreduce(min.flatten(q, {}), spmd::reduce_op::min).wait(); + } res.set_min(homogen_table::wrap(min.flatten(q, {}), 1, column_count)); } @@ -174,27 +181,48 @@ result_t finalize_compute_kernel_dense_impl::operator()(const descriptor_ } if (res_op_partial.test(result_options::sum)) { - const auto sums_nd = + auto sums_nd = pr::table2ndarray_1d(q, input.get_partial_sum(), sycl::usm::alloc::device); - { - ONEDAL_PROFILER_TASK(allreduce_sums, q); - comm_.allreduce(sums_nd.flatten(q, {}), spmd::reduce_op::sum).wait(); - } - const auto sums2_nd = pr::table2ndarray_1d(q, - input.get_partial_sum_squares(), - sycl::usm::alloc::device); - { - ONEDAL_PROFILER_TASK(allreduce_sums, q); - comm_.allreduce(sums2_nd.flatten(q, {}), spmd::reduce_op::sum).wait(); - } - const auto sums2cent_nd = - pr::table2ndarray_1d(q, - input.get_partial_sum_squares_centered(), - sycl::usm::alloc::device); - { - ONEDAL_PROFILER_TASK(allreduce_sums, q); - comm_.allreduce(sums2cent_nd.flatten(q, {}), spmd::reduce_op::sum).wait(); + auto sums2_nd = pr::table2ndarray_1d(q, + input.get_partial_sum_squares(), + sycl::usm::alloc::device); + + auto sums2cent_nd = pr::table2ndarray_1d(q, + input.get_partial_sum_squares_centered(), + sycl::usm::alloc::device); + if (is_distributed) { + auto sums_nd_copy = + pr::ndarray::empty(q, { column_count }, sycl::usm::alloc::device); + auto copy_event = copy(q, sums_nd_copy, sums_nd, {}); + copy_event.wait_and_throw(); + sums_nd = sums_nd_copy; + + { + ONEDAL_PROFILER_TASK(allreduce_sums, q); + comm_.allreduce(sums_nd.flatten(q, {}), spmd::reduce_op::sum).wait(); + } + + auto sums2_nd_copy = + pr::ndarray::empty(q, { column_count }, sycl::usm::alloc::device); + copy_event = copy(q, sums2_nd_copy, sums2_nd, {}); + copy_event.wait_and_throw(); + sums2_nd = sums2_nd_copy; + + { + ONEDAL_PROFILER_TASK(allreduce_sums, q); + comm_.allreduce(sums2_nd.flatten(q, {}), spmd::reduce_op::sum).wait(); + } + auto sums2cent_nd_copy = + pr::ndarray::empty(q, { column_count }, sycl::usm::alloc::device); + copy_event = copy(q, sums2cent_nd_copy, sums2cent_nd, {}); + copy_event.wait_and_throw(); + sums2cent_nd = sums2cent_nd_copy; + { + ONEDAL_PROFILER_TASK(allreduce_sums, q); + comm_.allreduce(sums2cent_nd.flatten(q, {}), spmd::reduce_op::sum).wait(); + } } + auto [result_means, result_variance, result_raw_moment, @@ -210,18 +238,20 @@ result_t finalize_compute_kernel_dense_impl::operator()(const descriptor_ if (res_op.test(result_options::sum)) { ONEDAL_ASSERT(input.get_partial_sum().get_column_count() == column_count); - res.set_sum(input.get_partial_sum()); + res.set_sum(homogen_table::wrap(sums_nd.flatten(q, { update_event }), 1, column_count)); } if (res_op.test(result_options::sum_squares)) { ONEDAL_ASSERT(input.get_partial_sum_squares().get_column_count() == column_count); - res.set_sum_squares(input.get_partial_sum_squares()); + res.set_sum_squares( + homogen_table::wrap(sums2_nd.flatten(q, { update_event }), 1, column_count)); } if (res_op.test(result_options::sum_squares_centered)) { ONEDAL_ASSERT(input.get_partial_sum_squares_centered().get_column_count() == column_count); - res.set_sum_squares_centered(input.get_partial_sum_squares_centered()); + res.set_sum_squares_centered( + homogen_table::wrap(sums2cent_nd.flatten(q, { update_event }), 1, column_count)); } if (res_op.test(result_options::mean)) { @@ -264,3 +294,5 @@ template class finalize_compute_kernel_dense_impl; template class finalize_compute_kernel_dense_impl; } // namespace oneapi::dal::basic_statistics::backend + +#endif // ONEDAL_DATA_PARALLEL diff --git a/cpp/oneapi/dal/algo/basic_statistics/test/online_spmd.cpp b/cpp/oneapi/dal/algo/basic_statistics/test/online_spmd.cpp index 892fb3e0813..cd57b7dce1e 100644 --- a/cpp/oneapi/dal/algo/basic_statistics/test/online_spmd.cpp +++ b/cpp/oneapi/dal/algo/basic_statistics/test/online_spmd.cpp @@ -88,8 +88,9 @@ class basic_statistics_online_spmd_test } partial_results.push_back(partial_result); } - const auto compute_result = this->finalize_compute_override(bs_desc, partial_results); - + auto compute_result = this->finalize_compute_override(bs_desc, partial_results); + base_t::check_compute_result(compute_mode, data, weights, compute_result); + compute_result = this->finalize_compute_override(bs_desc, partial_results); base_t::check_compute_result(compute_mode, data, weights, compute_result); } else { @@ -103,8 +104,9 @@ class basic_statistics_online_spmd_test } partial_results.push_back(partial_result); } - const auto compute_result = this->finalize_compute_override(bs_desc, partial_results); - + auto compute_result = this->finalize_compute_override(bs_desc, partial_results); + base_t::check_compute_result(compute_mode, data, table{}, compute_result); + compute_result = this->finalize_compute_override(bs_desc, partial_results); base_t::check_compute_result(compute_mode, data, table{}, compute_result); } } diff --git a/cpp/oneapi/dal/algo/covariance/backend/gpu/finalize_compute_kernel_dense_impl_dpc.cpp b/cpp/oneapi/dal/algo/covariance/backend/gpu/finalize_compute_kernel_dense_impl_dpc.cpp index 6f507c446be..c3844b2e97e 100644 --- a/cpp/oneapi/dal/algo/covariance/backend/gpu/finalize_compute_kernel_dense_impl_dpc.cpp +++ b/cpp/oneapi/dal/algo/covariance/backend/gpu/finalize_compute_kernel_dense_impl_dpc.cpp @@ -66,29 +66,39 @@ result_t finalize_compute_kernel_dense_impl::operator()(const descriptor_ const auto nobs_host = pr::table2ndarray(q, input.get_partial_n_rows()); auto rows_count_global = nobs_host.get_data()[0]; - { - ONEDAL_PROFILER_TASK(allreduce_rows_count_global); - comm_.allreduce(rows_count_global, spmd::reduce_op::sum).wait(); - } - - ONEDAL_ASSERT(rows_count_global > 0); - - const auto sums = - pr::table2ndarray_1d(q, input.get_partial_sum(), sycl::usm::alloc::device); - - { - ONEDAL_PROFILER_TASK(allreduce_sums, q); - comm_.allreduce(sums.flatten(q, {}), spmd::reduce_op::sum).wait(); - } - - const auto xtx = + auto sums = pr::table2ndarray_1d(q, input.get_partial_sum(), sycl::usm::alloc::device); + auto xtx = pr::table2ndarray(q, input.get_partial_crossproduct(), sycl::usm::alloc::device); - { - ONEDAL_PROFILER_TASK(allreduce_xtx, q); - comm_.allreduce(xtx.flatten(q, {}), spmd::reduce_op::sum).wait(); + if (comm_.get_rank_count() > 1) { + { + ONEDAL_PROFILER_TASK(allreduce_rows_count_global); + comm_.allreduce(rows_count_global, spmd::reduce_op::sum).wait(); + } + auto sums_copy = + pr::ndarray::empty(q, { column_count }, sycl::usm::alloc::device); + auto copy_event = copy(q, sums_copy, sums, {}); + copy_event.wait_and_throw(); + sums = sums_copy; + { + ONEDAL_PROFILER_TASK(allreduce_sums, q); + comm_.allreduce(sums.flatten(q, {}), spmd::reduce_op::sum).wait(); + } + + auto xtx_copy = pr::ndarray::empty(q, + { column_count, column_count }, + sycl::usm::alloc::device); + copy_event = copy(q, xtx_copy, xtx, {}); + copy_event.wait_and_throw(); + xtx = xtx_copy; + { + ONEDAL_PROFILER_TASK(allreduce_xtx, q); + comm_.allreduce(xtx.flatten(q, {}), spmd::reduce_op::sum).wait(); + } } + ONEDAL_ASSERT(rows_count_global > 0); + if (desc.get_result_options().test(result_options::cov_matrix)) { auto [cov, cov_event] = compute_covariance(q, rows_count_global, xtx, sums, bias, assume_centered); @@ -101,8 +111,17 @@ result_t finalize_compute_kernel_dense_impl::operator()(const descriptor_ (homogen_table::wrap(corr.flatten(q, { corr_event }), column_count, column_count))); } if (desc.get_result_options().test(result_options::means)) { - auto [means, means_event] = compute_means(q, sums, rows_count_global); - result.set_means(homogen_table::wrap(means.flatten(q, { means_event }), 1, column_count)); + if (!assume_centered) { + auto [means, means_event] = compute_means(q, sums, rows_count_global); + result.set_means( + homogen_table::wrap(means.flatten(q, { means_event }), 1, column_count)); + } + else { + auto [zero_means, zeros_event] = + pr::ndarray::zeros(q, { column_count }, sycl::usm::alloc::device); + result.set_means( + homogen_table::wrap(zero_means.flatten(q, { zeros_event }), 1, column_count)); + } } return result; } diff --git a/cpp/oneapi/dal/algo/covariance/backend/gpu/partial_compute_kernel_dense_dpc.cpp b/cpp/oneapi/dal/algo/covariance/backend/gpu/partial_compute_kernel_dense_dpc.cpp index 00c6cd97ab5..dfe850c92ab 100644 --- a/cpp/oneapi/dal/algo/covariance/backend/gpu/partial_compute_kernel_dense_dpc.cpp +++ b/cpp/oneapi/dal/algo/covariance/backend/gpu/partial_compute_kernel_dense_dpc.cpp @@ -57,12 +57,14 @@ static partial_compute_result partial_compute(const context_gpu& ctx, const std::int64_t column_count = data.get_column_count(); ONEDAL_ASSERT(column_count > 0); + auto assume_centered = desc.get_assume_centered(); + dal::detail::check_mul_overflow(row_count, column_count); dal::detail::check_mul_overflow(column_count, column_count); const auto data_nd = pr::table2ndarray(q, data, sycl::usm::alloc::device); - auto [sums, sums_event] = compute_sums(q, data_nd); + auto [sums, sums_event] = compute_sums(q, data_nd, assume_centered, {}); auto [crossproduct, crossproduct_event] = compute_crossproduct(q, data_nd, { sums_event }); diff --git a/cpp/oneapi/dal/algo/covariance/test/badargs.cpp b/cpp/oneapi/dal/algo/covariance/test/badargs.cpp index 2d776173175..421d8be08e5 100644 --- a/cpp/oneapi/dal/algo/covariance/test/badargs.cpp +++ b/cpp/oneapi/dal/algo/covariance/test/badargs.cpp @@ -43,7 +43,7 @@ using cov_types = COMBINE_TYPES((float, double), (covariance::task::compute)); #define COVARIANCE_BADARG_TEST(name) \ - TEMPLATE_TEST_M(covariance_badarg_test, name, "[covariance][badarg]", cov_types) + TEMPLATE_LIST_TEST_M(covariance_badarg_test, name, "[covariance][badarg]", cov_types) COVARIANCE_BADARG_TEST("throws if input data is empty") { const auto covariance_desc = this->get_descriptor(); diff --git a/cpp/oneapi/dal/algo/covariance/test/batch.cpp b/cpp/oneapi/dal/algo/covariance/test/batch.cpp index 4a887bea505..2477f52812c 100644 --- a/cpp/oneapi/dal/algo/covariance/test/batch.cpp +++ b/cpp/oneapi/dal/algo/covariance/test/batch.cpp @@ -23,73 +23,59 @@ namespace la = te::linalg; namespace cov = oneapi::dal::covariance; template -class covariance_batch_test : public covariance_test> {}; +class covariance_batch_test : public covariance_test> { +public: + using base_t = covariance_test>; + using descriptor_t = typename base_t::descriptor_t; -TEMPLATE_LIST_TEST_M(covariance_batch_test, - "covariance fill_normal common flow", - "[covariance][integration][batch]", - covariance_types) { - SKIP_IF(this->not_float64_friendly()); + void general_checks(const te::dataframe& input, + const te::table_id& input_table_id, + descriptor_t cov_desc) { + const table data = input.get_table(this->get_policy(), input_table_id); - const te::dataframe input = - GENERATE_DATAFRAME(te::dataframe_builder{ 4, 4 }.fill_normal(0, 1, 7777), - te::dataframe_builder{ 100, 100 }.fill_normal(0, 1, 7777), - te::dataframe_builder{ 250, 250 }.fill_normal(0, 1, 7777), - te::dataframe_builder{ 500, 100 }.fill_normal(0, 1, 7777)); - - // Homogen floating point type is the same as algorithm's floating point type - const auto input_data_table_id = this->get_homogen_table_id(); - this->general_checks(input, input_data_table_id); - this->general_checks_assume_centered(input, input_data_table_id); -} + auto compute_result = this->compute(cov_desc, data); + this->check_compute_result(cov_desc, data, compute_result); + } +}; TEMPLATE_LIST_TEST_M(covariance_batch_test, - "covariance compute one element matrix", - "[covariance][integration][batch]", + "covariance common flow", + "[covariance][integration][online]", covariance_types) { SKIP_IF(this->not_float64_friendly()); - const te::dataframe input = - GENERATE_DATAFRAME(te::dataframe_builder{ 1, 1 }.fill_normal(0, 1, 7777)); - // Homogen floating point type is the same as algorithm's floating point type - const auto input_data_table_id = this->get_homogen_table_id(); - this->general_checks(input, input_data_table_id); -} - -TEMPLATE_LIST_TEST_M(covariance_batch_test, - "covariance fill_uniform common flow", - "[covariance][integration][batch]", - covariance_types) { - SKIP_IF(this->not_float64_friendly()); + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; + + const bool assume_centered = GENERATE(true, false); + INFO("assume_centered=" << assume_centered); + const bool bias = GENERATE(true, false); + INFO("bias=" << bias); + const cov::result_option_id result_option = + GENERATE(covariance::result_options::means, + covariance::result_options::cov_matrix, + covariance::result_options::cor_matrix, + covariance::result_options::cor_matrix | covariance::result_options::cov_matrix, + covariance::result_options::cor_matrix | covariance::result_options::cov_matrix | + covariance::result_options::means); + INFO("result_option=" << result_option); + + auto cov_desc = covariance::descriptor() + .set_result_options(result_option) + .set_assume_centered(assume_centered) + .set_bias(bias); const te::dataframe input = - GENERATE_DATAFRAME(te::dataframe_builder{ 1000, 20 }.fill_uniform(-30, 30, 7777), - te::dataframe_builder{ 100, 10 }.fill_uniform(0, 1, 7777), - te::dataframe_builder{ 100, 10 }.fill_uniform(-10, 10, 7777), - te::dataframe_builder{ 500, 40 }.fill_uniform(-100, 100, 7777), - te::dataframe_builder{ 500, 250 }.fill_uniform(0, 1, 7777)); - - // Homogen floating point type is the same as algorithm's floating point type - const auto input_data_table_id = this->get_homogen_table_id(); - this->general_checks(input, input_data_table_id); - this->general_checks_assume_centered(input, input_data_table_id); -} - -TEMPLATE_LIST_TEST_M(covariance_batch_test, - "covariance fill_uniform nightly common flow", - "[covariance][integration][batch][nightly]", - covariance_types) { - SKIP_IF(this->not_float64_friendly()); + GENERATE_DATAFRAME(te::dataframe_builder{ 100, 100 }.fill_normal(0, 1, 7777), + te::dataframe_builder{ 500, 100 }.fill_normal(0, 1, 7777), + te::dataframe_builder{ 10000, 200 }.fill_uniform(-30, 30, 7777)); - const te::dataframe input = - GENERATE_DATAFRAME(te::dataframe_builder{ 5000, 20 }.fill_uniform(-30, 30, 7777), - te::dataframe_builder{ 10000, 200 }.fill_uniform(-30, 30, 7777), - te::dataframe_builder{ 1000000, 20 }.fill_uniform(-0.5, 0.5, 7777)); + INFO("num_rows=" << input.get_row_count()); + INFO("num_columns=" << input.get_column_count()); // Homogen floating point type is the same as algorithm's floating point type const auto input_data_table_id = this->get_homogen_table_id(); - this->general_checks(input, input_data_table_id); - this->general_checks_assume_centered(input, input_data_table_id); + this->general_checks(input, input_data_table_id, cov_desc); } } // namespace oneapi::dal::covariance::test diff --git a/cpp/oneapi/dal/algo/covariance/test/compute_parameters.cpp b/cpp/oneapi/dal/algo/covariance/test/compute_parameters.cpp index 6563b7f26c4..9a3b94a7cc1 100644 --- a/cpp/oneapi/dal/algo/covariance/test/compute_parameters.cpp +++ b/cpp/oneapi/dal/algo/covariance/test/compute_parameters.cpp @@ -64,6 +64,15 @@ class covariance_params_test : public covariance_testget_policy(), input_table_id); + + auto compute_result = this->compute(cov_desc, data); + this->check_compute_result(cov_desc, data, compute_result); + } + private: std::int64_t block_; bool pack_as_struct_; @@ -74,18 +83,41 @@ TEMPLATE_LIST_TEST_M(covariance_params_test, "[covariance][params]", covariance_types) { SKIP_IF(this->not_float64_friendly()); + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; + const bool assume_centered = GENERATE(true, false); + INFO("assume_centered=" << assume_centered); + const bool bias = GENERATE(true, false); + INFO("bias=" << bias); + const cov::result_option_id result_option = + GENERATE(covariance::result_options::means, + covariance::result_options::cov_matrix, + covariance::result_options::cor_matrix, + covariance::result_options::cor_matrix | covariance::result_options::cov_matrix, + covariance::result_options::cor_matrix | covariance::result_options::cov_matrix | + covariance::result_options::means); + INFO("result_option=" << result_option); + + auto cov_desc = covariance::descriptor() + .set_result_options(result_option) + .set_assume_centered(assume_centered) + .set_bias(bias); const te::dataframe input = GENERATE_DATAFRAME(te::dataframe_builder{ 500, 40 }.fill_uniform(-100, 100, 7777), te::dataframe_builder{ 1000, 20 }.fill_uniform(-30, 30, 7777), te::dataframe_builder{ 10000, 100 }.fill_uniform(-30, 30, 7777), te::dataframe_builder{ 100000, 20 }.fill_uniform(1, 10, 7777)); + + INFO("num_rows=" << input.get_row_count()); + INFO("num_columns=" << input.get_column_count()); + // Homogen floating point type is the same as algorithm's floating point type const auto input_data_table_id = this->get_homogen_table_id(); this->generate_parameters(); - this->general_checks(input, input_data_table_id); + this->general_checks(input, input_data_table_id, cov_desc); } TEST("can dump system-related parameters") { diff --git a/cpp/oneapi/dal/algo/covariance/test/fixture.hpp b/cpp/oneapi/dal/algo/covariance/test/fixture.hpp index 00e9738acad..975b81a1ec5 100644 --- a/cpp/oneapi/dal/algo/covariance/test/fixture.hpp +++ b/cpp/oneapi/dal/algo/covariance/test/fixture.hpp @@ -75,212 +75,8 @@ class covariance_test : public te::crtp_algo_fixture { return result; } - void general_checks_assume_centered(const te::dataframe& input, - const te::table_id& input_table_id) { - const table data = input.get_table(this->get_policy(), input_table_id); - INFO("create descriptor means assume centered"); - auto cov_desc = covariance::descriptor() - .set_result_options(covariance::result_options::means) - .set_assume_centered(true); - INFO("run compute optional: means assume centered"); - auto compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cov assume centered"); - cov_desc = covariance::descriptor() - .set_result_options(covariance::result_options::cov_matrix) - .set_assume_centered(true); - INFO("run compute optional: cov assume centered"); - compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cov means"); - cov_desc = covariance::descriptor() - .set_result_options(covariance::result_options::cov_matrix | - covariance::result_options::means) - .set_assume_centered(true); - INFO("run compute optional: cov means"); - compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cov cor means"); - cov_desc = covariance::descriptor() - .set_result_options(covariance::result_options::cov_matrix | - covariance::result_options::cor_matrix | - covariance::result_options::means) - .set_assume_centered(true); - INFO("run compute optional: cov cor means"); - compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - } - void general_checks(const te::dataframe& input, const te::table_id& input_table_id) { - const table data = input.get_table(this->get_policy(), input_table_id); - - INFO("create descriptor cov cor means"); - auto cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cov_matrix | covariance::result_options::cor_matrix | - covariance::result_options::means); - INFO("run compute optional: cov cor means"); - auto compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cov"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cov_matrix); - INFO("run compute optional: cov"); - compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cov biased"); - cov_desc = covariance::descriptor() - .set_result_options(covariance::result_options::cov_matrix) - .set_bias(true); - INFO("run compute optional: cov biased"); - compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cor"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cor_matrix); - INFO("run compute optional: cor"); - compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor means"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::means); - INFO("run compute optional: means"); - compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cov cor"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cov_matrix | covariance::result_options::cor_matrix); - INFO("run compute optional: cov cor"); - compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cov means"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cov_matrix | covariance::result_options::means); - INFO("run compute optional: cov means"); - compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cor means"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cor_matrix | covariance::result_options::means); - INFO("run compute optional: cor means"); - compute_result = this->compute(cov_desc, data); - check_compute_result(cov_desc, data, compute_result); - } - - void online_general_checks(const te::dataframe& input, - const te::table_id& input_table_id, - const std::int64_t nBlocks) { - const table data = input.get_table(this->get_policy(), input_table_id); - INFO("create descriptor cov cor means"); - auto cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cov_matrix | covariance::result_options::cor_matrix | - covariance::result_options::means); - INFO("run compute optional: cov cor means"); - dal::covariance::partial_compute_result<> partial_result; - auto input_table = split_table_by_rows(data, nBlocks); - for (std::int64_t i = 0; i < nBlocks; ++i) { - partial_result = this->partial_compute(cov_desc, partial_result, input_table[i]); - } - auto compute_result = this->finalize_compute(cov_desc, partial_result); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cov"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cov_matrix); - INFO("run compute optional: cov"); - partial_result = dal::covariance::partial_compute_result(); - input_table = split_table_by_rows(data, nBlocks); - for (std::int64_t i = 0; i < nBlocks; ++i) { - partial_result = this->partial_compute(cov_desc, partial_result, input_table[i]); - } - compute_result = this->finalize_compute(cov_desc, partial_result); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cor"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cor_matrix); - INFO("run compute optional: cor"); - partial_result = dal::covariance::partial_compute_result(); - input_table = split_table_by_rows(data, nBlocks); - for (std::int64_t i = 0; i < nBlocks; ++i) { - partial_result = this->partial_compute(cov_desc, partial_result, input_table[i]); - } - compute_result = this->finalize_compute(cov_desc, partial_result); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor means"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::means); - INFO("run compute optional: means"); - partial_result = dal::covariance::partial_compute_result(); - input_table = split_table_by_rows(data, nBlocks); - for (std::int64_t i = 0; i < nBlocks; ++i) { - partial_result = this->partial_compute(cov_desc, partial_result, input_table[i]); - } - compute_result = this->finalize_compute(cov_desc, partial_result); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cov cor"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cov_matrix | covariance::result_options::cor_matrix); - INFO("run compute optional: cov cor"); - partial_result = dal::covariance::partial_compute_result(); - input_table = split_table_by_rows(data, nBlocks); - for (std::int64_t i = 0; i < nBlocks; ++i) { - partial_result = this->partial_compute(cov_desc, partial_result, input_table[i]); - } - compute_result = this->finalize_compute(cov_desc, partial_result); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cov means"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cov_matrix | covariance::result_options::means); - INFO("run compute optional: cov means"); - partial_result = dal::covariance::partial_compute_result(); - input_table = split_table_by_rows(data, nBlocks); - for (std::int64_t i = 0; i < nBlocks; ++i) { - partial_result = this->partial_compute(cov_desc, partial_result, input_table[i]); - } - compute_result = this->finalize_compute(cov_desc, partial_result); - check_compute_result(cov_desc, data, compute_result); - - INFO("create descriptor cor means"); - cov_desc = - covariance::descriptor().set_result_options( - covariance::result_options::cor_matrix | covariance::result_options::means); - INFO("run compute optional: cor means"); - partial_result = dal::covariance::partial_compute_result(); - input_table = split_table_by_rows(data, nBlocks); - for (std::int64_t i = 0; i < nBlocks; ++i) { - partial_result = this->partial_compute(cov_desc, partial_result, input_table[i]); - } - compute_result = this->finalize_compute(cov_desc, partial_result); - check_compute_result(cov_desc, data, compute_result); - } - - void check_compute_result(const covariance::descriptor& desc, + void check_compute_result(const descriptor_t& desc, const table& data, const covariance::compute_result<>& result) { if (result.get_result_options().test(result_options::cov_matrix)) { @@ -315,9 +111,7 @@ class covariance_test : public te::crtp_algo_fixture { } } - void check_means_values(const covariance::descriptor& desc, - const table& data, - const table& means) { + void check_means_values(const descriptor_t& desc, const table& data, const table& means) { const auto reference_means = compute_reference_means(data, desc.get_assume_centered()); const double tol = te::get_tolerance(1e-4, 1e-9); const double diff = te::abs_error(reference_means, means); @@ -342,7 +136,7 @@ class covariance_test : public te::crtp_algo_fixture { return reference_means; } - void check_cov_matrix_values(const covariance::descriptor& desc, + void check_cov_matrix_values(const descriptor_t& desc, const table& data, const table& cov_matrix) { const auto reference_cov = compute_reference_cov(desc, data); @@ -352,8 +146,7 @@ class covariance_test : public te::crtp_algo_fixture { CHECK(diff < tol); } - la::matrix compute_reference_cov(const covariance::descriptor& desc, - const table& data) { + la::matrix compute_reference_cov(const descriptor_t& desc, const table& data) { const auto data_matrix = la::matrix::wrap(data); const auto row_count_data = data_matrix.get_row_count(); const auto column_count_data = data_matrix.get_column_count(); @@ -376,7 +169,7 @@ class covariance_test : public te::crtp_algo_fixture { } return reference_cov; } - void check_cor_matrix_values(const covariance::descriptor& desc, + void check_cor_matrix_values(const descriptor_t& desc, const table& data, const table& cor_matrix) { const auto reference_cor = compute_reference_cor(desc, data); @@ -385,8 +178,7 @@ class covariance_test : public te::crtp_algo_fixture { CHECK(diff < tol); } - la::matrix compute_reference_cor(const covariance::descriptor& desc, - const table& data) { + la::matrix compute_reference_cor(const descriptor_t& desc, const table& data) { const auto data_matrix = la::matrix::wrap(data); const auto column_count_data = data_matrix.get_column_count(); auto reference_means = compute_reference_means(data, desc.get_assume_centered()); diff --git a/cpp/oneapi/dal/algo/covariance/test/online.cpp b/cpp/oneapi/dal/algo/covariance/test/online.cpp index ef2e4bfc124..6998466bd68 100644 --- a/cpp/oneapi/dal/algo/covariance/test/online.cpp +++ b/cpp/oneapi/dal/algo/covariance/test/online.cpp @@ -24,57 +24,98 @@ namespace cov = oneapi::dal::covariance; template class covariance_online_test : public covariance_test> { + using base_t = covariance_test>; + using descriptor_t = typename base_t::descriptor_t; + +public: + void set_blocks_count(std::int64_t blocks_count) { + blocks_count_ = blocks_count; + } + + void online_general_checks(const te::dataframe& input, + const te::table_id& input_table_id, + descriptor_t cov_desc) { + const table data = input.get_table(this->get_policy(), input_table_id); + dal::covariance::partial_compute_result<> partial_result; + auto input_table = split_table_by_rows(data, blocks_count_); + for (std::int64_t i = 0; i < blocks_count_; ++i) { + partial_result = this->partial_compute(cov_desc, partial_result, input_table[i]); + } + auto compute_result = this->finalize_compute(cov_desc, partial_result); + this->check_compute_result(cov_desc, data, compute_result); + } + +private: + template + std::vector split_table_by_rows(const dal::table& t, std::int64_t split_count) { + ONEDAL_ASSERT(0l < split_count); + ONEDAL_ASSERT(split_count <= t.get_row_count()); + + const std::int64_t row_count = t.get_row_count(); + const std::int64_t column_count = t.get_column_count(); + const std::int64_t block_size_regular = row_count / split_count; + const std::int64_t block_size_tail = row_count % split_count; + + std::vector result(split_count); + + std::int64_t row_offset = 0; + for (std::int64_t i = 0; i < split_count; i++) { + const std::int64_t tail = std::int64_t(i + 1 == split_count) * block_size_tail; + const std::int64_t block_size = block_size_regular + tail; + + const auto row_range = dal::range{ row_offset, row_offset + block_size }; + const auto block = dal::row_accessor{ t }.pull(row_range); + result[i] = dal::homogen_table::wrap(block, block_size, column_count); + row_offset += block_size; + } + + return result; + } + + std::int64_t blocks_count_; }; TEMPLATE_LIST_TEST_M(covariance_online_test, - "covariance fill_normal common flow", + "covariance common flow", "[covariance][integration][online]", covariance_types) { SKIP_IF(this->not_float64_friendly()); - const int64_t nBlocks = GENERATE(1, 3, 10); - const te::dataframe input = - GENERATE_DATAFRAME(te::dataframe_builder{ 100, 100 }.fill_normal(0, 1, 7777), - te::dataframe_builder{ 100, 100 }.fill_normal(0, 1, 7777), - te::dataframe_builder{ 250, 250 }.fill_normal(0, 1, 7777), - te::dataframe_builder{ 500, 100 }.fill_normal(0, 1, 7777)); - // Homogen floating point type is the same as algorithm's floating point type - const auto input_data_table_id = this->get_homogen_table_id(); - this->online_general_checks(input, input_data_table_id, nBlocks); -} + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; -TEMPLATE_LIST_TEST_M(covariance_online_test, - "covariance fill_uniform common flow", - "[covariance][integration][online]", - covariance_types) { - SKIP_IF(this->not_float64_friendly()); - const int64_t nBlocks = GENERATE(1, 3, 10); - const te::dataframe input = - GENERATE_DATAFRAME(te::dataframe_builder{ 1000, 20 }.fill_uniform(-30, 30, 7777), - te::dataframe_builder{ 100, 10 }.fill_uniform(0, 1, 7777), - te::dataframe_builder{ 100, 10 }.fill_uniform(-10, 10, 7777), - te::dataframe_builder{ 500, 40 }.fill_uniform(-100, 100, 7777), - te::dataframe_builder{ 500, 250 }.fill_uniform(0, 1, 7777)); + const int64_t nBlocks = GENERATE(1, 10); + INFO("nBlocks=" << nBlocks); + this->set_blocks_count(nBlocks); - // Homogen floating point type is the same as algorithm's floating point type - const auto input_data_table_id = this->get_homogen_table_id(); - this->online_general_checks(input, input_data_table_id, nBlocks); -} + const bool assume_centered = GENERATE(true, false); + INFO("assume_centered=" << assume_centered); + const bool bias = GENERATE(true, false); + INFO("bias=" << bias); + const cov::result_option_id result_option = + GENERATE(covariance::result_options::means, + covariance::result_options::cov_matrix, + covariance::result_options::cor_matrix, + covariance::result_options::cor_matrix | covariance::result_options::cov_matrix, + covariance::result_options::cor_matrix | covariance::result_options::cov_matrix | + covariance::result_options::means); + INFO("result_option=" << result_option); + + auto cov_desc = covariance::descriptor() + .set_result_options(result_option) + .set_assume_centered(assume_centered) + .set_bias(bias); -TEMPLATE_LIST_TEST_M(covariance_online_test, - "covariance fill_uniform nightly common flow", - "[covariance][integration][online][nightly]", - covariance_types) { - SKIP_IF(this->not_float64_friendly()); - const int64_t nBlocks = GENERATE(1, 3, 10); const te::dataframe input = - GENERATE_DATAFRAME(te::dataframe_builder{ 5000, 20 }.fill_uniform(-30, 30, 7777), - te::dataframe_builder{ 10000, 200 }.fill_uniform(-30, 30, 7777), - te::dataframe_builder{ 1000000, 20 }.fill_uniform(-0.5, 0.5, 7777)); + GENERATE_DATAFRAME(te::dataframe_builder{ 100, 100 }.fill_normal(0, 1, 7777), + te::dataframe_builder{ 10000, 200 }.fill_uniform(-30, 30, 7777)); + + INFO("num_rows=" << input.get_row_count()); + INFO("num_columns=" << input.get_column_count()); // Homogen floating point type is the same as algorithm's floating point type const auto input_data_table_id = this->get_homogen_table_id(); - this->online_general_checks(input, input_data_table_id, nBlocks); + this->online_general_checks(input, input_data_table_id, cov_desc); } } // namespace oneapi::dal::covariance::test diff --git a/cpp/oneapi/dal/algo/covariance/test/online_spmd.cpp b/cpp/oneapi/dal/algo/covariance/test/online_spmd.cpp index bc4cf4f8dbd..cd28a24a025 100644 --- a/cpp/oneapi/dal/algo/covariance/test/online_spmd.cpp +++ b/cpp/oneapi/dal/algo/covariance/test/online_spmd.cpp @@ -34,6 +34,7 @@ class covariance_online_spmd_test using partial_input_t = typename base_t::partial_input_t; using partial_result_t = typename base_t::partial_result_t; using result_t = typename base_t::result_t; + using descriptor_t = typename base_t::descriptor_t; void set_rank_count(std::int64_t rank_count) { rank_count_ = rank_count; @@ -62,33 +63,57 @@ class covariance_online_spmd_test return input; } - void online_spmd_general_checks(const te::dataframe& data_fr, - cov::result_option_id compute_mode, - const te::table_id& data_table_id) { - CAPTURE(static_cast(compute_mode)); - const table data = data_fr.get_table(this->get_policy(), data_table_id); + void online_spmd_general_checks(const te::dataframe& input, + const te::table_id& input_table_id, + descriptor_t cov_desc) { + const table data = input.get_table(this->get_policy(), input_table_id); - const auto cov_desc = base_t::get_descriptor(compute_mode); std::vector partial_results; - auto input_table = base_t::template split_table_by_rows(data, rank_count_); + auto input_table = this->split_table_by_rows(data, rank_count_); for (int64_t i = 0; i < rank_count_; i++) { dal::covariance::partial_compute_result<> partial_result; - auto input_table_blocks = - base_t::template split_table_by_rows(input_table[i], blocks_count_); + auto input_table_blocks = split_table_by_rows(input_table[i], blocks_count_); for (int64_t j = 0; j < blocks_count_; j++) { partial_result = this->partial_compute(cov_desc, partial_result, input_table_blocks[j]); } partial_results.push_back(partial_result); } - const auto compute_result = this->finalize_compute_override(cov_desc, partial_results); - + auto compute_result = this->finalize_compute_override(cov_desc, partial_results); + base_t::check_compute_result(cov_desc, data, compute_result); + compute_result = this->finalize_compute_override(cov_desc, partial_results); base_t::check_compute_result(cov_desc, data, compute_result); } private: std::int64_t rank_count_; std::int64_t blocks_count_; + + template + std::vector split_table_by_rows(const dal::table& t, std::int64_t split_count) { + ONEDAL_ASSERT(0l < split_count); + ONEDAL_ASSERT(split_count <= t.get_row_count()); + + const std::int64_t row_count = t.get_row_count(); + const std::int64_t column_count = t.get_column_count(); + const std::int64_t block_size_regular = row_count / split_count; + const std::int64_t block_size_tail = row_count % split_count; + + std::vector result(split_count); + + std::int64_t row_offset = 0; + for (std::int64_t i = 0; i < split_count; i++) { + const std::int64_t tail = std::int64_t(i + 1 == split_count) * block_size_tail; + const std::int64_t block_size = block_size_regular + tail; + + const auto row_range = dal::range{ row_offset, row_offset + block_size }; + const auto block = dal::row_accessor{ t }.pull(row_range); + result[i] = dal::homogen_table::wrap(block, block_size, column_count); + row_offset += block_size; + } + + return result; + } }; using covariance_types = COMBINE_TYPES((float, double), (covariance::method::dense)); @@ -100,32 +125,45 @@ TEMPLATE_LIST_TEST_M(covariance_online_spmd_test, SKIP_IF(this->get_policy().is_cpu()); SKIP_IF(this->not_float64_friendly()); - const te::dataframe data = - GENERATE_DATAFRAME(te::dataframe_builder{ 1000, 100 }.fill_normal(-30, 30, 7777), - te::dataframe_builder{ 2000, 20 }.fill_normal(0, 1, 7777), - te::dataframe_builder{ 2500, 20 }.fill_normal(-30, 30, 7777)); - this->set_rank_count(GENERATE(1, 2, 4)); - this->set_blocks_count(GENERATE(1, 3, 10)); - cov::result_option_id mode_mean = result_options::means; - cov::result_option_id mode_cov = result_options::cov_matrix; - cov::result_option_id mode_cor = result_options::cor_matrix; - cov::result_option_id mode_cov_mean = result_options::cov_matrix | result_options::means; - cov::result_option_id mode_cov_cor = result_options::cov_matrix | result_options::cor_matrix; - cov::result_option_id mode_cor_mean = result_options::cor_matrix | result_options::means; - cov::result_option_id res_all = - result_options::cov_matrix | result_options::cor_matrix | result_options::means; - - const cov::result_option_id compute_mode = GENERATE_COPY(mode_mean, - mode_cor, - mode_cov, - mode_cor_mean, - mode_cov_mean, - mode_cov_cor, - res_all); - - const auto data_table_id = this->get_homogen_table_id(); - - this->online_spmd_general_checks(data, compute_mode, data_table_id); + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; + + const int64_t nBlocks = GENERATE(1, 10); + INFO("nBlocks=" << nBlocks); + this->set_blocks_count(nBlocks); + + const int64_t rank_count = GENERATE(2, 4); + INFO("rank_count=" << rank_count); + this->set_rank_count(rank_count); + + const bool assume_centered = GENERATE(true, false); + INFO("assume_centered=" << assume_centered); + const bool bias = GENERATE(true, false); + INFO("bias=" << bias); + const cov::result_option_id result_option = + GENERATE(covariance::result_options::means, + covariance::result_options::cov_matrix, + covariance::result_options::cor_matrix, + covariance::result_options::cor_matrix | covariance::result_options::cov_matrix, + covariance::result_options::cor_matrix | covariance::result_options::cov_matrix | + covariance::result_options::means); + INFO("result_option=" << result_option); + + auto cov_desc = covariance::descriptor() + .set_result_options(result_option) + .set_assume_centered(assume_centered) + .set_bias(bias); + + const te::dataframe input = + GENERATE_DATAFRAME(te::dataframe_builder{ 100, 100 }.fill_normal(0, 1, 7777), + te::dataframe_builder{ 500, 100 }.fill_normal(-30, 30, 7777)); + + INFO("num_rows=" << input.get_row_count()); + INFO("num_columns=" << input.get_column_count()); + + const auto input_data_table_id = this->get_homogen_table_id(); + + this->online_spmd_general_checks(input, input_data_table_id, cov_desc); } } // namespace oneapi::dal::covariance::test diff --git a/cpp/oneapi/dal/algo/covariance/test/spmd.cpp b/cpp/oneapi/dal/algo/covariance/test/spmd.cpp index ac50be44d2a..458ec9df3fd 100644 --- a/cpp/oneapi/dal/algo/covariance/test/spmd.cpp +++ b/cpp/oneapi/dal/algo/covariance/test/spmd.cpp @@ -31,6 +31,7 @@ class covariance_spmd_test : public covariance_test(compute_mode)); + const te::table_id& data_table_id, + descriptor_t cov_desc) { const table data = data_fr.get_table(this->get_policy(), data_table_id); - const auto cov_desc = base_t::get_descriptor(compute_mode); - const auto compute_result = this->compute_override(cov_desc, data); base_t::check_compute_result(cov_desc, data, compute_result); @@ -89,34 +87,42 @@ TEMPLATE_LIST_TEST_M(covariance_spmd_test, SKIP_IF(this->get_policy().is_cpu()); SKIP_IF(this->not_float64_friendly()); - const te::dataframe data = - GENERATE_DATAFRAME(te::dataframe_builder{ 10, 10 }.fill_normal(-30, 30, 7777), - te::dataframe_builder{ 20, 20 }.fill_normal(-30, 30, 7777), - te::dataframe_builder{ 1000, 100 }.fill_normal(-30, 30, 7777), - te::dataframe_builder{ 2000, 20 }.fill_normal(0, 1, 7777), - te::dataframe_builder{ 2500, 20 }.fill_normal(-30, 30, 7777)); - this->set_rank_count(GENERATE(2, 4)); - - cov::result_option_id mode_mean = result_options::means; - cov::result_option_id mode_cov = result_options::cov_matrix; - cov::result_option_id mode_cor = result_options::cor_matrix; - cov::result_option_id mode_cov_mean = result_options::cov_matrix | result_options::means; - cov::result_option_id mode_cov_cor = result_options::cov_matrix | result_options::cor_matrix; - cov::result_option_id mode_cor_mean = result_options::cor_matrix | result_options::means; - cov::result_option_id res_all = - result_options::cov_matrix | result_options::cor_matrix | result_options::means; - - const cov::result_option_id compute_mode = GENERATE_COPY(mode_mean, - mode_cor, - mode_cov, - mode_cor_mean, - mode_cov_mean, - mode_cov_cor, - res_all); - - const auto data_table_id = this->get_homogen_table_id(); - - this->spmd_general_checks(data, compute_mode, data_table_id); + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; + + const int rank_count = GENERATE(2, 4); + INFO("rank_count=" << rank_count); + this->set_rank_count(rank_count); + + const bool assume_centered = GENERATE(true, false); + INFO("assume_centered=" << assume_centered); + const bool bias = GENERATE(true, false); + INFO("bias=" << bias); + const cov::result_option_id result_option = + GENERATE(covariance::result_options::means, + covariance::result_options::cov_matrix, + covariance::result_options::cor_matrix, + covariance::result_options::cor_matrix | covariance::result_options::cov_matrix, + covariance::result_options::cor_matrix | covariance::result_options::cov_matrix | + covariance::result_options::means); + INFO("result_option=" << result_option); + + auto cov_desc = covariance::descriptor() + .set_result_options(result_option) + .set_assume_centered(assume_centered) + .set_bias(bias); + + const te::dataframe input = + GENERATE_DATAFRAME(te::dataframe_builder{ 100, 100 }.fill_normal(0, 1, 7777), + te::dataframe_builder{ 10000, 200 }.fill_uniform(-30, 30, 7777)); + + INFO("num_rows=" << input.get_row_count()); + INFO("num_columns=" << input.get_column_count()); + + // Homogen floating point type is the same as algorithm's floating point type + const auto input_data_table_id = this->get_homogen_table_id(); + + this->spmd_general_checks(input, input_data_table_id, cov_desc); } } // namespace oneapi::dal::covariance::test diff --git a/cpp/oneapi/dal/algo/dbscan/test/badarg.cpp b/cpp/oneapi/dal/algo/dbscan/test/badarg.cpp index 43e07196fb8..51788c327cb 100644 --- a/cpp/oneapi/dal/algo/dbscan/test/badarg.cpp +++ b/cpp/oneapi/dal/algo/dbscan/test/badarg.cpp @@ -26,9 +26,11 @@ namespace oneapi::dal::dbscan::test { namespace te = dal::test::engine; -template +template class dbscan_badarg_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count = 5; static constexpr std::int64_t bad_weight_element_count = 2; @@ -64,8 +66,10 @@ class dbscan_badarg_test : public te::algo_fixture { static constexpr std::array bad_weights_ = { 1.0, 1.0 }; }; +using dbscan_types = COMBINE_TYPES((float, double), (dbscan::method::brute_force)); + #define DBSCAN_BADARG_TEST(name) \ - TEMPLATE_TEST_M(dbscan_badarg_test, name, "[dbscan][badarg]", method::brute_force) + TEMPLATE_LIST_TEST_M(dbscan_badarg_test, name, "[dbscan][badarg]", dbscan_types) DBSCAN_BADARG_TEST("accepts positive min observations") { REQUIRE_NOTHROW(this->get_descriptor().set_min_observations(1)); diff --git a/cpp/oneapi/dal/algo/kmeans/test/badarg.cpp b/cpp/oneapi/dal/algo/kmeans/test/badarg.cpp index 481b032a387..a34d4a8674b 100644 --- a/cpp/oneapi/dal/algo/kmeans/test/badarg.cpp +++ b/cpp/oneapi/dal/algo/kmeans/test/badarg.cpp @@ -27,9 +27,11 @@ namespace oneapi::dal::kmeans::test { namespace te = dal::test::engine; -template +template class kmeans_badarg_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count = 8; static constexpr std::int64_t column_count = 2; static constexpr std::int64_t element_count = row_count * column_count; @@ -106,8 +108,10 @@ class kmeans_badarg_test : public te::algo_fixture { }; }; +using kmeans_types = COMBINE_TYPES((float, double), (kmeans::method::lloyd_dense)); + #define KMEANS_BADARG_TEST(name) \ - TEMPLATE_TEST_M(kmeans_badarg_test, name, "[kmeans][badarg]", method::lloyd_dense) + TEMPLATE_LIST_TEST_M(kmeans_badarg_test, name, "[kmeans][badarg]", kmeans_types) KMEANS_BADARG_TEST("accepts positive cluster_count") { REQUIRE_NOTHROW(this->get_descriptor().set_cluster_count(1)); diff --git a/cpp/oneapi/dal/algo/linear_kernel/test/badargs.cpp b/cpp/oneapi/dal/algo/linear_kernel/test/badargs.cpp index 13fd31307f7..10340ee02f7 100644 --- a/cpp/oneapi/dal/algo/linear_kernel/test/badargs.cpp +++ b/cpp/oneapi/dal/algo/linear_kernel/test/badargs.cpp @@ -26,9 +26,11 @@ namespace oneapi::dal::linear_kernel::test { namespace te = dal::test::engine; -template +template class linear_kernel_badarg_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count_x = 5; static constexpr std::int64_t row_count_y = 3; static constexpr std::int64_t column_count = 4; @@ -62,11 +64,13 @@ class linear_kernel_badarg_test : public te::algo_fixture { -2.0, -1.0, -2.0, -2.0 }; }; -#define LINEAR_KERNEL_BADARG_TEST(name) \ - TEMPLATE_TEST_M(linear_kernel_badarg_test, \ - name, \ - "[linear_kernel][badarg]", \ - linear_kernel::method::dense) +using lr_kernel_types = COMBINE_TYPES((float, double), (linear_kernel::method::dense)); + +#define LINEAR_KERNEL_BADARG_TEST(name) \ + TEMPLATE_LIST_TEST_M(linear_kernel_badarg_test, \ + name, \ + "[linear_kernel][badarg]", \ + lr_kernel_types) LINEAR_KERNEL_BADARG_TEST("throws if x data is empty") { const auto linear_kernel_desc = this->get_descriptor(); diff --git a/cpp/oneapi/dal/algo/linear_kernel/test/overflow.cpp b/cpp/oneapi/dal/algo/linear_kernel/test/overflow.cpp index b077823efb3..5ab53e1fe0c 100644 --- a/cpp/oneapi/dal/algo/linear_kernel/test/overflow.cpp +++ b/cpp/oneapi/dal/algo/linear_kernel/test/overflow.cpp @@ -25,9 +25,11 @@ namespace oneapi::dal::linear_kernel::test { namespace te = dal::test::engine; -template +template class linear_kernel_overflow_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count_x = 0x7FFFFFFFF; static constexpr std::int64_t row_count_y = 0x7FFFFFFFF; static constexpr std::int64_t column_count = 2; @@ -45,11 +47,13 @@ class linear_kernel_overflow_test : public te::algo_fixture { } }; -#define LINEAR_KERNEL_OVERFLOW_TEST(name) \ - TEMPLATE_TEST_M(linear_kernel_overflow_test, \ - name, \ - "[linear_kernel][overflow]", \ - linear_kernel::method::dense) +using lr_kernel_types = COMBINE_TYPES((float, double), (linear_kernel::method::dense)); + +#define LINEAR_KERNEL_OVERFLOW_TEST(name) \ + TEMPLATE_LIST_TEST_M(linear_kernel_overflow_test, \ + name, \ + "[linear_kernel][overflow]", \ + lr_kernel_types) LINEAR_KERNEL_OVERFLOW_TEST("compute throws if result values table leads to overflow") { const auto linear_kernel_desc = this->get_descriptor(); diff --git a/cpp/oneapi/dal/algo/linear_regression/backend/gpu/finalize_train_kernel_norm_eq_impl_dpc.cpp b/cpp/oneapi/dal/algo/linear_regression/backend/gpu/finalize_train_kernel_norm_eq_impl_dpc.cpp index c470f45403e..f6c6dd54091 100644 --- a/cpp/oneapi/dal/algo/linear_regression/backend/gpu/finalize_train_kernel_norm_eq_impl_dpc.cpp +++ b/cpp/oneapi/dal/algo/linear_regression/backend/gpu/finalize_train_kernel_norm_eq_impl_dpc.cpp @@ -20,6 +20,8 @@ #include "oneapi/dal/backend/primitives/lapack.hpp" +#ifdef ONEDAL_DATA_PARALLEL + namespace oneapi::dal::linear_regression::backend { namespace be = dal::backend; @@ -47,25 +49,32 @@ train_result finalize_train_kernel_norm_eq_impl::operator()( const auto feature_count = ext_feature_count - compute_intercept; const pr::ndshape<2> xtx_shape{ ext_feature_count, ext_feature_count }; - - const auto xtx_nd = - pr::table2ndarray(q, input.get_partial_xtx(), sycl::usm::alloc::device); - const auto xty_nd = pr::table2ndarray(q, - input.get_partial_xty(), - sycl::usm::alloc::device); - const pr::ndshape<2> betas_shape{ response_count, feature_count + 1 }; + auto xtx_nd = pr::table2ndarray(q, input.get_partial_xtx(), sycl::usm::alloc::device); + auto xty_nd = pr::table2ndarray(q, + input.get_partial_xty(), + sycl::usm::alloc::device); + const auto betas_size = check_mul_overflow(response_count, feature_count + 1); auto betas_arr = array::zeros(q, betas_size, alloc); if (comm_.get_rank_count() > 1) { + auto xtx_nd_copy = pr::ndarray::empty(q, xtx_shape, sycl::usm::alloc::device); + auto copy_event = copy(q, xtx_nd_copy, xtx_nd, {}); + copy_event.wait_and_throw(); + xtx_nd = xtx_nd_copy; { ONEDAL_PROFILER_TASK(xtx_allreduce); auto xtx_arr = dal::array::wrap(q, xtx_nd.get_mutable_data(), xtx_nd.get_count()); comm_.allreduce(xtx_arr).wait(); } + auto xty_nd_copy = + pr::ndarray::empty(q, betas_shape, sycl::usm::alloc::device); + copy_event = copy(q, xty_nd_copy, xty_nd, {}); + copy_event.wait_and_throw(); + xty_nd = xty_nd_copy; { ONEDAL_PROFILER_TASK(xty_allreduce); auto xty_arr = @@ -125,3 +134,5 @@ template class finalize_train_kernel_norm_eq_impl; template class finalize_train_kernel_norm_eq_impl; } // namespace oneapi::dal::linear_regression::backend + +#endif // ONEDAL_DATA_PARALLEL diff --git a/cpp/oneapi/dal/algo/linear_regression/test/online_spmd.cpp b/cpp/oneapi/dal/algo/linear_regression/test/online_spmd.cpp index c0f7968adfc..51e1ed18745 100644 --- a/cpp/oneapi/dal/algo/linear_regression/test/online_spmd.cpp +++ b/cpp/oneapi/dal/algo/linear_regression/test/online_spmd.cpp @@ -94,7 +94,7 @@ class lr_online_spmd_test : public lr_testfinalize_train_override(desc, partial_results); + auto train_result = this->finalize_train_override(desc, partial_results); SECTION("Checking intercept values") { if (desc.get_result_options().test(result_options::intercept)) @@ -105,6 +105,18 @@ class lr_online_spmd_test : public lr_testfinalize_train_override(desc, partial_results); + + SECTION("Checking intercept values after double finalize") { + if (desc.get_result_options().test(result_options::intercept)) + base_t::check_if_close(train_result.get_intercept(), base_t::bias_, tol); + } + + SECTION("Checking coefficient values after double finalize") { + if (desc.get_result_options().test(result_options::coefficients)) + base_t::check_if_close(train_result.get_coefficients(), base_t::beta_, tol); + } } private: diff --git a/cpp/oneapi/dal/algo/pca/backend/gpu/finalize_train_kernel_cov_impl_dpc.cpp b/cpp/oneapi/dal/algo/pca/backend/gpu/finalize_train_kernel_cov_impl_dpc.cpp index 31f6becf309..12862ab04ba 100644 --- a/cpp/oneapi/dal/algo/pca/backend/gpu/finalize_train_kernel_cov_impl_dpc.cpp +++ b/cpp/oneapi/dal/algo/pca/backend/gpu/finalize_train_kernel_cov_impl_dpc.cpp @@ -27,6 +27,8 @@ #include "oneapi/dal/algo/pca/backend/sign_flip.hpp" #include "oneapi/dal/table/row_accessor.hpp" +#ifdef ONEDAL_DATA_PARALLEL + namespace oneapi::dal::pca::backend { namespace bk = dal::backend; @@ -57,30 +59,42 @@ result_t finalize_train_kernel_cov_impl::operator()(const descriptor_t& d const auto nobs_host = pr::table2ndarray(q, input.get_partial_n_rows()); auto rows_count_global = nobs_host.get_data()[0]; - { - ONEDAL_PROFILER_TASK(allreduce_rows_count_global); - comm_.allreduce(rows_count_global, spmd::reduce_op::sum).wait(); - } - - const auto sums = - pr::table2ndarray_1d(q, input.get_partial_sum(), sycl::usm::alloc::device); - - { - ONEDAL_PROFILER_TASK(allreduce_sums, q); - comm_.allreduce(sums.flatten(q, {}), spmd::reduce_op::sum).wait(); + auto sums = pr::table2ndarray_1d(q, input.get_partial_sum(), sycl::usm::alloc::device); + auto xtx = + pr::table2ndarray(q, input.get_partial_crossproduct(), sycl::usm::alloc::device); + if (comm_.get_rank_count() > 1) { + { + ONEDAL_PROFILER_TASK(allreduce_rows_count_global); + comm_.allreduce(rows_count_global, spmd::reduce_op::sum).wait(); + } + auto sums_copy = + pr::ndarray::empty(q, { column_count }, sycl::usm::alloc::device); + auto copy_event = copy(q, sums_copy, sums, {}); + copy_event.wait_and_throw(); + sums = sums_copy; + + auto xtx_copy = pr::ndarray::empty(q, + { column_count, column_count }, + sycl::usm::alloc::device); + copy_event = copy(q, xtx_copy, xtx, {}); + copy_event.wait_and_throw(); + xtx = xtx_copy; + + { + ONEDAL_PROFILER_TASK(allreduce_sums, q); + comm_.allreduce(sums.flatten(q, {}), spmd::reduce_op::sum).wait(); + } + + { + ONEDAL_PROFILER_TASK(allreduce_xtx, q); + comm_.allreduce(xtx.flatten(q, {}), spmd::reduce_op::sum).wait(); + } } if (desc.get_result_options().test(result_options::means)) { auto [means, means_event] = compute_means(q, sums, rows_count_global, {}); result.set_means(homogen_table::wrap(means.flatten(q, { means_event }), 1, column_count)); } - - const auto xtx = - pr::table2ndarray(q, input.get_partial_crossproduct(), sycl::usm::alloc::device); - { - ONEDAL_PROFILER_TASK(allreduce_xtx, q); - comm_.allreduce(xtx.flatten(q, {}), spmd::reduce_op::sum).wait(); - } auto [cov, cov_event] = compute_covariance(q, rows_count_global, xtx, sums, {}); auto [vars, vars_event] = compute_variances(q, cov, { cov_event }); @@ -144,3 +158,5 @@ template class finalize_train_kernel_cov_impl; template class finalize_train_kernel_cov_impl; } // namespace oneapi::dal::pca::backend + +#endif // ONEDAL_DATA_PARALLEL diff --git a/cpp/oneapi/dal/algo/pca/backend/test/sign_flip.cpp b/cpp/oneapi/dal/algo/pca/backend/test/sign_flip.cpp index bcdd6f14aa6..77518cc558d 100644 --- a/cpp/oneapi/dal/algo/pca/backend/test/sign_flip.cpp +++ b/cpp/oneapi/dal/algo/pca/backend/test/sign_flip.cpp @@ -56,7 +56,9 @@ class sign_flip_test { } }; -TEMPLATE_TEST_M(sign_flip_test, "flips if all negative", "[negative]", float, double) { +using data_types = std::tuple; + +TEMPLATE_LIST_TEST_M(sign_flip_test, "flips if all negative", "[negative]", data_types) { auto data = this->get_negative_data(); sign_flip(data); @@ -64,7 +66,7 @@ TEMPLATE_TEST_M(sign_flip_test, "flips if all negative", "[negative]", float, do this->check_if_flipped_data_positive(this->get_negative_data(), data); } -TEMPLATE_TEST_M(sign_flip_test, "does not flips if all positive", "[positive]", float, double) { +TEMPLATE_LIST_TEST_M(sign_flip_test, "does not flips if all positive", "[positive]", data_types) { auto data = this->get_positive_data(); sign_flip(data); diff --git a/cpp/oneapi/dal/algo/pca/test/badarg.cpp b/cpp/oneapi/dal/algo/pca/test/badarg.cpp index 6de97954418..170fc7cf62b 100644 --- a/cpp/oneapi/dal/algo/pca/test/badarg.cpp +++ b/cpp/oneapi/dal/algo/pca/test/badarg.cpp @@ -27,9 +27,11 @@ namespace oneapi::dal::pca::test { namespace te = dal::test::engine; -template +template class pca_badarg_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count = 8; static constexpr std::int64_t column_count = 2; static constexpr std::int64_t element_count = row_count * column_count; @@ -60,8 +62,10 @@ class pca_badarg_test : public te::algo_fixture { }; }; +using pca_types = COMBINE_TYPES((float, double), (pca::method::cov, pca::method::svd)); + #define PCA_BADARG_TEST(name) \ - TEMPLATE_TEST_M(pca_badarg_test, name, "[pca][badarg]", pca::method::cov, pca::method::svd) + TEMPLATE_LIST_TEST_M(pca_badarg_test, name, "[pca][badarg]", pca_types) PCA_BADARG_TEST("accepts non-negative component_count") { REQUIRE_NOTHROW(this->get_descriptor().set_component_count(0)); diff --git a/cpp/oneapi/dal/algo/pca/test/online_spmd.cpp b/cpp/oneapi/dal/algo/pca/test/online_spmd.cpp index a75d288ccc8..82e19c667cc 100644 --- a/cpp/oneapi/dal/algo/pca/test/online_spmd.cpp +++ b/cpp/oneapi/dal/algo/pca/test/online_spmd.cpp @@ -79,8 +79,10 @@ class pca_online_spmd_test : public pca_testfinalize_train_override(pca_desc, partial_results); + auto train_result = this->finalize_train_override(pca_desc, partial_results); + base_t::check_train_result(pca_desc, data_fr, train_result); + train_result = this->finalize_train_override(pca_desc, partial_results); base_t::check_train_result(pca_desc, data_fr, train_result); } diff --git a/cpp/oneapi/dal/algo/pca/test/overflow.cpp b/cpp/oneapi/dal/algo/pca/test/overflow.cpp index cc5ca82015f..46c4d26fbcc 100644 --- a/cpp/oneapi/dal/algo/pca/test/overflow.cpp +++ b/cpp/oneapi/dal/algo/pca/test/overflow.cpp @@ -26,9 +26,11 @@ namespace oneapi::dal::pca::test { namespace te = dal::test::engine; -template +template class pca_overflow_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count = 8; static constexpr std::int64_t column_count = 2; static constexpr std::int64_t invalid_component_count = 0x7FFFFFFFFFFFFFFF; @@ -52,8 +54,10 @@ class pca_overflow_test : public te::algo_fixture { } }; // namespace oneapi::dal::pca::test +using pca_types = COMBINE_TYPES((float, double), (pca::method::cov, pca::method::svd)); + #define PCA_OVERFLOW_TEST(name) \ - TEMPLATE_TEST_M(pca_overflow_test, name, "[pca][overflow]", pca::method::cov, pca::method::svd) + TEMPLATE_LIST_TEST_M(pca_overflow_test, name, "[pca][overflow]", pca_types) PCA_OVERFLOW_TEST("train throws if component count leads to overflow") { const auto pca_desc = this->get_descriptor_with_invalid_component_count(); diff --git a/cpp/oneapi/dal/algo/polynomial_kernel/test/badargs.cpp b/cpp/oneapi/dal/algo/polynomial_kernel/test/badargs.cpp index 4b5fb0008ef..3ff318ce95d 100644 --- a/cpp/oneapi/dal/algo/polynomial_kernel/test/badargs.cpp +++ b/cpp/oneapi/dal/algo/polynomial_kernel/test/badargs.cpp @@ -26,9 +26,11 @@ namespace oneapi::dal::polynomial_kernel::test { namespace te = dal::test::engine; -template +template class polynomial_kernel_badarg_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count_x = 5; static constexpr std::int64_t row_count_y = 3; static constexpr std::int64_t column_count = 4; @@ -66,11 +68,13 @@ class polynomial_kernel_badarg_test : public te::algo_fixture { -2.0, -1.0, -2.0, -2.0 }; }; -#define POLYNOMIAL_KERNEL_BADARG_TEST(name) \ - TEMPLATE_TEST_M(polynomial_kernel_badarg_test, \ - name, \ - "[polynomial_kernel][badarg]", \ - polynomial_kernel::method::dense) +using pol_kernel_types = COMBINE_TYPES((float, double), (polynomial_kernel::method::dense)); + +#define POLYNOMIAL_KERNEL_BADARG_TEST(name) \ + TEMPLATE_LIST_TEST_M(polynomial_kernel_badarg_test, \ + name, \ + "[polynomial_kernel][badarg]", \ + pol_kernel_types) POLYNOMIAL_KERNEL_BADARG_TEST("accepts positive degree") { SKIP_IF(this->not_available_on_device()); diff --git a/cpp/oneapi/dal/algo/polynomial_kernel/test/overflow.cpp b/cpp/oneapi/dal/algo/polynomial_kernel/test/overflow.cpp index 4555f02acfc..90014940819 100644 --- a/cpp/oneapi/dal/algo/polynomial_kernel/test/overflow.cpp +++ b/cpp/oneapi/dal/algo/polynomial_kernel/test/overflow.cpp @@ -25,9 +25,11 @@ namespace oneapi::dal::polynomial_kernel::test { namespace te = dal::test::engine; -template +template class polynomial_kernel_overflow_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count_x = 0x7FFFFFFFF; static constexpr std::int64_t row_count_y = 0x7FFFFFFFF; static constexpr std::int64_t column_count = 2; @@ -49,11 +51,13 @@ class polynomial_kernel_overflow_test : public te::algo_fixture { } }; -#define POLYNOMIAL_KERNEL_OVERFLOW_TEST(name) \ - TEMPLATE_TEST_M(polynomial_kernel_overflow_test, \ - name, \ - "[polynomial_kernel][overflow]", \ - polynomial_kernel::method::dense) +using polynomial_kernel_types = COMBINE_TYPES((float, double), (polynomial_kernel::method::dense)); + +#define POLYNOMIAL_KERNEL_OVERFLOW_TEST(name) \ + TEMPLATE_LIST_TEST_M(polynomial_kernel_overflow_test, \ + name, \ + "[polynomial_kernel][overflow]", \ + polynomial_kernel_types) POLYNOMIAL_KERNEL_OVERFLOW_TEST("compute throws if result values table leads to overflow") { SKIP_IF(this->not_available_on_device()); diff --git a/cpp/oneapi/dal/algo/rbf_kernel/test/badargs.cpp b/cpp/oneapi/dal/algo/rbf_kernel/test/badargs.cpp index 37e76faef5a..02d5c3c71c4 100644 --- a/cpp/oneapi/dal/algo/rbf_kernel/test/badargs.cpp +++ b/cpp/oneapi/dal/algo/rbf_kernel/test/badargs.cpp @@ -26,9 +26,11 @@ namespace oneapi::dal::rbf_kernel::test { namespace te = dal::test::engine; -template +template class rbf_kernel_badarg_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count_x = 5; static constexpr std::int64_t row_count_y = 3; static constexpr std::int64_t column_count = 4; @@ -62,8 +64,10 @@ class rbf_kernel_badarg_test : public te::algo_fixture { -2.0, -1.0, -2.0, -2.0 }; }; +using rbf_kernel_types = COMBINE_TYPES((float, double), (rbf_kernel::method::dense)); + #define RBF_KERNEL_BADARG_TEST(name) \ - TEMPLATE_TEST_M(rbf_kernel_badarg_test, name, "[rbf_kernel][badarg]", rbf_kernel::method::dense) + TEMPLATE_LIST_TEST_M(rbf_kernel_badarg_test, name, "[rbf_kernel][badarg]", rbf_kernel_types) RBF_KERNEL_BADARG_TEST("accepts positive sigma") { REQUIRE_NOTHROW(this->get_descriptor().set_sigma(3)); diff --git a/cpp/oneapi/dal/algo/rbf_kernel/test/overflow.cpp b/cpp/oneapi/dal/algo/rbf_kernel/test/overflow.cpp index 0973606447a..27bb0682473 100644 --- a/cpp/oneapi/dal/algo/rbf_kernel/test/overflow.cpp +++ b/cpp/oneapi/dal/algo/rbf_kernel/test/overflow.cpp @@ -25,9 +25,11 @@ namespace oneapi::dal::rbf_kernel::test { namespace te = dal::test::engine; -template +template class rbf_kernel_overflow_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count_x = 0x7FFFFFFFF; static constexpr std::int64_t row_count_y = 0x7FFFFFFFF; static constexpr std::int64_t column_count = 2; @@ -45,11 +47,10 @@ class rbf_kernel_overflow_test : public te::algo_fixture { } }; -#define RBF_KERNEL_OVERFLOW_TEST(name) \ - TEMPLATE_TEST_M(rbf_kernel_overflow_test, \ - name, \ - "[rbf_kernel][overflow]", \ - rbf_kernel::method::dense) +using rbf_kernel_types = COMBINE_TYPES((float, double), (rbf_kernel::method::dense)); + +#define RBF_KERNEL_OVERFLOW_TEST(name) \ + TEMPLATE_LIST_TEST_M(rbf_kernel_overflow_test, name, "[rbf_kernel][overflow]", rbf_kernel_types) RBF_KERNEL_OVERFLOW_TEST("compute throws if result values table leads to overflow") { const auto rbf_kernel_desc = this->get_descriptor(); diff --git a/cpp/oneapi/dal/algo/sigmoid_kernel/test/badargs.cpp b/cpp/oneapi/dal/algo/sigmoid_kernel/test/badargs.cpp index 48cc8f310fb..56c9e290205 100644 --- a/cpp/oneapi/dal/algo/sigmoid_kernel/test/badargs.cpp +++ b/cpp/oneapi/dal/algo/sigmoid_kernel/test/badargs.cpp @@ -26,9 +26,11 @@ namespace oneapi::dal::sigmoid_kernel::test { namespace te = dal::test::engine; -template +template class sigmoid_kernel_badarg_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count_x = 5; static constexpr std::int64_t row_count_y = 3; static constexpr std::int64_t column_count = 4; @@ -66,11 +68,13 @@ class sigmoid_kernel_badarg_test : public te::algo_fixture { -2.0, -1.0, -2.0, -2.0 }; }; -#define SIGMOID_KERNEL_BADARG_TEST(name) \ - TEMPLATE_TEST_M(sigmoid_kernel_badarg_test, \ - name, \ - "[sigmoid_kernel][badarg]", \ - sigmoid_kernel::method::dense) +using sigmoid_kernel_types = COMBINE_TYPES((float, double), (sigmoid_kernel::method::dense)); + +#define SIGMOID_KERNEL_BADARG_TEST(name) \ + TEMPLATE_LIST_TEST_M(sigmoid_kernel_badarg_test, \ + name, \ + "[sigmoid_kernel][badarg]", \ + sigmoid_kernel_types) SIGMOID_KERNEL_BADARG_TEST("throws if x data is empty") { SKIP_IF(this->not_available_on_device()); diff --git a/cpp/oneapi/dal/algo/sigmoid_kernel/test/overflow.cpp b/cpp/oneapi/dal/algo/sigmoid_kernel/test/overflow.cpp index def94dc81a5..3d3cd482233 100644 --- a/cpp/oneapi/dal/algo/sigmoid_kernel/test/overflow.cpp +++ b/cpp/oneapi/dal/algo/sigmoid_kernel/test/overflow.cpp @@ -25,9 +25,11 @@ namespace oneapi::dal::sigmoid_kernel::test { namespace te = dal::test::engine; -template +template class sigmoid_kernel_overflow_test : public te::algo_fixture { public: + using Float = std::tuple_element_t<0, TestType>; + using Method = std::tuple_element_t<1, TestType>; static constexpr std::int64_t row_count_x = 0x7FFFFFFFF; static constexpr std::int64_t row_count_y = 0x7FFFFFFFF; static constexpr std::int64_t column_count = 2; @@ -49,11 +51,13 @@ class sigmoid_kernel_overflow_test : public te::algo_fixture { } }; -#define SIGMOID_KERNEL_OVERFLOW_TEST(name) \ - TEMPLATE_TEST_M(sigmoid_kernel_overflow_test, \ - name, \ - "[sigmoid_kernel][overflow]", \ - sigmoid_kernel::method::dense) +using sigmoid_kernel_types = COMBINE_TYPES((float, double), (sigmoid_kernel::method::dense)); + +#define SIGMOID_KERNEL_OVERFLOW_TEST(name) \ + TEMPLATE_LIST_TEST_M(sigmoid_kernel_overflow_test, \ + name, \ + "[sigmoid_kernel][overflow]", \ + sigmoid_kernel_types) SIGMOID_KERNEL_OVERFLOW_TEST("compute throws if result values table leads to overflow") { SKIP_IF(this->not_available_on_device()); diff --git a/cpp/oneapi/dal/backend/micromkl/macro.hpp b/cpp/oneapi/dal/backend/micromkl/macro.hpp index d4e8b484309..35b24d3e701 100644 --- a/cpp/oneapi/dal/backend/micromkl/macro.hpp +++ b/cpp/oneapi/dal/backend/micromkl/macro.hpp @@ -23,8 +23,8 @@ #error "This header cannot be included outside of micromkl module" #endif -#define STRINGIFY(x) #x -#define EXPAND(...) __VA_ARGS__ +#define STRINGIFY(x) #x +#define DAL_EXPAND(...) __VA_ARGS__ #ifdef ONEDAL_REF #define FUNC_NAME(prefix, name) name @@ -54,20 +54,20 @@ DISPATCH_FUNC_CPU(nominal_cpu, actual_cpu, prefix, name, argdecl, argcall) #if defined(TARGET_X86_64) -#define FUNC_AVX512(...) EXPAND(FUNC_CPU(avx512, avx512, __VA_ARGS__)) -#define FUNC_AVX2(...) EXPAND(FUNC_CPU(avx2, avx2, __VA_ARGS__)) +#define FUNC_AVX512(...) DAL_EXPAND(FUNC_CPU(avx512, avx512, __VA_ARGS__)) +#define FUNC_AVX2(...) DAL_EXPAND(FUNC_CPU(avx2, avx2, __VA_ARGS__)) #elif defined(TARGET_ARM) -#define FUNC_A8SVE(...) EXPAND(FUNC_CPU(sve, sve, __VA_ARGS__)) +#define FUNC_A8SVE(...) DAL_EXPAND(FUNC_CPU(sve, sve, __VA_ARGS__)) #elif defined(TARGET_RISCV64) -#define FUNC_RV64(...) EXPAND(FUNC_CPU(rv64, rv64, __VA_ARGS__)) +#define FUNC_RV64(...) DAL_EXPAND(FUNC_CPU(rv64, rv64, __VA_ARGS__)) #endif #ifdef __APPLE__ -#define FUNC_SSE42(...) EXPAND(FUNC_CPU(sse42, avx2, __VA_ARGS__)) -#define FUNC_SSE2(...) EXPAND(FUNC_CPU(sse2, avx2, __VA_ARGS__)) +#define FUNC_SSE42(...) DAL_EXPAND(FUNC_CPU(sse42, avx2, __VA_ARGS__)) +#define FUNC_SSE2(...) DAL_EXPAND(FUNC_CPU(sse2, avx2, __VA_ARGS__)) #else -#define FUNC_SSE42(...) EXPAND(FUNC_CPU(sse42, sse42, __VA_ARGS__)) -#define FUNC_SSE2(...) EXPAND(FUNC_CPU(sse2, sse2, __VA_ARGS__)) +#define FUNC_SSE42(...) DAL_EXPAND(FUNC_CPU(sse42, sse42, __VA_ARGS__)) +#define FUNC_SSE2(...) DAL_EXPAND(FUNC_CPU(sse2, sse2, __VA_ARGS__)) #endif #if defined(TARGET_X86_64) @@ -103,36 +103,36 @@ template void name argdecl(Float); #ifdef ONEDAL_CPU_DISPATCH_A8SVE -#define INSTANTIATE_A8SVE(...) EXPAND(INSTANTIATE_CPU(sve, __VA_ARGS__)) +#define INSTANTIATE_A8SVE(...) DAL_EXPAND(INSTANTIATE_CPU(sve, __VA_ARGS__)) #else #define INSTANTIATE_A8SVE(...) #endif #ifdef ONEDAL_CPU_DISPATCH_AVX512 -#define INSTANTIATE_AVX512(...) EXPAND(INSTANTIATE_CPU(avx512, __VA_ARGS__)) +#define INSTANTIATE_AVX512(...) DAL_EXPAND(INSTANTIATE_CPU(avx512, __VA_ARGS__)) #else #define INSTANTIATE_AVX512(...) #endif #ifdef ONEDAL_CPU_DISPATCH_AVX2 -#define INSTANTIATE_AVX2(...) EXPAND(INSTANTIATE_CPU(avx2, __VA_ARGS__)) +#define INSTANTIATE_AVX2(...) DAL_EXPAND(INSTANTIATE_CPU(avx2, __VA_ARGS__)) #else #define INSTANTIATE_AVX2(...) #endif #ifdef ONEDAL_CPU_DISPATCH_SSE42 -#define INSTANTIATE_SSE42(...) EXPAND(INSTANTIATE_CPU(sse42, __VA_ARGS__)) +#define INSTANTIATE_SSE42(...) DAL_EXPAND(INSTANTIATE_CPU(sse42, __VA_ARGS__)) #else #define INSTANTIATE_SSE42(...) #endif #ifdef ONEDAL_CPU_DISPATCH_RV64 -#define INSTANTIATE_RV64(...) EXPAND(INSTANTIATE_CPU(rv64, __VA_ARGS__)) +#define INSTANTIATE_RV64(...) DAL_EXPAND(INSTANTIATE_CPU(rv64, __VA_ARGS__)) #else #define INSTANTIATE_RV64(...) #endif -#define INSTANTIATE_SSE2(...) EXPAND(INSTANTIATE_CPU(sse2, __VA_ARGS__)) +#define INSTANTIATE_SSE2(...) DAL_EXPAND(INSTANTIATE_CPU(sse2, __VA_ARGS__)) #if defined(TARGET_X86_64) #define INSTANTIATE_FLOAT(name, Float, argdecl) \ diff --git a/cpp/oneapi/dal/backend/primitives/lapack/test/eigen.cpp b/cpp/oneapi/dal/backend/primitives/lapack/test/eigen.cpp index 663cc3caddd..6a6a0b44bbc 100644 --- a/cpp/oneapi/dal/backend/primitives/lapack/test/eigen.cpp +++ b/cpp/oneapi/dal/backend/primitives/lapack/test/eigen.cpp @@ -132,8 +132,10 @@ class sym_eigvals_test { static constexpr int seed_ = 7777; }; +using eigen_types = COMBINE_TYPES((float, double)); + #define SYM_EIGVALS_TEST(name) \ - TEMPLATE_TEST_M(sym_eigvals_test, name, "[sym_eigvals]", float, double) + TEMPLATE_LIST_TEST_M(sym_eigvals_test, name, "[sym_eigvals]", eigen_types) SYM_EIGVALS_TEST("check inplace sym_eigvals on symmetric positive-definite matrix") { const auto s = this->generate_symmetric_positive(); diff --git a/cpp/oneapi/dal/backend/primitives/optimizers/test/cg_solver_dpc.cpp b/cpp/oneapi/dal/backend/primitives/optimizers/test/cg_solver_dpc.cpp index 4989f0ca1fc..ea320f690a2 100644 --- a/cpp/oneapi/dal/backend/primitives/optimizers/test/cg_solver_dpc.cpp +++ b/cpp/oneapi/dal/backend/primitives/optimizers/test/cg_solver_dpc.cpp @@ -108,14 +108,13 @@ class cg_solver_test : public te::float_algo_fixture { ndarray b_host_; }; -TEMPLATE_TEST_M(cg_solver_test, "test with stable matrix - double", "[cg-solver][gpu]", double) { - SKIP_IF(this->not_float64_friendly()); - SKIP_IF(this->get_policy().is_cpu()); - this->gen_input(); - this->test_cg_solver(); -} +using cg_solver_types = COMBINE_TYPES((float, double)); -TEMPLATE_TEST_M(cg_solver_test, "test with stable matrix - float", "[cg-solver][gpu]", float) { +TEMPLATE_LIST_TEST_M(cg_solver_test, + "test with stable matrix", + "[cg-solver][gpu]", + cg_solver_types) { + SKIP_IF(this->not_float64_friendly()); SKIP_IF(this->get_policy().is_cpu()); this->gen_input(); this->test_cg_solver(); diff --git a/cpp/oneapi/dal/backend/primitives/optimizers/test/newton_cg_dpc.cpp b/cpp/oneapi/dal/backend/primitives/optimizers/test/newton_cg_dpc.cpp index 62dd0140e28..f473dddf1f7 100644 --- a/cpp/oneapi/dal/backend/primitives/optimizers/test/newton_cg_dpc.cpp +++ b/cpp/oneapi/dal/backend/primitives/optimizers/test/newton_cg_dpc.cpp @@ -219,38 +219,22 @@ class newton_cg_test : public te::float_algo_fixture { ndarray b_; }; -TEMPLATE_TEST_M(newton_cg_test, - "test newton-cg with stable matrix - float", - "[newton-cg][gpu]", - float) { - SKIP_IF(this->get_policy().is_cpu()); - this->gen_and_test_quadratic_function(); - this->test_newton_cg(); -} +using newton_cg_types = COMBINE_TYPES((float, double)); -TEMPLATE_TEST_M(newton_cg_test, - "test newton-cg with stable matrix - double", - "[newton-cg][gpu]", - double) { +TEMPLATE_LIST_TEST_M(newton_cg_test, + "test newton-cg with stable matrix", + "[newton-cg][gpu]", + newton_cg_types) { SKIP_IF(this->not_float64_friendly()); SKIP_IF(this->get_policy().is_cpu()); this->gen_and_test_quadratic_function(); this->test_newton_cg(); } -TEMPLATE_TEST_M(newton_cg_test, - "test newton-cg with logloss function - double", - "[newton-cg][gpu]", - double) { - SKIP_IF(this->not_float64_friendly()); - SKIP_IF(this->get_policy().is_cpu()); - this->gen_and_test_logistic_loss(); -} - -TEMPLATE_TEST_M(newton_cg_test, - "test newton-cg with logloss function - float", - "[newton-cg][gpu]", - float) { +TEMPLATE_LIST_TEST_M(newton_cg_test, + "test newton-cg with logloss function", + "[newton-cg][gpu]", + newton_cg_types) { SKIP_IF(this->not_float64_friendly()); SKIP_IF(this->get_policy().is_cpu()); this->gen_and_test_logistic_loss(); diff --git a/cpp/oneapi/dal/backend/primitives/sort/test/sort_dpc.cpp b/cpp/oneapi/dal/backend/primitives/sort/test/sort_dpc.cpp index 02fd315712d..8875f828975 100644 --- a/cpp/oneapi/dal/backend/primitives/sort/test/sort_dpc.cpp +++ b/cpp/oneapi/dal/backend/primitives/sort/test/sort_dpc.cpp @@ -209,7 +209,9 @@ TEMPLATE_LIST_TEST_M(sort_with_indices_test, this->check_sort(val, ind); } -TEMPLATE_TEST_M(sort_test, "basic sort", "[sort]", std::int32_t, std::uint32_t) { +using sort_indices_types_int = COMBINE_TYPES((std::int32_t, std::uint32_t)); + +TEMPLATE_LIST_TEST_M(sort_test, "basic sort", "[sort]", sort_indices_types_int) { SKIP_IF(this->get_policy().is_cpu()); std::int64_t vector_count = GENERATE_COPY(1, 128); diff --git a/cpp/oneapi/dal/backend/primitives/stat/test/cov_dpc.cpp b/cpp/oneapi/dal/backend/primitives/stat/test/cov_dpc.cpp index f39d21251c3..0f0bb8e99dd 100644 --- a/cpp/oneapi/dal/backend/primitives/stat/test/cov_dpc.cpp +++ b/cpp/oneapi/dal/backend/primitives/stat/test/cov_dpc.cpp @@ -211,7 +211,9 @@ class cov_test : public te::float_algo_fixture { } }; -TEMPLATE_TEST_M(cov_test, "correlation on diagonal data", "[cor]", float, double) { +using cov_types = COMBINE_TYPES((float, double)); + +TEMPLATE_LIST_TEST_M(cov_test, "correlation on diagonal data", "[cor]", cov_types) { using float_t = TestType; using dim2_t = std::tuple; @@ -285,7 +287,9 @@ TEMPLATE_TEST_M(cov_test, "correlation on diagonal data", "[cor]", float, double } } -TEMPLATE_TEST_M(cov_test, "correlation on one-row table", "[cor]", float) { +using cov_types_one_row = COMBINE_TYPES((float)); + +TEMPLATE_LIST_TEST_M(cov_test, "correlation on one-row table", "[cor]", cov_types_one_row) { using float_t = TestType; // DPC++ GEMM used underneath correlation is not supported on GPU SKIP_IF(this->get_policy().is_cpu()); @@ -327,7 +331,8 @@ TEMPLATE_TEST_M(cov_test, "correlation on one-row table", "[cor]", float) { var_event.wait_and_throw(); this->check_constant_variance(vars, 1, 0.0); } -TEMPLATE_TEST_M(cov_test, "correlation on gold data", "[cor]", float, double) { + +TEMPLATE_LIST_TEST_M(cov_test, "correlation on gold data", "[cor]", cov_types) { using float_t = TestType; SKIP_IF(this->get_policy().is_cpu()); SKIP_IF(this->not_float64_friendly()); diff --git a/cpp/oneapi/dal/backend/primitives/test/ndarray.cpp b/cpp/oneapi/dal/backend/primitives/test/ndarray.cpp index 117b4f7a95a..6b3b56f6808 100644 --- a/cpp/oneapi/dal/backend/primitives/test/ndarray.cpp +++ b/cpp/oneapi/dal/backend/primitives/test/ndarray.cpp @@ -23,7 +23,9 @@ namespace oneapi::dal::backend::primitives::test { namespace la = dal::test::engine::linalg; -#define ENUMERATE_AXIS_COUNT_123 ((std::int64_t axis_count), axis_count), 1, 2, 3 +#define ENUMERATE_AXIS_COUNT_123 \ + ((typename T, std::int64_t axis_count), T, axis_count), (std::int64_t, 1), (std::int64_t, 2), \ + (std::int64_t, 3) class ndarray_test { public: @@ -139,7 +141,6 @@ TEST("ndarray has correct default strides in f-order", "[ndarray_base]") { TEMPLATE_SIG_TEST("can create empty ndview", "[ndview]", ENUMERATE_AXIS_COUNT_123) { const auto x = ndview{}; - REQUIRE(x.has_data() == false); REQUIRE(x.get_count() == 0); REQUIRE(x.get_data() == nullptr); diff --git a/cpp/oneapi/dal/table/test/homogen_serialization.cpp b/cpp/oneapi/dal/table/test/homogen_serialization.cpp index 8cb1131a5c8..08fd18e6f6a 100644 --- a/cpp/oneapi/dal/table/test/homogen_serialization.cpp +++ b/cpp/oneapi/dal/table/test/homogen_serialization.cpp @@ -130,12 +130,12 @@ TEST_M(empty_homogen_table_serialization_test, "serialize/deserialize empty homo check_table_serialization(empty_table); } -TEMPLATE_TEST_M(homogen_table_serialization_test, - "serialize/deserialize host homogen table", - "[host]", - float, - double, - std::int32_t) { +using homogen_table_types = COMBINE_TYPES((float, double, std::int32_t)); + +TEMPLATE_LIST_TEST_M(homogen_table_serialization_test, + "serialize/deserialize host homogen table", + "[host]", + homogen_table_types) { const std::int64_t row_count = GENERATE(1, 10, 1000); const std::int64_t column_count = GENERATE(1, 10, 100); const homogen_table original = this->get_host_backed_table(row_count, column_count); @@ -144,12 +144,10 @@ TEMPLATE_TEST_M(homogen_table_serialization_test, } #ifdef ONEDAL_DATA_PARALLEL -TEMPLATE_TEST_M(homogen_table_serialization_test, - "serialize/deserialize device homogen table", - "[host]", - float, - double, - std::int32_t) { +TEMPLATE_LIST_TEST_M(homogen_table_serialization_test, + "serialize/deserialize device homogen table", + "[host]", + homogen_table_types) { const std::int64_t row_count = GENERATE(1, 10, 1000); const std::int64_t column_count = GENERATE(1, 10, 100); const homogen_table original = this->get_device_backed_table(row_count, column_count); diff --git a/cpp/oneapi/dal/test/archives.cpp b/cpp/oneapi/dal/test/archives.cpp index 73262b3c613..745e82ec605 100644 --- a/cpp/oneapi/dal/test/archives.cpp +++ b/cpp/oneapi/dal/test/archives.cpp @@ -18,17 +18,16 @@ #include "oneapi/dal/detail/array_utils.hpp" #include "oneapi/dal/detail/archives.hpp" #include "oneapi/dal/test/engine/common.hpp" +#include "oneapi/dal/test/engine/fixtures.hpp" #include "oneapi/dal/test/engine/serialization.hpp" namespace oneapi::dal::test { namespace te = dal::test::engine; -TEMPLATE_TEST("can write to binary_ouput_archive", - "[binary_ouput_archive]", - float, - double, - std::int32_t) { +using archives_types = std::tuple; + +TEMPLATE_LIST_TEST("can write to binary_ouput_archive", "[binary_ouput_archive]", archives_types) { detail::binary_output_archive archive; SECTION("single value") { @@ -57,11 +56,7 @@ TEMPLATE_TEST("can write to binary_ouput_archive", } } -TEMPLATE_TEST("can read from binary_input_archive", - "[binary_input_archive]", - float, - double, - std::int32_t) { +TEMPLATE_LIST_TEST("can read from binary_input_archive", "[binary_input_archive]", archives_types) { SECTION("singe value") { const TestType original = TestType(3.14); @@ -95,11 +90,7 @@ TEMPLATE_TEST("can read from binary_input_archive", } } -TEMPLATE_TEST("serialize/deserialize array to binary archive", - "[array]", - float, - double, - std::int32_t) { +TEMPLATE_LIST_TEST("serialize/deserialize array to binary archive", "[array]", archives_types) { const std::int64_t count = 100; const auto original = array::empty(count); for (std::int64_t i = 0; i < count; i++) { @@ -123,7 +114,9 @@ TEMPLATE_TEST("serialize/deserialize array to binary archive", } } -TEST("binary_input_archive throws if truncated data buffer is provided", "[binary_input_archive]") { +TEMPLATE_LIST_TEST("binary_input_archive throws if truncated data buffer is provided", + "[binary_input_archive]", + archives_types) { const std::int64_t count = 100; const auto original = array::empty(count); for (std::int64_t i = 0; i < count; i++) { diff --git a/cpp/oneapi/dal/test/array_serialization.cpp b/cpp/oneapi/dal/test/array_serialization.cpp index df379a7eba9..b16e841bc41 100644 --- a/cpp/oneapi/dal/test/array_serialization.cpp +++ b/cpp/oneapi/dal/test/array_serialization.cpp @@ -26,7 +26,7 @@ namespace te = dal::test::engine; namespace la = te::linalg; template -class array_serialization_test : te::policy_fixture { +class array_serialization_test : te::algo_fixture { public: array get_empty_array() { return array{}; @@ -110,11 +110,12 @@ TEMPLATE_LIST_TEST_M(array_serialization_test, } #endif -TEMPLATE_TEST_M(array_serialization_test, - "deserialize array to wrong type", - "[badarg]", - float, - double) { +using array_types_float = std::tuple; + +TEMPLATE_LIST_TEST_M(array_serialization_test, + "deserialize array to wrong type", + "[badarg]", + array_types_float) { const std::int64_t count = 10; const auto host_array = this->get_host_backed_array(count); diff --git a/makefile b/makefile index e70d8e002a5..d4d3ee6bc55 100644 --- a/makefile +++ b/makefile @@ -283,16 +283,6 @@ mklgpufpk.HEADERS := $(MKLGPUFPKDIR.include)/mkl_dal_sycl.hpp $(MKLGPUFPKDIR.inc include dev/make/deps.$(BACKEND_CONFIG).mk -#============================= oneAPI folders ===================================== -ifeq ($(if $(or $(OS_is_lnx),$(OS_is_win)),yes,),yes) -ONEAPIDIR := $(call topf,$$ONEAPI_ROOT) -ONEAPIDIR := $(if $(wildcard $(ONEAPIDIR)/compiler/latest),$(ONEAPIDIR)/compiler/latest,$(info ONEAPI_ROOT not defined)) -ONEAPIDIR.libia.prefix := $(if $(ONEAPIDIR),$(ONEAPIDIR)/$(if $(OS_is_win),windows,linux)/lib) - -libsycl := $(if $(OS_is_win),$(notdir $(wildcard $(ONEAPIDIR.libia.prefix)/sycl$d.lib $(ONEAPIDIR.libia.prefix)/sycl[0-9]$d.lib $(ONEAPIDIR.libia.prefix)/sycl[0-9][0-9]$d.lib))) -libsycl.default = sycl7$d.lib -endif - #=============================================================================== # Release library names #=============================================================================== @@ -780,7 +770,7 @@ $(WORKDIR.lib)/$(oneapi_y.dpc): LOPT += $(daaldep.rt.dpc) $(WORKDIR.lib)/$(oneapi_y.dpc): LOPT += $(if $(REQDBG),-flink-huge-device-code,) $(WORKDIR.lib)/$(oneapi_y.dpc): LOPT += $(if $(OS_is_win),-IMPLIB:$(@:%.$(MAJORBINARY).dll=%_dll.lib),) $(WORKDIR.lib)/$(oneapi_y.dpc): LOPT += $(if $(OS_is_win),$(WORKDIR.lib)/$(core_y:%.$(MAJORBINARY).dll=%_dll.lib)) -$(WORKDIR.lib)/$(oneapi_y.dpc): LOPT += $(if $(OS_is_win), $(if $(libsycl),$(libsycl),$(libsycl.default)) OpenCL.lib) +$(WORKDIR.lib)/$(oneapi_y.dpc): LOPT += $(if $(OS_is_win),sycl$d.lib OpenCL.lib) $(WORKDIR.lib)/$(oneapi_y.dpc): LOPT += $(mklgpufpk.LIBS_A) ifdef OS_is_win $(WORKDIR.lib)/$(oneapi_y.dpc:%.$(MAJORBINARY).dll=%_dll.lib): $(WORKDIR.lib)/$(oneapi_y.dpc)