Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
--name capio-docker \
alphaunito/capio:latest \
sh -c 'jq -n --arg pwd "$PWD" "$1" > test_config.json && \
printf "[capiocl]\nworkflow_name = \"CAPIO\"\nconfig_path = \"test_config.json\"\n[capio]\ndirectory = \"$PWD\"\n" > test_config.toml && \
LD_PRELOAD=libcapio_posix.so capio_syscall_unit_tests \
--gtest_break_on_failure \
--gtest_print_time=1' sh \
Expand Down Expand Up @@ -186,8 +187,11 @@ jobs:
--arg pwd $(pwd) \
'{name: "CAPIO", IO_Graph: [], exclude: [$pwd + "/aNonExistingFile", $pwd, $pwd + "/"]}' \
> test_config.json

printf '[capiocl]\nworkflow_name = "CAPIO"\nconfig_path = "test_config.json"\n[capio]\ndirectory = "%s"\n' \
"$(pwd)" > test_config.toml

export CONFIG_PATH=$(realpath test_config.json)
export CONFIG_PATH=$(realpath test_config.toml)

export LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ENDIF ()
FetchContent_Declare(
capio_cl
GIT_REPOSITORY https://github.com/High-Performance-IO/CAPIO-CL.git
GIT_TAG v1.5.2
GIT_TAG v2.0.1
)

FetchContent_Declare(
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ COPY --from=builder \

# Pkgconfig
COPY --from=builder \
"/usr/local/lib/pkgconfig/args.pc" \
"/usr/local/lib/pkgconfig/gmock.p[c]" \
"/usr/local/lib/pkgconfig/gmock_main.p[c]" \
"/usr/local/lib/pkgconfig/gtest.p[c]" \
Expand Down
97 changes: 52 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ The following dependencies are automatically fetched during the CMake configurat
- [CALF](https://github.com/High-Performance-IO/CALF) provides logging and CLI output.
- [alpha-unito/syscall_intercept](https://github.com/alpha-unito/syscall_intercept) intercepts system calls (forked from `pmem/syscall_intercept`).
- [ParaGroup/MTCL](https://github.com/ParaGroup/MTCL) provides dynamic, multi-backend communication between CAPIO server instances.
- [Taywee/args](https://github.com/Taywee/args) parses server command-line arguments.

### Compile capio

Expand All @@ -50,81 +49,89 @@ It is also possible to enable log in CAPIO, by defining `-DCAPIO_LOG=TRUE`.
Good news! You don't need to modify your code to benefit from the features of CAPIO. You have only to do three steps (
the first is optional).

1) Write a configuration file for injecting streaming capabilities to your workflow
1. Generate and edit the TOML configuration with `capio_server --genconf`, or use built-in defaults with `capio_server --defconf`.

2) Launch the CAPIO daemons with MPI passing the (eventual) configuration file as argument on the machines in which you
want to execute your program (one daemon for each node). If you desire to specify a custom folder
for capio, set `CAPIO_DIR` as a environment variable.
2. Launch the CAPIO daemons with MPI, passing the TOML configuration file on the machines in which you
want to execute your program (one daemon for each node). Set `capio.directory` in that file to
choose the managed root directory.
```bash
[CAPIO_DIR=your_capiodir] [mpiexec -N 1 --hostfile your_hostfile] capio_server -c conf.json
[mpiexec -N 1 --hostfile your_hostfile] capio_server default.toml
```

3) Launch your programs preloading the CAPIO shared library like this:
3. Launch your programs preloading the CAPIO shared library like this:
```bash
CAPIO_DIR=your_capiodir \
CAPIO_WORKFLOW_NAME=wfname \
CAPIO_WORKFLOW_NAME=wfname \
CAPIO_APP_NAME=appname \
LD_PRELOAD=libcapio_posix.so \
LD_PRELOAD=libcapio_posix.so \
./your_app <args>
```

> [!WARNING]
> `CAPIO_DIR` must be specified when launching a program with the CAPIO library. if `CAPIO_DIR` is not specified, CAPIO
> will not intercept syscalls.

> [!NOTE]
> If `CAPIO_DIR` is not specified when launching `capio_server`, it defaults to the server's current working directory.
> will not intercept syscalls. Its value must match `capio.directory` in the server TOML configuration.

### Server backend options

Use `--backend-options` to configure the MTCL backend. Its format is
`PROTO:PORT@POLL_INTERVAL_US`; for example:
Configure the backend in TOML. For example:

```bash
capio_server --no-config --backend mtcl --backend-options TCP:7600@1000000
```toml
[capio.backend]
type = "mtcl"

[capio.backend.mtcl]
proto = "TCP"
listen_address = "0.0.0.0"
port = 7600
poll_interval_us = 1000000
```

If omitted, MTCL defaults to `TCP:7600@1000000`. See the
If omitted, CAPIO uses the `none` backend. See the
[MTCL repository](https://github.com/ParaGroup/MTCL) for supported communication protocols and their requirements.

### Available environment variables
### Server configuration

CAPIO can be controlled through the usage of environment variables. The available variables are listed below:
The server reads runtime settings only from TOML. `capio_server --genconf` writes a documented `default.toml`, while
`capio_server --defconf` starts directly with the same built-in defaults. Important server settings include:

#### Global environment variable
```toml
[capio]
directory = "."

- `CAPIO_DIR` This environment variable tells to both server and application the mount point of capio;
- `CAPIO_LOG_LEVEL` this environment tells both server and application the log level to use. This variable works only
if `-DCAPIO_LOG=TRUE` was specified during cmake phase;
- `CAPIO_LOG_PREFIX` This environment variable is defined only for capio_posix applications and specifies the prefix of
the logfile name to which capio will log to. The default value is `posix_thread_`, which means that capio will log by
default to a set of files called `posix_thread_*.log`. An equivalent behaviour can be set on the capio server using
the `-l` option;
- `CAPIO_LOG_DIR` This environment variable is defined only for capio_posix applications and specifies the directory
name to which capio will be created. If this variable is not defined, capio will log by default to `capio_logs`. An
equivalent behaviour can be set on the capio server using the `-d` option;
- `CAPIO_CACHE_LINES`: This environment variable controls how many lines of cache are presents between posix and server
applications. defaults to 10 lines;
- `CAPIO_CACHE_LINE_SIZE`: This environment variable controls the size of a single cache line. defaults to 256KB;
[capio.storage]
file_initial_size = 4294967296
prefetch_data_size = 0

#### Server only environment variable
[capio.cache]
lines = 10
line_size = 262144
```

### POSIX environment variables

Preloaded applications remain separate processes and use these environment variables to connect to the configured
server:

- `CAPIO_FILE_INIT_SIZE`: This environment variable defines the default size of pre allocated memory for a new file
handled by capio. Defaults to 4MB. Bigger sizes will reduce the overhead of malloc but will fill faster node memory.
Value has to be expressed in bytes;
- `CAPIO_PREFETCH_DATA_SIZE`: If this variable is set, then data transfers between nodes will be always, at least of the
given value in bytes;
#### Logging

- `CAPIO_LOG_LEVEL` controls the application log level. This variable works only
if `-DCAPIO_LOG=TRUE` was specified during cmake phase;
- `CAPIO_LOG_PREFIX` specifies the prefix of
the logfile name to which capio will log to. The default value is `posix_thread_`, which means that capio will log by
default to a set of files called `posix_thread_*.log`;
- `CAPIO_LOG_DIR` specifies the log directory. It defaults to `capio_logs`.

#### Posix only environment variable
#### Runtime

> [!WARNING]
> The following variables are mandatory. If not provided to a posix, application, CAPIO will not be able to correctly
> handle the
> application, according to the specifications given from the json configuration file!
> handle the application according to the workflow configuration.

- `CAPIO_WORKFLOW_NAME`: This environment variable is used to define the scope of a workflow for a given step. Needs to
be the same one as the field `"name"` inside the json configuration file;
- `CAPIO_DIR`: must match `capio.directory` in the server TOML configuration;
- `CAPIO_WORKFLOW_NAME`: must match `capiocl.workflow_name` in the server TOML configuration;
- `CAPIO_APP_NAME`: This environment variable defines the app name within a workflow for a given step;
- `CAPIO_CACHE_LINES`: must match `capio.cache.lines`; defaults to 10;
- `CAPIO_CACHE_LINE_SIZE`: must match `capio.cache.line_size`; defaults to 256 KiB.

## How to inject streaming capabilities into your workflow

Expand Down
2 changes: 2 additions & 0 deletions capio/common/shm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <sys/stat.h>
#include <unistd.h>

#include "common/syscall.hpp"

#ifdef __CAPIO_POSIX
#include "calf/SyscallLogger.h"
#else
Expand Down
17 changes: 9 additions & 8 deletions capio/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ endif ()
# External projects
#####################################
FetchContent_Declare(
args
GIT_REPOSITORY https://github.com/Taywee/args.git
GIT_TAG 6.4.7
tomlplusplus
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
GIT_TAG v3.4.0
)

set(ARGS_BUILD_EXAMPLE OFF CACHE INTERNAL "")
set(ARGS_BUILD_UNITTESTS OFF CACHE INTERNAL "")

FetchContent_MakeAvailable(args capio_cl mtcl)
FetchContent_MakeAvailable(capio_cl mtcl tomlplusplus)


#####################################
Expand Down Expand Up @@ -51,9 +48,13 @@ target_sources(${TARGET_NAME} PRIVATE
target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${capio_cl_SOURCE_DIR}
${TOMLPLUSPLUS_SOURCE_DIR}/include
)
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${mtcl_SOURCE_DIR}/include)


target_link_libraries(${TARGET_NAME} PRIVATE tomlplusplus::tomlplusplus)

#####################################
# set CALF logger component name
#####################################
Expand All @@ -64,7 +65,7 @@ calf_set_default_log_dir(${TARGET_NAME} "./capio_logs")
#####################################
# Link libraries
#####################################
target_link_libraries(${TARGET_NAME} PRIVATE pthread rt stdc++fs libcapio_cl args)
target_link_libraries(${TARGET_NAME} PRIVATE pthread rt stdc++fs libcapio_cl)
if (MPI_CXX_FOUND)
target_compile_definitions(${TARGET_NAME} PRIVATE CAPIO_HAS_MPI)
target_link_libraries(${TARGET_NAME} PRIVATE MPI::MPI_CXX)
Expand Down
29 changes: 8 additions & 21 deletions capio/server/capio_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
#include "utils/capiocl_adapter.hpp"

#include "client-manager/client_manager.hpp"
#include "common/env.hpp"
#include "common/requests.hpp"
#include "common/semaphore.hpp"
#include "remote/backend.hpp"
#include "remote/discovery.hpp"
#include "storage/capio_file.hpp"
#include "utils/common.hpp"
#include "utils/env.hpp"
#include "utils/types.hpp"

ClientManager *client_manager;
Expand All @@ -39,8 +37,8 @@ Backend *backend;
DiscoveryService *discovery_service;

#include "handlers.hpp"
#include "utils/cli_parser.hpp"
#include "utils/location.hpp"
#include "utils/runtime_configuration.hpp"
#include "utils/signals.hpp"

#include "remote/listener.hpp"
Expand Down Expand Up @@ -94,7 +92,7 @@ static constexpr std::array<CSHandler_t, CAPIO_NR_REQUESTS> build_request_handle
setup_signal_handlers();
backend->handshake_servers();

storage_manager->addDirectory(getpid(), get_capio_dir());
storage_manager->addDirectory(getpid(), get_server_capio_dir());

internal_server_sem.unlock();

Expand All @@ -115,30 +113,19 @@ int main(int argc, char **argv) {

Semaphore internal_server_sem(0);

const auto configuration = parse_cli(argc, argv);

for (const auto line : CAPIO_LOG_SERVER_BANNER) {
CALF_PRINT("%s", line);
}
configure_server_runtime(
configuration.capio_dir, configuration.cache_lines, configuration.cache_line_size,
configuration.capio_file_default_init_size, configuration.capio_prefetch_data_size);

const auto configuration = parseCLI(argc, argv);

if (configuration.capio_cl_dynamic_config) {
capio_cl_engine = new capiocl::engine::Engine();
capio_cl_engine->startApiServer();
} else if (!configuration.capio_cl_config_path.empty()) {
capio_cl_engine = capiocl::parser::Parser::parse(configuration.capio_cl_config_path,
configuration.capio_cl_resolve_path,
configuration.store_all_in_memory);
} else {
capio_cl_engine = new capiocl::engine::Engine();
capio_cl_engine->setWorkflowName(get_capio_workflow_name());
}
capio_cl_engine = capiocl::parser::Parser::parse(configuration.capio_cl_config);

UPDATE_CALF_WORKFLOW_NAME(capio_cl_engine->getWorkflowName());

if (configuration.store_all_in_memory) {
capio_cl_engine->setAllStoreInMemory();
}

capio_cl_engine->print();

discovery_service = select_discovery_service(configuration);
Expand Down
5 changes: 2 additions & 3 deletions capio/server/include/handlers/getdents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

#include <thread>

#include "posix/utils/env.hpp"

#include "remote/backend.hpp"
#include "remote/requests.hpp"
#include "utils/location.hpp"
#include "utils/runtime_configuration.hpp"

extern StorageManager *storage_manager;
extern Backend *backend;
Expand Down Expand Up @@ -41,7 +40,7 @@ inline void handle_getdents(int tid, int fd, long int count) {

const std::string &app_name = client_manager->getAppName(tid);
const std::filesystem::path &path_to_check = storage_manager->getPath(tid, fd);
const std::filesystem::path &capio_dir = get_capio_dir();
const std::filesystem::path &capio_dir = get_server_capio_dir();
bool is_prod = CapioCLEngine::get().isProducer(path_to_check, app_name);
auto file_location_opt = get_file_location_opt(path_to_check);

Expand Down
3 changes: 2 additions & 1 deletion capio/server/include/handlers/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "remote/requests.hpp"

#include "utils/location.hpp"
#include "utils/runtime_configuration.hpp"

extern Backend *backend;

Expand Down Expand Up @@ -135,7 +136,7 @@ inline void handle_read(int tid, int fd, off64_t count) {
START_LOG(gettid(), "call(tid=%d, fd=%d, count=%ld)", tid, fd, count);

const std::filesystem::path &path = storage_manager->getPath(tid, fd);
const std::filesystem::path &capio_dir = get_capio_dir();
const std::filesystem::path &capio_dir = get_server_capio_dir();
const std::string &app_name = client_manager->getAppName(tid);
bool is_prod =
CapioCLEngine::get().isProducer(path, app_name) || client_manager->isProducer(tid, path);
Expand Down
3 changes: 2 additions & 1 deletion capio/server/include/handlers/stat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "remote/requests.hpp"

#include "utils/location.hpp"
#include "utils/runtime_configuration.hpp"
#include "utils/types.hpp"

#include "client-manager/client_manager.hpp"
Expand Down Expand Up @@ -67,7 +68,7 @@ inline void reply_stat(int tid, const std::filesystem::path &path) {
CapioFile &c_file = (c_file_opt) ? c_file_opt->get()
: storage_manager->add(path, false, get_file_initial_size());
LOG("Obtained capio file. ready to reply to client");
const std::filesystem::path &capio_dir = get_capio_dir();
const std::filesystem::path &capio_dir = get_server_capio_dir();
LOG("Obtained capio_dir");
if (!file_location_opt) {
LOG("File is now present from remote node. retrieving file again.");
Expand Down
2 changes: 1 addition & 1 deletion capio/server/include/remote/discovery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <thread>

#include "common/constants.hpp"
#include "utils/cli_parser.hpp"
#include "utils/runtime_configuration.hpp"
#include "utils/shm_canary.hpp"

/**
Expand Down
2 changes: 1 addition & 1 deletion capio/server/include/remote/listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "remote/backend/include.hpp"
#include "remote/handlers/read.hpp"
#include "remote/handlers/stat.hpp"
#include "utils/cli_parser.hpp"
#include "utils/runtime_configuration.hpp"

#include <cstdlib>
#include <stdexcept>
Expand Down
20 changes: 0 additions & 20 deletions capio/server/include/utils/cli_parser.hpp

This file was deleted.

Loading