Skip to content

Commit

Permalink
grid: Store pair as multiple fields in task_type
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Feb 7, 2020
1 parent a3a54d7 commit cd7f38e
Show file tree
Hide file tree
Showing 5 changed files with 346 additions and 316 deletions.
38 changes: 24 additions & 14 deletions src/qs_collocate_density.F
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ MODULE qs_collocate_density
rs_pw_transfer
USE rs_pw_interface, ONLY: density_rs2pw,&
density_rs2pw_basic
USE task_list_methods, ONLY: int2pair,&
rs_distribute_matrix
USE task_list_methods, ONLY: rs_distribute_matrix
USE task_list_types, ONLY: task_list_type,&
task_type

Expand Down Expand Up @@ -1438,12 +1437,12 @@ SUBROUTINE calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho,
routineP = moduleN//':'//routineN

CHARACTER(LEN=default_string_length) :: my_basis_type
INTEGER :: bcol, brow, ga_gb_function, handle, iatom, iatom_old, igrid_level, &
igrid_level_dummy, ikind, ikind_old, img, img_old, ipair, ipgf, iset, iset_old, itask, &
ithread, jatom, jatom_old, jkind, jkind_old, jpgf, jset, jset_old, lb, lbr, lbw, &
lmax_global, maxco, maxpgf, maxset, maxsgf, maxsgf_set, my_der_type, my_idir, n, na1, &
na2, natoms, nb1, nb2, nblock, ncoa, ncob, nimages, nr, nrlevel, nseta, nsetb, ntasks, &
nthread, nw, nxy, nz, nzsize, sgfa, sgfb, ub
INTEGER :: bcol, brow, ga_gb_function, handle, iatom, iatom_old, igrid_level, ikind, &
ikind_old, img, img_old, ipair, ipgf, iset, iset_old, itask, ithread, jatom, jatom_old, &
jkind, jkind_old, jpgf, jset, jset_old, lb, lbr, lbw, lmax_global, maxco, maxpgf, maxset, &
maxsgf, maxsgf_set, my_der_type, my_idir, n, na1, na2, natoms, nb1, nb2, nblock, ncoa, &
ncob, nimages, nr, nrlevel, nseta, nsetb, ntasks, nthread, nw, nxy, nz, nzsize, sgfa, &
sgfb, ub
INTEGER(kind=int_8), DIMENSION(:), POINTER :: atom_pair_recv, atom_pair_send
INTEGER, DIMENSION(:), POINTER :: la_max, la_min, lb_max, lb_min, mylmax, &
npgfa, npgfb, nsgfa, nsgfb
Expand Down Expand Up @@ -1691,7 +1690,7 @@ SUBROUTINE calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho,
!$OMP PRIVATE(nsetb,nsgfb,sphi_b,zetb,p_block,found), &
!$OMP PRIVATE(atom_pair_changed,ncoa,sgfa,ncob,sgfb,rab,rab2,ra,rb,zetp), &
!$OMP PRIVATE(na1,na2,nb1,nb2,scale,use_subpatch,rab_inv,ithread,lb,ub,n,nw), &
!$OMP PRIVATE(itask,nz,nxy,nzsize,nrlevel,nblock,lbw,lbr,nr,igrid_level_dummy)
!$OMP PRIVATE(itask,nz,nxy,nzsize,nrlevel,nblock,lbw,lbr,nr)

ithread = 0
!$ ithread = omp_get_thread_num()
Expand All @@ -1713,9 +1712,14 @@ SUBROUTINE calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho,
!$OMP DO schedule(dynamic, MAX(1,task_list%npairs(igrid_level)/(nthread*50)))
loop_pairs: DO ipair = 1, task_list%npairs(igrid_level)
loop_tasks: DO itask = task_list%taskstart(ipair, igrid_level), task_list%taskstop(ipair, igrid_level)
!decode the atom pair and basis info (igrid_level_dummy equals do loop variable by construction).
CALL int2pair(tasks(itask)%pair, igrid_level_dummy, img, iatom, jatom, iset, jset, ipgf, jpgf, &
nimages, natoms, maxset, maxpgf)
!decode the atom pair and basis info (grid_level equals do loop variable by construction).
img = tasks(itask)%image
iatom = tasks(itask)%iatom
jatom = tasks(itask)%jatom
iset = tasks(itask)%iset
jset = tasks(itask)%jset
ipgf = tasks(itask)%ipgf
jpgf = tasks(itask)%jpgf
ikind = particle_set(iatom)%atomic_kind%kind_number
jkind = particle_set(jatom)%atomic_kind%kind_number

