freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [pooma-dev] How Write Data Parallel Statement?


From: Stephen Smith
Subject: RE: [pooma-dev] How Write Data Parallel Statement?
Date: Thu, 12 Apr 2001 09:11:10 -0700

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:address@hidden]
Sent: Thursday, April 12, 2001 9:00 AM
To: address@hidden
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
address@hidden


reply via email to

[Prev in Thread] Current Thread [Next in Thread]