diff --git a/INSTALL.md b/INSTALL.md index c795d1c6f3c..38f798441b0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -78,7 +78,7 @@ is available as an alternative to the manual setup. 4. Set up MKL: _Note: if you used the general oneAPI setvars script from a Base Toolkit installation, this step will not be necessary as oneMKL will already have been set up._ - + Download and install [Intel(R) oneMKL](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html). Set the environment variables for for Intel(R) oneMKL. For example: @@ -149,7 +149,15 @@ It is possible to build oneDAL libraries with selected set of algorithms and/or make -f makefile daal PLAT=win32e CORE.ALGORITHMS.CUSTOM=low_order_moments REQCPU=avx2 -j16 +On **Linux\*** it is possible to build debug version of oneDAL or the version that allows to do kernel profiling using . + +- To build debug version of oneDAL, run: + + make -f makefile daal oneapi_c PLAT=lnx32e REQDBG=yes + +- To build oneDAL with kernel profiling information, run: + make -f makefile daal oneapi_c PLAT=lnx32e REQPROFILE=yes --- **NOTE:** Built libraries are located in the `__release_{os_name}[_{compiler_name}]/daal` directory. diff --git a/cpp/daal/src/externals/service_profiler.h b/cpp/daal/src/externals/service_profiler.h index e1e44e5283c..fd7f24f65d1 100755 --- a/cpp/daal/src/externals/service_profiler.h +++ b/cpp/daal/src/externals/service_profiler.h @@ -24,9 +24,8 @@ #ifndef __SERVICE_PROFILER_H__ #define __SERVICE_PROFILER_H__ -// #define ONEDAL_KERNEL_PROFILER - #ifdef ONEDAL_KERNEL_PROFILER +/* Here if oneDAL kernel profiling is enabled in the build */ #include #endif @@ -36,47 +35,83 @@ #define DAAL_ITTNOTIFY_UNIQUE_ID __LINE__ #define DAAL_ITTNOTIFY_SCOPED_TASK(name) \ - daal::internal::ProfilerTask DAAL_ITTNOTIFY_CONCAT(__profiler_taks__, DAAL_ITTNOTIFY_UNIQUE_ID) = daal::internal::Profiler::startTask(#name); + daal::internal::ProfilerTask DAAL_ITTNOTIFY_CONCAT(__profiler_task__, DAAL_ITTNOTIFY_UNIQUE_ID) = daal::internal::Profiler::startTask(#name); namespace daal { namespace internal { +/** + * Defines a logical unit of work to be tracked by performance profilier. + */ class ProfilerTask { public: + /** + * Constructs a task with a given name. + * \param[in] taskName Name of the task. + */ ProfilerTask(const char * taskName); ~ProfilerTask(); private: const char * _taskName; #ifdef ONEDAL_KERNEL_PROFILER - __itt_string_handle* _handle; - __itt_domain* _domain; + /* Here if oneDAL kernel profiling is enabled */ + __itt_string_handle * _handle; /* The task string handle */ + __itt_domain * _domain; /* Pointer to the domain of the task */ #endif }; -// This class is a stub in the library. Its redefinition will be in Bechmarks +/** + * Global performance profiler. + * + * By default this class is a stub in the library and its redefinition will be in C++ Bechmarks. + * If oneDAL kernel profiling is enabled, the profiler uses Task API from + */ class Profiler { public: + /** + * Start the task to be profiled. + * \param[in] taskName Name of the task. + */ static ProfilerTask startTask(const char * taskName); + + /** + * Start the task to profile. + * \param[in] taskName Name of the task. + */ static void endTask(const char * taskName); + #ifdef ONEDAL_KERNEL_PROFILER + /* Here if oneDAL kernel profiling is enabled */ + + /** + * Get pointer to a global profiler state. + * \return Pointer to a global profiler state. + */ static Profiler* getInstance() { static Profiler instance; return &instance; } - static __itt_domain* getDomain() { + /** + * Get pointer to the ITT domain associated with the profiler. + * \return Pointer to the ITT domain. + */ + static __itt_domain * getDomain() { return (getInstance())->_domain; } private: + /** + * Construct the profiler. + */ Profiler() { _domain = __itt_domain_create("oneDAL"); } ~Profiler() {} - __itt_domain* _domain; + __itt_domain * _domain; /* Pointer to the ITT domain */ #endif }; diff --git a/makefile b/makefile index a02d9292fcb..3fb0e58280b 100644 --- a/makefile +++ b/makefile @@ -306,15 +306,12 @@ include dev/make/deps.$(BACKEND_CONFIG).mk #=============================== VTune SDK folders ====================================== ifeq ($(REQPROFILE), yes) + -DPROFILER := -DONEDAL_KERNEL_PROFILER VTUNESDK.include := $(VTUNE_PROFILER_DIR)/sdk/include - VTUNESDK.libia := $(if $(OS_is_lnx), $(VTUNE_PROFILER_DIR)/sdk/lib64,) - VTUNESDK.LIBS_A := $(if $(OS_is_lnx), $(VTUNESDK.libia)/libittnotify.a,) endif -$(info VTUNESDK: $(VTUNESDK.include)) - #=============================================================================== # Release library names #=============================================================================== @@ -506,7 +503,7 @@ $(WORKDIR.lib)/$(core_y): $(daaldep.math_backend.ext) $(VTUNES $(CORE.tmpdir_y)/$(core_y:%.$y=%_link.txt) ; $(LINK.DYNAMIC) ; $(LINK.DYNAMIC.POST) $(CORE.objs_a): $(CORE.tmpdir_a)/inc_a_folders.txt -$(CORE.objs_a): COPT += $(-fPIC) $(-cxx17) $(-Zl) $(-DEBC) $(-DMKL_ILP64) +$(CORE.objs_a): COPT += $(-fPIC) $(-cxx17) $(-Zl) $(-DEBC) $(-DMKL_ILP64) $(-DPROFILER) $(CORE.objs_a): COPT += -D__TBB_NO_IMPLICIT_LINKAGE -DDAAL_NOTHROW_EXCEPTIONS \ -DDAAL_HIDE_DEPRECATED -DTBB_USE_ASSERT=0 -D_ENABLE_ATOMIC_ALIGNMENT_FIX \ $(if $(CHECK_DLL_SIG),-DDAAL_CHECK_DLL_SIG) @@ -515,7 +512,7 @@ $(CORE.objs_a): COPT += @$(CORE.tmpdir_a)/inc_a_folders.txt $(eval $(call append_uarch_copt,$(CORE.objs_a))) $(CORE.objs_y): $(CORE.tmpdir_y)/inc_y_folders.txt -$(CORE.objs_y): COPT += $(-fPIC) $(-cxx17) $(-Zl) $(-DEBC) $(-DMKL_ILP64) +$(CORE.objs_y): COPT += $(-fPIC) $(-cxx17) $(-Zl) $(-DEBC) $(-DMKL_ILP64) $(-DPROFILER) $(CORE.objs_y): COPT += -D__DAAL_IMPLEMENTATION \ -D__TBB_NO_IMPLICIT_LINKAGE -DDAAL_NOTHROW_EXCEPTIONS \ -DDAAL_HIDE_DEPRECATED -DTBB_USE_ASSERT=0 -D_ENABLE_ATOMIC_ALIGNMENT_FIX \ @@ -1117,7 +1114,8 @@ Flags: possible values: $(CORE.ALGORITHMS.CUSTOM.AVAILABLE) REQCPU - list of CPU optimizations to be included into library possible values: $(CPUs) - REQDBG - Flag that enables build in debug mode + REQDBG - flag that enables build in debug mode + REQPROFILE - flag that enables kernel profiling using endef daal_dbg: