diff --git a/plugins/Mmap/fortran_mmap.c b/plugins/Mmap/fortran_mmap.c deleted file mode 100644 index 2748dcba..00000000 --- a/plugins/Mmap/fortran_mmap.c +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - - -void* mmap_fortran(char* filename, size_t bytes, int* file_descr, int read_only) -{ - int i; - int fd; - int result; - void* map; - - if (read_only == 1) - { - fd = open(filename, O_RDONLY, (mode_t)0600); - if (fd == -1) { - printf("%s:\n", filename); - perror("Error opening mmap file for reading"); - exit(EXIT_FAILURE); - } - map = mmap(0, bytes, PROT_READ, MAP_SHARED, fd, 0); - } - else - { - fd = open(filename, O_RDWR | O_CREAT, (mode_t)0600); - if (fd == -1) { - printf("%s:\n", filename); - perror("Error opening mmap file for writing"); - exit(EXIT_FAILURE); - } - - result = lseek(fd, bytes, SEEK_SET); - if (result == -1) { - close(fd); - printf("%s:\n", filename); - perror("Error calling lseek() to stretch the file"); - exit(EXIT_FAILURE); - } - - result = write(fd, "", 1); - if (result != 1) { - close(fd); - printf("%s:\n", filename); - perror("Error writing last byte of the file"); - exit(EXIT_FAILURE); - } - - map = mmap(0, bytes, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - } - - if (map == MAP_FAILED) { - close(fd); - printf("%s:\n", filename); - perror("Error mmapping the file"); - exit(EXIT_FAILURE); - } - - *file_descr = fd; - return map; -} - -void munmap_fortran(size_t bytes, int fd, void* map) -{ - if (munmap(map, bytes) == -1) { - perror("Error un-mmapping the file"); - } - close(fd); -} diff --git a/plugins/Mmap/mmap.f90 b/plugins/Mmap/mmap.f90 deleted file mode 100644 index ce33e301..00000000 --- a/plugins/Mmap/mmap.f90 +++ /dev/null @@ -1,69 +0,0 @@ -module mmap_module - - use iso_c_binding - - interface - - ! File descriptors - ! ---------------- - - type(c_ptr) function c_mmap_fortran(filename, length, fd, read_only) bind(c,name='mmap_fortran') - use iso_c_binding - character(c_char), intent(in) :: filename(*) - integer(c_size_t), intent(in), value :: length - integer(c_int), intent(out) :: fd - integer(c_int), intent(in), value :: read_only - end function - - subroutine c_munmap(length, fd, map) bind(c,name='munmap_fortran') - use iso_c_binding - integer(c_size_t), intent(in), value :: length - integer(c_int), intent(in), value :: fd - type(c_ptr), intent(in), value :: map - end subroutine - - end interface - - contains - - subroutine mmap(filename, shape, bytes, fd, read_only, map) - use iso_c_binding - implicit none - character*(*), intent(in) :: filename ! Name of the mapped file - integer*8, intent(in) :: shape(:) ! Shape of the array to map - integer, intent(in) :: bytes ! Number of bytes per element - logical, intent(in) :: read_only ! If true, mmap is read-only - integer, intent(out) :: fd ! File descriptor - type(c_ptr), intent(out) :: map ! C Pointer - - integer(c_long) :: length - integer(c_int) :: fd_ - - length = PRODUCT( shape(:) ) * bytes - if (read_only) then - map = c_mmap_fortran( trim(filename)//char(0), length, fd_, 1) - else - map = c_mmap_fortran( trim(filename)//char(0), length, fd_, 0) - endif - fd = fd_ - end subroutine - - subroutine munmap(shape, bytes, fd, map) - use iso_c_binding - implicit none - integer*8, intent(in) :: shape(:) ! Shape of the array to map - integer, intent(in) :: bytes ! Number of bytes per element - integer, intent(in) :: fd ! File descriptor - type(c_ptr), intent(in) :: map ! C pointer - - integer(c_long) :: length - integer(c_int) :: fd_ - - length = PRODUCT( shape(:) ) * bytes - fd_ = fd - call c_munmap( length, fd_, map) - end - -end module mmap_module - - diff --git a/src/Determinants/filter_connected.irp.f b/src/Determinants/filter_connected.irp.f index 46280b31..8bd0f1f2 100644 --- a/src/Determinants/filter_connected.irp.f +++ b/src/Determinants/filter_connected.irp.f @@ -207,6 +207,7 @@ subroutine create_microlist(minilist, N_minilist, key_mask, microlist, idx_micro do j=1,n_element(1) nt = list(j,1) idx_microlist(cur_microlist(nt)) = i + ! TODO : Page faults do k=1,Nint microlist(k,1,cur_microlist(nt)) = minilist(k,1,i) microlist(k,2,cur_microlist(nt)) = minilist(k,2,i) diff --git a/src/Determinants/slater_rules.irp.f b/src/Determinants/slater_rules.irp.f index 967ac9a3..98d4f71d 100644 --- a/src/Determinants/slater_rules.irp.f +++ b/src/Determinants/slater_rules.irp.f @@ -1060,6 +1060,7 @@ subroutine i_H_psi_minilist(key,keys,idx_key,N_minilist,coef,Nint,Ndet,Ndet_max, i_in_coef = idx_key(idx(ii)) !DIR$ FORCEINLINE call i_H_j(keys(1,1,i_in_key),key,Nint,hij) + ! TODO : Cache misses i_H_psi_array(1) = i_H_psi_array(1) + coef(i_in_coef,1)*hij enddo diff --git a/src/Integrals_Bielec/NEEDED_CHILDREN_MODULES b/src/Integrals_Bielec/NEEDED_CHILDREN_MODULES index c17850c6..fbc783bb 100644 --- a/src/Integrals_Bielec/NEEDED_CHILDREN_MODULES +++ b/src/Integrals_Bielec/NEEDED_CHILDREN_MODULES @@ -1,2 +1,2 @@ -Pseudo Bitmask ZMQ Mmap +Pseudo Bitmask ZMQ diff --git a/src/Utils/NEEDED_CHILDREN_MODULES b/src/Utils/NEEDED_CHILDREN_MODULES index 993ebdae..e69de29b 100644 --- a/src/Utils/NEEDED_CHILDREN_MODULES +++ b/src/Utils/NEEDED_CHILDREN_MODULES @@ -1 +0,0 @@ -Mmap diff --git a/src/Utils/map_module.f90 b/src/Utils/map_module.f90 index 38af0830..b5169689 100644 --- a/src/Utils/map_module.f90 +++ b/src/Utils/map_module.f90 @@ -623,6 +623,7 @@ subroutine search_key_big_interval(key,X,sze,idx,ibegin_in,iend_in) idx = ibegin + istep do while (istep > 16) idx = ibegin + istep + ! TODO : Cache misses if (cache_key < X(idx)) then iend = idx istep = ishft(idx-ibegin,-1) @@ -912,17 +913,17 @@ subroutine map_save_to_disk(filename,map) map % consolidated = .True. - call munmap( (/ map % map_size + 2_8 /), 8, fd(1), c_pointer(1)) - call mmap(trim(filename)//'_consolidated_idx', (/ map % map_size + 2_8 /), 8, fd(1), .True., c_pointer(1)) - call c_f_pointer(c_pointer(1),map % consolidated_idx, (/ map % map_size +2_8/)) - - call munmap( (/ map % n_elements /), cache_key_kind, fd(2), c_pointer(2)) - call mmap(trim(filename)//'_consolidated_key', (/ map % n_elements /), cache_key_kind, fd(2), .True., c_pointer(2)) - call c_f_pointer(c_pointer(2),map % consolidated_key, (/ map % n_elements /)) - - call munmap( (/ map % n_elements /), integral_kind, fd(3), c_pointer(3)) - call mmap(trim(filename)//'_consolidated_value', (/ map % n_elements /), integral_kind, fd(3), .True., c_pointer(3)) - call c_f_pointer(c_pointer(3),map % consolidated_value, (/ map % n_elements /)) +! call munmap( (/ map % map_size + 2_8 /), 8, fd(1), c_pointer(1)) +! call mmap(trim(filename)//'_consolidated_idx', (/ map % map_size + 2_8 /), 8, fd(1), .True., c_pointer(1)) +! call c_f_pointer(c_pointer(1),map % consolidated_idx, (/ map % map_size +2_8/)) +! +! call munmap( (/ map % n_elements /), cache_key_kind, fd(2), c_pointer(2)) +! call mmap(trim(filename)//'_consolidated_key', (/ map % n_elements /), cache_key_kind, fd(2), .True., c_pointer(2)) +! call c_f_pointer(c_pointer(2),map % consolidated_key, (/ map % n_elements /)) +! +! call munmap( (/ map % n_elements /), integral_kind, fd(3), c_pointer(3)) +! call mmap(trim(filename)//'_consolidated_value', (/ map % n_elements /), integral_kind, fd(3), .True., c_pointer(3)) +! call c_f_pointer(c_pointer(3),map % consolidated_value, (/ map % n_elements /)) end