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

Keep track of adhoc storage instances client jobs

* adhoc_storage: Add job client information

* adhoc_storage_manager: Now stores adhoc_storage_info records and
  provides functions to update them.

* adhoc_storage_info: New synchronized type keeping updated information
  about the client job assigned to a adhoc_storage instance

* adhoc_storage: The context can now be updated using a new update()
  function (non-synchronized for now, because it is only ever called
  via the adhoc_storage_manager).

* job_info: Type is now synchronized.

* errors: Add ADM_EADHOC_BUSY. Fix missing error messages for ADM_ENOENT
  and ADM_EEXISTS.

* abt/shared_mutex: Is now movable.
parent 7c0bf64f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -200,6 +200,7 @@ FetchContent_Declare(
)

FetchContent_MakeAvailable(fmt)
set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON)

### spdlog: required for logging
message(STATUS "[${PROJECT_NAME}] Downloading and building spdlog")
+22 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
 * SPDX-License-Identifier: GPL-3.0-or-later
 *****************************************************************************/

#include <cassert>
#include <abt.h>
#include <fmt/format.h>
#include <bits/functexcept.h>
@@ -59,9 +60,30 @@ public:
    // copy constructor and copy assignment operator are disabled
    shared_mutex(const shared_mutex&) = delete;

    shared_mutex(shared_mutex&& rhs) noexcept {
        m_lock = rhs.m_lock;
        rhs.m_lock = ABT_RWLOCK_NULL;
    }

    shared_mutex&
    operator=(const shared_mutex&) = delete;

    shared_mutex&
    operator=(shared_mutex&& other) noexcept {

        if(this == &other) {
            return *this;
        }

        [[maybe_unused]] const auto ret = ABT_rwlock_free(&m_lock);
        assert(ret == ABT_SUCCESS);
        m_lock = other.m_lock;
        other.m_lock = ABT_RWLOCK_NULL;

        return *this;
    }


    // Exclusive ownership

    void
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ target_sources(_api_types PUBLIC admire_types.h admire_types.hpp PRIVATE
target_include_directories(_api_types PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(_api_types PRIVATE
  Margo::Margo common::logger PUBLIC fmt::fmt)
  Margo::Margo common::logger PUBLIC fmt::fmt common::abt_cxx)

set_property(TARGET _api_types PROPERTY POSITION_INDEPENDENT_CODE ON)

+2 −1
Original line number Diff line number Diff line
@@ -46,9 +46,10 @@ typedef enum {
    ADM_ESNAFU,
    ADM_EBADARGS,
    ADM_ENOMEM,
    ADM_EOTHER,
    ADM_EEXISTS,
    ADM_ENOENT,
    ADM_EADHOC_BUSY,
    ADM_EOTHER,
    ADM_ERR_MAX = 512
} ADM_return_t;

+13 −21
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ using transfer_id = std::uint64_t;

namespace internal {
struct job_info;
struct adhoc_storage_info;
} // namespace internal

struct server {
@@ -356,6 +357,9 @@ struct adhoc_storage : public storage {
    std::shared_ptr<storage::ctx>
    context() const final;

    void
    update(admire::adhoc_storage::ctx new_ctx);

private:
    class impl;
    std::unique_ptr<impl> m_pimpl;
@@ -456,15 +460,18 @@ struct fmt::formatter<admire::error_code> : formatter<std::string_view> {
            case ADM_ENOMEM:
                name = "ADM_ENOMEM";
                break;
            case ADM_EOTHER:
                name = "ADM_EOTHER";
                break;
            case ADM_EEXISTS:
                name = "ADM_EEXISTS";
                break;
            case ADM_ENOENT:
                name = "ADM_ENOENT";
                break;
            case ADM_EADHOC_BUSY:
                name = "ADM_EADHOC_BUSY";
                break;
            case ADM_EOTHER:
                name = "ADM_EOTHER";
                break;
            default:
                break;
        }
@@ -640,28 +647,13 @@ struct fmt::formatter<std::shared_ptr<admire::storage>>
    }
};

template <>
struct fmt::formatter<std::optional<std::uint64_t>>
    : formatter<std::string_view> {

    // parse is inherited from formatter<string_view>.
    template <typename FormatContext>
    auto
    format(const std::optional<std::uint64_t>& v, FormatContext& ctx) const {
        return formatter<std::string_view>::format(
                v ? std::to_string(v.value()) : "none", ctx);
    }
};

template <>
struct fmt::formatter<std::optional<admire::adhoc_storage>>
    : formatter<std::string_view> {
template <typename T>
struct fmt::formatter<std::optional<T>> : formatter<std::string_view> {

    // parse is inherited from formatter<string_view>.
    template <typename FormatContext>
    auto
    format(const std::optional<admire::adhoc_storage>& v,
           FormatContext& ctx) const {
    format(const std::optional<T>& v, FormatContext& ctx) const {
        return formatter<std::string_view>::format(
                v ? fmt::format("{}", v.value()) : "none", ctx);
    }
Loading