Sierra Toolkit Version of the Day
Parallel.cpp
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 #include <stk_util/parallel/Parallel.hpp>
00010 
00011 /*--------------------------------------------------------------------*/
00012 /* Parallel operations */
00013 
00014 #if defined( STK_HAS_MPI )
00015 
00016 namespace stk {
00017 
00018 unsigned parallel_machine_size( ParallelMachine parallel_machine )
00019 {
00020   int value = 1 ;
00021   if (parallel_machine != MPI_COMM_NULL) {
00022     if ( MPI_SUCCESS != MPI_Comm_size( parallel_machine , &value ) ) {
00023       value = 1 ;
00024     }
00025   }
00026   return value ;
00027 }
00028 
00029 unsigned parallel_machine_rank( ParallelMachine parallel_machine )
00030 {
00031   int value = 0 ;
00032   if (parallel_machine != MPI_COMM_NULL) {
00033     if ( MPI_SUCCESS != MPI_Comm_rank( parallel_machine , &value ) ) {
00034       value = 0 ;
00035     }
00036   }
00037   return value ;
00038 }
00039 
00040 void parallel_machine_barrier( ParallelMachine parallel_machine )
00041 {
00042   if (parallel_machine != MPI_COMM_NULL) {
00043     MPI_Barrier( parallel_machine );
00044   }
00045 }
00046 
00047 }
00048 
00049 #else
00050 
00051 namespace stk {
00052 
00053 unsigned parallel_machine_size( ParallelMachine parallel_machine) { return 1 ; }
00054 
00055 unsigned parallel_machine_rank( ParallelMachine parallel_machine) { return 0 ; }
00056 
00057 void parallel_machine_barrier( ParallelMachine parallel_machine) {}
00058 
00059 }
00060 
00061 #endif
00062 
00063 /*--------------------------------------------------------------------*/
00064 
00065 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines