diff --git a/Makefile b/Makefile index d3110a063..47c6d8427 100644 --- a/Makefile +++ b/Makefile @@ -279,7 +279,7 @@ $(GENGROUPLOCK): $(foreach directory,$(shell ls $(GROUP_DIR)), $(wildcard $(GROU $(Q)$(GEN_GROUPS) ./groups $(BUILD_DIR) ./perl/templates $(Q)touch $(GENGROUPLOCK) -$(FORTRAN_IF): $(SRC_DIR)/likwid.f90 +$(FORTRAN_IF): $(SRC_DIR)/likwid.F90 @echo "===> COMPILE FORTRAN INTERFACE $@" $(Q)$(FC) -c $(FCFLAGS) $< @rm -f likwid.o diff --git a/doc/Doxyfile b/doc/Doxyfile index d6b9cbf6c..1817cf878 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -648,7 +648,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ./src/includes/likwid.h ./src/includes/likwid-marker.h ./doc/likwid-doxygen.md ./src/includes/perfmon_types.h ./src/includes/topology_types.h ./src/includes/power_types.h ./src/includes/tree_types.h ./doc/archs/ ./doc/lua-doxygen.md ./doc/applications/ ./doc/likwid.cfg.md ./src/likwid.f90 +INPUT = ./src/includes/likwid.h ./src/includes/likwid-marker.h ./doc/likwid-doxygen.md ./src/includes/perfmon_types.h ./src/includes/topology_types.h ./src/includes/power_types.h ./src/includes/tree_types.h ./doc/archs/ ./doc/lua-doxygen.md ./doc/applications/ ./doc/likwid.cfg.md ./src/likwid.F90 # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/doc/likwid-doxygen.md b/doc/likwid-doxygen.md index 2a4f96305..f16bb7da6 100644 --- a/doc/likwid-doxygen.md +++ b/doc/likwid-doxygen.md @@ -73,6 +73,8 @@ Optionally, a global configuration file \ref likwid.cfg can be given to modify s \subsection Fortran90_Interface Fortran90 Interface - \ref Fortran_Interface +- \ref Fortran_RocmGPU_Interface +- \ref Fortran_NvGPU_Interface \section Architectures Supported Architectures \subsection Architectures_X86 X86 Architectures diff --git a/src/likwid.f90 b/src/likwid.F90 similarity index 70% rename from src/likwid.f90 rename to src/likwid.F90 index 8b1583580..fddbe8804 100644 --- a/src/likwid.f90 +++ b/src/likwid.F90 @@ -1,6 +1,6 @@ ! ======================================================================================= ! -! Filename: likwid.f90 +! Filename: likwid.F90 ! ! Description: Marker API f90 module ! @@ -124,7 +124,7 @@ subroutine likwid_markerResetRegion( regionTag ) character(*) :: regionTag end subroutine likwid_markerResetRegion - +#ifdef LIKWID_WITH_NVMON !> \ingroup Fortran_NvGPU_Interface !! \brief Initialize the Likwid NvMarker API !! This routine initializes the NvMarker API for Fortran. It reads some @@ -204,6 +204,90 @@ subroutine likwid_NvMarkerResetRegion( regionTag ) character(*) :: regionTag end subroutine likwid_NvMarkerResetRegion +#endif /* LIKWID_WITH_NVMON */ + +#ifdef LIKWID_WITH_ROCMON +!> \ingroup Fortran_RocmGPU_Interface +!! \brief Initialize the Likwid RocmonMarker API +!! This routine initializes the RocmonMarker API for Fortran. It reads some +!! environment commonly set by likwid-perfctr. +!! \note Must be called once in a serial region. + subroutine likwid_RocmMarkerInit() + end subroutine likwid_RocmMarkerInit + +!> \ingroup Fortran_RocmGPU_Interface +!! \brief Setup performance counters for the next event set +!! If multiple groups should be measured this function +!! switches to the next group in a round robin fashion. +!! Each call reprogramms the performance counters for the current CPU, +!! \note Do not call it while measuring a code region. + subroutine likwid_RocmMarkerNextGroup() + end subroutine likwid_RocmMarkerNextGroup + +!> \ingroup Fortran_RocmGPU_Interface +!! \brief Close the Likwid RocmonMarker API +!! Close the Likwid Marker API and write measured results to temporary file +!! for evaluation done by likwid-perfctr +!! \note Must be called once in a serial region and no further +!! Likwid calls should be used + subroutine likwid_RocmMarkerClose() + end subroutine likwid_RocmMarkerClose + +!> \ingroup Fortran_RocmGPU_Interface +!! \brief Register a code region +!! Initializes the hash table with an empty entry to reduce the overhead +!! at likwid_RocmMarkerStartRegion() + subroutine likwid_RocmMarkerRegisterRegion( regionTag ) +!> \param regionTag Name for the code region for later identification + character(*) :: regionTag + end subroutine likwid_RocmMarkerRegisterRegion + + +!> \ingroup Fortran_RocmGPU_Interface +!! \brief Start the measurement for a code region +!! Reads the currently running event set and store the results as start values. +!! for the measurement group identified by regionTag + subroutine likwid_RocmMarkerStartRegion( regionTag ) +!> \param regionTag Name for the code region for later identification + character(*) :: regionTag + end subroutine likwid_RocmMarkerStartRegion + +!> \ingroup Fortran_RocmGPU_Interface +!! \brief Stop the measurement for a code region +!! Reads the currently running event set and accumulate the difference between +!! stop and start data in the measurement group identified by regionTag. + subroutine likwid_RocmMarkerStopRegion( regionTag ) +!> \param regionTag Name for the code region for later identification + character(*) :: regionTag + end subroutine likwid_RocmMarkerStopRegion + +!> \ingroup Fortran_RocmGPU_Interface +!! \brief Get accumulated measurement results for a code region +!! Get the accumulated data in the measurement group identified by regionTag +!! for the current thread. +!! \warning Experimental +!! subroutine likwid_markerGetRegion( regionTag, nr_events, events, time, count ) +!> \param regionTag [in] Name for the code region for later identification +!! \param nr_events [in,out] Length of the events array +!! \param events [out] Events array to store intermediate results +!! \param time [out] Accumulated measurement time +!! \param count [out] Call count of the region +!! character(*) :: regionTag +!! INTEGER :: nr_events +!! DOUBLE PRECISION, DIMENSION(*) :: events +!! DOUBLE PRECISION :: time +!! INTEGER :: count +!! end subroutine likwid_markerGetRegion + +!> \ingroup Fortran_RocmGPU_Interface +!! \brief Reset the counters for a code region to zero + subroutine likwid_RocmMarkerResetRegion( regionTag ) +!> \param regionTag Name for the code region for later identification + character(*) :: regionTag + end subroutine likwid_RocmMarkerResetRegion + +#endif LIKWID_WITH_ROCMON + end interface end module likwid diff --git a/src/likwid_f90_interface.c b/src/likwid_f90_interface.c index d36742247..173fc2c02 100644 --- a/src/likwid_f90_interface.c +++ b/src/likwid_f90_interface.c @@ -249,3 +249,95 @@ likwid_nvmarkerresetregion_(char* regionTag, int len) free(tmp); } #endif + +#ifdef LIKWID_WITH_ROCMON +void __attribute__ ((visibility ("default") )) +likwid_rocmmarkerinit_(void) +{ + rocmon_markerInit(); +} + + +void __attribute__ ((visibility ("default") )) +likwid_rocmmarkerclose_(void) +{ + rocmon_markerClose(); +} + +void __attribute__ ((visibility ("default") )) +likwid_rocmmarkernextgroup_(void) +{ + rocmon_markerNextGroup(); +} + +void __attribute__ ((visibility ("default") )) +likwid_rocmmarkerregisterregion_(char* regionTag, 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; + } + } + + rocmon_markerRegisterRegion( tmp ); + free(tmp); +} + +void __attribute__ ((visibility ("default") )) +likwid_rocmmarkerstartregion_(char* regionTag, 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; + } + } + + rocmon_markerStartRegion( tmp ); + free(tmp); +} + +void __attribute__ ((visibility ("default") )) +likwid_rocmmarkerstopregion_(char* regionTag, 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; + } + } + + rocmon_markerStopRegion( tmp ); + free(tmp); +} + +void __attribute__ ((visibility ("default") )) +likwid_rocmmarkerresetregion_(char* regionTag, 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; + } + } + rocmon_markerResetRegion( tmp); + free(tmp); +} +#endif /* LIKWID_WITH_ROCMON */