Dear Craig,
If this would be the problem would be, the second two tests would
return false also.
Take a look at the last part of the code:
....
# .. but the imaginary part and the real part are just swapped
print "Imag and real swapped 1: " ,
np.all(g_random_complex.get().imag - random_complex.real < 1e-12)
print "Imag and real swapped 2: " ,
np.all(g_random_complex.get().real - random_complex.imag < 1e-12)
This would return false if the treshold were the problem, however it
returns true.
I found out that
np.exp(1j*x) = cumath.exp(1j*(pi/2-x)) for all x.
So I suspect that this is a bug in cuda. Am I right?
regards,
Dirk
On 20-02-14 21:38, Craig Stringham wrote:
The GPU uses single precision by default, so you need to use a higher
threshold 1e-7 works.
Craig
On Thu, Feb 20, 2014 at 10:00 AM, <[email protected]
<mailto:[email protected]>> wrote:
Send PyCUDA mailing list submissions to
[email protected] <mailto:[email protected]>
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.tiker.net/listinfo/pycuda
or, via email, send a message with subject or body 'help' to
[email protected] <mailto:[email protected]>
You can reach the person managing the list at
[email protected] <mailto:[email protected]>
When replying, please edit your Subject line so it is more specific
than "Re: Contents of PyCUDA digest..."
Today's Topics:
1. strange behaviour of cumath.exp (Dirk Boonzajer Flaes)
----------------------------------------------------------------------
Message: 1
Date: Thu, 20 Feb 2014 17:31:36 +0100
From: Dirk Boonzajer Flaes <[email protected]
<mailto:[email protected]>>
To: <[email protected] <mailto:[email protected]>>
Subject: [PyCUDA] strange behaviour of cumath.exp
Message-ID: <[email protected] <mailto:[email protected]>>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
Hi All!
I am quite new to GPU programming, but I found some strange
behaviour in
the cumath.exp function. Maybe it is well known, but to me it
seems that
the real and imaginary part are swapped. Consider the following code:
import pycuda.gpuarray as gpuarray
import pycuda.autoinit
import pycuda.cumath as cumath
import numpy as np
# create some random numbers in the complex plane
random_reals = np.random.rand(100,100)
random_complex = np.exp(1j*random_reals)
# use the same random numbers, but compute the complex numbers on
the GPU
g_random_reals = gpuarray.to_gpu(random_reals)
g_random_complex = cumath.exp(1.j*g_random_reals)
# it seems that the two arrays are not equal
print "Equal: " , np.all(g_random_complex.get().real -
random_complex.real < 1e-12)
# .. but the imaginary part and the real part are just swapped
print "Imag and real swapped 1: " ,
np.all(g_random_complex.get().imag - random_complex.real < 1e-12)
print "Imag and real swapped 2: " ,
np.all(g_random_complex.get().real - random_complex.imag < 1e-12)
prints
Equal: False
Imag and real swapped 1: True
Imag and real swapped 2: True
Is this indeed a bug? Or am I just missing something?
regards,
Dirk
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.tiker.net/pipermail/pycuda/attachments/20140220/958e5bb3/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
PyCUDA mailing list
[email protected] <mailto:[email protected]>
http://lists.tiker.net/listinfo/pycuda
------------------------------
End of PyCUDA Digest, Vol 68, Issue 4
*************************************
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda