ActorExt& operator=(const ActorExt&) = delete;
~ActorExt();
void finalize();
- int finalized();
- int initializing();
- int initialized();
+ int finalized() const;
+ int initializing() const;
+ int initialized() const;
void mark_as_initialized();
void set_replaying(bool value);
- bool replaying();
+ bool replaying() const;
void set_tracing_category(const std::string& category) { tracing_category_ = category; }
- const std::string& get_tracing_category() { return tracing_category_; }
+ const std::string& get_tracing_category() const { return tracing_category_; }
smpi_trace_call_location_t* call_location();
void set_privatized_region(smpi_privatization_region_t region);
- smpi_privatization_region_t privatized_region();
- s4u::Mailbox* mailbox() { return mailbox_; }
- s4u::Mailbox* mailbox_small() { return mailbox_small_; }
- s4u::MutexPtr mailboxes_mutex();
+ smpi_privatization_region_t privatized_region() const;
+ s4u::Mailbox* mailbox() const { return mailbox_; }
+ s4u::Mailbox* mailbox_small() const { return mailbox_small_; }
+ s4u::MutexPtr mailboxes_mutex() const;
#if HAVE_PAPI
- int papi_event_set();
+ int papi_event_set() const;
papi_counter_t& papi_counters();
#endif
xbt_os_timer_t timer();
void simulated_start();
- double simulated_elapsed();
- MPI_Comm comm_world();
+ double simulated_elapsed() const;
+ MPI_Comm comm_world() const;
MPI_Comm comm_self();
MPI_Comm comm_intra();
void set_comm_intra(MPI_Comm comm);
void set_sampling(int s);
- int sampling();
+ int sampling() const;
static void init();
s4u::ActorPtr get_actor();
- int get_optind();
+ int get_optind() const;
void set_optind(int optind);
MPI_Info info_env();
void bsend_buffer(void** buf, int* size);
int dup(MPI_Comm* newcomm);
int dup_with_info(MPI_Info info, MPI_Comm* newcomm);
MPI_Group group();
- MPI_Topology topo() { return topo_; }
+ MPI_Topology topo() const { return topo_; }
void set_topo(MPI_Topology topo){topo_=topo;}
- int size();
- int rank();
- int id();
- void get_name(char* name, int* len);
+ int size() const;
+ int rank() const;
+ int id() const;
+ void get_name(char* name, int* len) const;
void set_name(const char* name);
MPI_Info info();
void set_info( MPI_Info info);
void set_errhandler( MPI_Errhandler errhandler);
void set_leaders_comm(MPI_Comm leaders);
void set_intra_comm(MPI_Comm leaders) { intra_comm_ = leaders; };
- int* get_non_uniform_map();
- int* get_leaders_map();
- MPI_Comm get_leaders_comm();
- MPI_Comm get_intra_comm();
+ int* get_non_uniform_map() const;
+ int* get_leaders_map() const;
+ MPI_Comm get_leaders_comm() const;
+ MPI_Comm get_intra_comm() const;
MPI_Comm find_intra_comm(int* leader);
- bool is_uniform();
- bool is_blocked();
- bool is_smp_comm();
+ bool is_uniform() const;
+ bool is_blocked() const;
+ bool is_smp_comm() const;
MPI_Comm split(int color, int key);
void cleanup_smp();
void ref();
Datatype& operator=(const Datatype&) = delete;
virtual ~Datatype();
- char* name() { return name_; }
- size_t size() { return size_; }
- MPI_Aint lb() { return lb_; }
- MPI_Aint ub() { return ub_; }
- int flags() { return flags_; }
- int refcount() { return refcount_; }
+ char* name() const { return name_; }
+ size_t size() const { return size_; }
+ MPI_Aint lb() const { return lb_; }
+ MPI_Aint ub() const { return ub_; }
+ int flags() const { return flags_; }
+ int refcount() const { return refcount_; }
void ref();
static void unref(MPI_Datatype datatype);
void commit();
int copy_attrs(Datatype* datatype);
- bool is_valid();
- bool is_basic();
+ bool is_valid() const;
+ bool is_basic() const;
static const char* encode(const Datatype* dt) { return dt->id.c_str(); }
static MPI_Datatype decode(const std::string& datatype_id);
- bool is_replayable();
+ bool is_replayable() const;
void addflag(int flag);
- int extent(MPI_Aint* lb, MPI_Aint* extent);
- MPI_Aint get_extent() { return ub_ - lb_; };
- void get_name(char* name, int* length);
+ int extent(MPI_Aint* lb, MPI_Aint* extent) const;
+ MPI_Aint get_extent() const { return ub_ - lb_; };
+ void get_name(char* name, int* length) const;
void set_name(const char* name);
static int copy(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype);
static int keyval_free(int* keyval);
int pack(const void* inbuf, int incount, void* outbuf, int outcount, int* position, const Comm* comm);
int unpack(const void* inbuf, int insize, int* position, void* outbuf, int outcount, const Comm* comm);
- int get_contents(int max_integers, int max_addresses,
- int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
- MPI_Datatype *array_of_datatypes);
- int get_envelope(int* num_integers, int* num_addresses,
- int* num_datatypes, int* combiner);
+ int get_contents(int max_integers, int max_addresses, int max_datatypes, int* array_of_integers,
+ MPI_Aint* array_of_addresses, MPI_Datatype* array_of_datatypes) const;
+ int get_envelope(int* num_integers, int* num_addresses, int* num_datatypes, int* combiner) const;
static int create_contiguous(int count, MPI_Datatype old_type, MPI_Aint lb, MPI_Datatype* new_type);
static int create_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type);
static int create_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type);
explicit Errhandler(MPI_File_errhandler_fn *function):file_func_(function){};
explicit Errhandler(MPI_Win_errhandler_fn *function):win_func_(function){};
void ref();
- void call(MPI_Comm comm, int errorcode);
- void call(MPI_Win win, int errorcode);
- void call(MPI_File file, int errorcode);
+ void call(MPI_Comm comm, int errorcode) const;
+ void call(MPI_Win win, int errorcode) const;
+ void call(MPI_File file, int errorcode) const;
static void unref(Errhandler* errhandler);
static Errhandler* f2c(int id);
};
File(const File&) = delete;
File& operator=(const File&) = delete;
~File();
- int size();
- int get_position(MPI_Offset* offset);
- int get_position_shared(MPI_Offset* offset);
- int flags();
- MPI_Comm comm();
+ int size() const;
+ int get_position(MPI_Offset* offset) const;
+ int get_position_shared(MPI_Offset* offset) const;
+ int flags() const;
+ MPI_Comm comm() const;
int sync();
int seek(MPI_Offset offset, int whence);
int seek_shared(MPI_Offset offset, int whence);
int set_view(MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char* datarep, const Info* info);
- int get_view(MPI_Offset *disp, MPI_Datatype *etype, MPI_Datatype *filetype, char *datarep);
+ int get_view(MPI_Offset* disp, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep) const;
MPI_Info info();
void set_info( MPI_Info info);
static int read(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
int rank(s4u::Actor* process);
void ref();
static void unref(MPI_Group group);
- int size() { return size_; }
+ int size() const { return size_; }
int compare(MPI_Group group2);
int incl(int n, const int* ranks, MPI_Group* newgroup);
int excl(int n, const int* ranks, MPI_Group* newgroup);
void ref();
static void unref(MPI_Info info);
void set(const char* key, const char* value) { map_[key] = value; }
- int get(const char* key, int valuelen, char* value, int* flag);
+ int get(const char* key, int valuelen, char* value, int* flag) const;
int remove(const char* key);
- int get_nkeys(int* nkeys);
- int get_nthkey(int n, char* key);
- int get_valuelen(const char* key, int* valuelen, int* flag);
+ int get_nkeys(int* nkeys) const;
+ int get_nthkey(int n, char* key) const;
+ int get_valuelen(const char* key, int* valuelen, int* flag) const;
static Info* f2c(int id);
};
public:
Op(MPI_User_function* function, bool commutative, bool predefined=false) : func_(function), is_commutative_(commutative), predefined_(predefined) {}
- bool is_commutative() { return is_commutative_; }
- bool is_fortran_op() { return is_fortran_op_; }
+ bool is_commutative() const { return is_commutative_; }
+ bool is_fortran_op() const { return is_fortran_op_; }
// tell that we were created from fortran, so we need to translate the type to fortran when called
void set_fortran_op() { is_fortran_op_ = true; }
- void apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype);
+ void apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype) const;
static Op* f2c(int id);
void ref();
static void unref(MPI_Op* op);
public:
Request() = default;
Request(const void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags, MPI_Op op = MPI_REPLACE);
- MPI_Comm comm() { return comm_; }
- size_t size() { return size_; }
- size_t real_size() { return real_size_; }
- int src() { return src_; }
- int dst() { return dst_; }
- int tag() { return tag_; }
- int flags() { return flags_; }
- bool detached() { return detached_; }
- MPI_Datatype type() { return old_type_; }
- void print_request(const char* message);
+ MPI_Comm comm() const { return comm_; }
+ size_t size() const { return size_; }
+ size_t real_size() const { return real_size_; }
+ int src() const { return src_; }
+ int dst() const { return dst_; }
+ int tag() const { return tag_; }
+ int flags() const { return flags_; }
+ bool detached() const { return detached_; }
+ MPI_Datatype type() const { return old_type_; }
+ void print_request(const char* message) const;
void start();
void cancel();
void init_buffer(int count);
void ref();
void set_nbc_requests(MPI_Request* reqs, int size);
- int get_nbc_requests_size();
- MPI_Request* get_nbc_requests();
+ int get_nbc_requests_size() const;
+ MPI_Request* get_nbc_requests() const;
static void finish_wait(MPI_Request* request, MPI_Status* status);
static void unref(MPI_Request* request);
static int wait(MPI_Request* req, MPI_Status* status);
int get(int maxdims, int* dims, int* periods, int* coords);
int rank(const int* coords, int* rank);
int shift(int direction, int disp, int* rank_source, int* rank_dest);
- int dim_get(int* ndims);
+ int dim_get(int* ndims) const;
static int Dims_create(int nnodes, int ndims, int dims[]);
};
~Win();
int attach (void *base, MPI_Aint size);
int detach (const void *base);
- void get_name( char* name, int* length);
+ void get_name(char* name, int* length) const;
void get_group( MPI_Group* group);
void set_name(const char* name);
- int rank();
- int dynamic();
+ int rank() const;
+ int dynamic() const;
int start(MPI_Group group, int assert);
int post(MPI_Group group, int assert);
int complete();
MPI_Info info();
void set_info( MPI_Info info);
int wait();
- MPI_Aint size();
- void* base();
- int disp_unit();
+ MPI_Aint size() const;
+ void* base() const;
+ int disp_unit() const;
int fence(int assert);
int put(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Request* request=nullptr);
}
/** @brief Check if a process is finalized */
-int ActorExt::finalized()
+int ActorExt::finalized() const
{
return (state_ == SmpiProcessState::FINALIZED);
}
/** @brief Check if a process is partially initialized already */
-int ActorExt::initializing()
+int ActorExt::initializing() const
{
return (state_ == SmpiProcessState::INITIALIZING);
}
/** @brief Check if a process is initialized */
-int ActorExt::initialized()
+int ActorExt::initialized() const
{
// TODO cheinrich: Check if we still need this. This should be a global condition, not for a
// single process ... ?
replaying_ = value;
}
-bool ActorExt::replaying()
+bool ActorExt::replaying() const
{
return replaying_;
}
privatized_region_ = region;
}
-smpi_privatization_region_t ActorExt::privatized_region()
+smpi_privatization_region_t ActorExt::privatized_region() const
{
return privatized_region_;
}
-MPI_Comm ActorExt::comm_world()
+MPI_Comm ActorExt::comm_world() const
{
return comm_world_ == nullptr ? MPI_COMM_NULL : *comm_world_;
}
-s4u::MutexPtr ActorExt::mailboxes_mutex()
+s4u::MutexPtr ActorExt::mailboxes_mutex() const
{
return mailboxes_mutex_;
}
#if HAVE_PAPI
-int ActorExt::papi_event_set()
+int ActorExt::papi_event_set() const
{
return papi_event_set_;
}
simulated_ = SIMIX_get_clock();
}
-double ActorExt::simulated_elapsed()
+double ActorExt::simulated_elapsed() const
{
return SIMIX_get_clock() - simulated_;
}
sampling_ = s;
}
-int ActorExt::sampling()
+int ActorExt::sampling() const
{
return sampling_;
}
XBT_DEBUG("<%ld> SMPI process has been initialized: %p", ext->actor_->get_pid(), ext->actor_);
}
-int ActorExt::get_optind()
+int ActorExt::get_optind() const
{
return optind_;
}
public:
RequestStorage() {}
- int size()
- {
- return store.size();
- }
+ int size() const { return store.size(); }
req_storage_t& get_store()
{
return store;
}
- void get_requests(std::vector<MPI_Request>& vec)
+ void get_requests(std::vector<MPI_Request>& vec) const
{
for (auto const& pair : store) {
auto& req = pair.second;
return group_;
}
-int Comm::size()
+int Comm::size() const
{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->size();
return group_->size();
}
-int Comm::rank()
+int Comm::rank() const
{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->rank();
return group_->rank(s4u::Actor::self());
}
-int Comm::id()
+int Comm::id() const
{
return id_;
}
-void Comm::get_name (char* name, int* len)
+void Comm::get_name(char* name, int* len) const
{
if (this == MPI_COMM_UNINITIALIZED){
smpi_process()->comm_world()->get_name(name, len);
leaders_comm_=leaders;
}
-int* Comm::get_non_uniform_map(){
+int* Comm::get_non_uniform_map() const
+{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->get_non_uniform_map();
return non_uniform_map_;
}
-int* Comm::get_leaders_map(){
+int* Comm::get_leaders_map() const
+{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->get_leaders_map();
return leaders_map_;
}
-MPI_Comm Comm::get_leaders_comm(){
+MPI_Comm Comm::get_leaders_comm() const
+{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->get_leaders_comm();
return leaders_comm_;
}
-MPI_Comm Comm::get_intra_comm(){
+MPI_Comm Comm::get_intra_comm() const
+{
if (this == MPI_COMM_UNINITIALIZED || this==MPI_COMM_WORLD)
return smpi_process()->comm_intra();
else return intra_comm_;
}
-bool Comm::is_uniform()
+bool Comm::is_uniform() const
{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->is_uniform();
return is_uniform_ != 0;
}
-bool Comm::is_blocked()
+bool Comm::is_blocked() const
{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->is_blocked();
return is_blocked_ != 0;
}
-bool Comm::is_smp_comm()
+bool Comm::is_smp_comm() const
{
if (this == MPI_COMM_UNINITIALIZED)
return smpi_process()->comm_world()->is_smp_comm();
flags_ |= DT_FLAG_COMMITED;
}
-bool Datatype::is_valid(){
+bool Datatype::is_valid() const
+{
return (flags_ & DT_FLAG_COMMITED);
}
-bool Datatype::is_basic()
+bool Datatype::is_basic() const
{
return (flags_ & DT_FLAG_BASIC);
}
-bool Datatype::is_replayable()
+bool Datatype::is_replayable() const
{
return (simgrid::instr::trace_format == simgrid::instr::TraceFormat::Ti) &&
((this == MPI_BYTE) || (this == MPI_DOUBLE) || (this == MPI_INT) || (this == MPI_CHAR) ||
flags_ &= flag;
}
-int Datatype::extent(MPI_Aint * lb, MPI_Aint * extent){
+int Datatype::extent(MPI_Aint* lb, MPI_Aint* extent) const
+{
*lb = lb_;
*extent = ub_ - lb_;
return MPI_SUCCESS;
}
-void Datatype::get_name(char* name, int* length){
+void Datatype::get_name(char* name, int* length) const
+{
if(name_!=nullptr){
*length = strlen(name_);
strncpy(name, name_, *length+1);
return MPI_SUCCESS;
}
-int Datatype::get_contents (int max_integers, int max_addresses,
- int max_datatypes, int* array_of_integers, MPI_Aint* array_of_addresses,
- MPI_Datatype *array_of_datatypes)
+int Datatype::get_contents(int max_integers, int max_addresses, int max_datatypes, int* array_of_integers,
+ MPI_Aint* array_of_addresses, MPI_Datatype* array_of_datatypes) const
{
if(contents_==nullptr)
return MPI_ERR_ARG;
return MPI_SUCCESS;
}
-int Datatype::get_envelope (int* num_integers, int* num_addresses,
- int* num_datatypes, int* combiner)
+int Datatype::get_envelope(int* num_integers, int* num_addresses, int* num_datatypes, int* combiner) const
{
if(contents_==nullptr){
*num_integers = 0;
}
}
-void Errhandler::call(MPI_Comm comm, int errorcode){
+void Errhandler::call(MPI_Comm comm, int errorcode) const
+{
comm_func_(&comm, &errorcode);
}
-void Errhandler::call(MPI_Win win, int errorcode){
+void Errhandler::call(MPI_Win win, int errorcode) const
+{
win_func_(&win, &errorcode);
}
-void Errhandler::call(MPI_File file, int errorcode){
+void Errhandler::call(MPI_File file, int errorcode) const
+{
file_func_(&file, &errorcode);
}
return MPI_SUCCESS;
}
- int File::get_position(MPI_Offset* offset){
+ int File::get_position(MPI_Offset* offset) const
+ {
*offset=file_->tell();
return MPI_SUCCESS;
}
- int File::get_position_shared(MPI_Offset* offset){
+ int File::get_position_shared(MPI_Offset* offset) const
+ {
shared_mutex_->lock();
*offset=*shared_file_pointer_;
shared_mutex_->unlock();
return MPI_SUCCESS;
}
- int File::get_view(MPI_Offset* /*disp*/, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep)
+ int File::get_view(MPI_Offset* /*disp*/, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep) const
{
*etype=etype_;
*filetype=filetype_;
return MPI_SUCCESS;
}
- int File::size(){
+ int File::size() const
+ {
return file_->size();
}
- int File::flags(){
+ int File::flags() const
+ {
return flags_;
}
info_->ref();
}
- MPI_Comm File::comm(){
+ MPI_Comm File::comm() const
+ {
return comm_;
}
}
}
-int Info::get(const char *key, int valuelen, char *value, int *flag){
+int Info::get(const char* key, int valuelen, char* value, int* flag) const
+{
*flag=false;
auto val = map_.find(key);
if (val != map_.end()) {
return MPI_SUCCESS;
}
-int Info::get_nkeys(int *nkeys){
+int Info::get_nkeys(int* nkeys) const
+{
*nkeys = map_.size();
return MPI_SUCCESS;
}
-int Info::get_nthkey(int n, char *key){
+int Info::get_nthkey(int n, char* key) const
+{
int num=0;
for (auto const& elm : map_) {
if (num == n) {
return MPI_ERR_ARG;
}
-int Info::get_valuelen(const char *key, int *valuelen, int *flag){
+int Info::get_valuelen(const char* key, int* valuelen, int* flag) const
+{
*flag=false;
auto val = map_.find(key);
if (val != map_.end()) {
namespace simgrid{
namespace smpi{
-void Op::apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype)
+void Op::apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype) const
{
if (smpi_cfg_privatization() == SmpiPrivStrategies::MMAP) {
// we need to switch as the called function may silently touch global variables
return match_common(req, ref, req);
}
-void Request::print_request(const char *message)
+void Request::print_request(const char* message) const
{
XBT_VERB("%s request %p [buf = %p, size = %zu, src = %d, dst = %d, tag = %d, flags = %x]",
message, this, buf_, size_, src_, dst_, tag_, flags_);
}
}
-int Request::get_nbc_requests_size(){
+int Request::get_nbc_requests_size() const
+{
return nbc_requests_size_;
}
-MPI_Request* Request::get_nbc_requests(){
+MPI_Request* Request::get_nbc_requests() const
+{
return nbc_requests_;
}
-
}
}
return MPI_SUCCESS;
}
-int Topo_Cart::dim_get(int *ndims) {
+int Topo_Cart::dim_get(int* ndims) const
+{
*ndims =ndims_;
return MPI_SUCCESS;
}
return MPI_SUCCESS;
}
-void Win::get_name(char* name, int* length){
+void Win::get_name(char* name, int* length) const
+{
if(name_==nullptr){
*length=0;
name=nullptr;
return info_;
}
-int Win::rank(){
+int Win::rank() const
+{
return rank_;
}
-MPI_Aint Win::size(){
+MPI_Aint Win::size() const
+{
return size_;
}
-void* Win::base(){
+void* Win::base() const
+{
return base_;
}
-int Win::disp_unit(){
+int Win::disp_unit() const
+{
return disp_unit_;
}
-int Win::dynamic(){
+int Win::dynamic() const
+{
return dynamic_;
}
host_to_actors.insert({host, actor});
}
- s4u::Host* get_host(s4u::ActorPtr actor) { return actor_to_host[actor]; }
+ s4u::Host* get_host(s4u::ActorPtr actor) const { return actor_to_host.at(actor); }
- unsigned int count_actors(s4u::Host* host)
+ unsigned int count_actors(s4u::Host* host) const
{
return host_to_actors.count(host); // TODO This is linear in the size of the map. Maybe replace by constant lookup through another map?
}