Skip to content

Commit

Permalink
Merge pull request #117 from TauferLab/cpp_logger_find_package_fix
Browse files Browse the repository at this point in the history
Hotfix: fixes CI by correcting cpp-logger and DLIO profiler/dftracer stuff
  • Loading branch information
JaeseungYeom authored Jul 30, 2024
2 parents 5f9414a + c3ba415 commit fac9b4d
Show file tree
Hide file tree
Showing 17 changed files with 333 additions and 332 deletions.
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if (DYAD_ENABLE_UCX_DATA_RMA)
endif ()

set(DYAD_PROFILER "NONE" CACHE STRING "Profiler to use for DYAD")
set_property(CACHE DYAD_PROFILER PROPERTY STRINGS PERFFLOW_ASPECT CALIPER DLIO_PROFILER NONE)
set_property(CACHE DYAD_PROFILER PROPERTY STRINGS PERFFLOW_ASPECT CALIPER DFTRACER NONE)
set(DYAD_LOGGER "NONE" CACHE STRING "Logger to use for DYAD")
set_property(CACHE DYAD_LOGGER PROPERTY STRINGS FLUX CPP_LOGGER NONE)
set(DYAD_LOGGER_LEVEL "NONE" CACHE STRING "Logging level to use for DYAD")
Expand All @@ -131,8 +131,8 @@ if(DYAD_PROFILER STREQUAL "PERFFLOW_ASPECT")
set(DYAD_PROFILER_PERFFLOW_ASPECT 1)
elseif(DYAD_PROFILER STREQUAL "CALIPER")
set(DYAD_PROFILER_CALIPER 1)
elseif(DYAD_PROFILER STREQUAL "DLIO_PROFILER")
set(DYAD_PROFILER_DLIO_PROFILER 1)
elseif(DYAD_PROFILER STREQUAL "DFTRACER")
set(DYAD_PROFILER_DFTRACER 1)
else()
set(DYAD_PROFILER_NONE 1)
endif()
Expand Down Expand Up @@ -217,7 +217,7 @@ else ()
message(FATAL_ERROR "-- [${PROJECT_NAME}] FluxCore is needed for ${PROJECT_NAME} build")
endif ()
find_package(Jansson 2.10 REQUIRED)
if (${JANSSON_FOUND})
if (${JANSSON_FOUND}) # Note: this find_package does not properly name its '_FOUND' variable. This is the correct name
message(STATUS "[${PROJECT_NAME}] found Jansson at ${JANSSON_INCLUDE_DIRS}")
else ()
message(FATAL_ERROR "-- [${PROJECT_NAME}] Jansson is needed for ${PROJECT_NAME} build")
Expand All @@ -231,7 +231,7 @@ if (DYAD_LOGGER STREQUAL "CPP_LOGGER")
${CPP_LOGGER_PATH} ${cpp-logger_PATH}
$ENV{CPP_LOGGER_DIR} $ENV{cpp-logger_DIR}
$ENV{CPP_LOGGER_PATH} $ENV{cpp-logger_PATH})
if (${CPP_LOGGER_FOUND})
if (${cpp-logger_FOUND})
message(STATUS "[${PROJECT_NAME}] found cpp-logger at ${CPP_LOGGER_INCLUDE_DIRS}")
include_directories(${CPP_LOGGER_INCLUDE_DIRS})
set(DEPENDENCY_LIB ${DEPENDENCY_LIB} ${CPP_LOGGER_LIBRARIES})
Expand All @@ -246,14 +246,14 @@ if(DYAD_PROFILER STREQUAL "PERFFLOW_ASPECT")
else ()
message(FATAL_ERROR "-- [${PROJECT_NAME}] perfflowaspect is not found but selected in cmake options for ${PROJECT_NAME} build")
endif ()
elseif(DYAD_PROFILER STREQUAL "DLIO_PROFILER")
find_package(dlio_profiler REQUIRED IMPORTED)
if (${DLIO_PROFILER_FOUND})
message(STATUS "[${PROJECT_NAME}] found dlio_profiler at ${DLIO_PROFILER_INCLUDE_DIRS}")
include_directories(${DLIO_PROFILER_INCLUDE_DIRS})
set(DEPENDENCY_LIB ${DEPENDENCY_LIB} ${DLIO_PROFILER_LIBRARIES})
elseif(DYAD_PROFILER STREQUAL "DFTRACER")
find_package(dftracer REQUIRED IMPORTED)
if (${DFTRACER_FOUND})
message(STATUS "[${PROJECT_NAME}] found dftracer at ${DFTRACER_INCLUDE_DIRS}")
include_directories(${DFTRACER_INCLUDE_DIRS})
set(DEPENDENCY_LIB ${DEPENDENCY_LIB} ${DFTRACER_LIBRARIES})
else ()
message(FATAL_ERROR "-- [${PROJECT_NAME}] dlio_profiler is not found but selected in cmake options ${PROJECT_NAME} build")
message(FATAL_ERROR "-- [${PROJECT_NAME}] dftracer is not found but selected in cmake options ${PROJECT_NAME} build")
endif ()
endif()
if(DYAD_ENABLE_UCX_DATA OR DYAD_ENABLE_UCX_DATA_RMA)
Expand Down
20 changes: 10 additions & 10 deletions cmake/configure_files/dyad_config.hpp.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#ifndef DYAD_CONFIG_HPP
#define DYAD_CONFIG_HPP

