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

Merge branch '135-make-chunk-computations-constexpr' into 'master'

Resolve "Make chunk computations constexpr"

This MR implements the following changes:

- All arithmetic operations based on block sizes are now constexpr.
- Add several new functions, also constexpr: is_aligned(),
is_power_of_2().  - Reimplement log2() to make it faster based on
compiler builtins.  - Rename functions to avoid depending on the concept
of chunk (in preparation for more chunk-agnostic code).  - Add
exhaustive tests for all these functions and enable them in the CI.
- Rename the gkfs::util namespace to gkfs::utils.  - Create the
gkfs::utils::arithmetic namespace for all these functions, as well as
a convenience library/target in CMake for easier testing.

Fixes #137
Closes #135

See merge request !75
parents e0a1a1ed d4807ad9
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -95,6 +95,15 @@ integration tests:
    paths:
      - "${INTEGRATION_TESTS_RUN_PATH}"

unit:
  stage: test
  script:
    - ctest -j $(nproc) -L unit::all
  artifacts:
    when: on_failure
    paths:
      - Testing

test wr:
  stage: test
  script:
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ static const auto constexpr most = log_level::print_most;
static const auto constexpr all = log_level::print_all;
static const auto constexpr help = log_level::print_help;

static const auto constexpr level_names = util::make_array(
static const auto constexpr level_names = utils::make_array(
        "syscall",
        "syscall", // sycall_entry uses the same name as syscall
        "info", "critical", "error", "warning", "hermes", "mercury", "debug");
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

#include <array>

namespace gkfs::util {
namespace gkfs::utils {

template <typename... T>
constexpr auto
@@ -28,6 +28,6 @@ make_array(T&&... values) -> std::array<
            sizeof...(T)>{std::forward<T>(values)...};
}

} // namespace gkfs::util
} // namespace gkfs::utils

#endif // LIBGKFS_UTILS_MAKE_ARRAY_HPP
+2 −2
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ class async_engine;
extern std::unique_ptr<hermes::async_engine> ld_network_service;

// function definitions
namespace gkfs::util {
namespace gkfs::utils {
template <typename E>
constexpr typename std::underlying_type<E>::type
to_underlying(E e) {
@@ -74,6 +74,6 @@ read_hosts_file();
void
connect_to_hosts(const std::vector<std::pair<std::string, std::string>>& hosts);

} // namespace gkfs::util
} // namespace gkfs::utils

#endif // GEKKOFS_PRELOAD_UTIL_HPP
+8 −8
Original line number Diff line number Diff line
@@ -291,7 +291,7 @@ format_whence_arg_to(FmtBuffer& buffer, const printable_arg& parg) {

    /* Names for lseek() whence arg */
    const auto flag_names =
            util::make_array(
            utils::make_array(
            FLAG_ENTRY(SEEK_SET),
            FLAG_ENTRY(SEEK_CUR),
            FLAG_ENTRY(SEEK_END)
@@ -314,7 +314,7 @@ format_mmap_prot_arg_to(FmtBuffer& buffer, const printable_arg& parg) {

    /* Names for mmap() prot arg */
    const auto flag_names =
            util::make_array(
            utils::make_array(
            FLAG_ENTRY(PROT_NONE),
            FLAG_ENTRY(PROT_READ),
            FLAG_ENTRY(PROT_WRITE),
@@ -339,7 +339,7 @@ format_mmap_flags_arg_to(FmtBuffer& buffer, const printable_arg& parg) {

    /* Names for mmap() flags arg */
    const auto flag_names =
            util::make_array(
            utils::make_array(
            FLAG_ENTRY(MAP_SHARED),
            FLAG_ENTRY(MAP_PRIVATE),
#ifdef MAP_SHARED_VALIDATE
@@ -379,7 +379,7 @@ format_clone_flags_arg_to(FmtBuffer& buffer, const printable_arg& parg) {

    /* Names for clone() flags arg */
    const auto flag_names =
            util::make_array(
            utils::make_array(
            FLAG_ENTRY(CLONE_VM),
            FLAG_ENTRY(CLONE_FS),
            FLAG_ENTRY(CLONE_FILES),
@@ -431,7 +431,7 @@ format_signum_arg_to(FmtBuffer& buffer, const printable_arg& parg) {

    /* Names for signum args */
    const auto flag_names =
            util::make_array(
            utils::make_array(
            FLAG_ENTRY(SIGHUP),
            FLAG_ENTRY(SIGINT),
            FLAG_ENTRY(SIGQUIT),
@@ -485,7 +485,7 @@ format_sigproc_how_arg_to(FmtBuffer& buffer, const printable_arg& parg) {

    /* Names for sigproc how args */
    const auto flag_names =
            util::make_array(
            utils::make_array(
            FLAG_ENTRY(SIG_BLOCK),
            FLAG_ENTRY(SIG_UNBLOCK),
            FLAG_ENTRY(SIG_SETMASK));
@@ -572,13 +572,13 @@ format_open_flags_to(FmtBuffer& buffer,

    /* Names for O_ACCMODE args */
    const auto flag_names =
            util::make_array(
            utils::make_array(
            FLAG_ENTRY(O_RDONLY),
            FLAG_ENTRY(O_WRONLY),
            FLAG_ENTRY(O_RDWR));

    const auto extra_flag_names =
            util::make_array(
            utils::make_array(
#ifdef O_EXEC
            FLAG_ENTRY(O_EXEC),
#endif
Loading