diff --git a/CMakeLists.txt b/CMakeLists.txt index dba76a843fcf2c42cdf168bec254c89b5757d9d9..fd50a3642681a1275123a762fb3ab59cb9315ecc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -574,23 +574,7 @@ endif() ############################################################################################################################# set ( waLBerla_REQUIRED_MIN_BOOST_VERSION "1.48") -option ( WALBERLA_BUILD_WITH_BOOST_THREAD "Build with boost thread library support" ON ) -# There have been problems with the IBM compiler and boost thread, so WALBERLA_BUILD_WITH_BOOST_THREAD is disabled by default for this compiler -if( WALBERLA_CXX_COMPILER_IS_IBM ) - set ( WALBERLA_BUILD_WITH_BOOST_THREAD OFF CACHE BOOL "Build with boost thread library support" FORCE ) -endif() - -if ( WALBERLA_BUILD_WITH_BOOST_THREAD ) - list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS chrono filesystem system thread ) -else () - list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS chrono filesystem system ) -endif () - -if (( WALBERLA_CXX_COMPILER_IS_IBM ) OR - ( WALBERLA_CXX_COMPILER_IS_GNU AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9 ) OR - ( WALBERLA_CXX_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5 ) ) - list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS regex) - endif() +list ( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS filesystem system ) if ( WALBERLA_BUILD_WITH_PYTHON AND WALBERLA_CXX_COMPILER_IS_MSVC ) list( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS python3 ) @@ -699,11 +683,11 @@ endif() ############################################################################################################################ ## -## PThread is required in Linux environments by boost::thread +## PThread is required in Linux environments by std::thread ## ############################################################################################################################ -if ( NOT WIN32 AND WALBERLA_BUILD_WITH_BOOST_THREAD ) +if ( NOT WIN32 ) add_flag( CMAKE_CXX_FLAGS "-pthread" ) endif() diff --git a/src/core/Regex.h b/src/core/Regex.h index 85eeba2be889b3e4d7968d9a62acfff4f67ea2d3..03d45ba7812fb44b5e6e2cf97666c1f4c313df9e 100644 --- a/src/core/Regex.h +++ b/src/core/Regex.h @@ -22,43 +22,15 @@ #pragma once -#if ( defined WALBERLA_CXX_COMPILER_IS_IBM ) -#include <boost/regex.hpp> -#elif ( defined WALBERLA_CXX_COMPILER_IS_CLANG ) && ( ( __clang_major__ == 3 ) && ( __clang_minor__ <= 4 ) ) -#include <boost/regex.hpp> -#elif ( defined WALBERLA_CXX_COMPILER_IS_GNU ) && ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ <= 8 ) ) -#include <boost/regex.hpp> -#else #include <regex> -#endif namespace walberla { -#if ( defined WALBERLA_CXX_COMPILER_IS_IBM ) -using boost::regex; -using boost::regex_match; -using boost::regex_error; -using boost::regex_search; -using boost::regex_replace; -#elif ( defined WALBERLA_CXX_COMPILER_IS_CLANG ) && ( ( __clang_major__ == 3 ) && ( __clang_minor__ <= 4 ) ) -using boost::regex; -using boost::regex_match; -using boost::regex_error; -using boost::regex_search; -using boost::regex_replace; -#elif ( defined WALBERLA_CXX_COMPILER_IS_GNU ) && ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ <= 8 ) ) -using boost::regex; -using boost::regex_match; -using boost::regex_error; -using boost::regex_search; -using boost::regex_replace; -#else using std::regex; using std::regex_match; using std::regex_error; using std::regex_search; using std::regex_replace; -#endif } \ No newline at end of file diff --git a/src/core/singleton/Singleton.h b/src/core/singleton/Singleton.h index bb3e6ba8eb691e84df4a3334a2696f25e67a70ef..441a730c7e8dfae097317fda450101a71d1f1401 100644 --- a/src/core/singleton/Singleton.h +++ b/src/core/singleton/Singleton.h @@ -27,9 +27,7 @@ #include "core/DataTypes.h" #include "core/NonCopyable.h" -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD -#include <boost/thread/mutex.hpp> -#endif +#include <mutex> /// \cond internal @@ -41,14 +39,11 @@ namespace singleton { #ifdef WALBERLA_CXX_COMPILER_IS_GNU #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunknown-pragmas" -#pragma GCC diagnostic ignored "-Wpragmas" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #endif #ifdef WALBERLA_CXX_COMPILER_IS_CLANG #pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunknown-pragmas" #pragma clang diagnostic ignored "-Wunused-local-typedefs" #endif @@ -495,9 +490,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -520,9 +513,7 @@ private: shared_ptr<D7> dependency7_; //!< Handle to the seventh lifetime dependency. shared_ptr<D8> dependency8_; //!< Handle to the eighth lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -592,9 +583,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -616,9 +605,7 @@ private: shared_ptr<D6> dependency6_; //!< Handle to the sixth lifetime dependency. shared_ptr<D7> dependency7_; //!< Handle to the seventh lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -686,9 +673,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -709,9 +694,7 @@ private: shared_ptr<D5> dependency5_; //!< Handle to the fifth lifetime dependency. shared_ptr<D6> dependency6_; //!< Handle to the sixth lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -776,9 +759,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -798,9 +779,7 @@ private: shared_ptr<D4> dependency4_; //!< Handle to the fourth lifetime dependency. shared_ptr<D5> dependency5_; //!< Handle to the fifth lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -862,9 +841,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -883,9 +860,7 @@ private: shared_ptr<D3> dependency3_; //!< Handle to the third lifetime dependency. shared_ptr<D4> dependency4_; //!< Handle to the fourth lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -944,9 +919,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -964,9 +937,7 @@ private: shared_ptr<D2> dependency2_; //!< Handle to the second lifetime dependency. shared_ptr<D3> dependency3_; //!< Handle to the third lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -1022,9 +993,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -1041,9 +1010,7 @@ private: shared_ptr<D1> dependency1_; //!< Handle to the first lifetime dependency. shared_ptr<D2> dependency2_; //!< Handle to the second lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -1096,9 +1063,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -1114,9 +1079,7 @@ private: //@{ shared_ptr<D1> dependency1_; //!< Handle to the lifetime dependency. -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -1165,9 +1128,7 @@ public: //@{ static const shared_ptr<T>& instance() { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::mutex::scoped_lock lock( instanceMutex_ ); -#endif + std::lock_guard<std::mutex> lock( instanceMutex_ ); static shared_ptr<T> object( new T() ); isInstantiated_ = true; return object; @@ -1181,9 +1142,7 @@ private: //**Member variables**************************************************************************** /*!\name Member variables */ //@{ -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. -#endif + static std::mutex instanceMutex_; //!< Synchronization mutex for access to the singleton. static bool isInstantiated_; //@} @@ -1199,82 +1158,56 @@ private: // //====================================================================================================================== -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H > -boost::mutex Singleton<T,A,B,C,D,E,F,G,H>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,D,E,F,G,H>::instanceMutex_; template< typename T, typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H > bool Singleton<T,A,B,C,D,E,F,G,H>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C, typename D, typename E, typename F, typename G > -boost::mutex Singleton<T,A,B,C,D,E,F,G,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,D,E,F,G,NullType>::instanceMutex_; template< typename T, typename A, typename B, typename C, typename D, typename E, typename F, typename G > bool Singleton<T,A,B,C,D,E,F,G,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C, typename D, typename E, typename F > -boost::mutex Singleton<T,A,B,C,D,E,F,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,D,E,F,NullType,NullType>::instanceMutex_; template< typename T, typename A, typename B, typename C, typename D, typename E, typename F > bool Singleton<T,A,B,C,D,E,F,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C, typename D, typename E > -boost::mutex Singleton<T,A,B,C,D,E,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,D,E,NullType,NullType,NullType>::instanceMutex_; template< typename T, typename A, typename B, typename C, typename D, typename E > bool Singleton<T,A,B,C,D,E,NullType,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C, typename D > -boost::mutex Singleton<T,A,B,C,D,NullType,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,D,NullType,NullType,NullType,NullType>::instanceMutex_; template< typename T, typename A, typename B, typename C, typename D > bool Singleton<T,A,B,C,D,NullType,NullType,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B, typename C > -boost::mutex Singleton<T,A,B,C,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,C,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; template< typename T, typename A, typename B, typename C > bool Singleton<T,A,B,C,NullType,NullType,NullType,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A, typename B > -boost::mutex Singleton<T,A,B,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,B,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; template< typename T, typename A, typename B > bool Singleton<T,A,B,NullType,NullType,NullType,NullType,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T, typename A > -boost::mutex Singleton<T,A,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,A,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; template< typename T, typename A > bool Singleton<T,A,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::isInstantiated_ = false; - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD template< typename T > -boost::mutex Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; -#endif +std::mutex Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::instanceMutex_; template< typename T > bool Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>::isInstantiated_ = false; diff --git a/src/core/timing/Time.h b/src/core/timing/Time.h index 87a962f0ed6e85dabf2eb8dbb12dd49e16c7e6e6..f6112885951e14185e2bdddd3215bde85c495b67 100644 --- a/src/core/timing/Time.h +++ b/src/core/timing/Time.h @@ -31,7 +31,7 @@ #include <sstream> #include <string> -#include <boost/chrono/chrono.hpp> +#include <chrono> #if defined(_MSC_VER) # ifndef NOMINMAX @@ -75,18 +75,7 @@ inline double getCpuTime(); */ inline double getWcTime() { -#ifdef WIN32 - LARGE_INTEGER perfCounter, perfFrequency; - QueryPerformanceCounter( &perfCounter ); - QueryPerformanceFrequency( &perfFrequency ); - return static_cast<double>(perfCounter.QuadPart) / static_cast<double>(perfFrequency.QuadPart); -#elif defined __bg__ // boost::chrono seems broken on BG/Q - struct timeval tp; - gettimeofday( &tp, NULL ); - return ( static_cast<double>( tp.tv_sec ) + static_cast<double>( tp.tv_usec )/1E6 ); -#else - return static_cast<double>(boost::chrono::duration_cast<boost::chrono::nanoseconds>(boost::chrono::high_resolution_clock::now().time_since_epoch()).count()) * 1e-9; -#endif + return static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count()) * 1e-9; } //********************************************************************************************************************** diff --git a/src/core/uid/UID.h b/src/core/uid/UID.h index 3f4cb7f975be744d46917625d0a92c6286eba924..7739f7a39fe5139d27f9dd6614111d98d3e2c731 100644 --- a/src/core/uid/UID.h +++ b/src/core/uid/UID.h @@ -34,9 +34,8 @@ #include <sstream> #include <string> -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD -#include <boost/thread.hpp> -#endif +#include <mutex> +#include <shared_mutex> namespace walberla { @@ -69,8 +68,7 @@ namespace uid { * translates the numerical UID representations into a bit mask. For further information see the documentation of the * two member functions "toIndex()" and "toBitMask()" of this class. * -* If 'WALBERLA_BUILD_WITH_BOOST_THREAD' is defined, the class UID is thread safe and follows -* a multiple-readers / single-writer pattern. +* The class UID is thread safe and follows a multiple-readers / single-writer pattern. */ //********************************************************************************************************************** @@ -129,10 +127,8 @@ private: static std::map< uint_type, std::string >& uidToString() { static std::map< uint_type, std::string > map; return map; } static std::map< std::string, uint_type >& stringToUid() { static std::map< std::string, uint_type > map; return map; } -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - static boost::shared_mutex& uidToStringMutex() { static boost::shared_mutex mutex; return mutex; } - static boost::shared_mutex& stringToUidMutex() { static boost::shared_mutex mutex; return mutex; } -#endif + static std::shared_timed_mutex& uidToStringMutex() { static std::shared_timed_mutex mutex; return mutex; } + static std::shared_timed_mutex& stringToUidMutex() { static std::shared_timed_mutex mutex; return mutex; } uint_type uid_; @@ -197,9 +193,7 @@ inline UID<T>::UID( const std::string& identifier, const bool newUid, const bool template< typename T > void UID<T>::init( const std::string& identifier, const bool newUid, const bool appendUIDtoIdentifier ) { -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > stringToUid_lock( stringToUidMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > stringToUid_lock( stringToUidMutex() ); WALBERLA_ASSERT( !identifier.empty() ); @@ -211,9 +205,7 @@ void UID<T>::init( const std::string& identifier, const bool newUid, const bool WALBERLA_ASSERT( stringToUid().find( idString ) == stringToUid().end() ); // 'idString' must not exist -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > uidToString_lock( uidToStringMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > uidToString_lock( uidToStringMutex() ); uidToString()[ uid_ ] = idString; stringToUid()[ idString ] = uid_; @@ -226,9 +218,7 @@ void UID<T>::init( const std::string& identifier, const bool newUid, const bool uid_ = T::generateUID(); -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > uidToString_lock( uidToStringMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > uidToString_lock( uidToStringMutex() ); uidToString()[ uid_ ] = identifier; stringToUid()[ identifier ] = uid_; } @@ -256,10 +246,7 @@ UID<T>::UID( const bool createAnonymousUID ) : uid_( 0 ) { #endif } else { - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > stringToUid_lock( stringToUidMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > stringToUid_lock( stringToUidMutex() ); uid_ = T::generateUID(); @@ -267,9 +254,7 @@ UID<T>::UID( const bool createAnonymousUID ) : uid_( 0 ) { WALBERLA_ASSERT( stringToUid().find( identifier ) == stringToUid().end() ); // 'identifier' must not exist -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > uidToString_lock( uidToStringMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > uidToString_lock( uidToStringMutex() ); uidToString()[ uid_ ] = identifier; stringToUid()[ identifier ] = uid_; @@ -304,10 +289,7 @@ inline UID<T>::UID( const uint_type uid ) : uid_( uid ) //********************************************************************************************************************** template< typename T > UID<T> UID<T>::getOrConstruct( const std::string& identifier ) { - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > stringToUid_lock( stringToUidMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > stringToUid_lock( stringToUidMutex() ); WALBERLA_ASSERT( !identifier.empty() ); @@ -317,9 +299,7 @@ UID<T> UID<T>::getOrConstruct( const std::string& identifier ) { uint_type uid = T::generateUID(); -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::unique_lock< boost::shared_mutex > uidToString_lock( uidToStringMutex() ); -#endif + std::unique_lock< std::shared_timed_mutex > uidToString_lock( uidToStringMutex() ); uidToString()[ uid ] = identifier; stringToUid()[ identifier ] = uid; @@ -340,10 +320,7 @@ UID<T> UID<T>::getOrConstruct( const std::string& identifier ) { //********************************************************************************************************************** template< typename T > inline UID<T> UID<T>::get( const std::string& identifier ) { - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::shared_lock< boost::shared_mutex > lock( stringToUidMutex() ); -#endif + std::shared_lock< std::shared_timed_mutex > lock( stringToUidMutex() ); WALBERLA_ASSERT( stringToUid().find( identifier ) != stringToUid().end() ); // 'identifier' must exist @@ -354,10 +331,7 @@ inline UID<T> UID<T>::get( const std::string& identifier ) { template< typename T > inline const std::string& UID<T>::getIdentifier() const { - -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - boost::shared_lock< boost::shared_mutex > lock( uidToStringMutex() ); -#endif + std::shared_lock< std::shared_timed_mutex > lock( uidToStringMutex() ); WALBERLA_ASSERT( valid_ ); WALBERLA_ASSERT( uidToString().find( uid_ ) != uidToString().end() ); diff --git a/src/cuda/GPUCopy.cpp b/src/cuda/GPUCopy.cpp index 3c1c8f12649ab4f2de483e4b6a3ebf6877790910..834150fdcb921064392fb99d6690752b6eaaee3c 100644 --- a/src/cuda/GPUCopy.cpp +++ b/src/cuda/GPUCopy.cpp @@ -26,6 +26,8 @@ #include "GPUCopy.h" #include "ErrorChecking.h" +#include <cstring> + namespace walberla { namespace cuda { @@ -56,7 +58,7 @@ void copyDevToDevFZYX( const cudaPitchedPtr& dst, const cudaPitchedPtr& src, WALBERLA_ASSERT( fIntervalSize == 1 || ( Nz == dstAllocSizeZ && Nz == srcAllocSizeZ ) ); cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcX * typeSize, srcY, srcCoordF * srcAllocSizeZ + srcZ ); p.srcPtr = make_cudaPitchedPtr( src.ptr, src.pitch, src.xsize, src.ysize ); @@ -115,7 +117,7 @@ void copyDevToDevZYXF( const cudaPitchedPtr& dst, const cudaPitchedPtr& src, auto copyFunctor = [&](uint_t dstCoordZ, uint_t srcCoordZ, uint_t zIntervalSize) { cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcF * typeSize, srcX, srcCoordZ * srcAllocSizeY + srcY ); p.srcPtr = make_cudaPitchedPtr( src.ptr, src.pitch, src.xsize, src.ysize ); @@ -174,7 +176,7 @@ void copyHostToDevFZYX( const cudaPitchedPtr& dst, unsigned char* src, auto copyFunctor = [&](uint_t dstCoordF, uint_t srcCoordF, uint_t fIntervalSize) { cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcX * typeSize, srcY, srcCoordF * srcAllocSizeZ + srcZ ); p.srcPtr = make_cudaPitchedPtr( src, Nx * typeSize, Nx * typeSize, Ny ); @@ -233,7 +235,7 @@ void copyHostToDevZYXF( const cudaPitchedPtr& dst, unsigned char* src, auto copyFunctor = [&](uint_t dstCoordZ, uint_t srcCoordZ, uint_t zIntervalSize) { cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcF * typeSize, srcX, srcCoordZ * srcAllocSizeY + srcY ); p.srcPtr = make_cudaPitchedPtr( src, Nf * typeSize, Nf * typeSize, Nx ); @@ -293,7 +295,7 @@ void copyDevToHostFZYX( unsigned char* dst, const cudaPitchedPtr& src, auto copyFunctor = [&](uint_t dstCoordF, uint_t srcCoordF, uint_t fIntervalSize) { cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcX * typeSize, srcY, srcCoordF * srcAllocSizeZ + srcZ ); p.srcPtr = make_cudaPitchedPtr( src.ptr, src.pitch, src.xsize, src.ysize ); @@ -353,7 +355,7 @@ void copyDevToHostZYXF( unsigned char* dst, const cudaPitchedPtr& src, auto copyFunctor = [&](uint_t dstCoordZ, uint_t srcCoordZ, uint_t zIntervalSize) { cudaMemcpy3DParms p; - memset( &p, 0, sizeof(p) ); + std::memset( &p, 0, sizeof(p) ); p.srcPos = make_cudaPos( srcF * typeSize, srcX, srcCoordZ * srcAllocSizeY + srcY ); p.srcPtr = make_cudaPitchedPtr( src.ptr, src.pitch, src.xsize, src.ysize ); diff --git a/src/waLBerlaDefinitions.in.h b/src/waLBerlaDefinitions.in.h index 15a6df25970d702d06b0aae11c774f2b8e811e2f..0c4408a40bc7daaedc4f3ef00ff4de125f8c378e 100644 --- a/src/waLBerlaDefinitions.in.h +++ b/src/waLBerlaDefinitions.in.h @@ -23,7 +23,6 @@ #cmakedefine WALBERLA_BUILD_WITH_METIS #cmakedefine WALBERLA_BUILD_WITH_PARMETIS -#cmakedefine WALBERLA_BUILD_WITH_BOOST_THREAD #cmakedefine WALBERLA_BUILD_WITH_PYTHON #cmakedefine WALBERLA_BUILD_WITH_FFT diff --git a/tests/core/CMakeLists.txt b/tests/core/CMakeLists.txt index f81f11461e80d525317c9d909b4ecad08372fd0e..6885cf97661fa507cc240a45207b63a62aec4a43 100644 --- a/tests/core/CMakeLists.txt +++ b/tests/core/CMakeLists.txt @@ -106,10 +106,8 @@ waLBerla_execute_test( NAME EquationSolverTest ) waLBerla_compile_test( FILES mpi/BufferTest.cpp ) waLBerla_execute_test( NAME BufferTest ) -if( WALBERLA_BUILD_WITH_BOOST_THREAD ) - waLBerla_compile_test( FILES mpi/BufferSystemTest.cpp ) - waLBerla_execute_test( NAME BufferSystemTest PROCESSES 4 ) -endif() +waLBerla_compile_test( FILES mpi/BufferSystemTest.cpp ) +waLBerla_execute_test( NAME BufferSystemTest PROCESSES 4 ) waLBerla_compile_test( FILES mpi/BroadcastTest.cpp ) waLBerla_execute_test( NAME BroadcastTest1 COMMAND $<TARGET_FILE:BroadcastTest> ) diff --git a/tests/core/mpi/BufferSystemTest.cpp b/tests/core/mpi/BufferSystemTest.cpp index 9aa4d0f83d9afd22c4296d04909898666fc67e0c..312de87998ecc076f5c968241c0d5066d450728f 100644 --- a/tests/core/mpi/BufferSystemTest.cpp +++ b/tests/core/mpi/BufferSystemTest.cpp @@ -29,15 +29,17 @@ #include <boost/random/mersenne_twister.hpp> #include <boost/random/uniform_int.hpp> #include <boost/random/variate_generator.hpp> -#include <boost/thread/thread.hpp> #include <cmath> #include <iostream> #include <set> +#include <thread> +#include <chrono> using namespace walberla; using mpi::BufferSystem; +using namespace std::literals::chrono_literals; @@ -62,7 +64,7 @@ void randomSleep( int maxTimeInMs = 20 ) boost::variate_generator<base_generator_type&, boost::uniform_int<> > uni(generator, uni_dist); int sleepTime = uni(); - boost::this_thread::sleep( boost::posix_time::milliseconds( sleepTime ) ); + std::this_thread::sleep_for( sleepTime * 1ms ); } diff --git a/tests/core/timing/TimingTreeTest.cpp b/tests/core/timing/TimingTreeTest.cpp index 9d5c539d522657cb51f48bebb3a1737cc44eea8b..862620f326fc8b0eeadcfb55c3b64c6221fd13be 100644 --- a/tests/core/timing/TimingTreeTest.cpp +++ b/tests/core/timing/TimingTreeTest.cpp @@ -25,9 +25,6 @@ #include "core/timing/StaticPolicy.h" #include "core/timing/TimingTree.h" -#include <boost/date_time/posix_time/posix_time.hpp> -#include <boost/thread/thread.hpp> - #include <iostream> using namespace walberla; @@ -41,8 +38,6 @@ int main( int argc, char ** argv ) { debug::enterTestMode(); -#ifdef WALBERLA_BUILD_WITH_BOOST_THREAD - mpi::Environment mpiEnv(argc, argv); WALBERLA_UNUSED( mpiEnv ); @@ -123,7 +118,6 @@ int main( int argc, char ** argv ) // std::cout << tt2; // std::cout << tt3; } -#endif return 0; }