Line data Source code
1 : //# PTransport.h: Base class for parallel data transport models 2 : //# Copyright (C) 1998,1999,2000 3 : //# Associated Universities, Inc. Washington DC, USA. 4 : //# 5 : //# This library is free software; you can redistribute it and/or modify it 6 : //# under the terms of the GNU Library General Public License as published by 7 : //# the Free Software Foundation; either version 2 of the License, or (at your 8 : //# option) any later version. 9 : //# 10 : //# This library is distributed in the hope that it will be useful, but WITHOUT 11 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 13 : //# License for more details. 14 : //# 15 : //# You should have received a copy of the GNU Library General Public License 16 : //# along with this library; if not, write to the Free Software Foundation, 17 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 18 : //# 19 : //# Correspondence concerning AIPS++ should be addressed as follows: 20 : //# Internet email: aips2-request@nrao.edu. 21 : //# Postal address: AIPS++ Project Office 22 : //# National Radio Astronomy Observatory 23 : //# 520 Edgemont Road 24 : //# Charlottesville, VA 22903-2475 USA 25 : //# 26 : //# 27 : //# $Id$ 28 : 29 : #ifndef SYNTHESIS_PTRANSPORT_H 30 : #define SYNTHESIS_PTRANSPORT_H 31 : 32 : //# Includes 33 : #include <casacore/casa/aips.h> 34 : #include <casacore/casa/Arrays/Array.h> 35 : #include <casacore/casa/BasicSL/Complex.h> 36 : #include <casacore/casa/BasicSL/String.h> 37 : #include <casacore/casa/Containers/Block.h> 38 : 39 : namespace casacore{ 40 : 41 : class Record; 42 : 43 : } 44 : 45 : namespace casa { //# NAMESPACE CASA - BEGIN 46 : 47 : // <summary> 48 : // Interface / Base class for parallel data transport models 49 : // </summary> 50 : 51 : // <use visibility=local> or <use visibility=export> 52 : 53 : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 54 : // </reviewed> 55 : 56 : // <prerequisite> 57 : // <li> SomeClass 58 : // <li> SomeOtherClass 59 : // <li> some concept 60 : // </prerequisite> 61 : // 62 : // <etymology> 63 : // </etymology> 64 : // 65 : // <synopsis> 66 : // </synopsis> 67 : // 68 : // <example> 69 : // </example> 70 : // 71 : // <motivation> 72 : // </motivation> 73 : // 74 : // 75 : //# <todo asof="yyyy/mm/dd"> 76 : //# <li> add this feature 77 : //# <li> fix this bug 78 : //# <li> start discussion of this possible extension 79 : //# </todo> 80 : 81 : 82 : class PTransport { 83 : public: 84 : // Default constructor and destructor 85 0 : PTransport() : numprocs(0), myCpu(0), aWorker(0), aTag(0) {}; 86 0 : virtual ~PTransport() {} 87 : 88 : // Return the number of processes 89 0 : casacore::Int numThreads() {return numprocs;}; 90 : 91 : // Return the current process rank 92 0 : casacore::Int cpu() {return myCpu;} 93 : 94 : // Set the properties of the current connection including 95 : // source/destination and message tag. 96 0 : casacore::Int connect(casacore::Int i) {aWorker=i; return i;} 97 0 : void connectAnySource() {aWorker=anySource(); return;}; 98 0 : void connectToController() {aWorker=controllerRank(); return;}; 99 0 : void setTag(casacore::Int tag) {aTag=tag; return;}; 100 0 : void setAnyTag() {aTag=anyTag(); return;}; 101 : 102 : // Status functions for worker/controller designation 103 0 : casacore::Bool isController() {return (cpu()==controllerRank());}; 104 0 : casacore::Bool isWorker() {return (cpu()!=controllerRank());}; 105 : 106 : // Default source and message tag values 107 : virtual casacore::Int anyTag() = 0; 108 : virtual casacore::Int anySource() = 0; 109 : 110 : // Define the rank of the controller process 111 : virtual casacore::Int controllerRank() = 0; 112 : 113 : // Get and put functions on the parallel data transport layer 114 : virtual casacore::Int put(const casacore::Array<casacore::Float> &) = 0; 115 : virtual casacore::Int put(const casacore::Array<casacore::Double> &) = 0; 116 : virtual casacore::Int put(const casacore::Array<casacore::Complex> &) = 0; 117 : virtual casacore::Int put(const casacore::Array<casacore::DComplex> &) = 0; 118 : virtual casacore::Int put(const casacore::Array<casacore::Int> &) = 0; 119 : virtual casacore::Int put(const casacore::Float &) = 0; 120 : virtual casacore::Int put(const casacore::Double &) = 0; 121 : virtual casacore::Int put(const casacore::Complex &) = 0; 122 : virtual casacore::Int put(const casacore::DComplex &) = 0; 123 : virtual casacore::Int put(const casacore::Int &) = 0; 124 : virtual casacore::Int put(const casacore::String &) = 0; 125 : virtual casacore::Int put(const casacore::Bool &) = 0; 126 : virtual casacore::Int put(const casacore::Record &) = 0; 127 : 128 : virtual casacore::Int get(casacore::Array<casacore::Float> &) = 0; 129 : virtual casacore::Int get(casacore::Array<casacore::Double> &) = 0; 130 : virtual casacore::Int get(casacore::Array<casacore::Complex> &) = 0; 131 : virtual casacore::Int get(casacore::Array<casacore::DComplex> &) = 0; 132 : virtual casacore::Int get(casacore::Array<casacore::Int> &) = 0; 133 : virtual casacore::Int get(casacore::Float &) = 0; 134 : virtual casacore::Int get(casacore::Double &) = 0; 135 : virtual casacore::Int get(casacore::Complex &) = 0; 136 : virtual casacore::Int get(casacore::DComplex &) = 0; 137 : virtual casacore::Int get(casacore::Int &) = 0; 138 : virtual casacore::Int get(casacore::String &) = 0; 139 : virtual casacore::Int get(casacore::Bool &) = 0; 140 : virtual casacore::Int get(casacore::Record &) = 0; 141 : //check if MPI layer has been finalized 142 : virtual casacore::Bool isFinalized()=0; 143 : protected: 144 : // Number of processes 145 : casacore::Int numprocs; 146 : 147 : // Rank of current process 148 : casacore::Int myCpu; 149 : 150 : // Current source or destination process 151 : casacore::Int aWorker; 152 : 153 : // Current message tag 154 : casacore::Int aTag; 155 : 156 : bool debug_p = false; 157 : }; 158 : 159 : } //# NAMESPACE CASA - END 160 : 161 : #endif 162 : 163 :