Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing ROCProfilerV2 Integaration with HSA Initialization #1

Open
wants to merge 2 commits into
base: 2023.07.14_rocprofiler_v2_intergration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
PAPI_ROCM_ROOT ?= /opt/rocm

ifeq (@WITH_ROCPROFILER_VER@, V1)
ROCPSRCS += components/rocm/roc_profiler.c
else
ROCPSRCS += components/rocm/roc_profiler_v2.c
endif

COMPSRCS += components/rocm/rocm.c \
components/rocm/roc_profiler.c \
components/rocm/roc_dispatch.c \
components/rocm/roc_common.c
components/rocm/roc_common.c \
$(ROCPSRCS)

ifeq (@WITH_ROCPROFILER_VER@, V1)
ROCPOBJS += roc_profiler.o
else
ROCPOBJS += roc_profiler_v2.o
endif

COMPOBJS += rocm.o roc_profiler.o roc_dispatch.o roc_common.o
COMPOBJS += rocm.o roc_dispatch.o roc_common.o $(ROCPOBJS)

CFLAGS += -I$(PAPI_ROCM_ROOT)/include \
-I$(PAPI_ROCM_ROOT)/include/hsa \
Expand All @@ -22,6 +34,9 @@ rocm.o: components/rocm/rocm.c $(HEADERS)
roc_profiler.o: components/rocm/roc_profiler.c $(HEADERS)
$(CC) $(LIBCFLAGS) $(OPTFLAGS) -c $< -o $@

roc_profiler_v2.o: components/rocm/roc_profiler_v2.c $(HEADERS)
$(CC) $(LIBCFLAGS) $(OPTFLAGS) -c $< -o $@

roc_dispatch.o: components/rocm/roc_dispatch.c $(HEADERS)
$(CC) $(LIBCFLAGS) $(OPTFLAGS) -c $< -o $@

Expand Down
69 changes: 68 additions & 1 deletion src/components/rocm/roc_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,56 @@

#include "roc_dispatch.h"
#include "roc_common.h"

#ifdef ROCPROFILER_V1
#include "roc_profiler.h"
#else
#include "roc_profiler_v2.h"
#endif

int
rocd_init_environment(void)
{
#ifdef ROCPROFILER_V1
return rocp_init_environment();
#else
return rocp2_init_environment();
#endif
}

int
rocd_init(void)
{
int papi_errno = rocc_init();
int papi_errno;

#ifndef ROCPROFILER_V1
papi_errno = rocp2_load_library();
if (papi_errno != PAPI_OK) {
return papi_errno;
}
#endif

papi_errno = rocc_init();
if (papi_errno != PAPI_OK) {
return papi_errno;
}

#ifdef ROCPROFILER_V1
papi_errno = rocp_init();
#else
papi_errno = rocp2_init();
#endif
return papi_errno;
}

int
rocd_shutdown(void)
{
#ifdef ROCPROFILER_V1
int papi_errno = rocp_shutdown();
#else
int papi_errno = rocp2_shutdown();
#endif
if (papi_errno != PAPI_OK) {
return papi_errno;
}
Expand All @@ -42,25 +69,41 @@ rocd_shutdown(void)
int
rocd_evt_enum(unsigned int *event_code, int modifier)
{
#ifdef ROCPROFILER_V1
return rocp_evt_enum(event_code, modifier);
#else
return rocp2_evt_enum(event_code, modifier);
#endif
}

int
rocd_evt_code_to_descr(unsigned int event_code, char *descr, int len)
{
#ifdef ROCPROFILER_V1
return rocp_evt_code_to_descr(event_code, descr, len);
#else
return rocp2_evt_code_to_descr(event_code, descr, len);
#endif
}

int
rocd_evt_name_to_code(const char *name, unsigned int *event_code)
{
#ifdef ROCPROFILER_V1
return rocp_evt_name_to_code(name, event_code);
#else
return rocp2_evt_name_to_code(name, event_code);
#endif
}

int
rocd_evt_code_to_name(unsigned int event_code, char *name, int len)
{
#ifdef ROCPROFILER_V1
return rocp_evt_code_to_name(event_code, name, len);
#else
return rocp2_evt_code_to_name(event_code, name, len);
#endif
}

int
Expand All @@ -72,35 +115,59 @@ rocd_err_get_last(const char **error_str)
int
rocd_ctx_open(unsigned int *events_id, int num_events, rocd_ctx_t *ctx)
{
#ifdef ROCPROFILER_V1
return rocp_ctx_open(events_id, num_events, ctx);
#else
return rocp2_ctx_open(events_id, num_events, ctx);
#endif
}

int
rocd_ctx_close(rocd_ctx_t ctx)
{
#ifdef ROCPROFILER_V1
return rocp_ctx_close(ctx);
#else
return rocp2_ctx_close(ctx);
#endif
}

int
rocd_ctx_start(rocd_ctx_t ctx)
{
#ifdef ROCPROFILER_V1
return rocp_ctx_start(ctx);
#else
return rocp2_ctx_start(ctx);
#endif
}

int
rocd_ctx_stop(rocd_ctx_t ctx)
{
#ifdef ROCPROFILER_V1
return rocp_ctx_stop(ctx);
#else
return rocp2_ctx_stop(ctx);
#endif
}

int
rocd_ctx_read(rocd_ctx_t ctx, long long **counters)
{
#ifdef ROCPROFILER_V1
return rocp_ctx_read(ctx, counters);
#else
return rocp2_ctx_read(ctx, counters);
#endif
}

int
rocd_ctx_reset(rocd_ctx_t ctx)
{
#ifdef ROCPROFILER_V1
return rocp_ctx_reset(ctx);
#else
return rocp2_ctx_reset(ctx);
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
extern unsigned int _rocm_lock;
extern unsigned int rocm_prof_mode;

#define ROCPROFILER_@WITH_ROCPROFILER_VER@

#endif /* End of __ROC_PROFILER_CONFIG_H__ */
Loading