mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-29 06:35:28 -04:00
Fixed data races and undefined behavior
- Assert presence of certain arguments. - Fixed potential data races (Helgrind). - Avoid undefined behavior (UBSan). Minor (qs_harmonics_atom.F): - reduced memory consumption.
This commit is contained in:
parent
e5f3bfdf22
commit
d5104b917e
13 changed files with 29 additions and 29 deletions
|
|
@ -547,6 +547,8 @@ CONTAINS
|
|||
END DO
|
||||
END DO
|
||||
|
||||
CPASSERT(PRESENT(iatom) .AND. PRESENT(jatom) .AND. PRESENT(katom))
|
||||
CPASSERT(PRESENT(deltaR))
|
||||
DO idir = 1, 3
|
||||
DO j = ncoset(lb_min_set - 1) + 1, ncoset(lb_max_set)
|
||||
DO i = ncoset(la_min_set - 1) + 1, ncoset(la_max_set)
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ CONTAINS
|
|||
!$OMP matrix_r_rxvr, matrix_rxvr_r, my_r_rxvr, my_rxvr_r, &
|
||||
!$OMP pseudoatom, do_symmetric) &
|
||||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, cell_b, rab, &
|
||||
!$OMP iab, irow, icol, &
|
||||
!$OMP iab, irow, icol, lock_num, &
|
||||
!$OMP blocks_rv, blocks_rxrv, blocks_rrv, blocks_rvr, blocks_rrv_vrr, &
|
||||
!$OMP blocks_r_rxvr, blocks_rxvr_r, blocks_r_doublecom, &
|
||||
!$OMP found, iac, ibc, alist_ac, alist_bc, &
|
||||
|
|
@ -1619,7 +1619,7 @@ CONTAINS
|
|||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP SHARED (basis_set, matrix_mag_nl, sap_int, natom, nkind, eps_ppnl, locks, sab_all, &
|
||||
!$OMP particle_set, my_ref, refpoint) &
|
||||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, cell_b, rab, &
|
||||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, cell_b, rab, lock_num, &
|
||||
!$OMP iab, irow, icol, blocks_mag, r_ps, r_b, go, hash, &
|
||||
!$OMP found, iac, ibc, alist_ac, alist_bc, acint, bcint, &
|
||||
!$OMP achint, bchint, na, np, nb, kkind, kac, kbc)
|
||||
|
|
@ -1870,7 +1870,7 @@ CONTAINS
|
|||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, cell_b, rab, &
|
||||
!$OMP iab, irow, icol, blocks_rv, &
|
||||
!$OMP found, iac, ibc, alist_ac, alist_bc, &
|
||||
!$OMP na, np, nb, kkind, kac, kbc, i, &
|
||||
!$OMP na, np, nb, kkind, kac, kbc, i, lock_num, &
|
||||
!$OMP hash, natom, delta, gamma, achint, bchint, acint, bcint)
|
||||
|
||||
!$OMP SINGLE
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ CONTAINS
|
|||
!$OMP sab_orb, sac_ae, nthread, ncoset, nkind, cell_to_index, &
|
||||
!$OMP slot, ldsab, maxnset, ldai, nder, maxl, maxco, dokp, doat, locks, natom) &
|
||||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, rab, basis_set_a, basis_set_b, &
|
||||
!$OMP first_sgfa, la_max, la_min, npgfa, nsgfa, sphi_a, &
|
||||
!$OMP first_sgfa, la_max, la_min, npgfa, nsgfa, sphi_a, lock_num, &
|
||||
!$OMP zeta, first_sgfb, lb_max, lb_min, npgfb, nsetb, rpgfb, set_radius_b, sphi_b, &
|
||||
!$OMP zetb, zeta_c, alpha_c, core_charge, dab, irow, icol, h_block, found, iset, ncoa, &
|
||||
!$OMP sgfa, jset, ncob, sgfb, nsgfb, p_block, work, pab, hab, kkind, nseta, &
|
||||
|
|
@ -700,7 +700,7 @@ CONTAINS
|
|||
!$OMP sab_orb, sac_ae, nthread, ncoset, nkind, calpha, ccore, eps_core_charge, &
|
||||
!$OMP slot, ldsab, maxnset, ldai, maxl, maxco, doat, locks, natom) &
|
||||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, rab, basis_set_a, basis_set_b, &
|
||||
!$OMP first_sgfa, la_max, la_min, npgfa, nsgfa, sphi_a, &
|
||||
!$OMP first_sgfa, la_max, la_min, npgfa, nsgfa, sphi_a, lock_num, &
|
||||
!$OMP zeta, first_sgfb, lb_max, lb_min, npgfb, nsetb, rpgfb, set_radius_b, sphi_b, &
|
||||
!$OMP zetb, zeta_c, alpha_c, core_charge, dab, irow, icol, h_block, found, iset, ncoa, &
|
||||
!$OMP sgfa, jset, ncob, sgfb, nsgfb, p_block, work, pab, hab, kkind, nseta, &
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ CONTAINS
|
|||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, rab, basis_set_a, basis_set_b, &
|
||||
!$OMP first_sgfa, la_max, la_min, npgfa, nsgfa, sphi_a, &
|
||||
!$OMP zeta, first_sgfb, lb_max, lb_min, npgfb, nsetb, rpgfb, set_radius_b, sphi_b, &
|
||||
!$OMP zetb, dab, irow, icol, h_block, found, iset, ncoa, &
|
||||
!$OMP zetb, dab, irow, icol, h_block, found, iset, ncoa, lock_num, &
|
||||
!$OMP sgfa, jset, ncob, sgfb, nsgfb, p_block, work, pab, hab, hab2, hab2_w, &
|
||||
!$OMP atk0, atk1, h1_1block, h1_2block, h1_3block, kkind, nseta, &
|
||||
!$OMP gth_potential, sgp_potential, alpha, cexp_ppl, lpotextended, &
|
||||
|
|
@ -856,7 +856,7 @@ CONTAINS
|
|||
!$OMP SHARED (maxco,maxsgf,basis_set_list,calculate_forces,lri_ppl_coef,qs_kind_set,&
|
||||
!$OMP locks,natom,use_virial,virial,ncoset,atom_of_kind,sac_ppl) &
|
||||
!$OMP PRIVATE (ikind,kkind,iatom,katom,atom_a,rac,va,dva,dvas,basis_set,slot,&
|
||||
!$OMP first_sgfa,la_max,la_min,npgfa,nseta,nsgfa,rpgfa,set_radius_a,&
|
||||
!$OMP first_sgfa,la_max,la_min,npgfa,nseta,nsgfa,rpgfa,set_radius_a,lock_num,&
|
||||
!$OMP sphi_a,zeta,gth_potential,sgp_potential,alpha,cexp_ppl,lpotextended,ppl_radius,&
|
||||
!$OMP nexp_ppl,alpha_ppl,nct_ppl,cval_ppl,nloc,n_local,nrloc,a_local,aloc,bloc,c_local,nfun,work,&
|
||||
!$OMP hash,dac,force_a,iset,sgfa,sgfb,ncoa,bcon,cval_lpot,nct_lpot,alpha_lpot,nexp_lpot,&
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ CONTAINS
|
|||
!$OMP locks, virial, use_virial, calculate_forces, do_soc, natom) &
|
||||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, cell_b, rab, &
|
||||
!$OMP slot, iab, atom_a, f0, irow, icol, h_block, &
|
||||
!$OMP l_block_x, l_block_y, l_block_z, &
|
||||
!$OMP l_block_x, l_block_y, l_block_z, lock_num, &
|
||||
!$OMP r_2block, r_3block, atk, &
|
||||
!$OMP found,p_block, iac, ibc, alist_ac, alist_bc, acint, bcint, &
|
||||
!$OMP achint, bchint, alkint, blkint, &
|
||||
|
|
|
|||
|
|
@ -390,7 +390,9 @@ void dbm_zero(dbm_matrix_t *matrix) {
|
|||
#pragma omp parallel for DBM_OMP_SCHEDULE
|
||||
for (int ishard = 0; ishard < dbm_get_num_shards(matrix); ishard++) {
|
||||
dbm_shard_t *shard = &matrix->shards[ishard];
|
||||
memset(shard->data, 0, shard->data_size * sizeof(double));
|
||||
if (shard->data != NULL) {
|
||||
memset(shard->data, 0, shard->data_size * sizeof(double));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -238,8 +238,10 @@ void dbm_shard_allocate_promised_blocks(dbm_shard_t *shard) {
|
|||
shard->data =
|
||||
dbm_mempool_host_malloc(shard->data_allocated * sizeof(double));
|
||||
assert(shard->data != NULL);
|
||||
memcpy(shard->data, data, shard->data_size * sizeof(double));
|
||||
dbm_mempool_host_free(data);
|
||||
if (data != NULL) {
|
||||
memcpy(shard->data, data, shard->data_size * sizeof(double));
|
||||
dbm_mempool_host_free(data);
|
||||
}
|
||||
}
|
||||
|
||||
// Zero new blocks.
|
||||
|
|
|
|||
|
|
@ -216,8 +216,6 @@ CONTAINS
|
|||
!$OMP PRIVATE(is1,l1,m1,is2,l2,m2,is,n,y)
|
||||
|
||||
ALLOCATE (y(na))
|
||||
ALLOCATE (dc(nco(llmax), 3))
|
||||
|
||||
!$OMP DO
|
||||
DO iso = 1, max_s_harm
|
||||
l = indso(1, iso)
|
||||
|
|
@ -230,6 +228,7 @@ CONTAINS
|
|||
END DO ! ia
|
||||
END DO ! iso
|
||||
!$OMP END DO
|
||||
DEALLOCATE (y)
|
||||
|
||||
!$OMP DO
|
||||
DO ia = 1, na
|
||||
|
|
@ -243,6 +242,7 @@ CONTAINS
|
|||
! terms x^n1 y^n2 z^n3 transformed by spherical harmonics expansion coefficients
|
||||
!
|
||||
|
||||
ALLOCATE (dc(nco(llmax), 3))
|
||||
!$OMP DO
|
||||
DO ia = 1, na
|
||||
DO l = 0, indso(1, max_s_harm)
|
||||
|
|
@ -296,6 +296,7 @@ CONTAINS
|
|||
END DO ! l
|
||||
END DO !ia
|
||||
!$OMP END DO
|
||||
DEALLOCATE (dc)
|
||||
|
||||
! Expansion coefficients of the cartesian derivatives
|
||||
! of the product of two harmonics :
|
||||
|
|
@ -304,7 +305,6 @@ CONTAINS
|
|||
!$OMP DO COLLAPSE(3)
|
||||
DO iso1 = 1, maxs
|
||||
DO iso2 = 1, maxs
|
||||
|
||||
DO iso = 1, max_s_harm
|
||||
rx = 0.0_dp
|
||||
ry = 0.0_dp
|
||||
|
|
@ -320,9 +320,7 @@ CONTAINS
|
|||
END DO
|
||||
|
||||
harmonics%my_CG_dxyz(1, iso1, iso2, iso) = rx
|
||||
|
||||
harmonics%my_CG_dxyz(2, iso1, iso2, iso) = ry
|
||||
|
||||
harmonics%my_CG_dxyz(3, iso1, iso2, iso) = rz
|
||||
|
||||
END DO
|
||||
|
|
@ -356,9 +354,7 @@ CONTAINS
|
|||
END DO
|
||||
|
||||
harmonics%my_CG_dxyz_asym(1, iso1, iso2, iso) = drx
|
||||
|
||||
harmonics%my_CG_dxyz_asym(2, iso1, iso2, iso) = dry
|
||||
|
||||
harmonics%my_CG_dxyz_asym(3, iso1, iso2, iso) = drz
|
||||
|
||||
END DO ! iso
|
||||
|
|
@ -384,8 +380,6 @@ CONTAINS
|
|||
|
||||
! expansion coefficients of product of polar angle derivatives (dslm(1...)) in
|
||||
! spherical harmonics (used for tau functionals)
|
||||
|
||||
DEALLOCATE (y, dc)
|
||||
!$OMP END PARALLEL
|
||||
|
||||
CALL timestop(handle)
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ CONTAINS
|
|||
!$OMP first_sgfa, la_max, la_min, npgfa, nsgfa, nseta, rpgfa, set_radius_a, ncoa, ncob, force_a, &
|
||||
!$OMP zeta, first_sgfb, lb_max, lb_min, npgfb, nsetb, rpgfb, set_radius_b, nsgfb, p_block, dab, tab, &
|
||||
!$OMP slot, zetb, scon_a, scon_b, i, ic, irow, icol, f0, ff, found, trans, rab2, sgfa, sgfb, iset, jset, &
|
||||
!$OMP hash, hash1, hash2, iatom8) &
|
||||
!$OMP hash, hash1, hash2, iatom8, lock_num) &
|
||||
!$OMP REDUCTION (+ : pv_thread, force_thread )
|
||||
|
||||
!$OMP SINGLE
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ CONTAINS
|
|||
!$OMP , ikind, jkind, iatom, jatom, cell_b &
|
||||
!$OMP , basis_set_a, basis_set_b, img &
|
||||
!$OMP , found, next_task &
|
||||
!$OMP , kkind, paw_atom &
|
||||
!$OMP , kkind, paw_atom, lock_num &
|
||||
!$OMP , iac, alist_ac, kac, n_cont_a, list_a &
|
||||
!$OMP , ibc, alist_bc, kbc, n_cont_b, list_b &
|
||||
!$OMP , katom, rho_at, nsoctot &
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ CONTAINS
|
|||
!$OMP matrix_s, matrix_p,basis_set_list_a, basis_set_list_b, cell_to_index, &
|
||||
!$OMP matrixkp_s, matrixkp_p, locks, natom) &
|
||||
!$OMP PRIVATE (oint, owork, pmat, sint, ikind, jkind, iatom, jatom, rab, cell, &
|
||||
!$OMP basis_set_a, basis_set_b, &
|
||||
!$OMP basis_set_a, basis_set_b, lock_num, &
|
||||
!$OMP first_sgfa, la_max, la_min, npgfa, nsgfa, nseta, rpgfa, set_radius_a, ncoa, ncob, force_a, &
|
||||
!$OMP zeta, first_sgfb, lb_max, lb_min, npgfb, nsetb, rpgfb, set_radius_b, nsgfb, p_block, dab, f, &
|
||||
!$OMP zetb, scon_a, scon_b, ic, irow, icol, f0, ff, found, trans, rab2, n1, n2, sgfa, sgfb, iset, jset, &
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ CONTAINS
|
|||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, cell_b, &
|
||||
!$OMP iab, irow, icol, blocks_rv, &
|
||||
!$OMP found, iac, ibc, alist_ac, alist_bc, &
|
||||
!$OMP na, np, nb, kkind, kac, kbc, i, &
|
||||
!$OMP na, np, nb, kkind, kac, kbc, i, lock_num, &
|
||||
!$OMP hash, natom, acint, bcint, achint, bchint)
|
||||
|
||||
!$OMP SINGLE
|
||||
|
|
@ -453,7 +453,7 @@ CONTAINS
|
|||
!$OMP PRIVATE (kx_block,ky_block,kz_block,kab,qab,tab,ikind,jkind,iatom,jatom,rab,rac,rbc,cell, &
|
||||
!$OMP basis_set_a, basis_set_b, nseta, ncoa, ncob, ltab, nsetb, tkab, &
|
||||
!$OMP irow, icol, found, trans, sgfa, sgfb, iset, jset, &
|
||||
!$OMP hash, hash1, hash2, iatom8, slot) &
|
||||
!$OMP hash, hash1, hash2, iatom8, slot, lock_num) &
|
||||
!$OMP PRIVATE (first_sgfa, la_max, la_min, npgfa, nsgfa, rpgfa, set_radius_a, zeta, scon_a) &
|
||||
!$OMP PRIVATE (first_sgfb, lb_max, lb_min, npgfb, nsgfb, rpgfb, set_radius_b, zetb, scon_b) &
|
||||
!$OMP SHARED(particle_set, direction_or) &
|
||||
|
|
@ -1624,7 +1624,7 @@ CONTAINS
|
|||
!$OMP SHARED (basis_set, matrix_rv, direction_Or, &
|
||||
!$OMP sap_int, nkind, eps_ppnl, locks, sab_all) &
|
||||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, cell_b, rab, &
|
||||
!$OMP iab, irow, icol, blocks_rvr, &
|
||||
!$OMP iab, irow, icol, blocks_rvr, lock_num, &
|
||||
!$OMP found, iac, ibc, alist_ac, alist_bc, &
|
||||
!$OMP na, np, nb, kkind, kac, kbc, i, j, &
|
||||
!$OMP hash, natom, acint, bcint, achint, bchint)
|
||||
|
|
@ -1922,7 +1922,7 @@ CONTAINS
|
|||
!$OMP SHARED (basis_set, matrix_rv, &
|
||||
!$OMP sap_int, nkind, eps_ppnl, locks, sab_orb) &
|
||||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, cell_b, rab, &
|
||||
!$OMP iab, irow, icol, blocks_rv, &
|
||||
!$OMP iab, irow, icol, blocks_rv, lock_num, &
|
||||
!$OMP found, iac, ibc, alist_ac, alist_bc, &
|
||||
!$OMP na, np, nb, kkind, kac, kbc, i, j, &
|
||||
!$OMP hash, natom, acint, bcint, achint, bchint)
|
||||
|
|
@ -2336,7 +2336,7 @@ CONTAINS
|
|||
!$OMP SHARED (basis_set, matrix_rv, &
|
||||
!$OMP sap_int, nkind, eps_ppnl, locks, sab_all) &
|
||||
!$OMP PRIVATE (ikind, jkind, iatom, jatom, cell_b, rab, &
|
||||
!$OMP iab, irow, icol, blocks_rv, &
|
||||
!$OMP iab, irow, icol, blocks_rv, lock_num, &
|
||||
!$OMP found, iac, ibc, alist_ac, alist_bc, &
|
||||
!$OMP na, np, nb, kkind, kac, kbc, i, &
|
||||
!$OMP hash, natom, acint, bcint, achint, bchint)
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ CONTAINS
|
|||
!$OMP PRIVATE (real_block, imag_block, acint_cos, achint_cos, bcint_cos, bchint_cos, acint_sin,&
|
||||
!$OMP achint_sin, bcint_sin, bchint_sin, slot, ikind, jkind, iatom, jatom, cell_b, rab, irow, icol,&
|
||||
!$OMP found, kkind, iac, ibc, alist_cos_ac, alist_cos_bc, alist_sin_ac, alist_sin_bc, kac, kbc, &
|
||||
!$OMP na, np, nb, iatom8, hash)
|
||||
!$OMP na, np, nb, iatom8, hash, lock_num)
|
||||
|
||||
!$OMP SINGLE
|
||||
!$ ALLOCATE (locks(nlock))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue