2012-06-16 22:58:28 +06:00
|
|
|
/**************************************************************************/
|
|
|
|
/* File: mpi_interface.cpp */
|
|
|
|
/* Author: Joachim Schoeberl */
|
|
|
|
/* Date: 04. Apr. 97 */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
#include <mystdlib.h>
|
|
|
|
#include <myadt.hpp>
|
|
|
|
|
2012-07-05 19:02:01 +06:00
|
|
|
|
2012-06-16 22:58:28 +06:00
|
|
|
namespace netgen
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef PARALLEL
|
|
|
|
|
|
|
|
void MyMPI_SendCmd (const char * cmd)
|
|
|
|
{
|
2017-03-06 18:32:20 +05:00
|
|
|
int ntasks;
|
|
|
|
MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
|
2012-06-16 22:58:28 +06:00
|
|
|
|
2017-03-06 18:32:20 +05:00
|
|
|
if(ntasks==1)
|
|
|
|
return;
|
|
|
|
|
2012-06-16 22:58:28 +06:00
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
2018-03-14 15:42:22 +05:00
|
|
|
MPI_Send( (void*)cmd, (strlen(cmd)+1), MPI_CHAR, dest, MPI_TAG_CMD, MPI_COMM_WORLD);
|
2012-06-16 22:58:28 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
string MyMPI_RecvCmd ()
|
|
|
|
{
|
|
|
|
MPI_Status status;
|
|
|
|
int flag;
|
2017-03-06 18:32:20 +05:00
|
|
|
int size_of_msg = -1;
|
|
|
|
|
|
|
|
MPI_Probe(0, MPI_TAG_CMD, MPI_COMM_WORLD, &status);
|
|
|
|
MPI_Get_count(&status, MPI_CHAR, &size_of_msg);
|
|
|
|
|
|
|
|
//char* buf = (char*)malloc(size_of_msg*sizeof(char));
|
|
|
|
char buf[100000]; //1MB should be enough...
|
|
|
|
|
|
|
|
MPI_Recv( &buf, size_of_msg, MPI_CHAR, 0, MPI_TAG_CMD, MPI_COMM_WORLD, &status);
|
2012-06-16 22:58:28 +06:00
|
|
|
|
|
|
|
return string(buf);
|
|
|
|
}
|
|
|
|
|
2019-02-12 02:53:32 +05:00
|
|
|
// #else
|
|
|
|
// MPI_Comm MPI_COMM_WORLD, MPI_COMM_NULL;
|
2012-06-16 22:58:28 +06:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-02-12 19:49:55 +05:00
|
|
|
|
|
|
|
|