2016-02-19 00:20:28 +01:00
|
|
|
subroutine ao_bielec_integrals_in_map_slave_tcp(i)
|
2015-12-07 22:03:33 +01:00
|
|
|
implicit none
|
2016-02-19 00:20:28 +01:00
|
|
|
integer, intent(in) :: i
|
2015-12-07 22:03:33 +01:00
|
|
|
BEGIN_DOC
|
2016-02-19 00:20:28 +01:00
|
|
|
! Computes a buffer of integrals. i is the ID of the current thread.
|
2015-12-07 22:03:33 +01:00
|
|
|
END_DOC
|
2016-02-19 00:20:28 +01:00
|
|
|
call ao_bielec_integrals_in_map_slave(0,i)
|
2015-12-07 22:03:33 +01:00
|
|
|
end
|
|
|
|
|
2016-02-19 00:20:28 +01:00
|
|
|
|
|
|
|
subroutine ao_bielec_integrals_in_map_slave_inproc(i)
|
2015-12-07 22:03:33 +01:00
|
|
|
implicit none
|
2016-02-19 00:20:28 +01:00
|
|
|
integer, intent(in) :: i
|
2015-12-07 22:03:33 +01:00
|
|
|
BEGIN_DOC
|
2016-02-19 00:20:28 +01:00
|
|
|
! Computes a buffer of integrals. i is the ID of the current thread.
|
2015-12-07 22:03:33 +01:00
|
|
|
END_DOC
|
2016-02-19 00:20:28 +01:00
|
|
|
call ao_bielec_integrals_in_map_slave(1,i)
|
2015-12-07 22:03:33 +01:00
|
|
|
end
|
|
|
|
|
2016-02-19 00:20:28 +01:00
|
|
|
|
|
|
|
subroutine push_integrals(zmq_socket_push, n_integrals, buffer_i, buffer_value, task_id)
|
|
|
|
use f77_zmq
|
|
|
|
use map_module
|
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
! Push integrals in the push socket
|
|
|
|
END_DOC
|
|
|
|
integer(ZMQ_PTR), intent(in) :: zmq_socket_push
|
|
|
|
integer, intent(in) :: n_integrals
|
|
|
|
integer(key_kind), intent(in) :: buffer_i(*)
|
|
|
|
real(integral_kind), intent(in) :: buffer_value(*)
|
|
|
|
integer, intent(in) :: task_id
|
|
|
|
integer :: rc
|
|
|
|
|
|
|
|
rc = f77_zmq_send( zmq_socket_push, n_integrals, 4, ZMQ_SNDMORE)
|
|
|
|
if (rc /= 4) then
|
2016-07-13 01:10:36 +02:00
|
|
|
print *, irp_here, ': f77_zmq_send( zmq_socket_push, n_integrals, 4, ZMQ_SNDMORE)'
|
2016-02-19 00:20:28 +01:00
|
|
|
stop 'error'
|
|
|
|
endif
|
|
|
|
|
|
|
|
rc = f77_zmq_send( zmq_socket_push, buffer_i, key_kind*n_integrals, ZMQ_SNDMORE)
|
|
|
|
if (rc /= key_kind*n_integrals) then
|
2016-07-13 01:10:36 +02:00
|
|
|
print *, irp_here, ': f77_zmq_send( zmq_socket_push, buffer_i, key_kind*n_integrals, ZMQ_SNDMORE)'
|
2016-02-19 00:20:28 +01:00
|
|
|
stop 'error'
|
|
|
|
endif
|
|
|
|
|
|
|
|
rc = f77_zmq_send( zmq_socket_push, buffer_value, integral_kind*n_integrals, ZMQ_SNDMORE)
|
|
|
|
if (rc /= integral_kind*n_integrals) then
|
2016-07-13 01:10:36 +02:00
|
|
|
print *, irp_here, ': f77_zmq_send( zmq_socket_push, buffer_value, integral_kind*n_integrals, 0)'
|
2016-02-19 00:20:28 +01:00
|
|
|
stop 'error'
|
|
|
|
endif
|
|
|
|
|
|
|
|
rc = f77_zmq_send( zmq_socket_push, task_id, 4, 0)
|
|
|
|
if (rc /= 4) then
|
2016-07-13 01:10:36 +02:00
|
|
|
print *, irp_here, ': f77_zmq_send( zmq_socket_push, task_id, 4, 0)'
|
2016-02-19 00:20:28 +01:00
|
|
|
stop 'error'
|
|
|
|
endif
|
|
|
|
|
|
|
|
! Activate is zmq_socket_push is a REQ
|
2017-05-09 21:34:01 +02:00
|
|
|
! integer :: idummy
|
|
|
|
! rc = f77_zmq_recv( zmq_socket_push, idummy, 4, 0)
|
|
|
|
! if (rc /= 4) then
|
|
|
|
! print *, irp_here, ': f77_zmq_send( zmq_socket_push, idummy, 4, 0)'
|
|
|
|
! stop 'error'
|
|
|
|
! endif
|
2016-02-19 00:20:28 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-02 10:31:57 +02:00
|
|
|
|
|
|
|
|
2016-02-19 00:20:28 +01:00
|
|
|
subroutine ao_bielec_integrals_in_map_slave(thread,iproc)
|
2015-12-01 16:45:41 +01:00
|
|
|
use map_module
|
|
|
|
use f77_zmq
|
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
! Computes a buffer of integrals
|
|
|
|
END_DOC
|
|
|
|
|
2016-02-19 00:20:28 +01:00
|
|
|
integer, intent(in) :: thread, iproc
|
2015-12-07 22:03:33 +01:00
|
|
|
|
2015-12-01 16:45:41 +01:00
|
|
|
integer :: j,l,n_integrals
|
|
|
|
integer :: rc
|
|
|
|
real(integral_kind), allocatable :: buffer_value(:)
|
|
|
|
integer(key_kind), allocatable :: buffer_i(:)
|
2015-12-07 22:03:33 +01:00
|
|
|
|
|
|
|
integer :: worker_id, task_id
|
|
|
|
character*(512) :: task
|
|
|
|
|
|
|
|
integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket
|
|
|
|
integer(ZMQ_PTR) :: zmq_to_qp_run_socket
|
|
|
|
|
2016-02-19 00:20:28 +01:00
|
|
|
integer(ZMQ_PTR), external :: new_zmq_push_socket
|
2015-12-07 22:03:33 +01:00
|
|
|
integer(ZMQ_PTR) :: zmq_socket_push
|
2016-02-19 00:20:28 +01:00
|
|
|
|
2016-07-26 18:29:52 +02:00
|
|
|
character*(64) :: state
|
|
|
|
|
2016-02-19 00:20:28 +01:00
|
|
|
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
|
|
|
zmq_socket_push = new_zmq_push_socket(thread)
|
2015-12-01 16:45:41 +01:00
|
|
|
|
2015-12-07 22:03:33 +01:00
|
|
|
allocate ( buffer_i(ao_num*ao_num), buffer_value(ao_num*ao_num) )
|
2015-12-01 16:45:41 +01:00
|
|
|
|
2015-12-07 22:03:33 +01:00
|
|
|
call connect_to_taskserver(zmq_to_qp_run_socket,worker_id,thread)
|
2015-12-01 16:45:41 +01:00
|
|
|
|
2015-12-07 22:03:33 +01:00
|
|
|
do
|
|
|
|
call get_task_from_taskserver(zmq_to_qp_run_socket,worker_id, task_id, task)
|
2016-02-19 00:20:28 +01:00
|
|
|
if (task_id == 0) exit
|
2016-06-23 12:13:18 +02:00
|
|
|
read(task,*) j, l
|
|
|
|
call compute_ao_integrals_jl(j,l,n_integrals,buffer_i,buffer_value)
|
2016-05-02 10:31:57 +02:00
|
|
|
call task_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id)
|
2016-02-19 00:20:28 +01:00
|
|
|
call push_integrals(zmq_socket_push, n_integrals, buffer_i, buffer_value, task_id)
|
2015-12-01 16:45:41 +01:00
|
|
|
enddo
|
|
|
|
|
|
|
|
|
2016-02-19 00:20:28 +01:00
|
|
|
call disconnect_from_taskserver(zmq_to_qp_run_socket,zmq_socket_push,worker_id)
|
2016-07-26 18:29:52 +02:00
|
|
|
deallocate( buffer_i, buffer_value )
|
2016-02-22 20:17:48 +01:00
|
|
|
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
2016-02-19 00:20:28 +01:00
|
|
|
call end_zmq_push_socket(zmq_socket_push,thread)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2015-12-07 22:03:33 +01:00
|
|
|
|
2015-12-01 16:45:41 +01:00
|
|
|
subroutine ao_bielec_integrals_in_map_collector
|
|
|
|
use map_module
|
|
|
|
use f77_zmq
|
|
|
|
implicit none
|
|
|
|
BEGIN_DOC
|
|
|
|
! Collects results from the AO integral calculation
|
|
|
|
END_DOC
|
|
|
|
|
|
|
|
integer :: j,l,n_integrals
|
|
|
|
integer :: rc
|
2016-02-19 00:20:28 +01:00
|
|
|
|
2015-12-01 16:45:41 +01:00
|
|
|
real(integral_kind), allocatable :: buffer_value(:)
|
|
|
|
integer(key_kind), allocatable :: buffer_i(:)
|
2016-02-19 00:20:28 +01:00
|
|
|
|
|
|
|
integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket
|
|
|
|
integer(ZMQ_PTR) :: zmq_to_qp_run_socket
|
|
|
|
|
|
|
|
integer(ZMQ_PTR), external :: new_zmq_pull_socket
|
|
|
|
integer(ZMQ_PTR) :: zmq_socket_pull
|
|
|
|
|
|
|
|
integer*8 :: control, accu
|
2016-07-18 16:22:42 +02:00
|
|
|
integer :: task_id, more, sze
|
2016-02-19 00:20:28 +01:00
|
|
|
|
|
|
|
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
|
|
|
zmq_socket_pull = new_zmq_pull_socket()
|
2015-12-01 16:45:41 +01:00
|
|
|
|
2016-07-18 16:22:42 +02:00
|
|
|
sze = ao_num*ao_num
|
|
|
|
allocate ( buffer_i(sze), buffer_value(sze) )
|
2015-12-01 16:45:41 +01:00
|
|
|
|
2016-02-19 00:20:28 +01:00
|
|
|
accu = 0_8
|
|
|
|
more = 1
|
|
|
|
do while (more == 1)
|
2015-12-01 16:45:41 +01:00
|
|
|
|
2016-07-18 16:22:42 +02:00
|
|
|
rc = f77_zmq_recv( zmq_socket_pull, n_integrals, 4, 0)
|
|
|
|
if (rc == -1) then
|
|
|
|
n_integrals = 0
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
if (rc /= 4) then
|
|
|
|
print *, irp_here, ': f77_zmq_recv( zmq_socket_pull, n_integrals, 4, 0)'
|
|
|
|
stop 'error'
|
|
|
|
endif
|
|
|
|
|
2015-12-07 22:03:33 +01:00
|
|
|
if (n_integrals >= 0) then
|
2016-07-13 01:10:36 +02:00
|
|
|
|
2016-07-18 16:22:42 +02:00
|
|
|
if (n_integrals > sze) then
|
|
|
|
deallocate (buffer_value, buffer_i)
|
|
|
|
sze = n_integrals
|
|
|
|
allocate (buffer_value(sze), buffer_i(sze))
|
|
|
|
endif
|
|
|
|
|
|
|
|
rc = f77_zmq_recv( zmq_socket_pull, buffer_i, key_kind*n_integrals, 0)
|
|
|
|
if (rc /= key_kind*n_integrals) then
|
|
|
|
print *, rc, key_kind, n_integrals
|
|
|
|
print *, irp_here, ': f77_zmq_recv( zmq_socket_pull, buffer_i, key_kind*n_integrals, 0)'
|
|
|
|
stop 'error'
|
|
|
|
endif
|
|
|
|
|
|
|
|
rc = f77_zmq_recv( zmq_socket_pull, buffer_value, integral_kind*n_integrals, 0)
|
|
|
|
if (rc /= integral_kind*n_integrals) then
|
|
|
|
print *, irp_here, ': f77_zmq_recv( zmq_socket_pull, buffer_value, integral_kind*n_integrals, 0)'
|
|
|
|
stop 'error'
|
|
|
|
endif
|
|
|
|
|
|
|
|
rc = f77_zmq_recv( zmq_socket_pull, task_id, 4, 0)
|
|
|
|
|
|
|
|
! Activate if zmq_socket_pull is a REP
|
2017-05-09 21:34:01 +02:00
|
|
|
! rc = f77_zmq_send( zmq_socket_pull, 0, 4, 0)
|
|
|
|
! if (rc /= 4) then
|
|
|
|
! print *, irp_here, ' : f77_zmq_send (zmq_socket_pull,...'
|
|
|
|
! stop 'error'
|
|
|
|
! endif
|
2016-07-18 16:22:42 +02:00
|
|
|
|
|
|
|
|
2015-12-01 16:45:41 +01:00
|
|
|
call insert_into_ao_integrals_map(n_integrals,buffer_i,buffer_value)
|
2016-02-19 00:20:28 +01:00
|
|
|
accu += n_integrals
|
|
|
|
if (task_id /= 0) then
|
|
|
|
call zmq_delete_task(zmq_to_qp_run_socket,zmq_socket_pull,task_id,more)
|
|
|
|
endif
|
2015-12-01 16:45:41 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
enddo
|
|
|
|
|
|
|
|
deallocate( buffer_i, buffer_value )
|
2015-12-07 22:03:33 +01:00
|
|
|
|
2016-02-19 00:20:28 +01:00
|
|
|
integer (map_size_kind) :: get_ao_map_size
|
|
|
|
control = get_ao_map_size(ao_integrals_map)
|
|
|
|
|
|
|
|
if (control /= accu) then
|
2016-06-16 12:47:08 +02:00
|
|
|
print *, ''
|
|
|
|
print *, irp_here
|
|
|
|
print *, 'Control : ', control
|
|
|
|
print *, 'Accu : ', accu
|
|
|
|
print *, 'Some integrals were lost during the parallel computation.'
|
2016-02-19 00:20:28 +01:00
|
|
|
print *, 'Try to reduce the number of threads.'
|
|
|
|
stop
|
|
|
|
endif
|
|
|
|
|
|
|
|
call end_zmq_to_qp_run_socket(zmq_to_qp_run_socket)
|
|
|
|
call end_zmq_pull_socket(zmq_socket_pull)
|
|
|
|
|
2015-12-01 16:45:41 +01:00
|
|
|
end
|
|
|
|
|