Difference in output of find when using gpuArray
Show older comments
Hello,
I have this piece of code:
a = zeros(12,12,12);
for i=1:12, for j=1:12, for k=1:12
a(i,j,k)=((i-5)^2+(j-6)^2+(k-7)^2)<6;
end, end, end
b = find(a);
Now I've done the same thing using gpuArray.zeros instead of zeros, and I find that the output of the find function is different. b is of size 57x1. The output of the gpuArray version (call it b1) is of size 134x1. Also, the first 57 entries in b and b1 are the same. After that, there are a bunch of zeros and some other numbers. Any idea why the find function seems to be misbehaving for gpuArray?
Thanks in advance, Ranjan
EDIT: Here's some version info just in case it helps CUDA VERSION: 6.5
the command nvidia-smi returns this:
+------------------------------------------------------+
| NVIDIA-SMI 346.47 Driver Version: 346.47 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla C2050 Off | 0000:05:00.0 Off | 0 |
| 52% 87C P0 N/A / N/A | 79MiB / 2687MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 29631 C /usr/local/MATLAB/R2014b/bin/glnxa64/MATLAB 71MiB |
+-----------------------------------------------------------------------------+
Answers (1)
Edric Ellis
on 27 Apr 2015
I tried this in R2015a using a Tesla C2070 GPU and found no difference.
a1 = gpuArray.zeros(12,12,12);
a2 = zeros(12,12,12);
for i=1:12, for j=1:12, for k=1:12
a1(i,j,k)=((i-5)^2+(j-6)^2+(k-7)^2)<6;
a2(i,j,k)=((i-5)^2+(j-6)^2+(k-7)^2)<6;
end, end, end
b1 = find(a1);
b2 = find(a2);
% The following assertion passes
assert(isequal(b1, b2))
What release of MATLAB are you using, and what GPU device?
10 Comments
Ranjan Anantharaman
on 27 Apr 2015
Edric Ellis
on 27 Apr 2015
Edited: Edric Ellis
on 27 Apr 2015
Very strange, I just tried this in R2014b on Linux (C2070) and Windows (M2075), and did not see the assertion failure... I think you should probably contact technical support to see if they can help with this.
Ranjan Anantharaman
on 28 Apr 2015
Edric Ellis
on 28 Apr 2015
I'm using Debian 7.
Ranjan Anantharaman
on 28 Apr 2015
Edited: Ranjan Anantharaman
on 28 Apr 2015
Ranjan Anantharaman
on 29 Apr 2015
Edric Ellis
on 29 Apr 2015
Still very mysterious - especially since the computation for the elements of a2 is performed on the host, and then the value simply sent to the GPU - and that value is a logical which gets converted to a double. What's the output of running that code and then doing:
format hex
unique(a1(:))
?
Ranjan Anantharaman
on 29 Apr 2015
Edric Ellis
on 30 Apr 2015
Those values 0020000000000000 are giving the odd results. It's very strange to me that the error is a single bit. Is that really what unique returned? As you can clearly see, there are duplicate values in there...
Ranjan Anantharaman
on 1 May 2015
Categories
Find more on Parallel and Cloud in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!