Skip to content

Commit

Permalink
Merge pull request #26 from SC-SGS/change_mutex_defaults
Browse files Browse the repository at this point in the history
Change mutex defaults
  • Loading branch information
G-071 authored Oct 8, 2023
2 parents 733b870 + e515ae1 commit c1ae269
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
11 changes: 2 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(CMAKE_CXX_STANDARD 17)

set(CPPUDDLE_VERSION_MAJOR 0)
set(CPPUDDLE_VERSION_MINOR 3)
set(CPPUDDLE_VERSION_PATCH 0)
set(CPPUDDLE_VERSION_PATCH 1)
set(CPPUDDLE_VERSION_STRING "${CPPUDDLE_VERSION_MAJOR}.${CPPUDDLE_VERSION_MINOR}.${CPPUDDLE_VERSION_PATCH}.")

#------------------------------------------------------------------------------------------------------------
Expand All @@ -27,7 +27,7 @@ set(CPPUDDLE_WITH_MAX_NUMBER_GPUS "1" CACHE STRING "Number of GPUs that will be
# HPX-related options
option(CPPUDDLE_WITH_HPX "Enable basic HPX integration and examples" OFF)
option(CPPUDDLE_WITH_HPX_AWARE_ALLOCATORS "Enable HPX-aware allocators for even better HPX integration" ON)
set(CPPUDDLE_WITH_HPX_MUTEX OFF CACHE BOOL
set(CPPUDDLE_WITH_HPX_MUTEX ON CACHE BOOL
"Use HPX spinlock mutex instead of std::mutex")
set(CPPUDDLE_WITH_NUMBER_BUCKETS "128" CACHE STRING "Number of internal recycle buckets buffer type. Should ideally match the intended number of HPX workers or be 1 in non-HPX builds.")
# Test-related options
Expand All @@ -49,13 +49,6 @@ if (CPPUDDLE_WITH_HPX)
find_package(HPX 1.8.0 REQUIRED) # older versions might work but are untested with the current cppuddle
endif()

# HPX mutex requires HPX-Support
if(CPPUDDLE_WITH_HPX_MUTEX)
if(NOT CPPUDDLE_WITH_HPX)
message(FATAL_ERROR " CPPUDDLE_WITH_HPX_MUTEX requires a build with HPX (CPPUDDLE_WITH_HPX=ON)")
endif()
endif()

# HPX build are really better with HPX-aware allocators: Warn if disabled
if(CPPUDDLE_WITH_HPX)
if(NOT CPPUDDLE_WITH_HPX_AWARE_ALLOCATORS)
Expand Down
14 changes: 14 additions & 0 deletions include/aggregation_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#ifndef WORK_AGGREGATION_MANAGER
#define WORK_AGGREGATION_MANAGER

#ifndef CPPUDDLE_HAVE_HPX
#error "Work aggregation allocators/executors require CPPUDDLE_WITH_HPX=ON"
#endif

#include <stdexcept>
#define DEBUG_AGGREGATION_CALLS 1

Expand Down Expand Up @@ -48,6 +52,16 @@
#include "../include/stream_manager.hpp"
#include "../include/detail/config.hpp"

#ifndef CPPUDDLE_HAVE_HPX_MUTEX
#pragma message \
"Work aggregation will use hpx::mutex internally, despite CPPUDDLE_WITH_HPX_MUTEX=OFF"
#pragma message \
"Consider using CPPUDDLE_WITH_HPX_MUTEX=ON, to make the rest of CPPuddle also use hpx::mutex"
#endif
namespace recycler {
using aggregation_mutex_t = hpx::mutex;
}

//===============================================================================
//===============================================================================
// Helper functions/classes
Expand Down
2 changes: 0 additions & 2 deletions include/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ namespace recycler {

#if defined(CPPUDDLE_HAVE_HPX) && defined(CPPUDDLE_HAVE_HPX_MUTEX)
using mutex_t = hpx::spinlock_no_backoff;
using aggregation_mutex_t = hpx::mutex;
#else
using mutex_t = std::mutex;
using aggregation_mutex_t = std::mutex;
#endif

// Recycling configuration
Expand Down

0 comments on commit c1ae269

Please sign in to comment.