Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

PxSystem.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (c) 2003-2004, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *  Author(s):
00006  *  Frank Seinstra <fjseins@wins.uva.nl>
00007  */
00008 
00009 #ifndef __PxSystem_h_
00010 #define __PxSystem_h_
00011 
00012 
00013 #include "mpi.h"
00014 #include <stdlib.h>
00015 
00016 namespace Impala
00017 {
00018 namespace Core
00019 {
00020 namespace Array
00021 {
00022 namespace Pattern
00023 {
00024 
00025 
00026 /*** Global variables ***/
00027 
00028 int     sys_myCPU   = 0;
00029 char    sys_myCPUname[MPI_MAX_PROCESSOR_NAME] = "unknown";
00030 int     sys_nrCPUs  = 1;
00031 
00032 int     sys_xCPUs   = 1;
00033 int     sys_yCPUs   = 1;
00034 int     sys_zCPUs   = 1;
00035 int     sys_rootCPU = 0;
00036 
00037 int     run_parallel     = 1;
00038 int     run_lazyParallel = 1;
00039 
00040 int     in_dataCPU  = 0;
00041 int     out_dataCPU = 0;
00042 
00043 
00044 /**********************************************************************
00045  *** General Parallel System Functions                              ***
00046  **********************************************************************/
00047 
00048 inline void
00049 PxInitSystem(int *argc, char ***argv)
00050 {
00051     int reslen;
00052 
00053     MPI_Init(argc, argv);
00054     MPI_Comm_rank(MPI_COMM_WORLD, &sys_myCPU);
00055     MPI_Comm_size(MPI_COMM_WORLD, &sys_nrCPUs);
00056     MPI_Get_processor_name(sys_myCPUname, &reslen);
00057 }
00058 
00059 
00060 inline int
00061 PxExitSystem()
00062 {
00063     MPI_Barrier(MPI_COMM_WORLD);
00064     return MPI_Finalize();
00065 }
00066 
00067 
00068 inline void
00069 PxAbortSystem()
00070 {
00071     MPI_Barrier(MPI_COMM_WORLD);
00072     MPI_Abort(MPI_COMM_WORLD, 1);
00073     MPI_Finalize();
00074     exit(1);
00075 }
00076 
00077 
00078 inline int
00079 PxMyCPU()
00080 {
00081     return sys_myCPU;
00082 }
00083 
00084 
00085 inline char*
00086 PxMyCPUname()
00087 {
00088     return sys_myCPUname;
00089 }
00090 
00091 
00092 inline int
00093 PxNrCPUs()
00094 {
00095     return sys_nrCPUs;
00096 }
00097 
00098 
00099 inline void
00100 PxInitSystemGrid(int xcpus, int ycpus, int zcpus)
00101 {
00102     sys_xCPUs = xcpus;
00103     sys_yCPUs = ycpus;
00104     sys_zCPUs = zcpus;
00105 }
00106 
00107 
00108 inline int
00109 PxXCPUs()
00110 {
00111     return sys_xCPUs;
00112 }
00113 
00114 
00115 inline int
00116 PxYCPUs()
00117 {
00118     return sys_yCPUs;
00119 }
00120 
00121 
00122 inline int
00123 PxZCPUs()
00124 {
00125     return sys_zCPUs;
00126 }
00127 
00128 
00129 inline void
00130 PxInitRoot(int cpu)
00131 {
00132     sys_rootCPU = (cpu < 0 || cpu >= sys_nrCPUs) ? 0 : cpu;
00133 }
00134 
00135 
00136 inline int
00137 PxRootCPU()
00138 {
00139     return sys_rootCPU;
00140 }
00141 
00142 
00143 /**********************************************************************/
00144 
00145 
00146 inline void
00147 PxInitRunParallel(int runpar)
00148 {
00149     run_parallel = (runpar < 0 || runpar > 1) ? 0 : runpar;
00150     if (!run_parallel) {
00151         run_lazyParallel = 0;
00152     }
00153 }
00154 
00155 
00156 inline int
00157 PxRunParallel()
00158 {
00159     return run_parallel;
00160 }
00161 
00162 
00163 inline void
00164 PxInitLazyParallel(int lazypar)
00165 {
00166     run_lazyParallel = (lazypar < 0 || lazypar > 1) ? 0 : lazypar;
00167     if (run_lazyParallel) {
00168         run_parallel = 1;
00169     }
00170 }
00171 
00172 
00173 inline int
00174 PxRunLazyParallel()
00175 {
00176     return run_lazyParallel;
00177 }
00178 
00179 
00180 /**********************************************************************/
00181 
00182 
00183 inline void
00184 PxInitDataInOut(int cpu)
00185 {
00186     in_dataCPU  = (cpu < 0 || cpu >= sys_nrCPUs) ? sys_rootCPU : cpu;
00187     out_dataCPU = in_dataCPU;
00188 }
00189 
00190 
00191 inline int
00192 PxInCPU()
00193 {
00194     return in_dataCPU;
00195 }
00196 
00197 
00198 inline int
00199 PxOutCPU()
00200 {
00201     return out_dataCPU;
00202 }
00203 
00204 
00205 } // namespace Pattern
00206 } // namespace Array
00207 } // namespace Core
00208 } // namespace Impala
00209 
00210 #endif /* __PxSystem_h_ */

Generated on Fri Mar 19 09:30:52 2010 for ImpalaSrc by  doxygen 1.5.1