41 use,
intrinsic :: iso_c_binding
46 real(kind=
rp),
allocatable :: x(:,:)
47 character(len=NEKO_VARNAME_LEN) :: name =
""
48 type(c_ptr) :: x_d = c_null_ptr
49 integer,
private :: nrows = 0
50 integer,
private :: ncols = 0
51 integer,
private :: n = 0
93 integer,
intent(in) :: nrows
94 integer,
intent(in) :: ncols
95 character(len=*),
intent(in),
optional :: name
102 call m%alloc(nrows, ncols)
105 if (
present(name))
then
117 integer,
intent(in) :: nrows
118 integer,
intent(in) :: ncols
122 allocate(m%x(nrows, ncols))
139 if (
allocated(m%x))
then
167 integer,
intent(in) :: memdir
168 logical,
intent(in) :: sync
194 dims = [m%nrows, m%ncols]
202 if (
allocated(m%x))
then
206 if (.not.
allocated(m%x))
then
211 allocate(m%x(m%nrows, m%ncols))
232 real(kind=
rp),
intent(in) :: s
234 if (.not.
allocated(m%x))
then
248 integer,
optional :: bcknd
253 &implemented on accelarators.")
266 integer :: indr(m%nrows), indc(m%ncols), ipiv(m%ncols)
267 real(kind=
xp) :: rmult(m%nrows), amx, tmp, piv, eps
268 integer :: i, j, k, ir, jc
270 if (.not. (m%ncols .eq. m%nrows))
then
271 call neko_error(
"Fatal error: trying to invert m matrix that is not &
281 if (ipiv(i) .ne. 1)
then
283 if (ipiv(j) .eq. 0)
then
284 if (abs(m%x(i, j)) .ge. amx)
then
289 else if (ipiv(j) .gt. 1)
then
295 ipiv(jc) = ipiv(jc) + 1
301 m%x(ir, j) = m%x(jc, j)
308 if (abs(m%x(jc, jc)) .lt. eps)
then
309 call neko_error(
"matrix_inverse error: small Gauss Jordan Piv")
311 piv = 1.0_xp/m%x(jc, jc)
314 m%x(jc, j) = m%x(jc, j)*piv
319 m%x(jc, j) = m%x(1 , j)
323 rmult(i) = m%x(i, jc)
329 m%x(i, j) = m%x(i, j) - rmult(i)*m%x(1, j)
335 m%x(jc, j) = m%x(1 , j)
341 do j = m%nrows, 1, -1
342 if (indr(j) .ne. indc(j))
then
344 tmp = m%x(i, indr(j))
345 m%x(i, indr(j)) = m%x(i, indc(j))
346 m%x(i, indc(j)) = tmp
Map a Fortran array to a device (allocate and associate)
Copy data between host and device (or device and device)
Synchronize a device or stream.
Unmap a Fortran array from a device (deassociate and free)
subroutine, public device_copy(a_d, b_d, n, strm)
Copy a vector .
subroutine, public device_cfill(a_d, c, n, strm)
Set all elements to a constant c .
Device abstraction, common interface for various accelerators.
subroutine matrix_free(m)
Deallocate a matrix.
subroutine matrix_bcknd_inverse(m, bcknd)
pure integer function matrix_ncols(m)
Returns the number of columns in the matrix.
subroutine matrix_assign_matrix(m, w)
Assignment .
pure integer function, dimension(2) matrix_dims(m)
Returns the dimensions of the matrix.
subroutine cpu_matrix_inverse(m)
pure integer function matrix_nrows(m)
Returns the number of rows in the matrix.
subroutine matrix_init(m, nrows, ncols, name)
Initialise a matrix of size nrows*ncols.
pure integer function matrix_size(m)
Returns the number of entries in the matrix.
subroutine matrix_copy_from(m, memdir, sync)
Easy way to copy between host and device.
subroutine matrix_assign_scalar(m, s)
Assignment .
subroutine matrix_allocate(m, nrows, ncols)
Allocate a matrix of size nrows*ncols.
integer, parameter neko_bcknd_device
integer, parameter, public xp
integer, parameter, public rp
Global precision used in computations.
integer, parameter, public neko_varname_len