Expand Down Expand Up @@ -2170,8 +2174,14 @@ SUBROUTINE calculate_drho_elec(matrix_p, matrix_p_kp, drho, drho_gspace, qs_env,
loop_tasks: DO itask = 1, ntasks
!decode the atom pair and basis info
CALL int2pair(tasks(itask)%pair, igrid_level, img, iatom, jatom, iset, jset, ipgf, jpgf, &
nimages, natoms, maxset, maxpgf)
igrid_level = tasks(itask)%grid_level
img = tasks(itask)%image
iatom = tasks(itask)%iatom
jatom = tasks(itask)%jatom
iset = tasks(itask)%iset
jset = tasks(itask)%jset
ipgf = tasks(itask)%ipgf
jpgf = tasks(itask)%jpgf
ikind = particle_set(iatom)%atomic_kind%kind_number
jkind = particle_set(jatom)%atomic_kind%kind_number
Expand Down
24 changes: 17 additions & 7 deletions src/qs_integrate_potential_product.F
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ MODULE qs_integrate_potential_product
rs_grid_release,&
rs_grid_retain
USE rs_pw_interface, ONLY: potential_pw2rs
USE task_list_methods, ONLY: int2pair,&
rs_distribute_matrix
USE task_list_methods, ONLY: rs_distribute_matrix
USE task_list_types, ONLY: task_list_type,&
task_type
USE virial_types, ONLY: virial_type
Expand Down Expand Up @@ -516,9 +515,14 @@ SUBROUTINE integrate_v_rspace_low(v_rspace, hmat, hmat_kp, pmat, pmat_kp, qs_env
!$OMP DO schedule (dynamic, MAX(1,task_list%npairs(igrid_level)/(nthread*50)))
loop_pairs: DO ipair = 1, task_list%npairs(igrid_level)
loop_tasks: DO itask = task_list%taskstart(ipair, igrid_level), task_list%taskstop(ipair, igrid_level)

CALL int2pair(tasks(itask)%pair, ilevel, img, iatom, jatom, iset, jset, ipgf, jpgf, &
nimages, natom, maxset, maxpgf)
ilevel = tasks(itask)%grid_level
img = tasks(itask)%image
iatom = tasks(itask)%iatom
jatom = tasks(itask)%jatom
iset = tasks(itask)%iset
jset = tasks(itask)%jset
ipgf = tasks(itask)%ipgf
jpgf = tasks(itask)%jpgf
CPASSERT(img == 1 .OR. do_kp)

! At the start of a block of tasks, get atom data (and kind data, if needed)
Expand Down Expand Up @@ -731,8 +735,14 @@ SUBROUTINE integrate_v_rspace_low(v_rspace, hmat, hmat_kp, pmat, pmat_kp, qs_env
new_set_pair_coming = .FALSE.
atom_pair_done = .FALSE.
IF (itask < task_list%taskstop(ipair, igrid_level)) THEN
CALL int2pair(tasks(itask + 1)%pair, ilevel, img, iatom, jatom, iset_new, jset_new, ipgf_new, jpgf_new, &
nimages, natom, maxset, maxpgf)
ilevel = tasks(itask + 1)%grid_level
img = tasks(itask + 1)%image
iatom = tasks(itask + 1)%iatom
jatom = tasks(itask + 1)%jatom
iset_new = tasks(itask + 1)%iset
jset_new = tasks(itask + 1)%jset
ipgf_new = tasks(itask + 1)%ipgf
jpgf_new = tasks(itask + 1)%jpgf
IF (iset_new .NE. iset .OR. jset_new .NE. jset) THEN
new_set_pair_coming = .TRUE.
ENDIF
Expand Down
16 changes: 10 additions & 6 deletions src/qs_linres_current.F
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ MODULE qs_linres_current
rs_grid_retain, rs_grid_zero
USE rs_pw_interface, ONLY: density_rs2pw
USE task_list_methods, ONLY: distribute_tasks,&
int2pair,&
rs_distribute_matrix,&
task_list_inner_loop
USE task_list_types, ONLY: reallocate_tasks,&
Expand Down Expand Up @@ -870,7 +869,7 @@ SUBROUTINE calculate_jrho_resp(mat_d0, mat_jp, mat_jp_rii, mat_jp_riii, iB, idir
CALL task_list_inner_loop(tasks, dist_ab, ntasks, curr_tasks, rs_descs, &
dft_control, cube_info, gridlevel_info, cindex, &
iatom, jatom, rpgfa, rpgfb, zeta, zetb, kind_radius_b, set_radius_a, set_radius_b, ra, rab, &
la_max, la_min, lb_max, lb_min, npgfa, npgfb, maxpgf, maxset, natom, nimages, nseta, nsetb)
la_max, la_min, lb_max, lb_min, npgfa, npgfb, nseta, nsetb)

END DO
CALL neighbor_list_iterator_release(nl_iterator)
Expand All @@ -885,7 +884,7 @@ SUBROUTINE calculate_jrho_resp(mat_d0, mat_jp, mat_jp_rii, mat_jp_riii, iB, idir
ENDIF

! sorts / redistributes the task list
CALL distribute_tasks(rs_descs, ntasks, natom, maxset, maxpgf, nimages, &
CALL distribute_tasks(rs_descs, ntasks, natom, nimages, &
tasks, dist_ab, atom_pair_send, atom_pair_recv, &
symmetric=.FALSE., reorder_rs_grid_ranks=.TRUE., &
skip_load_balance_distributed=.FALSE.)
Expand Down Expand Up @@ -976,9 +975,14 @@ SUBROUTINE calculate_jrho_resp(mat_d0, mat_jp, mat_jp_rii, mat_jp_riii, iB, idir
ikind_old = -1; jkind_old = -1

loop_tasks: DO itask = 1, ntasks

CALL int2pair(tasks(itask)%pair, igrid_level, cindex, iatom, jatom, iset, jset, ipgf, jpgf, &
nimages, natom, maxset, maxpgf)
igrid_level = tasks(itask)%grid_level
cindex = tasks(itask)%image
iatom = tasks(itask)%iatom
jatom = tasks(itask)%jatom
iset = tasks(itask)%iset
jset = tasks(itask)%jset
ipgf = tasks(itask)%ipgf
jpgf = tasks(itask)%jpgf

! apparently generalised collocation not implemented correctly yet
CPASSERT(tasks(itask)%dist_type .NE. 2)
Expand Down

0 comments on commit cd7f38e

Please sign in to comment.