File: parallelfunc.cpp

package info (click to toggle)
netgen 6.2.2601%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,076 kB
  • sloc: cpp: 166,627; tcl: 6,310; python: 2,868; sh: 528; makefile: 90
file content (107 lines) | stat: -rw-r--r-- 1,977 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifdef PARALLEL

#include "dlfcn.h"


// #include <mystdlib.h>

#include <meshing.hpp>

// #include <visual.hpp>


#include <meshing.hpp>

void (*NGS_ParallelRun) (const string & message) = NULL;


namespace netgen
{
#include "../interface/writeuser.hpp"
  extern string ngdir;
}

void Parallel_Exit();


namespace netgen {
  extern AutoPtr<Mesh>  mesh;
  // extern VisualSceneMesh vsmesh;
  extern NGLIB_API MeshingParameters mparam;
}

using namespace netgen;
using netgen::RegisterUserFormats;


void ParallelRun()
{   
  string message;
  MPI_Status status;
      

  MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
  MPI_Comm_rank(MPI_COMM_WORLD, &id);

  while ( true )
    {
      message = MyMPI_RecvCmd();

      if ( message.compare(0, 3, "ngs") == 0 ) 
        {
	  if (NGS_ParallelRun == NULL)
	    {
	      static int timer = NgProfiler::CreateTimer ("load shared library ngsolve");
	      NgProfiler::RegionTimer reg (timer);
  

	      void * handle = dlopen ("libngsolve.so", RTLD_NOW | RTLD_GLOBAL);
	      if (!handle)
		{
		  cerr << "cannot load shared library libngsolve.so" << endl;
		  exit(1);
		}
	      
	      NGS_ParallelRun = (void (*) (const string & message))  dlsym (handle, "NGS_ParallelRun");
	      
	      if (!NGS_ParallelRun)
		{
		  cerr << "cannot bind function NGS_ParallelRun" << endl;
		  exit(1);
		}
	    }
          (*NGS_ParallelRun) (message);
        }
      else if ( message == "mesh" )
	{
	  VT_USER_START ("Mesh::ReceiveParallelMesh");
	  mesh.Reset( new netgen::Mesh);
	  mesh->SendRecvMesh();
	  VT_USER_END ("Mesh::ReceiveParallelMesh");
	}

      else if ( message == "visualize" )
	{
	  cout << "parallel message visualize depreciated" << endl;
	}
      
      else if ( message == "bcastparthread" )
	{
	  MyMPI_Bcast (mparam.parthread);
	}

      else if ( message ==  "end" )
	{
	  break;
	}
      
      else
	{
	  PrintMessage ( 1, "received unidentified message '" + message + "'\n");
	  break;
	}
      
    }
}

#endif