Skip to content

Commit

Permalink
Optionally disable caching allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Dec 2, 2023
1 parent 3253ee1 commit c14df59
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
22 changes: 21 additions & 1 deletion libs/core/allocator_support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,35 @@
# 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)

# Allow to disable caching allocator
hpx_option(
HPX_ALLOCATOR_SUPPORT_WITH_CACHING BOOL
"Enable caching allocator. (default: ON)" ON ADVANCED
CATEGORY "Modules"
MODULE ALLOCATOR_SUPPORT
)

if(HPX_ALLOCATOR_SUPPORT_WITH_CACHING)
hpx_add_config_define_namespace(
DEFINE HPX_ALLOCATOR_SUPPORT_HAVE_CACHING NAMESPACE ALLOCATOR_SUPPORT
)
endif()

set(allocator_support_headers
hpx/allocator_support/aligned_allocator.hpp
hpx/allocator_support/allocator_deleter.hpp
hpx/allocator_support/detail/new.hpp
hpx/allocator_support/internal_allocator.hpp
hpx/allocator_support/thread_local_caching_allocator.hpp
hpx/allocator_support/traits/is_allocator.hpp
)

if(HPX_ALLOCATOR_SUPPORT_WITH_CACHING)
set(allocator_support_headers
${allocator_support_headers}
hpx/allocator_support/thread_local_caching_allocator.hpp
)
endif()

# cmake-format: off
set(allocator_support_compat_headers
hpx/allocator_support.hpp => hpx/modules/allocator_support.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#pragma once

#include <hpx/config.hpp>
#include <hpx/allocator_support/config/defines.hpp>

#include <memory>
#include <new>
Expand All @@ -16,8 +17,10 @@

namespace hpx::util {

#if defined(HPX_ALLOCATOR_SUPPORT_HAVE_CACHING) && \
!((defined(HPX_HAVE_CUDA) && defined(__CUDACC__)) || \
defined(HPX_HAVE_HIP))
///////////////////////////////////////////////////////////////////////////
#if !((defined(HPX_HAVE_CUDA) && defined(__CUDACC__)) || defined(HPX_HAVE_HIP))
template <typename T = char, typename Allocator = std::allocator<T>>
struct thread_local_caching_allocator
{
Expand Down

0 comments on commit c14df59

Please sign in to comment.