Skip to content

Commit

Permalink
Merge pull request #34 from mochi-hpc/mdorier/update-to-latest-bedroc…
Browse files Browse the repository at this point in the history
…k-api

Updated bedrock module to latest API (remains to be tested)
  • Loading branch information
carns authored Oct 31, 2024
2 parents a4d5b8b + 2f96e78 commit b6688de
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 152 deletions.
5 changes: 2 additions & 3 deletions spack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ spack:
packages:
mochi-bedrock:
require:
- "@0.13.1:"
- "+ssg"
- "@0.15.0:"
- "+mpi"
mochi-flock:
require:
- "+mpi"
- "@0.3.1:"
- "@0.5.0:"
2 changes: 1 addition & 1 deletion src/Makefile.subdir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
src_libquintain_bedrock_la_SOURCES += src/quintain-bedrock-module.c
src_libquintain_bedrock_la_SOURCES += src/quintain-bedrock-module.cpp
src_libquintain_bedrock_la_LIBADD = src/libquintain-server.la src/libquintain-client.la -lbedrock-client

src_libquintain_client_la_SOURCES += src/quintain-client.c \
Expand Down
126 changes: 0 additions & 126 deletions src/quintain-bedrock-module.c

This file was deleted.

79 changes: 79 additions & 0 deletions src/quintain-bedrock-module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* (C) 2024 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#include "quintain-server.h"
#include <bedrock/AbstractComponent.hpp>

namespace tl = thallium;

class QuintainComponent : public bedrock::AbstractComponent {

quintain_provider_t m_provider = nullptr;

public:

QuintainComponent(const tl::engine& engine,
uint16_t provider_id,
const std::string& config,
const tl::pool& pool)
{
quintain_provider_init_info qargs = {
/* .json_config = */ config.c_str(),
/* .rpc_pool = */ pool.native_handle()
};
int ret = quintain_provider_register(
engine.get_margo_instance(),
provider_id,
&qargs,
&m_provider);
if(ret != 0) {
throw bedrock::Exception{
"Could not create Quintain provider: quintain_provider_register returned {}", ret};
}
}

~QuintainComponent() {
quintain_provider_deregister(m_provider);
}

void* getHandle() override {
return static_cast<void*>(m_provider);
}

std::string getConfig() override {
auto config_cstr = quintain_provider_get_config(m_provider);
auto config = std::string{config_cstr};
free(config_cstr);
return config;
}

static std::shared_ptr<bedrock::AbstractComponent>
Register(const bedrock::ComponentArgs& args) {
tl::pool pool;
auto it = args.dependencies.find("pool");
if(it != args.dependencies.end() && !it->second.empty()) {
pool = it->second[0]->getHandle<tl::pool>();
}
return std::make_shared<QuintainComponent>(
args.engine, args.provider_id, args.config, pool);
}

static std::vector<bedrock::Dependency>
GetDependencies(const bedrock::ComponentArgs& args) {
(void)args;
std::vector<bedrock::Dependency> dependencies{
bedrock::Dependency{
/* name */ "pool",
/* type */ "pool",
/* is_required */ false,
/* is_array */ false,
/* is_updatable */ false
}
};
return dependencies;
}
};

BEDROCK_REGISTER_COMPONENT_TYPE(quintain, QuintainComponent)
19 changes: 11 additions & 8 deletions tests/mochi-quintain-provider-rpc-threads.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,27 @@
]
}
},
"libraries" : {
"quintain" : "libquintain-bedrock.so",
"flock" : "libflock-bedrock-module.so"
},
"libraries" : [
"libquintain-bedrock.so",
"libflock-bedrock-module.so"
],
"providers" : [
{
"name" : "my_quintain_provider",
"type" : "quintain",
"provider_id" : 1,
"pool" : "quintain_rpcs",
"config" : {
}
"dependencies": {
"pool" : "quintain_rpcs"
},
"config" : {}
},
{
"name" : "quintain_group",
"type" : "flock",
"provider_id" : 2,
"pool" : "__primary__",
"dependencies": {
"pool" : "__primary__"
},
"config" : {
"group": {
"type": "static"
Expand Down
19 changes: 11 additions & 8 deletions tests/mochi-quintain-provider.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
{
"margo" : {
},
"libraries" : {
"quintain" : "libquintain-bedrock.so",
"flock" : "libflock-bedrock-module.so"
},
"libraries" : [
"libquintain-bedrock.so",
"libflock-bedrock-module.so"
],
"providers" : [
{
"name" : "my_quintain_provider",
"type" : "quintain",
"provider_id" : 1,
"pool" : "__primary__",
"config" : {
}
"dependencies": {
"pool" : "__primary__"
},
"config" : {}
},
{
"name" : "quintain_group",
"type" : "flock",
"provider_id" : 2,
"pool" : "__primary__",
"dependencies": {
"pool" : "__primary__"
},
"config" : {
"group": {
"type": "static"
Expand Down
16 changes: 10 additions & 6 deletions tests/mochi-quintain-provider.jx9
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ $config = {
"xstreams": []
}
},
"libraries" : {
"quintain" : "libquintain-bedrock.so",
"flock" : "libflock-bedrock-module.so"
},
"libraries" : [
"libquintain-bedrock.so",
"libflock-bedrock-module.so"
],
"providers" : [
{
"name" : "my_quintain_provider",
"type" : "quintain",
"provider_id" : 1,
"pool" : "__primary__",
"dependencies": {
"pool" : "__primary__"
},
"config" : {}
},
{
"name" : "quintain_group",
"type" : "flock",
"provider_id" : 2,
"pool" : "__primary__",
"dependencies": {
"pool" : "__primary__"
},
"config" : {
"group": {
"type": "static"
Expand Down

0 comments on commit b6688de

Please sign in to comment.