Skip to content

Commit

Permalink
fixes for rbf
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr-Solovev committed Aug 27, 2024
1 parent bc2a3aa commit 1bc4221
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 87 deletions.
128 changes: 64 additions & 64 deletions cpp/daal/src/externals/core_threading_win_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,68 +794,68 @@ DAAL_EXPORT void * _getThreadPinner(bool create_pinner, void (*read_topo)(int &,
#endif

#define CALL_VOID_FUNC_FROM_DLL(fn_dpref, fn_name, argdecl, argcall) \
typedef void(*##fn_dpref##fn_name##_t)##argdecl; \
static fn_dpref##fn_name##_t fn_dpref##fn_name##_ptr = NULL; \
typedef void(*##fn_name##_t)##argdecl; \
static fn_name##_t fn_dpref##fn_name##_ptr = NULL; \
CALL_VOID_FUNC_FROM_DLL_CPU(fn_dpref, avx512_, fn_name, argdecl, argcall) \
CALL_VOID_FUNC_FROM_DLL_CPU(fn_dpref, avx2_, fn_name, argdecl, argcall) \
CALL_VOID_FUNC_FROM_DLL_CPU(fn_dpref, sse42_, fn_name, argdecl, argcall) \
CALL_VOID_FUNC_FROM_DLL_CPU(fn_dpref, sse2_, fn_name, argdecl, argcall)

#define CALL_VOID_FUNC_FROM_DLL_CPU(fn_dpref, fn_cpu, fn_name, argdecl, argcall) \
extern "C" DAAL_EXPORT void fn_dpref##fn_cpu##fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_dpref##fn_name##_ptr == NULL) \
{ \
##fn_dpref##fn_name##_ptr = (##fn_dpref##fn_name##_t)load_daal_thr_func(#fn_dpref #fn_cpu #fn_name); \
} \
##fn_dpref##fn_name##_ptr##argcall; \
#define CALL_VOID_FUNC_FROM_DLL_CPU(fn_dpref, fn_cpu, fn_name, argdecl, argcall) \
extern "C" DAAL_EXPORT void fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_name##_ptr == NULL) \
{ \
##fn_name##_ptr = (##fn_name##_t)load_daal_thr_func(#fn_name); \
} \
##fn_name##_ptr##argcall; \
}

#if defined(_WIN64)
#define CALL_VOID_FUNC_FROM_DLL_CPU_MIC(fn_dpref, fn_cpu, fn_name, argdecl, argcall) \
extern "C" DAAL_EXPORT void fn_dpref##fn_cpu##fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_dpref##fn_name##_ptr == NULL) \
{ \
##fn_dpref##fn_name##_ptr = (##fn_dpref##fn_name##_t)load_daal_thr_func(#fn_dpref #fn_cpu #fn_name); \
} \
##fn_dpref##fn_name##_ptr##argcall; \
#define CALL_VOID_FUNC_FROM_DLL_CPU_MIC(fn_dpref, fn_cpu, fn_name, argdecl, argcall) \
extern "C" DAAL_EXPORT void##fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_name##_ptr == NULL) \
{ \
##fn_name##_ptr = (##fn_name##_t)load_daal_thr_func(#fn_name); \
} \
##fn_name##_ptr##argcall; \
}
#else
#define CALL_VOID_FUNC_FROM_DLL_CPU_MIC(fn_dpref, fn_cpu, fn_name, argdecl, argcall)
#endif

#define CALL_RET_FUNC_FROM_DLL(ret_type, fn_dpref, fn_name, argdecl, argcall) \
typedef ret_type(*##fn_dpref##fn_name##_t)##argdecl; \
static fn_dpref##fn_name##_t fn_dpref##fn_name##_ptr = NULL; \
typedef ret_type(*##fn_name##_t)##argdecl; \
static fn_name##_t fn_name##_ptr = NULL; \
CALL_RET_FUNC_FROM_DLL_CPU(ret_type, fn_dpref, avx512_, fn_name, argdecl, argcall) \
CALL_RET_FUNC_FROM_DLL_CPU(ret_type, fn_dpref, avx2_, fn_name, argdecl, argcall) \
CALL_RET_FUNC_FROM_DLL_CPU(ret_type, fn_dpref, sse42_, fn_name, argdecl, argcall) \
CALL_RET_FUNC_FROM_DLL_CPU(ret_type, fn_dpref, sse2_, fn_name, argdecl, argcall)

#define CALL_RET_FUNC_FROM_DLL_CPU(ret_type, fn_dpref, fn_cpu, fn_name, argdecl, argcall) \
extern "C" DAAL_EXPORT ret_type fn_dpref##fn_cpu##fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_dpref##fn_name##_ptr == NULL) \
{ \
##fn_dpref##fn_name##_ptr = (##fn_dpref##fn_name##_t)load_daal_thr_func(#fn_dpref #fn_cpu #fn_name); \
} \
return fn_dpref##fn_name##_ptr##argcall; \
#define CALL_RET_FUNC_FROM_DLL_CPU(ret_type, fn_dpref, fn_cpu, fn_name, argdecl, argcall) \
extern "C" DAAL_EXPORT ret_type fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_name##_ptr == NULL) \
{ \
##fn_name##_ptr = (##fn_name##_t)load_daal_thr_func(#fn_name); \
} \
return fn_name##_ptr##argcall; \
}

#if defined(_WIN64)
#define CALL_RET_FUNC_FROM_DLL_CPU_MIC(ret_type, fn_dpref, fn_cpu, fn_name, argdecl, argcall) \
extern "C" DAAL_EXPORT ret_type fn_dpref##fn_cpu##fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_dpref##fn_name##_ptr == NULL) \
{ \
##fn_dpref##fn_name##_ptr = (##fn_dpref##fn_name##_t)load_daal_thr_func(#fn_dpref #fn_cpu #fn_name); \
} \
return fn_dpref##fn_name##_ptr##argcall; \
#define CALL_RET_FUNC_FROM_DLL_CPU_MIC(ret_type, fn_dpref, fn_cpu, fn_name, argdecl, argcall) \
extern "C" DAAL_EXPORT ret_type fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_name##_ptr == NULL) \
{ \
##fn_name##_ptr = (##fn_name##_t)load_daal_thr_func(#fn_name); \
} \
return fn_name##_ptr##argcall; \
}
#else
#define CALL_RET_FUNC_FROM_DLL_CPU_MIC(ret_type, fn_dpref, fn_cpu, fn_name, argdecl, argcall)
Expand Down Expand Up @@ -1137,30 +1137,30 @@ typedef double Ipp64f;
CALL_RET_FUNC_FROM_DLL(IppStatus, fpk_dft_, ippsSortRadixAscend_64f_I, (Ipp64f * pSrcDst, Ipp64f * pTmp, Ipp32s len), (pSrcDst, pTmp, len));
CALL_RET_FUNC_FROM_DLL(IppStatus, fpk_dft_, ippsSortRadixAscend_32f_I, (Ipp32f * pSrcDst, Ipp32f * pTmp, Ipp32s len), (pSrcDst, pTmp, len));

#define CALL_VOID_FUNC_FROM_DLL_ALONE(fn_dpref, fn_name, argdecl, argcall) \
typedef void(*##fn_dpref##fn_name##_t)##argdecl; \
static fn_dpref##fn_name##_t fn_dpref##fn_name##_ptr = NULL; \
extern "C" DAAL_EXPORT void fn_dpref##fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_dpref##fn_name##_ptr == NULL) \
{ \
##fn_dpref##fn_name##_ptr = (##fn_dpref##fn_name##_t)load_daal_thr_func(#fn_dpref #fn_name); \
} \
##fn_dpref##fn_name##_ptr##argcall; \
}

#define CALL_RET_FUNC_FROM_DLL_ALONE(ret_type, fn_dpref, fn_name, argdecl, argcall) \
typedef ret_type(*##fn_dpref##fn_name##_t)##argdecl; \
static fn_dpref##fn_name##_t fn_dpref##fn_name##_ptr = NULL; \
extern "C" DAAL_EXPORT ret_type fn_dpref##fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_dpref##fn_name##_ptr == NULL) \
{ \
##fn_dpref##fn_name##_ptr = (##fn_dpref##fn_name##_t)load_daal_thr_func(#fn_dpref #fn_name); \
} \
return fn_dpref##fn_name##_ptr##argcall; \
#define CALL_VOID_FUNC_FROM_DLL_ALONE(fn_dpref, fn_name, argdecl, argcall) \
typedef void(*##fn_name##_t)##argdecl; \
static fn_name##_t fn_name##_ptr = NULL; \
extern "C" DAAL_EXPORT void fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_name##_ptr == NULL) \
{ \
##fn_name##_ptr = (##fn_name##_t)load_daal_thr_func(#fn_name); \
} \
##fn_name##_ptr##argcall; \
}

#define CALL_RET_FUNC_FROM_DLL_ALONE(ret_type, fn_dpref, fn_name, argdecl, argcall) \
typedef ret_type(*##fn_name##_t)##argdecl; \
static fn_name##_t ffn_name##_ptr = NULL; \
extern "C" DAAL_EXPORT ret_type fn_name##argdecl \
{ \
load_daal_thr_dll(); \
if (##fn_name##_ptr == NULL) \
{ \
##fn_name##_ptr = (##fn_name##_t)load_daal_thr_func(#fn_name); \
} \
return fn_name##_ptr##argcall; \
}

CALL_VOID_FUNC_FROM_DLL_ALONE(fpk_serv_, set_num_threads, (int nth), (nth));
Expand Down
48 changes: 25 additions & 23 deletions cpp/daal/src/externals/service_blas_mkl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
#define __DAAL_CONCAT51(a, b, c, d, e) a##b##c##d##e
#endif

#define __DAAL_MKLFN(f_cpu, f_pref, f_name) f_name
#define __DAAL_MKLFN_CALL(f_pref, f_name, f_args) __DAAL_MKLFN_CALL1(f_pref, f_name, f_args)
#define __DAAL_MKLFN_CALL_RETURN(f_pref, f_name, f_args) __DAAL_MKLFN_CALL2(f_pref, f_name, f_args)
#define __DAAL_MKLFN(f_cpu, f_pref, f_name) f_name
#define __DAAL_MKLFN_CALL(f_pref, f_name, f_args) __DAAL_MKLFN_CALL1(f_pref, f_name, f_args)
#define __DAAL_MKLFN_CALL_RETURN_BLAS(f_pref, f_name, f_args, res) __DAAL_MKLFN_CALL2_BLAS(f_pref, f_name, f_args, res)

#define __DAAL_MKLFN_CALL1(f_pref, f_name, f_args) \
if (avx512 == cpu) \
Expand All @@ -59,22 +59,22 @@
__DAAL_MKLFN(__DAAL_MKL_SSE2, f_pref, f_name) f_args; \
}

#define __DAAL_MKLFN_CALL2(f_pref, f_name, f_args) \
if (avx512 == cpu) \
{ \
return __DAAL_MKLFN(avx512_, f_pref, f_name) f_args; \
} \
if (avx2 == cpu) \
{ \
return __DAAL_MKLFN(avx2_, f_pref, f_name) f_args; \
} \
if (sse42 == cpu) \
{ \
return __DAAL_MKLFN(__DAAL_MKL_SSE42, f_pref, f_name) f_args; \
} \
if (sse2 == cpu) \
{ \
return __DAAL_MKLFN(__DAAL_MKL_SSE2, f_pref, f_name) f_args; \
#define __DAAL_MKLFN_CALL2_BLAS(f_pref, f_name, f_args, res) \
if (avx512 == cpu) \
{ \
res = __DAAL_MKLFN(avx512_, f_pref, f_name) f_args; \
} \
if (avx2 == cpu) \
{ \
res = __DAAL_MKLFN(avx2_, f_pref, f_name) f_args; \
} \
if (sse42 == cpu) \
{ \
res = __DAAL_MKLFN(__DAAL_MKL_SSE42, f_pref, f_name) f_args; \
} \
if (sse2 == cpu) \
{ \
res = __DAAL_MKLFN(__DAAL_MKL_SSE2, f_pref, f_name) f_args; \
}

namespace daal
Expand Down Expand Up @@ -189,9 +189,10 @@ struct MklBlas<double, cpu>
static double xxdot(const DAAL_INT * n, const double * x, const DAAL_INT * incx, const double * y, const DAAL_INT * incy)
{
int old_nthr = mkl_set_num_threads_local(1);
__DAAL_MKLFN_CALL_RETURN(blas_, ddot, ((MKL_INT *)n, x, (MKL_INT *)incx, y, (MKL_INT *)incy));
double res;
__DAAL_MKLFN_CALL_RETURN_BLAS(blas_, ddot, ((MKL_INT *)n, x, (MKL_INT *)incx, y, (MKL_INT *)incy), res);
mkl_set_num_threads_local(old_nthr);
return 0;
return res;
}
};

Expand Down Expand Up @@ -297,9 +298,10 @@ struct MklBlas<float, cpu>
static float xxdot(const DAAL_INT * n, const float * x, const DAAL_INT * incx, const float * y, const DAAL_INT * incy)
{
int old_nthr = mkl_set_num_threads_local(1);
__DAAL_MKLFN_CALL_RETURN(blas_, sdot, ((MKL_INT *)n, x, (MKL_INT *)incx, y, (MKL_INT *)incy));
float res;
__DAAL_MKLFN_CALL_RETURN_BLAS(blas_, sdot, ((MKL_INT *)n, x, (MKL_INT *)incx, y, (MKL_INT *)incy), res);
mkl_set_num_threads_local(old_nthr);
return 0;
return res;
}
};

Expand Down

0 comments on commit 1bc4221

Please sign in to comment.