Hi Anh,

The short answer, which applies to almost everything: do the experiment! :-)

The long answer:

For data that are truly two-dimensional, use a 2D region.  If the X10 
compiler fails to generate efficient executable code from this, then the 
compiler probably needs to be improved.

I assume you have read 
http://x10-lang.org/documentation/performance-tuning.html - 
specifically, the final section about for loop indexing?

Further to that, X10 arrays are optimized for the special cases of 
rectangular and zero-based arrays.  For example, indexing a zero-based 
array:

val x = new Array[Int](0..(N-1) * 0..(N-1));

will perform better than a rectangular, non-zero-based array:

val x = new Array[Int](1..N * 1..N);

which will in turn perform better than:

val r:Region(2) = // arbitrary region
val x = new Array[Int](r);

It's also worth considering that the X10 Array isn't just a C-style 
array (i.e. a pointer that allows subscripting).  It is a proper object 
with fields representing the Region, backing storage and some 
properties.  So an Array of Arrays will require additional storage for 
each internal Array object.  Depending on the internal dimension, this 
could be a significant overhead.

Cheers,

Josh

Anh Trinh wrote:
> which one is better performance
> 2D region array or Array[Array[Int]]?
>
> Thanks
>
>
> ------------------------------------------------------------------------------
> RSA® Conference 2012
> Save $700 by Nov 18
> Register now!
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>   


------------------------------------------------------------------------------
RSA® Conference 2012
Save $700 by Nov 18
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to