Verified Commit c8e06afa authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Merge branch '10-add-a-admire-hpp-header-with-the-api-definition' into main

Resolve "Add a proper admire API for clients"

This MR provides the initial implementation for the ADMIRE I/O Scheduler API.

Closes #10

See merge request !8
parents 41ae0815 93985b02
Loading
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -14,11 +14,12 @@ build:
    - mkdir -p build
    - cd build
    - cmake -DCMAKE_PREFIX_PATH:STRING=/usr/local -DCMAKE_INSTALL_PREFIX:STRING=${CI_PROJECT_DIR}/compiled -DSCORD_BUILD_EXAMPLES:BOOL=ON -DSCORD_TRANSPORT_LIBRARY=libfabric -DSCORD_TRANSPORT_PROTOCOL=ofi+tcp -DSCORD_BIND_ADDRESS=127.0.0.1 -DSCORD_BIND_PORT=52000 ..
    - make install
    - make -j$(nproc) install
  artifacts:
    paths:
      - compiled/bin/
      - compiled/etc/
      - compiled/lib/
      - build/examples/
      # depending on your build setup it's most likely a good idea to cache outputs to reduce the build time
  cache:
@@ -33,9 +34,9 @@ test:
  stage: test
  needs: [build]
  script:
    - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
    - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:${CI_PROJECT_DIR}/compiled/lib
    - compiled/bin/scord -f --force-console &
    - build/examples/ping ofi+tcp://127.0.0.1:52000
    - pkill -9 scord
    - pkill -TERM scord
  cache:
    key: $CI_COMMIT_REF_SLUG
+10 −0
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ FetchContent_Declare(
)

FetchContent_MakeAvailable(spdlog)
set_target_properties(spdlog PROPERTIES POSITION_INDEPENDENT_CODE ON)

### file_options: required for reading configuration files
message(STATUS "[${PROJECT_NAME}] Downloading and building file_options")
@@ -217,6 +218,15 @@ mark_variables_as_advanced(REGEX "^(FETCHCONTENT|fmt|FMT|spdlog|SPDLOG)_.*$")
# ##############################################################################
# Process subdirectories
# ##############################################################################

# set compile flags
add_compile_options("-Wall" "-Wextra" "$<$<CONFIG:RELEASE>:-O3>")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  add_compile_options("-stdlib=libc++")
else()
  # nothing special for gcc at the moment
endif()

add_subdirectory(etc)
add_subdirectory(src)

+15 −23
Original line number Diff line number Diff line
#include <fmt/format.h>
#include <engine.hpp>
#include <admire.hpp>


int
@@ -12,35 +12,27 @@ main(int argc, char* argv[]) {
        exit(EXIT_FAILURE);
    }

    scord::network::rpc_client rpc_client{"tcp"};
    rpc_client.register_rpcs();
    admire::server server{"tcp", argv[1]};

    auto endp = rpc_client.lookup(argv[1]);
    ADM_job_handle_t job{};
    ADM_transfer_handle_t tx_handle{};
    ADM_return_t ret = ADM_SUCCESS;

    fmt::print(
            stdout,
            "Calling ADM_cancel_transfer remote procedure on {} with transfer id {} ...\n",
            argv[1], argv[2]);
    ADM_cancel_transfer_in_t in;
    try {
        in.transfer_id = std::stoi(argv[2]);
        ret = admire::cancel_transfer(server, job, tx_handle);
    } catch(const std::exception& e) {
        fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n");
        fmt::print(stderr, "FATAL: ADM_cancel_transfer() failed: {}\n",
                   e.what());
        exit(EXIT_FAILURE);
    }
    ADM_cancel_transfer_out_t out;

    endp.call("ADM_cancel_transfer", &in, &out);


    if(out.ret < 0) {
        fmt::print(
                stdout,
                "ADM_cancel_transfer remote procedure not completed successfully\n");
    if(ret != ADM_SUCCESS) {
        fmt::print(stdout,
                   "ADM_cancel_transfer() remote procedure not completed "
                   "successfully\n");
        exit(EXIT_FAILURE);
    } else {
        fmt::print(
                stdout,
                "ADM_cancel_transfer remote procedure completed successfully\n");
    }

    fmt::print(stdout, "ADM_cancel_transfer() remote procedure completed "
                       "successfully\n");
}
+19 −38
Original line number Diff line number Diff line
#include <fmt/format.h>
#include <engine.hpp>
#include <admire.hpp>

