Commit 07185905 authored by snuverink_j's avatar snuverink_j
Browse files

Merge branch '451-unused-classes-in-opal' into 'master'

Resolve "Unused classes in OPAL"

Closes #451

See merge request !265
parents 28fe7987 1f5ba896
......@@ -4,7 +4,6 @@ set (_SRCS
set (_HDRS
AntiSymTenzor.h
AppTypeTraits.h
GenVektor.h
SymTenzor.h
Tenzor.h
TSVMetaAssign.h
......@@ -28,10 +27,9 @@ add_ippl_headers (${_HDRS})
install (FILES ${_HDRS} DESTINATION include/AppTypes)
# vi: set et ts=4 sw=4 sts=4:
# Local Variables:
# mode: cmake
# cmake-tab-width: 4
# indent-tabs-mode: nil
# End:
# End:
\ No newline at end of file
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
*
* Visit http://people.web.psi.ch/adelmann/ for more details
*
***************************************************************************/
//////////////////////////////////////////////////////////////////////
#ifndef GEN_VEKTOR_H
#define GEN_VEKTOR_H
//////////////////////////////////////////////////////////////////////
template<unsigned Dim, unsigned IDim>
class UnitComponentVektor
{
private:
// No actual data.
public:
// Allow access rather like a regular Vektor.
bool operator[](const unsigned int &d) const { return (d==IDim); }
};
//////////////////////////////////////////////////////////////////////
template<class T, unsigned Dim, unsigned IDim>
class ComponentVektor
{
private:
T Value;
public:
// Construct with or without a value.
ComponentVektor() {}
ComponentVektor(T value) : Value(value) {}
// Allow access rather like a regular Vektor.
T& operator[](const unsigned int &d) { return (d==IDim) ? Value : 0; }
T operator[](const unsigned int &d) const { return (d==IDim) ? Value : 0; }
};
//////////////////////////////////////////////////////////////////////
// Dot product of a UnitComponentVektor with a regular Vektor.
// The UnitComponentVektor just selects a value, no floating point ops.
// In the first two it takes in a Vektor& and returns a T&.
// That way this could be put on the left hand side like
// dot(vec,zhat) = 1.0;
template<class T, unsigned Dim, unsigned IDim>
inline
T& dot_ref(Vektor<T,Dim>& v, const UnitComponentVektor<Dim,IDim>&)
{
return v[IDim];
}
template<class T, unsigned Dim, unsigned IDim>
inline
T& dot_ref(const UnitComponentVektor<Dim,IDim>& , Vektor<T,Dim>& v)
{
return v[IDim];
}
// If the Vektor is const though, return by value so you
// can't assign to it.
template<class T, unsigned Dim, unsigned IDim>
inline
T dot(const Vektor<T,Dim>& v, const UnitComponentVektor<Dim,IDim>&)
{
return v[IDim];
}
template<class T, unsigned Dim, unsigned IDim>
inline
T dot(const UnitComponentVektor<Dim,IDim>& , const Vektor<T,Dim>& v)
{
return v[IDim];
}
//////////////////////////////////////////////////////////////////////
//
// These dot a regular Vektor with a ComponentVektor.
// They just do one multipply.
// The return by value of course.
//
template<class T, unsigned Dim, unsigned IDim>
inline
T dot(const Vektor<T,Dim>& v, const ComponentVektor<T,Dim,IDim>& c)
{
return v[IDim]*c[IDim];
}
template<class T, unsigned Dim, unsigned IDim>
inline
T dot(const ComponentVektor<T,Dim,IDim>& c, const Vektor<T,Dim>& v)
{
return v[IDim]*c[IDim];
}
#endif
/***************************************************************************
* $RCSfile: GenVektor.h,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:24 $
* IPPL_VERSION_ID: $Id: GenVektor.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $
***************************************************************************/
......@@ -39,7 +39,6 @@ set (_HDRS
FieldPrint.h
FieldPrint.hpp
Inform.h
IplCounter.h
IpplCounter.h
IpplException.h
IpplInfo.h
......@@ -53,8 +52,6 @@ set (_HDRS
ParticleDebug.hpp
ParticleDebugFunctions.h
RNGAssignDefs.h
RNGBitReverse.h
RNGLattice.h
RNGXDiv.h
RandomNumberGen.h
RefBlock.h
......
// -*- C++ -*-
/***************************************************************************
*
* The IPL Framework
*
*
* Visit http://people.web.psi.ch/adelmann/ for more details
*
***************************************************************************/
#ifndef IPL_COUNTER_H
#define IPL_COUNTER_H
/***************************************************************************
* IplCounter - a simple megaflops counter that accesses hardware counters
* for measureing megaflop performance.
*
* To use these counters:
* 1. Create a counter.
* example: Counter FFTcounter("FFT");
*
* 2. Locate the function which you would like to measure and start the
* counter by placing the startCounter() method before it. Then, stop
* the counter after it by using the stopCounter() method.
* example: FFTcounter.startCounter();
* fft->transform(....);
* FFTcounter.stopCounter();
*
* 3. Use the printIt() method to print to the screen.
* example: FFTcounter.printIt();
*
***************************************************************************/
// include files
#include "Utility/Inform.h"
#include
class IplCounter
{
public:
// constructor
IplCounter(const char *category);
// destructor
~IplCounter();
// counter operations
void startCounter();
void stopCounter();
void printIt();
private:
typedef long long CounterLong;
CounterLong totalcyc_m;
CounterLong totalinst_m;
CounterLong c0_m;
CounterLong c21_m;
int e0_m;
int e1_m;
int gen_start_m;
int gen_read_m;
std::string category_m;
Inform msg_m;
};
#endif
/***************************************************************************
* $RCSfile: IplCounter.h,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:33 $
***************************************************************************/
/***************************************************************************
* $RCSfile: addheaderfooter,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:17 $
* IPL_VERSION_ID: $Id: addheaderfooter,v 1.1.1.1 2003/01/23 07:40:17 adelmann Exp $
***************************************************************************/
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
*
* Visit http://people.web.psi.ch/adelmann/ for more details
*
***************************************************************************/
#ifndef RNG_BIT_REVERSE_H
#define RNG_BIT_REVERSE_H
/***********************************************************************
*
* class RNGBitReverse
* class RNGBitReverseSequence : public SequenceGen<RNGBitReverse>
*
* RNGBitReverse generates a set of values distributed over some domain
* based on a bit-reversal algorithm. These numbers will be uniformly
* distributed over the [0...1] domain. It requires the following
* parameters and values:
*
* base - used in bit reversal calculation; must be a prime number
* seed - a starting unsigned integer, which is incremented as new values
* are calculated. If not specified, it defaults to 1 initially.
* It is incremented after each calculation.
*
* RNGBitReverseSequence is derived from SequenceGen, and makes it easier
* to use this RNG in expressions.
* Use RNGBitReverse as a scalar or container element, and use
* RNGBitReverseSequence when you need a sequence of numbers to fill
* a container.
*
***********************************************************************/
// include files
#include "Utility/SequenceGen.h"
class RNGBitReverse {
public:
// return type
typedef double Return_t;
public:
// default constructor
RNGBitReverse(unsigned int base = 2, unsigned long seed = 1)
: Base(base), Seed(seed) {}
// copy constructor
RNGBitReverse(const RNGBitReverse& brg)
: Base(brg.Base), Seed(brg.Seed) {}
// destructor
~RNGBitReverse(void) {}
// advance seed for RNG n times
inline void AdvanceSeed(unsigned long n = 0) { Seed += n; }
// set seed to specified value
inline void SetSeed(unsigned long seed) { Seed = seed; }
// set base to specified value (should be a prime number!)
inline void SetBase(unsigned int base) { Base = base; }
// get seed value
inline unsigned long GetSeed(void) const { return Seed; }
// get base value
inline unsigned int GetBase(void) const { return Base; }
// get the next random number in sequence
inline Return_t GetRandom(void) const {
Return_t rev = 0.0;
Return_t power = 1.0;
long inum = Seed;
while (inum > 0) {
int iquot = inum/Base;
int irem = inum - iquot*Base;
power /= Return_t(Base);
rev += Return_t(irem)*power;
inum = iquot;
}
Seed++;
return rev;
}
// pseudonym for GetRandom()
inline Return_t operator()(void) const { return GetRandom(); }
// conversion to Return_t, same as GetRandom()
inline operator Return_t() const { return GetRandom(); }
private:
// the base and seed for this generator
unsigned int Base;
mutable unsigned long Seed;
};
RNG_BASIC_MATH(RNGBitReverse)
// A version of SequenceGen with extra constructors to make using this
// class easier. This is the version that people should use to fill
// containers with a random number sequence in an expression. This
// class is PETE-aware via its inheritance from SequenceGen.
class RNGBitReverseSequence : public SequenceGen<RNGBitReverse> {
public:
// default constructor
RNGBitReverseSequence(unsigned int base = 2, unsigned long seed = 1)
: SequenceGen<RNGBitReverse>(RNGBitReverse(base,seed)) {}
// copy constructor
RNGBitReverseSequence(const RNGBitReverseSequence& rngseq)
: SequenceGen<RNGBitReverse>(rngseq.getGenerator()) {}
// destructor
~RNGBitReverseSequence(void) {}
// wrappers around RNG generator functions
inline void AdvanceSeed(unsigned long adv = 0) {
getGenerator().AdvanceSeed(adv);
}
inline void SetSeed(unsigned long seed) { getGenerator().SetSeed(seed); }
inline void SetBase(unsigned int base) { getGenerator().SetBase(base); }
inline unsigned long GetSeed(void) const { return getGenerator().GetSeed(); }
inline unsigned int GetBase(void) const { return getGenerator().GetBase(); }
inline Return_t GetRandom(void) { return getGenerator().GetRandom(); }
inline Return_t operator()(void) { return getGenerator().GetRandom(); }
};
#endif // RNG_BIT_REVERSE_H
/***************************************************************************
* $RCSfile: RNGBitReverse.h,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:33 $
* IPPL_VERSION_ID: $Id: RNGBitReverse.h,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $
***************************************************************************/
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
***************************************************************************/
#ifndef RNG_LATTICE_H
#define RNG_LATTICE_H
/***********************************************************************
*
* class RNGLattice
* class RNGLatticeSequence : public SequenceGen<RNGLattice>
*
* Lattice class that implements random number generator by just
* providing an evenly spaced set of points between two endpoints.
*
* Note that this only works properly automatically on 1 PE; with multipple PE's
* you'll get a redundant set of points, the same on every PE, unless you take
* care to provide appropriate different seeds for each PE and call SetSeed
* before using it.
* Use RNGLattice as a scalar or container element, and use
* RNGLatticeSequence when you need a sequence of numbers to fill a container.
*
***********************************************************************/
#include "Utility/SequenceGen.h"
template<class T>
class RNGLattice {
public:
// return type
typedef T Return_t;
// constructor
RNGLattice(T minval, T maxval, unsigned long numpoints,
bool includeEndpoints = true)
: MinVal(minval), MaxVal(maxval), CurrPoint(0), NumPoints(numpoints),
IncludeEndpoints(includeEndpoints)
{
if (IncludeEndpoints) {
if (NumPoints == 0 || NumPoints == 1) {
Spacing = 0;
}
else {
Spacing = (MaxVal - MinVal)/(NumPoints - 1);
}
}
else {
if (NumPoints == 0) {
Spacing = 0;
}
else {
Spacing = (MaxVal - MinVal)/NumPoints;
}
}
}
// copy constructor
RNGLattice(const RNGLattice<T>& rng)
: MinVal(rng.MinVal), MaxVal(rng.MaxVal), CurrPoint(rng.CurrPoint),
Spacing(rng.Spacing), NumPoints(rng.NumPoints),
IncludeEndpoints(rng.IncludeEndpoints) {}
// destructor
~RNGLattice(void) {}
// advance current point by n, modulo NumPoints
inline void AdvanceSeed(unsigned long n = 0) {
CurrPoint = (CurrPoint + n) % NumPoints;
return;
}
// set current point to nth point, modulo NumPoints
inline void SetSeed(unsigned long n = 0) {
CurrPoint = n % NumPoints;
}
// get current point
inline unsigned long GetSeed(void) const { return CurrPoint; }
// return the next pseudo-random number (from MinVal ... MaxVal)
inline Return_t GetRandom(void) const {
Return_t currVal;
if (IncludeEndpoints)
currVal = MinVal + CurrPoint * Spacing;
else
currVal = MinVal + (CurrPoint + 0.5) * Spacing;
CurrPoint++;
if (CurrPoint == NumPoints) CurrPoint = 0;
return currVal;
}
// pseudonym for GetRandom()
inline Return_t operator()(void) const { return GetRandom(); }
// conversion to Return_t, same as GetRandom()
inline operator Return_t() const { return GetRandom(); }
// return the period of the RNG
unsigned long GetRandMax(void) const { return NumPoints; }
private:
T MinVal, MaxVal, Spacing;
mutable unsigned long CurrPoint;
unsigned long NumPoints;
bool IncludeEndpoints;
};
RNG_BASIC_MATH(RNGLattice<double>)
// A version of RNGLattice with extra constructors to make using this
// class easier. This is the version that people should use to fill
// containers with a random number sequence in an expression. This
// class is PETE-aware via its inheritance from SequenceGen.
template<class T>
class RNGLatticeSequence : public SequenceGen< RNGLattice<T> > {
public:
// constructor
RNGLatticeSequence(T minval, T maxval, unsigned long numpoints,
bool includeEndpoints = true)
: SequenceGen< RNGLattice<T> >(RNGLattice<T>(minval,maxval,numpoints,
includeEndpoints)) {}
// copy constructor
RNGLatticeSequence(const RNGLatticeSequence<T>& rngseq)
: SequenceGen< RNGLattice<T> >(rngseq.getGenerator()) {}
// destructor
~RNGLatticeSequence(void) {}
// wrappers around RNG generator functions
inline void AdvanceSeed(unsigned long adv = 0) {
this->getGenerator().AdvanceSeed(adv);
}
inline void SetSeed(unsigned long seed) { this->getGenerator().SetSeed(seed); }
inline unsigned long GetSeed(void) const { return this->getGenerator().GetSeed(); }
inline
typename RNGLattice<T>::Return_t
GetRandom(void) { return this->getGenerator().GetRandom(); }
inline
typename RNGLattice<T>::Return_t
operator()(void) { return this->getGenerator().GetRandom(); }
unsigned long GetRandMax(void) const { return this->getGenerator().GetRandMax(); }
};
#endif // RNG_LATTICE_H
......@@ -43,7 +43,6 @@
#include "Particle/ParticleSpatialLayout.h"
#include "Particle/IpplParticleBase.h"
#include "Particle/PAssign.h"
#include "Utility/RNGLattice.h"
#include "Utility/ParticleDebug.h"
#include "Utility/FieldDebug.h"
......
#ifndef __GEOMETRIC_STRATEGY_H__
#define __GEOMETRIC_STRATEGY_H__
#include <set>
#include <vector>
#include "Comm/Splitter/SplitStrategy.h"
typedef std::vector<int> coordinates_t;
typedef struct {
coordinates_t extensions;
coordinates_t origin;
MPI_Comm comm;
int master_pid;
std::vector<int> worker_pids;
} region_t;
/**
* The geometric strategy partitions the network graph in num_masters equally
* sized regions and then places a master at the centroid of each region.
* Workers inside a region are assigned to the master at its centroid.
*/
class GeometricStrategy : protected SplitStrategy {
public:
GeometricStrategy(size_t num_masters,
boost::shared_ptr<CommTopology> topology, MPI_Comm comm)
: Strategy(num_masters, topology, comm)
{}
virtual ~GeometricStrategy()
{}
void split() {
// 1. Initialize the region list with the initial topology
region_t initial_region;
for(int dim=0; dim < topology_.getNumDimensions(); dim++) {
initial_region.origin.push_back(0);
initial_region.extensions.push_back(dims_[dim]);
}
regions_.push_back(initial_region);
// 2. Build num_masters_ partitions of the topology
while(regions_.size() < num_masters_) {
splitInLargestDim();
}
// 3. Compute centroids of partition and assign master
for(region_t & region : regions_) {
computeCentroid(region);
}
// 4. Create communicator groups
for(region_t & region : regions_) {
bool is_worker = false;
coordinates_t iter = region.origin;
for(int x = 0; x < region.extensions[0]; x++) {
iter[0] = region.origin[0] + x;
for(int y = 0; y < region.extensions[1]; y++) {
iter[1] = region.origin[1] + y;
for(int z = 0; z < region.extensions[2]; z++) {
iter[2] = region.origin[2] + z;
std::vector<int> worker_pids;
coordinatesToPID(iter, worker_pids);
if(worker_pids[0] != region.master_pid)
region.worker_pids.push_back(worker_pids