diff --git a/Makefile b/Makefile index 294c15565..718b3118f 100644 --- a/Makefile +++ b/Makefile @@ -734,7 +734,7 @@ local: $(L_APPS) likwid.lua @echo "===> Setting Lua scripts to run from current directory" @PWD=$(shell pwd) @for APP in $(L_APPS); do \ - sed -i -e "s//$(VERSION)/g" -e "s//$(DATE)/g" -e "s//$(RELEASE)/g" -e "s//$(GITCOMMIT)/g" -e "s//$(MINOR)/g" -e "s+$(PREFIX)/bin/likwid-lua+$(PWD)/ext/lua/lua+" -e "s+$(PREFIX)/share/lua/?.lua+$(PWD)/?.lua+" -e "s+$(PREFIX)/bin/likwid-pin+$(PWD)/likwid-pin+" -e "s+$(PREFIX)/bin/likwid-perfctr+$(PWD)/likwid-perfctr+" $$APP; \ + sed -i -e "s//$(VERSION)/g" -e "s//$(DATE)/g" -e "s//$(RELEASE)/g" -e "s//$(GITCOMMIT)/g" -e "s//$(MINOR)/g" -e "s+$(PREFIX)/bin/likwid-lua+$(PWD)/ext/lua/lua+" -e "s+$(PREFIX)/share/lua/?.lua+$(PWD)/?.lua+" -e "s+$(PREFIX)/bin/likwid-pin+$(PWD)/likwid-pin+" -e "s+$(PREFIX)/bin/likwid-perfctr+$(PWD)/likwid-perfctr+" -e "s+$(PREFIX)/lib+$(PWD)+" $$APP; \ chmod +x $$APP; \ done @sed -i -e "s//$(VERSION)/g" -e "s//$(DATE)/g" -e "s//$(RELEASE)/g" -e "s+$(PREFIX)/lib+$(PWD)+g" -e "s+$(PREFIX)/share/likwid/perfgroups+$(PWD)/groups+g" -e "s//$(GITCOMMIT)/g" -e "s//$(MINOR)/g" likwid.lua; diff --git a/make/config_defines.mk b/make/config_defines.mk index 92c4b9e3b..d8f31de76 100644 --- a/make/config_defines.mk +++ b/make/config_defines.mk @@ -294,10 +294,12 @@ endif ifeq ($(strip $(NVIDIA_INTERFACE)),true) DEFINES += -DLIKWID_WITH_NVMON +BUILDAPPDAEMON = true endif ifeq ($(strip $(ROCM_INTERFACE)),true) DEFINES += -DLIKWID_WITH_ROCMON -D__HIP_PLATFORM_HCC__ +BUILDAPPDAEMON = true endif ifeq ($(strip $(BUILDDAEMON)),true) diff --git a/src/access-daemon/Makefile b/src/access-daemon/Makefile index f90bbc370..583e73270 100644 --- a/src/access-daemon/Makefile +++ b/src/access-daemon/Makefile @@ -51,7 +51,7 @@ CFLAGS += -std=c99 -fPIC -pie -fPIE -fstack-protector ifeq ($(COMPILER),GCCX86) CFLAGS += -m32 endif -CPPFLAGS := $(DEFINES) $(INCLUDES) -L$(PREFIX)/lib +CPPFLAGS := $(DEFINES) $(INCLUDES) -L../../lib ifeq ($(COMPILER),GCCARMv8) all: diff --git a/src/access-daemon/appDaemon.c b/src/access-daemon/appDaemon.c index 1f82f6757..137d6167a 100644 --- a/src/access-daemon/appDaemon.c +++ b/src/access-daemon/appDaemon.c @@ -111,7 +111,7 @@ static int parse_gpustr(char* gpuStr, int* numGpus, int** gpuIds) { // Create bstring bstring bGpuStr = bfromcstr(gpuStr); - + int (*ownatoi)(const char*) = atoi; // Parse list struct bstrList* gpuTokens = bsplit(bGpuStr,','); int tmpNumGpus = gpuTokens->qty; @@ -129,7 +129,7 @@ static int parse_gpustr(char* gpuStr, int* numGpus, int** gpuIds) // Parse ids to int for (int i = 0; i < tmpNumGpus; i++) { - tmpGpuIds[i] = atoi(bdata(gpuTokens->entry[i])); + tmpGpuIds[i] = ownatoi(bdata(gpuTokens->entry[i])); } // Copy data diff --git a/src/applications/likwid-perfctr.lua b/src/applications/likwid-perfctr.lua index 3ea17ab3c..12c6d274f 100644 --- a/src/applications/likwid-perfctr.lua +++ b/src/applications/likwid-perfctr.lua @@ -1541,14 +1541,14 @@ if use_marker == true then --------------------------- if nvSupported and #cuda_event_string_list > 0 then if likwid.access(nvMarkerFile, "e") >= 0 then - results, metrics = likwid.getNvMarkerResults(nvMarkerFile, markergpulist, nan2value) + results, metrics = likwid.getMarkerResultsCuda(nvMarkerFile, gpulist_cuda, nan2value) if not results then - print_stderr("Failure reading GPU Marker API result file.") + print_stderr("Failure reading Nv Marker API result file.") elseif #results == 0 then - print_stderr("No regions could be found in GPU Marker API result file.") + print_stderr("No regions could be found in Nv Marker API result file.") else for r = 1, #results do - likwid.printGpuOutput(results[r], metrics[r], gpulist_cuda, r, print_stats) + likwid.printOutputCuda(results[r], metrics[r], gpulist_cuda, r, print_stats) end end likwid.destroyNvMarkerFile() @@ -1561,7 +1561,7 @@ if use_marker == true then --------------------------- if rocmSupported and #rocm_event_string_list > 0 then if likwid.access(rocmMarkerFile, "e") >= 0 then - results, metrics = likwid.getMarkerResultsRocm(rocmMarkerFile, markerrocmgpulist, nan2value) + results, metrics = likwid.getMarkerResultsRocm(rocmMarkerFile, gpulist_rocm, nan2value) if not results then print_stderr("Failure reading ROCM Marker API result file.") elseif #results == 0 then diff --git a/src/applications/likwid.lua b/src/applications/likwid.lua index acf4d1c69..1d635f923 100644 --- a/src/applications/likwid.lua +++ b/src/applications/likwid.lua @@ -202,17 +202,17 @@ likwid.nvGetNameOfCounter = likwid_nvGetNameOfCounter likwid.nvSupported = likwid_nvSupported likwid.readNvMarkerFile = likwid_readNvMarkerFile likwid.destroyNvMarkerFile = likwid_destroyNvMarkerFile -likwid.nvMarkerNumRegions = nvmon_getNumberOfRegions -likwid.nvMarkerRegionGroup = nvmon_getGroupOfRegion -likwid.nvMarkerRegionTag = nvmon_getTagOfRegion -likwid.nvMarkerRegionEvents = likwid_markerRegionEvents -likwid.nvMarkerRegionMetrics = likwid_markerRegionMetrics -likwid.nvMarkerRegionGpulist = likwid_markerRegionGpulist -likwid.nvMarkerRegionGpus = likwid_markerRegionGpus -likwid.nvMarkerRegionTime = likwid_markerRegionTime -likwid.nvMarkerRegionCount = likwid_markerRegionCount -likwid.nvMarkerRegionResult = likwid_markerRegionResult -likwid.nvMarkerRegionMetric = likwid_markerRegionMetric +likwid.nvMarkerNumRegions = likwid_nvMarkerNumRegions +likwid.nvMarkerRegionGroup = likwid_nvMarkerRegionGroup +likwid.nvMarkerRegionTag = likwid_nvMarkerRegionTag +likwid.nvMarkerRegionEvents = likwid_nvMarkerRegionEvents +likwid.nvMarkerRegionMetrics = likwid_nvMarkerRegionMetrics +likwid.nvMarkerRegionGpulist = likwid_nvMarkerRegionGpulist +likwid.nvMarkerRegionGpus = likwid_nvMarkerRegionGpus +likwid.nvMarkerRegionTime = likwid_nvMarkerRegionTime +likwid.nvMarkerRegionCount = likwid_nvMarkerRegionCount +likwid.nvMarkerRegionResult = likwid_nvMarkerRegionResult +likwid.nvMarkerRegionMetric = likwid_nvMarkerRegionMetric likwid.nvInit = likwid_nvInit likwid.nvAddEventSet = likwid_nvAddEventSet likwid.nvFinalize = likwid_nvFinalize @@ -1367,59 +1367,10 @@ end likwid.getArch = llikwid_getArch -local function getGpuMarkerResults(filename, gpulist, nan2value) - local gputopo = likwid.getGpuTopology() - local ret = likwid.readNvMarkerFile(filename) - if ret < 0 then - return nil, nil - elseif ret == 0 then - return {}, {} - end - if not nan2value then - nan2value = '-' - end - results = {} - metrics = {} - for i=1, likwid.nvMarkerNumRegions() do - local regionName = likwid.nvMarkerRegionTag(i) - local groupID = likwid.nvMarkerRegionGroup(i) - local regionGPUs = likwid.nvMarkerRegionGpus(i) - results[i] = {} - metrics[i] = {} - results[i][groupID] = {} - metrics[i][groupID] = {} - for k=1, likwid.nvMarkerRegionEvents(i) do - local eventName = likwid.nvGetNameOfEvent(groupID, k) - local counterName = likwid.nvGetNameOfCounter(groupID, k) - results[i][groupID][k] = {} - for j=1, regionGPUs do - results[i][groupID][k][j] = likwid.nvMarkerRegionResult(i,k,j) - if results[i][groupID][k][j] ~= results[i][groupID][k][j] then - results[i][groupID][k][j] = nan2value - end - end - end - if likwid.nvMarkerRegionMetrics(groupID) > 0 then - for k=1, likwid.nvMarkerRegionMetrics(groupID) do - local metricName = likwid.getNameOfMetric(groupID, k) - metrics[i][likwid.nvMarkerRegionGroup(i)][k] = {} - for j=1, regionGPUs do - metrics[i][groupID][k][j] = likwid.nvMarkerRegionMetric(i,k,j) - if metrics[i][groupID][k][j] ~= metrics[i][groupID][k][j] then - metrics[i][groupID][k][j] = nan2value - end - end - end - end - end - return results, metrics -end - -likwid.getGpuMarkerResults = getGpuMarkerResults -local function printGpuOutput(results, metrics, gpulist, region, stats) +local function printOutputCuda(results, metrics, gpulist, region, stats) local maxLineFields = 0 - local gputopo = likwid.getGpuTopology() + local gputopo = likwid.getCudaTopology() local regionName = likwid.nvMarkerRegionTag(region) local regionGPUs = likwid.nvMarkerRegionGpus(region) local cur_gpulist = gpulist @@ -1572,10 +1523,10 @@ local function printGpuOutput(results, metrics, gpulist, region, stats) end end -likwid.printGpuOutput = printGpuOutput +likwid.printOutputCuda = printOutputCuda -local function getNvMarkerResults(filename, gpulist, nan2value) - local gputopo = likwid.getGpuTopology() +local function getMarkerResultsCuda(filename, gpulist, nan2value) + local gputopo = likwid.getCudaTopology() local ret = likwid.readNvMarkerFile(filename) if ret < 0 then return nil, nil @@ -1622,7 +1573,7 @@ local function getNvMarkerResults(filename, gpulist, nan2value) return results, metrics end -likwid.getNvMarkerResults = getNvMarkerResults +likwid.getMarkerResultsCuda = getMarkerResultsCuda local function getMarkerResultsRocm(filename, gpulist, nan2value) local gputopo = likwid.getGpuTopology_rocm() diff --git a/src/includes/likwid-marker.h b/src/includes/likwid-marker.h index 36a90f73a..aed173c05 100644 --- a/src/includes/likwid-marker.h +++ b/src/includes/likwid-marker.h @@ -108,39 +108,43 @@ Shortcut for likwid_markerWriteFile() if compiled with -DLIKWID_PERFMON. Otherwi */ /*! \def LIKWID_NVMARKER_INIT -Shortcut for likwid_gpuMarkerInit() if compiled with -DLIKWID_PERFMON. Otherwise no operation is performed +Shortcut for nvmon_markerInit() if compiled with -DLIKWID_PERFMON. Otherwise no operation is performed */ /*! \def LIKWID_NVMARKER_THREADINIT -Shortcut for likwid_gpuMarkerThreadInit() if compiled with -DLIKWID_PERFMON. Otherwise no operation is performed +No operation is performed, this macro exists only to be similar as CPU MarkerAPI */ /*! \def LIKWID_NVMARKER_REGISTER(regionTag) -Shortcut for likwid_gpuMarkerRegisterRegion() with \a regionTag if compiled with -DLIKWID_NVMON. Otherwise no operation is performed +Shortcut for nvmon_markerRegisterRegion() with \a regionTag if compiled with -DLIKWID_NVMON. Otherwise no operation is performed */ /*! \def LIKWID_NVMARKER_START(regionTag) -Shortcut for likwid_gpuMarkerStartRegion() with \a regionTag if compiled with -DLIKWID_NVMON. Otherwise no operation is performed +Shortcut for nvmon_markerStartRegion() with \a regionTag if compiled with -DLIKWID_NVMON. Otherwise no operation is performed */ /*! \def LIKWID_NVMARKER_STOP(regionTag) -Shortcut for likwid_gpuMarkerStopRegion() with \a regionTag if compiled with -DLIKWID_NVMON. Otherwise no operation is performed +Shortcut for nvmon_markerStopRegion() with \a regionTag if compiled with -DLIKWID_NVMON. Otherwise no operation is performed */ /*! \def LIKWID_NVMARKER_GET(regionTag, ngpus, nevents, events, time, count) -Shortcut for likwid_gpuMarkerGetRegion() for \a regionTag if compiled with -DLIKWID_NVMON. Otherwise no operation is performed +Shortcut for nvmon_markerGetRegion() for \a regionTag if compiled with -DLIKWID_NVMON. Otherwise no operation is performed */ /*! \def LIKWID_NVMARKER_SWITCH -Shortcut for likwid_gpuMarkerNextGroup() if compiled with -DLIKWID_NVMON. Otherwise no operation is performed +Shortcut for nvmon_markerNextGroup() if compiled with -DLIKWID_NVMON. Otherwise no operation is performed */ /*! \def LIKWID_NVMARKER_RESET(regionTag) -Shortcut for likwid_gpuMarkerResetRegion() if compiled with -DLIKWID_NVMON. Otherwise no operation is performed +Shortcut for nvmon_markerResetRegion() if compiled with -DLIKWID_NVMON. Otherwise no operation is performed */ /*! \def LIKWID_NVMARKER_CLOSE -Shortcut for likwid_gpuMarkerClose() if compiled with -DLIKWID_NVMON. Otherwise no operation is performed +Shortcut for nvmon_markerClose() if compiled with -DLIKWID_NVMON. Otherwise no operation is performed +*/ +/*! +\def LIKWID_NVMARKER_WRITE_FILE +Shortcut for nvmon_markerWriteFile() with \a filename if compiled with -DLIKWID_NVMON. Otherwise no operation is performed */ /** @}*/ @@ -149,16 +153,18 @@ Shortcut for likwid_gpuMarkerClose() if compiled with -DLIKWID_NVMON. Otherwise #define LIKWID_WITH_NVMON #endif #include -#define LIKWID_NVMARKER_INIT likwid_gpuMarkerInit() -#define LIKWID_NVMARKER_THREADINIT likwid_gpuMarkerThreadInit() -#define LIKWID_NVMARKER_SWITCH likwid_gpuMarkerNextGroup() -#define LIKWID_NVMARKER_REGISTER(regionTag) likwid_gpuMarkerRegisterRegion(regionTag) -#define LIKWID_NVMARKER_START(regionTag) likwid_gpuMarkerStartRegion(regionTag) -#define LIKWID_NVMARKER_STOP(regionTag) likwid_gpuMarkerStopRegion(regionTag) -#define LIKWID_NVMARKER_CLOSE likwid_gpuMarkerClose() -#define LIKWID_NVMARKER_RESET(regionTag) likwid_gpuMarkerResetRegion(regionTag) +#define LIKWID_NVMARKER_INIT nvmon_markerInit() +#define LIKWID_NVMARKER_THREADINIT +#define LIKWID_NVMARKER_SWITCH nvmon_markerNextGroup() +#define LIKWID_NVMARKER_REGISTER(regionTag) nvmon_markerRegisterRegion(regionTag) +#define LIKWID_NVMARKER_START(regionTag) nvmon_markerStartRegion(regionTag) +#define LIKWID_NVMARKER_STOP(regionTag) nvmon_markerStopRegion(regionTag) +#define LIKWID_NVMARKER_CLOSE nvmon_markerClose() +#define LIKWID_NVMARKER_RESET(regionTag) nvmon_markerResetRegion(regionTag) #define LIKWID_NVMARKER_GET(regionTag, ngpus, nevents, events, time, count) \ - likwid_gpuMarkerGetRegion(regionTag, ngpus, nevents, events, time, count) + nvmon_markerGetRegion(regionTag, ngpus, nevents, events, time, count) +#define LIKWID_NVMARKER_WRITE_FILE(markerfile) \ + nvmon_markerWriteFile(markerfile) #else /* LIKWID_NVMON */ #define LIKWID_NVMARKER_INIT #define LIKWID_NVMARKER_THREADINIT @@ -169,6 +175,7 @@ Shortcut for likwid_gpuMarkerClose() if compiled with -DLIKWID_NVMON. Otherwise #define LIKWID_NVMARKER_CLOSE #define LIKWID_NVMARKER_GET(regionTag, nevents, events, time, count) #define LIKWID_NVMARKER_RESET(regionTag) +#define LIKWID_NVMARKER_WRITE_FILE(markerfile) #endif /* LIKWID_NVMON */ @@ -211,6 +218,10 @@ Shortcut for rocmon_markerResetRegion() if compiled with -DLIKWID_ROCMON. Otherw \def ROCMON_MARKER_CLOSE Shortcut for rocmon_markerClose() if compiled with -DLIKWID_ROCMON. Otherwise no operation is performed */ +/*! +\def ROCMON_MARKER_WRITE_FILE +Shortcut for rocmon_markerWriteFile() with \a filename if compiled with -DLIKWID_ROCMON. Otherwise no operation is performed +*/ /** @}*/ #ifdef LIKWID_ROCMON @@ -227,6 +238,7 @@ Shortcut for rocmon_markerClose() if compiled with -DLIKWID_ROCMON. Otherwise no #define ROCMON_MARKER_CLOSE rocmon_markerClose() #define ROCMON_MARKER_RESET(regionTag) rocmon_markerResetRegion(regionTag) #define ROCMON_MARKER_GET(regionTag, ngpus, nevents, events, time, count) rocmon_markerGetRegion(regionTag, ngpus, nevents, events, time, count) +#define ROCMON_MARKER_WRITE_FILE(filename) rocmon_markerWriteFile(filename) #else /* LIKWID_ROCMON */ #define ROCMON_MARKER_INIT #define ROCMON_MARKER_THREADINIT @@ -237,6 +249,7 @@ Shortcut for rocmon_markerClose() if compiled with -DLIKWID_ROCMON. Otherwise no #define ROCMON_MARKER_CLOSE #define ROCMON_MARKER_GET(regionTag, nevents, events, time, count) #define ROCMON_MARKER_RESET(regionTag) +#define ROCMON_MARKER_WRITE_FILE(filename) #endif /* LIKWID_ROCMON */ diff --git a/src/includes/likwid.h b/src/includes/likwid.h index 9e9f6ad89..4c3c51e15 100644 --- a/src/includes/likwid.h +++ b/src/includes/likwid.h @@ -2327,6 +2327,13 @@ extern void nvmon_markerGetRegion(const char *regionTag, int *nr_gpus, int *nr_events, double **events, double *time, int *count) __attribute__((visibility("default"))); +/*! \brief Write the output file of the NvMarker API +@param [in] markerfile Filename for NvMarker API results +@return 0 or negative error number +*/ +extern int nvmon_markerWriteFile(const char* markerfile) + __attribute__((visibility("default"))); + /*! \brief Read the output file of the NvMarker API @param [in] filename Filename with NvMarker API results @@ -3099,6 +3106,24 @@ Reset the values of all configured counters and timers. int rocmon_markerResetRegion(const char *regionTag) __attribute__((visibility("default"))); +/*! \brief Write measurement data to file + +Write current values to file +@param markerfile [in] Filename for writing +@return Error code of write operation +*/ +int rocmon_markerWriteFile(const char *markerfile) + __attribute__((visibility("default"))); + +/*! \brief Select next group to measure + +Must be called in parallel region of the application to switch group on every +CPU. +*/ +extern void rocmon_markerNextGroup(void) + __attribute__((visibility("default"))); + + /*! \brief Read the output file of the RocmonMarker API @param [in] filename Filename with RocmonMarker API results @return 0 or negative error number diff --git a/src/libnvctr.c b/src/libnvctr.c index 0d6898889..49ab2c3b7 100644 --- a/src/libnvctr.c +++ b/src/libnvctr.c @@ -267,6 +267,76 @@ void nvmon_markerClose(void) { // nvmon_finalize(); } +int nvmon_markerWriteFile(const char* markerfile) +{ + FILE *file = NULL; + int numberOfGPUs = 0; + int numberOfRegions = 0; + if (markerfile == NULL) { + fprintf(stderr, "File can not be NULL.\n"); + return -EFAULT; + } + numberOfRegions = get_map_size(cuda_maps[0]); + numberOfGPUs = nvmon_getNumberOfGPUs(); + if ((numberOfGPUs == 0) || (numberOfRegions == 0)) { + fprintf(stderr, "No GPUs or regions defined in hash table\n"); + return -EFAULT; + } + + file = fopen(markerfile, "w"); + if (file != NULL) { + DEBUG_PRINT(DEBUGLEV_DEVELOP, + Creating GPU Marker file % s with % d regions % d groups and + % d GPUs, + markerfile, numberOfRegions, numberOfCudaGroups, numberOfGPUs); + bstring thread_regs_grps = + bformat("%d %d %d", numberOfGPUs, numberOfRegions, numberOfCudaGroups); + fprintf(file, "%s\n", bdata(thread_regs_grps)); + DEBUG_PRINT(DEBUGLEV_DEVELOP, % s, bdata(thread_regs_grps)); + bdestroy(thread_regs_grps); + + for (int j = 0; j < numberOfRegions; j++) { + LikwidGpuResults *results = NULL; + int ret = get_smap_by_idx(cuda_maps[0], j, (void **)&results); + if (ret == 0) { + bstring tmp = bformat("%d:%s", j, bdata(results->label)); + fprintf(file, "%s\n", bdata(tmp)); + DEBUG_PRINT(DEBUGLEV_DEVELOP, % s, bdata(tmp)); + bdestroy(tmp); + } + } + + for (int j = 0; j < numberOfRegions; j++) { + + for (int i = 0; i < numberOfGPUs; i++) { + LikwidGpuResults *results = NULL; + int ret = get_smap_by_idx(cuda_maps[i], j, (void **)&results); + if (!ret) { + bstring l = + bformat("%d %d %d %u %e %d ", j, results->groupID, + id2Cuda[results->gpuID], results->count, results->time, + nvmon_getNumberOfEvents(results->groupID)); + for (int k = 0; k < nvmon_getNumberOfEvents(results->groupID); k++) { + bstring tmp = bformat("%e ", results->PMcounters[k]); + bconcat(l, tmp); + bdestroy(tmp); + } + fprintf(file, "%s\n", bdata(l)); + DEBUG_PRINT(DEBUGLEV_DEVELOP, % s, bdata(l)); + bdestroy(l); + } + free(results); + } + } + } else { + int err = errno; + fprintf(stderr, "Cannot open file %s\n", markerfile); + fprintf(stderr, "%s", strerror(err)); + return -err; + } + return 0; +} + int nvmon_markerRegisterRegion(const char *regionTag) { if (!likwid_cuda_init) { return -EFAULT; diff --git a/src/likwid.F90 b/src/likwid.F90 index 0d0b05261..618dd9215 100644 --- a/src/likwid.F90 +++ b/src/likwid.F90 @@ -213,6 +213,12 @@ subroutine likwid_NvMarkerResetRegion( regionTag ) character(*) :: regionTag end subroutine likwid_NvMarkerResetRegion +!> \ingroup Fortran_NvGPU_Interface +!! \brief Write the current results to file + subroutine likwid_NvMarkerWriteFile( filename ) +!> \param filename Filename to write data + character(*) :: filename + end subroutine likwid_NvMarkerWriteFile #endif /* LIKWID_WITH_NVMON */ #ifdef LIKWID_WITH_ROCMON @@ -295,6 +301,13 @@ subroutine likwid_RocmMarkerResetRegion( regionTag ) character(*) :: regionTag end subroutine likwid_RocmMarkerResetRegion +!> \ingroup Fortran_RocmGPU_Interface +!! \brief Write the current results to file + subroutine likwid_RocmMarkerWriteFile( filename ) +!> \param filename Filename to write data + character(*) :: filename + end subroutine likwid_RocmMarkerWriteFile + #endif /* LIKWID_WITH_ROCMON */ end interface diff --git a/src/likwid_f90_interface.c b/src/likwid_f90_interface.c index 4094e321c..26567d82e 100644 --- a/src/likwid_f90_interface.c +++ b/src/likwid_f90_interface.c @@ -266,6 +266,23 @@ likwid_nvmarkerresetregion_(char* regionTag, int len) nvmon_markerResetRegion( tmp); free(tmp); } + +int __attribute__ ((visibility ("default") )) +likwid_nvmarkerwritefile_(char* filename, int len) +{ + char* tmp = (char*) malloc((len+1) * sizeof(char)); + strncpy(tmp, regionTag, len * sizeof(char) ); + + for (int i=(len-1); len > 0; len--) + { + if (tmp[i] != ' ') { + tmp[i+1] = 0; + break; + } + } + nvmon_markerWriteFile(tmp); + free(tmp); +} #endif #ifdef LIKWID_WITH_ROCMON @@ -358,4 +375,21 @@ likwid_rocmmarkerresetregion_(char* regionTag, int len) rocmon_markerResetRegion( tmp); free(tmp); } + +int __attribute__ ((visibility ("default") )) +likwid_rocmmarkerwritefile_(char* filename, int len) +{ + char* tmp = (char*) malloc((len+1) * sizeof(char)); + strncpy(tmp, filename, len * sizeof(char) ); + + for (int i=(len-1); len > 0; len--) + { + if (tmp[i] != ' ') { + tmp[i+1] = 0; + break; + } + } + rocmon_markerWriteFile(tmp); + free(tmp); +} #endif /* LIKWID_WITH_ROCMON */ diff --git a/src/luawid.c b/src/luawid.c index 09bc4f8c4..c7b604e21 100644 --- a/src/luawid.c +++ b/src/luawid.c @@ -3040,11 +3040,6 @@ lua_likwid_nvSupported(lua_State *L) RocmTopology_t rocmtopo = NULL; int rocmtopology_isInitialized = 0; -static int lua_likwid_rocmSupported(lua_State *L) { - lua_pushboolean(L, TRUE); - return 1; -} - static int lua_likwid_getRocmTopology(lua_State *L) { if (!rocmtopology_isInitialized) { if (topology_rocm_init() == EXIT_SUCCESS) { diff --git a/src/rocmon_marker.c b/src/rocmon_marker.c index 828e9cdde..1e03185a6 100644 --- a/src/rocmon_marker.c +++ b/src/rocmon_marker.c @@ -120,7 +120,7 @@ _rocmon_parse_gpustr(char* gpuStr, int* numGpus, int** gpuIds) } static void -_rocmon_saveToFile(void) +_rocmon_saveToFile(const char* markerfile) { /* File format * 1 numberOfGPUs numberOfRegions numberOfGpuGroups @@ -130,14 +130,6 @@ _rocmon_saveToFile(void) * 5 regionID groupID gpuID callCount timeActive numEvents countersvalues(space separated) */ - // Get markerfile path from environment - char* markerfile = getenv("LIKWID_ROCMON_FILEPATH"); - if (markerfile == NULL) - { - fprintf(stderr, "Is the application executed with LIKWID wrapper? No file path for the Rocmon Marker API output defined.\n"); - return; - } - // Verify there is something to output int numberOfRegions = get_map_size(gpu_maps[0]); int numberOfGPUs = rocmon_getNumberOfGPUs(); @@ -379,11 +371,33 @@ rocmon_markerClose(void) // Stop counters rocmon_stopCounters(); - _rocmon_saveToFile(); + // Get markerfile path from environment + char* markerfile = getenv("LIKWID_ROCMON_FILEPATH"); + if (markerfile == NULL) + { + fprintf(stderr, "Is the application executed with LIKWID wrapper? No file path for the Rocmon Marker API output defined.\n"); + return; + } + else + { + _rocmon_saveToFile(markerfile); + } + _rocmon_finalize(); } +int +rocmon_markerWriteFile(const char* markerfile) +{ + if (!markerfile) + { + return -EINVAL; + } + _rocmon_saveToFile(markerfile); + return 0; +} + int rocmon_markerRegisterRegion(const char* regionTag) {