Patch: ABCTest: Complete Revision
Jeffrey Oldham
oldham at codesourcery.com
Fri Oct 12 23:27:15 UTC 2001
2001-10-12 Jeffrey D. Oldham <oldham at codesourcery.com>
Revise ABC, adding more implementations, and ensuring that all the
computations are the same. I used Doof2d code as a model so any
mistakes there are likely to be replicated here.
These files were almost completely revised:
* ABC.cpp
* ABC.h
* ABCInC.c
* ABCInC.h
even though 'diff' may be able to find a few matching lines.
Tested on sequential Linux using g++3.1 by running the tests
Approved by Stephen Smith
Applied to mainline
Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
? LINUXgcc
? ABC.12Oct.16.4.patch
? ABC.12Oct.13.5.ChangeLog
Index: ABC.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/benchmarks/ABCTest/ABC.cpp,v
retrieving revision 1.8
diff -c -p -r1.8 ABC.cpp
*** ABC.cpp 2000/04/13 19:56:31 1.8
--- ABC.cpp 2001/10/12 23:25:19
***************
*** 31,58 ****
// Include files
#include "ABC.h"
//-----------------------------------------------------------------------------
// Main program.
//-----------------------------------------------------------------------------
int main(int argc, char* argv[])
{
! Pooma::initialize(argc, argv);
Benchmark abc(argc, argv);
! abc.setSamplingParameters(100,0,1);
! abc.addImplementation(new ABCInC);
! abc.addImplementation(new ABCInCppTran<Brick, false>);
! abc.addImplementation(new ABCInP2<Brick, false>);
! abc.addImplementation(new ABCInP2<CompressibleBrick, false>);
! abc.addImplementation(new ABCInP2<Brick, true>(abc.numPatches()));
! abc.addImplementation(new ABCInP2<CompressibleBrick, true>(abc.numPatches()));
! abc.run();
Pooma::finalize();
return 0;
--- 31,129 ----
// Include files
+ #include "Pooma/Pooma.h"
#include "ABC.h"
+ #include "ABCInC.h"
+ #if POOMA_CHEETAH
+ typedef Remote<Brick> BrickTag_t;
+ typedef Remote<CompressibleBrick> CompressibleBrickTag_t;
+ #else
+ typedef Brick BrickTag_t;
+ typedef CompressibleBrick CompressibleBrickTag_t;
+ #endif
+
//-----------------------------------------------------------------------------
// Main program.
//-----------------------------------------------------------------------------
int main(int argc, char* argv[])
{
! Pooma::initialize(argc, argv);
Benchmark abc(argc, argv);
! typedef Array<2, double, BrickTag_t>
! BrickStore_t;
! typedef Array<2, double, CompressibleBrickTag_t>
! CompBrickStore_t;
! typedef Array<2, double, MultiPatch<UniformTag, BrickTag_t> >
! MPBrickStore_t;
! typedef Array<2, double, MultiPatch<UniformTag, CompressibleBrickTag_t> >
! MPCompBrickStore_t;
!
! typedef Field<UniformRectilinearMesh<2>, double, BrickTag_t>
! FBrickStore_t;
! typedef Field<UniformRectilinearMesh<2>, double, CompressibleBrickTag_t>
! FCompBrickStore_t;
! typedef Field<UniformRectilinearMesh<2>, double,
! MultiPatch<UniformTag, BrickTag_t> >
! FMPBrickStore_t;
! typedef Field<UniformRectilinearMesh<2>, double,
! MultiPatch<UniformTag, CompressibleBrickTag_t> >
! FMPCompBrickStore_t;
!
! // C versions
! #if !POOMA_NO_RESTRICT
! abc.addImplementation(new AbcInC<true>());
! #endif
! abc.addImplementation(new AbcInC<false>());
!
! // CppTran version Brick
! abc.addImplementation(new AbcCppTran<BrickStore_t>);
!
! // Brick single patch
! abc.addImplementation(new AbcP2<BrickStore_t>);
!
! // Compressible Brick single patch
! abc.addImplementation(new AbcP2<CompBrickStore_t>);
!
! // Brick multi-patch no guards
! abc.addImplementation(new AbcP2<MPBrickStore_t>(abc.numPatches()));
!
! // Brick multi-patch with 1 guard layer
! abc.addImplementation(new AbcP2<MPBrickStore_t>(abc.numPatches(),1));
!
! // Compressible brick multi-patch no guard layers
! abc.addImplementation(new AbcP2<MPCompBrickStore_t>(abc.numPatches()));
!
! // Compressible brick multi-patch with 1 guard layer
! abc.addImplementation(new AbcP2<MPCompBrickStore_t>(abc.numPatches(),1));
!
! // Field CppTran version Brick
! abc.addImplementation(new AbcCppTran<FBrickStore_t>);
!
! // Field Brick single patch
! abc.addImplementation(new AbcP2<FBrickStore_t>);
!
! // Field Compressible Brick single patch
! abc.addImplementation(new AbcP2<FCompBrickStore_t>);
!
! // Field Brick multi-patch no guards
! abc.addImplementation(new AbcP2<FMPBrickStore_t>(abc.numPatches()));
! // Field Brick multi-patch with 1 guard layer
! abc.addImplementation(new AbcP2<FMPBrickStore_t>(abc.numPatches(),1));
!
! // Field Compressible brick multi-patch no guard layers
! abc.addImplementation(new AbcP2<FMPCompBrickStore_t>(abc.numPatches()));
+ // Field Compressible brick multi-patch with 1 guard layer
+ abc.addImplementation(new AbcP2<FMPCompBrickStore_t>(abc.numPatches(),1));
+
+ abc.setSamplingParameters(100,0,1);
+ abc.run();
+
Pooma::finalize();
return 0;
*************** int main(int argc, char* argv[])
*** 60,66 ****
// ACL:rcsinfo
// ----------------------------------------------------------------------
! // $RCSfile: ABC.cpp,v $ $Author: julianc $
! // $Revision: 1.8 $ $Date: 2000/04/13 19:56:31 $
// ----------------------------------------------------------------------
// ACL:rcsinfo
--- 131,137 ----
// ACL:rcsinfo
// ----------------------------------------------------------------------
! // $RCSfile: ABC.cpp,v $ $Author: oldham $
! // $Revision: 1.20 $ $Date: 2001/09/28 03:41:36 $
// ----------------------------------------------------------------------
// ACL:rcsinfo
Index: ABC.h
===================================================================
RCS file: /home/pooma/Repository/r2/benchmarks/ABCTest/ABC.h,v
retrieving revision 1.29
diff -c -p -r1.29 ABC.h
*** ABC.h 2000/06/30 01:56:15 1.29
--- ABC.h 2001/10/12 23:25:19
***************
*** 25,231 ****
// or visit the POOMA web page at http://www.acl.lanl.gov/pooma/.
// ----------------------------------------------------------------------
// ACL:license
//-----------------------------------------------------------------------------
! // Classes ABCTestBase, ABCInCppTran, ABCInP2.
//-----------------------------------------------------------------------------
! #ifndef POOMA_BENCHMARKS_ABCTEST_ABC_H
! #define POOMA_BENCHMARKS_ABCTEST_ABC_H
// Include files
#include "Pooma/Arrays.h"
#include "Utilities/Benchmark.h"
! #include <stdlib.h>
#include <typeinfo>
!
! // Function declarations
!
! extern "C" {
! void runABCInC(double *a, double *b, double *c, int n);
! }
//-----------------------------------------------------------------------------
! // ABCTestBase class definitions. We define this as a partially specialized
! // class so it is easy to make subclasses work for UMP or not.
//-----------------------------------------------------------------------------
! // General version.
! template<class EngineTag, bool UMP>
! class ABCTestBase { };
! // Non-UMP version.
! template<class EngineTag>
! class ABCTestBase<EngineTag, false> : public Implementation {
! public:
! // Dummy constructor.
!
! ABCTestBase(int xxx = 1) { }
!
! // Typedefs for the Array types we'll be using here.
! typedef Array<2,double,EngineTag> Array2D;
! // Initialize function gets the size and adjusts the arrays.
!
! void initialize(int n)
! {
! // Save the problem size.
!
! n_m = n;
! // Get new array domain.
!
! Interval<1> N(1, n_m);
! Interval<2> newDomain(N, N);
! // Resize the arrays.
! a_m.initialize(newDomain);
! b_m.initialize(newDomain);
! c_m.initialize(newDomain);
! // Intialize Array element values.
!
! setInitialConditions();
! }
!
! // To set up the run, we simply need to update c.
!
! void runSetup()
! {
! c_m = 1000.0;
! Pooma::blockAndEvaluate();
}
-
- // Return references to arrays.
-
- Array2D &aRef() { return a_m; }
- Array2D &bRef() { return b_m; }
- Array2D &cRef() { return c_m; }
-
- // Return value for checking result of benchmark run.
! double resultCheck() const { return check_m; }
! // Return number of flops in this kernel.
! double opCount() const { return (40 * (double)n_m * (double)n_m); }
! protected:
! // 2D data arrays.
! Array2D a_m, b_m, c_m;
! // Problem check value.
! double check_m;
! // Problem size.
! int n_m;
! private:
! void setInitialConditions()
{
! // Initialize arrays.
! bRef() = 1.0;
! Pooma::blockAndEvaluate();
! }
! };
! // UMP version.
! template<class EngineTag>
! class ABCTestBase<EngineTag, true> : public Implementation {
! public:
! // Typedefs for the Array types we'll be using here.
! typedef Array<2,double, MultiPatch<UniformTag,EngineTag> > Array2D;
! // Constructor allows us to specify the number of patches in each direction.
!
! ABCTestBase(int np = 1)
! : np_m(np), layout_m(NULL), a_m(NULL), b_m(NULL), c_m(NULL)
! { }
!
! // Destructor deletes pointers.
!
! ~ABCTestBase()
! {
! delete a_m;
! delete b_m;
! delete c_m;
! delete layout_m;
! }
! // Return references to arrays.
!
! Array2D &aRef() { return *a_m; }
! Array2D &bRef() { return *b_m; }
! Array2D &cRef() { return *c_m; }
!
! // Initialize function gets the size and adjusts the arrays.
!
! void initialize(int n)
{
! // Save the problem size. We need to make sure we have evenly sized blocks.
- n_m = (n / np_m) * np_m;
-
- // Delete old pointers.
-
- delete a_m;
- delete b_m;
- delete c_m;
- delete layout_m;
-
// Get new array domain.
! Interval<1> N(1, n_m);
Interval<2> newDomain(N, N);
// Create the block sizes.
! Loc<2> blocks(np_m, np_m);
! // Create the partitioner.
!
! UniformGridPartition<2> partition(blocks);
!
// Create the layout.
! layout_m = new UniformGridLayout<2>(newDomain, partition, ReplicatedTag());
! // Create the arrays.
!
! a_m = new Array2D(*layout_m);
! b_m = new Array2D(*layout_m);
! c_m = new Array2D(*layout_m);
! // Intialize Array element values.
!
! setInitialConditions();
}
! // To set up the run, we simply need to update c.
! void runSetup()
{
! *c_m = 1000.0;
! Pooma::blockAndEvaluate();
}
// Return value for checking result of benchmark run.
--- 25,292 ----
// or visit the POOMA web page at http://www.acl.lanl.gov/pooma/.
// ----------------------------------------------------------------------
// ACL:license
+
//-----------------------------------------------------------------------------
! // Classes AbcCppTran, AbcP2, AbcNinePt, AbcOpt
! // Implementation Classes AbcStorage, AbcBase,
//-----------------------------------------------------------------------------
! #ifndef POOMA_BENCHMARKS_ABC_H
! #define POOMA_BENCHMARKS_ABC_H
// Include files
#include "Pooma/Arrays.h"
+ #include "Pooma/Fields.h"
#include "Utilities/Benchmark.h"
! #include <cstdlib>
#include <typeinfo>
! #include <string>
+ #if POOMA_CHEETAH
+ typedef DistributedTag LayoutTag_t;
+ #else
+ typedef ReplicatedTag LayoutTag_t;
+ #endif
//-----------------------------------------------------------------------------
! // PatchString class definitions. These return a string notation of
! // the engine type.
//-----------------------------------------------------------------------------
! template<class ETag>
! struct PatchString
! {
! static
! std::string get()
! {
! if (typeid(ETag) == typeid(Brick))
! return "Bk";
! else
! return "CmBk";
! }
! };
! template<class ETag>
! struct PatchString<Remote<ETag> >
! {
! static
! std::string get()
! {
! return "r" + PatchString<ETag>::get();
! }
! };
! template<class LTag, class ETag>
! struct PatchString<MultiPatch<LTag, ETag> >
! {
! static
! std::string get()
! {
! return PatchString<ETag>::get() + "MP";
! }
! };
! template<int D, class T, class ETag>
! std::string qualification(const Array<D, T, ETag> &)
! {
! return PatchString<ETag>::get();
! }
! template<class Mesh, class T, class ETag>
! std::string qualification(const Field<Mesh, T, ETag> &)
! {
! return "Fd" + PatchString<ETag>::get();
! }
! //-----------------------------------------------------------------------------
! // AbcStorage class definitions. These classes allocate the array
! // or field and initialize it. We define this as a partially
! // specialized class so it is easy to make subclasses work for Uniform
! // MultiPatch (UMP) or not.
! //-----------------------------------------------------------------------------
! template<class Storage, bool UMP>
! class AbcStorage
! {
! };
! template<class ETag>
! class AbcStorage<Array<2, double, ETag>, false>
! {
! public:
! void initializeStorage(int &n, int np, int ng)
! {
! // Get new array domain, including "guards".
! Interval<1> N(1, n);
! Interval<2> vertDomain(N, N);
! // Resize the arrays.
! a_m.initialize(vertDomain);
! b_m.initialize(vertDomain);
! c_m.initialize(vertDomain);
}
! Array<2, double, ETag> a_m, b_m, c_m;
! };
! template<class Mesh, class ETag>
! class AbcStorage<Field<Mesh, double, ETag>, false>
! {
! public:
! void initializeStorage(int &n, int np, int ng)
! {
! // Get new array domain, including "guards".
! Interval<1> N(1, n);
! Interval<2> vertDomain(N, N);
! DomainLayout<2> layout(vertDomain);
! Mesh mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
! Centering<2> vert = canonicalCentering<2>(VertexType, Continuous, AllDim);
! // Initialize the fields.
! a_m.initialize(vert, layout, mesh);
! b_m.initialize(vert, layout, mesh);
! c_m.initialize(vert, layout, mesh);
! }
! Field<Mesh, double, ETag> a_m, b_m, c_m;
! };
! template<class ETag>
! class AbcStorage<Array<2, double, ETag>, true>
! {
! public:
! void initializeStorage(int &n, int np, int ng)
{
! n = (n / np) * np;
! // Get new array domain.
!
! Interval<1> N(1, n);
! Interval<2> newDomain(N, N);
! // Create the block sizes.
!
! Loc<2> blocks(np, np);
! // Create the partitioner:
! // We set the internal guard layers to ng_m, and don't allocate external
! // guard layers. The internal guard layers are unnecessary.
!
! UniformGridPartition<2> partition(blocks,
! GuardLayers<2>(ng),
! GuardLayers<2>(0));
! // Create the layout.
!
! UniformGridLayout<2> layout(newDomain, partition, LayoutTag_t());
! // Create the arrays.
!
! a_m.initialize(layout);
! b_m.initialize(layout);
! c_m.initialize(layout);
! }
! Array<2, double, ETag> a_m, b_m, c_m;
! };
! template<class Mesh, class ETag>
! class AbcStorage<Field<Mesh, double, ETag>, true>
! {
! public:
! void initializeStorage(int &n, int np, int ng)
{
! n = (n / np) * np;
// Get new array domain.
! Interval<1> N(1, n);
Interval<2> newDomain(N, N);
// Create the block sizes.
! Loc<2> blocks(np, np);
! // Create the partitioner:
! // We set the internal guard layers to ng_m, and don't allocate external
! // guard layers. The internal guard layers are unnecessary.
! UniformGridPartition<2> partition(blocks,
! GuardLayers<2>(ng),
! GuardLayers<2>(0));
!
// Create the layout.
! UniformGridLayout<2> layout(newDomain, partition, LayoutTag_t());
! Mesh mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
! Centering<2> vert = canonicalCentering<2>(VertexType, Continuous, AllDim);
!
! // Initialize the fields.
!
! a_m.initialize(vert, layout, mesh);
! b_m.initialize(vert, layout, mesh);
! c_m.initialize(vert, layout, mesh);
}
+
+ Field<Mesh, double, ETag> a_m, b_m, c_m;
+ };
+
+ template<class Store>
+ struct StoreTraits
+ {
+ typedef typename Store::Engine_t Engine_t;
+ static const bool multiPatch = Engine_t::multiPatch;
+ };
+
+
+ //-----------------------------------------------------------------------------
+ // AbcBase class definitions. We define this as a partially specialized
+ // class so it is easy to make subclasses work for Uniform MultiPatch
+ // (UMP) or not.
+ //-----------------------------------------------------------------------------
+
+ template<class Store>
+ class AbcBase :
+ public Implementation,
+ public AbcStorage<Store, StoreTraits<Store>::multiPatch>
+ {
+ public:
+
+ // Dummy constructor.
! AbcBase(int np = 1, int ng = 0)
! : np_m(np), ng_m(ng)
! { }
! // Initialize function gets the size and adjusts the arrays.
!
! void initialize(int n)
{
! // Save the problem size.
! n_m = n;
!
! // This call can decrease n_m to an integral multiple of np_m.
! initializeStorage(n_m, np_m, ng_m);
!
! // Set up domains for the internal cells.
!
! I = Interval<1>(1,n_m);
! J = Interval<1>(1,n_m);
}
// Return value for checking result of benchmark run.
*************** public:
*** 234,247 ****
// Return number of flops in this kernel.
! double opCount() const { return (40 * (double)n_m * (double)n_m); }
protected:
- // 2D data arrays.
-
- Array2D *a_m, *b_m, *c_m;
-
// Problem check value.
double check_m;
--- 295,304 ----
// Return number of flops in this kernel.
! double opCount() const { return ( 40 * n_m * n_m ); }
protected:
// Problem check value.
double check_m;
*************** protected:
*** 250,439 ****
int n_m, np_m;
! // Layout.
!
! UniformGridLayout<2> *layout_m;
!
! private:
!
! void setInitialConditions()
! {
! // Initialize arrays.
!
! bRef() = 1.0;
!
! Pooma::blockAndEvaluate();
! }
! };
!
!
! //-----------------------------------------------------------------------------
! // ABCInC class definition.
! //-----------------------------------------------------------------------------
!
! class ABCInC : public ABCTestBase<Brick,false> {
! public:
!
! // This is a C benchmark using brick engines.
!
! const char *type() const { return CType(); }
!
! void run()
! {
! // Run setup
! c_m = 1000.0;
!
! Pooma::blockAndEvaluate();
!
! // Run kernel.
!
! runABCInC(&a_m(1, 1), &b_m(1, 1), &c_m(1, 1), n_m);
! check_m = a_m(n_m / 2, n_m / 2);
! }
};
//-----------------------------------------------------------------------------
! // ABCInCppTran class definition.
//-----------------------------------------------------------------------------
! template<class EngineTag, bool UMP>
! class ABCInCppTran : public ABCTestBase<EngineTag, UMP> {
public:
! // Constructor allows us to specify the number of patches in each direction
! // (if we're UMP-based).
! ABCInCppTran(int np = 1)
! : ABCTestBase<EngineTag, UMP>(np) { }
!
! typedef typename ABCTestBase<EngineTag, UMP>::Array2D Array2D;
// This is a C++Tran benchmark, perhaps using UMP.
const char* type() const { return CppTranType(); }
const char* qualification() const
{
! if (UMP)
! {
! if (typeid(EngineTag) == typeid(Brick))
! return "BrickUMP";
! else
! return "CompBrickUMP";
! }
! else
! {
! if (typeid(EngineTag) == typeid(Brick))
! return "Brick";
! else
! return "CompBrick";
! }
}
void run()
{
! Array2D &a = aRef(), &c = cRef();
! const Array2D &b = bRef();
! int i, j, iter;
! // Run setup
!
! c = 1000.0;
- Pooma::blockAndEvaluate();
-
// Run kernel.
!
! for (iter = 0; iter < 10; ++iter)
{
! double k = 1.0 / sqrt(double(iter + 1));
! for (j = 1; j <= n_m; j++)
{
! for (i = 1; i <= n_m; i++)
{
! a(i, j) = b(i, j) + k * c(i, j);
! c(i, j) = 0.5 * (a(i, j) - b(i, j));
}
}
}
! check_m = a(n_m / 2, n_m / 2);
}
};
//-----------------------------------------------------------------------------
! // ABCInP2 class definition.
//-----------------------------------------------------------------------------
! template<class EngineTag, bool UMP>
! class ABCInP2 : public ABCTestBase<EngineTag, UMP> {
public:
! // Constructor allows us to specify the number of patches in each direction
! // (if we're UMP-based).
! ABCInP2(int np = 1)
! : ABCTestBase<EngineTag, UMP>(np) { }
!
! typedef typename ABCTestBase<EngineTag, UMP>::Array2D Array2D;
// This is a P2 benchmark, perhaps using UMP.
const char* type() const { return P2Type(); }
const char* qualification() const
{
! if (UMP)
! {
! if (typeid(EngineTag) == typeid(Brick))
! return "BrickUMP";
! else
! return "CompBrickUMP";
! }
else
! {
! if (typeid(EngineTag) == typeid(Brick))
! return "Brick";
! else
! return "CompBrick";
! }
}
void run()
{
! Array2D &a = aRef(), &c = cRef();
! const Array2D &b = bRef();
! // Run setup
! c = 1000.0;
!
! Pooma::blockAndEvaluate();
// Run kernel.
! for (int iter = 0; iter< 10; ++iter)
{
! double k = 1.0 / sqrt(double(iter + 1));
! a = b + k * c;
! c = 0.5 * (a - b);
}
Pooma::blockAndEvaluate();
// Save result for checking.
! check_m = a(n_m / 2, n_m / 2);
}
};
! #endif // POOMA_BENCHMARKS_ABCTEST_ABC_H
// ACL:rcsinfo
// ----------------------------------------------------------------------
! // $RCSfile: ABC.h,v $ $Author: jac $
! // $Revision: 1.29 $ $Date: 2000/06/30 01:56:15 $
// ----------------------------------------------------------------------
// ACL:rcsinfo
--- 307,465 ----
int n_m, np_m;
! // Internal guard layers.
! int ng_m;
! // Domains for stencil.
!
! Interval<1> I, J;
};
//-----------------------------------------------------------------------------
! // AbcCppTran class definition, executing a C++ version of ForTran code.
//-----------------------------------------------------------------------------
! template<class Store>
! class AbcCppTran :
! public AbcBase<Store>
! {
public:
! // Constructor allows us to specify the number of patches for each direction.
! AbcCppTran(int np = 1)
! : AbcBase<Store>(np)
! { }
// This is a C++Tran benchmark, perhaps using UMP.
const char* type() const { return CppTranType(); }
const char* qualification() const
{
! typedef typename Store::Engine_t Engine_t;
! return ::qualification(a_m).c_str();
}
void run()
{
! // Run setup.
! runSetup();
// Run kernel.
!
! for (int iter = 0; iter < 10; ++iter)
{
! const double k = 1.0 / sqrt(static_cast<double>(iter+1));
! for (int j = 1; j <= n_m; ++j)
{
! for (int i = 1; i <= n_m; ++i)
{
! a_m(i,j) = b_m(i,j) + k * c_m(i,j);
! c_m(i,j) = 0.5 * (a_m(i,j) - b_m(i,j));
}
}
}
+
+ // Save result for checking.
+
+ check_m = a_m(n_m / 2, n_m / 2);
+ }
! void runSetup()
! {
! for (int j = 1; j <= n_m; ++j)
! {
! for (int i = 1; i <= n_m; ++i)
! {
! b_m(i,j) = 0.0;
! c_m(i,j) = 1000.0;
! }
! }
}
};
//-----------------------------------------------------------------------------
! // AbcP2 class definition, executing Pooma data-parallel code.
//-----------------------------------------------------------------------------
! template<class Store>
! class AbcP2
! : public AbcBase<Store>
! {
public:
! // Constructor allows us to specify the number of patches for each direction.
! AbcP2(int np = 1, int ng = 0)
! : AbcBase<Store>(np,ng),
! guarded_m(ng > 0)
! { }
// This is a P2 benchmark, perhaps using UMP.
const char* type() const { return P2Type(); }
const char* qualification() const
{
! typedef typename Store::Engine_t Engine_t;
!
! std::string qual = ::qualification(a_m);
!
! if (guarded_m)
! {
! PAssert(Engine_t::multiPatch);
! return ("GC" + qual).c_str();
! }
else
! {
! return qual.c_str();
! }
}
void run()
{
! int k;
! // Run setup.
! runSetup();
// Run kernel.
! for (int iter = 0; iter < 10; ++iter)
{
! const double k = 1.0 / sqrt(static_cast<double>(iter+1));
! a_m = b_m + k * c_m;
! c_m = 0.5 * (a_m - b_m);
}
Pooma::blockAndEvaluate();
// Save result for checking.
+
+ check_m = a_m(n_m / 2, n_m / 2);
+ }
+
+ void runSetup()
+ {
+ // Run setup.
! b_m = 0.0;
! c_m = 1000.0;
}
+
+ private:
+ bool guarded_m;
};
! #endif // POOMA_BENCHMARKS_ABC_H
// ACL:rcsinfo
// ----------------------------------------------------------------------
! // $RCSfile: ABC.h,v $ $Author: oldham $
! // $Revision: 1.1 $ $Date: 2001/09/28 03:41:36 $
// ----------------------------------------------------------------------
// ACL:rcsinfo
Index: ABCInC.c
===================================================================
RCS file: /home/pooma/Repository/r2/benchmarks/ABCTest/ABCInC.c,v
retrieving revision 1.9
diff -c -p -r1.9 ABCInC.c
*** ABCInC.c 2000/04/12 01:03:33 1.9
--- ABCInC.c 2001/10/12 23:25:19
***************
*** 27,55 ****
*/
/* ACL:license */
#include "Pooma/Configuration.h"
#include <math.h>
#if POOMA_NO_RESTRICT
#define restrict /**/
#endif
#ifdef __cplusplus
extern "C" {
#endif
void
! runABCInC(double * restrict a, double * b, double * restrict c, int n)
{
! int i, j, iter;
!
for (iter = 0; iter < 10; ++iter)
{
double k;
k = 1.0 / sqrt((double)(iter + 1));
! for (j = 0; j < n; j++)
{
! for (i = 0; i < n; i++)
{
a[i + n * j] = b[i + n * j] + k * c[i + n * j];
c[i + n * j] = 0.5 * (a[i + n * j] - b[i + n * j]);
--- 27,102 ----
*/
/* ACL:license */
+ /* include files */
+
#include "Pooma/Configuration.h"
#include <math.h>
+ /* define away "restrict" if it is not supported */
+
#if POOMA_NO_RESTRICT
#define restrict /**/
#endif
+ /* wrapper for integrated C/C++ compilers */
+
#ifdef __cplusplus
extern "C" {
#endif
+ void
+ runAbcSetup(double* a, double* b, double *c, int n)
+ {
+ int i, j;
+
+ for (j = 0; j <= n - 1; j++)
+ {
+ for (i = 0; i <= n - 1; i++)
+ {
+ b[i + n * j] = 0.0;
+ c[i + n * j] = 1000.0;
+ }
+ }
+ }
+
+ /* Abc kernels */
+
+ void
+ runAbcInCRestrict(double *restrict a, double *restrict b,
+ double *restrict c, int n)
+ {
+ int iter, j, i;
+
+ runAbcSetup(a, b, c, n);
+
+ for (iter = 0; iter < 10; ++iter)
+ {
+ const double k = 1.0 / sqrt((double)(iter+1));
+ for (j = 0; j < n; ++j)
+ {
+ for (i = 0; i < n; ++i)
+ {
+ a[i + n * j] = b[i + n * j] + k * c[i + n * j];
+ c[i + n * j] = 0.5 * (a[i + n * j] - b[i + n * j]);
+ }
+ }
+ }
+ }
+
void
! runAbcInC(double* a, double* b, double* c, int n)
{
! int iter, j, i;
!
! runAbcSetup(a, b, c, n);
!
for (iter = 0; iter < 10; ++iter)
{
double k;
k = 1.0 / sqrt((double)(iter + 1));
! for (j = 0; j < n; ++j)
{
! for (i = 0; i < n; ++i)
{
a[i + n * j] = b[i + n * j] + k * c[i + n * j];
c[i + n * j] = 0.5 * (a[i + n * j] - b[i + n * j]);
*************** runABCInC(double * restrict a, double *
*** 64,71 ****
/* ACL:rcsinfo */
/* ----------------------------------------------------------------------
! * $RCSfile: ABCInC.c,v $ $Author: julianc $
! * $Revision: 1.9 $ $Date: 2000/04/12 01:03:33 $
* ----------------------------------------------------------------------
*/
/* ACL:rcsinfo */
--- 111,118 ----
/* ACL:rcsinfo */
/* ----------------------------------------------------------------------
! * $RCSfile: AbcInC.c,v $ $Author: oldham $
! * $Revision: 1.14 $ $Date: 2001/09/28 03:41:36 $
* ----------------------------------------------------------------------
*/
/* ACL:rcsinfo */
Index: ABCInC.h
===================================================================
RCS file: ABCInC.h
diff -N ABCInC.h
*** /dev/null Fri Mar 23 21:37:44 2001
--- ABCInC.h Fri Oct 12 17:25:19 2001
***************
*** 0 ****
--- 1,147 ----
+ // -*- C++ -*-
+ // ACL:license
+ // ----------------------------------------------------------------------
+ // This software and ancillary information (herein called "SOFTWARE")
+ // called POOMA (Parallel Object-Oriented Methods and Applications) is
+ // made available under the terms described here. The SOFTWARE has been
+ // approved for release with associated LA-CC Number LA-CC-98-65.
+ //
+ // Unless otherwise indicated, this SOFTWARE has been authored by an
+ // employee or employees of the University of California, operator of the
+ // Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
+ // the U.S. Department of Energy. The U.S. Government has rights to use,
+ // reproduce, and distribute this SOFTWARE. The public may copy, distribute,
+ // prepare derivative works and publicly display this SOFTWARE without
+ // charge, provided that this Notice and any statement of authorship are
+ // reproduced on all copies. Neither the Government nor the University
+ // makes any warranty, express or implied, or assumes any liability or
+ // responsibility for the use of this SOFTWARE.
+ //
+ // If SOFTWARE is modified to produce derivative works, such modified
+ // SOFTWARE should be clearly marked, so as not to confuse it with the
+ // version available from LANL.
+ //
+ // For more information about POOMA, send e-mail to pooma at acl.lanl.gov,
+ // or visit the POOMA web page at http://www.acl.lanl.gov/pooma/.
+ // ----------------------------------------------------------------------
+ // ACL:license
+
+ #ifndef POOMA_BENCHMARKS_ABC_ABCINC_H
+ #define POOMA_BENCHMARKS_ABC_ABCINC_H
+
+ //-----------------------------------------------------------------------------
+ // Class AbcInC.
+ //-----------------------------------------------------------------------------
+
+ // include files
+
+ #include "Utilities/Benchmark.h"
+ #include "Utilities/PAssert.h"
+
+ #include <stdlib.h>
+
+ // function declarations
+
+ extern "C" {
+ void runAbcSetup(double* a, double* b, double* c, int n);
+ void runAbcInC(double* a, double* b, double* c, int n);
+ void runAbcInCRestrict(double* a, double* b, double* c, int n);
+ };
+
+
+ //-----------------------------------------------------------------------------
+ // Class definitions.
+ //-----------------------------------------------------------------------------
+
+ template<bool UseRestrict>
+ class AbcInC : public Implementation {
+ public:
+
+ // constructor: just set data pointers to null
+ AbcInC() : a_m(NULL), b_m(NULL), c_m(NULL) {}
+
+ // destructor: clean up allocated memory
+ ~AbcInC() {
+ delete [] a_m;
+ delete [] b_m;
+ delete [] c_m;
+ }
+
+ // This is a C benchmark.
+
+ const char *type() const { return CType(); }
+ const char *qualification() const
+ {
+ if (UseRestrict)
+ return "restrict";
+ else
+ return "";
+ }
+
+ void initialize(int n) {
+ // delete and reallocate the arrays
+ delete [] a_m;
+ delete [] b_m;
+ delete [] c_m;
+
+ a_m = new double[n * n];
+ b_m = new double[n * n];
+ c_m = new double[n * n];
+
+ PInsist(a_m != NULL, "Memory allocation failure of a_m.");
+ PInsist(b_m != NULL, "Memory allocation failure of b_m.");
+ PInsist(c_m != NULL, "Memory allocation failure of c_m.");
+
+ // Save problem size.
+ n_m = n;
+ }
+
+ void run() {
+ // run kernel
+
+ if (UseRestrict)
+ runAbcInCRestrict(a_m, b_m, c_m, n_m);
+ else
+ runAbcInC(a_m, b_m, c_m, n_m);
+
+ // save result
+ check_m = a_m[n_m / 2 - 1 + n_m * (n_m / 2 - 1)];
+ }
+
+ void runSetup()
+ {
+ runAbcSetup(a_m, b_m, c_m, n_m);
+ }
+
+ // Return value for checking result of benchmark run.
+
+ double resultCheck() const { return check_m; }
+
+ // Return number of flops in this kernel.
+
+ double opCount() const { return ( 40 * n_m * n_m ); }
+
+ private:
+
+ // Data Arrays.
+
+ double *a_m, *b_m, *c_m;
+
+ // Problem check value.
+
+ double check_m;
+
+ // Problem Size.
+
+ int n_m;
+
+ };
+
+ #endif // POOMA_BENCHMARKS_ABC_ABCINC_H
+
+ // ACL:rcsinfo
+ // ----------------------------------------------------------------------
+ // $RCSfile: AbcInC.h,v $ $Author: oldham $
+ // $Revision: 1.23 $ $Date: 2001/09/28 03:41:36 $
+ // ----------------------------------------------------------------------
+ // ACL:rcsinfo
More information about the pooma-dev
mailing list