Returns the switchover value for a positional array argument for a specified BLAS routine.
CUBLAS_GET
— The array size switchover value used to switch between use of
the NVIDIA device or standard Fortran BLAS routine. (Output)
When
ARRAY_ARGUMENT
is set to 4, the return value will be 0 or 1 indicating whether the Fortran BLAS
routine was used on the last use of the specified routine. ( 0 = Fortran BLAS
was used , 1= NVIDIA device was used).
ENUM — An
enumerator which specifies the BLAS routine for which the switchover value is
described. (Input)
ENUM must be one of
the values defined in Tables 9.3, 9.4, or 9.5.
ARRAY_ARGUMENT —
An integer indicating the array argument of the BLAS routine for which
information is to be retrieved. The array argument is specified by its position
in the calling sequence, i.e. 1 = array argument 1, 2 = array argument 2,
etc. (Input)
For example, for the BLAS routine SGEMM, array A
is ARRAY_ARGUMENT =1,
array B is ARRAY_ARGUMENT = 2,
and array C is ARRAY_ARGUMENT =3.
Setting ARRAY_ARGUMENT to 4
will dictate that CUBLAS_GET returns a
0, 1 value indicating which was last used – the standard Fortran BLAS routine or
the NVIDIA device, respectively.
Generic: CUBLAS_GET (ENUM, ARRAY_ARGUMENT)
This routine can be used to either retrieve the array size switchover value, NSTART, for a specified array of a specified BLAS routine or retrieve a 0, 1 flag which indicates whether the NVIDIA device was used for the last specified BLAS routine called.
In this example the switchover value for array A of the BLAS routine SGEMM is first retrieved by making a call to CUBLAS_GET. Then CUBLAS_SET is used to inform CUDABLAS_SGEMM not to copy array A from the CPU to the GPU after the initial copy. Then, CUBLAS_SET is used to reset the switchover value back to its original setting. Finally, CUBLAS_GET is used to query whether or not the NVIDIA device was used on the last call to SGEMM.
USE CUDABLAS_LIBRARY
USE UMACH_INT
INTEGER ARRAY_ARGUMENT, IDEVICE, ISWITCH, NOUT
INTEGER, PARAMETER :: N=500
REAL ALPHA, BETA, A(N,N), B(N,N), C(N,N), D(N,N)
ALPHA = 1.0
BETA = 1.0
A = 2.0
B = 3.0
C = 4.0
! ARRAY A IS THE FIRST ARRAY IN
! THE SGEMM CALLING SEQUENCE
ARRAY_ARGUMENT = 1
! GET THE CURRENT SWITCHOVER VALUE
! FOR sGEMM
ISWITCH = CUBLAS_GET (CUDABLAS_SGEMM, ARRAY_ARGUMENT)
! PERFORM AN ARRAY MULITIPLICATION
CALL SGEMM ('N', 'N', N, N, N, ALPHA, A, N, B, N, BETA, D, N)
! AVOID COPYING A FROM THE CPU TO
! THE GPU HENCEFORTH
CALL CUBLAS_SET (CUDABLAS_SGEMM, ARRAY_ARGUMENT, -ABS(ISWITCH))
! PERFORM A SECOND ARRAY MULTIPLICATION
CALL SGEMM ('N', 'N', N, N, N, ALPHA, A, N, C, N, BETA, C, N)
! RESET THE SWITCHOVER VALUE FOR
! SGEMM BACK TO ITS ORIGINAL VALUE
CALL CUBLAS_SET (CUDABLAS_SGEMM, ARRAY_ARGUMENT, ISWITCH)
! DETERMINE WHETHER OR NOT THE GPU
! WAS USED FOR THE LAST SGEMM CALL
ARRAY_ARGUMENT = 4
IDEVICE = CUBLAS_GET (CUDABLAS_SGEMM, ARRAY_ARGUMENT)
! PRINT THE RESULT OF THE LAST QUERY
CALL UMACH (2, NOUT)
IF (IDEVICE .EQ. 0) THEN
WRITE(NOUT, *)'THE STANDARD FORTRAN BLAS SGEMM WAS USED.'
ELSE
WRITE(NOUT, *)'THE NVIDIA DEVICE SGEMM WAS USED.'
END IF
END
The NVIDIA DEVICE SGEMM WAS USED.
PHONE: 713.784.3131 FAX:713.781.9260 |