Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When rinning simple_example.py - OverflowError: can't convert negative value to size_t #46

Open
ivbsd1 opened this issue Feb 15, 2020 · 3 comments

Comments

@ivbsd1
Copy link

ivbsd1 commented Feb 15, 2020

Hi,

I recently tried to use gpyfft on following setup:
CPU - ARMv7, 32bits
Debian: Linux tinkerboard 4.4.103+ #1 SMP Fri Jun 22 16:14:49 CST 2018 armv7l GNU/Linux
Python 3.5.3
Cython 0.29.15
Pyopencl 2019.1.2

I installed libclfft and build gpyfft in following way:
python3 setup.py build
python3 setup.py install

After that I tried to run simple_example.py from examples directory and I received:
Traceback (most recent call last):
File "simple_example.py", line 13, in
transform = FFT(context, queue, data_gpu, axes = (2, 1))
File "/usr/local/lib/python3.5/dist-packages/gpyfft-0.7.3-py3.5-linux-armv7l.egg/gpyfft/fft.py", line 93, in init
plan = GFFT.create_plan(context, t_shape)
File "gpyfft/gpyfftlib.pyx", line 142, in gpyfft.gpyfftlib.GpyFFT.create_plan
File "gpyfft/gpyfftlib.pyx", line 219, in gpyfft.gpyfftlib.Plan.init
OverflowError: can't convert negative value to size_t

Can you, please, help me to fix this problem ?

Thanks

@ivbsd1
Copy link
Author

ivbsd1 commented Feb 15, 2020

Actually, I succeeded to fix this problem.
In file gpyfftlib.pyx, I changed
ctypedef size_t voidptr_t
to
ctypedef int voidptr_t

and rebuild gpyfft. Now this works.
Please let me know if you can give more elegant solution

@geggo
Copy link
Owner

geggo commented Feb 17, 2020

Thanks for the report, that is a less common platform. I think you discovered a bug. Your fix is ok for your platform, I will try to find some platform independent solution. One possibility might be to use

ctypedef ptrdiff_t voidptr_t

Can you please test this and report back?

For the records: The problem arises when converting e.g. a OpenCL context reference (natively a void*) from pyopencl, where it is exposed as a (signed) Python int (int_ptr attribute), back to a void*. By any reason, a direct cast is not possible/allowed in cython, therefor an intermediate cast to some signed integer type of platform dependent size is needed. size_t is guaranteed to be large enough, but it is an unsigned integer type. ptrdiff_t is devised for signed arithmetic, but I am not sure if it has the right size on all platforms, could be longer. Don't know if that could create any harm.

hope that helps
Gregor

@ivbsd1
Copy link
Author

ivbsd1 commented Feb 17, 2020

Hi,

I did the change, you suggested
ctypedef ptrdiff_t voidptr_t
and it works.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants