mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 13:50:33 +05:00
parallelization
This commit is contained in:
parent
580f4b9f52
commit
660f31d7cd
@ -15,17 +15,13 @@
|
|||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
|
|
||||||
|
extern int id, ntasks;
|
||||||
|
|
||||||
|
|
||||||
#ifndef PARALLEL
|
#ifndef PARALLEL
|
||||||
|
|
||||||
|
// enum { id = 0 };
|
||||||
|
// enum { ntasks = 0 };
|
||||||
// namespace netgen
|
|
||||||
// {
|
|
||||||
//using namespace netgen;
|
|
||||||
enum { id = 0 };
|
|
||||||
enum { ntasks = 0 };
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
#else // if PARALLEL
|
#else // if PARALLEL
|
||||||
|
|
||||||
@ -37,12 +33,11 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
//#include "parallelfunc.hpp"
|
//#include "parallelfunc.hpp"
|
||||||
extern MPI_Group MPI_HIGHORDER_WORLD;
|
extern MPI_Group MPI_HIGHORDER_WORLD;
|
||||||
extern MPI_Comm MPI_HIGHORDER_COMM;
|
extern MPI_Comm MPI_HIGHORDER_COMM;
|
||||||
|
|
||||||
// namespace netgen
|
// namespace netgen
|
||||||
// {
|
// {
|
||||||
extern int id, ntasks;
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
MPI_Datatype MyGetMPIType ( ) { cerr << "ERROR in GetMPIType() -- no type found" << endl;return 0;}
|
MPI_Datatype MyGetMPIType ( ) { cerr << "ERROR in GetMPIType() -- no type found" << endl;return 0;}
|
||||||
@ -201,7 +196,8 @@ extern MPI_Comm MPI_HIGHORDER_COMM;
|
|||||||
inline void MyMPI_Bcast (Array<T, 0> & s, int root, MPI_Comm comm = MPI_COMM_WORLD)
|
inline void MyMPI_Bcast (Array<T, 0> & s, int root, MPI_Comm comm = MPI_COMM_WORLD)
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
MPI_Comm_rank(MPI_HIGHORDER_COMM, &id);
|
// MPI_Comm_rank(MPI_HIGHORDER_COMM, &id);
|
||||||
|
MPI_Comm_rank(comm, &id);
|
||||||
|
|
||||||
int size = s.Size();
|
int size = s.Size();
|
||||||
MPI_Bcast (&size, 1, MPI_INT, root, comm);
|
MPI_Bcast (&size, 1, MPI_INT, root, comm);
|
||||||
|
@ -17,12 +17,16 @@
|
|||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace netgen
|
||||||
|
{
|
||||||
|
int id = 0, ntasks = 1;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PARALLEL
|
#ifdef PARALLEL
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
int id, ntasks;
|
|
||||||
MPI_Group MPI_HIGHORDER_WORLD;
|
MPI_Group MPI_HIGHORDER_WORLD;
|
||||||
MPI_Comm MPI_HIGHORDER_COMM;
|
MPI_Comm MPI_HIGHORDER_COMM;
|
||||||
}
|
}
|
||||||
@ -74,9 +78,6 @@ int main(int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
|
|
||||||
#ifdef PARALLEL
|
#ifdef PARALLEL
|
||||||
// parallel profiling
|
|
||||||
#pragma pomp inst init
|
|
||||||
|
|
||||||
MPI_Init(&argc, &argv);
|
MPI_Init(&argc, &argv);
|
||||||
|
|
||||||
MPI_Comm_size(MPI_COMM_WORLD, &netgen::ntasks);
|
MPI_Comm_size(MPI_COMM_WORLD, &netgen::ntasks);
|
||||||
@ -92,10 +93,9 @@ int main(int argc, char ** argv)
|
|||||||
MPI_Comm_group ( MPI_COMM_WORLD, &MPI_GROUP_WORLD);
|
MPI_Comm_group ( MPI_COMM_WORLD, &MPI_GROUP_WORLD);
|
||||||
MPI_Group_incl ( MPI_GROUP_WORLD, n_ho, process_ranks, & netgen::MPI_HIGHORDER_WORLD);
|
MPI_Group_incl ( MPI_GROUP_WORLD, n_ho, process_ranks, & netgen::MPI_HIGHORDER_WORLD);
|
||||||
MPI_Comm_create ( MPI_COMM_WORLD, netgen::MPI_HIGHORDER_WORLD, & netgen::MPI_HIGHORDER_COMM);
|
MPI_Comm_create ( MPI_COMM_WORLD, netgen::MPI_HIGHORDER_WORLD, & netgen::MPI_HIGHORDER_COMM);
|
||||||
|
|
||||||
#pragma pomp inst begin(main)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if ( netgen::id == 0 )
|
if ( netgen::id == 0 )
|
||||||
{
|
{
|
||||||
cout << "NETGEN-" << PACKAGE_VERSION << endl;
|
cout << "NETGEN-" << PACKAGE_VERSION << endl;
|
||||||
@ -313,7 +313,6 @@ int main(int argc, char ** argv)
|
|||||||
Tcl_DeleteInterp (myinterp);
|
Tcl_DeleteInterp (myinterp);
|
||||||
|
|
||||||
#ifdef PARALLEL
|
#ifdef PARALLEL
|
||||||
#pragma pomp inst altend(main)
|
|
||||||
|
|
||||||
// MPI beenden
|
// MPI beenden
|
||||||
MPI_Barrier(MPI_COMM_WORLD);
|
MPI_Barrier(MPI_COMM_WORLD);
|
||||||
@ -328,8 +327,6 @@ int main(int argc, char ** argv)
|
|||||||
// main for parallel processors
|
// main for parallel processors
|
||||||
ParallelRun();
|
ParallelRun();
|
||||||
|
|
||||||
#pragma pomp inst end(main)
|
|
||||||
|
|
||||||
// MPI beenden
|
// MPI beenden
|
||||||
MPI_Barrier(MPI_COMM_WORLD);
|
MPI_Barrier(MPI_COMM_WORLD);
|
||||||
MPI_Finalize();
|
MPI_Finalize();
|
||||||
|
@ -92,10 +92,8 @@ void Ng_Exit ()
|
|||||||
void ParallelRun()
|
void ParallelRun()
|
||||||
{
|
{
|
||||||
string message;
|
string message;
|
||||||
|
|
||||||
MPI_Status status;
|
MPI_Status status;
|
||||||
|
|
||||||
// int id, rc, ntasks;
|
|
||||||
|
|
||||||
MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
|
MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
|
||||||
MPI_Comm_rank(MPI_COMM_WORLD, &id);
|
MPI_Comm_rank(MPI_COMM_WORLD, &id);
|
||||||
@ -104,8 +102,6 @@ void ParallelRun()
|
|||||||
|
|
||||||
bool test = true;
|
bool test = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
testout = new ofstream (string("testout_proc") + id );
|
testout = new ofstream (string("testout_proc") + id );
|
||||||
|
|
||||||
while ( test )
|
while ( test )
|
||||||
@ -114,9 +110,7 @@ void ParallelRun()
|
|||||||
#pragma pomp inst begin (message)
|
#pragma pomp inst begin (message)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
(*testout) << "wait for mess " << endl;
|
|
||||||
MyMPI_Recv ( message, 0 );
|
MyMPI_Recv ( message, 0 );
|
||||||
(*testout) << "message " << message << endl;
|
|
||||||
|
|
||||||
#ifdef SCALASCA
|
#ifdef SCALASCA
|
||||||
#pragma pomp inst end (message)
|
#pragma pomp inst end (message)
|
||||||
|
Loading…
Reference in New Issue
Block a user