Program Listing for File IParallelizable.h
↰ Return to documentation for file (include/gwmodelpp/IParallelizable.h
)
#ifndef IPARALLELIZABLE_H
#define IPARALLELIZABLE_H
namespace gwm
{
enum ParallelType
{
SerialOnly = 1 << 0,
OpenMP = 1 << 1,
CUDA = 1 << 2,
MPI = (1 << 3),
MPI_Serial = (1 << 3) | (1 << 0),
MPI_MP = (1 << 3) | (1 << 1),
MPI_CUDA = (1 << 3) | (1 << 2)
};
struct IParallelizable
{
virtual int parallelAbility() const = 0;
virtual ParallelType parallelType() const = 0;
virtual void setParallelType(const ParallelType& type) = 0;
};
struct IParallelOpenmpEnabled
{
virtual void setOmpThreadNum(const int threadNum) = 0;
};
struct IParallelCudaEnabled
{
virtual void setGPUId(const int gpuId) = 0;
virtual void setGroupSize(const std::size_t size) = 0;
};
struct IParallelMpiEnabled
{
virtual int workerId() = 0;
virtual void setWorkerId(int id) = 0;
virtual void setWorkerNum(int size) = 0;
};
#define GWM_MPI_MASTER_BEGIN if (workerId() == 0) {
#define GWM_MPI_MASTER_END }
#define GWM_MPI_WORKER_BEGIN if (workerId() != 0) {
#define GWM_MPI_WORKER_END }
#define GWM_MPI_MASTER_WORKER_SWITCH } else {
}
#endif // IPARALLELIZABLE_H