-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathelldev_mod.F90
321 lines (288 loc) · 12.1 KB
/
elldev_mod.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
! Parallel Sparse BLAS GPU plugin
! (C) Copyright 2013
!
! Salvatore Filippone
! Alessandro Fanfarillo
!
! Redistribution and use in source and binary forms, with or without
! modification, are permitted provided that the following conditions
! are met:
! 1. Redistributions of source code must retain the above copyright
! notice, this list of conditions and the following disclaimer.
! 2. Redistributions in binary form must reproduce the above copyright
! notice, this list of conditions, and the following disclaimer in the
! documentation and/or other materials provided with the distribution.
! 3. The name of the PSBLAS group or the names of its contributors may
! not be used to endorse or promote products derived from this
! software without specific written permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! POSSIBILITY OF SUCH DAMAGE.
!
module elldev_mod
use iso_c_binding
use core_mod
type, bind(c) :: elldev_parms
integer(c_int) :: element_type
integer(c_int) :: pitch
integer(c_int) :: rows
integer(c_int) :: columns
integer(c_int) :: maxRowSize
integer(c_int) :: avgRowSize
integer(c_int) :: firstIndex
end type elldev_parms
interface
function FgetEllDeviceParams(rows, maxRowSize, nnzeros, columns, elementType, firstIndex) &
& result(res) bind(c,name='getEllDeviceParams')
use iso_c_binding
import :: elldev_parms
type(elldev_parms) :: res
integer(c_int), value :: rows,maxRowSize,nnzeros,columns,elementType,firstIndex
end function FgetEllDeviceParams
end interface
interface
function FallocEllDevice(deviceMat,rows,maxRowSize,nnzeros,columns,&
& elementType,firstIndex) &
& result(res) bind(c,name='FallocEllDevice')
use iso_c_binding
integer(c_int) :: res
integer(c_int), value :: rows,maxRowSize,nnzeros,columns,elementType,firstIndex
type(c_ptr) :: deviceMat
end function FallocEllDevice
end interface
interface writeEllDevice
function writeEllDeviceFloat(deviceMat,val,ja,ldj,irn,idiag) &
& result(res) bind(c,name='writeEllDeviceFloat')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat
integer(c_int), value :: ldj
real(c_float) :: val(ldj,*)
integer(c_int) :: ja(ldj,*),irn(*),idiag(*)
end function writeEllDeviceFloat
function writeEllDeviceDouble(deviceMat,val,ja,ldj,irn,idiag) &
& result(res) bind(c,name='writeEllDeviceDouble')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat
integer(c_int), value :: ldj
real(c_double) :: val(ldj,*)
integer(c_int) :: ja(ldj,*),irn(*),idiag(*)
end function writeEllDeviceDouble
function writeEllDeviceFloatComplex(deviceMat,val,ja,ldj,irn,idiag) &
& result(res) bind(c,name='writeEllDeviceFloatComplex')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat
integer(c_int), value :: ldj
complex(c_float_complex) :: val(ldj,*)
integer(c_int) :: ja(ldj,*),irn(*),idiag(*)
end function writeEllDeviceFloatComplex
function writeEllDeviceDoubleComplex(deviceMat,val,ja,ldj,irn,idiag) &
& result(res) bind(c,name='writeEllDeviceDoubleComplex')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat
integer(c_int), value :: ldj
complex(c_double_complex) :: val(ldj,*)
integer(c_int) :: ja(ldj,*),irn(*),idiag(*)
end function writeEllDeviceDoubleComplex
end interface
interface readEllDevice
function readEllDeviceFloat(deviceMat,val,ja,ldj,irn,idiag) &
& result(res) bind(c,name='readEllDeviceFloat')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat
integer(c_int), value :: ldj
real(c_float) :: val(ldj,*)
integer(c_int) :: ja(ldj,*),irn(*),idiag(*)
end function readEllDeviceFloat
function readEllDeviceDouble(deviceMat,val,ja,ldj,irn,idiag) &
& result(res) bind(c,name='readEllDeviceDouble')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat
integer(c_int), value :: ldj
real(c_double) :: val(ldj,*)
integer(c_int) :: ja(ldj,*),irn(*),idiag(*)
end function readEllDeviceDouble
function readEllDeviceFloatComplex(deviceMat,val,ja,ldj,irn,idiag) &
& result(res) bind(c,name='readEllDeviceFloatComplex')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat
integer(c_int), value :: ldj
complex(c_float_complex) :: val(ldj,*)
integer(c_int) :: ja(ldj,*),irn(*),idiag(*)
end function readEllDeviceFloatComplex
function readEllDeviceDoubleComplex(deviceMat,val,ja,ldj,irn,idiag) &
& result(res) bind(c,name='readEllDeviceDoubleComplex')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat
integer(c_int), value :: ldj
complex(c_double_complex) :: val(ldj,*)
integer(c_int) :: ja(ldj,*),irn(*),idiag(*)
end function readEllDeviceDoubleComplex
end interface
interface
subroutine freeEllDevice(deviceMat) &
& bind(c,name='freeEllDevice')
use iso_c_binding
type(c_ptr), value :: deviceMat
end subroutine freeEllDevice
end interface
interface
subroutine zeroEllDevice(deviceMat) &
& bind(c,name='zeroEllDevice')
use iso_c_binding
type(c_ptr), value :: deviceMat
end subroutine zeroEllDevice
end interface
interface
subroutine resetEllTimer() bind(c,name='resetEllTimer')
use iso_c_binding
end subroutine resetEllTimer
end interface
interface
function getEllTimer() &
& bind(c,name='getEllTimer') result(res)
use iso_c_binding
real(c_double) :: res
end function getEllTimer
end interface
interface
function getEllDevicePitch(deviceMat) &
& bind(c,name='getEllDevicePitch') result(res)
use iso_c_binding
type(c_ptr), value :: deviceMat
integer(c_int) :: res
end function getEllDevicePitch
end interface
interface
function getEllDeviceMaxRowSize(deviceMat) &
& bind(c,name='getEllDeviceMaxRowSize') result(res)
use iso_c_binding
type(c_ptr), value :: deviceMat
integer(c_int) :: res
end function getEllDeviceMaxRowSize
end interface
interface psi_CopyCooToElg
function psiCopyCooToElgFloat(nr, nc, nza, hacksz, ldv, nzm, irn, &
& idisp, ja, val, deviceMat) &
& result(res) bind(c,name='psiCopyCooToElgFloat')
use iso_c_binding
integer(c_int) :: res
integer(c_int), value :: nr,nc,nza,hacksz,ldv,nzm
type(c_ptr), value :: deviceMat
real(c_float) :: val(*)
integer(c_int) :: irn(*),idisp(*),ja(*)
end function psiCopyCooToElgFloat
function psiCopyCooToElgDouble(nr, nc, nza, hacksz, ldv, nzm, irn, &
& idisp, ja, val, deviceMat) &
& result(res) bind(c,name='psiCopyCooToElgDouble')
use iso_c_binding
integer(c_int) :: res
integer(c_int), value :: nr,nc,nza,hacksz,ldv,nzm
type(c_ptr), value :: deviceMat
real(c_double) :: val(*)
integer(c_int) :: irn(*),idisp(*),ja(*)
end function psiCopyCooToElgDouble
function psiCopyCooToElgFloatComplex(nr, nc, nza, hacksz, ldv, nzm, irn, &
& idisp, ja, val, deviceMat) &
& result(res) bind(c,name='psiCopyCooToElgFloatComplex')
use iso_c_binding
integer(c_int) :: res
integer(c_int), value :: nr,nc,nza,hacksz,ldv,nzm
type(c_ptr), value :: deviceMat
complex(c_float_complex) :: val(*)
integer(c_int) :: irn(*),idisp(*),ja(*)
end function psiCopyCooToElgFloatComplex
function psiCopyCooToElgDoubleComplex(nr, nc, nza, hacksz, ldv, nzm, irn, &
& idisp, ja, val, deviceMat) &
& result(res) bind(c,name='psiCopyCooToElgDoubleComplex')
use iso_c_binding
integer(c_int) :: res
integer(c_int), value :: nr,nc,nza,hacksz,ldv,nzm
type(c_ptr), value :: deviceMat
complex(c_double_complex) :: val(*)
integer(c_int) :: irn(*),idisp(*),ja(*)
end function psiCopyCooToElgDoubleComplex
end interface
interface csputEllDeviceFloat
function dev_csputEllDeviceFloat(deviceMat, nnz, ia, ja, val) &
& result(res) bind(c,name='dev_csputEllDeviceFloat')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat , ia, ja, val
integer(c_int), value :: nnz
end function dev_csputEllDeviceFloat
end interface
interface csputEllDeviceDouble
function dev_csputEllDeviceDouble(deviceMat, nnz, ia, ja, val) &
& result(res) bind(c,name='dev_csputEllDeviceDouble')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat , ia, ja, val
integer(c_int), value :: nnz
end function dev_csputEllDeviceDouble
end interface
interface csputEllDeviceFloatComplex
function dev_csputEllDeviceFloatComplex(deviceMat, nnz, ia, ja, val) &
& result(res) bind(c,name='dev_csputEllDeviceFloatComplex')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat , ia, ja, val
integer(c_int), value :: nnz
end function dev_csputEllDeviceFloatComplex
end interface
interface csputEllDeviceDoubleComplex
function dev_csputEllDeviceDoubleComplex(deviceMat, nnz, ia, ja, val) &
& result(res) bind(c,name='dev_csputEllDeviceDoubleComplex')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat , ia, ja, val
integer(c_int), value :: nnz
end function dev_csputEllDeviceDoubleComplex
end interface
interface spmvEllDevice
function spmvEllDeviceFloat(deviceMat,alpha,x,beta,y) &
& result(res) bind(c,name='spmvEllDeviceFloat')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat, x, y
real(c_float),value :: alpha, beta
end function spmvEllDeviceFloat
function spmvEllDeviceDouble(deviceMat,alpha,x,beta,y) &
& result(res) bind(c,name='spmvEllDeviceDouble')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat, x, y
real(c_double),value :: alpha, beta
end function spmvEllDeviceDouble
function spmvEllDeviceFloatComplex(deviceMat,alpha,x,beta,y) &
& result(res) bind(c,name='spmvEllDeviceFloatComplex')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat, x, y
complex(c_float_complex),value :: alpha, beta
end function spmvEllDeviceFloatComplex
function spmvEllDeviceDoubleComplex(deviceMat,alpha,x,beta,y) &
& result(res) bind(c,name='spmvEllDeviceDoubleComplex')
use iso_c_binding
integer(c_int) :: res
type(c_ptr), value :: deviceMat, x, y
complex(c_double_complex),value :: alpha, beta
end function spmvEllDeviceDoubleComplex
end interface
end module elldev_mod