Skip to content

Commit

Permalink
Complete makefile changes; Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Vika-F committed Nov 25, 2024
1 parent 26a96fe commit 5d576b4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
10 changes: 9 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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 <ittnotify.h>.

- 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.
Expand Down
51 changes: 43 additions & 8 deletions cpp/daal/src/externals/service_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ittnotify.h>
#endif

Expand All @@ -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 <ittnotify.h>
*/
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
};

Expand Down
12 changes: 5 additions & 7 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
#===============================================================================
Expand Down Expand Up @@ -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)
Expand All @@ -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 \
Expand Down Expand Up @@ -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 <ittnotify.h>
endef

daal_dbg:
Expand Down

0 comments on commit 5d576b4

Please sign in to comment.