11-30-2021 07:54 AM
I am running a system that requires that requires processing large amounts of data through this Vi. As it is now, it takes around 0.5s in my computer to execute.
Using the toolkit for multicore analysis I was able to speed it up quite a bit, but I wonder if there is any trick I could use to speed it up even more. Building a DLL would bring any benefit?
Thank you very much in advance.
11-30-2021 08:09 AM - edited 11-30-2021 08:14 AM
Hi obarriel,
how large are typical input data?
Your "ch0" contains 465120 elements: which computation speed do you expect?
Can you provide a VI using "standard" functions instead of those from "SparseMatrix" toolkit? (There are not so many people having that toolkit installed.)
What I see:
11-30-2021 08:21 AM
Yes, the typical input array contains 465120 elements
The output array will typically have 16 or 23 elements depending on what I plug in the "basis function control"
Later I will upload the vi with the standard functions.
Thank you for your tips!
11-30-2021 09:44 AM
It probably won't save you many ms, but i see you've tried to use SGL and you have a number or coercion dots converting the arrays back to DBLs. Cleaning that up does something, if not much. 🙂
11-30-2021 09:51 AM
It's not clear even the toolkit function even give an advantage here. As has been said, blindly parallelizing everything (e.g. inner loops) is not reasonable.
Can you take a step back and point us to a website that shows the algorithm. Maybe a rewrite from scratch would make more sense.
11-30-2021 10:23 AM
@altenbach wrote:
Can you take a step back and point us to a website that shows the algorithm. Maybe a rewrite from scratch would make more sense.
Are you sure the code is correct? It does not make a lot of sense! For example:
11-30-2021 10:37 AM - edited 11-30-2021 10:50 AM
I attach the original vi with a realistic dataset (takes 1.6mb) and using the standard functions instead of using functions from the multicore toolkit
(In my computer using the multicore toolkit improved the whole execution time by a factor of 2.5 or 3).
I will start now implementing your suggestions to see if they provide a speed advantge. Thank you so much.
The code itself consist of building a large matrix filled with sin and cos (e.g. dimensions 16x465120) and pseudoinvert to multiply it by an incoming signal vector with 465120 elements.
11-30-2021 01:21 PM - edited 11-30-2021 01:29 PM
Hi obarriel,
can you please provide the formulas/algorithm you want to implement?
No substantial changes to your VI, but with Christians suggestion:

It takes ~1.25s on my 8 year old laptop…
(Edit: parallelizing the first FOR loop for sinewave creation to 4 instances reduces by ~25ms.)
11-30-2021 02:12 PM
Thank you for your responses.
I include in the attached pdf the equations that are implemented in this vi. This is actually part of a scientific paper that I can also share, but I think only this part is relevant.
With Christian's modification, I had a slight speed improvement. I will paralyze the first loop too to get also this small improvement.
The FFT part I think it is not really very relevant speed-wise, it is used to correct for the high-frequency attenuation introduced by some acquisition hardware. Oddly I get almost the same result symmetrizing my roll-off function, as suggested by Christian, than as it is now.
Upgrading the computer and getting a cpu a larger number of cores would immediately improve the speed, but it is something that I am trying to avoid at the moment as there are some hardware elements in the current computer that need to be kept.