Skip to content

Commit

Permalink
Merge pull request #124 from TauferLab/autoformatting
Browse files Browse the repository at this point in the history
Adds scripts, Dockerfiles, and GitHub Actions CI for checking formatting and autoformatting
  • Loading branch information
wangvsa authored Dec 17, 2024
2 parents 19f8f33 + 9fcd6f4 commit ceb0f6f
Show file tree
Hide file tree
Showing 39 changed files with 3,777 additions and 3,426 deletions.
5 changes: 4 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ TabWidth: '4'
UseTab: Never
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterDefinitionReturnType: None
ContinuationIndentWidth: Always
ContinuationIndentWidth: '4'
IncludeBlocks: 'Preserve'
SortIncludes: 'CaseSensitive'
InsertNewlineAtEOF: 'true'
25 changes: 25 additions & 0 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check code formatting

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
cpp-format-check:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4

- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
clang-format-17
- name: Test formatting
run: |
./scripts/formatting/check-formatting.sh /usr/bin/clang-format-17
7 changes: 7 additions & 0 deletions docs/developer_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ etiquette:
* `The 'Contributing' Page from the Flux Framework's ReadTheDocs <https://flux-framework.readthedocs.io/en/latest/contributing.html>`_
* `The Flux Coding Style Guide <https://github.com/flux-framework/rfc/blob/master/spec_7.rst>`_ (used for C code)
* `The black Coding Style Guide <https://black.readthedocs.io/en/stable/the_black_code_style/index.html>`_ (used for Python code)

Besides the broader Flux contribution guidelines above, we also expect C/C++ :code:`#include`
directives to be grouped. Each group should be separated by one newline.
Includes for external tools, system headers, and the C++
Standard Library should be placed in one group, and includes for internal DYAD headers
should be placed in another group. The group for external headers should be placed
before the group for internal headers.
26 changes: 12 additions & 14 deletions include/dyad/client/dyad_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
extern "C" {
#endif
#if DYAD_PERFFLOW
#define DYAD_CORE_FUNC_MODS __attribute__((annotate("@critical_path()"))) static
#define DYAD_CORE_FUNC_MODS __attribute__ ((annotate ("@critical_path()"))) static
#else
#define DYAD_CORE_FUNC_MODS static inline
#endif

struct dyad_metadata {
char *fpath;
uint32_t owner_rank;
char *fpath;
uint32_t owner_rank;
};
typedef struct dyad_metadata dyad_metadata_t;

Expand All @@ -47,8 +47,7 @@ typedef struct dyad_metadata dyad_metadata_t;
*
* @return An error code from dyad_rc.h
*/
DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t dyad_produce(dyad_ctx_t *ctx,
const char *fname);
DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t dyad_produce (dyad_ctx_t *ctx, const char *fname);

/**
* @brief Obtain DYAD metadata for a file in the consumer-managed directory
Expand All @@ -61,12 +60,12 @@ DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t dyad_produce(dyad_ctx_t *ctx,
*
* @return An error code from dyad_rc.h
*/
DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t
dyad_get_metadata(dyad_ctx_t *ctx, const char *fname, bool should_wait,
dyad_metadata_t **mdata);
DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t dyad_get_metadata (dyad_ctx_t *ctx,
const char *fname,
bool should_wait,
dyad_metadata_t **mdata);

DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t
dyad_free_metadata(dyad_metadata_t **mdata);
DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t dyad_free_metadata (dyad_metadata_t **mdata);

/**
* @brief Wrapper function that performs all the common tasks needed
Expand All @@ -76,8 +75,7 @@ dyad_free_metadata(dyad_metadata_t **mdata);
*
* @return An error code from dyad_rc.h
*/
DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t dyad_consume(dyad_ctx_t *ctx,
const char *fname);
DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t dyad_consume (dyad_ctx_t *ctx, const char *fname);

/**
* @brief Wrapper function that performs all the common tasks needed
Expand All @@ -89,8 +87,8 @@ DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t dyad_consume(dyad_ctx_t *ctx,
*
* @return An error code from dyad_rc.h
*/
DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t dyad_consume_w_metadata(
dyad_ctx_t *ctx, const char *fname, const dyad_metadata_t *mdata);
DYAD_PFA_ANNOTATE DYAD_DLL_EXPORTED dyad_rc_t
dyad_consume_w_metadata (dyad_ctx_t *ctx, const char *fname, const dyad_metadata_t *mdata);

#ifdef __cplusplus
}
Expand Down
16 changes: 8 additions & 8 deletions include/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
43 changes: 21 additions & 22 deletions include/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
2 changes: 1 addition & 1 deletion include/dyad/common/dyad_structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
struct dyad_ctx;
typedef struct dyad_ctx dyad_ctx_t;

