src/IplPaws/PawsFieldData.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 // ACL:license
00018 // ----------------------------------------------------------------------
00019 // This software and ancillary information (herein called "SOFTWARE")
00020 // called PAWS (Parallel Application WorkSpace) is made available under
00021 // display this SOFTWARE without charge, provided that this Notice and
00022 // any statement of authorship are reproduced on all copies.  Neither the
00023 // Government nor the University makes any warranty, express or implied,
00024 // or assumes any liability or responsibility for the use of this
00025 // SOFTWARE.
00026 // 
00027 // If SOFTWARE is modified to produce derivative works, such modified
00028 // SOFTWARE should be clearly marked, so as not to confuse it with the
00029 // version available from LANL.
00030 // 
00031 // For more information about PAWS, send e-mail to paws@acl.lanl.gov,
00032 // or visit the PAWS web page at http://www.acl.lanl.gov/paws/.
00033 // ----------------------------------------------------------------------
00034 // ACL:license
00035 
00036 #include "IpplPaws/PawsFieldData.h"
00037 
00038 //
00039 // Construct an empty PawsFieldData which will be filled dynamically
00040 // when the size is determined
00041 //
00042 template <class T, unsigned Dim, class M, class C>
00043 PawsFieldData<T,Dim,M,C>::PawsFieldData(const char* name, int io_mode,
00044                         int sync_mode, int order_mode, PawsApplication& app)
00045                         : PawsGeneralData<Repr,Desc>() 
00046 {
00047     initialize(name, io_mode, sync_mode, order_mode, app);
00048 }
00049 
00050 
00051 //
00052 // Construct a PawsFieldData given an existing Field_t* distributed by Ippl
00053 // Creates the necessary representation, descriptor, and PawsData
00054 //
00055 template <class T, unsigned Dim, class M, class C>
00056 PawsFieldData<T,Dim,M,C>::PawsFieldData(const char* name, Field_t* ptr,
00057                                 int io_mode, int sync_mode, int order_mode,
00058                                 PawsApplication& app)
00059                                 : PawsGeneralData<Repr,Desc>() 
00060 {
00061     initialize(name, ptr, 
00062                 io_mode, sync_mode, order_mode, app);
00063 }
00064 
00065 
00066 //
00067 // Initialization a dynamic PawsFIeldData, data structures are created
00068 // but are not filled with useable information
00069 //
00070 template <class T, unsigned Dim, class M, class C>
00071 void
00072 PawsFieldData<T,Dim,M,C>::initialize(const char* name, int io_mode,
00073                 int sync_mode, int order_mode, PawsApplication& app)
00074 {
00075     static char* id = "PawsFieldData::initialize(DYNAMIC)";
00076     PDebug(PAWSD_ARR, ("%s entering\n", id));
00077 
00078     // Check for valid arguments and that we're not already initialized
00079     //
00080     PAssert(data_app == PAWS_NULL);
00081     int valid = true;
00082     if ((io_mode != PAWS_IN) && (io_mode != PAWS_OUT) &&
00083         (io_mode != PAWS_INOUT)) {
00084         PDebug(PAWSD_ERR, ("ERROR: I/O mode flag is not valid\n"));
00085         valid = false;
00086     }
00087     if ((sync_mode != PAWS_SYNC) && (sync_mode != PAWS_ASYNC) &&
00088         (sync_mode != PAWS_PSYNC)) {
00089         PDebug(PAWSD_ERR, ("ERROR: Synchronization mode flag is not valid\n"));
00090         valid = false;
00091     }
00092     if ((order_mode != PAWS_ROW) && (order_mode != PAWS_COLUMN)) {
00093         PDebug(PAWSD_ERR, ("ERROR: Order mode flag is not valid\n"));
00094         valid = false;
00095     }
00096     if (valid == false) {
00097         PInsist(false, "ERROR: Bad arguments for constructing PawsArray");
00098     }
00099 
00100     // Set values in the base class PawsDomainData
00101     data_name = name;
00102     data_app = &app;
00103 
00104     // Construct the representation, descriptor and PawsData
00105     //
00106     data_rep = new Repr(); 
00107     data_desc = new Desc(*data_rep); 
00108     paws_data = new PawsData_t(*data_rep, *data_desc, name, io_mode, sync_mode,
00109                       PAWS_PARALLEL, dataType(), "ARRAY( Field<T,Dim,M,C> )",
00110                       "IPPL", app);
00111 
00112     // Indicate that this representation has not been initialized with size
00113     paws_data->updateFlag(PAWS_OFF);
00114 
00115     // Add this object to the list maintained by the PawsApplication
00116     app.addDomainData(this);
00117 }
00118 
00119 
00120 //
00121 // Initialization a sized PawsFieldData, data structures are created
00122 // and filled with sized representations and pointers to data
00123 //
00124 template <class T, unsigned Dim, class M, class C>
00125 void
00126 PawsFieldData<T,Dim,M,C>::initialize(const char* name, Field_t* ptr, 
00127                         int io_mode, int sync_mode, int order_mode,
00128                         PawsApplication& app)
00129 {
00130     static char* id = "PawsFieldData::initialize(SIZE)";
00131     PDebug(PAWSD_ARR, ("%s entering\n", id));
00132 
00133     // Check for valid arguments and that we aren't already initialized
00134     //
00135     PAssert(data_app == PAWS_NULL);
00136     int valid = true;
00137     if ((io_mode != PAWS_IN) && (io_mode != PAWS_OUT) &&
00138         (io_mode != PAWS_INOUT)) {
00139         PDebug(PAWSD_ERR, ("ERROR: I/O mode flag is not valid\n"));
00140         valid = false;
00141     }
00142     if ((sync_mode != PAWS_SYNC) && (sync_mode != PAWS_ASYNC) &&
00143         (sync_mode != PAWS_PSYNC)) {
00144         PDebug(PAWSD_ERR, ("ERROR: Synchronization mode flag is not valid\n"));
00145         valid = false;
00146     }
00147     if ((order_mode != PAWS_ROW) && (order_mode != PAWS_COLUMN)) {
00148         PDebug(PAWSD_ERR, ("ERROR: Order mode flag is not valid\n"));
00149         valid = false;
00150     }
00151     if (valid == false) {
00152         PInsist(false, "ERROR: Bad arguments for constructing PawsArray");
00153     }
00154 
00155     // Set values in the base class PawsDomainData
00156     data_name = name;
00157     data_app = &app;
00158 
00159     // Construct the representation, descriptor and PawsData
00160     //
00161     data_rep = new Repr(ptr->getLayout());
00162     data_desc = new Desc(*data_rep, ptr);
00163     PString size_str, desc;
00164     data_rep->sizeString(size_str);
00165     desc = "ARRAY(size=" + size_str + ")";
00166     paws_data = new PawsData_t
00167                        (*data_rep, *data_desc, name, io_mode, sync_mode,
00168                        PAWS_PARALLEL, dataType(), desc.c_str(), "PAWS", app);
00169 
00170     // Indicate that this Representation has been sized
00171     paws_data->updateFlag(PAWS_ON);
00172 
00173     // Add this object to the list maintained by the PawsApplication
00174     app.addDomainData(this);
00175 
00176     PDebug(PAWSD_ARR, ("%s exiting\n", id));
00177 }
00178 
00179 
00180 // Calculates a new schedule
00181 // Reports new local representation to master for sending to other applications
00182 //
00183 template <class T, unsigned Dim, class M, class C>
00184 void
00185 PawsFieldData<T,Dim,M,C>::update(Field_t* ptr)
00186 {
00187     static char* id = "PawsFieldData::update(USERDIST)";
00188     PAssert(data_app != PAWS_NULL);
00189 
00190     // Build a new layout
00191     // Update the DLRepresentation, DLDescriptor, PawsData
00192     // build new schedules, and send message to remotes
00193     //
00194     data_rep->update(ptr->getLayout());
00195     data_desc->update(*data_rep, ptr);
00196     paws_data->updateFlag(PAWS_ON);
00197 
00198     // Build a local schedule for the updated data
00199     paws_data->updateLocalData();
00200 
00201     // Send message to remote data master with new representation
00202     data_app->updateData(paws_data);
00203     PDebug(PAWSD_ARR, ("%s exiting\n", id));
00204 }
00205 
00206 
00207 //
00208 // Updates the current representation and descriptor with a new layout
00209 // DOES NOT calculate a new schedule, because it expects a returning update
00210 // Reports new local representation to master for sending to other applications
00211 //
00212 template <class T, unsigned Dim, class M, class C>
00213 void
00214 PawsFieldData<T,Dim,M,C>::resize(Field_t* ptr)
00215 {
00216     static char* id = "PawsFieldData::resize(USERDIST)";
00217     PAssert(data_app != PAWS_NULL);
00218 
00219     // Build a new layout
00220     // Update the DLRepresentation, DLDescriptor, PawsData
00221     // build new schedules, and send message to remotes
00222     //
00223     data_rep->update(ptr->getLayout());
00224     data_desc->update(*data_rep, ptr);
00225     paws_data->updateFlag(PAWS_ON);
00226 
00227     // Current schedule is no longer valid
00228     paws_data->scheduleDoneOff();
00229 
00230     // Send message to remote data master with new representation
00231     data_app->updateData(paws_data);
00232     PDebug(PAWSD_ARR, ("%s exiting\n", id));
00233 }
00234 
00235 
00236 //
00237 // Sum a PawsArray
00238 //
00239 template <class T, unsigned Dim, class M, class C>
00240 T
00241 sum(const PawsFieldData<T,Dim,M,C>& data)
00242 {
00243     return data.sum();
00244 }
00245 
00246 
00247 // ACL:rcsinfo
00248 // ----------------------------------------------------------------------
00249 // $RCSfile: PawsFieldData.cpp,v $   $Author: adelmann $
00250 // $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:32 $
00251 // ----------------------------------------------------------------------
00252 // ACL:rcsinfo
00253 
00254 /***************************************************************************
00255  * $RCSfile: addheaderfooter,v $   $Author: adelmann $
00256  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:17 $
00257  * IPPL_VERSION_ID: $Id: addheaderfooter,v 1.1.1.1 2003/01/23 07:40:17 adelmann Exp $ 
00258  ***************************************************************************/
00259 

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