bool
string_to_convert(std::string s) {
@@ -24,52 +24,33 @@ main(int argc, char* argv[]) {
        exit(EXIT_FAILURE);
    }

    scord::network::rpc_client rpc_client{"tcp"};
    rpc_client.register_rpcs();
    admire::server server{"tcp", argv[1]};

    auto endp = rpc_client.lookup(argv[1]);
    ADM_job_handle_t job{};
    ADM_dataset_handle_t input{};
    ADM_dataset_handle_t output{};
    bool should_stream = false;
    va_list args; // FIXME placeholder
    ADM_return_t ret = ADM_SUCCESS;

    fmt::print(
            stdout,
            "Calling ADM_connect_data_operation remote procedure on {} with operation id {}, input {}, stream {}, arguments {} and job id {} ...\n",
            argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
    ADM_connect_data_operation_in_t in;
    try {
        in.operation_id = std::stoi(argv[2]);
    } catch(const std::exception& e) {
        fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n");
        exit(EXIT_FAILURE);
    }
    in.input = argv[3];
    try {
        in.stream = string_to_convert(argv[4]);
    } catch(const std::invalid_argument& ia) {
        fmt::print(stderr, "ERROR: Incorrect input value. Please try again.\n");
        exit(EXIT_FAILURE);
    }
    in.arguments = argv[5];
    try {
        in.job_id = std::stoi(argv[6]);
        ret = admire::connect_data_operation(server, job, input, output,
                                             should_stream, args);
    } catch(const std::exception& e) {
        fmt::print(
                stderr,
                "ERROR: ERROR: Incorrect input value. Please introduce TRUE/FALSE value. \n");
        fmt::print(stderr, "FATAL: ADM_connect_data_operation() failed: {}\n",
                   e.what());
        exit(EXIT_FAILURE);
    }

    ADM_connect_data_operation_out_t out;

    endp.call("ADM_connect_data_operation", &in, &out);


    if(out.ret < 0) {
    if(ret != ADM_SUCCESS) {
        fmt::print(
                stdout,
                "ADM_connect_data_operation remote procedure not completed successfully\n");
                "ADM_connect_data_operation() remote procedure not completed "
                "successfully\n");
        exit(EXIT_FAILURE);
    } else {
        fmt::print(
                stdout,
                "ADM_connect_data_operation remote procedure completed successfully\n");
    }

    fmt::print(stdout,
               "ADM_connect_data_operation() remote procedure completed "
               "successfully\n");
}
+18 −27
Original line number Diff line number Diff line
#include <fmt/format.h>
#include <engine.hpp>
#include <admire.hpp>


int
@@ -13,39 +13,30 @@ main(int argc, char* argv[]) {
        exit(EXIT_FAILURE);
    }

    scord::network::rpc_client rpc_client{"tcp"};
    rpc_client.register_rpcs();
    admire::server server{"tcp", argv[1]};

    auto endp = rpc_client.lookup(argv[1]);
    ADM_job_handle_t job{};
    const char* path = "";
    ADM_data_operation_handle_t op_handle;
    va_list args; // FIXME: placeholder
    ADM_return_t ret = ADM_SUCCESS;

    fmt::print(
            stdout,
            "Calling ADM_define_data_operation remote procedure on {} -> {} with operation id {} and arguments {} ...\n",
            argv[1], argv[2], argv[3], argv[4]);

    ADM_define_data_operation_in_t in;
    in.path = argv[2];
    try {
        in.operation_id = std::stoi(argv[3]);
        ret = admire::define_data_operation(server, job, path, &op_handle,
                                            args);
    } catch(const std::exception& e) {
        fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n");
        fmt::print(stderr, "FATAL: ADM_define_data_operation() failed: {}\n",
                   e.what());
        exit(EXIT_FAILURE);
    }
    in.arguments = argv[4];

    ADM_define_data_operation_out_t out;

    endp.call("ADM_define_data_operation", &in, &out);


    if(out.ret < 0) {
        fmt::print(
                stdout,
                "ADM_define_data_operation remote procedure not completed successfully\n");
    if(ret != ADM_SUCCESS) {
        fmt::print(stdout,
                   "ADM_define_data_operation() remote procedure not completed "
                   "successfully\n");
        exit(EXIT_FAILURE);
    } else {
        fmt::print(
                stdout,
                "ADM_define_data_operation remote procedure completed successfully\n");
    }

    fmt::print(stdout, "ADM_define_data_operation() remote procedure completed "
                       "successfully\n");
}
Loading