9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-21 19:13:29 +01:00

Fixed distributed PT2

This commit is contained in:
Anthony Scemama 2021-04-27 00:35:18 +02:00
parent 0459eb475a
commit e0ce8d026b
4 changed files with 27 additions and 19 deletions

View File

@ -15,7 +15,7 @@ END_PROVIDER
pt2_n_tasks_max = min(pt2_n_tasks_max,1+N_det_generators/10000) pt2_n_tasks_max = min(pt2_n_tasks_max,1+N_det_generators/10000)
call write_int(6,pt2_n_tasks_max,'pt2_n_tasks_max') call write_int(6,pt2_n_tasks_max,'pt2_n_tasks_max')
pt2_F(:) = int(sqrt(float(pt2_n_tasks_max))) pt2_F(:) = max(int(sqrt(float(pt2_n_tasks_max))),1)
do i=1,pt2_n_0(1+pt2_N_teeth/4) do i=1,pt2_n_0(1+pt2_N_teeth/4)
pt2_F(i) = pt2_n_tasks_max*pt2_min_parallel_tasks pt2_F(i) = pt2_n_tasks_max*pt2_min_parallel_tasks
enddo enddo
@ -26,7 +26,6 @@ END_PROVIDER
pt2_F(i) = 1 pt2_F(i) = 1
enddo enddo
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ integer, pt2_N_teeth ] BEGIN_PROVIDER [ integer, pt2_N_teeth ]

View File

@ -183,9 +183,9 @@ subroutine run_pt2_slave_large(thread,iproc,energy)
type(selection_buffer) :: b type(selection_buffer) :: b
logical :: done, buffer_ready logical :: done, buffer_ready
type(pt2_type) :: pt2_data(1) type(pt2_type) :: pt2_data
integer :: n_tasks, k, N integer :: n_tasks, k, N
integer :: i_generator(1), subset integer :: i_generator, subset
integer :: bsize ! Size of selection buffers integer :: bsize ! Size of selection buffers
logical :: sending logical :: sending
@ -220,7 +220,14 @@ subroutine run_pt2_slave_large(thread,iproc,energy)
endif endif
if (n_tasks == 0) exit if (n_tasks == 0) exit
call sscanf_ddd(task, subset, i_generator(1), N) call sscanf_ddd(task, subset, i_generator, N)
!$OMP CRITICAL
print *, ':task:', subset, i_generator, N, pt2_F(i_generator)
!$OMP END CRITICAL
if( pt2_F(i_generator) <= 0 .or. pt2_F(i_generator) > N_det ) then
print *, irp_here
stop 'bug in selection'
endif
if (b%N == 0) then if (b%N == 0) then
! Only first time ! Only first time
bsize = min(N, (elec_alpha_num * (mo_num-elec_alpha_num))**2) bsize = min(N, (elec_alpha_num * (mo_num-elec_alpha_num))**2)
@ -232,15 +239,10 @@ subroutine run_pt2_slave_large(thread,iproc,energy)
double precision :: time0, time1 double precision :: time0, time1
call wall_time(time0) call wall_time(time0)
call pt2_alloc(pt2_data(1),N_states) call pt2_alloc(pt2_data,N_states)
b%cur = 0 b%cur = 0
!double precision :: time2 call select_connected(i_generator,energy,pt2_data,b,subset,pt2_F(i_generator))
!call wall_time(time2)
call select_connected(i_generator(1),energy,pt2_data(1),b,subset,pt2_F(i_generator(1)))
!call wall_time(time1)
!print *, i_generator(1), time1-time2, n_tasks, pt2_F(i_generator(1))
call wall_time(time1) call wall_time(time1)
!print *, '-->', i_generator(1), time1-time0, n_tasks
integer, external :: tasks_done_to_taskserver integer, external :: tasks_done_to_taskserver
if (tasks_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id,n_tasks) == -1) then if (tasks_done_to_taskserver(zmq_to_qp_run_socket,worker_id,task_id,n_tasks) == -1) then
@ -255,14 +257,14 @@ subroutine run_pt2_slave_large(thread,iproc,energy)
call omp_unset_lock(global_selection_buffer_lock) call omp_unset_lock(global_selection_buffer_lock)
if ( iproc == 1 ) then if ( iproc == 1 ) then
call omp_set_lock(global_selection_buffer_lock) call omp_set_lock(global_selection_buffer_lock)
call push_pt2_results_async_send(zmq_socket_push, i_generator, pt2_data, global_selection_buffer, task_id, n_tasks,sending) call push_pt2_results_async_send(zmq_socket_push, i_generator, pt2_data, global_selection_buffer, task_id, 1,sending)
global_selection_buffer%cur = 0 global_selection_buffer%cur = 0
call omp_unset_lock(global_selection_buffer_lock) call omp_unset_lock(global_selection_buffer_lock)
else else
call push_pt2_results_async_send(zmq_socket_push, i_generator, pt2_data, b, task_id, n_tasks,sending) call push_pt2_results_async_send(zmq_socket_push, i_generator, pt2_data, b, task_id, 1,sending)
endif endif
call pt2_dealloc(pt2_data(1)) call pt2_dealloc(pt2_data)
end do end do
call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending) call push_pt2_results_async_recv(zmq_socket_push,b%mini,sending)

View File

@ -122,7 +122,7 @@ subroutine run_slave_main
IRP_ENDIF IRP_ENDIF
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) cycle if (zmq_get_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) cycle
pt2_e0_denominator(1:N_states) = energy(1:N_states) pt2_e0_denominator(1:N_states) = energy(1:N_states)
TOUCH pt2_e0_denominator state_average_weight threshold_generators selection_weight TOUCH pt2_e0_denominator state_average_weight threshold_generators selection_weight psi_det psi_coef
if (mpi_master) then if (mpi_master) then
print *, 'N_det', N_det print *, 'N_det', N_det
@ -230,7 +230,8 @@ subroutine run_slave_main
IRP_ENDIF IRP_ENDIF
if (zmq_get_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) cycle if (zmq_get_dvector(zmq_to_qp_run_socket,1,'selection_weight',selection_weight,N_states) == -1) cycle
pt2_e0_denominator(1:N_states) = energy(1:N_states) pt2_e0_denominator(1:N_states) = energy(1:N_states)
SOFT_TOUCH pt2_e0_denominator state_average_weight pt2_stoch_istate threshold_generators selection_weight SOFT_TOUCH pt2_e0_denominator state_average_weight pt2_stoch_istate threshold_generators selection_weight psi_det psi_coef N_det_generators N_det_selectors
call wall_time(t1) call wall_time(t1)
call write_double(6,(t1-t0),'Broadcast time') call write_double(6,(t1-t0),'Broadcast time')
@ -300,7 +301,13 @@ subroutine run_slave_main
PROVIDE det_to_configuration PROVIDE det_to_configuration
endif endif
PROVIDE global_selection_buffer PROVIDE global_selection_buffer pt2_N_teeth pt2_F N_det_generators
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
PROVIDE psi_bilinear_matrix_transp_order psi_selectors_coef_transp psi_det_sorted
PROVIDE psi_det_hii selection_weight pseudo_sym pt2_min_parallel_tasks
if (mpi_master) then if (mpi_master) then
print *, 'Running PT2' print *, 'Running PT2'
endif endif

View File

@ -46,7 +46,7 @@ program fci
endif endif
else else
PROVIDE mo_two_e_integrals_in_map PROVIDE mo_two_e_integrals_in_map pt2_min_parallel_tasks
call run_slave_cipsi call run_slave_cipsi