Skip to content

Commit

Permalink
minor updates + kmeans prints
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr-Solovev committed Aug 21, 2024
1 parent a6220db commit b4babe5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
13 changes: 7 additions & 6 deletions .ci/pipeline/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,13 @@ jobs:
--test_thread_mode=par
displayName: 'cpp-examples-thread-release-static'
- script: |
export DALROOT=`pwd`/bazel-bin/release/daal/latest
bazel test //examples/oneapi/cpp:all \
--test_link_mode=release_dynamic \
--test_thread_mode=par
displayName: 'cpp-examples-thread-release-dynamic'
# uncomment after bazel or other fixes
# - script: |
# export DALROOT=`pwd`/bazel-bin/release/daal/latest
# bazel test //examples/oneapi/cpp:all \
# --test_link_mode=release_dynamic \
# --test_thread_mode=par
# displayName: 'cpp-examples-thread-release-dynamic'

- script: |
bazel test //cpp/daal:tests
Expand Down
17 changes: 17 additions & 0 deletions cpp/daal/src/algorithms/kmeans/kmeans_init_impl.i
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "src/algorithms/distributions/uniform/uniform_kernel.h"
#include "src/algorithms/distributions/uniform/uniform_impl.i"
#include "src/services/service_data_utils.h"
#include <iostream>

