netgen/libsrc/general/mpi_interface.cpp

58 lines
1.2 KiB
C++
Raw Normal View History

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)
{
char buf[10000];
2012-06-16 22:58:28 +06:00
strcpy (buf, cmd);
2012-06-16 22:58:28 +06:00
// MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD);
for (int dest = 1; dest < ntasks; dest++)
MPI_Send( &buf, 10000, MPI_CHAR, dest, MPI_TAG_CMD, MPI_COMM_WORLD);
2012-06-16 22:58:28 +06:00
}
string MyMPI_RecvCmd ()
{
char buf[10000];
2012-06-16 22:58:28 +06:00
// MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD);
2012-06-19 00:40:05 +06:00
// VT_OFF();
2012-06-16 22:58:28 +06:00
MPI_Status status;
int flag;
do
{
MPI_Iprobe (0, MPI_TAG_CMD, MPI_COMM_WORLD, &flag, &status);
2012-06-19 00:40:05 +06:00
if (!flag)
{
VT_TRACER ("sleep");
usleep (1000);
}
2012-06-16 22:58:28 +06:00
}
while (!flag);
2012-06-19 00:40:05 +06:00
// VT_ON();
2012-06-16 22:58:28 +06:00
MPI_Recv( &buf, 10000, MPI_CHAR, 0, MPI_TAG_CMD, MPI_COMM_WORLD, &status);
2012-06-16 22:58:28 +06:00
return string(buf);
}
#endif
}