src/Message/CommCreator.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  * This program was prepared by PSI. 
00007  * All rights in the program are reserved by PSI.
00008  * Neither PSI nor the author(s)
00009  * makes any warranty, express or implied, or assumes any liability or
00010  * responsibility for the use of this software
00011  *
00012  * Visit http://www.acl.lanl.gov/POOMS for more details
00013  *
00014  ***************************************************************************/
00015 
00016 // -*- C++ -*-
00017 /***************************************************************************
00018  *
00019  * The IPPL Framework
00020  * 
00021  *
00022  * Visit http://people.web.psi.ch/adelmann/ for more details
00023  *
00024  ***************************************************************************/
00025 
00026 // include files
00027 #include "Message/CommCreator.h"
00028 #include "Message/Communicate.h"
00029 #include "Profile/Profiler.h"
00030 
00031 // include files for specific communication libraries
00032 #if defined(IPPL_PVM)
00033 #include "Message/CommPVM.h"
00034 #endif
00035 
00036 #if defined(IPPL_MPI)
00037 #include "Message/CommMPI.h"
00038 #endif
00039 
00040 #if defined(IPPL_SHMEMPI)
00041 #include "Message/CommSHMEMPI.h"
00042 #endif
00043 
00044 #if defined(IPPL_ACLMPL)
00045 #include "Message/CommACLMPL.h"
00046 #endif
00047 
00048 #if defined(IPPL_PM)
00049 #include "Message/CommPM.h"
00050 #endif
00051 
00052 #include <string.h>
00053 
00054 // static data for this file
00055 static char *CommLibraryNames[CommCreator::COMMLIBRARIES] =
00056   { "aclmpl", "pm", "mpi", "shmempi", "pvm", "serial" };
00057 static char *CommLibraryList = "aclmpl, pm, mpi, shmempi, pvm, or serial";
00058 
00059 
00061 // return the name of the Nth library
00062 const char *CommCreator::getLibraryName(int n) {
00063   TAU_PROFILE("CommCreator::getLibraryName()", "char * (int n)", TAU_MESSAGE);
00064   if (n >= 0 && n < COMMLIBRARIES)
00065     return CommLibraryNames[n];
00066   else
00067     return 0;
00068 }
00069 
00070 
00072 // return a list of all the libraries, as a single string
00073 const char *CommCreator::getAllLibraryNames() {
00074   TAU_PROFILE("CommCreator::getAllLibraryNames()", "char *()", TAU_MESSAGE);
00075   return CommLibraryList;
00076 }
00077 
00078 
00080 bool CommCreator::supported(int cm) {
00081   TAU_PROFILE("CommCreator::supported()", "bool (int)", TAU_MESSAGE);
00082   if (cm == ACLMPL) {
00083 #ifdef IPPL_ACLMPL
00084     return true;
00085 #endif
00086   } else if (cm == PM) {
00087 #ifdef IPPL_PM
00088     return true;
00089 #endif
00090   } else if (cm == MPI) {
00091 #ifdef IPPL_MPI
00092     return true;
00093 #endif
00094   } else if (cm == SHMEMPI) {
00095 #ifdef IPPL_SHMEMPI
00096     return true;
00097 #endif
00098   } else if (cm == PVM) {
00099 #ifdef IPPL_PVM
00100     return true;
00101 #endif
00102   } else if (cm == SERIAL) {
00103     return true;
00104   }
00105 
00106   return false;
00107 }
00108 
00109 
00111 // return the index of the given named library, or (-1) if not found
00112 int CommCreator::libindex(const char *nm) {
00113   TAU_PROFILE("CommCreator::libindex()", "int (char *)", TAU_MESSAGE);
00114   for (int i=0; i < COMMLIBRARIES; ++i) {
00115     if (strcmp(nm, getLibraryName(i)) == 0)
00116       return i;
00117   }
00118 
00119   // if here, it was not found
00120   return (-1);
00121 }
00122 
00123 
00125 // create a new Communicate object.  Arguments = type, argc, argv, num nodes,
00126 // whether to do initialization or not (ignored by some libs).
00127 // If the type code is illegal, or the comm library is not supported,
00128 // return 0.
00129 Communicate *CommCreator::create(int cm, int& argc, char**& argv, int nodes,
00130                                  bool doinit) {
00131   TAU_PROFILE("CommCreator::create()",
00132               "Communicate * (int, int, char **, int)", TAU_MESSAGE);
00133 
00134   Communicate *comm = 0;
00135 
00136   // to avoid warning message
00137   if (doinit);
00138 
00139   if (cm == ACLMPL) {
00140 #ifdef IPPL_ACLMPL
00141     comm = new CommACLMPL(argc, argv, nodes);
00142 #endif
00143 
00144   } else if (cm == PM) {
00145 #ifdef IPPL_PM
00146     comm = new CommPM(argc, argv, nodes);
00147 #endif  
00148 
00149   } else if (cm == MPI) {
00150 #ifdef IPPL_MPI
00151     comm = new CommMPI(argc, argv, nodes, doinit);
00152 #endif
00153 
00154   } else if (cm == SHMEMPI) {
00155 #ifdef IPPL_SHMEMPI
00156     comm = new CommSHMEMPI(argc, argv, nodes);
00157 #endif
00158 
00159   } else if (cm == PVM) {
00160 #ifdef IPPL_PVM
00161     comm = new CommPVM(argc, argv, nodes);
00162 #endif
00163 
00164   } else if (cm == SERIAL) {
00165     // just make a dummy comm object, which does nothing
00166     comm = new Communicate(argc, argv, nodes);
00167   }
00168 
00169   // return the Communicate object
00170   return comm;
00171 }
00172 
00173 
00174 /***************************************************************************
00175  * $RCSfile: CommCreator.cpp,v $   $Author: adelmann $
00176  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:28 $
00177  * IPPL_VERSION_ID: $Id: CommCreator.cpp,v 1.1.1.1 2003/01/23 07:40:28 adelmann Exp $ 
00178  ***************************************************************************/

Generated on Mon Jan 16 13:23:51 2006 for IPPL by  doxygen 1.4.6