namespace daal
{
Expand All @@ -50,6 +51,7 @@ template <Method method, typename algorithmFPType, CpuType cpu>
Status init(size_t p, size_t n, size_t nRowsTotal, size_t nClusters, algorithmFPType * clusters, NumericTable * ntData, unsigned int seed,
engines::BatchBase & engine, size_t & clustersFound)
{
std::cout << "init begin" << std::endl;
if (method == deterministicDense || method == deterministicCSR)
{
ReadRows<algorithmFPType, cpu> mtData(ntData, 0, nClusters);
Expand Down Expand Up @@ -104,6 +106,7 @@ Status init(size_t p, size_t n, size_t nRowsTotal, size_t nClusters, algorithmFP
return s;
}
DAAL_ASSERT(false && "should never happen");
std::cout << "init end" << std::endl;
return Status();
}

Expand All @@ -112,6 +115,7 @@ services::Status KMeansInitKernel<method, algorithmFPType, cpu>::compute(size_t
const NumericTable * const * r, const Parameter * par,
engines::BatchBase & engine)
{
std::cout << "compute begin" << std::endl;
NumericTable * ntData = const_cast<NumericTable *>(a[0]);
NumericTable * ntClusters = const_cast<NumericTable *>(r[0]);

Expand All @@ -123,12 +127,14 @@ services::Status KMeansInitKernel<method, algorithmFPType, cpu>::compute(size_t
algorithmFPType * clusters = clustersBD.get();

size_t clustersFound = 0;
std::cout << "compute end" << std::endl;
return init<method, algorithmFPType, cpu>(p, n, n, nClusters, clusters, ntData, par->seed, engine, clustersFound);
}

template <typename algorithmFPType, CpuType cpu>
Status initDistrDeterministic(const NumericTable * pData, const Parameter * par, size_t & nClustersFound, NumericTablePtr & pRes)
{
std::cout << "init distr begin" << std::endl;
nClustersFound = 0;
if (par->nClusters <= par->offset) return Status(); //ok

Expand All @@ -148,12 +154,14 @@ Status initDistrDeterministic(const NumericTable * pData, const Parameter * par,
DAAL_CHECK_BLOCK_STATUS(dataBD);
const size_t sz = pData->getNumberOfColumns() * nClustersFound * sizeof(algorithmFPType);
int result = daal::services::internal::daal_memcpy_s(resBD.get(), sz, dataBD.get(), sz);
std::cout << "init distr end" << std::endl;
return (!result) ? st : services::Status(services::ErrorMemoryCopyFailedInternal);
}

template <typename algorithmFPType, CpuType cpu>
Status generateRandomIndices(const Parameter * par, size_t nRows, size_t & nClustersFound, int * clusters, engines::BatchBase & engine)
{
std::cout << "gen random indicies begin" << std::endl;
DAAL_OVERFLOW_CHECK_BY_MULTIPLICATION(size_t, par->nClusters, sizeof(int));

TArray<int, cpu> aIndices(par->nClusters);
Expand Down Expand Up @@ -181,13 +189,15 @@ Status generateRandomIndices(const Parameter * par, size_t nRows, size_t & nClus
clusters[nClustersFound] = c - par->offset;
nClustersFound++;
}
std::cout << "gen random indicies end" << std::endl;
return s;
}

template <typename algorithmFPType, CpuType cpu>
Status initDistrRandom(const NumericTable * pData, const Parameter * par, size_t & nClustersFound, NumericTablePtr & pRes,
engines::BatchBase & engine)
{
std::cout << "initDistrRandom begin" << std::endl;
DAAL_OVERFLOW_CHECK_BY_MULTIPLICATION(size_t, par->nClusters, sizeof(int));

TArray<int, cpu> clusters(par->nClusters);
Expand Down Expand Up @@ -215,13 +225,15 @@ Status initDistrRandom(const NumericTable * pData, const Parameter * par, size_t
DAAL_CHECK_BLOCK_STATUS(dataBD);
for (size_t j = 0; j < p; j++) aClusters[i * p + j] = pRow[j];
}
std::cout << "initDistrRandom end" << std::endl;
return s;
}

template <typename algorithmFPType, CpuType cpu>
Status initDistrPlusPlus(const NumericTable * pData, const Parameter * par, size_t & nClustersFound, NumericTablePtr & pRes,
engines::BatchBase & engine)
{
std::cout << "initDistrPlusPlus begin" << std::endl;
nClustersFound = 0;
int index = 0;

Expand All @@ -248,6 +260,7 @@ Status initDistrPlusPlus(const NumericTable * pData, const Parameter * par, size
WriteOnlyRows<algorithmFPType, cpu> resBD(*pRes, 0, 1);
DAAL_CHECK_BLOCK_STATUS(resBD);
int result = daal::services::internal::daal_memcpy_s(resBD.get(), sizeof(algorithmFPType) * p, dataBD.get(), sizeof(algorithmFPType) * p);
std::cout << "initDistrPlusPlus end" << std::endl;
return (!result) ? s : services::Status(services::ErrorMemoryCopyFailedInternal);
}

Expand All @@ -256,6 +269,7 @@ services::Status KMeansInitStep1LocalKernel<method, algorithmFPType, cpu>::compu
NumericTable * pNumPartialClusters,
NumericTablePtr & pPartialClusters, engines::BatchBase & engine)
{
std::cout << "compute 2 begin" << std::endl;
size_t nClustersFound = 0;
services::Status s;
if ((method == deterministicDense) || (method == deterministicCSR))
Expand All @@ -271,13 +285,15 @@ services::Status KMeansInitStep1LocalKernel<method, algorithmFPType, cpu>::compu
DAAL_CHECK_BLOCK_STATUS(npcBD);
DAAL_CHECK(nClustersFound <= services::internal::MaxVal<int>::get(), ErrorIncorrectNumberOfPartialClusters)
*npcBD.get() = (int)nClustersFound;
std::cout << "compute 2 end" << std::endl;
return s;
}

template <Method method, typename algorithmFPType, CpuType cpu>
services::Status KMeansInitStep2MasterKernel<method, algorithmFPType, cpu>::finalizeCompute(size_t na, const NumericTable * const * a,
NumericTable * ntClusters, const Parameter * par)
{
std::cout << "finalizeCompute begin" << std::endl;
const size_t nBlocks = na / 2;
const size_t p = ntClusters->getNumberOfColumns();
const size_t nClusters = par->nClusters;
Expand Down Expand Up @@ -307,6 +323,7 @@ services::Status KMeansInitStep2MasterKernel<method, algorithmFPType, cpu>::fina
k++;
}
}
std::cout << "finalizeCompute begin" << std::endl;
return Status();
}

Expand Down
2 changes: 1 addition & 1 deletion dev/bazel/deps/mkl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ mkl_repo = repos.prebuilt_libs_repo_rule(
"lib/libmkl_core.a",
"lib/libmkl_intel_ilp64.a",
"lib/libmkl_sequential.a",
"lib/libmkl_sycl.a",
"lib/libmkl_tbb_thread.a",
"lib/libmkl_sycl.a",
],
build_template = "@onedal//dev/bazel/deps:mkl.tpl.BUILD",
download_mapping = {
Expand Down
6 changes: 0 additions & 6 deletions dev/bazel/deps/onedal.tpl.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ cc_library(
":headers",
"@tbb//:tbb_binary",
"@tbb//:tbbmalloc_binary",
"@mkl//:mkl_dpc",
"@mkl//:headers",
"@mkl//:mkl_seq",
],
)

Expand Down Expand Up @@ -112,9 +109,6 @@ cc_library(
":headers",
"@tbb//:tbb_binary",
"@tbb//:tbbmalloc_binary",
"@mkl//:mkl_dpc",
"@mkl//:headers",
"@mkl//:mkl_seq",
],
)

Expand Down

0 comments on commit b4babe5

Please sign in to comment.