Skip to content

Commit

Permalink
Merge pull request #35 from uiuc-hpc/hdf5-pnetcdf-new-funcs
Browse files Browse the repository at this point in the history
Automatic tracing wrapper generation
  • Loading branch information
wangvsa authored Dec 10, 2024
2 parents 0aa0eaf + a127e8b commit a99a3b0
Show file tree
Hide file tree
Showing 34 changed files with 20,923 additions and 1,251 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,9 @@ install
/build/
.cache

# IDE-specific
.idea/
/cmake-build-debug/

# clangd database
compile_commands.json
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ include_directories(${PROJECT_BINARY_DIR})
#------------------------------------------------------------------------------
# Version information
#------------------------------------------------------------------------------
set(RECORDER_VERSION_MAJOR "2")
set(RECORDER_VERSION_MINOR "5")
set(RECORDER_VERSION_PATCH "2")
set(RECORDER_VERSION_MAJOR "3")
set(RECORDER_VERSION_MINOR "0")
set(RECORDER_VERSION_PATCH "0")
set(RECORDER_PACKAGE "recorder")
set(RECORDER_PACKAGE_NAME "RECORDER")
set(RECORDER_PACKAGE_VERSION "${RECORDER_VERSION_MAJOR}.${RECORDER_VERSION_MINOR}.${RECORDER_VERSION_PATCH}")
Expand All @@ -15,6 +15,13 @@ set(RECORDER_PACKAGE_VERSION_MINOR "${RECORDER_VERSION_PATCH}")
set(RECORDER_PACKAGE_STRING "${RECORDER_PACKAGE_NAME} ${RECORDER_PACKAGE_VERSION}")
set(RECORDER_PACKAGE_TARNAME "${RECORDER_PACKAGE}")


# ignore warning message
if(POLICY CMP0074)
cmake_policy(SET CMP0074 OLD)
endif()


#------------------------------------------------------------------------------
# Setup install and output Directories
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -124,6 +131,10 @@ option(RECORDER_ENABLE_CUDA_TRACE "Enable tracing of CUDA kernels." OFF)
option(RECORDER_ENABLE_FCNTL_TRACE "Enable tracing of fcntl()." ON)
option(RECORDER_INSTALL_TESTS "Enable installation of tests." OFF)


set(PNETCDF_INSTALL_PATH "/usr" CACHE STRING "Build Recorder with PnetCDF")


#mark_as_advanced(RECORDER_ENABLE_CUDA_TRACE)
#mark_as_advanced(RECORDER_ENABLE_FCNTL_TRACE)

Expand Down
5 changes: 5 additions & 0 deletions docs/source/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ is currently under active development.

- MPI
- HDF5
- PnetCDF (optional) - Needed for PnetCDF tracing
- Arrow (optional) > 5.0.0 - Needed for building Parquet convertor.
- CUDA (optional) - Needed for CUDA kernels interception.


*Note that Recorder and the applications you intend to trace must be
compiled with the same version of HDF5 and MPI.*

Expand Down Expand Up @@ -44,6 +46,9 @@ need to use ``-DCMAKE_PREFIX_PATH`` to indicate their locations:
-DCMAKE_INSTALL_PREFIX=[install location] \
-DCMAKE_PREFIX_PATH=[semicolon separated depedencies dir]
Recorder can also be built with PnetCDF to trace PnetCDF calls, use `-DRECORDER_WITH_PNETCDF=/path/to/pnetcdf/install`
to build Recorder with the specified PnetCDF.

(2) Intercepting ``fcntl()`` call:

Since v2.1.7, ``fcntl(int fd, int cmd, ...)`` is intercepted. The
Expand Down
2,134 changes: 2,049 additions & 85 deletions include/recorder-gotcha.h

Large diffs are not rendered by default.

722 changes: 686 additions & 36 deletions include/recorder-logger.h

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion include/recorder-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ double recorder_wtime(void); // return the timestamp
char* itoa(off64_t val); // convert an integer to string
char* ftoa(double val); // convert a float to string
char* ptoa(const void* ptr); // convert a pointer to string
char* strtoa(const char* ptr); // convert a char* to string (safer strdup)
char* arrtoa(size_t arr[], int count); // convert an array of size_t to a string
char** assemble_args_list(int arg_count, ...);
const char* get_function_name_by_id(int id);
unsigned char get_function_id_by_name(const char* name);
int get_function_id_by_name(const char* name);
char* realrealpath(const char* path); // return the absolute path (mapped to id in string)
int mkpath(char* file_path, mode_t mode); // recursive mkdir()

Expand Down
6 changes: 5 additions & 1 deletion include/recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#define RECORDER_MPIIO_TRACING "RECORDER_MPIIO_TRACING"
#define RECORDER_MPI_TRACING "RECORDER_MPI_TRACING"
#define RECORDER_HDF5_TRACING "RECORDER_HDF5_TRACING"
#define RECORDER_PNETCDF_TRACING "RECORDER_PNETCDF_TRACING"
#define RECORDER_NETCDF_TRACING "RECORDER_NETCDF_TRACING"


