generated from mochi-hpc/margo-microservice-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
SCRIPT_DIR=$(dirname "$0") | ||
cmake .. -DENABLE_TESTS=ON -DENABLE_BEDROCK=ON -DENABLE_EXAMPLES=ON | ||
cmake .. -DENABLE_TESTS=ON -DENABLE_BEDROCK=ON -DENABLE_EXAMPLES=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo | ||
make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* (C) 2024 The University of Chicago | ||
* | ||
* See COPYRIGHT in top-level directory. | ||
*/ | ||
#include <stdio.h> | ||
#include <margo.h> | ||
#include <flock/flock-server.h> | ||
#include <flock/flock-client.h> | ||
#include <flock/flock-group.h> | ||
#include <stdexcept> | ||
#include <vector> | ||
|
||
struct TestGroup { | ||
|
||
TestGroup(margo_instance_id mid, | ||
size_t group_size, | ||
const char* provider_config = R"({"group":{"type":"static","config":{}}})") { | ||
|
||
// get address of current process | ||
hg_addr_t addr = HG_ADDR_NULL; | ||
hg_return_t hret = margo_addr_self(mid, &addr); | ||
if(hret != HG_SUCCESS) | ||
throw std::runtime_error("margo_addr_self failed when creating TestGroup"); | ||
|
||
// get self address as a string | ||
char address[256]; | ||
hg_size_t address_size = 256; | ||
hret = margo_addr_to_string(mid, address, &address_size, addr); | ||
if(hret != HG_SUCCESS) | ||
throw std::runtime_error("margo_addr_to_string failed when creating TestGroup"); | ||
margo_addr_free(mid, addr); | ||
|
||
// create the initial group view to bootstrap with | ||
flock_group_view_t initial_view = FLOCK_GROUP_VIEW_INITIALIZER; | ||
for(size_t i = 0; i < group_size; ++i) | ||
flock_group_view_add_member(&initial_view, i, (uint16_t)(i+1), address); | ||
|
||
// add some metadata | ||
flock_group_view_add_metadata(&initial_view, "matthieu", "dorier"); | ||
flock_group_view_add_metadata(&initial_view, "shane", "snyder"); | ||
|
||
// register flock providers | ||
providers.resize(group_size, nullptr); | ||
struct flock_provider_args args = FLOCK_PROVIDER_ARGS_INIT; | ||
args.initial_view = &initial_view; | ||
for(size_t i = 0; i < group_size; ++i) { | ||
flock_return_t ret = flock_provider_register( | ||
mid, i+1, provider_config, &args, | ||
&providers[i]); | ||
if(ret != FLOCK_SUCCESS) | ||
throw std::runtime_error("flock_provider_register failed when initializing TestGroup"); | ||
} | ||
} | ||
|
||
virtual ~TestGroup() { | ||
for(auto provider : providers) | ||
flock_provider_destroy(provider); | ||
} | ||
|
||
std::vector<flock_provider_t> providers; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters