make cwt function faster

Hi everyone!
I have a code where I loop the cwt function for about 1000 times (Because I have 1000 trials of recordings). Every time I run the code, it takes approximately 150s for the code to execute. Also, each cwt takes about 0.02s to run. I tried to make it run faster by generating a CUDA GPU code from cwt but it actually made it slower. Each CUDA cwt takes about 0.04s to run. Is it reasonable? or I am doing something wrong? Also, do you have any ideas how I can make it faster? like some parallel processing using GPU..
Here is how the code looks like:
for i = 1:1000
tic
[wavelet_signal_temp,f] = cwt(signal(i,:),'amor',fs);
toc
end

3 Comments

Ive J
Ive J on 23 Dec 2021
Edited: Ive J on 23 Dec 2021
Your benchmark doesn't make much sense, since 0.02 s and 0.04 s are too small that can be compared to each other. To better benchmark GPU/CPU, run your scripts using timeit instead, or at least place tic/toc out of the loop.
You can also use parfor loop even with GPU, but whether it throws an out of memory error or not depends on your GPU memory (and of course other nuances).
Also, this may prove useful as well: https://mathworks.com/help/wavelet/ug/cuda-code-from-cwt.html
Hey‌ Ive,
Actually I have put a tic/toc out of my loop and that was how I realized the difference in the first place. But I have not tried timeit and parfor yet! Thank you for the suggestion!
Also about the link, I exactly used the instructions in this link to generate my GPU MEX code.
parfor would hep if you had multiple GPUs.

Sign in to comment.

Answers (0)

Products

Release

R2021b

Asked:

on 23 Dec 2021

Commented:

on 23 Dec 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!