00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "Message/CommCreator.h"
00028 #include "Message/Communicate.h"
00029 #include "Profile/Profiler.h"
00030
00031
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
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
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
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
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
00120 return (-1);
00121 }
00122
00123
00125
00126
00127
00128
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
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
00166 comm = new Communicate(argc, argv, nodes);
00167 }
00168
00169
00170 return comm;
00171 }
00172
00173
00174
00175
00176
00177
00178