1module clfft_types
2  type clfftPlanHandle
3    private
4
5    integer, pointer :: p
6  end type clfftPlanHandle
7end module clfft_types
8
9module clfft
10  use cl
11  use clfft_types
12
13  implicit none
14
15  private
16
17  public ::                      &
18    clfftGetVersion,          &
19    clfftSetup,               &
20    clfftTeardown,            &
21    clfftPlanHandle,          &
22    clfftCreateDefaultPlan,   &
23    clfftDestroyPlan,         &
24    clfftEnqueueTransform,    &
25    clfftSetPlanPrecision,    &
26    clfftSetPlanBatchSize,    &
27    clfftSetLayout,           &
28    clfftSetResultLocation,   &
29    clfftSetPlanInStride,     &
30    clfftSetPlanOutStride,    &
31    clfftGetPlanInStride,     &
32    clfftGetPlanOutStride,    &
33    clfftSetPlanScale,        &
34    clfftGetPlanScale,        &
35    clfftBakePlan,            &
36    clfftGetTmpBufSize
37
38  integer, public, parameter ::                                                   &
39    CLFFT_INVALID_GLOBAL_WORK_SIZE         = CL_INVALID_GLOBAL_WORK_SIZE,         &
40    CLFFT_INVALID_MIP_LEVEL                = CL_INVALID_MIP_LEVEL,                &
41    CLFFT_INVALID_BUFFER_SIZE              = CL_INVALID_BUFFER_SIZE,              &
42    CLFFT_INVALID_GL_OBJECT                = CL_INVALID_GL_OBJECT,                &
43    CLFFT_INVALID_OPERATION                = CL_INVALID_OPERATION,                &
44    CLFFT_INVALID_EVENT                    = CL_INVALID_EVENT,                    &
45    CLFFT_INVALID_EVENT_WAIT_LIST          = CL_INVALID_EVENT_WAIT_LIST,          &
46    CLFFT_INVALID_GLOBAL_OFFSET            = CL_INVALID_GLOBAL_OFFSET,            &
47    CLFFT_INVALID_WORK_ITEM_SIZE           = CL_INVALID_WORK_ITEM_SIZE,           &
48    CLFFT_INVALID_WORK_GROUP_SIZE          = CL_INVALID_WORK_GROUP_SIZE,          &
49    CLFFT_INVALID_WORK_DIMENSION           = CL_INVALID_WORK_DIMENSION,           &
50    CLFFT_INVALID_KERNEL_ARGS              = CL_INVALID_KERNEL_ARGS,              &
51    CLFFT_INVALID_ARG_SIZE                 = CL_INVALID_ARG_SIZE,                 &
52    CLFFT_INVALID_ARG_VALUE                = CL_INVALID_ARG_VALUE,                &
53    CLFFT_INVALID_ARG_INDEX                = CL_INVALID_ARG_INDEX,                &
54    CLFFT_INVALID_KERNEL                   = CL_INVALID_KERNEL,                   &
55    CLFFT_INVALID_KERNEL_DEFINITION        = CL_INVALID_KERNEL_DEFINITION,        &
56    CLFFT_INVALID_KERNEL_NAME              = CL_INVALID_KERNEL_NAME,              &
57    CLFFT_INVALID_PROGRAM_EXECUTABLE       = CL_INVALID_PROGRAM_EXECUTABLE,       &
58    CLFFT_INVALID_PROGRAM                  = CL_INVALID_PROGRAM,                  &
59    CLFFT_INVALID_BUILD_OPTIONS            = CL_INVALID_BUILD_OPTIONS,            &
60    CLFFT_INVALID_BINARY                   = CL_INVALID_BINARY,                   &
61    CLFFT_INVALID_SAMPLER                  = CL_INVALID_SAMPLER
62
63  integer, public, parameter ::                                                   &
64    CLFFT_INVALID_IMAGE_SIZE               = CL_INVALID_IMAGE_SIZE,               &
65    CLFFT_INVALID_IMAGE_FORMAT_DESCRIPTOR  = CL_INVALID_IMAGE_FORMAT_DESCRIPTOR,  &
66    CLFFT_INVALID_MEM_OBJECT               = CL_INVALID_MEM_OBJECT,               &
67    CLFFT_INVALID_HOST_PTR                 = CL_INVALID_HOST_PTR,                 &
68    CLFFT_INVALID_COMMAND_QUEUE            = CL_INVALID_COMMAND_QUEUE,            &
69    CLFFT_INVALID_QUEUE_PROPERTIES         = CL_INVALID_QUEUE_PROPERTIES,         &
70    CLFFT_INVALID_CONTEXT                  = CL_INVALID_CONTEXT,                  &
71    CLFFT_INVALID_DEVICE                   = CL_INVALID_DEVICE,                   &
72    CLFFT_INVALID_PLATFORM                 = CL_INVALID_PLATFORM,                 &
73    CLFFT_INVALID_DEVICE_TYPE              = CL_INVALID_DEVICE_TYPE,              &
74    CLFFT_INVALID_VALUE                    = CL_INVALID_VALUE,                    &
75    CLFFT_MAP_FAILURE                      = CL_MAP_FAILURE,                      &
76    CLFFT_BUILD_PROGRAM_FAILURE            = CL_BUILD_PROGRAM_FAILURE,            &
77    CLFFT_IMAGE_FORMAT_NOT_SUPPORTED       = CL_IMAGE_FORMAT_NOT_SUPPORTED,       &
78    CLFFT_IMAGE_FORMAT_MISMATCH            = CL_IMAGE_FORMAT_MISMATCH,            &
79    CLFFT_MEM_COPY_OVERLAP                 = CL_MEM_COPY_OVERLAP,                 &
80    CLFFT_PROFILING_INFO_NOT_AVAILABLE     = CL_PROFILING_INFO_NOT_AVAILABLE,     &
81    CLFFT_OUT_OF_HOST_MEMORY               = CL_OUT_OF_HOST_MEMORY,               &
82    CLFFT_OUT_OF_RESOURCES                 = CL_OUT_OF_RESOURCES,                 &
83    CLFFT_MEM_OBJECT_ALLOCATION_FAILURE    = CL_MEM_OBJECT_ALLOCATION_FAILURE,    &
84    CLFFT_COMPILER_NOT_AVAILABLE           = CL_COMPILER_NOT_AVAILABLE,           &
85    CLFFT_DEVICE_NOT_AVAILABLE             = CL_DEVICE_NOT_AVAILABLE,             &
86    CLFFT_DEVICE_NOT_FOUND                 = CL_DEVICE_NOT_FOUND,                 &
87    CLFFT_SUCCESS                          = CL_SUCCESS
88
89  integer, public, parameter ::                                                   &
90    CLFFT_BUGCHECK                         = 4*1024    ,                          &
91    CLFFT_NOTIMPLEMENTED                   = 4*1024 + 1,                          &
92    CLFFT_FILE_NOT_FOUND                   = 4*1024 + 2,                          &
93    CLFFT_FILE_CREATE_FAILURE              = 4*1024 + 3,                          &
94    CLFFT_VERSION_MISMATCH                 = 4*1024 + 4,                          &
95    CLFFT_INVALID_PLAN                     = 4*1024 + 5,                          &
96    CLFFT_DEVICE_NO_DOUBLE                 = 4*1024 + 6,                          &
97    CLFFT_ENDSTATUS                        = 4*1024 + 7
98
99  integer, public, parameter ::        &
100    CLFFT_1D                      = 1, &
101    CLFFT_2D                      = 2, &
102    CLFFT_3D                      = 3, &
103    ENDDIMENSION                  = 4
104
105  integer, public, parameter ::        &
106    CLFFT_COMPLEX_INTERLEAVED     = 1, &
107    CLFFT_COMPLEX_PLANAR          = 2, &
108    CLFFT_HERMITIAN_INTERLEAVED   = 3, &
109    CLFFT_HERMITIAN_PLANAR        = 4, &
110    CLFFT_REAL                    = 5, &
111    ENDLAYOUT                     = 6
112
113  integer, public, parameter ::        &
114    CLFFT_SINGLE                  = 1, &
115    CLFFT_DOUBLE                  = 2, &
116    CLFFT_SINGLE_FAST             = 3, &
117    CLFFT_DOUBLE_FAST             = 4, &
118    ENDPRECISION                  = 5
119
120  integer, public, parameter ::         &
121    CLFFT_FORWARD                 = -1, &
122    CLFFT_BACKWARD                =  1, &
123    CLFFT_MINUS                   = -1, &
124    CLFFT_PLUS                    =  1, &
125    ENDDIRECTION                  =  2
126
127  integer, public, parameter ::        &
128    CLFFT_INPLACE                 = 1, &
129    CLFFT_OUTOFPLACE              = 2, &
130    ENDPLACE                      = 3
131  ! ---------------------------------------------------------
132
133  interface clfftGetVersion
134    subroutine clfftgetversion_low(major, minor, patch, status)
135      implicit none
136
137      integer, intent(out) :: major
138      integer, intent(out) :: minor
139      integer, intent(out) :: patch
140      integer, intent(out) :: status
141    end subroutine clfftgetversion_low
142  end interface clfftGetVersion
143
144  ! ---------------------------------------------------------
145
146  interface clfftSetup
147    subroutine clfftsetup_low(status)
148      implicit none
149
150      integer, intent(out) :: status
151    end subroutine clfftsetup_low
152  end interface clfftSetup
153
154  ! ---------------------------------------------------------
155
156  interface clfftTeardown
157    subroutine clfftteardown_low()
158    end subroutine clfftteardown_low
159  end interface clfftTeardown
160
161  ! ---------------------------------------------------------
162
163  interface clfftCreateDefaultPlan
164    subroutine clfftcreatedefaultplan_low(plHandle, context, dim, clLengths, status)
165      use cl
166      use clfft_types
167
168      implicit none
169
170      type(clfftPlanHandle), intent(out)   :: plHandle
171      type(cl_context),         intent(inout) :: context
172      integer,                  intent(in)    :: dim
173      integer(8),               intent(in)    :: clLengths(1:dim)
174      integer,                  intent(out)   :: status
175    end subroutine clfftcreatedefaultplan_low
176  end interface clfftCreateDefaultPlan
177
178  ! ---------------------------------------------------------
179
180  interface clfftDestroyPlan
181    subroutine clfftdestroyplan_low(plHandle, status)
182      use clfft_types
183
184      implicit none
185
186      type(clfftPlanHandle), intent(inout) :: plHandle
187      integer,                  intent(out)   :: status
188    end subroutine clfftdestroyplan_low
189  end interface clfftDestroyPlan
190
191  ! ---------------------------------------------------------
192
193  interface clfftEnqueueTransform
194
195    subroutine clfftenqueuetransform_low(plHandle, dir, commQueues, inputBuffers, outputBuffers, status)
196      use cl
197      use clfft_types
198
199      implicit none
200
201      type(clfftPlanHandle), intent(out)   :: plHandle
202      integer,                  intent(in)    :: dir
203      type(cl_command_queue),   intent(inout) :: commQueues
204      type(cl_mem),             intent(in)    :: inputBuffers
205      type(cl_mem),             intent(inout) :: outputBuffers
206      integer,                  intent(out)   :: status
207    end subroutine clfftenqueuetransform_low
208
209    subroutine clfftenqueuetransform_tmpbuf_low(plHandle, dir, commQueues, inputBuffers, outputBuffers, tmpBuffer, status)
210      use cl
211      use clfft_types
212
213      implicit none
214
215      type(clfftPlanHandle), intent(out)   :: plHandle
216      integer,                  intent(in)    :: dir
217      type(cl_command_queue),   intent(inout) :: commQueues
218      type(cl_mem),             intent(in)    :: inputBuffers
219      type(cl_mem),             intent(inout) :: outputBuffers
220      type(cl_mem),             intent(inout) :: tmpBuffer
221      integer,                  intent(out)   :: status
222    end subroutine clfftenqueuetransform_tmpbuf_low
223
224  end interface clfftEnqueueTransform
225
226  ! ---------------------------------------------------------
227
228  interface clfftSetPlanPrecision
229    subroutine clfftSetPlanPrecision_low(plHandle, precision, status)
230      use clfft_types
231
232      implicit none
233
234      type(clfftPlanHandle), intent(inout) :: plHandle
235      integer,                  intent(in)    :: precision
236      integer,                  intent(out)   :: status
237    end subroutine clfftSetPlanPrecision_low
238  end interface clfftSetPlanPrecision
239
240  ! ---------------------------------------------------------
241
242  interface clfftSetPlanBatchSize
243    subroutine clfftSetPlanBatchSize_low(plHandle, batchSize, status)
244      use clfft_types
245
246      implicit none
247
248      type(clfftPlanHandle), intent(inout) :: plHandle
249      integer(8),               intent(in)    :: batchSize
250      integer,                  intent(out)   :: status
251    end subroutine clfftSetPlanBatchSize_low
252  end interface clfftSetPlanBatchSize
253
254  ! ---------------------------------------------------------
255
256  interface clfftSetLayout
257    subroutine clfftSetLayout_low(plHandle, iLayout, oLayout, status)
258      use clfft_types
259
260      implicit none
261
262      type(clfftPlanHandle), intent(inout) :: plHandle
263      integer,                  intent(in)    :: iLayout
264      integer,                  intent(in)    :: oLayout
265      integer,                  intent(out)   :: status
266    end subroutine clfftSetLayout_low
267  end interface clfftSetLayout
268
269  ! ---------------------------------------------------------
270
271  interface clfftSetResultLocation
272    subroutine clfftSetResultLocation_low(plHandle, placeness, status)
273      use clfft_types
274
275      implicit none
276
277      type(clfftPlanHandle), intent(inout) :: plHandle
278      integer,                  intent(in)    :: placeness
279      integer,                  intent(out)   :: status
280    end subroutine clfftSetResultLocation_low
281  end interface clfftSetResultLocation
282
283  ! ---------------------------------------------------------
284
285  interface clfftSetPlanInStride
286    subroutine clfftSetPlanInStride_low(plHandle, dim, clStrides, status)
287      use clfft_types
288
289      implicit none
290
291      type(clfftPlanHandle), intent(inout) :: plHandle
292      integer,                  intent(in)    :: dim
293      integer(8),               intent(in)    :: clStrides(1:dim)
294      integer,                  intent(out)   :: status
295    end subroutine clfftSetPlanInStride_low
296  end interface clfftSetPlanInStride
297
298  ! ---------------------------------------------------------
299
300  interface clfftSetPlanOutStride
301    subroutine clfftSetPlanOutStride_low(plHandle, dim, clStrides, status)
302      use clfft_types
303
304      implicit none
305
306      type(clfftPlanHandle), intent(inout) :: plHandle
307      integer,                  intent(in)    :: dim
308      integer(8),               intent(in)    :: clStrides(1:dim)
309      integer,                  intent(out)   :: status
310    end subroutine clfftSetPlanOutStride_low
311  end interface clfftSetPlanOutStride
312
313  ! ---------------------------------------------------------
314
315  interface clfftGetPlanInStride
316    subroutine clfftGetPlanInStride_low(plHandle, dim, clStrides, status)
317      use clfft_types
318
319      implicit none
320
321      type(clfftPlanHandle), intent(inout) :: plHandle
322      integer,                  intent(in)    :: dim
323      integer(8),               intent(out)   :: clStrides(1:dim)
324      integer,                  intent(out)   :: status
325    end subroutine clfftGetPlanInStride_low
326  end interface clfftGetPlanInStride
327
328  ! ---------------------------------------------------------
329
330  interface clfftGetPlanOutStride
331    subroutine clfftGetPlanOutStride_low(plHandle, dim, clStrides, status)
332      use clfft_types
333
334      implicit none
335
336      type(clfftPlanHandle), intent(inout) :: plHandle
337      integer,                  intent(in)    :: dim
338      integer(8),               intent(out)   :: clStrides(1:dim)
339      integer,                  intent(out)   :: status
340    end subroutine clfftGetPlanOutStride_low
341  end interface clfftGetPlanOutStride
342  ! ---------------------------------------------------------
343
344  interface clfftSetPlanScale
345    subroutine clfftSetPlanScale_low(plHandle, dir, scale, status)
346      use clfft_types
347
348      implicit none
349
350      type(clfftPlanHandle), intent(inout) :: plHandle
351      integer,                  intent(in)    :: dir
352      real(8),                  intent(in)    :: scale
353      integer,                  intent(out)   :: status
354    end subroutine clfftSetPlanScale_low
355  end interface clfftSetPlanScale
356
357  ! ---------------------------------------------------------
358
359  interface clfftGetPlanScale
360    subroutine clfftGetPlanScale_low(plHandle, dir, scale, status)
361      use clfft_types
362
363      implicit none
364
365      type(clfftPlanHandle), intent(inout) :: plHandle
366      integer,                  intent(in)    :: dir
367      real(8),                  intent(out)   :: scale
368      integer,                  intent(out)   :: status
369    end subroutine clfftGetPlanScale_low
370  end interface clfftGetPlanScale
371
372  ! ---------------------------------------------------------
373
374  interface clfftBakePlan
375    subroutine clfftBakePlan_low(plHandle, commQueues, status)
376      use cl
377      use clfft_types
378
379      implicit none
380
381      type(clfftPlanHandle), intent(inout) :: plHandle
382      type(cl_command_queue),   intent(inout) :: commQueues
383      integer,                  intent(out)   :: status
384    end subroutine clfftBakePlan_low
385  end interface clfftBakePlan
386
387  ! ---------------------------------------------------------
388
389  interface clfftGetTmpBufSize
390    subroutine clfftGetTmpBufSize_low(plHandle, buffersize, status)
391      use cl
392      use clfft_types
393
394      implicit none
395
396      type(clfftPlanHandle), intent(in)    :: plHandle
397      integer(8),               intent(out)   :: buffersize
398      integer,                  intent(out)   :: status
399    end subroutine clfftGetTmpBufSize_low
400  end interface clfftGetTmpBufSize
401
402
403end module clfft
404