distributed.h
Go to the documentation of this file.
# ifndef _RHEO_DISTRIBUTED_H
# define _RHEO_DISTRIBUTED_H
#include "rheolef/compiler_mpi.h"
namespace rheolef {
struct undefined_memory_model {};
struct sequential {};
// compile-time predicate: is_sequential, is_distributed
template<class M>
struct is_sequential {
static const bool value = false;
};
template<class M>
struct is_distributed {
static const bool value = false;
};
template<>
struct is_sequential<sequential> {
static const bool value = true;
};
template<>
struct is_distributed<sequential> {
static const bool value = false;
};
// useful in expressions of type mixing fields and class-functions:
// promote memory_type to the field one
template<class M1, class M2>
struct promote_memory {
typedef undefined_memory_model type;
};
template<>
struct promote_memory<undefined_memory_model,sequential> {
typedef sequential type;
};
template<>
struct promote_memory<sequential,undefined_memory_model> {
typedef sequential type;
};
template<>
struct promote_memory<sequential,sequential> {
typedef sequential type;
};
} // namespace rheolef
#ifndef _RHEOLEF_HAVE_MPI
// -----------------------------------------------------------------------
// distributed code & library should compile even without mpi
// -----------------------------------------------------------------------
# ifndef rheo_default_memory_model
# define rheo_default_memory_model sequential
# endif
namespace rheolef {
struct communicator {
typedef std::vector<int>::size_type size_type;
int rank() const { return 0; }
int size() const { return 1; }
};
} // namespace rheolef
#else
// -----------------------------------------------------------------------
// distributed code here
// -----------------------------------------------------------------------
namespace rheolef {
struct distributed {};
template<>
struct is_sequential<distributed> {
static const bool value = false;
};
template<>
struct is_distributed<distributed> {
static const bool value = true;
};
template<>
struct promote_memory<undefined_memory_model,distributed> {
typedef distributed type;
};
template<>
struct promote_memory<distributed,undefined_memory_model> {
typedef distributed type;
};
template<>
struct promote_memory<distributed,distributed> {
typedef distributed type;
};
} // namespace rheolef
# ifndef rheo_default_memory_model
# define rheo_default_memory_model distributed
# endif
#endif // _RHEOLEF_HAVE_MPI
#include "rheolef/environment.h"
#endif // _RHEO_DISTRIBUTED_H
rheolef::promote_memory< distributed, undefined_memory_model >::type
distributed type
Definition: distributed.h:104
rheolef::sequential
Definition: distributed.h:28
rheolef::promote_memory< sequential, sequential >::type
sequential type
Definition: distributed.h:64
rheolef::promote_memory< distributed, distributed >::type
distributed type
Definition: distributed.h:108
rheolef::size_type
size_t size_type
Definition: basis_get.cc:76
rheolef::is_distributed
Definition: distributed.h:36
rheolef::promote_memory< sequential, undefined_memory_model >::type
sequential type
Definition: distributed.h:60
rheolef::is_sequential
Definition: distributed.h:32
rheolef::distributed
Definition: distributed.h:88
rheolef::promote_memory< undefined_memory_model, distributed >::type
distributed type
Definition: distributed.h:100
rheolef::promote_memory< undefined_memory_model, sequential >::type
sequential type
Definition: distributed.h:56
rheolef::undefined_memory_model
Definition: distributed.h:27
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::promote_memory::type
undefined_memory_model type
Definition: distributed.h:52
rheolef::is_sequential::value
static const bool value
Definition: distributed.h:33
size_type
field::size_type size_type
Definition: branch.cc:425
rheolef::is_distributed::value
static const bool value
Definition: distributed.h:37
rheolef::promote_memory
Definition: distributed.h:51