mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-09-01 05:33:40 +02:00
Compare commits
4 Commits
3967b197fa
...
edd2276b75
Author | SHA1 | Date | |
---|---|---|---|
edd2276b75 | |||
1120d572fa | |||
a6c95879de | |||
3763767f77 |
@ -148,7 +148,7 @@ subroutine run_pt2_slave_small(thread,iproc,energy)
|
||||
integer, external :: disconnect_from_taskserver
|
||||
do i=1,300
|
||||
if (disconnect_from_taskserver(zmq_to_qp_run_socket,worker_id) /= -2) exit
|
||||
call sleep(1)
|
||||
call usleep(500)
|
||||
print *, 'Retry disconnect...'
|
||||
end do
|
||||
|
||||
|
@ -74,7 +74,7 @@ subroutine run_selection_slave(thread,iproc,energy)
|
||||
if(done .or. ctask == size(task_id)) then
|
||||
do i=1, ctask
|
||||
if (task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id(i)) == -1) then
|
||||
call sleep(1)
|
||||
call usleep(100)
|
||||
if (task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id(i)) == -1) then
|
||||
ctask = 0
|
||||
done = .true.
|
||||
@ -85,6 +85,7 @@ subroutine run_selection_slave(thread,iproc,energy)
|
||||
if(ctask > 0) then
|
||||
call sort_selection_buffer(buf)
|
||||
! call merge_selection_buffers(buf,buf2)
|
||||
print *, task_id(1), pt2(1), buf%cur, ctask
|
||||
call push_selection_results(zmq_socket_push, pt2, variance, norm, buf, task_id(1), ctask)
|
||||
! buf%mini = buf2%mini
|
||||
pt2(:) = 0d0
|
||||
@ -132,7 +133,6 @@ subroutine push_selection_results(zmq_socket_push, pt2, variance, norm, b, task_
|
||||
print *, 'f77_zmq_send( zmq_socket_push, b%cur, 4, ZMQ_SNDMORE)'
|
||||
endif
|
||||
|
||||
if (b%cur > 0) then
|
||||
|
||||
rc = f77_zmq_send( zmq_socket_push, pt2, 8*N_states, ZMQ_SNDMORE)
|
||||
if(rc /= 8*N_states) then
|
||||
@ -149,6 +149,8 @@ subroutine push_selection_results(zmq_socket_push, pt2, variance, norm, b, task_
|
||||
print *, 'f77_zmq_send( zmq_socket_push, norm, 8*N_states, ZMQ_SNDMORE)'
|
||||
endif
|
||||
|
||||
if (b%cur > 0) then
|
||||
|
||||
rc = f77_zmq_send( zmq_socket_push, b%val(1), 8*b%cur, ZMQ_SNDMORE)
|
||||
if(rc /= 8*b%cur) then
|
||||
print *, 'f77_zmq_send( zmq_socket_push, b%val(1), 8*b%cur, ZMQ_SNDMORE)'
|
||||
@ -203,7 +205,10 @@ subroutine pull_selection_results(zmq_socket_pull, pt2, variance, norm, val, det
|
||||
print *, 'f77_zmq_recv( zmq_socket_pull, N, 4, 0)'
|
||||
endif
|
||||
|
||||
if (N>0) then
|
||||
pt2(:) = 0.d0
|
||||
variance(:) = 0.d0
|
||||
norm(:) = 0.d0
|
||||
|
||||
rc = f77_zmq_recv( zmq_socket_pull, pt2, N_states*8, 0)
|
||||
if(rc /= 8*N_states) then
|
||||
print *, 'f77_zmq_recv( zmq_socket_pull, pt2, N_states*8, 0)'
|
||||
@ -219,6 +224,7 @@ subroutine pull_selection_results(zmq_socket_pull, pt2, variance, norm, val, det
|
||||
print *, 'f77_zmq_recv( zmq_socket_pull, norm, N_states*8, 0)'
|
||||
endif
|
||||
|
||||
if (N>0) then
|
||||
rc = f77_zmq_recv( zmq_socket_pull, val(1), 8*N, 0)
|
||||
if(rc /= 8*N) then
|
||||
print *, 'f77_zmq_recv( zmq_socket_pull, val(1), 8*N, 0)'
|
||||
@ -228,10 +234,6 @@ subroutine pull_selection_results(zmq_socket_pull, pt2, variance, norm, val, det
|
||||
if(rc /= bit_kind*N_int*2*N) then
|
||||
print *, 'f77_zmq_recv( zmq_socket_pull, det(1,1,1), bit_kind*N_int*2*N, 0)'
|
||||
endif
|
||||
else
|
||||
pt2(:) = 0.d0
|
||||
variance(:) = 0.d0
|
||||
norm(:) = 0.d0
|
||||
endif
|
||||
|
||||
rc = f77_zmq_recv( zmq_socket_pull, ntask, 4, 0)
|
||||
|
@ -63,7 +63,7 @@ subroutine run_slave_main
|
||||
if (mpi_master) then
|
||||
call wait_for_states(states,zmq_state,size(states))
|
||||
if (zmq_state(1:64) == old_state(1:64)) then
|
||||
call sleep(1)
|
||||
call usleep(200)
|
||||
cycle
|
||||
else
|
||||
old_state(1:64) = zmq_state(1:64)
|
||||
|
@ -39,6 +39,8 @@ BEGIN_PROVIDER [ character*(128), ezfio_filename ]
|
||||
write(command,*) 'echo 15 > /proc//'//trim(adjustl(pidc))//'/oom_adj'
|
||||
call system(command)
|
||||
|
||||
PROVIDE file_lock
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [ character*(128), ezfio_work_dir ]
|
||||
|
@ -43,8 +43,13 @@ subroutine run
|
||||
E_CI_before(:) = psi_energy(:) + nuclear_repulsion
|
||||
relative_error=PT2_relative_error
|
||||
|
||||
if (do_pt2) then
|
||||
call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
|
||||
norm,0) ! Stochastic PT2
|
||||
else
|
||||
call ZMQ_selection(0, pt2, variance, norm)
|
||||
endif
|
||||
|
||||
do k=1,N_states
|
||||
rpt2(k) = pt2(k)/(1.d0 + norm(k))
|
||||
enddo
|
||||
|
6
src/utils/c_funcs.c
Normal file
6
src/utils/c_funcs.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
void usleep_c(int s)
|
||||
{
|
||||
usleep((useconds_t) s);
|
||||
}
|
21
src/utils/c_functions.f90
Normal file
21
src/utils/c_functions.f90
Normal file
@ -0,0 +1,21 @@
|
||||
module c_functions
|
||||
use iso_c_binding
|
||||
|
||||
interface
|
||||
subroutine usleep_c(us) bind (C,name="usleep_c")
|
||||
use iso_c_binding
|
||||
integer(c_int), value :: us
|
||||
end subroutine usleep_c
|
||||
end interface
|
||||
|
||||
end module
|
||||
|
||||
subroutine usleep(us)
|
||||
use c_functions
|
||||
use iso_c_binding
|
||||
implicit none
|
||||
integer, intent(in) :: us
|
||||
integer(c_int) :: u
|
||||
u = us
|
||||
call usleep_c(u)
|
||||
end
|
@ -15,6 +15,7 @@ BEGIN_PROVIDER [ integer, qp_max_mem ]
|
||||
END_PROVIDER
|
||||
|
||||
subroutine resident_memory(value)
|
||||
use c_functions
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Returns the current used memory in gigabytes used by the current process.
|
||||
@ -25,6 +26,8 @@ subroutine resident_memory(value)
|
||||
double precision, intent(out) :: value
|
||||
|
||||
call omp_set_lock(file_lock)
|
||||
call usleep(10)
|
||||
|
||||
value = 0.d0
|
||||
iunit = getUnitAndOpen('/proc/self/status','r')
|
||||
do
|
||||
|
@ -275,7 +275,6 @@ IRP_ENDIF
|
||||
rc = f77_zmq_bind(new_zmq_pull_socket, zmq_socket_pull_tcp_address)
|
||||
if (rc /= 0) then
|
||||
icount = icount-1
|
||||
! call sleep(3)
|
||||
zmq_socket_pull_tcp_address = 'tcp://*:'//zmq_port(2+icount*100)//' '
|
||||
zmq_socket_push_tcp_address = trim(qp_run_address)//':'//zmq_port(2+icount*100)//' '
|
||||
else
|
||||
@ -301,7 +300,6 @@ function new_zmq_push_socket(thread)
|
||||
END_DOC
|
||||
integer, intent(in) :: thread
|
||||
integer :: rc
|
||||
character*(8), external :: zmq_port
|
||||
integer(ZMQ_PTR) :: new_zmq_push_socket
|
||||
|
||||
call omp_set_lock(zmq_lock)
|
||||
@ -425,7 +423,6 @@ subroutine end_zmq_pair_socket(zmq_socket_pair)
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_socket_pair
|
||||
integer :: rc
|
||||
character*(8), external :: zmq_port
|
||||
|
||||
call omp_set_lock(zmq_lock)
|
||||
rc = f77_zmq_close(zmq_socket_pair)
|
||||
@ -445,7 +442,6 @@ subroutine end_zmq_pull_socket(zmq_socket_pull)
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_socket_pull
|
||||
integer :: rc
|
||||
character*(8), external :: zmq_port
|
||||
|
||||
! rc = f77_zmq_setsockopt(zmq_socket_pull,ZMQ_LINGER,0,4)
|
||||
! if (rc /= 0) then
|
||||
@ -472,7 +468,6 @@ subroutine end_zmq_push_socket(zmq_socket_push,thread)
|
||||
integer, intent(in) :: thread
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_socket_push
|
||||
integer :: rc
|
||||
character*(8), external :: zmq_port
|
||||
|
||||
rc = f77_zmq_setsockopt(zmq_socket_push,ZMQ_LINGER,300000,4)
|
||||
if (rc /= 0) then
|
||||
@ -756,6 +751,8 @@ integer function add_task_to_taskserver(zmq_to_qp_run_socket,task)
|
||||
|
||||
add_task_to_taskserver = 0
|
||||
|
||||
sze = len(trim(task)) + len(trim(zmq_state))+11
|
||||
allocate(character(len=sze) :: message)
|
||||
message='add_task '//trim(zmq_state)//' '//trim(task)
|
||||
sze = len(message)
|
||||
rc = f77_zmq_send(zmq_to_qp_run_socket, message, sze, 0)
|
||||
@ -771,6 +768,7 @@ integer function add_task_to_taskserver(zmq_to_qp_run_socket,task)
|
||||
add_task_to_taskserver = -1
|
||||
return
|
||||
endif
|
||||
deallocate(message)
|
||||
|
||||
end
|
||||
|
||||
@ -1032,7 +1030,6 @@ subroutine end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
||||
! Terminate the socket from the application to qp_run
|
||||
END_DOC
|
||||
integer(ZMQ_PTR), intent(in) :: zmq_to_qp_run_socket
|
||||
character*(8), external :: zmq_port
|
||||
integer :: rc
|
||||
|
||||
rc = f77_zmq_setsockopt(zmq_to_qp_run_socket,ZMQ_LINGER,300000,4)
|
||||
|
Loading…
Reference in New Issue
Block a user