Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cmake-build-*
#logfies and capio files
*.log
files_location*.txt
capio_logs
calf_logs

# Other
debug
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ FetchContent_Declare(
GIT_TAG v1.4.0
)

FetchContent_Declare(
calf
GIT_REPOSITORY https://github.com/High-Performance-IO/calf.git
GIT_TAG main
)

set(CALF_LOG ${CAPIO_LOG} CACHE BOOL "" FORCE)
set(CALF_BUILD_STL ON CACHE BOOL "" FORCE)
set(CALF_BUILD_SYSCALL ON CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(calf)

#####################################
# Targets
#####################################
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ CAPIO depends on the following software that needs to be manually installed:
The following dependencies are automatically fetched during cmake configuration phase, and compiled when required.

- [CAPIO-CL](https://github.com/High-Performance-IO/CAPIO-CL) To handle the CAPIO-CL configuration and enforce streaming directives
- [CALF](https://github.com/High-Performance-IO/CALF) To manage logging and CLI printing
- [alpha-unito/syscall_intercept](https://github.com/alpha-unito/syscall_intercept) to intercept syscalls (forked from ```pmem/syscall_interept```)
- [Taywee/args](https://github.com/Taywee/args) to parse server command line inputs

Expand Down
44 changes: 9 additions & 35 deletions capio/common/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ constexpr int CAPIO_CACHE_LINE_SIZE_DEFAULT = 256 * 1024;
constexpr size_t CAPIO_SERVER_REQUEST_MAX_SIZE = sizeof(char) * (PATH_MAX + 81920);
constexpr size_t CAPIO_REQ_MAX_SIZE = 256 * sizeof(char);

constexpr char LOG_CAPIO_START_REQUEST[] = "\n+++++++++++ SYSCALL %s (%d) +++++++++++";
constexpr char LOG_CAPIO_END_REQUEST[] = "----------- END SYSCALL ----------\n";
constexpr char CAPIO_SERVER_LOG_START_REQUEST_MSG[] = "+++++++++++++++++REQUEST+++++++++++++++++";
constexpr char CAPIO_SERVER_LOG_END_REQUEST_MSG[] = "~~~~~~~~~~~~~~~END REQUEST~~~~~~~~~~~~~~~";
constexpr int CAPIO_LOG_MAX_MSG_LEN = 2048;
constexpr int CAPIO_SEM_RETRIES = 100;
constexpr int THEORETICAL_SIZE_DIRENT64 = sizeof(ino64_t) + sizeof(off64_t) +
constexpr int CAPIO_SEM_RETRIES = 100;
constexpr int THEORETICAL_SIZE_DIRENT64 = sizeof(ino64_t) + sizeof(off64_t) +
sizeof(unsigned short) + sizeof(unsigned char) +
sizeof(char) * NAME_MAX;

Expand All @@ -44,10 +39,6 @@ constexpr int CAPIO_POSIX_SYSCALL_REQUEST_SKIP = -2;
constexpr int CAPIO_POSIX_SYSCALL_SKIP = 1;
constexpr int CAPIO_POSIX_SYSCALL_SUCCESS = 0;

// CAPIO logger - common
constexpr char CAPIO_LOG_PRE_MSG[] = "at[%.15llu][%.40s]: ";
constexpr char CAPIO_DEFAULT_LOG_FOLDER[] = "capio_logs\0";

// CAPIO common - shared memory constant names
constexpr char SHM_FIRST_ELEM[] = "_first_elem_";
constexpr char SHM_LAST_ELEM[] = "_last_elem_";
Expand All @@ -66,15 +57,8 @@ constexpr char CAPIO_SHM_OPEN_ERROR[] =
"Unable to open shared memory segment. Could it be that another instance of capio server is "
"running with the same WORKFLOW_NAME?";

// CAPIO logger - POSIX
constexpr char CAPIO_LOG_POSIX_DEFAULT_LOG_FILE_PREFIX[] = "posix_thread_\0";
constexpr char CAPIO_LOG_POSIX_SYSCALL_START[] = "\n+++++++++ SYSCALL %s (%d) +++++++++";
constexpr char CAPIO_LOG_POSIX_SYSCALL_END[] = "~~~~~~~~~ END SYSCALL ~~~~~~~~~\n";

// CAPIO logger - server
constexpr char CAPIO_SERVER_DEFAULT_LOG_FILE_PREFIX[] = "server_thread_\0";
// Note: Ensure CAPIO_VERSION is defined as a string literal, e.g., #define CAPIO_VERSION "1.0.0"
constexpr char CAPIO_LOG_SERVER_BANNER[14][80] = {
constexpr char CAPIO_LOG_SERVER_BANNER[14][80] = {
"",
"\033[1;34m /$$$$$$ /$$$$$$ /$$$$$$$ \033[0;96m /$$$$$$ /$$$$$$ ",
"\033[1;34m /$$__ $$ /$$__ $$| $$__ $$ \033[0;96m|_ $$_/ /$$__ $$",
Expand All @@ -91,27 +75,24 @@ constexpr char CAPIO_LOG_SERVER_BANNER[14][80] = {
"",
};

constexpr char CAPIO_LOG_SERVER_CLI_LOGGING_NOT_AVAILABLE[] =
"CAPIO_LOG set but log support was not compiled into CAPIO!";
constexpr char CAPIO_LOG_SERVER_REQUEST_START[] = "\n+++++++++++ REQUEST +++++++++++";
constexpr char CAPIO_LOG_SERVER_REQUEST_END[] = "~~~~~~~~~ END REQUEST ~~~~~~~~~\n";

// Server - Warning banners
constexpr char CAPIO_LOG_SERVER_CLI_LOGGING_ENABLED_WARNING[5][80] = {
constexpr char CAPIO_LOG_SERVER_CLI_LOGGING_ENABLED_WARNING[6][80] = {
"\033[1;33m|==================================================================|\033[0m",
"\033[1;33m| you are running a build of CAPIO with logging enabled. |\033[0m",
"\033[1;33m| this will have impact on performance. you should recompile CAPIO |\033[0m",
"\033[1;33m| with -DCAPIO_LOG=FALSE |\033[0m",
"\033[1;33m|==================================================================|\033[0m"};
"\033[1;33m|==================================================================|\033[0m",
""};

constexpr char CAPIO_LOG_SERVER_CLI_CONT_ON_ERR_WARNING[7][80] = {
constexpr char CAPIO_LOG_SERVER_CLI_CONT_ON_ERR_WARNING[8][80] = {
"\033[1;31m|==================================================================|\033[0m",
"\033[1;31m| you are running CAPIO with --continue-on-error |\033[0m",
"\033[1;31m| This is extremely dangerous as CAPIO server will continue |\033[0m",
"\033[1;31m| its execution even if it should terminate. |\033[0m",
"\033[1;31m| |\033[0m",
"\033[1;31m| USE IT AT YOUR OWN RISK |\033[0m",
"\033[1;31m|==================================================================|\033[0m"};
"\033[1;31m|==================================================================|\033[0m",
""};

// CAPIO server argument parser
constexpr char CAPIO_SERVER_ARG_PARSER_PRE[] =
Expand Down Expand Up @@ -146,11 +127,4 @@ constexpr char CAPIO_SERVER_ARG_PARSER_CONFIG_BACKEND_HELP[] =
"Backend used in CAPIO. The value [backend] can be one of the following implemented backends: "
"\n\t> mpi \n\t> mpisync \n\t> none (default)";

// Cli pre messages
constexpr char CAPIO_LOG_SERVER_CLI_LEVEL_RESET[] = "\033[0m";
constexpr char CAPIO_LOG_SERVER_CLI_LEVEL_STATUS[] = "\033[1;34m";
constexpr char CAPIO_LOG_SERVER_CLI_LEVEL_INFO[] = "\033[1;32m";
constexpr char CAPIO_LOG_SERVER_CLI_LEVEL_WARNING[] = "\033[1;33m";
constexpr char CAPIO_LOG_SERVER_CLI_LEVEL_ERROR[] = "\033[1;31m";

#endif // CAPIO_COMMON_CONSTANTS_HPP
43 changes: 16 additions & 27 deletions capio/common/env.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
#include <cstdlib>
#include <filesystem>
#include <iostream>

#include <sys/stat.h>

#include "common/constants.hpp"
#include "common/syscall.hpp"
#include "logger.hpp"

#include <calf/StdOutLogger.h>

#ifdef __CAPIO_POSIX
#include "calf/SyscallLogger.h"
#else
#include "calf/StlLogger.h"
#endif

// TODO: remove forward declaration of function by splitting into header and impl. capio/common
inline bool is_forbidden_path(const std::string_view &path);
Expand All @@ -26,19 +33,19 @@ inline const std::filesystem::path &get_capio_dir() {

if (val == nullptr) {

std::cout << "\n"
<< CAPIO_LOG_SERVER_CLI_LEVEL_ERROR << "Fatal: CAPIO_DIR not provided!"
<< std::endl;
#ifndef __CAPIO_POSIX
CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR, "CAPIO_DIR not provided");
#endif
ERR_EXIT("Fatal: CAPIO_DIR not provided!");

} else {

const char *realpath_res = capio_realpath(val, buf.get());
if (realpath_res == nullptr) {
std::cout << "\n"
<< CAPIO_LOG_SERVER_CLI_LEVEL_ERROR
<< "Fatal: CAPIO_DIR set, but folder does not exists on filesystem!"
<< std::endl;
#ifndef __CAPIO_POSIX
CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR,
"Fatal: CAPIO_DIR set, but folder does not exists on filesystem!");
#endif
ERR_EXIT("error CAPIO_DIR: directory %s does not "
"exist. [buf=%s]",
val, buf.get());
Expand Down Expand Up @@ -91,24 +98,6 @@ inline long get_cache_line_size() {
return data_bufs_count;
}

inline int get_capio_log_level() {
static int level = -2;
if (level == -2) {
char *log_level = std::getenv("CAPIO_LOG_LEVEL");
if (log_level == nullptr) {
level = 0;
} else {
auto [ptr, ec] = std::from_chars(log_level, log_level + strlen(log_level), level);
if (ec != std::errc()) {
std::cout << CAPIO_LOG_SERVER_CLI_LEVEL_WARNING << "invalid CAPIO_LOG_LEVEL value"
<< std::endl;
level = 0;
}
}
}
return level;
}

inline std::string get_capio_workflow_name() {
static std::string name;
if (name.empty()) {
Expand Down
7 changes: 6 additions & 1 deletion capio/common/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

#include <sys/stat.h>

#include "common/logger.hpp"
#ifdef __CAPIO_POSIX
#include "calf/SyscallLogger.h"
#else
#include "calf/StlLogger.h"
#endif

#include "common/syscall.hpp"
#include "env.hpp"

Expand Down
Loading
Loading