02-27-2015 05:16 AM
Hi,
i'm currently struggling to find an array function to generate a running sum array.
My current implementation is working so far. But with bigger arrays (>100000 elements) the throughput is not sufficient.
Running sum means:
Each array element is the sum of the previous elements + the value of the according Input-array-element.
INPUT Array:
[100, 10, 95, 95, 5,5,100]
OUTPUT Array:
[100,110,205,300,305,310,410]
Does anybody know an array/matrix function to speed up this operation?
If possible without any loops.
Solved! Go to Solution.
02-27-2015 06:05 AM - edited 02-27-2015 06:10 AM
Hi Daniel,
adding up 100k array elements takes ~1ms on my PC:
Using HighResolutionRelativeSeconds it just reports ~400µs for this routine.
With 1M elements it reports ~4ms, so this scales linearly with number of elements…
How much do you want to speed this up?
03-02-2015 12:43 AM
As fast as possible.
Down to a few us would be a big advantage.
But in my opinion this is only possible by using array functions.
So the question is:
Exists an array or matrix function which is doing this operation?
03-02-2015 01:40 AM
DaIn wrote:But in my opinion this is only possible by using array functions.
Based on what evidence?
The autoindexing FOR loop is extremely efficient. What makes you think otherwise?
03-02-2015 02:06 AM
Using array functions instead of for/while loops was in the past in the most cases a good tool to speed up such operations.
This operation is implemented in the SW part of a high-throughput FPGA application.
Maybe using an auto-indexing FOR loop is the best and fastest solution.
But I want to be sure that I'm using the most efficient implementation.
03-02-2015 02:11 AM
Hi Daln,
ohh wait: we talk about LabVIEW on FPGA now? Why didn't you mention it in the first place?
- LV-FPGA can use arrays, BUT usually insists on fixed-length arrays…
- LV-FPGA needs a lot of space to handle big arrays, so you need some streamlining of smaller chunks anyway…
03-02-2015 02:18 AM
No no....
This function is implemented in the SOFTWARE PART of an FPGA application.
So the FPGA is generating the data. This data is streamed to the Host-vi which is running on a PC.
And this "Running sum" operation is implemented in one of the Sub-vis on the PC.
No FPGA solution needed!
03-02-2015 02:21 AM
DaIn wrote:Down to a few us would be a big advantage.
Do the math!
To add 100000 elements in a microsecond, an single addition would have to take 10ps.
Even if the CPU could do an addition in a single clock cycle, you still would need a 100GHz processor. Not realistic!
03-02-2015 02:28 AM
From that point of view: You are correct.
Like stated above:
I only wanted to be sure, that there is no faster way to do this operation in Labview.
This is 100% fine for me if it is the fastest way.
03-02-2015 02:31 AM
For a running sum, especially on a large array you'll only need to keep the previous sum and add the new number, no need to recalculate the previous values that'll be constant.
/Y