Skip to content

Commit

Permalink
Merge pull request #342 from LLNL/feature/boost1.87
Browse files Browse the repository at this point in the history
Support Boost 1.87
  • Loading branch information
KIwabuchi authored Jan 7, 2025
2 parents ee4859c + 422d2bf commit 5e3b2b6
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 50 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI Test
on: [push, pull_request]

jobs:
bst1-86-0:
bst1-87-0:
runs-on: ubuntu-latest
env:
METALL_LIMIT_MAKE_PARALLELS: 8
Expand All @@ -12,9 +12,9 @@ jobs:
- name: Test
run: |
pushd /dev/shm
wget -q https://boostorg.jfrog.io/artifactory/main/release/1.86.0/source/boost_1_86_0.tar.gz
wget -q https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz
mkdir boost
tar xf boost_1_86_0.tar.gz -C boost --strip-components 1
tar xf boost_1_87_0.tar.gz -C boost --strip-components 1
export BOOST_ROOT=${PWD}/boost
popd
export METALL_TEST_DIR=${GITHUB_JOB}
Expand All @@ -32,7 +32,7 @@ jobs:
- name: Test
run: |
pushd /dev/shm
wget -q https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz
wget -q https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz
mkdir boost
tar xf boost_1_80_0.tar.gz -C boost --strip-components 1
export BOOST_ROOT=${PWD}/boost
Expand Down
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GitLab CI YML file dedicated for LC environment (Quartz)
# GitLab CI YML file dedicated for LC environment (Ruby)
#
# Spack must be available
# It would be better to install all Boost versions manually,
Expand All @@ -25,21 +25,21 @@ install_boost:
- shell
script:
- hostname
- srun -N1 -ppci spack install boost@1.86.0 boost@1.85.0 boost@1.84.0 boost@1.83.0 boost@1.82.0 boost@1.81.0 boost@1.80.0
- srun -N1 -ppci -A seq spack install boost@1.86.0 boost@1.85.0 boost@1.84.0 boost@1.83.0 boost@1.82.0 boost@1.81.0 boost@1.80.0
- spack clean


.build:
stage: build
tags:
- quartz
- ruby
- shell
script:
- echo "=== build section ==="
- module load gcc/${GCC_VERSION}
- spack load --first boost@${BOOST_VERSION} arch=$(spack arch)
- export METALL_TEST_DIR="/dev/shm/metall_test-${CI_CONCURRENT_ID}-${CI_PIPELINE_IID}"
- srun -N1 -ppci bash ./scripts/CI/build_and_test.sh
- srun -N1 -ppci -A seq bash ./scripts/CI/build_and_test.sh

build_gcc12.1.1_bst1.86.0:
extends: .build
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ find_boost_headers(1.80 FALSE)
if (NOT Boost_FOUND)
message(STATUS "Fetching Boost")
FetchContent_Declare(Boost
URL https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.bz2)
URL https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.bz2
SYSTEM)
FetchContent_MakeAvailable(Boost)
set(BOOST_ROOT ${boost_SOURCE_DIR})
find_package(Boost 1.80 REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions cmake/find_boost_headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function(find_boost_headers min_version required)
if (Boost_FOUND)
set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} PARENT_SCOPE)
set(Boost_FOUND ${Boost_FOUND} PARENT_SCOPE)
message(STATUS "Found Boost at ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost version: ${Boost_VERSION}")
return()
endif ()

Expand Down
18 changes: 0 additions & 18 deletions include/metall/detail/in_place_interface.hpp

This file was deleted.

46 changes: 43 additions & 3 deletions include/metall/detail/named_proxy.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// Copyright 2019 Lawrence Livermore National Security, LLC and other Metall
// Copyright 2024 Lawrence Livermore National Security, LLC and other Metall
// Project Developers. See the top-level COPYRIGHT file for details.
//
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

// This file contains some code from Boost.Interprocess.
// Here is the original license:
// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef METALL_UTILITY_DETAIL_NAMED_PROXY_HPP
#define METALL_UTILITY_DETAIL_NAMED_PROXY_HPP

Expand All @@ -12,13 +18,47 @@
/// \brief Namespace for implementation details
namespace metall::mtlldetail {

template <typename T, bool is_iterator, typename... Args>
using CtorArgN =
boost::interprocess::ipcdetail::CtorArgN<T, is_iterator, Args...>;

/// \brief Proxy class that implements named allocation syntax.
/// \tparam segment_manager segment manager to construct the object
/// \tparam T type of object to build
/// \tparam is_iterator passing parameters are normal object or iterators?
template <typename segment_manager, typename T, bool is_iterator>
using named_proxy = boost::interprocess::ipcdetail::named_proxy<segment_manager,
T, is_iterator>;
class named_proxy {
public:
using char_type = typename segment_manager::char_type;

named_proxy(segment_manager *mngr, const char_type *name, bool find,
bool dothrow)
: m_name(name),
m_mngr(mngr),
m_num(1),
m_find(find),
m_dothrow(dothrow) {}

template <typename... Args>
T *operator()(Args &&...args) const {
CtorArgN<T, is_iterator, Args...> ctor_obj(std::forward<Args>(args)...);
return m_mngr->template generic_construct<T>(
m_name, m_num, m_find, m_dothrow, ctor_obj);
}

// This operator allows --> named_new("Name")[3]; <-- syntax
const named_proxy &operator[](const std::size_t num) const {
m_num *= num;
return *this;
}

private:
const char_type *const m_name;
segment_manager *const m_mngr;
mutable std::size_t m_num;
const bool m_find;
const bool m_dothrow;
};

} // namespace metall::mtlldetail

Expand Down
11 changes: 5 additions & 6 deletions include/metall/kernel/manager_kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <metall/kernel/attributed_object_directory.hpp>
#include <metall/object_attribute_accessor.hpp>
#include <metall/detail/utilities.hpp>
#include <metall/detail/in_place_interface.hpp>
#include <metall/detail/file.hpp>
#include <metall/detail/file_clone.hpp>
#include <metall/detail/char_ptr_holder.hpp>
Expand Down Expand Up @@ -328,11 +327,11 @@ class manager_kernel {
/// the same name. \param do_throw Ignored. This method does not throw its own
/// exception --- this function throws an exception thrown by the constructor
/// of the object. This is how Boost.Interprocess treats this parameter.
/// \param table Reference to an in_place_interface object.
/// \param pr Reference to a CtorArgN object.
/// \return Returns a pointer to the constructed object(s).
template <typename T>
template <typename T, typename proxy>
T *generic_construct(char_ptr_holder_type name, size_type num, bool try2find,
bool do_throw, mdtl::in_place_interface &table);
bool do_throw, proxy &pr);

/// \brief Return a reference to the segment header.
/// \return A reference to the segment header.
Expand Down Expand Up @@ -500,9 +499,9 @@ class manager_kernel {
static bool priv_unmark_properly_closed(const path_type &base_path);

// ---------- For constructed objects ---------- //
template <typename T>
template <typename T, typename proxy>
T *priv_generic_construct(char_ptr_holder_type name, size_type length,
bool try2find, mdtl::in_place_interface &table);
bool try2find, proxy &pr);

template <typename T>
bool priv_register_attr_object_no_mutex(char_ptr_holder_type name,
Expand Down
22 changes: 8 additions & 14 deletions include/metall/kernel/manager_kernel_impl.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,12 @@ manager_kernel<st, sst, cn, cs>::anonymous_end() const {
}

template <typename st, typename sst, typename cn, std::size_t cs>
template <typename T>
template <typename T, typename proxy>
T *manager_kernel<st, sst, cn, cs>::generic_construct(
char_ptr_holder_type name, const size_type num, const bool try2find,
[[maybe_unused]] const bool do_throw, mdtl::in_place_interface &table) {
[[maybe_unused]] const bool do_throw, proxy &pr) {
priv_check_sanity();
return priv_generic_construct<T>(name, num, try2find, table);
return priv_generic_construct<T>(name, num, try2find, pr);
}

template <typename st, typename sst, typename cn, std::size_t cs>
Expand Down Expand Up @@ -694,15 +694,9 @@ bool manager_kernel<st, sst, cn, cs>::priv_unmark_properly_closed(
}

template <typename st, typename sst, typename cn, std::size_t cs>
template <typename T>
template <typename T, typename proxy>
T *manager_kernel<st, sst, cn, cs>::priv_generic_construct(
char_ptr_holder_type name, size_type length, bool try2find,
mdtl::in_place_interface &table) {
// Check overflow for security
if (length > ((std::size_t)-1) / table.size) {
return nullptr;
}

char_ptr_holder_type name, size_type length, bool try2find, proxy &pr) {
void *ptr = nullptr;
try {
#ifdef METALL_ENABLE_MUTEX_IN_MANAGER_KERNEL
Expand Down Expand Up @@ -754,18 +748,18 @@ T *manager_kernel<st, sst, cn, cs>::priv_generic_construct(
});

#if BOOST_VERSION >= 108500
table.construct_n(ptr, length);
pr.construct_n(ptr, length);
#else
// Constructs each object in the allocated memory
// When one of objects of T in the array throws exception,
// this function calls T's destructor for successfully constructed objects and
// rethrows the exception
std::size_t constructed = 0;
try {
table.construct_n(ptr, length, constructed);
pr.construct_n(ptr, length, constructed);
} catch (...) {
std::size_t destroyed = 0;
table.destroy_n(ptr, constructed, destroyed);
pr.destroy_n(ptr, constructed, destroyed);
throw;
}
#endif
Expand Down

0 comments on commit 5e3b2b6

Please sign in to comment.