/**
Expand All @@ -49,6 +51,8 @@
*
*/
#define RECORDER_INTERCEPTOR_PROLOGUE_CORE(ret, func, real_args) \
/*printf("chen intercept %s\n", #func);*/\
/*fflush(stdout);*/\
Record *record = recorder_malloc(sizeof(Record)); \
record->func_id = get_function_id_by_name(#func); \
record->tid = recorder_gettid(); \
Expand All @@ -61,7 +65,7 @@
if (sizeof(ret)) { \
record->res = malloc(sizeof(ret)); \
memcpy(record->res, &res, sizeof(ret)); \
}
}

// Fortran wrappers call this
// ierr is of type MPI_Fint*, set only for fortran calls
Expand Down
43 changes: 43 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,47 @@ else()
message(STATUS, "HDF5 not found")
endif()

# PnetCDF is not a CMAKE project, we use find_path() to locate it
# this requires users to set -DRECORDER_WITH_PNETCDF=/xx/xx/
find_path(PNETCDF_INCLUDE_DIRS pnetcdf.h ${RECORDER_WITH_PNETCDF}/include)
find_path(PNETCDF_LIBRARY_FOUND libpnetcdf.so ${RECORDER_WITH_PNETCDF}/lib)
if(PNETCDF_INCLUDE_DIRS AND PNETCDF_LIBRARY_FOUND)
message("-- " "Found PnetCDF:" ${RECORDER_WITH_PNETCDF})
set(RECORDER_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/recorder-pnetcdf.c
${RECORDER_SRCS}
)
include_directories(${PNETCDF_INCLUDE_DIRS})
set(PNETCDF_LIBRARIES ${RECORDER_WITH_PNETCDF}/lib/libpnetcdf.so)
set(RECORDER_EXT_INCLUDE_DEPENDENCIES ${PNETCDF_INCLUDE_DIRS}
${RECORDER_EXT_INCLUDE_DEPENDENCIES})
set(RECORDER_EXT_LIB_DEPENDENCIES
${PNETCDF_LIBRARIES} ${RECORDER_EXT_LIB_DEPENDENCIES})
else()
message("-- " "PnetCDF not found. Will build Recorder without it.")
endif()

# Look for NetCDF
# -DRECORDER_WITH_NETCDF=/xx/xx/
find_path(NETCDF_INCLUDE_DIRS netcdf.h ${RECORDER_WITH_NETCDF}/include)
find_path(NETCDF_LIBRARY_FOUND libnetcdf.so ${RECORDER_WITH_NETCDF}/lib)
if(NETCDF_INCLUDE_DIRS AND NETCDF_LIBRARY_FOUND)
message("-- " "Found NetCDF:" ${RECORDER_WITH_NETCDF})
set(RECORDER_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/recorder-netcdf.c
${RECORDER_SRCS}
)
include_directories(${NETCDF_INCLUDE_DIRS})
set(NETCDF_LIBRARIES ${RECORDER_WITH_NETCDF}/lib/libnetcdf.so)
set(RECORDER_EXT_INCLUDE_DEPENDENCIES ${NETCDF_INCLUDE_DIRS}
${RECORDER_EXT_INCLUDE_DEPENDENCIES})
set(RECORDER_EXT_LIB_DEPENDENCIES
${NETCDF_LIBRARIES} ${RECORDER_EXT_LIB_DEPENDENCIES})
else()
message("-- " "NetCDF not found. Will build Recorder without it.")
endif()


find_package(MPI REQUIRED)
if(MPI_FOUND)
include_directories(${MPI_CXX_INCLUDE_DIRS})
Expand Down Expand Up @@ -129,6 +170,8 @@ target_compile_definitions(recorder
PRIVATE $<$<BOOL:${HAVE___LXSTAT64}>:HAVE___LXSTAT64>
PRIVATE $<$<BOOL:${HAVE___FXSTAT}>:HAVE___FXSTAT>
PRIVATE $<$<BOOL:${HAVE___FXSTAT64}>:HAVE___FXSTAT64>
PRIVATE $<$<AND:$<BOOL:${PNETCDF_INCLUDE_DIRS}>,$<BOOL:${PNETCDF_LIBRARY_FOUND}>>:RECORDER_WITH_PNETCDF>
PRIVATE $<$<AND:$<BOOL:${NETCDF_INCLUDE_DIRS}>,$<BOOL:${NETCDF_LIBRARY_FOUND}>>:RECORDER_WITH_NETCDF>
PRIVATE $<$<BOOL:${RECORDER_ENABLE_FCNTL_TRACE}>:RECORDER_ENABLE_FCNTL_TRACE>
PRIVATE $<$<BOOL:${RECORDER_ENABLE_CUDA_TRACE}>:RECORDER_ENABLE_CUDA_TRACE>
)
Expand Down
Loading

0 comments on commit a99a3b0

Please sign in to comment.