LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace array subset in parallel for loop without increasing memory

How is an array of clusters of arrays smaller than a single array of values and an array of lengths? 


 

The recommendation isn't only about the total memory consumed by the data.  There are other advantages to the "array of clusters containing arrays of data."

 

Internally, this will probably be stored as something like a single array of pointers, each pointer points to a distinct individual array.  (Possibly there's another pointer layer for the cluster container, but I'm guessing LabVIEW can optimize that away.)  As a result, you no longer need a single big block of *contiguous* memory in order to hold all the data.  Instead you have a whole bunch of smallish, independent chunks.  *THIS* factor is quite likely to be a *big* help for the problem where you say, "if I am not careful I crash the program because the computer can’t allocate enough to Labview."

 

I can't speak for the LabVIEW compiler internals, but the processing you show *seems* to make it sufficiently clear for LabVIEW to work in-place on the arrays.  So I wouldn't count on an efficiency improvement due to in-placeness.  However, in my mind at least, it's at least conceivable that an "array of clusters of arrays" might more easily benefit from For Loop parallelization.   (... and reviewing the thread, it looks like GerdW had the same thought first in msg #2).

 

 

-Kevin P

 

 

 

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 11 of 53
(1,764 Views)

@altenbach wrote:

 

(I have not benchmarked if parallelization really gives a speedup. Not sure about the overhead of that concatenating tunnel ;))

 

SubsetProcessing.png


I get about a 3-4x speedup comparing a parallel FOR loop with a regular FOR loop using the otherwise identical above code.

 

SubsetProcessingBenchmark.png

 

 

Message 12 of 53
(1,760 Views)

 

 

 

 

0 Kudos
Message 13 of 53
(1,713 Views)

Just to make sure we are on the same page, your complicated code with the pyramid of IPEs (with parallelism removed) performs nearly identically (within a few %) to my much simpler version (also, with parallelism removed).

0 Kudos
Message 14 of 53
(1,739 Views)

@Altenbach - I believe you are correct.

 

I modified my original code to get rid of parallelization and remove some of the IPE structures.

See below.

 

AnotherTry.viAnotherTry.vi

 

I also modified Altenbach's Code to include a sort array.

See below.

ParallelTest.viParallelTest.vi

 

Did not extensively test nor bench mark, but attached are results for the VI profiler. The IPE saves memory if that is important to the OP.

Snap2.png

 

 

mcduff

 

 

 

Download All
0 Kudos
Message 15 of 53
(1,736 Views)

@mcduff wrote:

 

I also modified Altenbach's Code to include a sort array.


What was wrong with the "sort array" that was already there??? 😮

0 Kudos
Message 16 of 53
(1,738 Views)

@Altenbach - Sorry. I am quite tired and did not see the sort array in your original image, much like the gorilla walking by the kids bouncing the ball.

 

mcduff

Message 17 of 53
(1,733 Views)

Also, your "another try" performs nearly identically to my sequential version. My parallel version is still 3-4x faster.

0 Kudos
Message 18 of 53
(1,726 Views)

What about memory usage? You got to throw me some table scraps. Smiley Very Happy

 

mcduff

0 Kudos
Message 19 of 53
(1,724 Views)

Well, I don't know, but it seems the IPE is not as optimized as you think. For example if you unroll the loop completely as follows (still the same result), it does not speed up over your code, even though all sorting operations can execute in parallel ( ... and I am currently on a dual Xeon with 16 hyperthreaded cores (32 virtual cores).

 

I am not sure about memory use but the LabVIEW compiler is typically good at keeping things in-place as much as possible, even without the IPE structure.

 

NoLoop.png

 

 

(Of course this is not really scalable, just wired up as a test scenario)

Message 20 of 53
(1,717 Views)