LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing Parallel Loop Iterations

Solved!
Go to solution

I'm trying to time each specific iteration. I've searched around and none of the iteration timers I have found work for what I need (all return a 0 time). My issue is that I can't add a shift register on a parallel for loop to try to measure and calculate ticks per iteration. 

What I want to do is to measure/calculate the time it takes for the program to run using various amounts of parallel threads. Something like the link below but the video does not show how they are timing the loop? (maybe they are, if so can someone explain?)

https://www.youtube.com/watch?time_continue=5&v=pSHJRotX7mY&feature=emb_logo

 

Below is what I have for my block diagram & front panel, what am I doing wrong?

lbvw.png

0 Kudos
Message 1 of 7
(3,876 Views)

If you only have one iteration, nothing gets parallelized. A parallel FOR requires that all iterations are independent, so muiltiple iterations can be executed in parallel. Your code makes little sense overall. Did you do some tutorials first?

 

And please attach your VI. We cannot run or debug pictures.

 

Note that the multicore toolkit has parallel versions of linear algebra VIs. Useful for very large matrices.

0 Kudos
Message 2 of 7
(3,827 Views)

I watched and read (and tried) a bunch of tutorials first which lead to this (it has been a while since I properly used labVIEW). I did not know about the multicore toolbox and am currently downloading it. Attached is my VI.

 

For the iterations, my processor can run up to 12 threads so based on what you mentioned I should set the iterations to 12 (or just higher than 1)?

 

The main program (multiplying the matrices) works, the issue is that I need to time how long it takes to run the code based on the number of threads (like the linked video shows in the original post)

0 Kudos
Message 3 of 7
(3,815 Views)

After more searching through these forums I found a way to monitor VIs through Tools > Profile > Performance and Memory

0 Kudos
Message 4 of 7
(3,702 Views)
Solution
Accepted by topic author MKlono

@MKlono wrote:

After more searching through these forums I found a way to monitor VIs through Tools > Profile > Performance and Memory


That't wont be really useful here.

 

Your VI still does not make a lot of sense. What's the purpose of the while loop and associated code?

Don't underestimate the compiler, it might decide that the inner FOR loop calculation always gives the same result and not do it 12 times. 

 

You did not fill the input matrices and other controls with useful default data. How big are they? For small matrices the parallelization overhead (splitting the problem and assembling the partial results will most likely slow you down more that the parallelization gain!). You did not even disable debugging.

 

What is the problem you are trying to solve? Just multiplying two matrices will not gain anything unless you either use the version from the multicore toolkit or you make you own matrix multiplication using simple operations and parallelize some operations (read this : You won't get a N-times speedup using N cores to matrix multiply).

 

Hyperthreading does not add a real CPU core, you only have six cores. In your current code, you'll see up to a 6x parallelization advantage if you would multiply six (or more) different pairs of A&B matrices in parallel.

 

Multiplying two small matrices will be nearly infinitely fast. Try with much, much larger inputs. Note that the video uses 10k elements for the FFT and is a really (really!) bad example. It makes no sense, because the ptbypt FFT will operate on N parallel instances, so the result not only depends on the number of parallel instances, but also on the random scheduling of them. Unless the number of parallel instances is 1, the resulting 2D array will be different for every run!

 

Again: Are you trying to solve a problem or are you just playing around as a learning tool?

At this point in your learning curve, focus on more basic programming concepts. Parallelization can wait!

0 Kudos
Message 5 of 7
(3,688 Views)

I ended up removing the while loop because the more I looked at it the less it made sense and also increased the matrix size. I don't have the matrices auto indexed so I was just adding the numbers manually.

 

This experiment was more playing around based on a different actual problem using a different program. Thank you for all your input!

0 Kudos
Message 6 of 7
(3,677 Views)
0 Kudos
Message 7 of 7
(3,510 Views)