Sierra Toolkit  Version of the Day
Parallel.cpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #include <stk_util/parallel/Parallel.hpp>
10 
11 /*--------------------------------------------------------------------*/
12 /* Parallel operations */
13 
14 #if defined( STK_HAS_MPI )
15 
16 namespace stk_classic {
17 
18 unsigned parallel_machine_size( ParallelMachine parallel_machine )
19 {
20  int value = 1 ;
21  if (parallel_machine != MPI_COMM_NULL) {
22  if ( MPI_SUCCESS != MPI_Comm_size( parallel_machine , &value ) ) {
23  value = 1 ;
24  }
25  }
26  return value ;
27 }
28 
29 unsigned parallel_machine_rank( ParallelMachine parallel_machine )
30 {
31  int value = 0 ;
32  if (parallel_machine != MPI_COMM_NULL) {
33  if ( MPI_SUCCESS != MPI_Comm_rank( parallel_machine , &value ) ) {
34  value = 0 ;
35  }
36  }
37  return value ;
38 }
39 
40 void parallel_machine_barrier( ParallelMachine parallel_machine )
41 {
42  if (parallel_machine != MPI_COMM_NULL) {
43  MPI_Barrier( parallel_machine );
44  }
45 }
46 
47 }
48 
49 #else
50 
51 namespace stk_classic {
52 
53 unsigned parallel_machine_size( ParallelMachine parallel_machine) { return 1 ; }
54 
55 unsigned parallel_machine_rank( ParallelMachine parallel_machine) { return 0 ; }
56 
57 void parallel_machine_barrier( ParallelMachine parallel_machine) {}
58 
59 }
60 
61 #endif
62 
63 /*--------------------------------------------------------------------*/
64 
65 
unsigned parallel_machine_rank(ParallelMachine parallel_machine)
Member function parallel_machine_rank ...
Definition: Parallel.cpp:29
unsigned parallel_machine_size(ParallelMachine parallel_machine)
Member function parallel_machine_size ...
Definition: Parallel.cpp:18
Sierra Toolkit.
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32
void parallel_machine_barrier(ParallelMachine parallel_machine)
Member function parallel_machine_barrier ...
Definition: Parallel.cpp:40