src/IplPaws/DLRepresentation.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://www.acl.lanl.gov/POOMS for more details
00023  *
00024  ***************************************************************************/
00025 
00026 #include <iostream.h>
00027 #include "IpplPaws/DLRepresentation.h"
00028 
00029 
00031 //
00032 // Default DLRepresentation constructor.
00033 //
00035 
00036 template<class D, unsigned Dim>
00037 DLRepresentation<D,Dim>::DLRepresentation()
00038 {
00039   static char* id = "DLRepresentation::DLRepresentation()";
00040   PDebug(PAWSD_APP, ("%s entering\n", id));
00041   PDebug(PAWSD_APP, ("%s exiting\n", id));
00042 }
00043 
00044 
00046 //
00047 // Construct a DLRepresentation given a FieldLayout
00048 // Divide into Global and LocalBlocks
00049 //
00051 
00052 template<class D, unsigned Dim>
00053 DLRepresentation<D,Dim>::DLRepresentation(FieldLayout<Dim> &layout)
00054 {
00055   static char* id = "DLRepresentation::DLRepresentation(FieldLayout)";
00056   PDebug(PAWSD_APP, ("%s entering\n", id));
00057 
00058   update(layout);
00059 
00060   PDebug(PAWSD_APP, ("%s exiting\n", id));
00061 }
00062 
00063 
00065 //
00066 // Update the DLRepresentation with a new FieldLayout and num_nodes
00067 // This routine is called when a PawsRemoteData is created with an
00068 // empty, dynamic array.  We want it to match the local domain, but
00069 // to have the global blocks calculated using the number of processors
00070 // on the remote machine
00071 //
00073 template<class D, unsigned Dim>
00074 void
00075 DLRepresentation<D,Dim>::update(FieldLayout<Dim> &layout)
00076 {
00077   static char* id = "DLRepresentation::update(FieldLayout)";
00078   PDebug(PAWSD_APP, ("%s entering\n", id));
00079 
00080   // Clear out the current representation and add the new
00081   clearLocal();
00082   clearGlobal();
00083 
00084   setStorageOrder(PAWS_COLUMN);
00085   int total_nodes = Ippl::getNodes();
00086   int node_rank = Ippl::myNode();
00087   int i;
00088 
00089   // Number the blocks when building the representation
00090   // Used to assign the block number of the LField within the structure
00091   //
00092   int *block_num = new int[total_nodes];
00093   for (i = 0; i < total_nodes; i++)
00094     block_num[i] = 0;
00095 
00096   // Get the whole domain
00097   //
00098   int first[Dim];
00099   int last[Dim];
00100   int stride[Dim];
00101   const D &whole_domain = layout.getDomain();
00102   for (i = 0; i < Dim; i++) {
00103     first[i] = whole_domain[i].first();
00104     last[i] = whole_domain[i].last();
00105     stride[i] = whole_domain[i].stride();
00106   }
00107   initialize(Dim, first, last, stride, node_rank);
00108 
00109   // Iterate through the FieldLayout to copy out the local part
00110   // Iterator returns vmap with second element being a vnode having a domain
00111   //
00112   int bnum = 0;
00113   FieldLayout<Dim>::iterator_iv loc;
00114   for (loc = layout.begin_iv(); loc != layout.end_iv(); ++loc) {
00115 
00116     // Store the local block within the DLRepresentation
00117     const D &local_domain = (*loc).second->getDomain();
00118     for (i = 0; i < Dim; i++) {
00119       first[i] = local_domain[i].first();
00120       last[i] = local_domain[i].last();
00121       stride[i] = local_domain[i].stride();
00122     }
00123     insertLocal(Dim, first, last, stride, bnum++, node_rank);
00124   }
00125 
00126   // Iterate through the FieldLayout to copy out the remote part
00127   // Iterator returns actual vnodes
00128   //
00129   FieldLayout<Dim>::iterator_dv rem;
00130   for (rem = layout.begin_rdv(); rem != layout.end_rdv(); ++rem) {
00131 
00132     // Store the global block within the DLRepresentation
00133     int node = (*rem).second->getNode();
00134     const D &global_domain = (*rem).first;
00135     for (i = 0; i < Dim; i++) {
00136       first[i] = global_domain[i].first();
00137       last[i] = global_domain[i].last();
00138       stride[i] = global_domain[i].stride();
00139     }
00140     insertGlobal(Dim, first, last, stride, block_num[node]++, node);
00141   }
00142 
00143   delete [] block_num;
00144   PDebug(PAWSD_APP, ("%s exiting\n", id));
00145 }
00146 
00147 
00148 /***************************************************************************
00149  * $RCSfile: DLRepresentation.cpp,v $   $Author: adelmann $
00150  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:32 $
00151  * IPPL_VERSION_ID: $Id: DLRepresentation.cpp,v 1.1.1.1 2003/01/23 07:40:32 adelmann Exp $ 
00152  ***************************************************************************/
00153 

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