00001 /* 00002 * *************************************************************************** 00003 * MALOC = < Minimal Abstraction Layer for Object-oriented C > 00004 * Copyright (C) 1994--2008 Michael Holst 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 * rcsid="$Id: vmp.c,v 1.10 2008/03/12 05:13:58 fetk Exp $" 00021 * *************************************************************************** 00022 */ 00023 00024 /* 00025 * *************************************************************************** 00026 * File: vmp.c 00027 * 00028 * Purpose: Class Vmp: methods. 00029 * 00030 * Notes: Thin MPI abstraction layer on top of VCOM and VMPI. 00031 * This layer is going to dissappear completely when 00032 * VCOM and VMPI are merged. 00033 * 00034 * Author: Michael Holst 00035 * *************************************************************************** 00036 */ 00037 00038 #include "vmp_p.h" 00039 00040 VEMBED(rcsid="$Id: vmp.c,v 1.10 2008/03/12 05:13:58 fetk Exp $") 00041 00042 #define USE_VCOM_NOT 1 00043 00044 /* 00045 * *************************************************************************** 00046 * Class Vmp: Inlineable methods 00047 * *************************************************************************** 00048 */ 00049 #if !defined(VINLINE_MALOC) 00050 00051 #endif /* if !defined(VINLINE_MALOC) */ 00052 /* 00053 * *************************************************************************** 00054 * Class Vmp: Non-inlineable methods 00055 * *************************************************************************** 00056 */ 00057 00058 /* 00059 * *************************************************************************** 00060 * Routine: Vmp_init 00061 * 00062 * Purpose: The Vmp initializer. 00063 * 00064 * Author: Michael Holst 00065 * *************************************************************************** 00066 */ 00067 VPUBLIC int Vmp_init(int *argc, char ***argv) 00068 { 00069 # if defined(USE_VCOM) 00070 return Vcom_init(argc,argv); 00071 # else 00072 return Vmpi_init(argc,argv); 00073 # endif 00074 } 00075 00076 /* 00077 * *************************************************************************** 00078 * Routine: Vmp_finalize 00079 * 00080 * Purpose: The Vmp finalizer. 00081 * 00082 * Author: Michael Holst 00083 * *************************************************************************** 00084 */ 00085 VPUBLIC int Vmp_finalize(void) 00086 { 00087 # if defined(USE_VCOM) 00088 return Vcom_finalize(); 00089 # else 00090 return Vmpi_finalize(); 00091 # endif 00092 } 00093 00094 /* 00095 * *************************************************************************** 00096 * Routine: Vmp_ctor 00097 * 00098 * Purpose: The Vmp constructor. 00099 * 00100 * Author: Michael Holst 00101 * *************************************************************************** 00102 */ 00103 VPUBLIC Vmp* Vmp_ctor(void) 00104 { 00105 # if defined(USE_VCOM) 00106 return (Vmp*)Vcom_ctor(1); 00107 # else 00108 return (Vmp*)Vmpi_ctor(); 00109 # endif 00110 } 00111 00112 /* 00113 * *************************************************************************** 00114 * Routine: Vmp_dtor 00115 * 00116 * Purpose: The Vmp destructor. 00117 * 00118 * Author: Michael Holst 00119 * *************************************************************************** 00120 */ 00121 VPUBLIC void Vmp_dtor(Vmp **thee) 00122 { 00123 # if defined(USE_VCOM) 00124 Vcom_dtor( (Vcom**)thee ); 00125 # else 00126 Vmpi_dtor( (Vmpi**)thee ); 00127 # endif 00128 } 00129 00130 /* 00131 * *************************************************************************** 00132 * Routine: Vmp_rank 00133 * 00134 * Purpose: Return my processor ID. 00135 * 00136 * Author: Michael Holst 00137 * *************************************************************************** 00138 */ 00139 VPUBLIC int Vmp_rank(Vmp *thee) 00140 { 00141 # if defined(USE_VCOM) 00142 return Vcom_rank( (Vcom*)thee ); 00143 # else 00144 return Vmpi_rank( (Vmpi*)thee ); 00145 # endif 00146 } 00147 00148 /* 00149 * *************************************************************************** 00150 * Routine: Vmp_size 00151 * 00152 * Purpose: Return the number of processors involved. 00153 * 00154 * Author: Michael Holst 00155 * *************************************************************************** 00156 */ 00157 VPUBLIC int Vmp_size(Vmp *thee) 00158 { 00159 # if defined(USE_VCOM) 00160 return Vcom_size( (Vcom*)thee ); 00161 # else 00162 return Vmpi_size( (Vmpi*)thee ); 00163 # endif 00164 } 00165 00166 /* 00167 * *************************************************************************** 00168 * Routine: Vmp_barr 00169 * 00170 * Purpose: An MPI barrier. 00171 * 00172 * Author: Michael Holst 00173 * *************************************************************************** 00174 */ 00175 VPUBLIC int Vmp_barr(Vmp *thee) 00176 { 00177 # if defined(USE_VCOM) 00178 return Vcom_barr( (Vcom*)thee ); 00179 # else 00180 return Vmpi_barr( (Vmpi*)thee ); 00181 # endif 00182 } 00183 00184 /* 00185 * *************************************************************************** 00186 * Routine: Vmp_send 00187 * 00188 * Purpose: An MPI blocking send. 00189 * 00190 * Author: Michael Holst 00191 * *************************************************************************** 00192 */ 00193 VPUBLIC int Vmp_send(Vmp *thee, int des, char *buf, int bufsize) 00194 { 00195 # if defined(USE_VCOM) 00196 return Vcom_send( (Vcom*)thee, des, buf, bufsize, 0, 1 ); 00197 # else 00198 return Vmpi_send( (Vmpi*)thee, des, buf, bufsize ); 00199 # endif 00200 } 00201 00202 /* 00203 * *************************************************************************** 00204 * Routine: Vmp_recv 00205 * 00206 * Purpose: An MPI blocking receive. 00207 * 00208 * Author: Michael Holst 00209 * *************************************************************************** 00210 */ 00211 VPUBLIC int Vmp_recv(Vmp *thee, int src, char *buf, int bufsize) 00212 { 00213 # if defined(USE_VCOM) 00214 return Vcom_recv( (Vcom*)thee, src, buf, bufsize, 0, 1 ); 00215 # else 00216 return Vmpi_recv( (Vmpi*)thee, src, buf, bufsize ); 00217 # endif 00218 } 00219