Hi Apan --

Completely unrelated to this thread with you, I received the following mail from Nikhil Padmanabhan (community user/developer and Yale prof), who said it was OK for me to reflect it on this thread (he's not on this mailing list, suggesting that it might be useful/interesting to capture this discussion on a GitHub issue). Editing his mail down a bit, he offered the following. Hope this is helpful/of interest.

-Brad

Nikhil writes:

Here is an oldie that I recently came back to in working on the PAW code... how does one map an SOA to AOS?

Now, zip gets you most of this, but we'd ideally not want to keep writing zip and remembering structure names etc... But it seems like zip wrapped in an iterator does the trick:

use BlockDist;

const Space = {0.. #10};
const D : domain(1) dmapped Block(boundingBox=Space) = Space;
var x,y,z: [D] int;

iter Coords() ref {
  for tup in zip(x,y,z) {
    yield tup;
  }
}

iter Coords(param tag:iterKind) ref where tag==iterKind.standalone {
  forall tup in zip(x,y,z) {
    yield tup;
  }
}

forall (x1,y1,z1) in Coords() {
  if (x1.locale.id != here.id) then writeln("ERROR!");
  if (y1.locale.id != here.id) then writeln("ERROR!");
  if (z1.locale.id != here.id) then writeln("ERROR!");
  x1 = 1 + here.id;
  y1 = 2 + here.id;
  z1 = 3 + here.id;
}

writeln(x);
writeln(y);
writeln(z);


On Fri, 7 Jul 2017, Brad Chamberlain wrote:


Hi Apan --

I'm happy that you're thinking about this challenge, as it's a longstanding one that users bring up and one for which we've kicked ideas around, yet without any ideal solution yet.

My question is, is there a way to determine which field is being requested in an AoS reference (A[i].x) from within the domain map code?

Unfortunately not -- because the domain map code is only implementing the array itself, it can only get the [i] access as an argument and know that the element type is a(n apparent) record.

I'll mention that when this challenge was first levelled at us (by some potential Chapel users from DOE labs), I proposed a domain map-based solution, albeit possibly one different than the one you are pursuing. I'd imagined having the domain map be parameterized by the number/type of elements in the fields and having it pre-allocate the data for them. I recall that there was something about this solution that they found off-putting, but can't quite recall what it was -- it seems like it was related to an extra indirection or multiplication, but I can't reconstruct the conversation just now.

From there, my thoughts turned to approaches that would rely on the facts that Chapel types can (1) implement their own indexing functions and (2) support methods that omit parenthesis to get pseudo-fields. That is:

-----
record R {
 proc this(i: real) {
   return 2*i;
 }

 proc x {
   return 3.14;
 }
}

var myR: R;

writeln(R[2.4]);
writeln(R.x);
-----


The last time I was kicking this problem around, I was wondering whether creating a record/class that wrapped an array, or group of arrays, could lean on these mechanisms to provide AoS vs. SoA transparency. Offhand, I can't recall whether I got stymied or never spent the time on it to see it through.


I'll also mention that I'm (personally) open to modifying the language to "solve" the AoS vs. SoA challenge, though I'm hesitant to take the approach of giving domain maps more context for the expression that follows the indexing expression as you were asking about, at least on the surface (but perhaps could be convinced, given a strong enough proposal and rationale).

-Brad




On Fri, 7 Jul 2017, Qasem, Apan M wrote:

Hello,

I am implementing data layout transformations in Chapel that favor GPU/heterogenous memory hierarchy.

One of the transformations I am looking at is the AoS-to-SoA conversion (critical for heterogenous applications). I am hoping to implement this using a domain map. For example,

var N = 1..100;

record img {
 var r: int;
 var g: int;
 var b: int;
 var x: int;
}

var domAoS : domain(1) = {N};
var domSoA : domain(1) dmapped SoA() = {N};

var A : [domAoS] img;
var B : [domSoA] img;

A[3].g = 17;   // A accessed as AoS
B[3].g = 17;   // B accessed as SoA


I have a partial implementation where I am able to map an AoS index to an SoA index in the SoA() domain map (as long as the field access information is hard coded in the module code).

My question is, is there a way to determine which field is being requested in an AoS reference (A[i].x) from within the domain map code?

- Apan

Apan Qasem, PhD
Visiting Scholar, AMD Research
Associate Professor, Dept of Computer Science
Texas State University
http://www.cs.txstate.edu/~aq10




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to