Sandia Home Sandia Home
Main Page | Publications | Downloads | Configuration | Running the Code | Solver Parameters | FAQ | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

APPSPACK_GCI.hpp

Go to the documentation of this file.
00001 // $Id: APPSPACK_GCI.hpp,v 1.10 2005/06/30 00:44:20 tgkolda Exp $ 
00002 // $Source: /space/CVS-Acro/acro/packages/appspack/appspack/src/APPSPACK_GCI.hpp,v $ 
00003 
00004 //@HEADER
00005 // ************************************************************************
00006 // 
00007 //          APPSPACK: Asynchronous Parallel Pattern Search
00008 //                 Copyright (2003) Sandia Corporation
00009 // 
00010 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00011 // license for use of this work by or on behalf of the U.S. Government.
00012 // 
00013 // This library is free software; you can redistribute it and/or modify
00014 // it under the terms of the GNU Lesser General Public License as
00015 // published by the Free Software Foundation; either version 2.1 of the
00016 // License, or (at your option) any later version.
00017 //  
00018 // This library is distributed in the hope that it will be useful, but
00019 // WITHOUT ANY WARRANTY; without even the implied warranty of
00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021 // Lesser General Public License for more details.
00022 //                                                                                 
00023 // You should have received a copy of the GNU Lesser General Public
00024 // License along with this library; if not, write to the Free Software
00025 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00026 // USA.                                                                           .
00027 // 
00028 // Questions? Contact Tammy Kolda (tgkolda@sandia.gov) 
00029 // 
00030 // ************************************************************************
00031 //@HEADER
00032 
00033 
00038 #ifndef APPSPACK_GCI_H
00039 #define APPSPACK_GCI_H
00040 
00041 #include "APPSPACK_Common.hpp"
00042 #include "APPSPACK_Vector.hpp"
00043 
00044 #ifdef HAVE_PVM
00045 #include "pvm3.h"
00046 #endif
00047 
00048 #ifdef HAVE_MPI
00049 #include "mpi.h"                // for some private variables
00050 #endif
00051 
00052 namespace APPSPACK {
00053 
00063 class GCI {
00064 
00065 public:
00066 
00068 
00070   static int init();
00071 
00073   /* This routine puts all processes in a communicator called
00074      APPS_COMM. Users who wish to divide the processes into more than
00075      one communicator, in order to do multi-level parallelism for
00076      instance, should add code to pare down worldgroup to just the set
00077      of processes APPS should use. */
00078   static int init(int& argc, char**& argv);
00079   
00081   /* Set standard output to pipe through this process ONLY IF this
00082      process HAS NOT been launched from the PVM console. If flag
00083      (default true) is false, then disable output redirection.*/
00084   static void catchOutput(bool flag = true);
00085 
00087   /* Spawn a SINGLE task with the given name on a specified host. If
00088      the host name is unspecified (""), then the task is spawned on
00089      any available machine. Argv is the array of arguments to the
00090      spawned job. Default argv is NULL. Return 0 if the spawn
00091      failed. Otherwise, return the PVM taskid. */
00092   static int spawn(const string name, const string host, char* argv[] = NULL);
00093 
00095   static void kill(int tid);
00096 
00098   static void exit();
00099 
00101 
00103 
00105   static int getMyTid();
00106 
00108   static int getNumProcs();
00109 
00113   static bool isOrphan();
00114 
00116   static int parent();
00117 
00119   static int tidToHost(int tid);
00120 
00124   static void notify(int msgtag, int taskid);
00125 
00129   static void notify(int msgtag);
00130 
00132 
00134 
00136   static void initSend();
00137 
00139   static void send(int msgtag, int taskid);
00140 
00143   static void broadcast (int msgtag, const vector<int>& taskid);
00144 
00146 
00150   static bool recv(int msgtag = -1, int taskid = -1);
00151 
00153 
00156   static bool nrecv(int msgtag = -1, int taskid = -1);
00157 
00159 
00163   static bool probe(int msgtag = -1, int taskid = -1);
00164 
00166 
00169   static void bprobe(int msgtag = -1, int taskid = -1); 
00170 
00173   static void bufinfo(int& msgtag, int& taskid);
00174 
00175   //static void bufinfo(int bufid, int& msgtag, int& taskid);
00176 
00178 
00180 
00182   static void pack(int i);
00183 
00185   static void pack(char i);
00186 
00188   static void pack(double d);
00189 
00191   static void pack(float f);
00192 
00194   static void pack(bool b);
00195 
00197   static void pack(const string s);
00198 
00200   static void pack(const vector<int>& v);
00201 
00203   static void pack(const Vector& v);
00204 
00206   static void pack(const vector<float>& v);
00207 
00209   static void pack(const vector< Vector >& v);
00210 
00212   static void pack(const vector<string>& v);
00213 
00215   static void pack(const vector<bool>& v);
00216 
00218   static void pack(int length, const char* array);
00219 
00221   static void pack(int length, const int* array);
00222 
00224   static void pack(int length, const double* array);
00225 
00227   static void pack(int length, const float* array);
00228 
00230   static void unpack(int& i);
00231 
00233   static void unpack(char& c);
00234 
00236   static void unpack(double& d);
00237 
00239   static void unpack(float& f);
00240 
00242   static void unpack(bool& b);
00243 
00245   static void unpack(string& s);
00246 
00248   static void unpack(vector<int>& v);
00249 
00251   static void unpack(Vector& v);
00252 
00254   static void unpack(vector< Vector >& v);
00255 
00257   static void unpack(vector<string>& v);
00258 
00260   static void unpack(vector<bool>& v);
00261 
00263   static void unpack(int& length, char*& array);
00264 
00266   static void unpack(int& length, int*& array);
00267 
00269   static void unpack(int& length, double*& array);
00270 
00272   static void unpack(int& length, float*& array);
00273 
00275 
00277 
00281   static int resetHostInfo();
00282 
00284   static int getHostTid(int i);
00286   static int getHostSpeed(int i);
00287 
00289   static char* getHostName(int i);
00291 
00292 
00293 
00294 private:
00295 
00296 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00297 
00298   static void pack(const char* s);
00299   static void unpack(char*& s);
00300 
00301 #ifdef HAVE_PVM
00302   static void pvmPackCheck(int info);
00303   static void pvmUnpackCheck(int info);
00304   static int lastBufferId;
00305   static struct pvmhostinfo* pvmHostInfo;
00306   static int nHosts;
00307   static int nArch;
00308 #endif
00309 
00310 #ifdef HAVE_MPI
00311   static char* sendBuffer;
00312   static char* recvBuffer;
00313   static int sendPosition, recvPosition, msgSize;
00314   static MPI_Comm APPS_COMM;
00315   static MPI_Status status;
00316   static int mpiGetMsgSize(MPI_Status localStatus, MPI_Datatype dataType);
00317   static void mpiStretchSendBuffer(int nBytes);
00318 #endif
00319 
00320 #endif
00321 
00322 };
00323 
00324 }
00325 #endif

 

© Sandia Corporation | Site Contact | Privacy and Security

Generated on Fri Feb 16 10:33:35 2007 for APPSPACK 5.0.1 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2002