Skip to content
Snippets Groups Projects
Commit 2d80c095 authored by Boris Martin's avatar Boris Martin
Browse files

minor refactoring before adding the optimiezd version

parent fac943bb
No related branches found
No related tags found
No related merge requests found
Pipeline #12695 failed
......@@ -143,7 +143,20 @@ namespace gmshfem::field
local.push_back({dof->numType(), dof->entity(), rank});
}
// MPI type for key/rank
int blocklengths[3] = {1, 1, 1};
MPI_Datatype types[3] = {MPI_UNSIGNED_LONG, MPI_UNSIGNED_LONG, MPI_INT};
MPI_Datatype mpi_struct_type;
MPI_Aint offsets[3];
offsets[0] = offsetof(ShareDofInfo, type);
offsets[1] = offsetof(ShareDofInfo, entity);
offsets[2] = offsetof(ShareDofInfo, this_rank);
MPI_Type_create_struct(3, blocklengths, offsets, types, &mpi_struct_type);
MPI_Type_commit(&mpi_struct_type);
// Get the sizes and offset of the global array
if(!neighboringRanks) {
int total_size = 0;
std::vector< int > sizes(commSize), displs(commSize);
int loc_size = local.size();
......@@ -154,23 +167,19 @@ namespace gmshfem::field
total_size += sizes[i];
}
// Create temporary MPI Type for the struct
const int nitems = 3;
int blocklengths[3] = {1, 1, 1};
MPI_Datatype types[3] = {MPI_UNSIGNED_LONG, MPI_UNSIGNED_LONG, MPI_INT};
MPI_Datatype mpi_struct_type;
MPI_Aint offsets[3];
offsets[0] = offsetof(ShareDofInfo, type);
offsets[1] = offsetof(ShareDofInfo, entity);
offsets[2] = offsetof(ShareDofInfo, this_rank);
MPI_Type_create_struct(nitems, blocklengths, offsets, types, &mpi_struct_type);
MPI_Type_commit(&mpi_struct_type);
// Synchronize the full array
global.resize(total_size);
if(rank == 0)
msg::info << "Synchronizing Interface Ownership with a total of " << global.size() << " interface DOFs exchanged." << msg::endl;
MPI_Allgatherv(local.data(), local.size(), mpi_struct_type,
global.data(), sizes.data(), displs.data(), mpi_struct_type,
MPI_COMM_WORLD);
}
else {
// TODO
}
// Free the type
MPI_Type_free(&mpi_struct_type);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment