Skip to content

Commit

Permalink
sampling_daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
Solomon Bekele committed Nov 8, 2024
1 parent 615dd37 commit 36e185f
Show file tree
Hide file tree
Showing 5 changed files with 909 additions and 496 deletions.
29 changes: 27 additions & 2 deletions xprof/xprof.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new(THAPI_RUBY_MINIMAL_VERSION)
exit(1)
end

# Define signals for sampling daemon



# We Cannot use "@ .. @" for libdir, bindir, and dataroodir
# as they will appear as bash "${exec_prefix}/lib"
# So for now we will rely on them having the default value,
Expand Down Expand Up @@ -239,6 +243,9 @@ def lttng_home_dir
File.join('/', 'tmp', "lttng_home--#{mpi_job_id}")
end




def thapi_trace_dir_root
raise unless mpi_master?

Expand Down Expand Up @@ -731,10 +738,24 @@ def gm_rename_folder
exec("mv -T #{thapi_trace_dir_tmp_root} #{thapi_trace_dir_root}") unless OPTIONS[:'trace-output']
thapi_trace_dir_root
end
SIGRTMIN = 40
RT_SIGNAL_SAMPLING_READY = SIGRTMIN
RT_SIGNAL_SAMPLING_FINISH = SIGRTMIN + 1
def start_sampling_daemon()
puts "Started sampling daemon (PID #{Process.pid}})"
sampling_daemon_pid = spawn("sampling_daemon #{Process.pid}")
Process.detach(sampling_daemon_pid)
puts "Started sampling daemon (PID #{sampling_daemon_pid }})"
sampling_daemon_pid
end

def stop_sampling_daemon(sampling_daemon_pid)
Process.kill(RT_SIGNAL_SAMPLING_FINISH, sampling_daemon_pid)
puts "Sent FINISH signal to sampling daemon (PID #{sampling_daemon_pid})"
end
# Start, Stop lttng, amd do the on-node analsysis
def trace_and_on_node_processing(usr_argv)
def teardown_lttng(syncd, pids)
def teardown_lttng(syncd, pids, sampling_daemon_pid = nil)
# We need to be sure that all the local ranks are finished
syncd.local_barrier('waiting_for_application_ending')

Expand All @@ -743,6 +764,7 @@ def trace_and_on_node_processing(usr_argv)
# for the early exiting ranks
return unless mpi_local_master?

stop_sampling_daemon(sampling_daemon_pid) if sampling_daemon_pid
# Stop Lttng session and babeltrace daemons
lm_lttng_teardown_session
if OPTIONS[:archive]
Expand Down Expand Up @@ -770,6 +792,9 @@ def trace_and_on_node_processing(usr_argv)
end

syncd.local_barrier('waiting_for_lttng_setup')
if sampling?
sampling_daemon_pid = start_sampling_daemon()
end

# Launch User Command
begin
Expand All @@ -779,7 +804,7 @@ def trace_and_on_node_processing(usr_argv)
raise
end

teardown_lttng(syncd, pids)
teardown_lttng(syncd, pids, sampling_daemon_pid)
return unless mpi_local_master?

# Preprocess trace
Expand Down
34 changes: 27 additions & 7 deletions ze/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ EXTRA_DIST += \
ze_model.rb \
gen_babeltrace_ze_model.rb


ZE_PROBES = $(ZE_NAMESPACES:=_tracepoints) $(ZE_STRUCTS_NAMESPACES:=_tracepoints)
ZE_PROBES_TP = $(ZE_PROBES:=.tp)
ZE_PROBES_INCL = $(ZE_PROBES:=.h)
Expand Down Expand Up @@ -139,6 +140,8 @@ CLEANFILES += \
$(ZE_STATIC_PROBES_INCL) \
$(ZE_STATIC_PROBES_SRC)



EXTRA_DIST += \
gen_probe_base.rb \
$(ZE_GEN_TRACEPOINTS) \
Expand All @@ -148,14 +151,22 @@ BUILT_SOURCES = \
$(ZE_PROBES_INCL) \
$(ZE_STATIC_PROBES_INCL)

