{"action":"created","issue":{"url":"https://api.github.com/repos/cupy/cupy/issues/1669","repository_url":"https://api.github.com/repos/cupy/cupy","labels_url":"https://api.github.com/repos/cupy/cupy/issues/1669/labels{/name}","comments_url":"https://api.github.com/repos/cupy/cupy/issues/1669/comments","events_url":"https://api.github.com/repos/cupy/cupy/issues/1669/events","html_url":"https://github.com/cupy/cupy/issues/1669","id":365250038,"node_id":"MDU6SXNzdWUzNjUyNTAwMzg=","number":1669,"title":"Need in-place C2C & Z2Z FFT for better performance","user":{"login":"leofang","id":5534781,"node_id":"MDQ6VXNlcjU1MzQ3ODE=","avatar_url":"https://avatars1.githubusercontent.com/u/5534781?v=4","gravatar_id":"","url":"https://api.github.com/users/leofang","html_url":"https://github.com/leofang","followers_url":"https://api.github.com/users/leofang/followers","following_url":"https://api.github.com/users/leofang/following{/other_user}","gists_url":"https://api.github.com/users/leofang/gists{/gist_id}","starred_url":"https://api.github.com/users/leofang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leofang/subscriptions","organizations_url":"https://api.github.com/users/leofang/orgs","repos_url":"https://api.github.com/users/leofang/repos","events_url":"https://api.github.com/users/leofang/events{/privacy}","received_events_url":"https://api.github.com/users/leofang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-30T18:46:16Z","updated_at":"2018-09-30T19:47:17Z","closed_at":null,"author_association":"NONE","body":"Hello it's me again. I am migrating another set of codes to CuPy. This program heavily relies on C2C & Z2Z (complex-to-complex, single/double precision) FFT (we spend >50% of runtime in FFT), and I notice that CuPy's FFT wrapper always does an \"out of place\" transform; that is, all routines in the `cupy.fft` family allocate an additional buffer during FFT at this line https://github.com/cupy/cupy/blob/5e17c157faa60bedacd6d6cbdc51d63e7145c80d/cupy/fft/fft.py#L74\r\n, causing highly redundant data movement in our code (nvprof shows ~25% of time spent here). \r\n\r\nHowever, according to the cuFFT doc it supports in-place C2C & Z2Z FFT, so it'd be nice if this feature can be added. Perhaps we can have an additional flag for users to make their own decision, or we can also compare the in and out buffer to decide if in place or not under the hood, see for example scikit-cuda's implementation at https://github.com/lebedov/scikit-cuda/blob/87f34fbe09d45825b2214665d5aa8c4da9e2ffdb/skcuda/fft.py#L195 \r\n(this may not be easy to achieve based on the current API design though).\r\nIf you do not have the bandwidth to support this in the near future, I might be able to create a PR. Let me know what you think.\r\n\r\nThank you very much."},"comment":{"url":"https://api.github.com/repos/cupy/cupy/issues/comments/425746417","html_url":"https://github.com/cupy/cupy/issues/1669#issuecomment-425746417","issue_url":"https://api.github.com/repos/cupy/cupy/issues/1669","id":425746417,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTc0NjQxNw==","user":{"login":"grlee77","id":6528957,"node_id":"MDQ6VXNlcjY1Mjg5NTc=","avatar_url":"https://avatars3.githubusercontent.com/u/6528957?v=4","gravatar_id":"","url":"https://api.github.com/users/grlee77","html_url":"https://github.com/grlee77","followers_url":"https://api.github.com/users/grlee77/followers","following_url":"https://api.github.com/users/grlee77/following{/other_user}","gists_url":"https://api.github.com/users/grlee77/gists{/gist_id}","starred_url":"https://api.github.com/users/grlee77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grlee77/subscriptions","organizations_url":"https://api.github.com/users/grlee77/orgs","repos_url":"https://api.github.com/users/grlee77/repos","events_url":"https://api.github.com/users/grlee77/events{/privacy}","received_events_url":"https://api.github.com/users/grlee77/received_events","type":"User","site_admin":false},"created_at":"2018-09-30T19:47:17Z","updated_at":"2018-09-30T19:47:17Z","author_association":"NONE","body":"Hi @leofang \r\nI recently implemented this for `fftn` and `ifftn` and was planning to make a PR.  If you want to test it or collaborate on improvements, that would be welcome.\r\n\r\nI am not sure exactly how it can best fit into `cupy` as it introduces a couple of keyword arguments that are not part of the NumPy API.\r\n\r\nSpecifically, if you want to try it you can use the following branch:\r\nhttps://github.com/grlee77/cupy/tree/cufftn/\r\nI have only modified `cupy.fft.fftn` and `cupy.fft.ifftn` to use n-dimensional plans and potential in-place operation. To try it, you need to set `plan_type='nd'` and pass in your preallocated array via the `out` kwarg.  The PR also allows precomputing and storing the plan via a new function `cupy.fft.get_cufft_plan_nd` which can also be passed in via the `plan` kwarg.\r\nFor the 2D and 3D FFTs I have been using, the n-d planning and preallocating the plan make a much bigger difference than the use of an in-place array.  I have seen an order of magnitude improvement in some situations. \r\n"}}
{"actor":{"display_login":"grlee77"}}