wstat_memory_report.f90 8.13 KB
Newer Older
Marco Govoni's avatar
Marco Govoni committed
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
!
! Copyright (C) 2015-2016 M. Govoni 
! 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.
!
! Contributors to this file: 
! Marco Govoni
!
!-----------------------------------------------------------------------
SUBROUTINE wstat_memory_report()
  !----------------------------------------------------------------------------
  !
  USE kinds,          ONLY : DP
  USE io_global,      ONLY : stdout
  USE wvfct,          ONLY : npwx, nbnd, nbndx
  USE basis,          ONLY : natomwfc
  USE fft_base,       ONLY : dfftp,dffts
  USE gvect,          ONLY : ngl, ngm, ngm_g
  USE gvecs,          ONLY : ngms_g, ngms
  USE uspp,           ONLY : nkb
  USE control_flags,  ONLY : isolve, nmix, gamma_only, lscf
  USE mp_global,      ONLY : np_ortho
Marco Govoni's avatar
Marco Govoni committed
27
28
  USE mp_world,       ONLY : mpime,root
  USE westcom,        ONLY : nbnd_occ,n_pdep_basis,npwq0x,logfile
Marco Govoni's avatar
Marco Govoni committed
29
30
  USE distribution_center,  ONLY : pert
  USE noncollin_module,      ONLY : noncolin,npol
Marco Govoni's avatar
Marco Govoni committed
31
  USE json_module,    ONLY : json_file
Marco Govoni's avatar
Marco Govoni committed
32
33
34
  !
  IMPLICIT NONE
  !
Marco Govoni's avatar
Marco Govoni committed
35
36
  TYPE(json_file) :: json 
  INTEGER :: iunit
Marco Govoni's avatar
Marco Govoni committed
37
38
39
40
41
42
43
  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] ----------------------------------------------------------")')
  !
Marco Govoni's avatar
Marco Govoni committed
44
45
46
47
48
49
50
51
  IF( mpime == root ) THEN 
     !
     CALL json%initialize()
     CALL json%load_file(filename=TRIM(logfile))
     CALL json%add( 'memory.units', 'Mb' ) 
     !
  ENDIF 
  !
Marco Govoni's avatar
Marco Govoni committed
52
53
54
55
56
57
58
59
60
  ! the conversions to double prevent integer overflow in very large run
  !
  mem_tot = 0._DP
  WRITE(stdout,'(5x,"[MEM] Allocated arrays      ",5x,"est. size (Mb)", 5x,"dimensions")')
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  !
  mem_partial = DBLE(complex_size*nbnd*npwx)/DBLE(Mb)
  WRITE( stdout, '(5x,"[MEM] Kohn-Sham Wavefunctions ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, npwx,nbnd
Marco Govoni's avatar
Marco Govoni committed
61
  IF( mpime == root ) CALL json%add( 'memory.evc', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
62
63
64
65
66
  mem_tot = mem_tot + mem_partial
  !
  mem_partial = DBLE(complex_size*nkb*npwx)/DBLE(Mb)
  WRITE( stdout, '(5x,"[MEM] NL pseudopotentials     ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, npwx, nkb
Marco Govoni's avatar
Marco Govoni committed
67
  IF( mpime == root ) CALL json%add( 'memory.nlpp', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
68
69
70
71
72
  mem_tot = mem_tot + mem_partial
  !
  mem_partial = DBLE(complex_size*dfftp%nnr)/DBLE(Mb)
  WRITE( stdout, '(5x,"[MEM] Each V/rho on FFT grid  ",f10.2," Mb", 5x,"(",i7,")")') &
     mem_partial, dfftp%nnr
Marco Govoni's avatar
Marco Govoni committed
73
  IF( mpime == root ) CALL json%add( 'memory.rhor', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
74
75
76
77
78
  mem_tot = mem_tot + mem_partial
  !
  mem_partial = DBLE(real_size*ngms)/DBLE(Mb)
  WRITE( stdout, '(5x,"[MEM] Each G-vector array     ",f10.2," Mb", 5x,"(",i7,")")') &
     mem_partial, ngms
Marco Govoni's avatar
Marco Govoni committed
79
  IF( mpime == root ) CALL json%add( 'memory.rhog', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
80
81
82
83
84
  mem_tot = mem_tot + mem_partial
  !
  mem_partial = DBLE(real_size*ngl)/DBLE(Mb)
  WRITE( stdout, '(5x,"[MEM] G-vector shells         ",f10.2," Mb", 5x,"(",i7,")")') &
     mem_partial, ngl
Marco Govoni's avatar
Marco Govoni committed
85
  IF( mpime == root ) CALL json%add( 'memory.gshells', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
  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] ----------------------------------------------------------")')
  mem_tot = 0._DP
  WRITE(stdout,'(5x,"[MEM] Allocated arrays      ",5x,"est. size (Mb)", 5x,"dimensions")')
  WRITE(stdout,'(5x,"[MEM] ----------------------------------------------------------")')
  !
  mem_partial = DBLE(complex_size*npwq0x*pert%nlocx)/DBLE(Mb)
  WRITE( stdout, '(5x,"[MEM] dvg                     ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, npwq0x, pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
104
  IF( mpime == root ) CALL json%add( 'memory.dvg', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
105
106
107
108
109
  mem_tot = mem_tot + mem_partial
  !
  mem_partial = DBLE(complex_size*npwq0x*pert%nlocx)/DBLE(Mb)
  WRITE( stdout, '(5x,"[MEM] dng                     ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, npwq0x, pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
110
  IF( mpime == root ) CALL json%add( 'memory.dng', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
111
112
113
114
115
116
117
118
119
  mem_tot = mem_tot + mem_partial
  !
  IF( gamma_only ) THEN  
     mem_partial = DBLE(real_size*n_pdep_basis*pert%nlocx)/DBLE(Mb)
  ELSE
     mem_partial = DBLE(complex_size*n_pdep_basis*pert%nlocx)/DBLE(Mb)
  ENDIF
  WRITE( stdout, '(5x,"[MEM] hr_distr                ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, n_pdep_basis, pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
120
  IF( mpime == root ) CALL json%add( 'memory.hr_distr', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
121
122
123
124
125
126
127
128
129
  mem_tot = mem_tot + mem_partial 
  !
  IF( gamma_only ) THEN  
     mem_partial = DBLE(real_size*n_pdep_basis*pert%nlocx)/DBLE(Mb)
  ELSE
     mem_partial = DBLE(complex_size*n_pdep_basis*pert%nlocx)/DBLE(Mb)
  ENDIF
  WRITE( stdout, '(5x,"[MEM] vr_distr                ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, n_pdep_basis, pert%nlocx
Marco Govoni's avatar
Marco Govoni committed
130
  IF( mpime == root ) CALL json%add( 'memory.vr_distr', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
  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] ")')
  !
  !
  mem_tot = 0._DP
  !
  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] ----------------------------------------------------------")')
  !
  mem_partial = DBLE(complex_size*npwx*npol*nbnd_occ(1))/DBLE(Mb)
  WRITE( stdout, '(5x,"[MEM] dvpsi                   ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, npwx*npol, nbnd_occ(1)
Marco Govoni's avatar
Marco Govoni committed
149
  IF( mpime == root ) CALL json%add( 'memory.dvpsi', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
150
151
152
153
154
  mem_tot = mem_tot + mem_partial 
  !
  mem_partial = DBLE(complex_size*npwx*npol*nbnd_occ(1))/DBLE(Mb)
  WRITE( stdout, '(5x,"[MEM] dpsi                    ",f10.2," Mb", 5x,"(",i7,",",i5,")")') &
     mem_partial, npwx*npol, nbnd_occ(1)
Marco Govoni's avatar
Marco Govoni committed
155
  IF( mpime == root ) CALL json%add( 'memory.dpsi', mem_partial ) 
Marco Govoni's avatar
Marco Govoni committed
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
  mem_tot = mem_tot + mem_partial
  !
!  mem_partial = DBLE(complex_size*dffts%nnr)/DBLE(Mb)
!  WRITE( stdout, '(5x,"[MEM] aux_r                   ",f10.2," Mb", 5x,"(",i7,")")') &
!     mem_partial, dffts%nnr
!  mem_tot1 = mem_tot1 + mem_partial 
!  !
!  mem_partial = DBLE(complex_size*npwx)/DBLE(Mb)
!  WRITE( stdout, '(5x,"[MEM] aux_g                   ",f10.2," Mb", 5x,"(",i7,")")') &
!     mem_partial, npwx
!  mem_tot1 = mem_tot1 + mem_partial 
!  !
!  IF(.NOT.gamma_only) THEN
!     mem_partial = DBLE(complex_size*npwx)/DBLE(Mb)
!     WRITE( stdout, '(5x,"[MEM] dpsic                   ",f10.2," Mb", 5x,"(",i7,")")') &
!        mem_partial, dffts%nnr
!     mem_tot1 = mem_tot1 + mem_partial 
!  ENDIF
!  !
!  mem_partial = DBLE(complex_size*npwx*pert%nlocx)/DBLE(Mb)
!  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] ----------------------------------------------------------")')
  !
Marco Govoni's avatar
Marco Govoni committed
184
185
186
187
188
189
190
191
192
  IF( mpime == root ) THEN 
     !
     OPEN( NEWUNIT=iunit,FILE=TRIM(logfile) )
     CALL json%print_file( iunit )
     CLOSE( iunit )
     CALL json%destroy()
     !
  ENDIF 
  !
Marco Govoni's avatar
Marco Govoni committed
193
END SUBROUTINE