-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfield_basic_module.F90
136 lines (102 loc) · 3.78 KB
/
field_basic_module.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
! (C) Copyright 2022- ECMWF.
! (C) Copyright 2022- Meteo-France.
!
! This software is licensed under the terms of the Apache Licence Version 2.0
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
! In applying this licence, ECMWF does not waive the privileges and immunities
! granted to it by virtue of its status as an intergovernmental organisation
! nor does it submit to any jurisdiction.
MODULE FIELD_BASIC_MODULE
USE DEV_ALLOC_MODULE
USE FIELD_CONSTANTS_MODULE
USE PARKIND1, ONLY : JPIM
IMPLICIT NONE
PRIVATE
TYPE GPU_STATS
INTEGER :: TRANSFER_CPU_TO_GPU = 0
INTEGER :: TRANSFER_GPU_TO_CPU = 0
REAL :: TOTAL_TIME_TRANSFER_CPU_TO_GPU = 0
REAL :: TOTAL_TIME_TRANSFER_GPU_TO_CPU = 0
CONTAINS
PROCEDURE :: INC_CPU_TO_GPU_TRANSFER
PROCEDURE :: INC_GPU_TO_CPU_TRANSFER
END TYPE GPU_STATS
TYPE, ABSTRACT :: FIELD_BASIC
LOGICAL :: THREAD_BUFFER = .FALSE.
INTEGER(KIND=JPIM) :: ISTATUS = 0
TYPE(GPU_STATS) :: STATS
LOGICAL :: LOBJECT_COPIED = .FALSE.
LOGICAL :: MAP_DEVPTR = .TRUE.
INTEGER(KIND=JPIM) :: BLKID = 0
CONTAINS
PROCEDURE (FIELD_BASIC_SYNC), DEFERRED :: SYNC_HOST_RDWR
PROCEDURE (FIELD_BASIC_SYNC), DEFERRED :: SYNC_HOST_RDONLY
PROCEDURE (FIELD_BASIC_SYNC), DEFERRED :: SYNC_DEVICE_RDWR
PROCEDURE (FIELD_BASIC_SYNC), DEFERRED :: SYNC_DEVICE_RDONLY
PROCEDURE (FIELD_BASIC_DELETE_DEVICE_DATA), DEFERRED :: DELETE_DEVICE_DATA
PROCEDURE (FIELD_BASIC_CREATE_DEVICE_DATA), DEFERRED :: CREATE_DEVICE_DATA
#ifdef WITH_FIAT
PROCEDURE (FIELD_BASIC_CRC64), DEFERRED :: CRC64
#endif
PROCEDURE :: SET_CHILDREN_DEVPTR => FIELD_BASIC_SET_CHILDREN_DEVPTR
PROCEDURE :: SET_DEVICE_DIRTY => FIELD_BASIC_SET_DEVICE_DIRTY
PROCEDURE :: SET_STATUS => FIELD_BASIC_SET_STATUS
PROCEDURE :: GET_STATUS => FIELD_BASIC_GET_STATUS
END TYPE FIELD_BASIC
PUBLIC :: FIELD_BASIC
ABSTRACT INTERFACE
SUBROUTINE FIELD_BASIC_SYNC (SELF, QUEUE)
IMPORT FIELD_BASIC
CLASS(FIELD_BASIC) :: SELF
INTEGER, OPTIONAL, INTENT(IN) :: QUEUE
END SUBROUTINE
SUBROUTINE FIELD_BASIC_DELETE_DEVICE_DATA (SELF)
IMPORT FIELD_BASIC
CLASS(FIELD_BASIC) :: SELF
END SUBROUTINE
SUBROUTINE FIELD_BASIC_CREATE_DEVICE_DATA (SELF)
IMPORT FIELD_BASIC
CLASS(FIELD_BASIC) :: SELF
END SUBROUTINE
#ifdef WITH_FIAT
INTEGER*8 FUNCTION FIELD_BASIC_CRC64 (SELF)
IMPORT FIELD_BASIC
CLASS(FIELD_BASIC) :: SELF
END FUNCTION
#endif
END INTERFACE
PUBLIC :: FIELD_BASIC_SYNC
CONTAINS
SUBROUTINE INC_CPU_TO_GPU_TRANSFER(SELF, START, FINISH)
CLASS(GPU_STATS), INTENT(INOUT) :: SELF
REAL, INTENT(IN) :: START, FINISH
SELF%TRANSFER_CPU_TO_GPU = SELF%TRANSFER_CPU_TO_GPU + 1
SELF%TOTAL_TIME_TRANSFER_CPU_TO_GPU = SELF%TOTAL_TIME_TRANSFER_CPU_TO_GPU + FINISH - START
END SUBROUTINE
SUBROUTINE INC_GPU_TO_CPU_TRANSFER(SELF, START, FINISH)
CLASS(GPU_STATS), INTENT(INOUT) :: SELF
REAL, INTENT(IN) :: START, FINISH
SELF%TRANSFER_GPU_TO_CPU = SELF%TRANSFER_GPU_TO_CPU + 1
SELF%TOTAL_TIME_TRANSFER_GPU_TO_CPU = SELF%TOTAL_TIME_TRANSFER_GPU_TO_CPU + FINISH - START
END SUBROUTINE
SUBROUTINE FIELD_BASIC_SET_CHILDREN_DEVPTR (SELF)
USE FIELD_ABORT_MODULE
CLASS (FIELD_BASIC) :: SELF
CALL FIELD_ABORT ('FIELD_BASIC_SET_CHILDREN_DEVPTR: SHOULD NOT BE CALLED')
END SUBROUTINE
SUBROUTINE FIELD_BASIC_SET_DEVICE_DIRTY (SELF)
CLASS (FIELD_BASIC) :: SELF
IF (IAND (SELF%GET_STATUS (), NDEVFRESH)==NDEVFRESH) THEN
CALL SELF%SET_STATUS (IAND (SELF%GET_STATUS (), NOT (NDEVFRESH)))
ENDIF
END SUBROUTINE FIELD_BASIC_SET_DEVICE_DIRTY
SUBROUTINE FIELD_BASIC_SET_STATUS (SELF, KSTATUS)
CLASS (FIELD_BASIC) :: SELF
INTEGER (KIND=JPIM), INTENT (IN) :: KSTATUS
SELF%ISTATUS = KSTATUS
END SUBROUTINE FIELD_BASIC_SET_STATUS
INTEGER (KIND=JPIM) FUNCTION FIELD_BASIC_GET_STATUS (SELF)
CLASS (FIELD_BASIC) :: SELF
FIELD_BASIC_GET_STATUS = SELF%ISTATUS
END FUNCTION
END MODULE FIELD_BASIC_MODULE