Skip to content

Commit

Permalink
added API
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorier committed Mar 21, 2024
1 parent d0fb7b3 commit bcbc1df
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 38 deletions.
10 changes: 1 addition & 9 deletions examples/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(int argc, char** argv)
flock_group_handle_t flock_rh;

margo_info(mid, "Creating FLOCK client");
ret = flock_client_init(mid, &flock_clt);
ret = flock_client_init(mid, ABT_POOL_NULL, &flock_clt);
if(ret != FLOCK_SUCCESS) {
FATAL(mid,"flock_client_init failed (ret = %d)", ret);
}
Expand All @@ -54,14 +54,6 @@ int main(int argc, char** argv)
FATAL(mid,"flock_group_handle_create failed (ret = %d)", ret);
}

margo_info(mid, "Computing sum");
int32_t result;
ret = flock_compute_sum(flock_rh, 45, 23, &result);
if(ret != FLOCK_SUCCESS) {
FATAL(mid,"flock_compute_sum failed (ret = %d)", ret);
}
margo_info(mid, "45 + 23 = %d", result);

margo_info(mid, "Releasing group handle");
ret = flock_group_handle_release(flock_rh);
if(ret != FLOCK_SUCCESS) {
Expand Down
6 changes: 5 additions & 1 deletion include/flock/flock-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ typedef struct flock_client* flock_client_t;
* @brief Creates a FLOCK client.
*
* @param[in] mid Margo instance
* @param[in] pool Pool in which to run operations such as updates
* @param[out] client FLOCK client
*
* @return FLOCK_SUCCESS or error code defined in flock-common.h
*/
flock_return_t flock_client_init(margo_instance_id mid, flock_client_t* client);
flock_return_t flock_client_init(
margo_instance_id mid,
ABT_pool pool,
flock_client_t* client);

/**
* @brief Finalizes a FLOCK client.
Expand Down
38 changes: 36 additions & 2 deletions include/flock/flock-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@
#define __FLOCK_COMMON_H

#include <stdint.h>
#include <margo.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef enum flock_update_t {
FLOCK_MEMBER_JOINED,
FLOCK_MEMBER_LEFT,
FLOCK_MEMBER_DIED,
} flock_update_t;

#define FLOCK_MODE_INIT_UPDATE 0x1 /* Update the group on initialization */
#define FLOCK_MODE_SUBSCRIBE 0x2 /* Subscribe to the group on initialization */

/**
* @brief Error codes that can be returned by FLOCK functions.
*/
Expand All @@ -20,18 +30,42 @@ typedef enum flock_return_t {
FLOCK_ERR_ALLOCATION, /* Allocation error */
FLOCK_ERR_INVALID_ARGS, /* Invalid argument */
FLOCK_ERR_INVALID_PROVIDER, /* Invalid provider id */
FLOCK_ERR_INVALID_GROUP, /* Invalid group id */
FLOCK_ERR_INVALID_GROUP, /* Invalid group id */
FLOCK_ERR_INVALID_BACKEND, /* Invalid backend type */
FLOCK_ERR_INVALID_CONFIG, /* Invalid configuration */
FLOCK_ERR_INVALID_TOKEN, /* Invalid token */
FLOCK_ERR_FROM_MERCURY, /* Mercurt error */
FLOCK_ERR_FROM_ARGOBOTS, /* Argobots error */
FLOCK_ERR_OP_UNSUPPORTED, /* Unsupported operation */
FLOCK_ERR_OP_FORBIDDEN, /* Forbidden operation */
FLOCK_ERR_NO_MEMBER, /* No member at this rank */
FLOCK_ERR_NO_METADATA, /* Invalid metadata key */
/* ... TODO add more error codes here if needed */
FLOCK_ERR_OTHER /* Other error */
} flock_return_t;

/**
* @brief Type of function called when a member joins, leaves, or dies.
*
* @param void* User-provided context
* @param flock_update_t Update type
* @param size_t Rank of the member
* @param hg_addr_t Address of the member
* @param uint16_t Provider ID of the member
*/
typedef void (*flock_membership_update_fn)(void*, flock_update_t, size_t, hg_addr_t, uint16_t);

/**
* @brief Type of function called when a key/value pair in the metadata of
* a group is updated.
*
* @param void* User-provided context
* @param const char* Metadata key
* @param size_t Size of the metadata key
* @param const char* Metadata value
* @param size_t Size of the metadata value
*/
typedef void (*flock_metadata_update_fn)(void*, const char*, size_t, const char*, size_t);

#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit bcbc1df

Please sign in to comment.