Skip to content

Commit

Permalink
Merge pull request #22 from mochi-hpc/dev-large-refactoring
Browse files Browse the repository at this point in the history
Large refactoring
  • Loading branch information
mdorier authored Sep 18, 2024
2 parents a6bf743 + 8a989ec commit 5f58a79
Show file tree
Hide file tree
Showing 78 changed files with 902 additions and 6,301 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build the develop version using Spack

on:
workflow_dispatch: {}
schedule:
- cron: "0 0 * * *"

jobs:
build:
runs-on: ubuntu-22.04
name: Build the main version of the package
steps:
- uses: actions/checkout@v4
- uses: mochi-hpc/mochi-test-build-action@v1
with:
package-version: "@develop"
8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup spack
uses: spack/[email protected]
Expand Down Expand Up @@ -44,9 +44,6 @@ jobs:
cmake .. -DENABLE_TESTS=ON \
-DENABLE_EXAMPLES=ON \
-DENABLE_MPI=ON \
-DENABLE_MONA=ON \
-DENABLE_SSG=ON \
-DENABLE_ABT_IO=ON \
-DENABLE_PYTHON=ON \
-DCMAKE_BUILD_TYPE=Debug
make
Expand All @@ -65,9 +62,6 @@ jobs:
-DENABLE_TESTS=ON \
-DENABLE_EXAMPLES=ON \
-DENABLE_MPI=ON \
-DENABLE_MONA=ON \
-DENABLE_SSG=ON \
-DENABLE_ABT_IO=ON \
-DENABLE_PYTHON=ON \
-DCMAKE_BUILD_TYPE=Debug
make
Expand Down
28 changes: 1 addition & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See COPYRIGHT in top-level directory.
cmake_minimum_required (VERSION 3.8)
project (bedrock C CXX)
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
enable_testing ()

Expand All @@ -11,10 +11,7 @@ option (ENABLE_COVERAGE "Enable code coverage" OFF)
option (ENABLE_TESTS "Build tests" OFF)
option (ENABLE_EXAMPLES "Build examples" OFF)
option (ENABLE_MPI "Enable MPI support" OFF)
option (ENABLE_MONA "Enable MoNA support" OFF)
option (ENABLE_SSG "Enable SSG support" OFF)
option (ENABLE_FLOCK "Enable Flock support" OFF)
option (ENABLE_ABT_IO "Enable ABT-IO support" OFF)
option (ENABLE_PYTHON "Enable Python support" OFF)

# library version set here (e.g. for shared libs).
Expand Down Expand Up @@ -59,8 +56,6 @@ endif ()

# search for bedrock-module-api
find_package (bedrock-module-api REQUIRED)
# search for pkg-config
find_package (PkgConfig REQUIRED)
# search fo thallium
find_package (thallium REQUIRED)
# search for nlohmann/json and schema validator
Expand All @@ -75,20 +70,6 @@ find_package (fmt REQUIRED)
# search for toml11
find_package (toml11 REQUIRED)
# search for abt-io
if (ENABLE_ABT_IO)
pkg_check_modules (ABTIO REQUIRED IMPORTED_TARGET abt-io)
add_definitions (-DENABLE_ABT_IO)
set (OPTIONAL_ABT_IO PkgConfig::ABTIO)
set (OPTIONAL_SERVER_DEPS "${OPTIONAL_SERVER_DEPS} abt-io")
endif ()
# search for ssg
if (ENABLE_SSG)
pkg_check_modules (SSG REQUIRED IMPORTED_TARGET ssg)
add_definitions (-DENABLE_SSG)
set (OPTIONAL_SSG PkgConfig::SSG)
set (OPTIONAL_SERVER_DEPS "${OPTIONAL_SERVER_DEPS} ssg")
set (OPTIONAL_CLIENT_DEPS "${OPTIONAL_CLIENT_DEPS} ssg")
endif ()
if (ENABLE_FLOCK)
find_package (flock REQUIRED)
add_definitions (-DENABLE_FLOCK)
Expand All @@ -102,13 +83,6 @@ if (${ENABLE_MPI})
add_definitions (-DENABLE_MPI)
set (OPTIONAL_MPI MPI::MPI_C)
endif ()
# search for mona
if (ENABLE_MONA)
pkg_check_modules (MONA REQUIRED IMPORTED_TARGET mona)
add_definitions (-DENABLE_MONA)
set (OPTIONAL_MONA PkgConfig::MONA)
set (OPTIONAL_SERVER_DEPS "${OPTIONAL_SERVER_DEPS} mona")
endif ()
# search for Python
if (ENABLE_PYTHON)
set (Python3_FIND_STRATEGY LOCATION)
Expand Down
30 changes: 3 additions & 27 deletions bin/bedrock-query.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include <bedrock/Client.hpp>
#include <bedrock/ServiceGroupHandle.hpp>
#ifdef ENABLE_SSG
#include <ssg.h>
#endif
#include <spdlog/spdlog.h>
#include <tclap/CmdLine.h>
#include <nlohmann/json.hpp>
Expand All @@ -20,7 +17,6 @@ using nlohmann::json;
static std::string g_protocol;
static std::vector<std::string> g_addresses;
static std::string g_log_level;
static std::string g_ssg_file;
static std::string g_flock_file;
static std::string g_jx9_file;
static std::string g_jx9_script_content;
Expand All @@ -47,10 +43,6 @@ int main(int argc, char** argv) {
try {
auto engine = thallium::engine(g_protocol, THALLIUM_CLIENT_MODE);

#ifdef ENABLE_SSG
ssg_init();
#endif

if(!g_flock_file.empty()) {
json flock_file_content;
std::ifstream flock_file{g_flock_file};
Expand All @@ -70,18 +62,14 @@ int main(int argc, char** argv) {

bedrock::Client client(engine);

auto sgh = g_ssg_file.empty() ? client.makeServiceGroupHandle(g_addresses, g_provider_id)
: client.makeServiceGroupHandleFromSSGFile(g_ssg_file, g_provider_id);
auto sgh = client.makeServiceGroupHandle(g_addresses, g_provider_id);

std::string result;
if (g_jx9_script_content.empty())
sgh.getConfig(&result);
else
sgh.queryConfig(g_jx9_script_content, &result);
std::cout << (g_pretty ? json::parse(result).dump(4) : result) << std::endl;
#ifdef ENABLE_SSG
ssg_finalize();
#endif
} catch (const std::exception& e) { spdlog::critical(e.what()); exit(-1); }
return 0;
}
Expand All @@ -106,12 +94,6 @@ static void parseCommandLine(int argc, char** argv) {
"f", "flock-file",
"Flock file from which to read addresses of Bedrock daemons", false,
"", "filename");
#ifdef ENABLE_SSG
TCLAP::ValueArg<std::string> ssgFile(
"s", "ssg-file",
"SSG file from which to read addresses of Bedrock daemons", false,
"", "filename");
#endif
TCLAP::ValueArg<std::string> jx9File(
"j", "jx9-file", "Jx9 file to send to processes and execute", false,
"", "filename");
Expand All @@ -122,9 +104,6 @@ static void parseCommandLine(int argc, char** argv) {
cmd.add(protocol);
cmd.add(logLevel);
cmd.add(flockFile);
#ifdef ENABLE_SSG
cmd.add(ssgFile);
#endif
cmd.add(providerID);
cmd.add(addresses);
cmd.add(prettyJSON);
Expand All @@ -133,15 +112,12 @@ static void parseCommandLine(int argc, char** argv) {
g_addresses = addresses.getValue();
g_log_level = logLevel.getValue();
g_flock_file = flockFile.getValue();
#ifdef ENABLE_SSG
g_ssg_file = ssgFile.getValue();
#endif
g_protocol = protocol.getValue();
g_provider_id = providerID.getValue();
g_pretty = prettyJSON.getValue();
g_jx9_file = jx9File.getValue();
if(!g_addresses.empty() && !g_ssg_file.empty()) {
std::cerr << "error: specifying -s and -a at the same time is not supported" << std::endl;
if(g_addresses.empty()) {
std::cerr << "error: no address specified" << std::endl;
exit(-1);
}
} catch (TCLAP::ArgException& e) {
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
SCRIPT_DIR=$(dirname "$0")
cmake $SCRIPT_DIR -DENABLE_TESTS=ON -DENABLE_EXAMPLES=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_PYTHON=ON -DENABLE_MPI=ON -DENABLE_MONA=ON -DENABLE_SSG=ON -DENABLE_ABT_IO=ON -DENABLE_FLOCK=ON
cmake $SCRIPT_DIR -DENABLE_TESTS=ON -DENABLE_EXAMPLES=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_PYTHON=ON -DENABLE_MPI=ON -DENABLE_FLOCK=ON
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_executable (example-client ${CMAKE_CURRENT_SOURCE_DIR}/client.cpp)
target_link_libraries (example-client bedrock-client)

add_library (example-module-a ${CMAKE_CURRENT_SOURCE_DIR}/module-a.c)
add_library (example-module-a ${CMAKE_CURRENT_SOURCE_DIR}/module-a.cpp)
target_include_directories (example-module-a PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_link_libraries (example-module-a bedrock::module-api)

Expand Down
110 changes: 0 additions & 110 deletions examples/module-a.c

This file was deleted.

53 changes: 53 additions & 0 deletions examples/module-a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* (C) 2020 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#include <bedrock/AbstractComponent.hpp>
#include <iostream>

struct ActualProviderA {};

class ComponentA : public bedrock::AbstractComponent {

ActualProviderA* m_provider = nullptr;

public:

ComponentA()
: m_provider{new ActualProviderA{}} {}

~ComponentA() {
delete m_provider;
}

static std::shared_ptr<bedrock::AbstractComponent>
Register(const bedrock::ComponentArgs& args) {
std::cout << "Registering a ComponentA" << std::endl;
std::cout << " -> mid = " << (void*)args.engine.get_margo_instance() << std::endl;
std::cout << " -> provider id = " << args.provider_id << std::endl;
std::cout << " -> config = " << args.config << std::endl;
std::cout << " -> name = " << args.name << std::endl;
std::cout << " -> tags = ";
for(auto& t : args.tags) std::cout << t << " ";
std::cout << std::endl;
auto pool_it = args.dependencies.find("pool");
auto pool = pool_it->second[0]->getHandle<thallium::pool>();
return std::make_shared<ComponentA>();
}

static std::vector<bedrock::Dependency>
GetDependencies(const bedrock::ComponentArgs& args) {
(void)args;
std::vector<bedrock::Dependency> deps = {
{ "pool", "pool", true, false, false }
};
return deps;
}

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

BEDROCK_REGISTER_COMPONENT_TYPE(module_a, ComponentA)
Loading

0 comments on commit 5f58a79

Please sign in to comment.