RTOp_mpi.c

Go to the documentation of this file.
00001 /*
00002 // @HEADER
00003 // ***********************************************************************
00004 // 
00005 //      Thyra: Interfaces and Support Code for the Interoperability of Abstract Numerical Algorithms 
00006 //                 Copyright (2004) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 // @HEADER
00029 */
00030 
00031 /*
00032  * This file includes selected hollow MPI function definitions for a
00033  * sinlge process implementation.
00034  */
00035 
00036 /*
00037  * RAB: 2004/01/22: This file is included because it includes
00038  * Thyra_Config.h which then defines RTOp_USE_MPI or not.  If
00039  * RTOp_USE_MPI is defined then this header file will also include
00040  * RTOp_mpi.h for these delcarations.
00041  */
00042 #include "RTOp_MPI_config.h"
00043 
00044 #ifndef RTOp_USE_MPI
00045 
00046 int MPI_Init(int *argc, char ***argv)
00047 {
00048   return 0;
00049 }
00050 
00051 int MPI_Finalize(void)
00052 {
00053   return 0;
00054 }
00055 
00056 int MPI_Comm_size(MPI_Comm comm, int *size)
00057 {
00058   *size = 1;
00059   return 0;
00060 }
00061 
00062 int MPI_Comm_rank(MPI_Comm comm, int *rank)
00063 {
00064   *rank = 0;
00065   return 0;
00066 }
00067 
00068 int MPI_Type_struct(int count , int *array_of_blocklengths, MPI_Aint *array_of_displacements
00069   , MPI_Datatype *array_of_types, MPI_Datatype *data_type)
00070 {
00071   /* Make the mpi datatype just the extent (needed latter!) */
00072   int len = 0, extent = 0, k = 0;
00073   for( k = 0; k < count; ++k ) {
00074     switch( array_of_types[k] ) {
00075       case MPI_CHAR:
00076         len = sizeof(char);
00077         break;
00078       case MPI_INT:
00079         len = sizeof(int);
00080         break;
00081       case MPI_FLOAT:
00082         len = sizeof(float);
00083         break;
00084       case MPI_DOUBLE:
00085         len = sizeof(double);
00086         break;
00087       default:
00088         assert(0);
00089     }
00090     len = array_of_displacements[k] + array_of_blocklengths[k] * len;
00091     if( len > extent )
00092       extent = len;
00093   }
00094   *data_type = extent;
00095   return 0;
00096 }
00097 
00098 int MPI_Type_commit(MPI_Datatype *datatype)
00099 {
00100   return 0;
00101 }
00102 
00103 int MPI_Type_free(MPI_Datatype *op)
00104 {
00105   *op = MPI_DATATYPE_NULL;
00106   return 0;
00107 }
00108 
00109 int MPI_Op_create(MPI_User_function *func, int communitive, MPI_Op *op)
00110 {
00111   *op = (MPI_Op)*func;
00112   return 0;
00113 }
00114 int MPI_Op_free( MPI_Op *op)
00115 {
00116   *op = MPI_OP_NULL;
00117   return 0;
00118 }
00119 
00120 int MPI_Send(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
00121 {
00122   assert(0); /* Should never be called in serial mode */
00123   return 0;
00124 }
00125 int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status* status)
00126 {
00127   assert(0); /* Should never be called in serial mode */
00128   return 0;
00129 }
00130 
00131 int MPI_Sendrecv_replace(void* buff, int count, MPI_Datatype datatype, int dest, int sendtag, int source, int recvtag, MPI_Comm comm, MPI_Status* status)
00132 {
00133   assert(0); /* Should never be called in serial mode */
00134   return 0;
00135 }
00136 
00137 int MPI_Reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op
00138   , int root, MPI_Comm comm)
00139 {
00140   char
00141     *_sendbuf = sendbuf,
00142     *_recvbuf = recvbuf;
00143   int k;
00144   for( k = 0; k < count * datatype; ++k )
00145     _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
00146   return 0;
00147 }
00148 
00149 int MPI_Allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype
00150   , MPI_Op op, MPI_Comm comm)
00151 {
00152   char
00153     *_sendbuf = sendbuf,
00154     *_recvbuf = recvbuf;
00155   int k;
00156   for( k = 0; k < count * datatype; ++k )
00157     _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
00158   return 0;
00159 }
00160 
00161 int MPI_Barrier(MPI_Comm comm)
00162 {
00163   return 0;
00164 }
00165 
00166 int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm )
00167 {
00168   return 0;
00169 }
00170 
00171 int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype
00172          , void* recvbuf, int recvcount, MPI_Datatype recvtype, int root , MPI_Comm comm )
00173 {
00174   char
00175     *_sendbuf = sendbuf,
00176     *_recvbuf = recvbuf;
00177   int k;
00178   assert(sendtype == recvtype);
00179   assert(sendcount == recvcount);
00180   for( k = 0; k < sendcount * sendtype; ++k )
00181     _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
00182   return 0;
00183 }
00184 
00185 #endif /* RTOp_USE_MPI */

Generated on Thu Sep 18 12:30:42 2008 for RTOp Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1