Main Page | Namespace List | Class Hierarchy | Alphabetical List | 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.8.2.1 2005/06/29 17:07:42 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
    00043 #ifdef HAVE_PVM
    00044 #include "pvm3.h"
    00045 #endif
    00046
    00047 #ifdef HAVE_MPI
    00048 #include "mpi.h"                // for some private variables
    00049 #endif
    00050
    00051 namespace APPSPACK {
    00052
    00062 class GCI {
    00063
    00064 public:
    00065
    00067
    00069   static int init();
    00070
    00072   /* This routine puts all processes in a communicator called
    00073      APPS_COMM. Users who wish to divide the processes into more than
    00074      one communicator, in order to do multi-level parallelism for
    00075      instance, should add code to pare down worldgroup to just the set
    00076      of processes APPS should use. */
    00077   static int init(int& argc, char**& argv);
    00078
    00080   /* Set standard output to pipe through this process ONLY IF this
    00081      process HAS NOT been launched from the PVM console. If flag
    00082      (default true) is false, then disable output redirection.*/
    00083   static void catchOutput(bool flag = true);
    00084
    00086   /* Spawn a SINGLE task with the given name on a specified host. If
    00087      the host name is unspecified (""), then the task is spawned on
    00088      any available machine. Argv is the array of arguments to the
    00089      spawned job. Default argv is NULL. Return 0 if the spawn
    00090      failed. Otherwise, return the PVM taskid. */
    00091   static int spawn(const string name, const string host, char* argv[] = NULL);
    00092
    00094   static void kill(int tid);
    00095
    00097   static void exit();
    00098
    00100
    00102
    00104   static int getMyTid();
    00105
    00107   static int getNumProcs();
    00108
    00112   static bool isOrphan();
    00113
    00115   static int parent();
    00116
    00118   static int tidToHost(int tid);
    00119
    00123   static void notify(int msgtag, int taskid);
    00124
    00128   static void notify(int msgtag);
    00129
    00131
    00133
    00135   static void initSend();
    00136
    00138   static void send(int msgtag, int taskid);
    00139
    00142   static void broadcast (int msgtag, const vector<int>& taskid);
    00143
    00145
    00149   static bool recv(int msgtag = -1, int taskid = -1);
    00150
    00152
    00155   static bool nrecv(int msgtag = -1, int taskid = -1);
    00156
    00158
    00162   static bool probe(int msgtag = -1, int taskid = -1);
    00163
    00165
    00168   static void bprobe(int msgtag = -1, int taskid = -1);
    00169
    00172   static void bufinfo(int& msgtag, int& taskid);
    00173
    00174   //static void bufinfo(int bufid, int& msgtag, int& taskid);
    00175
    00177
    00179
    00181   static void pack(int i);
    00182
    00184   static void pack(char i);
    00185
    00187   static void pack(double d);
    00188
    00190   static void pack(float f);
    00191
    00193   static void pack(bool b);
    00194
    00196   static void pack(const string s);
    00197
    00199   static void pack(const vector<int>& v);
    00200
    00202   static void pack(const vector<double>& v);
    00203
    00205   static void pack(const vector<float>& v);
    00206
    00208   static void pack(const vector< vector<double> >& v);
    00209
    00211   static void pack(const vector<string>& v);
    00212
    00214   static void pack(const vector<bool>& v);
    00215
    00217   static void pack(int length, const char* array);
    00218
    00220   static void pack(int length, const int* array);
    00221
    00223   static void pack(int length, const double* array);
    00224
    00226   static void pack(int length, const float* array);
    00227
    00229   static void unpack(int& i);
    00230
    00232   static void unpack(char& c);
    00233
    00235   static void unpack(double& d);
    00236
    00238   static void unpack(float& f);
    00239
    00241   static void unpack(bool& b);
    00242
    00244   static void unpack(string& s);
    00245
    00247   static void unpack(vector<int>& v);
    00248
    00250   static void unpack(vector<double>& v);
    00251
    00253   static void unpack(vector< vector<double> >& v);
    00254
    00256   static void unpack(vector<string>& v);
    00257
    00259   static void unpack(vector<bool>& v);
    00260
    00262   static void unpack(int& length, char*& array);
    00263
    00265   static void unpack(int& length, int*& array);
    00266
    00268   static void unpack(int& length, double*& array);
    00269
    00271   static void unpack(int& length, float*& array);
    00272
    00274
    00276
    00280   static int resetHostInfo();
    00281
    00283   static int getHostTid(int i);
    00285   static int getHostSpeed(int i);
    00286
    00288   static char* getHostName(int i);
    00290
    00291
    00292
    00293 private:
    00294
    00295 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00296
    00297   static void pack(const char* s);
    00298   static void unpack(char*& s);
    00299
    00300 #ifdef HAVE_PVM
    00301   static void pvmPackCheck(int info);
    00302   static void pvmUnpackCheck(int info);
    00303   static int lastBufferId;
    00304   static struct pvmhostinfo* pvmHostInfo;
    00305   static int nHosts;
    00306   static int nArch;
    00307 #endif
    00308
    00309 #ifdef HAVE_MPI
    00310   static char* sendBuffer;
    00311   static char* recvBuffer;
    00312   static int sendPosition, recvPosition, msgSize;
    00313   static MPI_Comm APPS_COMM;
    00314   static MPI_Status status;
    00315   static int mpiGetMsgSize(MPI_Status localStatus, MPI_Datatype dataType);
    00316   static void mpiStretchSendBuffer(int nBytes);
    00317 #endif
    00318
    00319 #endif
    00320
    00321 };
    00322
    00323 }
    00324 #endif

© Sandia Corporation | Site Contact | Privacy and Security

Generated on Wed Dec 14 18:41:04 2005 for APPSPACK 4.0.2 by 1.3.8 written by Dimitri van Heesch, © 1997-2002