Hi Anh,
you could use the specialized 1D rail constructor for Array, e.g.
val tmp = new Array[Rail[Byte]](Nb*(Nr+1), (i:Int) => new
Array[Byte](4));
... however, at least for initialisation it might be faster to use a 2D
array. This is because
val tmp = new Array[Byte](0..(Nb*(Nr+1)-1) * 0..3);
will zero all Nb*(Nr+1)*4 elements using a single native operation,
whereas the Rail[Rail[Byte]] version must call the array constructor for
every one of the Nb*(Nr+1) elements of the outer array. Like I said,
it's worth doing the experiment to compare 2D Arrays vs. Rail[Rail].
In addition to the -O compile flag, you can try compiling with
-NO_CHECKS. Among other things this removes X10 arrays bounds checks,
so it should improve performance for array-heavy code like yours. Of
course you should only do this once you're sure the code is functionally
correct.
http://x10-lang.org/documentation/performance-tuning.html#PerformanceTuninganX10Application-Compilerandbuildoptionstomaximizeperformance
I'm not sure if you mentioned whether you're using Managed X10 (x10c) or
Native X10 (x10c++)? Have you profiled the code to see where the
majority of the time is being spent?
Cheers,
Josh
On 03/11/11 19:46, Anh Trinh wrote:
Hi,
Changed Array[Byte] to Rail[Byte], I can see performance boost, but
Java is still 2x faster
File: 21M
X10: 25 seconds
Java: 17 seconds
There are places I do this:
val tmp:Rail[Rail[Byte]]= new
Array[Array[Byte](1){rect,zeroBased,rail}](0..(Nb*(Nr+1)-1));
for(var i:int=0; i<tmp.size; i++){
tmp(i) = new Array[Byte](0..3);
}
wonder if this will hit performance, I tried Array constructor
new Array[Rail[Byte]](0..(Nb*(Nr+1)-1), i:Point(1)=>new
Array[Byte](0..3));
and other variations, but not successful. Any suggestion for more
performance?
Thanks
On Nov 2, 2011, at 6:34 PM, David P Grove wrote:
Anh <a...@pacbell.net <mailto:a...@pacbell.net>> wrote on 11/02/2011
09:12:52 PM:
>
> looking at library API, I don't see Rail. Does latest version have
> this feature? I saw this from previous version
Yes. It's now a typedef for Array[T]{rank==1,zeroBased,rect}. In
older versions of X10 it was a special, hand-optimized class distinct
from Array.
The tool that generates the library documentation is based on javadoc
and doesn't quite understand X10's typedefs. If you look in
x10.lang.Rail.x10 you'll find it:
[dgrove@wahtutca lang]$ more Rail.x10
/*
* This file is part of the X10 project (http://x10-lang.org
<http://x10-lang.org/>).
*
* This file is licensed to You under the Eclipse Public License (EPL);
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.opensource.org/licenses/eclipse-1.0.php
*
* (C) Copyright IBM Corporation 2006-2010.
*/
package x10.lang;
public type Rail[T] =
Array[T]{self.rank==1,self.zeroBased,self.rect,self.rail};
--dave
------------------------------------------------------------------------------
RSA(R) 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(R) 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