// clang-format off
/* Version string for DYAD */
#define DYAD_PACKAGE_VERSION @DYAD_PACKAGE_VERSION@
#cmakedefine DYAD_GIT_VERSION @DYAD_GIT_VERSION@
// clang-format on

/* Compiler used */
#cmakedefine CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
Expand Down Expand Up @@ -32,7 +34,7 @@
// Profiler
#cmakedefine DYAD_PROFILER_PERFFLOW_ASPECT 1
#cmakedefine DYAD_PROFILER_CALIPER 1
#cmakedefine DYAD_PROFILER_DLIO_PROFILER 1
#cmakedefine DYAD_PROFILER_DFTRACER 1
#cmakedefine DYAD_PROFILER_NONE 1
// Logger
#cmakedefine DYAD_LOGGER_FLUX 1
Expand All @@ -50,22 +52,20 @@

#define DYAD_PATH_DELIM "/"

//#define DYAD_NOOP_MACRO do {} while (0)
// #define DYAD_NOOP_MACRO do {} while (0)
#define DYAD_NOOP_MACRO


// Detect VAR_OPT
// https://stackoverflow.com/questions/48045470/portably-detect-va-opt-support
#if __cplusplus <= 201703 && defined __GNUC__ \
&& !defined __clang__ && !defined __EDG__
#define VA_OPT_SUPPORTED false
#if __cplusplus <= 201703 && defined __GNUC__ && !defined __clang__ && !defined __EDG__
#define VA_OPT_SUPPORTED false
#else
#define PP_THIRD_ARG(a,b,c,...) c
#define VA_OPT_SUPPORTED_I(...) PP_THIRD_ARG(__VA_OPT__(,),true,false,)
#define VA_OPT_SUPPORTED VA_OPT_SUPPORTED_I(?)
#define PP_THIRD_ARG(a, b, c, ...) c
#define VA_OPT_SUPPORTED_I(...) PP_THIRD_ARG (__VA_OPT__ (, ), true, false, )
#define VA_OPT_SUPPORTED VA_OPT_SUPPORTED_I(?)
#endif

#if !defined (DYAD_HASH_SEED) || (DYAD_HASH_SEED <= 0)
#if !defined(DYAD_HASH_SEED) || (DYAD_HASH_SEED <= 0)
#define DYAD_SEED 104723u
#endif

Expand Down
24 changes: 12 additions & 12 deletions pydyad/pydyad/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import enum
from pathlib import Path
import warnings
from dlio_profiler.logger import dlio_logger, fn_interceptor
dlio_log = fn_interceptor("DYAD_PY")
from dftracer.logger import dftracer, dft_fn
dft_log = dft_fn("DYAD_PY")

DYAD_LIB_DIR = None

Expand Down Expand Up @@ -94,7 +94,7 @@ class DTLCommMode(enum.IntEnum):


class Dyad:
@dlio_log.log_init
@dft_log.log_init
def __init__(self):
self.initialized = False
self.dyad_core_lib = None
Expand Down Expand Up @@ -211,7 +211,7 @@ def __init__(self):
self.prod_path = None
self.log_inst = None

@dlio_log.log
@dft_log.log
def init(
self,
debug=False,
Expand All @@ -231,7 +231,7 @@ def init(
dtl_comm_mode=DTLCommMode.DYAD_COMM_RECV,
flux_handle=None
):
self.log_inst = dlio_logger.initialize_log(logfile=None, data_dir=None, process_id=-1)
self.log_inst = dftracer.initialize_log(logfile=None, data_dir=None, process_id=-1)
if self.dyad_init is None:
warnings.warn(
"Trying to initialize DYAD when libdyad_ctx.so was not found",
Expand Down Expand Up @@ -270,7 +270,7 @@ def init(
self.cons_path = Path(self.ctx.contents.cons_managed_path.decode("utf-8")).expanduser().resolve()
self.initialized = True

@dlio_log.log
@dft_log.log
def init_env(
self,
dtl_comm_mode=DTLCommMode.DYAD_COMM_RECV,
Expand Down Expand Up @@ -301,7 +301,7 @@ def init_env(
def __del__(self):
self.finalize()

@dlio_log.log
@dft_log.log
def produce(self, fname):
if self.dyad_produce is None:
warnings.warn(
Expand All @@ -316,7 +316,7 @@ def produce(self, fname):
if int(res) != 0:
raise RuntimeError("Cannot produce data with DYAD!")

@dlio_log.log
@dft_log.log
def get_metadata(self, fname, should_wait=False, raw=False):
if self.dyad_get_metadata is None:
warnings.warn(
Expand All @@ -337,7 +337,7 @@ def get_metadata(self, fname, should_wait=False, raw=False):
return DyadMetadata(mdata, self)
return mdata

@dlio_log.log
@dft_log.log
def free_metadata(self, metadata_wrapper):
if self.dyad_free_metadata is None:
warnings.warn("Trying to free DYAD metadata when libdyad_core.so was not found", RuntimeWarning)
Expand All @@ -348,7 +348,7 @@ def free_metadata(self, metadata_wrapper):
if int(res) != 0:
raise RuntimeError("Could not free DYAD metadata")

@dlio_log.log
@dft_log.log
def consume(self, fname):
if self.dyad_consume is None:
warnings.warn(
Expand All @@ -363,7 +363,7 @@ def consume(self, fname):
if int(res) != 0:
raise RuntimeError("Cannot consume data with DYAD!")

@dlio_log.log
@dft_log.log
def consume_w_metadata(self, fname, metadata_wrapper):
if self.dyad_consume is None:
warnings.warn(
Expand All @@ -379,7 +379,7 @@ def consume_w_metadata(self, fname, metadata_wrapper):
if int(res) != 0:
raise RuntimeError("Cannot consume data with metadata with DYAD!")

@dlio_log.log
@dft_log.log
def finalize(self):
if not self.initialized:
return
Expand Down
6 changes: 3 additions & 3 deletions pydyad/pydyad/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import io
from pathlib import Path

from dlio_profiler.logger import fn_interceptor
dlio_log = fn_interceptor("DYAD_PY")
from dftracer.logger import dft_fn
dft_log = dft_fn("DYAD_PY")
DYAD_IO = None


# The design of dyad_open is based on the PEP for Python's 'with' syntax:
# https://peps.python.org/pep-0343/
@contextmanager
@dlio_log.log
@dft_log.log
def dyad_open(*args, dyad_ctx=None, metadata_wrapper=None, register_dyad_ctx=False, **kwargs):
global DYAD_IO
local_dyad_io = dyad_ctx
Expand Down
3 changes: 2 additions & 1 deletion pydyad/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ classifier =
python_requires = >=3.7
install_requires =
numpy
dlio_profiler_py @ git+https://github.com/hariharan-devarajan/dlio-profiler.git
# dlio_profiler_py @ git+https://github.com/hariharan-devarajan/dlio-profiler.git
pydftracer==1.0.2
36 changes: 19 additions & 17 deletions src/dyad/common/dyad_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#error "no config"
#endif

#ifdef DYAD_PROFILER_DLIO_PROFILER // DLIO_PROFILER
#include <dlio_profiler/dlio_profiler.h>
#ifdef DYAD_PROFILER_DFTRACER // DFTRACER
#include <dftracerr/dftracer.h>
#endif

// clang-format off
#ifdef __cplusplus
#ifdef DYAD_PROFILER_NONE
#define DYAD_CPP_FUNCTION() DYAD_NOOP_MACRO
Expand All @@ -29,12 +30,12 @@
#define DYAD_CPP_REGION_START(name) DYAD_NOOP_MACRO
#define DYAD_CPP_REGION_END(name) DYAD_NOOP_MACRO
#define DYAD_CPP_REGION_UPDATE(name) DYAD_NOOP_MACRO
#elif defined(DYAD_PROFILER_DLIO_PROFILER) // DLIO_PROFILER
#define DYAD_CPP_FUNCTION() DLIO_PROFILER_CPP_FUNCTION()
#define DYAD_CPP_FUNCTION_UPDATE(key, value) DLIO_PROFILER_CPP_FUNCTION_UPDATE((key), (value))
#define DYAD_CPP_REGION_START(name) DLIO_PROFILER_CPP_REGION_START((name))
#define DYAD_CPP_REGION_END(name) DLIO_PROFILER_CPP_REGION_END((name))
#define DYAD_CPP_REGION_UPDATE(name) DLIO_PROFILER_CPP_REGION_DYN_UPDATE((name), (key), (value))
#elif defined(DYAD_PROFILER_DFTRACER) // DFTRACER
#define DYAD_CPP_FUNCTION() DFTRACER_CPP_FUNCTION()
#define DYAD_CPP_FUNCTION_UPDATE(key, value) DFTRACER_CPP_FUNCTION_UPDATE((key), (value))
#define DYAD_CPP_REGION_START(name) DFTRACER_CPP_REGION_START((name))
#define DYAD_CPP_REGION_END(name) DFTRACER_CPP_REGION_END((name))
#define DYAD_CPP_REGION_UPDATE(name) DFTRACER_CPP_REGION_DYN_UPDATE((name), (key), (value))
#endif
#endif

Expand Down Expand Up @@ -70,19 +71,20 @@ extern "C" {
#define DYAD_C_REGION_END(name) DYAD_NOOP_MACRO
#define DYAD_C_REGION_UPDATE_INT(name) DYAD_NOOP_MACRO
#define DYAD_C_REGION_UPDATE_STR(name) DYAD_NOOP_MACRO
#elif defined(DYAD_PROFILER_DLIO_PROFILER) // DLIO_PROFILER
#define DYAD_C_FUNCTION_START() DLIO_PROFILER_C_FUNCTION_START()
#define DYAD_C_FUNCTION_END() DLIO_PROFILER_C_FUNCTION_END()
#define DYAD_C_FUNCTION_UPDATE_INT(key, value) DLIO_PROFILER_C_FUNCTION_UPDATE_INT((key), (value))
#define DYAD_C_FUNCTION_UPDATE_STR(key, value) DLIO_PROFILER_C_FUNCTION_UPDATE_STR((key), (value))
#define DYAD_C_REGION_START(name) DLIO_PROFILER_C_REGION_START((name))
#define DYAD_C_REGION_END(name) DLIO_PROFILER_C_REGION_END((name))
#define DYAD_C_REGION_UPDATE_INT(name) DLIO_PROFILER_C_REGION_UPDATE_INT((name), (key), (value))
#define DYAD_C_REGION_UPDATE_STR(name) DLIO_PROFILER_C_REGION_UPDATE_STR((name), (key), (value))
#elif defined(DYAD_PROFILER_DFTRACER) // DFTRACER
#define DYAD_C_FUNCTION_START() DFTRACER_C_FUNCTION_START()
#define DYAD_C_FUNCTION_END() DFTRACER_C_FUNCTION_END()
#define DYAD_C_FUNCTION_UPDATE_INT(key, value) DFTRACER_C_FUNCTION_UPDATE_INT((key), (value))
#define DYAD_C_FUNCTION_UPDATE_STR(key, value) DFTRACER_C_FUNCTION_UPDATE_STR((key), (value))
#define DYAD_C_REGION_START(name) DFTRACER_C_REGION_START((name))
#define DYAD_C_REGION_END(name) DFTRACER_C_REGION_END((name))
#define DYAD_C_REGION_UPDATE_INT(name) DFTRACER_C_REGION_UPDATE_INT((name), (key), (value))
#define DYAD_C_REGION_UPDATE_STR(name) DFTRACER_C_REGION_UPDATE_STR((name), (key), (value))
#endif

#ifdef __cplusplus
}
#endif
// clang-format on

#endif // DYAD_COMMON_DYAD_PROFILER_H
4 changes: 2 additions & 2 deletions src/dyad/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ if(DYAD_PROFILER STREQUAL "PERFFLOW_ASPECT")
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${perfflowaspect_INCLUDE_DIRS})
target_compile_definitions(${PROJECT_NAME}_core PRIVATE DYAD_PERFFLOW=1)
endif()
if(DYAD_PROFILER STREQUAL "DLIO_PROFILER")
target_link_libraries(${PROJECT_NAME}_core PRIVATE ${DLIO_PROFILER_LIBRARIES})
if(DYAD_PROFILER STREQUAL "DFTRACER")
target_link_libraries(${PROJECT_NAME}_core PRIVATE ${DFTRACER_LIBRARIES})
endif()
install(
TARGETS ${PROJECT_NAME}_core ${PROJECT_NAME}_ctx
Expand Down
Loading

0 comments on commit fac9b4d

Please sign in to comment.