Mantid
Loading...
Searching...
No Matches
Namespaces | Macros | Functions
MultiThreaded.h File Reference
#include <atomic>
#include <mutex>

Go to the source code of this file.

Namespaces

namespace  Mantid
 Helper class which provides the Collimation Length for SANS instruments.
 
namespace  Mantid::Kernel
 

Macros

#define IF_NOT_PARALLEL
 
#define IF_PARALLEL   if (false)
 
#define PARALLEL
 
#define PARALLEL_ATOMIC
 
#define PARALLEL_CHECK_INTERRUPT_REGION
 Adds a check after a Parallel region to see if it was interupted. More...
 
#define PARALLEL_CRITICAL(name)
 
#define PARALLEL_END_INTERRUPT_REGION
 Ends a block to skip processing is the algorithm has been interupted Note the start of the block if not defined that must be added by including PARALLEL_START_INTERRUPT_REGION at the start of the loop. More...
 
#define PARALLEL_FOR_IF(condition)
 Empty definitions - to enable set your complier to enable openMP. More...
 
#define PARALLEL_FOR_NO_WSP_CHECK()
 
#define PARALLEL_FOR_NO_WSP_CHECK_FIRSTPRIVATE2(variable1, variable2)
 
#define PARALLEL_FOR_NOWS_CHECK_FIRSTPRIVATE(variable)
 
#define PARALLEL_GET_MAX_THREADS   1
 
#define PARALLEL_NUMBER_OF_THREADS   1
 
#define PARALLEL_SECTION
 
#define PARALLEL_SECTIONS
 
#define PARALLEL_SET_CONFIG_THREADS
 
#define PARALLEL_SET_DYNAMIC(val)
 
#define PARALLEL_SET_NUM_THREADS(MaxCores)
 
#define PARALLEL_START_INTERRUPT_REGION
 Begins a block to skip processing is the algorithm has been interupted Note the end of the block if not defined that must be added by including PARALLEL_END_INTERRUPT_REGION at the end of the loop. More...
 
#define PARALLEL_THREAD_NUMBER   0
 
#define PRAGMA(x)   _Pragma(#x)
 
#define PRAGMA_OMP(expression)
 

Functions

template<typename T , typename BinaryOp >
void Mantid::Kernel::AtomicOp (std::atomic< T > &f, T d, BinaryOp op)
 Uses std::compare_exchange_weak to update the atomic value f = op(f, d) Used to improve parallel scaling in algorithms MDNormDirectSC and MDNormSCD. More...
 
template<typename Arg >
std::enable_if< std::is_pointer< Arg >::value, bool >::type Mantid::Kernel::threadSafe (Arg workspace)
 Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access. More...
 
template<typename Arg , typename... Args>
std::enable_if< std::is_pointer< Arg >::value, bool >::type Mantid::Kernel::threadSafe (Arg workspace, Args &&...others)
 Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access. More...
 
template<typename Arg >
std::enable_if<!std::is_pointer< Arg >::value, bool >::type Mantid::Kernel::threadSafe (const Arg &workspace)
 Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access. More...
 
template<typename Arg , typename... Args>
std::enable_if<!std::is_pointer< Arg >::value, bool >::type Mantid::Kernel::threadSafe (const Arg &workspace, Args &&...others)
 Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access. More...
 

Macro Definition Documentation

◆ IF_NOT_PARALLEL

#define IF_NOT_PARALLEL

Definition at line 223 of file MultiThreaded.h.

◆ IF_PARALLEL

#define IF_PARALLEL   if (false)

Definition at line 222 of file MultiThreaded.h.

◆ PARALLEL

#define PARALLEL

Definition at line 231 of file MultiThreaded.h.

◆ PARALLEL_ATOMIC

#define PARALLEL_ATOMIC

Definition at line 225 of file MultiThreaded.h.

◆ PARALLEL_CHECK_INTERRUPT_REGION

#define PARALLEL_CHECK_INTERRUPT_REGION
Value:
if (m_parallelException) { \
g_log.debug("Exception thrown in parallel region"); \
throw std::runtime_error(this->name() + ": error (see log)"); \
} \
interruption_point();
void debug(const std::string &msg)
Logs at debug level.
Definition: Logger.cpp:114

Adds a check after a Parallel region to see if it was interupted.

Definition at line 117 of file MultiThreaded.h.

◆ PARALLEL_CRITICAL

#define PARALLEL_CRITICAL (   name)

Definition at line 224 of file MultiThreaded.h.

◆ PARALLEL_END_INTERRUPT_REGION

#define PARALLEL_END_INTERRUPT_REGION
Value:
} /* End of try block in PARALLEL_START_INTERRUPT_REGION */ \
catch (std::exception & ex) { \
if (!m_parallelException) { \
m_parallelException = true; \
g_log.error() << this->name() << ": " << ex.what() << "\n"; \
} \
} \
catch (...) { \
m_parallelException = true; \
} \
}
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77

Ends a block to skip processing is the algorithm has been interupted Note the start of the block if not defined that must be added by including PARALLEL_START_INTERRUPT_REGION at the start of the loop.

Definition at line 102 of file MultiThreaded.h.

◆ PARALLEL_FOR_IF

#define PARALLEL_FOR_IF (   condition)

Empty definitions - to enable set your complier to enable openMP.

Definition at line 218 of file MultiThreaded.h.

◆ PARALLEL_FOR_NO_WSP_CHECK

#define PARALLEL_FOR_NO_WSP_CHECK ( )

Definition at line 219 of file MultiThreaded.h.

◆ PARALLEL_FOR_NO_WSP_CHECK_FIRSTPRIVATE2

#define PARALLEL_FOR_NO_WSP_CHECK_FIRSTPRIVATE2 (   variable1,
  variable2 
)

Definition at line 221 of file MultiThreaded.h.

◆ PARALLEL_FOR_NOWS_CHECK_FIRSTPRIVATE

#define PARALLEL_FOR_NOWS_CHECK_FIRSTPRIVATE (   variable)

Definition at line 220 of file MultiThreaded.h.

◆ PARALLEL_GET_MAX_THREADS

#define PARALLEL_GET_MAX_THREADS   1

Definition at line 230 of file MultiThreaded.h.

◆ PARALLEL_NUMBER_OF_THREADS

#define PARALLEL_NUMBER_OF_THREADS   1

Definition at line 229 of file MultiThreaded.h.

◆ PARALLEL_SECTION

#define PARALLEL_SECTION

Definition at line 233 of file MultiThreaded.h.

◆ PARALLEL_SECTIONS

#define PARALLEL_SECTIONS

Definition at line 232 of file MultiThreaded.h.

◆ PARALLEL_SET_CONFIG_THREADS

#define PARALLEL_SET_CONFIG_THREADS
Value:
setMaxCoresToConfig(); \
PARALLEL_SET_DYNAMIC(false);

Definition at line 85 of file MultiThreaded.h.

◆ PARALLEL_SET_DYNAMIC

#define PARALLEL_SET_DYNAMIC (   val)

Definition at line 228 of file MultiThreaded.h.

◆ PARALLEL_SET_NUM_THREADS

#define PARALLEL_SET_NUM_THREADS (   MaxCores)

Definition at line 227 of file MultiThreaded.h.

◆ PARALLEL_START_INTERRUPT_REGION

#define PARALLEL_START_INTERRUPT_REGION
Value:
if (!m_parallelException && !m_cancel) { \
try {

Begins a block to skip processing is the algorithm has been interupted Note the end of the block if not defined that must be added by including PARALLEL_END_INTERRUPT_REGION at the end of the loop.

Definition at line 94 of file MultiThreaded.h.

◆ PARALLEL_THREAD_NUMBER

#define PARALLEL_THREAD_NUMBER   0

Definition at line 226 of file MultiThreaded.h.

◆ PRAGMA

#define PRAGMA (   x)    _Pragma(#x)

Definition at line 84 of file MultiThreaded.h.

◆ PRAGMA_OMP

#define PRAGMA_OMP (   expression)

Definition at line 234 of file MultiThreaded.h.