mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-12-22 12:23:43 +01:00
Get total memory
This commit is contained in:
parent
905d88529f
commit
4237fa888f
@ -141,7 +141,7 @@ BEGIN_PROVIDER [ integer, cholesky_ao_num ]
|
||||
logical :: memory_ok
|
||||
memory_ok = .False.
|
||||
|
||||
s = 1.d-2
|
||||
s = 0.1d0
|
||||
|
||||
! Inrease s until the arrays fit in memory
|
||||
do
|
||||
@ -176,7 +176,7 @@ BEGIN_PROVIDER [ integer, cholesky_ao_num ]
|
||||
exit
|
||||
endif
|
||||
|
||||
if (nq == 0) then
|
||||
if ((s > 1.d0).or.(nq == 0)) then
|
||||
print *, 'Not enough memory. Reduce cholesky threshold'
|
||||
stop -1
|
||||
endif
|
||||
@ -219,10 +219,15 @@ BEGIN_PROVIDER [ integer, cholesky_ao_num ]
|
||||
stop -1
|
||||
endif
|
||||
|
||||
Delta(:,:) = 0.d0
|
||||
|
||||
!$OMP PARALLEL DEFAULT(SHARED) PRIVATE(m,k,p,q,j)
|
||||
|
||||
!$OMP DO
|
||||
do q=1,nq
|
||||
Delta(:,q) = 0.d0
|
||||
enddo
|
||||
!$OMP ENDDO NOWAIT
|
||||
|
||||
!$OMP DO
|
||||
do k=1,N
|
||||
do p=1,np
|
||||
@ -232,7 +237,9 @@ BEGIN_PROVIDER [ integer, cholesky_ao_num ]
|
||||
Ltmp_q(q,k) = L(Dset(q),k)
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END DO NOWAIT
|
||||
|
||||
!$OMP BARRIER
|
||||
|
||||
!$OMP DO SCHEDULE(guided)
|
||||
do m=1,nq
|
||||
|
@ -4,8 +4,10 @@ BEGIN_PROVIDER [ integer, qp_max_mem ]
|
||||
! Maximum memory in Gb
|
||||
END_DOC
|
||||
character*(128) :: env
|
||||
integer, external :: get_total_available_memory
|
||||
|
||||
qp_max_mem = 500
|
||||
qp_max_mem = get_total_available_memory()
|
||||
call write_int(6,qp_max_mem,'Total available memory (GB)')
|
||||
call getenv('QP_MAXMEM',env)
|
||||
if (trim(env) /= '') then
|
||||
call lock_io()
|
||||
@ -122,3 +124,35 @@ subroutine print_memory_usage()
|
||||
'.. >>>>> [ RES MEM : ', rss , &
|
||||
' GB ] [ VIRT MEM : ', mem, ' GB ] <<<<< ..'
|
||||
end
|
||||
|
||||
integer function get_total_available_memory() result(res)
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Returns the total available memory on the current machine
|
||||
END_DOC
|
||||
|
||||
character(len=128) :: line
|
||||
integer :: status
|
||||
integer :: iunit
|
||||
integer*8, parameter :: KB = 1024
|
||||
integer*8, parameter :: GiB = 1024**3
|
||||
integer, external :: getUnitAndOpen
|
||||
|
||||
iunit = getUnitAndOpen('/proc/meminfo','r')
|
||||
|
||||
res = 512
|
||||
do
|
||||
read(iunit, '(A)', END=10) line
|
||||
if (line(1:10) == "MemTotal: ") then
|
||||
read(line(11:), *, ERR=20) res
|
||||
res = int((res*KB) / GiB,4)
|
||||
exit
|
||||
20 continue
|
||||
end if
|
||||
end do
|
||||
10 continue
|
||||
close(iunit)
|
||||
|
||||
end function get_total_available_memory
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user