-/* Copyright (c) 2010, 2013-2015. The SimGrid Team.
+/* Copyright (c) 2010, 2013-2017. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include "private.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_group, smpi, "Logging specific to SMPI (group)");
+
simgrid::smpi::Group mpi_MPI_GROUP_EMPTY;
MPI_Group MPI_GROUP_EMPTY=&mpi_MPI_GROUP_EMPTY;
xbt_dict_free(&index_to_rank_map_);
}
-void Group::destroy()
-{
- if(this != MPI_COMM_WORLD->group()
- && this != MPI_GROUP_EMPTY)
- this->unuse();
-}
-
void Group::set_mapping(int index, int rank)
{
int * val_rank;
return *ptr_rank;
}
-int Group::use()
+void Group::ref()
{
refcount_++;
- return refcount_;
}
-int Group::unuse()
+void Group::unref(Group* group)
{
- refcount_--;
- if (refcount_ <= 0) {
- delete this;
- return 0;
+ group->refcount_--;
+ if (group->refcount_ <= 0) {
+ delete group;
}
- return refcount_;
}
int Group::size()
if(this!= MPI_COMM_WORLD->group()
&& this != MPI_COMM_SELF->group()
&& this != MPI_GROUP_EMPTY)
- this->use();
+ this->ref();
} else {
*newgroup = new Group(n);
for (i = 0; i < n; i++) {
if (size1 == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
- *newgroup = new simgrid::smpi::Group(size1);
+ *newgroup = new Group(size1);
size2 = this->size();
for (int i = 0; i < size2; i++) {
int proc1 = this->index(i);
if (size2 == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
- *newgroup = new simgrid::smpi::Group(size2);
+ *newgroup = new Group(size2);
int j=0;
for (int i = 0; i < group2->size(); i++) {
int proc2 = group2->index(i);
if (newsize == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
- *newgroup = new simgrid::smpi::Group(newsize);
+ *newgroup = new Group(newsize);
for (int i = 0; i < size2; i++) {
int proc1 = this->index(i);
int proc2 = group2->rank(proc1);
int Group::excl(int n, int *ranks, MPI_Group * newgroup){
int oldsize = size_;
int newsize = oldsize - n;
- *newgroup = new simgrid::smpi::Group(newsize);
+ *newgroup = new Group(newsize);
int* to_exclude=xbt_new0(int, size_);
for (int i = 0; i < oldsize; i++)
to_exclude[i]=0;
}
}
}
- *newgroup = new simgrid::smpi::Group(newsize);
+ *newgroup = new Group(newsize);
int j = 0;
for (int i = 0; i < n; i++) {
for (int rank = ranges[i][0]; /* First */
if (newsize == 0) {
*newgroup = MPI_GROUP_EMPTY;
} else {
- *newgroup = new simgrid::smpi::Group(newsize);
+ *newgroup = new Group(newsize);
int newrank = 0;
int oldrank = 0;
while (newrank < newsize) {
return MPI_SUCCESS;
}
+MPI_Group Group::f2c(int id) {
+ if(id == -2) {
+ return MPI_GROUP_EMPTY;
+ } else if(F2C::f2c_lookup() != nullptr && id >= 0) {
+ char key[KEY_SIZE];
+ return static_cast<MPI_Group>(xbt_dict_get_or_null(F2C::f2c_lookup(), get_key(key, id)));
+ } else {
+ return static_cast<MPI_Group>(MPI_GROUP_NULL);
+ }
+}
+
}
}