+ if (info_ == MPI_INFO_NULL)
+ info_ = new Info();
+ info_->ref();
+ return info_;
+}
+
+void Comm::set_info(MPI_Info info)
+{
+ if (info_ != MPI_INFO_NULL)
+ simgrid::smpi::Info::unref(info);
+ info_ = info;
+ if (info_ != MPI_INFO_NULL)
+ info->ref();
+}
+
+MPI_Errhandler Comm::errhandler()
+{
+ if (this != MPI_COMM_WORLD){
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ errhandler_->ref();
+ return errhandler_;
+ } else {
+ if(errhandlers_==nullptr)
+ return MPI_ERRORS_ARE_FATAL;
+ else {
+ if(errhandlers_[this->rank()] != MPI_ERRHANDLER_NULL)
+ errhandlers_[this->rank()]->ref();
+ return errhandlers_[this->rank()];
+ }
+ }
+}
+
+void Comm::set_errhandler(MPI_Errhandler errhandler)
+{
+ if(this != MPI_COMM_WORLD){
+ if (errhandler_ != MPI_ERRHANDLER_NULL)
+ simgrid::smpi::Errhandler::unref(errhandler_);
+ errhandler_ = errhandler;
+ }else{
+ if(errhandlers_==nullptr)
+ errhandlers_= new MPI_Errhandler[this->size()]{MPI_ERRHANDLER_NULL};
+ if(errhandlers_[this->rank()] != MPI_ERRHANDLER_NULL)
+ simgrid::smpi::Errhandler::unref(errhandlers_[this->rank()]);
+ errhandlers_[this->rank()]=errhandler;
+ }
+ if (errhandler != MPI_ERRHANDLER_NULL)
+ errhandler->ref();
+}
+
+MPI_Comm Comm::split_type(int type, int /*key*/, const Info*)
+{
+ //MPI_UNDEFINED can be given to some nodes... but we need them to still perform the smp part which is collective
+ if(type != MPI_COMM_TYPE_SHARED && type != MPI_UNDEFINED){
+ return MPI_COMM_NULL;
+ }
+ int leader=0;
+ MPI_Comm res= this->find_intra_comm(&leader);
+ if(type != MPI_UNDEFINED)
+ return res;
+ else{
+ xbt_assert(res->refcount_ == 1); // ensure the next call to Comm::destroy really frees the comm
+ Comm::destroy(res);