Commit d16e606f authored by Camille Coti's avatar Camille Coti
Browse files

Overlap computation + communication

parent 803648b5
......@@ -38,12 +38,16 @@ gi::ex add_expressions_parall( std::vector<std::string> expressions, gi::lst sym
int rank, size;
int chunk, end;
char* expr_c;
char* expr_2;
char* tmp;
char* total_c = NULL;
int expr = 0;
int* m_len;
int* m_disp;
char* toto = NULL;
int totallen = 0;
MPI_Request req;
MPI_Status stat;
MPI_Comm_rank( comm, &rank );
MPI_Comm_size( comm, &size );
......@@ -158,6 +162,7 @@ gi::ex add_expressions_parall( std::vector<std::string> expressions, gi::lst sym
maxlen = ( maxlen < lengths[ expr ] ) ? lengths[ expr ] : maxlen; //std::max( maxlen, lengths[ expr ] );
}
expr_c = (char*)malloc( maxlen + 1 ); // Add a final \0
expr_2 = (char*)malloc( maxlen + 1 ); // Add a final \0
/* Send the expressions */
......@@ -173,11 +178,26 @@ gi::ex add_expressions_parall( std::vector<std::string> expressions, gi::lst sym
if( 0 == rank ) toto = const_cast<char*>( expressions[expr].c_str() );
MPI_Scatterv( toto, m_len, m_disp, MPI_CHAR,
MPI_Iscatterv( toto, m_len, m_disp, MPI_CHAR,
expr_c, len, MPI_CHAR,
0, comm );
0, comm , &req );
// results_s.push_back( std::string( expr_c ) );
if( 0 != expr ) {
Tens += de_linearize_expression( std::string( expr_2 ), symbols );
}
/* get the new expression in expr_c and swap the pointers so that we can work with expr_2 and receive in expr_c */
MPI_Wait( &req, &stat );
expr_c[len ] = '\0'; // The master sends C++ strings, which do not contain the final '\0'
results_s.push_back( std::string( expr_c ) );
// std::cout << "Got iteration " << expr << std::endl;
tmp = expr_2;
expr_2 = expr_c;
expr_c = tmp;
}
Tens += de_linearize_expression( std::string( expr_2 ), symbols );
// }
// if( rank == 0 ){
// for( peer = 0 ; peer < size ; peer++ ) {
......@@ -188,11 +208,11 @@ gi::ex add_expressions_parall( std::vector<std::string> expressions, gi::lst sym
// std::cout << expr_c << std::endl;
/* TODO: this can be overlapped with the computation of the previous addition */
}
// }
/* Add them */
Tens = add_expressions( results_s, symbols );
// Tens = add_expressions( results_s, symbols );
// std::cout << Tens << std::endl;
/* Send the result to the master */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment