MOOCHO (Single Doxygen Collection) Version of the Day
RTOp_mpi.c
Go to the documentation of this file.
00001 /*
00002 // @HEADER
00003 // ***********************************************************************
00004 // 
00005 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00006 //                  Copyright (2003) 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 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00039 // 
00040 // ***********************************************************************
00041 // @HEADER
00042 */
00043 
00044 /*
00045  * This file includes selected hollow MPI function definitions for a
00046  * sinlge process implementation.
00047  */
00048 
00049 #include <assert.h>
00050 
00051 /*
00052  * RAB: 2004/01/22: This file is included because it includes
00053  * Thyra_Config.h which then defines RTOp_USE_MPI or not.  If
00054  * RTOp_USE_MPI is defined then this header file will also include
00055  * RTOp_mpi.h for these delcarations.
00056  */
00057 #include "RTOp_MPI_config.h"
00058 
00059 #ifndef RTOp_USE_MPI
00060 
00061 int MPI_Init(int *argc, char ***argv)
00062 {
00063   return 0;
00064 }
00065 
00066 int MPI_Finalize(void)
00067 {
00068   return 0;
00069 }
00070 
00071 int MPI_Comm_size(MPI_Comm comm, int *size)
00072 {
00073   *size = 1;
00074   return 0;
00075 }
00076 
00077 int MPI_Comm_rank(MPI_Comm comm, int *rank)
00078 {
00079   *rank = 0;
00080   return 0;
00081 }
00082 
00083 int MPI_Type_struct(int count , int *array_of_blocklengths, MPI_Aint *array_of_displacements
00084   , MPI_Datatype *array_of_types, MPI_Datatype *data_type)
00085 {
00086   /* Make the mpi datatype just the extent (needed latter!) */
00087   int len = 0, extent = 0, k = 0;
00088   for( k = 0; k < count; ++k ) {
00089     switch( array_of_types[k] ) {
00090       case MPI_CHAR:
00091         len = sizeof(char);
00092         break;
00093       case MPI_INT:
00094         len = sizeof(int);
00095         break;
00096       case MPI_FLOAT:
00097         len = sizeof(float);
00098         break;
00099       case MPI_DOUBLE:
00100         len = sizeof(double);
00101         break;
00102       default:
00103         assert(0);
00104     }
00105     len = array_of_displacements[k] + array_of_blocklengths[k] * len;
00106     if( len > extent )
00107       extent = len;
00108   }
00109   *data_type = extent;
00110   return 0;
00111 }
00112 
00113 int MPI_Type_commit(MPI_Datatype *datatype)
00114 {
00115   return 0;
00116 }
00117 
00118 int MPI_Type_free(MPI_Datatype *op)
00119 {
00120   *op = MPI_DATATYPE_NULL;
00121   return 0;
00122 }
00123 
00124 int MPI_Op_create(MPI_User_function *func, int communitive, MPI_Op *op)
00125 {
00126   *op = (MPI_Op)*func;
00127   return 0;
00128 }
00129 int MPI_Op_free( MPI_Op *op)
00130 {
00131   *op = MPI_OP_NULL;
00132   return 0;
00133 }
00134 
00135 int MPI_Send(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
00136 {
00137   assert(0); /* Should never be called in serial mode */
00138   return 0;
00139 }
00140 int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, RTOP_MPI_Status* status)
00141 {
00142   assert(0); /* Should never be called in serial mode */
00143   return 0;
00144 }
00145 
00146 int MPI_Sendrecv_replace(void* buff, int count, MPI_Datatype datatype, int dest, int sendtag, int source, int recvtag, MPI_Comm comm, RTOP_MPI_Status* status)
00147 {
00148   assert(0); /* Should never be called in serial mode */
00149   return 0;
00150 }
00151 
00152 int MPI_Reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op
00153   , int root, MPI_Comm comm)
00154 {
00155   char
00156     *_sendbuf = sendbuf,
00157     *_recvbuf = recvbuf;
00158   int k;
00159   for( k = 0; k < count * datatype; ++k )
00160     _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
00161   return 0;
00162 }
00163 
00164 int MPI_Allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype
00165   , MPI_Op op, MPI_Comm comm)
00166 {
00167   char
00168     *_sendbuf = sendbuf,
00169     *_recvbuf = recvbuf;
00170   int k;
00171   for( k = 0; k < count * datatype; ++k )
00172     _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
00173   return 0;
00174 }
00175 
00176 int MPI_Barrier(MPI_Comm comm)
00177 {
00178   return 0;
00179 }
00180 
00181 int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm )
00182 {
00183   return 0;
00184 }
00185 
00186 int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype
00187          , void* recvbuf, int recvcount, MPI_Datatype recvtype, int root , MPI_Comm comm )
00188 {
00189   char
00190     *_sendbuf = sendbuf,
00191     *_recvbuf = recvbuf;
00192   int k;
00193   assert(sendtype == recvtype);
00194   assert(sendcount == recvcount);
00195   for( k = 0; k < sendcount * sendtype; ++k )
00196     _recvbuf[k] =_sendbuf[k]; /* just copy bit for bit */
00197   return 0;
00198 }
00199 
00200 #endif /* RTOp_USE_MPI */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines