Skip to content
Snippets Groups Projects
Commit 95072d94 authored by Camille Coti's avatar Camille Coti
Browse files

Fixed the communicator construction when the teams have different sizes

parent fdfe9173
No related branches found
No related tags found
No related merge requests found
#include <iostream>
#include <mpi.h>
#include <ginac/ginac.h>
#include <math.h> // ceil
#include "products.h"
#include "utils_parall.h"
......@@ -23,7 +24,7 @@ void create_communicators_hierarch( MPI_Comm& COMM_FOREMEN, MPI_Comm& COMM_TEAM
color_foreman is set to 1 if I am the root or a foreman */
int color_foreman, workers_per_foreman;
workers_per_foreman = ( np - 1) / NBFOREMEN;
workers_per_foreman = ceil( (double)( np - 1) / (double)NBFOREMEN );
if( ROOT == rank ) {
color_foreman = 1;
} else {
......@@ -42,10 +43,8 @@ void create_communicators_hierarch( MPI_Comm& COMM_FOREMEN, MPI_Comm& COMM_TEAM
if( ROOT == rank ) {
color_team = 0;
} else {
workers_per_foreman = ( np - 1) / NBFOREMEN;
color_team = 1 + ( (rank-1) / workers_per_foreman );
color_team = 1 + floor( ( (rank-1) / workers_per_foreman ) );
}
MPI_Comm_split( MPI_COMM_WORLD, color_team, rank, &COMM_TEAM );
#if DEBUG
......@@ -99,7 +98,7 @@ gi::ex multiply_1level_foreman_hierarch_distribute_work( tensor3D_t& T, matrix_i
}
/* Distribute the work */
/* Very copy/paste from multiply_1level_master -> possible refactoing here */
/* Very copy/paste from multiply_1level_master -> possible refactoring here */
while( input.size() > 0 ) {
MPI_Recv( &len, 1, MPI_UNSIGNED, MPI_ANY_SOURCE, MPI_ANY_TAG, comm_team, &status );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment