wstat_memory_report.f90 8.08 KB
Newer Older
Marco Govoni's avatar
Marco Govoni committed
1
!
2
! Copyright (C) 2015-2017 M. Govoni
Marco Govoni's avatar
Marco Govoni committed
3
4
5
6
7
8
9
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
! This file is part of WEST.
!
10
! Contributors to this file:
Marco Govoni's avatar
Marco Govoni committed
11
12
13
14
15
16
! Marco Govoni
!
!-----------------------------------------------------------------------
SUBROUTINE wstat_memory_report()
  !----------------------------------------------------------------------------
  !
17
18
19
20
21
22
23
24
  USE kinds,               ONLY : DP
  USE io_global,           ONLY : stdout
  USE wvfct,               ONLY : npwx, nbnd
  USE fft_base,            ONLY : dfftp
  USE gvect,               ONLY : ngl
  USE gvecs,               ONLY : ngms
  USE uspp,                ONLY : nkb
  USE control_flags,       ONLY : gamma_only
25
  USE mp_bands,            ONLY : nbgrp
26
27
28
29
30
  USE mp_world,            ONLY : mpime,root
  USE westcom,             ONLY : nbnd_occ,n_pdep_basis,npwqx,logfile
  USE distribution_center, ONLY : pert
  USE noncollin_module,    ONLY : npol
  USE json_module,         ONLY : json_file
Marco Govoni's avatar
Marco Govoni committed
31
32
33
  !
  IMPLICIT NONE
  !
34
  TYPE(json_file) :: json
Marco Govoni's avatar
Marco Govoni committed
35
  INTEGER :: iunit
Marco Govoni's avatar
Marco Govoni committed
36
37
38
39
40
41
42
  INTEGER, PARAMETER :: Mb=1024*1024, complex_size=16, real_size=8
  REAL(DP) :: mem_tot, mem_partial
  !
  WRITE(stdout,'(/,5x,"[MEM] ----------------------------------------------------------")')
  WRITE(stdout,'(5x,"[MEM] **Memory** analysis: QE")')
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  !
43
  IF( mpime == root ) THEN
Marco Govoni's avatar
Marco Govoni committed
44
45
46
     !
     CALL json%initialize()
     CALL json%load_file(filename=TRIM(logfile))
47
     CALL json%add( 'memory.units', 'Mb' )
Marco Govoni's avatar
Marco Govoni committed
48
     !
49
  ENDIF
Marco Govoni's avatar
Marco Govoni committed
50
  !
Marco Govoni's avatar
Marco Govoni committed
51
52
  ! the conversions to double prevent integer overflow in very large run
  !
53
  mem_tot = 0.0_DP
Marco Govoni's avatar
Marco Govoni committed
54
55
56
  WRITE(stdout,'(5x,"[MEM] Allocated arrays      ",5x,"est. size (Mb)", 5x,"dimensions")')
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  !
57
  mem_partial = (1.0_DP/Mb)*complex_size*nbnd*npwx
Marco Govoni's avatar
Marco Govoni committed
58
59
  WRITE( stdout, '(5x,"[MEM] Kohn-Sham Wavefunctions ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, npwx,nbnd
60
  IF( mpime == root ) CALL json%add( 'memory.evc', mem_partial )
Marco Govoni's avatar
Marco Govoni committed
61
62
  mem_tot = mem_tot + mem_partial
  !
63
  mem_partial = (1.0_DP/Mb)*complex_size*nkb*npwx
Marco Govoni's avatar
Marco Govoni committed
64
65
  WRITE( stdout, '(5x,"[MEM] NL pseudopotentials     ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, npwx, nkb
66
  IF( mpime == root ) CALL json%add( 'memory.nlpp', mem_partial )
Marco Govoni's avatar
Marco Govoni committed
67
68
  mem_tot = mem_tot + mem_partial
  !
69
  mem_partial = (1.0_DP/Mb)*complex_size*dfftp%nnr
Marco Govoni's avatar
Marco Govoni committed
70
71
  WRITE( stdout, '(5x,"[MEM] Each V/rho on FFT grid  ",f10.2," Mb", 5x,"(",i7,")")') &
     mem_partial, dfftp%nnr
72
  IF( mpime == root ) CALL json%add( 'memory.rhor', mem_partial )
Marco Govoni's avatar
Marco Govoni committed
73
74
  mem_tot = mem_tot + mem_partial
  !
75
  mem_partial = (1.0_DP/Mb)*real_size*ngms
Marco Govoni's avatar
Marco Govoni committed
76
77
  WRITE( stdout, '(5x,"[MEM] Each G-vector array     ",f10.2," Mb", 5x,"(",i7,")")') &
     mem_partial, ngms
78
  IF( mpime == root ) CALL json%add( 'memory.rhog', mem_partial )
Marco Govoni's avatar
Marco Govoni committed
79
80
  mem_tot = mem_tot + mem_partial
  !
81
  mem_partial = (1.0_DP/Mb)*real_size*ngl
Marco Govoni's avatar
Marco Govoni committed
82
83
  WRITE( stdout, '(5x,"[MEM] G-vector shells         ",f10.2," Mb", 5x,"(",i7,")")') &
     mem_partial, ngl
84
  IF( mpime == root ) CALL json%add( 'memory.gshells', mem_partial )
Marco Govoni's avatar
Marco Govoni committed
85
86
87
88
89
90
91
92
93
94
95
  mem_tot = mem_tot + mem_partial
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  WRITE( stdout, '(5x,"[MEM] TOT                     ",f10.2," Mb", 5x)') mem_tot
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  WRITE(stdout,'(5x,"[MEM] ")')
  !
  !
  !
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  WRITE(stdout,'(5x,"[MEM] **Memory** analysis: WSTAT global")')
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
96
  mem_tot = 0.0_DP
Marco Govoni's avatar
Marco Govoni committed
97
98
99
  WRITE(stdout,'(5x,"[MEM] Allocated arrays      ",5x,"est. size (Mb)", 5x,"dimensions")')
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  !
100
  mem_partial = (1.0_DP/Mb)*complex_size*npwqx*pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
101
  WRITE( stdout, '(5x,"[MEM] dvg                     ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
102
     mem_partial, npwqx, pert%nlocx
103
  IF( mpime == root ) CALL json%add( 'memory.dvg', mem_partial )
Marco Govoni's avatar
Marco Govoni committed
104
105
  mem_tot = mem_tot + mem_partial
  !
106
  mem_partial = (1.0_DP/Mb)*complex_size*npwqx*pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
107
  WRITE( stdout, '(5x,"[MEM] dng                     ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
108
     mem_partial, npwqx, pert%nlocx
109
  IF( mpime == root ) CALL json%add( 'memory.dng', mem_partial )
Marco Govoni's avatar
Marco Govoni committed
110
111
  mem_tot = mem_tot + mem_partial
  !
112
113
  IF( gamma_only ) THEN
     mem_partial = (1.0_DP/Mb)*real_size*n_pdep_basis*pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
114
  ELSE
115
     mem_partial = (1.0_DP/Mb)*complex_size*n_pdep_basis*pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
116
117
118
  ENDIF
  WRITE( stdout, '(5x,"[MEM] hr_distr                ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, n_pdep_basis, pert%nlocx
119
120
  IF( mpime == root ) CALL json%add( 'memory.hr_distr', mem_partial )
  mem_tot = mem_tot + mem_partial
Marco Govoni's avatar
Marco Govoni committed
121
  !
122
123
  IF( gamma_only ) THEN
     mem_partial = (1.0_DP/Mb)*real_size*n_pdep_basis*pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
124
  ELSE
125
     mem_partial = (1.0_DP/Mb)*complex_size*n_pdep_basis*pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
126
127
128
  ENDIF
  WRITE( stdout, '(5x,"[MEM] vr_distr                ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, n_pdep_basis, pert%nlocx
129
130
  IF( mpime == root ) CALL json%add( 'memory.vr_distr', mem_partial )
  mem_tot = mem_tot + mem_partial
Marco Govoni's avatar
Marco Govoni committed
131
132
133
134
135
136
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  WRITE( stdout, '(5x,"[MEM] TOT                     ",f10.2," Mb", 5x)') mem_tot
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  WRITE(stdout,'(5x,"[MEM] ")')
  !
  !
137
  mem_tot = 0.0_DP
Marco Govoni's avatar
Marco Govoni committed
138
139
140
141
142
143
144
  !
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  WRITE(stdout,'(5x,"[MEM] **Memory** analysis: WSTAT temporary")')
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  WRITE(stdout,'(5x,"[MEM] Allocated arrays      ",5x,"est. size (Mb)", 5x,"dimensions")')
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  !
145
  mem_partial = (1.0_DP/Mb)*complex_size*npwx*npol*((nbnd_occ(1)-1)/nbgrp+1)
Marco Govoni's avatar
Marco Govoni committed
146
  WRITE( stdout, '(5x,"[MEM] dvpsi                   ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
147
     mem_partial, npwx*npol, ((nbnd_occ(1)-1)/nbgrp+1)
148
149
  IF( mpime == root ) CALL json%add( 'memory.dvpsi', mem_partial )
  mem_tot = mem_tot + mem_partial
Marco Govoni's avatar
Marco Govoni committed
150
  !
151
  mem_partial = (1.0_DP/Mb)*complex_size*npwx*npol*((nbnd_occ(1)-1)/nbgrp+1)
Marco Govoni's avatar
Marco Govoni committed
152
  WRITE( stdout, '(5x,"[MEM] dpsi                    ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
153
     mem_partial, npwx*npol, ((nbnd_occ(1)-1)/nbgrp+1)
154
  IF( mpime == root ) CALL json%add( 'memory.dpsi', mem_partial )
Marco Govoni's avatar
Marco Govoni committed
155
156
  mem_tot = mem_tot + mem_partial
  !
157
!  mem_partial = (1.0_DP/Mb)*complex_size*dffts%nnr
Marco Govoni's avatar
Marco Govoni committed
158
159
!  WRITE( stdout, '(5x,"[MEM] aux_r                   ",f10.2," Mb", 5x,"(",i7,")")') &
!     mem_partial, dffts%nnr
160
!  mem_tot1 = mem_tot1 + mem_partial
Marco Govoni's avatar
Marco Govoni committed
161
!  !
162
!  mem_partial = (1.0_DP/Mb)*complex_size*npwx
Marco Govoni's avatar
Marco Govoni committed
163
164
!  WRITE( stdout, '(5x,"[MEM] aux_g                   ",f10.2," Mb", 5x,"(",i7,")")') &
!     mem_partial, npwx
165
!  mem_tot1 = mem_tot1 + mem_partial
Marco Govoni's avatar
Marco Govoni committed
166
167
!  !
!  IF(.NOT.gamma_only) THEN
168
!     mem_partial = (1.0_DP/Mb)*complex_size*npwx
Marco Govoni's avatar
Marco Govoni committed
169
170
!     WRITE( stdout, '(5x,"[MEM] dpsic                   ",f10.2," Mb", 5x,"(",i7,")")') &
!        mem_partial, dffts%nnr
171
!     mem_tot1 = mem_tot1 + mem_partial
Marco Govoni's avatar
Marco Govoni committed
172
173
!  ENDIF
!  !
174
!  mem_partial = (1.0_DP/Mb)*complex_size*npwx*pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
175
176
177
178
179
180
181
!  WRITE( stdout, '(5x,"[MEM] dhg                     ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
!     mem_partial, npwx, pert%nlocx
!  mem_tot2 = mem_tot2 + mem_partial
  !
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  WRITE( stdout, '(5x,"[MEM] Total estimate          ",f10.2," Mb", 5x)') mem_tot
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
182
  WRITE(stdout,*)
Marco Govoni's avatar
Marco Govoni committed
183
  !
184
  IF( mpime == root ) THEN
Marco Govoni's avatar
Marco Govoni committed
185
186
187
188
189
190
     !
     OPEN( NEWUNIT=iunit,FILE=TRIM(logfile) )
     CALL json%print_file( iunit )
     CLOSE( iunit )
     CALL json%destroy()
     !
191
  ENDIF
Marco Govoni's avatar
Marco Govoni committed
192
  !
Marco Govoni's avatar
Marco Govoni committed
193
END SUBROUTINE