Skip to content

Commit

Permalink
Implement serv_get_ht, serv_get_ncpus, serv_get_ncorespercpu function…
Browse files Browse the repository at this point in the history
… for MKL backend
  • Loading branch information
Vika-F committed Sep 23, 2024
1 parent 788cee7 commit 9cca77a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions cpp/daal/src/externals/service_service_mkl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define __SERVICE_SERVICE_MKL_H__

#include "services/daal_defines.h"
#include "src/services/service_topo.h"
#include <mkl.h>
#include <mkl_service.h>
#include <string.h>
Expand Down Expand Up @@ -61,22 +62,22 @@ struct MklService
// return memmove_s(dest, destSize, src, smax);
}

static int serv_get_ht()
static int serv_get_ncpus()
{
// TODO: real detection of hypertheading
return 0;
unsigned int ncores = daal::services::internal::_internal_daal_GetSysProcessorCoreCount();
return (ncores ? ncores : 1);
}

static int serv_get_ncpus()
static int serv_get_ncorespercpu()
{
// TODO: detection of npus
return 1;
unsigned int nlogicalcpu = daal::services::internal::_internal_daal_GetSysLogicalProcessorCount();
unsigned int ncpus = serv_get_ncpus();
return (ncpus > 0 && nlogicalcpu > 0 && nlogicalcpu > ncpus ? nlogicalcpu / ncpus : 1);
}

static int serv_get_ncorespercpu()
static int serv_get_ht()
{
// TODO: detection of ncores per cpu
return 1;
return (serv_get_ncorespercpu() > 1 ? 1 : 0);
}

// TODO: The real call should be delegated to a backend library if the option is supported
Expand Down
2 changes: 1 addition & 1 deletion cpp/daal/src/services/service_topo.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,13 @@ unsigned _internal_daal_GetLogicalProcessorCount();
unsigned _internal_daal_GetCoresPerPackageProcessorCount();
unsigned _internal_daal_GetProcessorPackageCount();
unsigned _internal_daal_GetEnumerateAPICID(unsigned processor);
unsigned _internal_daal_GetLogicalPerCoreProcessorCount();
unsigned _internal_daal_GetCoreCount(unsigned long package_ordinal);
unsigned _internal_daal_GetThreadCount(unsigned long package_ordinal, unsigned long core_ordinal);
unsigned _internal_daal_GetLogicalProcessorQueue(int * queue);
unsigned _internal_daal_GetStatus();

unsigned _internal_daal_GetSysLogicalProcessorCount();
unsigned _internal_daal_GetSysProcessorCoreCount();
} // namespace internal
} // namespace services
} // namespace daal
Expand Down

0 comments on commit 9cca77a

Please sign in to comment.