USE iso_c_binding
IMPLICIT NONE
INTEGER :: i, j
INTEGER(KIND=RSB_BLAS_IDX_KIND) :: istat = 0, res
TYPE(C_PTR),TARGET :: mtxAp = c_null_ptr
INTEGER :: A
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: incx = 1
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: incy = 1
REAL(KIND=8),parameter :: alpha = 3
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: nr = 20
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: nc = nr
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: nnz = (nr*(nr+1))/2
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: nrhs = 1
INTEGER(KIND=RSB_IDX_KIND) :: nt = 0
INTEGER :: ic, ir
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: IA(nnz) = (/ (((ir), ic=1,ir), ir=1,nr ) /)
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: JA(nnz) = (/ (((ic), ic=1,ir), ir=1,nr ) /)
REAL(KIND=8),parameter :: va(nnz) = (/ ((1, ic=1,ir), ir=1,nr ) /)
REAL(KIND=8) :: x(nc,nrhs) = reshape((/((1), ic=1,nc*nrhs)/),[nc,nrhs])
REAL(KIND=8),parameter :: cy(nr,nrhs) = reshape((/((alpha+alpha*nr), ir=1,nr*nrhs)/),[nr,nrhs])
REAL(KIND=8) :: y(nr,nrhs) = reshape((/((alpha), ir=1,nr*nrhs)/),[nr,nrhs])
res = 0
IF (res.NE.0) GOTO 9999
IF (istat.NE.0) GOTO 9997
IF (istat.NE.0) print *,"autotuning returned nonzero:", istat &
&," ...did you enable autotuning ?"
IF (istat.NE.0) GOTO 9997
IF (istat.NE.0) GOTO 9997
IF (nt.NE.0) print*,"autotuner chose ",nt," threads"
IF (istat.NE.0) GOTO 9997
DO j = 1, nrhs
CALL usmv(transn,alpha,a,x(:,j),incx,y(:,j),incy,istat)
END DO
IF (istat.NE.0) GOTO 9997
DO j = 1, nrhs
DO i = 1, nr
IF (y(i,j).NE.cy(i,j)) print *, "first check results are not ok"
IF (y(i,j).NE.cy(i,j)) GOTO 9997
END DO
END DO
y(:,:) = alpha
IF (istat.NE.0) GOTO 9997
DO j = 1, nrhs
CALL usmv(transn,alpha,a,x(:,j),incx,y(:,j),incy,istat)
END DO
IF (istat.NE.0) GOTO 9997
DO j = 1, nrhs
DO i = 1, nr
IF (y(i,j).NE.cy(i,j)) print *,"second check results are not ok"
IF (y(i,j).NE.cy(i,j)) GOTO 9997
END DO
END DO
print *, "check results are ok"
GOTO 9998
9997 res = -1
9998 CONTINUE
IF (istat.NE.0) res = -1
9999 CONTINUE
USE iso_c_binding
IMPLICIT NONE
INTEGER(KIND=RSB_IDX_KIND) :: res
INTEGER :: j
INTEGER(KIND=RSB_BLAS_IDX_KIND) :: istat = 0
INTEGER :: A
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: incx = 1
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: incy = 1
COMPLEX(KIND=8),PARAMETER :: alpha = 3
INTEGER(KIND=RSB_IDX_KIND) :: nr
INTEGER(KIND=RSB_IDX_KIND) :: nc
INTEGER(KIND=RSB_IDX_KIND) :: nz
INTEGER(KIND=RSB_IDX_KIND) :: st
INTEGER(KIND=RSB_IDX_KIND),PARAMETER :: nrhs = 4
COMPLEX(KIND=8), ALLOCATABLE, TARGET, DIMENSION(:,:) :: x
COMPLEX(KIND=8), ALLOCATABLE, TARGET, DIMENSION(:,:) :: y
CHARACTER(KIND=C_CHAR,LEN=7),TARGET :: filename = 'pd.mtx'//c_null_char
REAL(KIND=c_double) :: mvt,mmt,omt
INTEGER(KIND=C_INT),TARGET::IZERO=0
res = 0
print*,"Read matrix ",filename(1:6)," ",nr,"x",nc,":",nz
IF (st .EQ. 1) print*,"Matrix has no symmetry"
IF (st .EQ. 1) print*,"Matrix is upper symmetric"
IF (st .EQ. 1) print*,"Matrix is upper hermitian"
IF (istat.NE.0) GOTO 9997
WRITE(*,'(a,i0)') "Using NRHS=",nrhs
ALLOCATE( x(nc,nrhs))
ALLOCATE( y(nr,nrhs))
x = 1.0
y = 0.0
DO j = 1, nrhs
CALL usmv(transn,alpha,a,x(:,j),incx,y(:,j),incy,istat)
END DO
IF (istat.NE.0) GOTO 9997
WRITE(*,'(a,e12.4,a)') "Repeated USMV took ",mvt," s"
y = 0.0
IF (istat.NE.0) GOTO 9997
WRITE(*,'(a,e12.4,a)') "A single USMM took ",mmt," s"
WRITE(*,'(a,g11.4,a)')"USMM-to-USMV speed ratio is is ", mvt/mmt, "x"
print*,"Call auto-tuning routine.."
IF (res.NE.0) GOTO 9997
IF (istat.NE.0) GOTO 9997
IF (istat.NE.0) GOTO 9997
print*,"Repeat measurement."
y = 0.0
IF (istat.NE.0) GOTO 9997
WRITE(*,'(a,e12.4,a)') "Tuned USMM took ",omt," s"
WRITE(*,'(a,g11.4,a)')"Tuned-to-untuned speed ratio is is ",mmt/omt,"x"
GOTO 9998
9997 res = -1
9998 CONTINUE
IF (istat.NE.0) res = -1
USE iso_c_binding
IMPLICIT NONE
INTEGER :: passed = 0, failed = 0
INTEGER(KIND=RSB_IDX_KIND) :: res
TYPE(C_PTR),PARAMETER :: EO = c_null_ptr
TYPE(C_PTR),PARAMETER :: IO = c_null_ptr
INTEGER(KIND=C_INT),TARGET::IONE=1
IF (res.LT.0) failed = failed + 1
IF (res.EQ.0) passed = passed + 1
IF (res.LT.0) failed = failed + 1
IF (res.EQ.0) passed = passed + 1
print *, "FAILED:", failed
print *, "PASSED:", passed
IF (failed .GT. 0) THEN
stop 1
END IF
END PROGRAM
auto main() -> int
Definition: assemble.cpp:38
@ blas_no_trans
Definition: blas_sparse.h:32
@ blas_num_nonzeros
Definition: blas_sparse.h:129
@ blas_num_cols
Definition: blas_sparse.h:128
@ blas_num_rows
Definition: blas_sparse.h:127
@ blas_invalid_handle
Definition: blas_sparse.h:133
@ blas_upper_symmetric
Definition: blas_sparse.h:114
@ blas_upper_hermitian
Definition: blas_sparse.h:116
@ blas_general
Definition: blas_sparse.h:107
@ blas_lower_symmetric
Definition: blas_sparse.h:113
@ blas_colmajor
Definition: blas_sparse.h:28
@ blas_rsb_autotune_next_operation
Definition: blas_sparse.h:153
@ blas_rsb_spmv_autotuning_off
Definition: blas_sparse.h:148
@ blas_rsb_spmv_autotuning_on
Definition: blas_sparse.h:147
subroutine blas_sparse_io_example(res)
Definition: fortran.F90:126
subroutine blas_sparse_mod_example(res)
Definition: fortran.F90:27
Definition: rsb_blas_sparse.F90:243
inserts multiple entries
Definition: rsb_blas_sparse.F90:49
multiplication : c <- beta c + alpha A b
Definition: rsb_blas_sparse.F90:126
multiplication : c <- beta c + alpha A b
Definition: rsb_blas_sparse.F90:104
ISO C BINDING interface to rsb_blas_file_mtx_load.
Definition: rsb.F90:864
ISO C BINDING interface to rsb_file_mtx_save.
Definition: rsb.F90:745
ISO C BINDING interface to rsb_lib_exit.
Definition: rsb.F90:107
ISO C BINDING interface to rsb_lib_init.
Definition: rsb.F90:49
ISO C BINDING interface to rsb_lib_set_opt.
Definition: rsb.F90:83
ISO C BINDING interface to rsb_time.
Definition: rsb.F90:851
Definition: rsb_blas_sparse.F90:29
subroutine usgp(A, pname, istat)
Get a matrix property.
Definition: rsb_blas_sparse.F90:301
subroutine ussp(A, pname, istat)
Set a matrix property. Should be called just after creation, before nonzeroes insertion.
Definition: rsb_blas_sparse.F90:324
subroutine uscr_end(A, istat)
Makes an assembled matrix out of a matrix in build state. After this, it is not possible anymore to i...
Definition: rsb_blas_sparse.F90:279
subroutine usds(A, istat)
Destroys a matrix.
Definition: rsb_blas_sparse.F90:259
subroutine duscr_begin(m, n, A, istat)
Allocates an empty matrix (A) and leaves it in build state.
Definition: rsb_blas_sparse.F90:375
integer, parameter rsb_idx_kind
Definition: rsb.F90:15
integer(c_signed_char), parameter rsb_numerical_type_double_complex
Definition: rsb.F90:1081
integer(c_int), parameter rsb_io_want_extra_verbose_interface
See RSB_IO_WANT_EXTRA_VERBOSE_INTERFACE.
Definition: rsb.F90:1111
integer(c_int), parameter rsb_io_want_verbose_tuning
See RSB_IO_WANT_VERBOSE_TUNING.
Definition: rsb.F90:1138