[pooma-dev] How Write Data Parallel Statement?
Stephen Smith
stephens at proximation.com
Thu Apr 12 16:11:10 UTC 2001
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;
}
Of course this isn't too efficient. It would be better to just
compute the vector at each location. We don't have a data-parallel
operation to create a vector from components... (it would be easy to
write though).
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.
Stephen
-----Original Message-----
From: Jeffrey Oldham [mailto:oldham at codesourcery.com]
Sent: Thursday, April 12, 2001 9:00 AM
To: pooma-dev at pooma.codesourcery.com
Subject: [pooma-dev] How Write Data Parallel Statement?
How do I write a Pooma data-parallel statement for this assignment to
2-D array c?
#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));
Pooma::finalize();
return 0;
}
Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/pooma-dev/attachments/20010412/ff715fc4/attachment.html>
More information about the pooma-dev
mailing list