Skip to content

Commit

Permalink
Add ability of vtune profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
Vika-F committed Nov 24, 2024
1 parent 14f4e79 commit 26a96fe
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
24 changes: 24 additions & 0 deletions cpp/daal/src/externals/service_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@ namespace daal
{
namespace internal
{
#ifdef ONEDAL_KERNEL_PROFILER

ProfilerTask::ProfilerTask(const char * taskName) : _taskName(taskName)
{
_handle = __itt_string_handle_create(taskName);

__itt_task_begin(Profiler::getDomain(), __itt_null, __itt_null, _handle);
}

ProfilerTask::~ProfilerTask() {
Profiler::endTask(_taskName);
}

ProfilerTask Profiler::startTask(const char * taskName)
{
return ProfilerTask(taskName);
}

void Profiler::endTask(const char * taskName) {
__itt_task_end(Profiler::getDomain());
}

#else
ProfilerTask Profiler::startTask(const char * taskName)
{
return ProfilerTask(taskName);
Expand All @@ -34,6 +57,7 @@ ProfilerTask::~ProfilerTask()
{
Profiler::endTask(_taskName);
}
#endif

} // namespace internal
} // namespace daal
26 changes: 26 additions & 0 deletions cpp/daal/src/externals/service_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
#ifndef __SERVICE_PROFILER_H__
#define __SERVICE_PROFILER_H__

// #define ONEDAL_KERNEL_PROFILER

#ifdef ONEDAL_KERNEL_PROFILER
#include <ittnotify.h>
#endif

#define DAAL_ITTNOTIFY_CONCAT2(x, y) x##y
#define DAAL_ITTNOTIFY_CONCAT(x, y) DAAL_ITTNOTIFY_CONCAT2(x, y)

Expand All @@ -44,6 +50,10 @@ class ProfilerTask

private:
const char * _taskName;
#ifdef ONEDAL_KERNEL_PROFILER
__itt_string_handle* _handle;
__itt_domain* _domain;
#endif
};

// This class is a stub in the library. Its redefinition will be in Bechmarks
Expand All @@ -52,6 +62,22 @@ class Profiler
public:
static ProfilerTask startTask(const char * taskName);
static void endTask(const char * taskName);
#ifdef ONEDAL_KERNEL_PROFILER
static Profiler* getInstance() {
static Profiler instance;
return &instance;
}

static __itt_domain* getDomain() {
return (getInstance())->_domain;
}
private:
Profiler() {
_domain = __itt_domain_create("oneDAL");
}
~Profiler() {}
__itt_domain* _domain;
#endif
};

} // namespace internal
Expand Down
24 changes: 19 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,18 @@ endif

include dev/make/deps.$(BACKEND_CONFIG).mk

#=============================== VTune SDK folders ======================================

ifeq ($(REQPROFILE), yes)
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 @@ -436,9 +448,11 @@ CORE.srcdirs := $(CORE.SERV.srcdir) $(CORE.srcdir) \
$(CPPDIR.daal)/src/data_management

CORE.incdirs.common := $(RELEASEDIR.include) $(CPPDIR.daal) $(WORKDIR)
CORE.incdirs.thirdp := $(daaldep.math_backend.incdir) $(TBBDIR.include)
CORE.incdirs.thirdp := $(daaldep.math_backend.incdir) $(VTUNESDK.include) $(TBBDIR.include)
CORE.incdirs := $(CORE.incdirs.common) $(CORE.incdirs.thirdp)

$(info CORE.incdirs: $(CORE.incdirs))

containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
notcontaining = $(foreach v,$2,$(if $(findstring $1,$v),,$v))
cpy = cp -fp "$<" "$@"
Expand Down Expand Up @@ -479,7 +493,7 @@ $(CORE.tmpdir_a)/$(core_a:%.$a=%_link.txt): $(CORE.objs_a) | $(CORE.tmpdir_a)/.
$(CORE.tmpdir_a)/$(core_a:%.$a=%_link.$a): LOPT:=
$(CORE.tmpdir_a)/$(core_a:%.$a=%_link.$a): $(CORE.tmpdir_a)/$(core_a:%.$a=%_link.txt) | $(CORE.tmpdir_a)/. ; $(LINK.STATIC)
$(WORKDIR.lib)/$(core_a): LOPT:=
$(WORKDIR.lib)/$(core_a): $(daaldep.math_backend.ext) $(CORE.tmpdir_a)/$(core_a:%.$a=%_link.$a) ; $(LINK.STATIC)
$(WORKDIR.lib)/$(core_a): $(daaldep.math_backend.ext) $(VTUNESDK.LIBS_A) $(CORE.tmpdir_a)/$(core_a:%.$a=%_link.$a) ; $(LINK.STATIC)

$(WORKDIR.lib)/$(core_y): LOPT += $(-fPIC)
$(WORKDIR.lib)/$(core_y): LOPT += $(daaldep.rt.seq)
Expand All @@ -488,7 +502,7 @@ ifdef OS_is_win
$(WORKDIR.lib)/$(core_y:%.$(MAJORBINARY).dll=%_dll.lib): $(WORKDIR.lib)/$(core_y)
endif
$(CORE.tmpdir_y)/$(core_y:%.$y=%_link.txt): $(CORE.objs_y) $(if $(OS_is_win),$(CORE.tmpdir_y)/dll.res,) | $(CORE.tmpdir_y)/. ; $(WRITE.PREREQS)
$(WORKDIR.lib)/$(core_y): $(daaldep.math_backend.ext) \
$(WORKDIR.lib)/$(core_y): $(daaldep.math_backend.ext) $(VTUNESDK.LIBS_A) \
$(CORE.tmpdir_y)/$(core_y:%.$y=%_link.txt) ; $(LINK.DYNAMIC) ; $(LINK.DYNAMIC.POST)

$(CORE.objs_a): $(CORE.tmpdir_a)/inc_a_folders.txt
Expand Down Expand Up @@ -552,7 +566,7 @@ PARAMETERS.tmpdir_a.dpc := $(WORKDIR)/parameters_dpc_static
PARAMETERS.tmpdir_y.dpc := $(WORKDIR)/parameters_dpc_dynamic

ONEAPI.incdirs.common := $(CPPDIR)
ONEAPI.incdirs.thirdp := $(CORE.incdirs.common) $(daaldep.math_backend_oneapi.incdir) $(TBBDIR.include)
ONEAPI.incdirs.thirdp := $(CORE.incdirs.common) $(daaldep.math_backend_oneapi.incdir) $(VTUNESDK.include) $(TBBDIR.include)
ONEAPI.incdirs := $(ONEAPI.incdirs.common) $(CORE.incdirs.thirdp) $(ONEAPI.incdirs.thirdp)

ONEAPI.dispatcher_cpu = $(WORKDIR)/oneapi/dal/_dal_cpu_dispatcher_gen.hpp
Expand Down Expand Up @@ -697,7 +711,7 @@ $(ONEAPI.objs_y): COPT += $(-fPIC) $(-cxx17) $(-Zl) $(-DMKL_ILP64) $(-DEBC) $(-E
$(eval $(call update_copt_from_dispatcher_tag,$(ONEAPI.objs_y)))

# Note: The libonedal_dpc.so library does not support debug mode.
# When compiling with the debug flag $(-DEBC_DPCPP), linking with libonedal_dpc.so may cause indefinite linking times
# When compiling with the debug flag $(-DEBC_DPCPP), linking with libonedal_dpc.so may cause indefinite linking times
# due to the extensive processing of debug information. For debugging, please use the static library version (libonedal_dpc.a).
$(ONEAPI.objs_y.dpc): $(ONEAPI.dispatcher_cpu) $(ONEAPI.tmpdir_y.dpc)/inc_y_folders.txt
$(ONEAPI.objs_y.dpc): COPT += $(-fPIC) $(-cxx17) $(-Zl_DPCPP) $(-DMKL_ILP64) $(-EHsc) $(pedantic.opts.dpcpp) \
Expand Down

0 comments on commit 26a96fe

Please sign in to comment.