Fortran OpenACC Runtime Library Routines

Hello,

Can you kindly identify what is wrong in the following code?

!      set ACC_DEVICE_TYPE=nvidia
!  use pgfortran -fast -o ACCHECK.exe  ACCHECK.for -ta=tesla:cc35

      Program ACCHECK
      use Openacc
      IMPLICIT NONE
      INTEGER :: ngpus
      integer, value :: devicenum
      integer(acc_device_kind), value :: devicetype
      integer(acc_device_property):: property
      character*(1000) :: string
      ngpus = acc_get_num_devices(devicetype)
      Write(*,*) 'Number of ACC devices are: ', ngpus
      property=acc_property_driver
      call acc_get_property_string(devicenum,devicetype,property,string)
      Write(*,*) string
      End Program

I have two NVIDIA GPUs: TITAN X and TESLA K40. I believe that the they are compute capability cc50 and cc35 respectively. When I execute the above code, I get 1 GPU and the “string” variable is empty.
Is there something wrong with my coding?
I am actually trying to check that the TESLA K40 is the one running my code. Any tips?

Thank you for your time.
Ahmed

Hi Ahmed,

You need to set the device type and device number which you which to query. For example:

% cat test.f90
!      set ACC_DEVICE_TYPE=nvidia
!  use pgfortran -fast -o ACCHECK.exe  ACCHECK.for -ta=tesla:cc35

      Program ACCHECK
      use Openacc
      IMPLICIT NONE
      INTEGER :: ngpus
      integer, value :: devicenum
      integer(acc_device_kind), value :: devicetype
      integer(acc_device_property):: property
      character*(1000) :: string
      devicetype = acc_get_device_type()
      ngpus = acc_get_num_devices(devicetype)
      Write(*,*) 'Number of ACC devices are: ', ngpus
      do devicenum=1,ngpus
         property=acc_property_driver
         call acc_get_property_string(devicenum,devicetype,property,string)
         Write(*,*) trim(string)
      enddo
      End Program
% pgf90 -ta=tesla:cc70 test.f90; a.out
 Number of ACC devices are:             4
 9010
 9010
 9010
 9010

Hope this helps,
Mat