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 #include <assert.h>
00037 
00038 /*
00039  * RAB: 2004/01/22: This file is included because it includes
00040  * Thyra_Config.h which then defines RTOp_USE_MPI or not.  If
00041  * RTOp_USE_MPI is defined then this header file will also include
00042  * RTOp_mpi.h for these delcarations.
00043  */
00044 #include "RTOp_MPI_config.h"
00045 
00046 #ifndef RTOp_USE_MPI
00047 
00048 int MPI_Init(int *argc, char ***argv)
00049 {
00050   return 0;
00051 }
00052 
00053 int MPI_Finalize(void)
00054 {
00055   return 0;
00056 }
00057 
00058 int MPI_Comm_size(MPI_Comm comm, int *size)
00059 {
00060   *size = 1;
00061   return 0;
00062 }
00063 
00064 int MPI_Comm_rank(MPI_Comm comm, int *rank)
00065 {
00066   *rank = 0;
00067   return 0;
00068 }
00069 
00070 int MPI_Type_struct(int count , int *array_of_blocklengths, MPI_Aint *array_of_displacements
00071   , MPI_Datatype *array_of_types, MPI_Datatype *data_type)
00072 {
00073   /* Make the mpi datatype just the extent (needed latter!) */
00074   int len = 0, extent = 0, k = 0;
00075   for( k = 0; k < count; ++k ) {
00076     switch( array_of_types[k] ) {
00077       case MPI_CHAR:
00078         len = sizeof(char);
00079         break;
00080       case MPI_INT:
00081         len = sizeof(int);
00082         break;
00083       case MPI_FLOAT:
00084         len = sizeof(float);
00085         break;
00086       case MPI_DOUBLE:
00087         len = sizeof(double);
00088         break;
00089       default:
00090         assert(0);
00091     }
00092     len = array_of_displacements[k] + array_of_blocklengths[k] * len;
00093     if( len > extent )
00094       extent = len;
00095   }
00096   *data_type = extent;
00097   return 0;
00098 }
00099 
00100 int MPI_Type_commit(MPI_Datatype *datatype)
00101 {
00102   return 0;
00103 }
00104 
00105 int MPI_Type_free(MPI_Datatype *op)
00106 {
00107   *op = MPI_DATATYPE_NULL;
00108   return 0;
00109 }
00110 
00111 int MPI_Op_create(MPI_User_function *func, int communitive, MPI_Op *op)
00112 {
00113   *op = (MPI_Op)*func;
00114   return 0;
00115 }
00116 int MPI_Op_free( MPI_Op *op)
00117 {
00118   *op = MPI_OP_NULL;
00119   return 0;
00120 }
00121 
00122 int MPI_Send(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
00123 {
00124   assert(0); /* Should never be called in serial mode */
00125   return 0;
00126 }
00127 int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status* status)
00128 {
00129   assert(0); /* Should never be called in serial mode */
00130   return 0;
00131 }
00132 
00133 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)
00134 {
00135   assert(0); /* Should never be called in serial mode */
00136   return 0;
00137 }
00138 
00139 int MPI_Reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op
00140   , int root, MPI_Comm comm)
00141 {
00142   char
00143     *_sendbuf = sendbuf,
00144     *_recvbuf = recvbuf;
00145   int k;
00146   for( k = 0; k < count * datatype; ++k )
00147     _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
00148   return 0;
00149 }
00150 
00151 int MPI_Allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype
00152   , MPI_Op op, MPI_Comm comm)
00153 {
00154   char
00155     *_sendbuf = sendbuf,
00156     *_recvbuf = recvbuf;
00157   int k;
00158   for( k = 0; k < count * datatype; ++k )
00159     _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
00160   return 0;
00161 }
00162 
00163 int MPI_Barrier(MPI_Comm comm)
00164 {
00165   return 0;
00166 }
00167 
00168 int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm )
00169 {
00170   return 0;
00171 }
00172 
00173 int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype
00174          , void* recvbuf, int recvcount, MPI_Datatype recvtype, int root , MPI_Comm comm )
00175 {
00176   char
00177     *_sendbuf = sendbuf,
00178     *_recvbuf = recvbuf;
00179   int k;
00180   assert(sendtype == recvtype);
00181   assert(sendcount == recvcount);
00182   for( k = 0; k < sendcount * sendtype; ++k )
00183     _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
00184   return 0;
00185 }
00186 
00187 #endif /* RTOp_USE_MPI */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:11:01 2011 for MOOCHO (Single Doxygen Collection) by  doxygen 1.6.3