Odd Profiler GPU Bug?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have a loop that does some operations on the GPU. When I call the function from the command line, each epoch runs in 96 seconds. When I call it from profiler, each epoch takes about 4 seconds. The CPU version of the code runs in about 63 seconds. Any ideas on how to fix this so that I get the GPU speed up without profiler? I could call it from profiler exclusively, but that seems silly. Here is the portion of code that seems to be affected by this phenomenon. The r array is large, e.g., 4000x78000.
tic
r = gpuArray(single(r));
U_grad = gpuArray(single(0));
W = gpuArray(single(W'));
for k = 1:max_class
U_grad = U_grad + bsxfun(@times, W(:, k), r);
end
U_grad = double(gather(U_grad)) * (q');
toc
2 Commenti
Edric Ellis
il 2 Nov 2015
Any chance you could post a standalone reproduction? What version of MATLAB are you using? What OS? What GPU?
Risposte (1)
Joss Knight
il 27 Nov 2015
When you have the profiler on (from MATLAB R2015a onwards), to get realistic timings the GPU is forced to run synchronously.
My guess is that without the profiler, your second call to bsxfun is executed before the first finishes (this is possible because it can compute it without needing the output from the previous loop). MATLAB attempts to allocate space for an output array of appropriate size, but there isn't enough space available for two arrays of that size.
With the profiler on, the space from the first call to bsxfun has been freed up and made available to the second bsxfun.
You can confirm this is the case by calling wait(gpuDevice) inside your loop to prevent this execution overlap.
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with GPU Coder in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!