Commit dbebcad9 authored by David Moxey's avatar David Moxey
Browse files

Remove Loki as a dependency of Nektar++

Switch to a simple static member function to implement singletons, which is guaranteed to be thread-safe in C++11.
parent c094be96
...@@ -222,7 +222,6 @@ ENDIF () ...@@ -222,7 +222,6 @@ ENDIF ()
# Find ThirdParty libraries and headers. # Find ThirdParty libraries and headers.
INCLUDE (ThirdPartyTinyxml) INCLUDE (ThirdPartyTinyxml)
INCLUDE (ThirdPartyLoki)
INCLUDE (ThirdPartyMetis) INCLUDE (ThirdPartyMetis)
INCLUDE (ThirdPartyHDF5) INCLUDE (ThirdPartyHDF5)
INCLUDE (ThirdPartyScotch) INCLUDE (ThirdPartyScotch)
......
...@@ -50,10 +50,6 @@ SET(Boost_LIBRARY_DIRS "@Boost_CONFIG_LIBRARY_DIR@") ...@@ -50,10 +50,6 @@ SET(Boost_LIBRARY_DIRS "@Boost_CONFIG_LIBRARY_DIR@")
SET(NEKTAR++_TP_LIBRARIES SET(NEKTAR++_TP_LIBRARIES
${NEKTAR++_TP_LIBRARIES} ${Boost_LIBRARIES}) ${NEKTAR++_TP_LIBRARIES} ${Boost_LIBRARIES})
SET(LOKI_INCLUDE_DIRS "@LOKI_CONFIG_INCLUDE_DIR@")
SET(NEKTAR++_TP_INCLUDE_DIRS
${NEKTAR++_TP_INCLUDE_DIRS} ${LOKI_INCLUDE_DIRS})
SET(TINYXML_INCLUDE_DIRS "@TINYXML_CONFIG_INCLUDE_DIR@") SET(TINYXML_INCLUDE_DIRS "@TINYXML_CONFIG_INCLUDE_DIR@")
SET(NEKTAR++_TP_INCLUDE_DIRS SET(NEKTAR++_TP_INCLUDE_DIRS
${NEKTAR++_TP_INCLUDE_DIRS} ${TINYXML_INCLUDE_DIRS}) ${NEKTAR++_TP_INCLUDE_DIRS} ${TINYXML_INCLUDE_DIRS})
......
########################################################################
#
# ThirdParty configuration for Nektar++
#
# Loki headers library
#
########################################################################
# Try to find system Loki headers. Hint /opt/local/include for MacPorts
# (although there is no Portfile for Loki currently).
FIND_PATH(LOKI_INCLUDE_DIR loki/Singleton.h PATHS /opt/local/include)
IF (LOKI_INCLUDE_DIR)
SET(BUILD_LOKI OFF)
ELSE()
SET(BUILD_LOKI ON)
ENDIF()
OPTION(THIRDPARTY_BUILD_LOKI
"Download and extract Loki library to ThirdParty." ${BUILD_LOKI})
IF (THIRDPARTY_BUILD_LOKI)
# Download Loki if it doesn't already exist.
IF (NOT EXISTS ${TPSRC}/loki-0.1.3.tar.bz2)
FILE(DOWNLOAD ${TPURL}/loki-0.1.3.tar.bz2 ${TPSRC}/loki-0.1.3.tar.bz2)
ENDIF()
# TODO: Check hashes.
# Extract.
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E tar jxf ${TPSRC}/loki-0.1.3.tar.bz2
WORKING_DIRECTORY ${TPSRC}
)
# Set LOKI_INCLUDE_DIR.
FILE(COPY ${TPSRC}/loki-0.1.3/include/loki/ DESTINATION ${TPDIST}/include/loki/)
SET(LOKI_INCLUDE_DIR ${TPDIST}/include CACHE PATH "" FORCE)
MESSAGE(STATUS "Build Loki: ${LOKI_INCLUDE_DIR}")
SET(LOKI_CONFIG_INCLUDE_DIR ${TPINC})
ELSE()
MESSAGE(STATUS "Found Loki: ${LOKI_INCLUDE_DIR}")
SET(LOKI_CONFIG_INCLUDE_DIR ${LOKI_INCLUDE_DIR})
ENDIF()
INCLUDE_DIRECTORIES(SYSTEM ${LOKI_INCLUDE_DIR})
MARK_AS_ADVANCED(LOKI_INCLUDE_DIR)
...@@ -640,10 +640,6 @@ automatically built during the \nekpp build process. Below are the choices of X: ...@@ -640,10 +640,6 @@ automatically built during the \nekpp build process. Below are the choices of X:
(MPI-only) Parallel communication library. (MPI-only) Parallel communication library.
\item \inlsh{LOKI}
An implementation of a singleton.
\item \inlsh{METIS} \item \inlsh{METIS}
A graph partitioning library used for substructuring of matrices and mesh A graph partitioning library used for substructuring of matrices and mesh
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <Collections/Operator.h> #include <Collections/Operator.h>
#include <Collections/Collection.h> #include <Collections/Collection.h>
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <Collections/Operator.h> #include <Collections/Operator.h>
#include <Collections/Collection.h> #include <Collections/Collection.h>
#include <Collections/IProduct.h> #include <Collections/IProduct.h>
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <Collections/Operator.h> #include <Collections/Operator.h>
#include <Collections/Collection.h> #include <Collections/Collection.h>
#include <Collections/IProduct.h> #include <Collections/IProduct.h>
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <Collections/Operator.h> #include <Collections/Operator.h>
#include <Collections/Collection.h> #include <Collections/Collection.h>
...@@ -107,13 +106,10 @@ Operator::~Operator() ...@@ -107,13 +106,10 @@ Operator::~Operator()
/** /**
* *
*/ */
OperatorFactory& GetOperatorFactory() static OperatorFactory& GetOperatorFactory()
{ {
typedef Loki::SingletonHolder<OperatorFactory, static OperatorFactory instance;
Loki::CreateUsingNew, return instance;
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
} }
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <Collections/Operator.h> #include <Collections/Operator.h>
#include <Collections/Collection.h> #include <Collections/Collection.h>
......
...@@ -43,6 +43,4 @@ ...@@ -43,6 +43,4 @@
#define FIELD_UTILS_EXPORT #define FIELD_UTILS_EXPORT
#endif #endif
#define LOKI_CLASS_LEVEL_THREADING
#endif // NEKTAR_FIELD_UTILS_DECLSPEC_H #endif // NEKTAR_FIELD_UTILS_DECLSPEC_H
...@@ -46,12 +46,10 @@ namespace FieldUtils ...@@ -46,12 +46,10 @@ namespace FieldUtils
/** /**
* Returns an instance of the module factory, held as a singleton. * Returns an instance of the module factory, held as a singleton.
*/ */
ModuleFactory &GetModuleFactory() static ModuleFactory &GetModuleFactory()
{ {
typedef Loki::SingletonHolder<ModuleFactory, Loki::CreateUsingNew, static ModuleFactory instance;
Loki::NoDestroy, Loki::SingleThreaded> return instance;
Type;
return Type::Instance();
} }
/** /**
......
...@@ -46,12 +46,10 @@ MappingSharedPtr Mapping::m_mappingPtr = MappingSharedPtr(); ...@@ -46,12 +46,10 @@ MappingSharedPtr Mapping::m_mappingPtr = MappingSharedPtr();
bool Mapping::m_init = false; bool Mapping::m_init = false;
bool Mapping::m_isDefined = false; bool Mapping::m_isDefined = false;
MappingFactory& GetMappingFactory() static MappingFactory& GetMappingFactory()
{ {
typedef Loki::SingletonHolder<MappingFactory, static MappingFactory instance;
Loki::CreateUsingNew, return instance;
Loki::NoDestroy > Type;
return Type::Instance();
} }
Mapping::Mapping(const LibUtilities::SessionReaderSharedPtr& pSession, Mapping::Mapping(const LibUtilities::SessionReaderSharedPtr& pSession,
......
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
#include <LibUtilities/BasicUtils/FieldIO.h> #include <LibUtilities/BasicUtils/FieldIO.h>
#include <LibUtilities/BasicUtils/FileSystem.h> #include <LibUtilities/BasicUtils/FileSystem.h>
#include <loki/Singleton.h>
#include <fstream> #include <fstream>
#include <set> #include <set>
...@@ -73,10 +71,8 @@ std::string fldCmdFormat = SessionReader::RegisterCmdLineArgument( ...@@ -73,10 +71,8 @@ std::string fldCmdFormat = SessionReader::RegisterCmdLineArgument(
*/ */
FieldIOFactory &GetFieldIOFactory() FieldIOFactory &GetFieldIOFactory()
{ {
typedef Loki:: static FieldIOFactory instance;
SingletonHolder<FieldIOFactory, Loki::CreateUsingNew, Loki::NoDestroy, return instance;
Loki::ClassLevelLockable> Type;
return Type::Instance();
} }
/// Enumerator for auto-detection of FieldIO types. /// Enumerator for auto-detection of FieldIO types.
......
...@@ -69,11 +69,8 @@ namespace Nektar ...@@ -69,11 +69,8 @@ namespace Nektar
{ {
MeshPartitionFactory& GetMeshPartitionFactory() MeshPartitionFactory& GetMeshPartitionFactory()
{ {
typedef Loki::SingletonHolder<MeshPartitionFactory, static MeshPartitionFactory instance;
Loki::CreateUsingNew, return instance;
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
} }
MeshPartition::MeshPartition(const LibUtilities::SessionReaderSharedPtr& pSession) : MeshPartition::MeshPartition(const LibUtilities::SessionReaderSharedPtr& pSession) :
......
...@@ -48,11 +48,8 @@ namespace Thread ...@@ -48,11 +48,8 @@ namespace Thread
*/ */
ThreadManagerFactory& GetThreadManagerFactory() ThreadManagerFactory& GetThreadManagerFactory()
{ {
typedef Loki::SingletonHolder<ThreadManagerFactory, static ThreadManagerFactory instance;
Loki::CreateUsingNew, return instance;
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
} }
/** /**
...@@ -142,11 +139,8 @@ ThreadMaster::~ThreadMaster() ...@@ -142,11 +139,8 @@ ThreadMaster::~ThreadMaster()
*/ */
ThreadMaster& GetThreadMaster() ThreadMaster& GetThreadMaster()
{ {
typedef Loki::SingletonHolder<ThreadMaster, static ThreadMaster instance;
Loki::CreateUsingNew, return instance;
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
} }
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include <boost/enable_shared_from_this.hpp> #include <boost/enable_shared_from_this.hpp>
#include <LibUtilities/BasicUtils/NekFactory.hpp> #include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <loki/Singleton.h>
namespace Nektar namespace Nektar
{ {
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/Communication/Comm.h> #include <LibUtilities/Communication/Comm.h>
#include <loki/Singleton.h> // for CreateUsingNew, NoDestroy, etc
namespace Nektar namespace Nektar
{ {
...@@ -60,10 +59,8 @@ bool Comm::v_RemoveExistingFiles(void) ...@@ -60,10 +59,8 @@ bool Comm::v_RemoveExistingFiles(void)
CommFactory &GetCommFactory() CommFactory &GetCommFactory()
{ {
typedef Loki::SingletonHolder<CommFactory, Loki::CreateUsingNew, static CommFactory instance;
Loki::NoDestroy, Loki::SingleThreaded> return instance;
Type;
return Type::Instance();
} }
} }
} }
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/FFT/NektarFFT.h> #include <LibUtilities/FFT/NektarFFT.h>
#include <loki/Singleton.h> // for CreateUsingNew, NoDestroy, etc
namespace Nektar namespace Nektar
{ {
...@@ -68,11 +67,8 @@ namespace Nektar ...@@ -68,11 +67,8 @@ namespace Nektar
NektarFFTFactory& GetNektarFFTFactory() NektarFFTFactory& GetNektarFFTFactory()
{ {
typedef Loki::SingletonHolder<NektarFFTFactory, static NektarFFTFactory instance;
Loki::CreateUsingNew, return instance;
Loki::NoDestroy,
Loki::ClassLevelLockable> Type;
return Type::Instance();
} }
/** /**
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include <loki/Singleton.h>
#include <LibUtilities/Foundations/GaussPoints.h> #include <LibUtilities/Foundations/GaussPoints.h>
#include <LibUtilities/Foundations/FourierPoints.h> #include <LibUtilities/Foundations/FourierPoints.h>
#include <LibUtilities/Foundations/FourierSingleModePoints.h> #include <LibUtilities/Foundations/FourierSingleModePoints.h>
...@@ -109,12 +108,14 @@ namespace Nektar ...@@ -109,12 +108,14 @@ namespace Nektar
PointsManagerT &PointsManager(void) PointsManagerT &PointsManager(void)
{ {
return Loki::SingletonHolder<PointsManagerT>::Instance(); static PointsManagerT instance;
return instance;
} }
BasisManagerT &BasisManager(void) BasisManagerT &BasisManager(void)
{ {
return Loki::SingletonHolder<BasisManagerT>::Instance(); static BasisManagerT instance;
return instance;
} }
} // end of namespace LibUtilities } // end of namespace LibUtilities
......
...@@ -42,16 +42,6 @@ ...@@ -42,16 +42,6 @@
#include <boost/algorithm/string/trim.hpp> #include <boost/algorithm/string/trim.hpp>
#include <boost/random/detail/seed.hpp> #include <boost/random/detail/seed.hpp>
#ifdef _MSC_VER
#include <boost/preprocessor/cat.hpp>
#endif //MSC_VER
#ifdef _MSC_VER
#define NEKTAR_MATH_NAME(x) BOOST_PP_CAT(_, x)
#else
#define NEKTAR_MATH_NAME(x) x
#endif
#if( BOOST_VERSION / 100 % 1000 >= 36 ) #if( BOOST_VERSION / 100 % 1000 >= 36 )
using namespace boost::spirit::classic; using namespace boost::spirit::classic;
#else #else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment