Hello Hui,
Both homogeneous tuples and 1D arrays result in a dense region of memory
to hold the data. Homogeneous tuples are generated as static C arrays,
while 1D arrays are generated as dynamically allocated arrays in C with
descriptor wrappers that could cause some extra overhead.
However, after a quick experiment, I don't think this is the main cause
of the overhead you've observed. I suspect you didn't use the flag
'--fast' when compiling your example. Without the '--fast' flag, all
array accesses are bounds checked and much optimization is disabled.
Please ensure you use '--fast' whenever timing Chapel code.
Experimenting with your toy program, I see:
First, no '--fast' flag:
% chpl toy.chpl
% a.out
Total Time of tuple: 1.84453
Total Time of array: 3.31332
Next, use '--fast':
% chpl --fast toy.chpl
% a.out
Total Time of tuple: 0.833608
Total Time of array: 0.834094
So, '--fast' causes a significant improvement for both the tuple and the
array, but it also brings the array time in line with the tuple.
David
On 3/30/16 2:52 PM, Hui Zhang wrote:
Hello,
I'm wondering the difference between the overhead of using homogeneous
tuple and array, for example:
var TupleVar: 8*real;
var ArrayVar: [1..8] real;
1. Are they both allocated on memory in a row-major behavior ? (Index
order makes big difference ?)
2. I played a little bit on both with a toy program:
var stt = getCurrentTime();
for i in 1..8 {
for j in 1..12345678 {
tmp = j/101 + 3.14/j;
tupleVar[i] += tmp;
}
}
var ent = getCurrentTime();
writeln("Total Time of tuple: ", ent-stt);
stt = getCurrentTime();
for i in 1..8 {
for j in 1..12345678 {
tmp = j/101 + 3.14/j;
arrayVar[i] += tmp;
}
}
ent = getCurrentTime();
writeln("Total Time of array: ", ent-stt);
The time for tuple is about 2.25 seconds, while the time for array is
about 4.8 seconds, more than twice of the one tuple one, kinda
superised me, I want to know why.
Thank you !
--
Best regards
Hui Zhang
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers