It amazes me when see new stuff which happened again today.
In the Fortran compiler it says under OFFLOAD:
use, intrinsic :: iso_c_binding enum , bind (C) enumerator :: OFFLOAD_SUCCESS = 0 enumerator :: OFFLOAD_DISABLED = 1 ! offload is disabled enumerator :: OFFLOAD_UNAVAILABLE = 2 ! card is not available enumerator :: OFFLOAD_OUT_OF_MEMORY = 3 ! not enough memory on device enumerator :: OFFLOAD_PROCESS_DIED = 4 ! target process has died enumerator :: OFFLOAD_ERROR = 5 ! unspecified error end enum type, bind (C) :: offload_status integer(kind=c_int) :: result = OFFLOAD_DISABLED ! result, see enum above integer(kind=c_int) :: device_number = -1 ! device number integer(kind=c_int) :: data_sent = 0 ! number of bytes sent to the target integer(kind=c_int) :: data_received = 0 ! number of bytes received by host end type offload_status
So I poked into my code the following:
MODULE TYPE(offload_status), PUBLIC, DIMENSION(60) :: MICSTATUS !... more stuff LOGICAL(KIND=4), PARAMETER :: Yes = .TRUE. LOGICAL(KIND=4), PARAMETER :: No = .FALSE. LOGICAL(KIND=4), PARAMETER :: Amy = No !Or No no no !... more stuff END MODULE
In the main I have something like this:
!... !DIR$ ALIGN:64 DataIn REAL(KIND=4), DIMENSION(:,:), ALLOCATABLE :: DataIn !... ALLOCATE(DataIn(1024,60)) !... ! establish the allocation on the mic !DIR$ OFFLOAD)TRANSFER TARGET(mic:0) IN(DataIn: ALLOW_IF(YES) FREE_IF(NO) ) STATUS(MICStatus(1)) !DIR$ OFFLOAD_WAIT TAREGT(mic:0) WAIT(MICStatus(1)) WRITE(*,100) '100', 1, MICStatus(1).RESULT, MICStatus(1).DEVICE, MICStatus(1).DATA_SENT, MICStatus(1).DATA_RECEIVED 100 FORMAT(A,' MS(',I3,').RES=',I2, ' Dev=',I3 ' Tx=',I15, ' Rx=',I15) !... !A bigger loop DO I = 1, 60 !DIR$ OFFLOAD)TRANSFER TARGET(mic:0) IN(DataIn(:,I): ALLOW_IF(YES) FREE_IF(NO) ) STATUS(MICStatus(I)) !--- This stuff below was in a separate loop ... !DIR$ OFFLOAD_WAIT TAREGT(mic:0) WAIT(MICStatus(I)) WRITE(*,100) '120',I,MICStatus(I).RESULT, MICStatus(I).DEVICE, MICStatus(I).DATA_SENT, MICStatus(I).DATA_RECEIVED ENDDO !End of a bigger loop !... ! clean up the mic !DIR$ OFFLOAD)TRANSFER TARGET(mic:0) OUT(DataIn: ALLOW_IF(YES) FREE_IF(YES) ) STATUS(MICStatus(1)) !DIR$ OFFLOAD_WAIT TAREGT(mic:0) WAIT(MICStatus(1)) WRITE(*,100) '100', 1, MICStatus(1).RESULT, MICStatus(1).DEVICE, MICStatus(1).DATA_SENT, MICStatus(1).DATA_RECEIVED 100 FORMAT(A,' MS(',I3,').RES=',I2, ' Dev=',I3 ' Tx=',I15, ' Rx=',I15) DEALLOCATE(DataIn)
What I see if that only MICStatus(1) is showing the results correctly.
The sizeof(Status(1)) is 24 bytes, which I was expecting to be 16 (which is 4x C_INT).
Then I tried doing the following:
MODULE TYPE(offload_status), PUBLIC, DIMENSION(60) :: pSTATUS TYPE(offload_status), PUBLIC :: MICSTATUS1 TYPE(offload_status), PUBLIC :: MICSTATUS2 TYPE(offload_status), PUBLIC :: MICSTATUS3 TYPE(offload_status), PUBLIC :: MICSTATUS4 ... !... more stuff END MODULE
Followed by:
ALLOCATE(pMICSTATUS(60)) pMICSTATUS(1) => MICStatus1 pMICSTATUS(2) => MICStatus2
The last one failed as there are arguments for BIND(C) that require something... (??), and enumerator is a new one for me.
I just wast to get the data moved to the mic and then start scheduling the work on the mic as the data is on it, so I need to know how to handle the status tags as indexed array structure/type or with a pointer.