Skip to content

Commit

Permalink
Applies results of autoformatting to repo + manually divides includes…
Browse files Browse the repository at this point in the history
… into groups
  • Loading branch information
ilumsden committed Nov 13, 2024
1 parent 4026510 commit cdec006
Show file tree
Hide file tree
Showing 28 changed files with 927 additions and 874 deletions.
2 changes: 1 addition & 1 deletion include/dyad/stream/dyad_params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace dyad
struct dyad_params {
bool m_debug;
/** Indicate if the storage associated with the managed path is shared
* (i.e. visible to all ranks) */
* (i.e. visible to all ranks) */
bool m_shared_storage;
/// Indicate if reinitialization is required even if already initinialized
bool m_reinit;
Expand Down
169 changes: 76 additions & 93 deletions include/dyad/stream/dyad_stream_api.hpp

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions include/dyad/stream/dyad_stream_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#error "no config"
#endif

#include <climits>
#include <iostream>
#include <string>
#include <climits>

#include <dyad/stream/dyad_params.hpp>

Expand Down Expand Up @@ -52,12 +52,12 @@ class dyad_stream_core
bool chk_initialized () const;

bool chk_fsync_write () const;
bool cmp_canonical_path_prefix (bool is_prod, const char* const __restrict__ path);
bool cmp_canonical_path_prefix (bool is_prod, const char *const __restrict__ path);
std::string get_upath () const;

int file_lock_exclusive(int fd) const;
int file_lock_shared(int fd) const;
int file_unlock(int fd) const;
int file_lock_exclusive (int fd) const;
int file_lock_shared (int fd) const;
int file_unlock (int fd) const;

private:
const dyad_ctx *m_ctx;
Expand Down
16 changes: 8 additions & 8 deletions src/dyad/common/dyad_dtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
extern "C" {
#endif


enum dyad_dtl_mode { DYAD_DTL_UCX = 0,
DYAD_DTL_FLUX_RPC = 1,
DYAD_DTL_DEFAULT = 1,
DYAD_DTL_END = 2 };
enum dyad_dtl_mode {
DYAD_DTL_UCX = 0,
DYAD_DTL_FLUX_RPC = 1,
DYAD_DTL_DEFAULT = 1,
DYAD_DTL_END = 2
};
typedef enum dyad_dtl_mode dyad_dtl_mode_t;

static const char* dyad_dtl_mode_name[DYAD_DTL_END+1] __attribute__((unused))
= {"UCX", "FLUX_RPC", "DTL_UNKNOWN"};
static const char* dyad_dtl_mode_name[DYAD_DTL_END + 1]
__attribute__ ((unused)) = {"UCX", "FLUX_RPC", "DTL_UNKNOWN"};

enum dyad_dtl_comm_mode {
DYAD_COMM_NONE = 0, // Sanity check value for when
Expand All @@ -30,7 +31,6 @@ enum dyad_dtl_comm_mode {
};
typedef enum dyad_dtl_comm_mode dyad_dtl_comm_mode_t;


#define DYAD_DTL_RPC_NAME "dyad.fetch"

struct dyad_dtl;
Expand Down
228 changes: 118 additions & 110 deletions src/dyad/common/dyad_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,133 +6,141 @@
#error "no config"
#endif

#include <dyad/common/dyad_structures.h>
#include <sys/types.h>
#include <unistd.h>

#include <dyad/common/dyad_structures.h>

#ifdef __cplusplus
extern "C" {
#endif

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

//=============================================================================
#ifdef DYAD_LOGGER_NO_LOG
//=============================================================================
#define DYAD_LOGGER_INIT() DYAD_NOOP_MACRO
#define DYAD_LOG_STDERR(...) DYAD_NOOP_MACRO
#define DYAD_LOG_STDOUT(...) DYAD_NOOP_MACRO
#define DYAD_LOG_ERROR(dyad_ctx, ...) DYAD_NOOP_MACRO
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_NOOP_MACRO
#define DYAD_LOG_INFO(dyad_ctx, ...) DYAD_NOOP_MACRO
#define DYAD_LOG_DEBUG(dyad_ctx, ...) DYAD_NOOP_MACRO
#define DYAD_LOGGER_INIT() DYAD_NOOP_MACRO
#define DYAD_LOG_STDERR(...) DYAD_NOOP_MACRO
#define DYAD_LOG_STDOUT(...) DYAD_NOOP_MACRO
#define DYAD_LOG_ERROR(dyad_ctx, ...) DYAD_NOOP_MACRO
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_NOOP_MACRO
#define DYAD_LOG_INFO(dyad_ctx, ...) DYAD_NOOP_MACRO
#define DYAD_LOG_DEBUG(dyad_ctx, ...) DYAD_NOOP_MACRO
#define DYAD_LOG_STDOUT_REDIRECT(fpath) DYAD_NOOP_MACRO
#define DYAD_LOG_STDERR_REDIRECT(fpath) DYAD_NOOP_MACRO
//=============================================================================
#else
//=============================================================================
#define DYAD_LOG_STDERR(...) fprintf(stderr, __VA_ARGS__);
#define DYAD_LOG_STDOUT(...) fprintf(stdout, __VA_ARGS__);

#ifdef DYAD_LOGGER_FLUX // FLUX -----------------------------------------------
#define DYAD_LOGGER_INIT() ;
#define DYAD_LOG_STDOUT_REDIRECT(fpath) freopen ((fpath), "a+", stdout);
#define DYAD_LOG_STDERR_REDIRECT(fpath) freopen ((fpath), "a+", stderr);

#ifdef DYAD_UTIL_LOGGER
#ifdef DYAD_LOGGER_LEVEL_DEBUG
#define DYAD_LOG_DEBUG(dyad_ctx, ...) DYAD_LOG_STDERR(__VA_ARGS__)
#else
#define DYAD_LOG_DEBUG(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_INFO
#define DYAD_LOG_INFO(dyad_ctx, ...) DYAD_LOG_STDOUT(__VA_ARGS__)
#else
#define DYAD_LOG_INFO(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_WARN
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_LOG_STDOUT(__VA_ARGS__)
#else
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_ERROR
#define DYAD_LOG_ERROR(dyad_ctx, ...) DYAD_LOG_STDERR(__VA_ARGS__)
#else
#define DYAD_LOG_ERROR(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif
#else // DYAD_UTIL_LOGGER
#include <flux/core.h>
#ifdef DYAD_LOGGER_LEVEL_DEBUG
#define DYAD_LOG_DEBUG(dyad_ctx, ...) flux_log ((flux_t*)(((dyad_ctx_t*) dyad_ctx)->h), LOG_DEBUG, __VA_ARGS__);
#else
#define DYAD_LOG_DEBUG(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_INFO
#define DYAD_LOG_INFO(dyad_ctx, ...) flux_log ((flux_t*)(((dyad_ctx_t*) dyad_ctx)->h), LOG_INFO, __VA_ARGS__);
#else
#define DYAD_LOG_INFO(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_WARN
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_NOOP_MACRO
#else
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_ERROR
#define DYAD_LOG_ERROR(dyad_ctx, ...) flux_log_error ((flux_t*)(((dyad_ctx_t*) dyad_ctx)->h), __VA_ARGS__);
#else
#define DYAD_LOG_ERROR(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif
#endif // DYAD_UTIL_LOGGER
#elif defined(DYAD_LOGGER_CPP_LOGGER) // CPP_LOGGER ---------------------------
#include <cpp-logger/clogger.h>

#define DYAD_LOGGER_NAME "DYAD"

#ifdef DYAD_LOGGER_LEVEL_DEBUG
#define DYAD_LOGGER_INIT() cpp_logger_clog_level(CPP_LOGGER_DEBUG, DYAD_LOGGER_NAME);
#elif defined(DYAD_LOGGER_LEVEL_INFO)
#define DYAD_LOGGER_INIT() cpp_logger_clog_level(CPP_LOGGER_INFO, DYAD_LOGGER_NAME);
#elif defined(DYAD_LOGGER_LEVEL_WARN)
#define DYAD_LOGGER_INIT() cpp_logger_clog_level(CPP_LOGGER_WARN, DYAD_LOGGER_NAME);
#else
#define DYAD_LOGGER_INIT() cpp_logger_clog_level(CPP_LOGGER_ERROR, DYAD_LOGGER_NAME);
#endif

#define DYAD_LOG_STDOUT_REDIRECT(fpath) freopen ((fpath), "a+", stdout);
#define DYAD_LOG_STDERR_REDIRECT(fpath) freopen ((fpath), "a+", stderr);

#ifdef DYAD_LOGGER_LEVEL_DEBUG
#define DYAD_LOG_DEBUG(dyad_ctx, ...) cpp_logger_clog(CPP_LOGGER_DEBUG, DYAD_LOGGER_NAME, __VA_ARGS__);
#else
#define DYAD_LOG_DEBUG(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_INFO
#define DYAD_LOG_INFO(dyad_ctx, ...) cpp_logger_clog(CPP_LOGGER_INFO, DYAD_LOGGER_NAME, __VA_ARGS__);
#else
#define DYAD_LOG_INFO(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_WARN
#define DYAD_LOG_WARN(dyad_ctx, ...) cpp_logger_clog(CPP_LOGGER_WARN, DYAD_LOGGER_NAME, __VA_ARGS__);
#else
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_ERROR
#define DYAD_LOG_ERROR(dyad_ctx, ...) cpp_logger_clog(CPP_LOGGER_ERROR, DYAD_LOGGER_NAME, __VA_ARGS__);
#else
#define DYAD_LOG_ERROR(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif
#endif // DYAD_LOGGER_FLUX ----------------------------------------------------
#define DYAD_LOG_STDERR(...) fprintf (stderr, __VA_ARGS__);
#define DYAD_LOG_STDOUT(...) fprintf (stdout, __VA_ARGS__);

#ifdef DYAD_LOGGER_FLUX // FLUX -----------------------------------------------
#define DYAD_LOGGER_INIT() ;
#define DYAD_LOG_STDOUT_REDIRECT(fpath) freopen ((fpath), "a+", stdout);
#define DYAD_LOG_STDERR_REDIRECT(fpath) freopen ((fpath), "a+", stderr);

#ifdef DYAD_UTIL_LOGGER
#ifdef DYAD_LOGGER_LEVEL_DEBUG
#define DYAD_LOG_DEBUG(dyad_ctx, ...) DYAD_LOG_STDERR (__VA_ARGS__)
#else
#define DYAD_LOG_DEBUG(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_INFO
#define DYAD_LOG_INFO(dyad_ctx, ...) DYAD_LOG_STDOUT (__VA_ARGS__)
#else
#define DYAD_LOG_INFO(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_WARN
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_LOG_STDOUT (__VA_ARGS__)
#else
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_ERROR
#define DYAD_LOG_ERROR(dyad_ctx, ...) DYAD_LOG_STDERR (__VA_ARGS__)
#else
#define DYAD_LOG_ERROR(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif
#else // DYAD_UTIL_LOGGER
#include <flux/core.h>
#ifdef DYAD_LOGGER_LEVEL_DEBUG
#define DYAD_LOG_DEBUG(dyad_ctx, ...) \
flux_log ((flux_t *)(((dyad_ctx_t *)dyad_ctx)->h), LOG_DEBUG, __VA_ARGS__);
#else
#define DYAD_LOG_DEBUG(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_INFO
#define DYAD_LOG_INFO(dyad_ctx, ...) \
flux_log ((flux_t *)(((dyad_ctx_t *)dyad_ctx)->h), LOG_INFO, __VA_ARGS__);
#else
#define DYAD_LOG_INFO(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_WARN
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_NOOP_MACRO
#else
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_ERROR
#define DYAD_LOG_ERROR(dyad_ctx, ...) \
flux_log_error ((flux_t *)(((dyad_ctx_t *)dyad_ctx)->h), __VA_ARGS__);
#else
#define DYAD_LOG_ERROR(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif
#endif // DYAD_UTIL_LOGGER
#elif defined(DYAD_LOGGER_CPP_LOGGER) // CPP_LOGGER ---------------------------
#include <cpp-logger/clogger.h>

#define DYAD_LOGGER_NAME "DYAD"

#ifdef DYAD_LOGGER_LEVEL_DEBUG
#define DYAD_LOGGER_INIT() cpp_logger_clog_level (CPP_LOGGER_DEBUG, DYAD_LOGGER_NAME);
#elif defined(DYAD_LOGGER_LEVEL_INFO)
#define DYAD_LOGGER_INIT() cpp_logger_clog_level (CPP_LOGGER_INFO, DYAD_LOGGER_NAME);
#elif defined(DYAD_LOGGER_LEVEL_WARN)
#define DYAD_LOGGER_INIT() cpp_logger_clog_level (CPP_LOGGER_WARN, DYAD_LOGGER_NAME);
#else
#define DYAD_LOGGER_INIT() cpp_logger_clog_level (CPP_LOGGER_ERROR, DYAD_LOGGER_NAME);
#endif

#define DYAD_LOG_STDOUT_REDIRECT(fpath) freopen ((fpath), "a+", stdout);
#define DYAD_LOG_STDERR_REDIRECT(fpath) freopen ((fpath), "a+", stderr);

#ifdef DYAD_LOGGER_LEVEL_DEBUG
#define DYAD_LOG_DEBUG(dyad_ctx, ...) \
cpp_logger_clog (CPP_LOGGER_DEBUG, DYAD_LOGGER_NAME, __VA_ARGS__);
#else
#define DYAD_LOG_DEBUG(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_INFO
#define DYAD_LOG_INFO(dyad_ctx, ...) \
cpp_logger_clog (CPP_LOGGER_INFO, DYAD_LOGGER_NAME, __VA_ARGS__);
#else
#define DYAD_LOG_INFO(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_WARN
#define DYAD_LOG_WARN(dyad_ctx, ...) \
cpp_logger_clog (CPP_LOGGER_WARN, DYAD_LOGGER_NAME, __VA_ARGS__);
#else
#define DYAD_LOG_WARN(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif

#ifdef DYAD_LOGGER_LEVEL_ERROR
#define DYAD_LOG_ERROR(dyad_ctx, ...) \
cpp_logger_clog (CPP_LOGGER_ERROR, DYAD_LOGGER_NAME, __VA_ARGS__);
#else
#define DYAD_LOG_ERROR(dyad_ctx, ...) DYAD_NOOP_MACRO
#endif
#endif // DYAD_LOGGER_FLUX ----------------------------------------------------
//=============================================================================
#endif // DYAD_LOGGER_NO_LOG
#endif // DYAD_LOGGER_NO_LOG
//=============================================================================

#ifdef __cplusplus
Expand Down
43 changes: 21 additions & 22 deletions src/dyad/common/dyad_rc.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ extern "C" {
#endif

enum dyad_core_return_codes {
DYAD_RC_OK = 0, // Operation worked correctly
DYAD_RC_SYSFAIL = -1, // Some sys call or C standard
// library call failed
DYAD_RC_OK = 0, // Operation worked correctly
DYAD_RC_SYSFAIL = -1, // Some sys call or C standard
// library call failed
// Internal
DYAD_RC_NOCTX = -1000, // No DYAD Context found
DYAD_RC_BADMETADATA = -1001, // Cannot create/populate a DYAD response
Expand All @@ -42,27 +42,26 @@ enum dyad_core_return_codes {
DYAD_RC_BAD_CLI_PARSE = -1009, // Trying to parse CLI arguments failed
DYAD_RC_BADBUF = -1010, // Invalid buffer/pointer passed to function


// FLUX
DYAD_RC_FLUXFAIL = -2000, // Some Flux function failed
DYAD_RC_BADCOMMIT = -2001, // Flux KVS commit didn't work
DYAD_RC_NOTFOUND = -2002, // Flux KVS lookup didn't work
DYAD_RC_BADFETCH = -2003, // Flux KVS commit didn't work
DYAD_RC_BADRPC = -2004, // Flux RPC pack or get didn't work
DYAD_RC_BADPACK = -2005, // JSON packing failed
DYAD_RC_BADUNPACK = -2006, // JSON unpacking failed
DYAD_RC_RPC_FINISHED = -2007, // The Flux RPC responded with ENODATA (i.e.,
// end of stream) sooner than expected
DYAD_RC_FLUXFAIL = -2000, // Some Flux function failed
DYAD_RC_BADCOMMIT = -2001, // Flux KVS commit didn't work
DYAD_RC_NOTFOUND = -2002, // Flux KVS lookup didn't work
DYAD_RC_BADFETCH = -2003, // Flux KVS commit didn't work
DYAD_RC_BADRPC = -2004, // Flux RPC pack or get didn't work
DYAD_RC_BADPACK = -2005, // JSON packing failed
DYAD_RC_BADUNPACK = -2006, // JSON unpacking failed
DYAD_RC_RPC_FINISHED = -2007, // The Flux RPC responded with ENODATA (i.e.,
// end of stream) sooner than expected

//UCX
DYAD_RC_UCXINIT_FAIL = -3001, // UCX initialization failed
DYAD_RC_UCXWAIT_FAIL = -3002, // UCX wait (either custom or
// 'ucp_worker_wait') failed
DYAD_RC_UCXEP_FAIL = -3003, // An operation on a ucp_ep_h failed
DYAD_RC_UCXCOMM_FAIL = -3004, // UCX communication routine failed
DYAD_RC_UCXMMAP_FAIL = -3005, // Failed to perform operations with ucp_mem_map
DYAD_RC_UCXRKEY_PACK_FAILED = -3006, // Failed to perform operations with ucp_mem_map
DYAD_RC_UCXRKEY_UNPACK_FAILED = -3007, // Failed to perform operations with ucp_mem_map
// UCX
DYAD_RC_UCXINIT_FAIL = -3001, // UCX initialization failed
DYAD_RC_UCXWAIT_FAIL = -3002, // UCX wait (either custom or
// 'ucp_worker_wait') failed
DYAD_RC_UCXEP_FAIL = -3003, // An operation on a ucp_ep_h failed
DYAD_RC_UCXCOMM_FAIL = -3004, // UCX communication routine failed
DYAD_RC_UCXMMAP_FAIL = -3005, // Failed to perform operations with ucp_mem_map
DYAD_RC_UCXRKEY_PACK_FAILED = -3006, // Failed to perform operations with ucp_mem_map
DYAD_RC_UCXRKEY_UNPACK_FAILED = -3007, // Failed to perform operations with ucp_mem_map

};

Expand Down
Loading

0 comments on commit cdec006

Please sign in to comment.