Skip to content

Integration of transform-agnostic memory objects (cl_mem, clfft) #24

Description

@tdd11235813

Hi,
just need to write down some ongoing developments.
For the testOpenCL.cpp from PR #22 I tried to test liFFT together with cl_mem.
cl_mem encapsulates OpenCL data and does not offer an accessor and type interface.
As far as I know, the existing liFFT interfaces cannot deal with transform-agnostic memory objects.
cl_mem is not an array like type and not an integral type, so liFFT requires meta-data wrapped around cl_mem.

Test scheme, which I want to use:

cl_mem dat1 = clCreateBuffer(...);
cl_mem dat2 = clCreateBuffer(...);
using FFT = LiFFT::FFT_2D_C2C<TestPrecision>;
auto inWrapped  = FFT::wrapInput(  LiFFT::mem::wrapLibPtr<FFT::isComplexInput> 
                                   (dat1, TestExtents(testSize, testSize)) );  
auto outWrapped = FFT::wrapOutput( LiFFT::mem::wrapLibPtr<FFT::isComplexOutput>
                                   (dat2, TestExtents(testSize, testSize)) );  
auto fft = LiFFT::makeFFT<TestLibrary>(inWrapped, outWrapped);
fft(inWrapped, outWrapped);
LiFFT::policies::copy(inWrapped, baseR2CInput);

wrapLibPtr should wrap the cl_mem (_cl_mem*) in order to return a DataContainer like PlainPtrWrapper. Latter one cannot be used due to validating against Real and Complex types.

// Generally, in the liFFT backend non-integral types are required to be wrapped containing FFT properties. FFT_Definition type also contains all the FFT properties. It is used to validate those data objects given to liFFT. Giving raw pointer to liFFT would work for floats or doubles, however for complex numbers a raw float array would fail to compile.

Anyway, cl_mem needs a wrapper class. I would call it LibPtr for now.
I would mimic the Real or Complex type containing proper meta data, but they only would return the pointer itself.
I would mark it as device pointer, where CPU also is a device, namely an OpenCL device.
Since, PlainPtrWrapper is too specific about transform types, it would require an own DataContainer type, but I dont know if this would work in the end.

Am I on the right path or do you see better way of integration for this use case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions