[pooma-dev] How Write Data Parallel Statement?
Jeffrey Oldham
oldham at codesourcery.com
Thu Apr 12 20:23:51 UTC 2001
On Thu, Apr 12, 2001 at 09:11:10AM -0700, Stephen Smith wrote:
> There's a function that provides indices called Iota
> that can be used for this:
>
> #include <cmath>
> #include "Pooma/NewFields.h"
>
> int main(int argc, char *argv[])
> {
> Pooma::initialize(argc,argv);
>
> Array<2,Vector<2> > c(5,4);
> Iota<2>::Iota_t ij(c.domain());
>
> c.comp(0) = ij.comp(0) * cos(ij.comp(1));
> c.comp(1) = ij.comp(0) * sin(ij.comp(1));
>
> // How do I write a data-parallel statement equivalent to?
> for (unsigned i = all values in c's domain's first component)
> for (unsigned j = all values in c's domain's second component)
> c(i,j) = Vector<2>(i * cos (j), i * sin (j));
>
> Pooma::finalize();
> return 0;
> }
Compiling the attached program, basically the same as you suggested,
using gcc 3.1 causes numerous compilation errors. Do you also see
these errors? I will now look into their sources.
> You could use the IndexFunction engine to perform an arbitrary
> computation on the indices and get the compuation you want in one
> step. You'd need to write the expression
> Vector<2>(i * cos (j), i * sin (j));
> out-of-line in a functor object. See the file src/Pooma/Indices.h
> to see how to use an index function engine.
I am looking into Engine/IndexFunctionEngine.h because an index
function engine looks promising.
Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
#include <cmath>
#include "Pooma/NewFields.h"
int main(int argc, char *argv[])
{
Pooma::initialize(argc,argv);
Array<2,Vector<2> > c(5,4);
// How do I write a data-parallel statement equivalent to?
// for (unsigned i = all values in c's domain's first component)
// for (unsigned j = all values in c's domain's second component)
// c(i,j) = Vector<2>(i * cos (j), i * sin (j));
Iota<2>::Iota_t ij(c.domain());
c.comp(0) = ij.comp(0) * cos(ij.comp(1));
c.comp(1) = ij.comp(0) * sin(ij.comp(1));
std::cout << c << std::endl;
Pooma::finalize();
return 0;
}
-------------- next part --------------
cd /nfs/oz/home/oldham/pooma/kernel/
make -j 2 goo
/nfs/oz/home/oldham/gcc-install/gcc3/bin/g++ -DUSE_LIBGXX_INLINES -g -Wall -Wno-sign-compare -DDEBUG -DCORNER_FIELD_TEMPORARY -I/nfs/oz/home/oldham/pooma/pooma0/src/ -I/nfs/oz/home/oldham/pooma/pooma0/lib/LINUXgcc/ -L. goo.cc -lpooma-gcc -o goo
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/OperatorTags.h: In member function
`typename UnaryReturn<T, FnCos>::Type_t FnCos::operator()(const T&) const
[with T = int]':
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/Combiners.h:227: instantiated from `static typename UnaryReturn<T, Op>::Type_t Combine1<A, Op, OpCombine>::combine(A, OpCombine) [with A = int, Op = FnCos]'
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/ForEach.h:101: instantiated from `static typename Combine1<typename ForEach<A, FTag, CTag>::Type_t, Op, CTag>::Type_t ForEach<UnaryNode<Op, A>, FTag, CTag>::apply(const UnaryNode<Op, A>&, const FTag&, const CTag&) [with Op = FnCos, A = Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, FTag = EvalLeaf<2>, CTag = OpCombine]'
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/ForEach.h:116: instantiated from `static typename Combine2<typename ForEach<A, FTag, CTag>::Type_t, typename ForEach<B, FTag, CTag>::Type_t, Op, CTag>::Type_t ForEach<BinaryNode<Op, A, B>, FTag, CTag>::apply(const BinaryNode<Op, A, B>&, const FTag&, const CTag&) [with Op = OpMultiply, A = Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, B = UnaryNode<FnCos, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > >, FTag = EvalLeaf<2>, CTag = OpCombine]'
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/ForEach.h:89: instantiated from `typename ForEach<Expr, FTag, CTag>::Type_t forEach(const Expr&, const FTag&, const CTag&) [with Expr = BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnCos, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > >, FTag = EvalLeaf<2>, CTag = OpCombine]'
/nfs/oz/home/oldham/pooma/pooma0/src/Engine/ExpressionEngine.h:553: instantiated from `T Engine<Dim, T, ExpressionTag<expr> >::read(int, int) const [with int Dim = 2, T = int, Expr = BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnCos, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > >]'
/nfs/oz/home/oldham/pooma/pooma0/src/Array/Array.h:827: instantiated from `static typename Array<D1, T1, E1>::Element_t View2<Array<D1, T1, E1>, int, int>::makeRead(const Array<D1, T1, E1>&, int, int) [with int Dim = 2, T = int, EngineTag = ExpressionTag<BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnCos, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > > >]'
/nfs/oz/home/oldham/pooma/pooma0/src/Array/Array.h:1812: instantiated from `typename View2<Array<Dim, T, EngineTag>, Sub1, Sub2>::ReadType_t Array<Dim, T, EngineTag>::read(const Sub1&, const Sub2&) const [with Sub1 = int, Sub2 = int, int Dim = 2, T = int, EngineTag = ExpressionTag<BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnCos, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > > >]'
/nfs/oz/home/oldham/pooma/pooma0/src/Evaluator/InlineEvaluator.h:176: instantiated from `static void KernelEvaluator<InlineKernelTag>::evaluate(const LHS&, const Op&, const RHS&, const Domain&, WrappedInt<2>) [with LHS = Array<2, double, CompFwd<Engine<2, Vector<2, double, Full>, BrickView>, Loc<1> > >, Op = OpAssign, RHS = Array<2, int, ExpressionTag<BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnCos, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > > > >, Domain = Interval<2>]'
/nfs/oz/home/oldham/pooma/pooma0/src/Evaluator/InlineEvaluator.h:101: instantiated from `static void KernelEvaluator<InlineKernelTag>::evaluate(const LHS&, const Op&, const RHS&) [with LHS = Array<2, double, CompFwd<Engine<2, Vector<2, double, Full>, BrickView>, Loc<1> > >, Op = OpAssign, RHS = Array<2, int, ExpressionTag<BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnCos, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > > > >]'
/nfs/oz/home/oldham/pooma/pooma0/src/Evaluator/Evaluator.h:167: instantiated from `void Evaluator<SinglePatchEvaluatorTag>::evaluate(const LHS&, const Op&, const RHS&) const [with LHS = Array<2, double, CompFwd<Engine<2, Vector<2, double, Full>, BrickView>, Loc<1> > >, RHS = Array<2, int, ExpressionTag<BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnCos, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > > > >, Op = OpAssign]'
/nfs/oz/home/oldham/pooma/pooma0/src/Evaluator/Evaluator.h:108: instantiated from `void Evaluator<MainEvaluatorTag>::evaluate(const LHS&, const Op&, const RHS&) const [with LHS = Array<2, double, CompFwd<Engine<2, Vector<2, double, Full>, Brick>, Loc<1> > >, RHS = Array<2, int, ExpressionTag<BinaryNode<OpMultiply, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > >, UnaryNode<FnCos, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > > > > > >, Op = OpAssign]'
/nfs/oz/home/oldham/pooma/pooma0/src/Array/Array.h:2435: instantiated from `const Array<D1, T1, E1>& assign(const Array<D1, T1, E1>&, const Array<D2, T2, E2>&, const Op&) [with int Dim = 2, T = double, EngineTag = CompFwd<Engine<2, Vector<2, double, Full>, Brick>, Loc<1> >, int OtherDim = 2, OtherT = int, OtherEngineTag = ExpressionTag<BinaryNode<OpMultiply, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > >, UnaryNode<FnCos, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > > > > >, Op = OpAssign]'
/nfs/oz/home/oldham/pooma/pooma0/src/Array/Array.h:2067: instantiated from `const Array<Dim, T, EngineTag>& Array<Dim, T, EngineTag>::operator=(const T1&) const [with T1 = Array<2, int, ExpressionTag<BinaryNode<OpMultiply, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > >, UnaryNode<FnCos, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > > > > > >, int Dim = 2, T = double, EngineTag = CompFwd<Engine<2, Vector<2, double, Full>, Brick>, Loc<1> >]'
goo.cc:16: instantiated from here
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/OperatorTags.h:96: warning: return to
`int' from `double'
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/OperatorTags.h:96: warning: argument
to `int' from `double'
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/OperatorTags.h: In member function
`typename UnaryReturn<T, FnSin>::Type_t FnSin::operator()(const T&) const
[with T = int]':
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/Combiners.h:227: instantiated from `static typename UnaryReturn<T, Op>::Type_t Combine1<A, Op, OpCombine>::combine(A, OpCombine) [with A = int, Op = FnSin]'
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/ForEach.h:101: instantiated from `static typename Combine1<typename ForEach<A, FTag, CTag>::Type_t, Op, CTag>::Type_t ForEach<UnaryNode<Op, A>, FTag, CTag>::apply(const UnaryNode<Op, A>&, const FTag&, const CTag&) [with Op = FnSin, A = Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, FTag = EvalLeaf<2>, CTag = OpCombine]'
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/ForEach.h:116: instantiated from `static typename Combine2<typename ForEach<A, FTag, CTag>::Type_t, typename ForEach<B, FTag, CTag>::Type_t, Op, CTag>::Type_t ForEach<BinaryNode<Op, A, B>, FTag, CTag>::apply(const BinaryNode<Op, A, B>&, const FTag&, const CTag&) [with Op = OpMultiply, A = Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, B = UnaryNode<FnSin, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > >, FTag = EvalLeaf<2>, CTag = OpCombine]'
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/ForEach.h:89: instantiated from `typename ForEach<Expr, FTag, CTag>::Type_t forEach(const Expr&, const FTag&, const CTag&) [with Expr = BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnSin, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > >, FTag = EvalLeaf<2>, CTag = OpCombine]'
/nfs/oz/home/oldham/pooma/pooma0/src/Engine/ExpressionEngine.h:553: instantiated from `T Engine<Dim, T, ExpressionTag<expr> >::read(int, int) const [with int Dim = 2, T = int, Expr = BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnSin, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > >]'
/nfs/oz/home/oldham/pooma/pooma0/src/Array/Array.h:827: instantiated from `static typename Array<D1, T1, E1>::Element_t View2<Array<D1, T1, E1>, int, int>::makeRead(const Array<D1, T1, E1>&, int, int) [with int Dim = 2, T = int, EngineTag = ExpressionTag<BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnSin, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > > >]'
/nfs/oz/home/oldham/pooma/pooma0/src/Array/Array.h:1812: instantiated from `typename View2<Array<Dim, T, EngineTag>, Sub1, Sub2>::ReadType_t Array<Dim, T, EngineTag>::read(const Sub1&, const Sub2&) const [with Sub1 = int, Sub2 = int, int Dim = 2, T = int, EngineTag = ExpressionTag<BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnSin, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > > >]'
/nfs/oz/home/oldham/pooma/pooma0/src/Evaluator/InlineEvaluator.h:176: instantiated from `static void KernelEvaluator<InlineKernelTag>::evaluate(const LHS&, const Op&, const RHS&, const Domain&, WrappedInt<2>) [with LHS = Array<2, double, CompFwd<Engine<2, Vector<2, double, Full>, BrickView>, Loc<1> > >, Op = OpAssign, RHS = Array<2, int, ExpressionTag<BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnSin, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > > > >, Domain = Interval<2>]'
/nfs/oz/home/oldham/pooma/pooma0/src/Evaluator/InlineEvaluator.h:101: instantiated from `static void KernelEvaluator<InlineKernelTag>::evaluate(const LHS&, const Op&, const RHS&) [with LHS = Array<2, double, CompFwd<Engine<2, Vector<2, double, Full>, BrickView>, Loc<1> > >, Op = OpAssign, RHS = Array<2, int, ExpressionTag<BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnSin, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > > > >]'
/nfs/oz/home/oldham/pooma/pooma0/src/Evaluator/Evaluator.h:167: instantiated from `void Evaluator<SinglePatchEvaluatorTag>::evaluate(const LHS&, const Op&, const RHS&) const [with LHS = Array<2, double, CompFwd<Engine<2, Vector<2, double, Full>, BrickView>, Loc<1> > >, RHS = Array<2, int, ExpressionTag<BinaryNode<OpMultiply, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > >, UnaryNode<FnSin, Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, ViewEngine<2, IndexFunction<IotaFunctor> > >, Loc<1> > > > > > >, Op = OpAssign]'
/nfs/oz/home/oldham/pooma/pooma0/src/Evaluator/Evaluator.h:108: instantiated from `void Evaluator<MainEvaluatorTag>::evaluate(const LHS&, const Op&, const RHS&) const [with LHS = Array<2, double, CompFwd<Engine<2, Vector<2, double, Full>, Brick>, Loc<1> > >, RHS = Array<2, int, ExpressionTag<BinaryNode<OpMultiply, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > >, UnaryNode<FnSin, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > > > > > >, Op = OpAssign]'
/nfs/oz/home/oldham/pooma/pooma0/src/Array/Array.h:2435: instantiated from `const Array<D1, T1, E1>& assign(const Array<D1, T1, E1>&, const Array<D2, T2, E2>&, const Op&) [with int Dim = 2, T = double, EngineTag = CompFwd<Engine<2, Vector<2, double, Full>, Brick>, Loc<1> >, int OtherDim = 2, OtherT = int, OtherEngineTag = ExpressionTag<BinaryNode<OpMultiply, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > >, UnaryNode<FnSin, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > > > > >, Op = OpAssign]'
/nfs/oz/home/oldham/pooma/pooma0/src/Array/Array.h:2067: instantiated from `const Array<Dim, T, EngineTag>& Array<Dim, T, EngineTag>::operator=(const T1&) const [with T1 = Array<2, int, ExpressionTag<BinaryNode<OpMultiply, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > >, UnaryNode<FnSin, Reference<Array<2, int, CompFwd<Engine<2, Vector<2, int, Full>, IndexFunction<IotaFunctor> >, Loc<1> > > > > > > >, int Dim = 2, T = double, EngineTag = CompFwd<Engine<2, Vector<2, double, Full>, Brick>, Loc<1> >]'
goo.cc:17: instantiated from here
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/OperatorTags.h:173: warning: return
to `int' from `double'
/nfs/oz/home/oldham/pooma/pooma0/src/PETE/OperatorTags.h:173: warning: argument
to `int' from `double'
Compilation finished at Thu Apr 12 13:18:47
More information about the pooma-dev
mailing list