|
Sierra Toolkit
Version of the Day
|
00001 /*------------------------------------------------------------------------*/ 00002 /* Copyright 2010 Sandia Corporation. */ 00003 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ 00004 /* license for use of this work by or on behalf of the U.S. Government. */ 00005 /* Export of this program may require a license from the */ 00006 /* United States Government. */ 00007 /*------------------------------------------------------------------------*/ 00008 00009 #ifndef stk_util_parallel_Parallel_hpp 00010 #define stk_util_parallel_Parallel_hpp 00011 00012 // stk_config.h resides in the build directory and contains the 00013 // complete set of #define macros for build-dependent features. 00014 00015 #include <stk_util/stk_config.h> 00016 00017 //---------------------------------------------------------------------- 00018 // Parallel machine 00019 00020 #if defined( STK_HAS_MPI ) 00021 00022 #include <mpi.h> 00023 00024 namespace stk_classic { 00025 00030 00031 00032 typedef MPI_Comm ParallelMachine ; 00033 00035 00036 typedef MPI_Datatype ParallelDatatype ; 00037 00043 inline ParallelMachine parallel_machine_null() { return MPI_COMM_NULL ; } 00044 00054 inline ParallelMachine parallel_machine_init( int * argc , char *** argv ) 00055 { 00056 MPI_Init( argc , argv ); 00057 return MPI_COMM_WORLD ; 00058 } 00059 00064 inline void parallel_machine_finalize() 00065 { 00066 MPI_Finalize(); 00067 } 00068 00071 } 00072 00073 //---------------------------------------- 00074 // Other parallel communication machines go here 00075 // as '#elif defined( STK_HAS_<name> )' 00076 00077 //---------------------------------------- 00078 // Stub for non-parallel 00079 00080 #else 00081 00082 // Some needed stubs 00083 #define MPI_Comm int 00084 #define MPI_COMM_WORLD 0 00085 #define MPI_COMM_SELF 0 00086 #define MPI_Barrier( a ) (void)a 00087 00088 namespace stk_classic { 00089 00090 typedef int ParallelMachine ; 00091 typedef int ParallelDatatype ; 00092 00093 inline ParallelMachine parallel_machine_null() { return 0 ; } 00094 00095 inline ParallelMachine parallel_machine_init( int * , char *** ) 00096 { return 0 ; } 00097 00098 inline void parallel_machine_finalize() 00099 {} 00100 00101 } 00102 00103 #endif 00104 00105 //---------------------------------------------------------------------- 00106 // Common parallel machine needs. 00107 00108 namespace stk_classic { 00109 00117 unsigned parallel_machine_size( ParallelMachine parallel_machine ); 00118 00126 unsigned parallel_machine_rank( ParallelMachine parallel_machine ); 00127 00132 void parallel_machine_barrier( ParallelMachine parallel_machine); 00133 } 00134 00135 //---------------------------------------------------------------------- 00136 00137 #endif 00138