#endif /* DYAD_COMMON_STRUCTURES_H */
#endif /* DYAD_COMMON_STRUCTURES_H */
46 changes: 27 additions & 19 deletions include/dyad/core/dyad_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ extern "C" {

DYAD_DLL_EXPORTED extern const struct dyad_ctx dyad_ctx_default;

DYAD_DLL_EXPORTED dyad_ctx_t *dyad_ctx_get();
DYAD_DLL_EXPORTED void dyad_ctx_init(dyad_dtl_comm_mode_t dtl_comm_mode,
void *flux_handle);
DYAD_DLL_EXPORTED void dyad_ctx_fini();
DYAD_DLL_EXPORTED dyad_ctx_t *dyad_ctx_get ();
DYAD_DLL_EXPORTED void dyad_ctx_init (dyad_dtl_comm_mode_t dtl_comm_mode, void *flux_handle);
DYAD_DLL_EXPORTED void dyad_ctx_fini ();

/**
* @brief Intialize the DYAD context
Expand All @@ -47,37 +46,46 @@ DYAD_DLL_EXPORTED void dyad_ctx_fini();
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_init(
bool debug, bool check, bool shared_storage, bool reinit,
bool async_publish, bool fsync_write, unsigned int key_depth,
unsigned int key_bins, unsigned int service_mux, const char *kvs_namespace,
const char *prod_managed_path, const char *cons_managed_path,
bool relative_to_managed_path, const char *dtl_mode_str,
const dyad_dtl_comm_mode_t dtl_comm_mode, void *flux_handle);
DYAD_DLL_EXPORTED dyad_rc_t dyad_init (bool debug,
bool check,
bool shared_storage,
bool reinit,
bool async_publish,
bool fsync_write,
unsigned int key_depth,
unsigned int key_bins,
unsigned int service_mux,
const char *kvs_namespace,
const char *prod_managed_path,
const char *cons_managed_path,
bool relative_to_managed_path,
const char *dtl_mode_str,
const dyad_dtl_comm_mode_t dtl_comm_mode,
void *flux_handle);

/**
* @brief Intialize the DYAD context using environment variables
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t
dyad_init_env(const dyad_dtl_comm_mode_t dtl_comm_mode, void *flux_handle);
DYAD_DLL_EXPORTED dyad_rc_t dyad_init_env (const dyad_dtl_comm_mode_t dtl_comm_mode,
void *flux_handle);

/**
* @brief Reset producer path. Can be used by the module
* @param[in] producer path string
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_prod_path(const char *path);
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_prod_path (const char *path);

/**
* @brief Reset consumer path. Can be used by the module
* @param[in] consumer path string
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_cons_path(const char *path);
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_cons_path (const char *path);

/**
* @brief Reset dtl mode. Can be used by the module
Expand All @@ -86,23 +94,23 @@ DYAD_DLL_EXPORTED dyad_rc_t dyad_set_cons_path(const char *path);
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_and_init_dtl_mode(
const char *dtl_mode_name, dyad_dtl_comm_mode_t dtl_comm_mode);
DYAD_DLL_EXPORTED dyad_rc_t dyad_set_and_init_dtl_mode (const char *dtl_mode_name,
dyad_dtl_comm_mode_t dtl_comm_mode);

/**
* Reset the contents of the ctx to the default values and deallocate
* internal objects linked. However, do not destroy the ctx object itself.
* This is needed for wrapper to handle dyad exceptions as the wrapper requires
* ctx for it's lifetime
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_clear();
DYAD_DLL_EXPORTED dyad_rc_t dyad_clear ();

/**
* @brief Finalizes the DYAD instance and deallocates the context
*
* @return An error code from dyad_rc.h
*/
DYAD_DLL_EXPORTED dyad_rc_t dyad_finalize();
DYAD_DLL_EXPORTED dyad_rc_t dyad_finalize ();

#ifdef __cplusplus
}
Expand Down
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
Loading

0 comments on commit ceb0f6f

Please sign in to comment.