-
Notifications
You must be signed in to change notification settings - Fork 85
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
C API feedback #1
Comments
I'm having trouble with this part of the example: // get pointers to enable read/write of data // initialize input The get_ptr return is something like a blocking clEnqueueMapBuffer call. How do you tell the API that you're done with the pointer and to migrate the data back to the device? Or if you prefer AMP concepts, the get_ptr return is something like an array_view, and there needs to be a call to synchronize() to copy it to the device. |
Shouldn't there be a size_in_bytes or some other argument to buffer_create_with_ptr to enable some basic range checking? |
After thinking about this a bit more, with some more discussion/inputs from Kent and Timmy, here are my thoughts: First, here are some of the assumptions.
Given this, I propose 2 approaches to managing device memory Approach 1:
In adition to rocFFT interface, we provide an exact replica of FFTW interface (which hides all GPU programming) to support other languages. Here, we manage all device memory within the library; the user only sees host memory regions with calls to fftw_malloc etc. Within the execute API function, we copy data from host to device, do compute immediately and write it back; there is performance implication with this though but we keep the semblance of an ordinary C library to the user Approach 2:
Providing replica FFTW interface is not needed in this case, but can be done for convenience. My current rocFFT header kind of followed approach 2, but I realize I have not provided all of the features. I only created entry points for allocation/freeing of device memory. There is no explicit api for copying of data between host and device. I assumed the application developer can always use HIP functions for these; but I realize this is not an option for other language programmers. I feel that if we are going to have a library abstraction layer that deals with memory management, then we should have it independent of rocFFT. Maybe a base/common library that other libs such as rocBLAS can use. I am starting to favor approach 1. I am going to delete memory related APIs from rocFFT. I can document how device memory created with HIP or HC C++ need to be passed to the library. There would not be any type safety though, with void pointer arguments. @b-sumner with regard to your question above, my idea with the function 'rocfft_buffer_get_ptr' is to give the pointer created by call to hipMalloc inside the library back to the user and it is a very simple non blocking call. This pointer would be useless for de-referencing or pointer arithmetic on the host side. |
I am also an advocate of approach 1
I think this should just be framed to say that native C interfaces enable language wrappers. It can be used by anybody, and anybody can make a language wrapper if they so desire.
void* can come from mutliple sources: hipMalloc, hc::am_alloc and clSVMalloc(). So, void* should enable a very flexible, non-typed interface
I would say we provide FFTW interfaces to facilitate quick CPU ports. I don't think the primary purpose should be to enable other language wrappers; they should wrap the native C interface. |
Thanks for feedback Kent, I am in agreement. I think it would be good to show example wrappers for other languages such as python/fortran, to show the possibility and to provoke interest. |
Ya, I think we should provide wrappers for c++ and python. C++ will be more under our direct control. We will need to figure out how to create queues and allocate device memory in python, but i think there will be a way. I think python will be the next easiest, not sure how to make queues or device memory in fortran. It might mean making wrappers for hip or hc. |
Is there any reason both input and output to the execute function are pointers to arrays?https://github.com/RadeonOpenCompute/rocFFT/blob/master/src/include/rocfft.h#L91 Shouldn't the input just be an array and output be pointer to an array ideally ? |
Now that I think about it, neither one of them needs to be a pointer to an array since output is pre-allocated. Is this done in case the n transforms are not part of the same buffer? |
@pavanky the reason is to support planar formats. Both in & out are pointers to array of void-pointers. This 'array' length is either 1 or 2. It is 1 if the data is in complex interleaved format (1 buffer has both real & imaginary) and 2 if the data is in complex planar format (real and imaginary in separate buffers). |
@bragadeesh Yeah that makes sense. thanks for the clarification. |
Lets use this issue tracker to comment on C API design.
The text was updated successfully, but these errors were encountered: