10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-22 04:13:55 +01:00

mmap is now shared in cholesky

This commit is contained in:
Anthony Scemama 2024-06-20 13:43:46 +02:00
parent c6712b0d60
commit 4b578d9849
2 changed files with 23 additions and 16 deletions

View File

@ -31,12 +31,11 @@ END_PROVIDER
integer*8 :: ndim8
integer :: rank
double precision :: tau, tau2
double precision, pointer :: L(:,:), Delta(:,:)
double precision, pointer :: L(:,:)
double precision :: s
double precision :: dscale, dscale_tmp
double precision, allocatable :: D(:), Ltmp_p(:,:), Ltmp_q(:,:), D_sorted(:), Delta_col(:)
double precision, allocatable :: D(:), Ltmp_p(:,:), Ltmp_q(:,:), D_sorted(:), Delta_col(:), Delta(:,:)
integer, allocatable :: addr1(:), addr2(:)
integer*8, allocatable :: Lset(:), Dset(:)
logical, allocatable :: computed(:)
@ -102,7 +101,7 @@ END_PROVIDER
rank = 0
allocate( D(ndim8), Lset(ndim8), Dset(ndim8), D_sorted(ndim8))
allocate( addr1(ndim8), addr2(ndim8), Delta_col(ndim8) )
allocate( addr1(ndim8), addr2(ndim8), Delta_col(ndim8), computed(ndim8) )
call resident_memory(mem0)
@ -149,11 +148,9 @@ END_PROVIDER
Dmax = D_sorted(1)
! 2.
dscale = 1.d0
dscale_tmp = dscale*dscale*Dmax
np8=0_8
do p8=1,ndim8
if ( dscale_tmp*D(p8) >= tau2 ) then
if ( Dmax*D(p8) >= tau2 ) then
np8 = np8+1_8
Lset(np8) = p8
endif
@ -203,16 +200,23 @@ END_PROVIDER
mem = mem0 &
+ np*memory_of_double(nq) & ! Delta(np,nq)
+ (np+nq)*memory_of_double(block_size) & ! Ltmp_p(np,block_size) + Ltmp_q(nq,block_size)
+ memory_of_int(nq) ! computed(nq)
+ (np+nq)*memory_of_double(block_size) ! Ltmp_p(np,block_size) + Ltmp_q(nq,block_size)
if (mem > qp_max_mem*0.5d0) then
nq = nq/2
Dmin = D_sorted(nq/2)
do ii=nq/2,np-1
if (D_sorted(ii) < Dmin) then
nq = ii
exit
endif
enddo
else
exit
endif
enddo
!call print_memory_usage
!print *, 'np, nq, Predicted memory: ', np, nq, mem
if (nq <= 0) then
print *, nq
@ -247,8 +251,7 @@ END_PROVIDER
endif
allocate(computed(nq))
computed(:) = .False.
computed(1:nq) = .False.
!$OMP PARALLEL DEFAULT(SHARED) PRIVATE(k,p,q)
@ -406,7 +409,6 @@ END_PROVIDER
deallocate(Ltmp_p)
deallocate(Ltmp_q)
deallocate(computed)
deallocate(Delta)
! i.
@ -419,11 +421,9 @@ END_PROVIDER
Dmax = D_sorted(1)
dscale = 1.d0
dscale_tmp = dscale*dscale*Dmax
np8=0_8
do p8=1,ndim8
if ( dscale_tmp*D(p8) >= tau2 ) then
if ( Dmax*D(p8) >= tau2 ) then
np8 = np8+1_8
Lset(np8) = p8
endif
@ -436,6 +436,10 @@ END_PROVIDER
print *, '============ ============='
print *, ''
deallocate( D, Lset, Dset, D_sorted )
deallocate( addr1, addr2, Delta_col, computed )
allocate(cholesky_ao(ao_num,ao_num,rank), stat=ierr)
if (ierr /= 0) then

View File

@ -49,10 +49,13 @@ void* mmap_fortran(char* filename, size_t bytes, int* file_descr, int read_only,
}
if (single_node == 1) {
map = mmap(NULL, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
/*
map = mmap(NULL, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_POPULATE | MAP_NONBLOCK | MAP_NORESERVE, fd, 0);
if (map == MAP_FAILED) {
map = mmap(NULL, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
}
*/
} else {
map = mmap(NULL, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
}