-
Notifications
You must be signed in to change notification settings - Fork 21
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
callback argument for the FFT class #51
Comments
Is there an example for performing the callback using the FFT high-level interface ? Do I give pass the argument to the FFT high level callback as a part of the dict only ? If yes, what keyword does it look for there ?
Secondly, in a callback function, how to access a 2D array ?
Please guide !
sincerely,
Mugundhan
Hi,
currently there is no example for using calbacks with the high-level. However, the tests contain one example, test_callbacks.py, for using it with the low level interface. You can use the low-level commands on the FFT.plan attribute to set callbacks. Alternatively, you can provide to the high-level FFT constructor the callback OpenCL kernel sources as a dict with keys „pre“ or „post“. Note that in this case the corresponding OpenCL kernels need to be named „pre“ or „post“.
The kernels itself are called with a single offset argument, as described in the clFFT documentation. Unfortunately, for an 2d, 3d or batched transform it is not documented how this offset is related to the row/column index of the corresponding array entry, you have to guess.
hope that helps
Gregor
|
Hi Gregor,
Thank you for your reply and sorry for the late reply.
For the high level FFT constructor, where we pass callback as elements of a
dictionary, can we pass the arguments, if we have any (like user_data in
the example) as elements of the dictionary itself ? When I do this, there
is an error: dict object has no attribute has_key. I googled this up, and
results are that has_key has been deprecated in python3. Is there an
updated version of the library that I can install to get over this ?
I'm trying this using low level, but the high level is sort of very
convenient ! :D
Sincerely,
V. Mugundhan
…On Sun, Oct 11, 2020 at 12:08 AM Gregor Thalhammer ***@***.***> wrote:
> Is there an example for performing the callback using the FFT high-level
interface ? Do I give pass the argument to the FFT high level callback as a
part of the dict only ? If yes, what keyword does it look for there ?
>
> Secondly, in a callback function, how to access a 2D array ?
>
> Please guide !
> sincerely,
>
> Mugundhan
>
>
Hi,
currently there is no example for using calbacks with the high-level.
However, the tests contain one example, test_callbacks.py, for using it
with the low level interface. You can use the low-level commands on the
FFT.plan attribute to set callbacks. Alternatively, you can provide to the
high-level FFT constructor the callback OpenCL kernel sources as a dict
with keys „pre“ or „post“. Note that in this case the corresponding OpenCL
kernels need to be named „pre“ or „post“.
The kernels itself are called with a single offset argument, as described
in the clFFT documentation. Unfortunately, for an 2d, 3d or batched
transform it is not documented how this offset is related to the row/column
index of the corresponding array entry, you have to guess.
hope that helps
Gregor
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#51 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC3LYYCOB6CBQQQBFWPSHSLSKCSYVANCNFSM4SLCS67A>
.
|
Hi Gregor,
Also, how do we profile the FFT ? The same way by trying to profile the
queue as in pyopencl ?
Additional doubt: Is the callback function of the FFT similar to the
eventwisekernel operation ? What are the differences ? (This may not be a
gpyfft question. If this is the case, can you point me to some references ?)
Sincerely
Mugundhan
On Mon, Oct 12, 2020 at 4:36 PM Mugundhan vijayaraghavan <
[email protected]> wrote:
… Hi Gregor,
Thank you for your reply and sorry for the late reply.
For the high level FFT constructor, where we pass callback as elements of
a dictionary, can we pass the arguments, if we have any (like user_data in
the example) as elements of the dictionary itself ? When I do this, there
is an error: dict object has no attribute has_key. I googled this up, and
results are that has_key has been deprecated in python3. Is there an
updated version of the library that I can install to get over this ?
I'm trying this using low level, but the high level is sort of very
convenient ! :D
Sincerely,
V. Mugundhan
On Sun, Oct 11, 2020 at 12:08 AM Gregor Thalhammer <
***@***.***> wrote:
> > Is there an example for performing the callback using the FFT
> high-level interface ? Do I give pass the argument to the FFT high level
> callback as a part of the dict only ? If yes, what keyword does it look for
> there ?
> >
> > Secondly, in a callback function, how to access a 2D array ?
> >
> > Please guide !
> > sincerely,
> >
> > Mugundhan
> >
> >
> Hi,
>
> currently there is no example for using calbacks with the high-level.
> However, the tests contain one example, test_callbacks.py, for using it
> with the low level interface. You can use the low-level commands on the
> FFT.plan attribute to set callbacks. Alternatively, you can provide to the
> high-level FFT constructor the callback OpenCL kernel sources as a dict
> with keys „pre“ or „post“. Note that in this case the corresponding OpenCL
> kernels need to be named „pre“ or „post“.
>
> The kernels itself are called with a single offset argument, as described
> in the clFFT documentation. Unfortunately, for an 2d, 3d or batched
> transform it is not documented how this offset is related to the row/column
> index of the corresponding array entry, you have to guess.
>
> hope that helps
> Gregor
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#51 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AC3LYYCOB6CBQQQBFWPSHSLSKCSYVANCNFSM4SLCS67A>
> .
>
|
Hi, thanks for the report, porting to Python 3.x broke setting callbacks from the high-level interface. The high-level also does not support providing user data to the callbacks. I have to think how to implement this properly. For the moment, you have to use the low-level interface for setting the callbacks, but you can mix it easily, e.g.
The enqueue() method of the transform returns a list of events for each internal kernel call. You can access the profiling information of each event, e.g., via evt.profile.start , provided that profiling has been enabled for the queue. The callbacks are called once for each element of the transform data, for input (pre) and output (post). In this respect it es similar to an elementwise kernel, if this is what you mean. There are some examples on how to use callbacks (with C) link hope that helps |
Hi Gregor !
Thank you for your inputs. I was able to run a FFT with callback using the
low level interface. I will try doing this using the high level interface
also!
Yes, I think the pyopencl elementwise kernel also is called once per
element. But I will check this through profiling as well!
Sincerely,
V. Mugundhan
…On Mon, Oct 12, 2020 at 8:37 PM Gregor Thalhammer ***@***.***> wrote:
Hi,
thanks for the report, porting to Python 3.x broke setting callbacks from
the high-level interface. The high-level also does not support providing
user data to the callbacks. I have to think how to implement this properly.
For the moment, you have to use the low-level interface for setting the
callbacks, but you can mix it easily, e.g.
transform = FFT(context, queue, data)
transform.plan.set_callback('your_kernel_name', kernel_source, 'post', user_data)
transform.enqueue()
The enqueue() method of the transform returns a list of events for each
internal kernel call. You can access the profiling information of each
event, e.g., via evt.profile.start , provided that profiling has been
enabled for the queue.
The callbacks are called once for each element of the transform data, for
input (pre) and output (post). In this respect it es similar to an
elementwise kernel, if this is what you mean.
There are some examples on how to use callbacks (with C) link
<https://developer.amd.com/improve-fft-post-processing-performance-using-clfft-post-callback/>
hope that helps
Gregor
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#51 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC3LYYD2FJH266J7QB42HILSKMLUPANCNFSM4SLCS67A>
.
|
Hi,
Is there an example for performing the callback using the FFT high-level interface ? Do I give pass the argument to the FFT high level callback as a part of the dict only ? If yes, what keyword does it look for there ?
Secondly, in a callback function, how to access a 2D array ?
Please guide !
sincerely,
Mugundhan
The text was updated successfully, but these errors were encountered: