LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transpose 2D Array - strange behavior with timing

Colleagues,

 

Just would like to measure the performance of Transpose 2D Array  function and got something strange:

 

Strange Phenomena with Transpose.png

 

Now results:

 

results.png

 

Is any rational explanation exists - why Time 1 is equal to zero?

 

Compare with multiply - here we will get nearby same time:

 

Multiply_OK.png

 

res_mul.png 

 

Probably bug? 

 

Andrey.

0 Kudos
Message 1 of 3
(3,197 Views)

Andrey Dmitriev wrote:

Probably bug? 


If the result is correct, it cannot be a bug. 🙂 

 

It could be an optimization. I thought I heard somewhere that transpose does not actually touch the data, but just adds a flag to reverse the order of the indices. (Similarly, reverse array does not reverse the data in memory, just adds a flag to run the index backwards (see first comment here)).

 

Certain code constructs, e.g. the while loop in the second part, might force it to do an explicit transpose.

 

Of course this is all just guessing. I am sure somebody more knowledgeable will chime in. 😉

Message Edited by altenbach on 10-16-2009 05:57 AM
0 Kudos
Message 2 of 3
(3,180 Views)

Andrey,

 

I would expect time one to be zero most of the time if the transpose time is well under a millisecond.  If transpose works by switching indices rather than moving the data, the time should only be dependent on the number of dimensions rather than the size of the array.

 

I replaced your while loop with a for loop. The time does not change until the value of N exceeds 1000000.  For any value of N the second and subsequent runs are much faster than the first.  I suspect that with constant folding and compiler optimization, this method of timing may not be very meaningful.

 

Lynn 

0 Kudos
Message 3 of 3
(3,170 Views)