bin_PROGRAMS = sampling_daemon

sampling_daemon_SOURCES = sampling_daemon.c
sampling_daemon_CPPFLAGS = -I$(top_srcdir)/utils -I$(top_srcdir)/utils/include -I$(top_srcdir)/ze/include -I./
sampling_daemon_CFLAGS = -Wall -Wextra $(WERROR) $(LTTNG_UST_CFLAGS)
sampling_daemon_LDADD = libzetracepoints.la -ldl -lpthread $(LTTNG_UST_LIBS) ../sampling/libThapiSampling.la

tracer_ze.c: $(srcdir)/gen_ze.rb $(srcdir)/tracer_ze_helpers.include.c $(srcdir)/ze.h.include $(ZE_MODEL) $(ZE_PROBES_INCL) $(ZE_STATIC_PROBES_INCL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@


EXTRA_DIST += \
gen_ze.rb \
tracer_ze_helpers.include.c

CLEANFILES += tracer_ze.c
CLEANFILES += tracer_ze.c sampling_daemon

bin_SCRIPTS = \
tracer_ze.sh
Expand All @@ -172,23 +183,32 @@ libzetracepoints_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(top_srcdir)/utils/inclu
libzetracepoints_la_CFLAGS = -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-type-limits -Wno-sign-compare $(WERROR) $(LTTNG_UST_CFLAGS)
libzetracepoints_la_LDFLAGS = $(LTTNG_UST_LIBS)

zedir = $(pkglibdir)/ze
ze_LTLIBRARIES = libze_loader.la

bt2dir = $(pkglibdir)/bt2
bt2_LTLIBRARIES = libZEInterval.la
lib_LTLIBRARIES = libze_loader.la libZEInterval.la

nodist_libze_loader_la_SOURCES = \
$(ZE_PROBES_INCL) \
$(ZE_STATIC_PROBES_INCL) \
tracer_ze.c

libze_loader_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(top_srcdir)/utils/include -I$(top_srcdir)/sampling -I$(srcdir)/include -I$(top_srcdir)/utils -I./
libze_loader_la_CFLAGS = -Wall -Wextra $(WERROR) $(LIBFFI_CFLAGS) $(LTTNG_UST_CFLAGS)
libze_loader_la_LDFLAGS = $(LTTNG_UST_LIBS) -ldl -lpthread $(LIBFFI_LIBS) ../sampling/libThapiSampling.la
libze_loader_la_LDFLAGS += -version-info 1:0:0
libze_loader_la_LIBADD = libzetracepoints.la

install-exec-hook:
$(MKDIR_P) $(DESTDIR)$(pkglibdir)/ze
$(LN_S) -f $(DESTDIR)$(libdir)/libze_loader.so.1.0.0 $(DESTDIR)$(pkglibdir)/ze/libze_loader.so.1
$(LN_S) -f $(DESTDIR)$(pkglibdir)/ze/libze_loader.so.1 $(DESTDIR)$(pkglibdir)/ze/libze_loader.so
$(MKDIR_P) $(DESTDIR)$(pkglibdir)/bt2
$(LN) -f $(DESTDIR)$(libdir)/libZEInterval.so $(DESTDIR)$(pkglibdir)/bt2/libZEInterval.so

uninstall-hook:
$(RM) -f $(DESTDIR)$(pkglibdir)/ze/libze_loader.so.1 $(DESTDIR)$(pkglibdir)/ze/libze_loader.so
-rmdir $(DESTDIR)$(pkglibdir)/ze
$(RM) -f $(DESTDIR)$(pkglibdir)/bt2/libZEInterval.so
-rmdir $(DESTDIR)$(pkglibdir)/bt2

tmplibdir = $(libdir)/tmp

install-data-hook:
Expand Down
Loading

0 comments on commit 36e185f

Please sign in to comment.