wstat_memory_report.f90 6.92 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
!
! 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
  USE westcom,        ONLY : nbnd_occ,n_pdep_basis,npwq0x
  USE distribution_center,  ONLY : pert
  USE noncollin_module,      ONLY : noncolin,npol
  !
  IMPLICIT NONE
  !
  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] ----------------------------------------------------------")')
  !
  ! 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
  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
  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
  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
  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
  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
  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
  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
  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
  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)
  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)
  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] ----------------------------------------------------------")')
  !
END SUBROUTINE