You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BLAS/LAPACK routines mostly use assumed size arrays, thus contiguous arrays, but can handle non contiguous data by using the inc*/ld* arguments.
In the modern wrapper (e.g. solve) you are developing, you are defining assumed-shape arguments, which is a good thing.
The problem is that compilers may/will generate copy-in/copy-out in the underlying calls to the LAPACK routines.
subroutinebrand_new(A)
real, intent(inout) :: A(:,:)
interface
subroutineold_timer(n,A,lda)
integer n, lda
real A(lda,*)
endsubroutine old_timer
end interface
n =size(A,1)
call old_timer(n,A,n) ! possible copy-in/copy-out at this point
endsubroutine brand_new
How can we avoid that? We talked about inquiring the strides, using the C interoperability and the C array descriptors. So it could look like:
subroutinebrand_new(A)
real, intent(inout) :: A(:,:)
interface
subroutineold_timer(n,A,lda)
integer n, lda
real A(lda,*)
endsubroutine old_timer
end interface
n =size(A,1)
inc = stride(A,1) ! C routine behind
lda = stride(A,2) ! C routine behind
if (inc == 1) thencall old_timer(n,A(1,1),lda) ! not nice, but supposed to work and avoid copy-in/copy-outelsecall old_timer(n,A,n) ! copy-in/copy-out cannot be avoided in this case
end ifendsubroutine brand_new
What do you think ?
The text was updated successfully, but these errors were encountered:
We already discussed that on Discourse.
BLAS/LAPACK routines mostly use assumed size arrays, thus contiguous arrays, but can handle non contiguous data by using the
inc*
/ld*
arguments.In the modern wrapper (e.g.
solve
) you are developing, you are defining assumed-shape arguments, which is a good thing.The problem is that compilers may/will generate copy-in/copy-out in the underlying calls to the LAPACK routines.
How can we avoid that? We talked about inquiring the strides, using the C interoperability and the C array descriptors. So it could look like:
What do you think ?
The text was updated successfully, but these errors were encountered: