From 708e1dba18770f41940c6645a0700677b7d5c60a Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Mon, 24 Aug 2026 14:55:40 +0000 Subject: [PATCH] KOKKOS: remove silent fp32/fp64 conversions package-wide Continue the fp32/fp64 cleanup started in #4754 and extend it to the full set of packages that provide KOKKOS styles. The conversions were found by building with clang and -Wall -Wextra -Wimplicit-float-conversion -Wdouble-promotion -pedantic in both the single- and the mixed-precision configuration, and then making every flagged conversion explicit. Both builds are now free of -Wimplicit-float-conversion and -Wdouble-promotion warnings. The changes follow a few repeated patterns: - Bare libm calls (sqrt, pow, exp, log, sin, cos, erfc, fabs, ...) on KK_FLOAT arguments resolve to the double overload and promote, so they are qualified with Kokkos:: to select the float overload. Note that Kokkos::pow() with an integer exponent still promotes, so those exponents are cast to KK_FLOAT. - Double literals and constants (1.0, 0.5, MY_PIS, EWALD_P, A1-A5, MY_EPSILON and similar) mixed into KK_FLOAT expressions are cast to KK_FLOAT, which folds at compile time. - Base-class double scalars used inside kernels are copied once into a local KK_FLOAT, using the existing _kk suffix convention. - Values that accumulate into EV_FLOAT fields, the per-atom eatom/vatom views or the atomic force and torque views are cast to KK_ACC_FLOAT, while values read back out of those views into float math are cast to KK_FLOAT. The direction was chosen per site from the declared view type. This distinction only matters in the mixed build, which is why it was built and cleaned as a separate configuration. - Host-side reductions into the base-class double eng_vdwl, eng_coul and virial[] are cast to double. Two changes go beyond adding a cast: pair_table_kokkos compute_fpair(), compute_evdwl() and compute_ecoul() now take and return KK_FLOAT like every other pair style instead of double. The table interpolation still runs in double internally through an explicit local and converts at the return. Previously this style's double interface propagated into the shared PairComputeFunctor and forced rsq to promote there for every style. The STACKPARAMS cutoff comparison in pair_kokkos.h is cast to KK_FLOAT accordingly, which is a no-op for the styles whose cutsq is already KK_FLOAT. In pair_tip4p_kokkos.h apply_site_force() the O-branch force components fOx and fHx are declared KK_FLOAT to match fdx in the same function and the sibling non-O branch above it, so the virial products are formed in KK_FLOAT and widened once at the accumulator. This is the only change that is not bit-identical: in the mixed build alone those virial products are formed in float rather than double. The single and double builds are unaffected. Everything else is numerically inert: in the default double build every added cast is a no-op, so results are unchanged. --- src/KOKKOS/angle_charmm_kokkos.cpp | 10 +- src/KOKKOS/angle_class2_kokkos.cpp | 196 ++--- src/KOKKOS/angle_class2_p6_kokkos.cpp | 16 +- src/KOKKOS/angle_class2xe_kokkos.cpp | 150 ++-- src/KOKKOS/angle_cosine_delta_kokkos.cpp | 142 ++-- src/KOKKOS/angle_cosine_kokkos.cpp | 148 ++-- src/KOKKOS/angle_cosine_periodic_kokkos.cpp | 138 ++-- src/KOKKOS/angle_cosine_shift_exp_kokkos.cpp | 142 ++-- src/KOKKOS/angle_cosine_shift_kokkos.cpp | 140 ++-- src/KOKKOS/angle_cosine_squared_kokkos.cpp | 138 ++-- ...angle_cosine_squared_restricted_kokkos.cpp | 138 ++-- src/KOKKOS/angle_cross_kokkos.cpp | 8 +- src/KOKKOS/angle_dipole_kokkos.cpp | 6 +- src/KOKKOS/angle_fourier_kokkos.cpp | 4 +- src/KOKKOS/angle_fourier_simple_kokkos.cpp | 12 +- src/KOKKOS/angle_gaussian_kokkos.cpp | 30 +- src/KOKKOS/angle_harmonic_kokkos.cpp | 8 +- src/KOKKOS/angle_mm3_kokkos.cpp | 16 +- src/KOKKOS/angle_mwlc_kokkos.cpp | 12 +- src/KOKKOS/angle_quartic_kokkos.cpp | 8 +- src/KOKKOS/angle_spica_kokkos.cpp | 252 +++--- src/KOKKOS/atom_vec_kokkos.cpp | 592 +++++++------- src/KOKKOS/bond_class2_kokkos.cpp | 122 +-- src/KOKKOS/bond_fene_expand_kokkos.cpp | 4 +- src/KOKKOS/bond_fene_kokkos.cpp | 2 +- src/KOKKOS/bond_fene_nm_kokkos.cpp | 12 +- src/KOKKOS/bond_gaussian_kokkos.cpp | 14 +- src/KOKKOS/bond_harmonic_kokkos.cpp | 2 +- src/KOKKOS/bond_harmonic_restrain_kokkos.cpp | 4 +- src/KOKKOS/bond_harmonic_shift_cut_kokkos.cpp | 4 +- src/KOKKOS/bond_harmonic_shift_kokkos.cpp | 4 +- src/KOKKOS/bond_mm3_kokkos.cpp | 2 +- src/KOKKOS/bond_morse_kokkos.cpp | 6 +- src/KOKKOS/bond_nonlinear_kokkos.cpp | 2 +- src/KOKKOS/bond_quartic_exp_kokkos.cpp | 10 +- src/KOKKOS/bond_quartic_kokkos.cpp | 2 +- src/KOKKOS/comm_kokkos.cpp | 6 +- src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp | 42 +- .../compute_composition_atom_kokkos.cpp | 7 +- src/KOKKOS/compute_coord_atom_kokkos.cpp | 8 +- src/KOKKOS/compute_erotate_asphere_kokkos.cpp | 6 +- .../compute_gaussian_grid_local_kokkos.cpp | 14 +- .../compute_orientorder_atom_kokkos.cpp | 65 +- src/KOKKOS/compute_temp_com_kokkos.cpp | 44 +- src/KOKKOS/compute_temp_deform_kokkos.cpp | 12 +- src/KOKKOS/compute_temp_kokkos.cpp | 18 +- src/KOKKOS/compute_temp_sphere_kokkos.cpp | 34 +- src/KOKKOS/dihedral_charmm_kokkos.cpp | 6 +- src/KOKKOS/dihedral_charmmfsw_kokkos.cpp | 348 ++++---- src/KOKKOS/dihedral_class2_kokkos.cpp | 400 ++++----- src/KOKKOS/dihedral_class2xe_kokkos.cpp | 438 +++++----- .../dihedral_cosine_shift_exp_kokkos.cpp | 212 ++--- ...edral_cosine_squared_restricted_kokkos.cpp | 232 +++--- src/KOKKOS/dihedral_fourier_kokkos.cpp | 200 ++--- src/KOKKOS/dihedral_harmonic_kokkos.cpp | 200 ++--- src/KOKKOS/dihedral_helix_kokkos.cpp | 250 +++--- src/KOKKOS/dihedral_multi_harmonic_kokkos.cpp | 234 +++--- src/KOKKOS/dihedral_nharmonic_kokkos.cpp | 216 ++--- src/KOKKOS/dihedral_opls_kokkos.cpp | 248 +++--- src/KOKKOS/dihedral_quadratic_kokkos.cpp | 244 +++--- src/KOKKOS/dihedral_spherical_kokkos.cpp | 294 +++---- src/KOKKOS/domain_kokkos.cpp | 114 +-- src/KOKKOS/fix_addforce_kokkos.cpp | 68 +- src/KOKKOS/fix_aveforce_kokkos.cpp | 12 +- src/KOKKOS/fix_cmap_kokkos.cpp | 120 +-- src/KOKKOS/fix_dpd_energy_kokkos.cpp | 6 +- src/KOKKOS/fix_drag_kokkos.cpp | 14 +- src/KOKKOS/fix_dt_reset_kokkos.cpp | 56 +- src/KOKKOS/fix_efield_kokkos.cpp | 108 +-- src/KOKKOS/fix_electron_stopping_kokkos.cpp | 10 +- src/KOKKOS/fix_eos_table_rx_kokkos.cpp | 37 +- src/KOKKOS/fix_external_kokkos.cpp | 6 +- src/KOKKOS/fix_langevin_kokkos.cpp | 114 +-- src/KOKKOS/fix_langevin_kokkos.h | 2 +- src/KOKKOS/fix_lineforce_kokkos.cpp | 11 +- src/KOKKOS/fix_minimize_kokkos.cpp | 12 +- src/KOKKOS/fix_momentum_kokkos.cpp | 33 +- src/KOKKOS/fix_neigh_history_kokkos.cpp | 4 +- src/KOKKOS/fix_nh_kokkos.cpp | 45 +- src/KOKKOS/fix_nh_sphere_kokkos.cpp | 26 +- src/KOKKOS/fix_nve_asphere_kokkos.cpp | 95 ++- src/KOKKOS/fix_nve_kokkos.cpp | 82 +- src/KOKKOS/fix_nve_limit_kokkos.cpp | 58 +- src/KOKKOS/fix_nve_noforce_kokkos.cpp | 7 +- src/KOKKOS/fix_nve_sphere_kokkos.cpp | 88 +- src/KOKKOS/fix_nvt_sllod_kokkos.cpp | 76 +- src/KOKKOS/fix_oneway_kokkos.cpp | 4 +- src/KOKKOS/fix_planeforce_kokkos.cpp | 11 +- src/KOKKOS/fix_recenter_kokkos.cpp | 6 +- src/KOKKOS/fix_rx_kokkos.cpp | 148 ++-- src/KOKKOS/fix_setforce_kokkos.cpp | 36 +- src/KOKKOS/fix_shake_kokkos.cpp | 54 +- src/KOKKOS/fix_shardlow_kokkos.cpp | 56 +- src/KOKKOS/fix_spring_kokkos.cpp | 62 +- src/KOKKOS/fix_spring_self_kokkos.cpp | 24 +- src/KOKKOS/fix_temp_berendsen_kokkos.cpp | 7 +- src/KOKKOS/fix_temp_rescale_kokkos.cpp | 7 +- src/KOKKOS/fix_viscous_kokkos.cpp | 8 +- src/KOKKOS/fix_viscous_sphere_kokkos.cpp | 6 +- src/KOKKOS/fix_wall_flow_kokkos.cpp | 28 +- src/KOKKOS/fix_wall_gran_kokkos.cpp | 91 ++- src/KOKKOS/fix_wall_harmonic_kokkos.cpp | 16 +- src/KOKKOS/fix_wall_lj1043_kokkos.cpp | 18 +- src/KOKKOS/fix_wall_lj126_kokkos.cpp | 16 +- src/KOKKOS/fix_wall_lj93_kokkos.cpp | 16 +- src/KOKKOS/fix_wall_morse_kokkos.cpp | 14 +- src/KOKKOS/fix_wall_reflect_kokkos.cpp | 16 +- src/KOKKOS/fix_wall_region_kokkos.cpp | 142 ++-- src/KOKKOS/group_kokkos.h | 80 +- src/KOKKOS/improper_class2_kokkos.cpp | 320 ++++---- src/KOKKOS/improper_cossq_kokkos.cpp | 10 +- src/KOKKOS/improper_cvff_kokkos.cpp | 14 +- src/KOKKOS/improper_distance_kokkos.cpp | 2 +- src/KOKKOS/improper_distharm_kokkos.cpp | 2 +- src/KOKKOS/improper_fourier_kokkos.cpp | 10 +- src/KOKKOS/improper_harmonic_kokkos.cpp | 12 +- .../improper_inversion_harmonic_kokkos.cpp | 16 +- src/KOKKOS/improper_ring_kokkos.cpp | 6 +- src/KOKKOS/improper_sqdistharm_kokkos.cpp | 2 +- src/KOKKOS/improper_umbrella_kokkos.cpp | 12 +- src/KOKKOS/kokkos_type.h | 6 +- src/KOKKOS/math_extra_kokkos.h | 78 +- src/KOKKOS/math_special_kokkos.h | 2 +- src/KOKKOS/meam_dens_final_kokkos.h | 36 +- src/KOKKOS/meam_dens_init_kokkos.h | 118 +-- src/KOKKOS/meam_force_kokkos.h | 200 ++--- src/KOKKOS/meam_funcs_kokkos.h | 98 +-- src/KOKKOS/meam_kokkos.h | 4 +- src/KOKKOS/meam_setup_done_kokkos.h | 16 +- src/KOKKOS/min_cg_kokkos.cpp | 50 +- src/KOKKOS/min_fire_kokkos.cpp | 119 +-- src/KOKKOS/min_kokkos.cpp | 20 +- src/KOKKOS/min_linesearch_kokkos.cpp | 50 +- src/KOKKOS/nbin_kokkos.cpp | 2 +- src/KOKKOS/nbin_ssa_kokkos.cpp | 4 +- src/KOKKOS/neigh_bond_kokkos.cpp | 78 +- src/KOKKOS/neighbor_kokkos.cpp | 6 +- src/KOKKOS/npair_halffull_kokkos.cpp | 36 +- src/KOKKOS/npair_kokkos.cpp | 146 ++-- src/KOKKOS/npair_skip_kokkos.cpp | 12 +- src/KOKKOS/npair_ssa_kokkos.cpp | 30 +- src/KOKKOS/npair_trim_kokkos.cpp | 12 +- src/KOKKOS/pair_adp_kokkos.cpp | 386 ++++----- src/KOKKOS/pair_beck_kokkos.cpp | 30 +- src/KOKKOS/pair_bondval_kokkos.cpp | 178 ++-- src/KOKKOS/pair_bondval_vec_kokkos.cpp | 226 +++--- src/KOKKOS/pair_born_coul_long_kokkos.cpp | 16 +- src/KOKKOS/pair_born_coul_wolf_kokkos.cpp | 82 +- src/KOKKOS/pair_born_kokkos.cpp | 30 +- src/KOKKOS/pair_brownian_kokkos.cpp | 171 ++-- src/KOKKOS/pair_brownian_kokkos.h | 8 +- .../pair_buck6d_coul_gauss_dsf_kokkos.cpp | 64 +- .../pair_buck6d_coul_gauss_long_kokkos.cpp | 22 +- src/KOKKOS/pair_buck_coul_cut_kokkos.cpp | 76 +- src/KOKKOS/pair_buck_coul_long_kokkos.cpp | 130 +-- src/KOKKOS/pair_buck_kokkos.cpp | 50 +- src/KOKKOS/pair_colloid_kokkos.cpp | 28 +- src/KOKKOS/pair_coul_cut_kokkos.cpp | 54 +- src/KOKKOS/pair_coul_debye_kokkos.cpp | 66 +- src/KOKKOS/pair_coul_diel_kokkos.cpp | 42 +- src/KOKKOS/pair_coul_dsf_kokkos.cpp | 147 ++-- src/KOKKOS/pair_coul_long_kokkos.cpp | 106 +-- src/KOKKOS/pair_coul_shield_kokkos.cpp | 42 +- src/KOKKOS/pair_coul_slater_long_kokkos.cpp | 14 +- src/KOKKOS/pair_coul_wolf_kokkos.cpp | 147 ++-- src/KOKKOS/pair_dpd_ext_kokkos.cpp | 132 +-- src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp | 120 +-- src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp | 206 ++--- src/KOKKOS/pair_dpd_kokkos.cpp | 134 +-- src/KOKKOS/pair_dpd_tstat_kokkos.cpp | 96 +-- src/KOKKOS/pair_eam_kokkos.cpp | 8 +- src/KOKKOS/pair_exp6_rx_kokkos.cpp | 768 +++++++++--------- src/KOKKOS/pair_gauss_kokkos.cpp | 26 +- src/KOKKOS/pair_gran_hooke_history_kokkos.cpp | 8 +- src/KOKKOS/pair_kokkos.h | 12 +- src/KOKKOS/pair_lj96_cut_kokkos.cpp | 4 +- ..._lj_charmm_coul_charmm_implicit_kokkos.cpp | 126 +-- .../pair_lj_charmm_coul_charmm_kokkos.cpp | 124 +-- .../pair_lj_charmm_coul_long_kokkos.cpp | 8 +- .../pair_lj_charmmfsw_coul_long_kokkos.cpp | 154 ++-- src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp | 70 +- .../pair_lj_class2_coul_long_kokkos.cpp | 124 +-- src/KOKKOS/pair_lj_class2_kokkos.cpp | 44 +- src/KOKKOS/pair_lj_cubic_kokkos.cpp | 6 +- src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp | 66 +- src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp | 78 +- src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp | 89 +- src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp | 8 +- src/KOKKOS/pair_lj_cut_coul_wolf_kokkos.cpp | 74 +- src/KOKKOS/pair_lj_cut_dipole_cut_kokkos.cpp | 244 +++--- src/KOKKOS/pair_lj_cut_sphere_kokkos.cpp | 28 +- src/KOKKOS/pair_lj_cut_tip4p_cut_kokkos.cpp | 11 +- src/KOKKOS/pair_lj_cut_tip4p_long_kokkos.cpp | 11 +- .../pair_lj_expand_coul_long_kokkos.cpp | 126 +-- src/KOKKOS/pair_lj_expand_kokkos.cpp | 46 +- .../pair_lj_gromacs_coul_gromacs_kokkos.cpp | 139 ++-- src/KOKKOS/pair_lj_gromacs_kokkos.cpp | 54 +- src/KOKKOS/pair_lj_smooth_kokkos.cpp | 26 +- src/KOKKOS/pair_lj_spica_coul_long_kokkos.cpp | 128 +-- src/KOKKOS/pair_lj_spica_kokkos.cpp | 48 +- .../pair_lj_switch3_coulgauss_long_kokkos.cpp | 22 +- src/KOKKOS/pair_meam_kokkos.cpp | 638 +++++++-------- ...pair_mm3_switch3_coulgauss_long_kokkos.cpp | 22 +- src/KOKKOS/pair_morse_kokkos.cpp | 46 +- src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp | 189 ++--- src/KOKKOS/pair_nm_cut_coul_cut_kokkos.cpp | 42 +- src/KOKKOS/pair_nm_cut_coul_long_kokkos.cpp | 22 +- src/KOKKOS/pair_pod_kokkos.cpp | 458 +++++------ src/KOKKOS/pair_soft_kokkos.cpp | 42 +- src/KOKKOS/pair_sw_kokkos.cpp | 206 ++--- src/KOKKOS/pair_table_kokkos.cpp | 56 +- src/KOKKOS/pair_table_kokkos.h | 6 +- src/KOKKOS/pair_table_rx_kokkos.cpp | 248 +++--- src/KOKKOS/pair_tersoff_kokkos.cpp | 64 +- src/KOKKOS/pair_tersoff_mod_kokkos.cpp | 341 ++++---- src/KOKKOS/pair_tersoff_zbl_kokkos.cpp | 387 ++++----- src/KOKKOS/pair_tip4p_kokkos.h | 67 +- src/KOKKOS/pair_uf3_kokkos.cpp | 388 ++++----- src/KOKKOS/pair_ufm_kokkos.cpp | 28 +- src/KOKKOS/pair_vashishta_kokkos.cpp | 299 ++++--- src/KOKKOS/pair_ylz_kokkos.cpp | 68 +- src/KOKKOS/pair_yukawa_colloid_kokkos.cpp | 44 +- src/KOKKOS/pair_yukawa_kokkos.cpp | 46 +- src/KOKKOS/pair_zbl_kokkos.cpp | 28 +- src/KOKKOS/region_block_kokkos.cpp | 6 +- src/KOKKOS/region_sphere_kokkos.cpp | 2 +- src/KOKKOS/sna_kokkos_impl.h | 34 +- 227 files changed, 9734 insertions(+), 9399 deletions(-) diff --git a/src/KOKKOS/angle_charmm_kokkos.cpp b/src/KOKKOS/angle_charmm_kokkos.cpp index 43a360a5078..b02dd97ebdd 100644 --- a/src/KOKKOS/angle_charmm_kokkos.cpp +++ b/src/KOKKOS/angle_charmm_kokkos.cpp @@ -155,7 +155,7 @@ void AngleCharmmKokkos::operator()(TagAngleCharmmCompute::operator()(TagAngleCharmmCompute::operator()(TagAngleCharmmCompute::operator()(TagAngleCharmmCompute static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); s = static_cast(1.0) / s; // harmonic force & energy - const KK_FLOAT dtheta = acos(c) - d_theta0[type]; + const KK_FLOAT dtheta = Kokkos::acos(c) - d_theta0[type]; const KK_FLOAT tk = d_k[type] * dtheta; if (eflag) eangle += tk*dtheta; diff --git a/src/KOKKOS/angle_class2_kokkos.cpp b/src/KOKKOS/angle_class2_kokkos.cpp index 14cd8dcff35..4442ffdfa8d 100644 --- a/src/KOKKOS/angle_class2_kokkos.cpp +++ b/src/KOKKOS/angle_class2_kokkos.cpp @@ -130,14 +130,14 @@ void AngleClass2Kokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -176,7 +176,7 @@ void AngleClass2Kokkos::operator()(TagAngleClass2Compute::operator()(TagAngleClass2Compute 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = static_cast(1.0); + if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(1.0 - c*c); - if (s < SMALL) s = SMALL; - s = 1.0/s; + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); + if (s < static_cast(SMALL)) s = static_cast(SMALL); + s = static_cast(1.0)/s; // force & energy for angle term - const KK_FLOAT dtheta = acos(c) - d_theta0[type]; + const KK_FLOAT dtheta = Kokkos::acos(c) - d_theta0[type]; const KK_FLOAT dtheta2 = dtheta*dtheta; const KK_FLOAT dtheta3 = dtheta2*dtheta; const KK_FLOAT dtheta4 = dtheta3*dtheta; - const KK_FLOAT de_angle = 2.0*d_k2[type]*dtheta + 3.0*d_k3[type]*dtheta2 + 4.0*d_k4[type]*dtheta3; + const KK_FLOAT de_angle = static_cast(2.0)*d_k2[type]*dtheta + static_cast(3.0)*d_k3[type]*dtheta2 + static_cast(4.0)*d_k4[type]*dtheta3; const KK_FLOAT a = -de_angle*s; const KK_FLOAT a11 = a*c / rsq1; @@ -286,21 +286,21 @@ void AngleClass2Kokkos::operator()(TagAngleClass2Compute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) -= f1[0] + f3[0]; - a_f(i2,1) -= f1[1] + f3[1]; - a_f(i2,2) -= f1[2] + f3[2]; + a_f(i2,0) -= static_cast(f1[0] + f3[0]); + a_f(i2,1) -= static_cast(f1[1] + f3[1]); + a_f(i2,2) -= static_cast(f1[2] + f3[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (EVFLAG) ev_tally(ev,i1,i2,i3,eangle,f1,f3, @@ -373,21 +373,21 @@ void AngleClass2Kokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->nangletypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k2.view_host()[i] = k2[i]; - k_k3.view_host()[i] = k3[i]; - k_k4.view_host()[i] = k4[i]; - k_bb_k.view_host()[i] = bb_k[i]; - k_bb_r1.view_host()[i] = bb_r1[i]; - k_bb_r2.view_host()[i] = bb_r2[i]; - k_ba_k1.view_host()[i] = ba_k1[i]; - k_ba_k2.view_host()[i] = ba_k2[i]; - k_ba_r1.view_host()[i] = ba_r1[i]; - k_ba_r2.view_host()[i] = ba_r2[i]; + k_k2.view_host()[i] = static_cast(k2[i]); + k_k3.view_host()[i] = static_cast(k3[i]); + k_k4.view_host()[i] = static_cast(k4[i]); + k_bb_k.view_host()[i] = static_cast(bb_k[i]); + k_bb_r1.view_host()[i] = static_cast(bb_r1[i]); + k_bb_r2.view_host()[i] = static_cast(bb_r2[i]); + k_ba_k1.view_host()[i] = static_cast(ba_k1[i]); + k_ba_k2.view_host()[i] = static_cast(ba_k2[i]); + k_ba_r1.view_host()[i] = static_cast(ba_r1[i]); + k_ba_r2.view_host()[i] = static_cast(ba_r2[i]); k_setflag.view_host()[i] = setflag[i]; k_setflag_a.view_host()[i] = setflag_a[i]; k_setflag_bb.view_host()[i] = setflag_bb[i]; k_setflag_ba.view_host()[i] = setflag_ba[i]; - k_theta0.view_host()[i] = theta0[i]; + k_theta0.view_host()[i] = static_cast(theta0[i]); } k_k2.modify_host(); @@ -452,21 +452,21 @@ void AngleClass2Kokkos::read_restart(FILE *fp) //int n = atom->nangletypes; for (int i = 1; i <= n; i++) { - k_k2.view_host()[i] = k2[i]; - k_k3.view_host()[i] = k3[i]; - k_k4.view_host()[i] = k4[i]; - k_bb_k.view_host()[i] = bb_k[i]; - k_bb_r1.view_host()[i] = bb_r1[i]; - k_bb_r2.view_host()[i] = bb_r2[i]; - k_ba_k1.view_host()[i] = ba_k1[i]; - k_ba_k2.view_host()[i] = ba_k2[i]; - k_ba_r1.view_host()[i] = ba_r1[i]; - k_ba_r2.view_host()[i] = ba_r2[i]; + k_k2.view_host()[i] = static_cast(k2[i]); + k_k3.view_host()[i] = static_cast(k3[i]); + k_k4.view_host()[i] = static_cast(k4[i]); + k_bb_k.view_host()[i] = static_cast(bb_k[i]); + k_bb_r1.view_host()[i] = static_cast(bb_r1[i]); + k_bb_r2.view_host()[i] = static_cast(bb_r2[i]); + k_ba_k1.view_host()[i] = static_cast(ba_k1[i]); + k_ba_k2.view_host()[i] = static_cast(ba_k2[i]); + k_ba_r1.view_host()[i] = static_cast(ba_r1[i]); + k_ba_r2.view_host()[i] = static_cast(ba_r2[i]); k_setflag.view_host()[i] = setflag[i]; k_setflag_a.view_host()[i] = setflag_a[i]; k_setflag_bb.view_host()[i] = setflag_bb[i]; k_setflag_ba.view_host()[i] = setflag_ba[i]; - k_theta0.view_host()[i] = theta0[i]; + k_theta0.view_host()[i] = static_cast(theta0[i]); } k_k2.modify_host(); @@ -509,21 +509,21 @@ void AngleClass2Kokkos::ev_tally(EV_FLOAT &ev, const int i, const in if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eangle; + if (newton_bond) ev.evdwl += static_cast(eangle); else { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (i < nlocal) ev.evdwl += eanglethird; - if (j < nlocal) ev.evdwl += eanglethird; - if (k < nlocal) ev.evdwl += eanglethird; + if (i < nlocal) ev.evdwl += static_cast(eanglethird); + if (j < nlocal) ev.evdwl += static_cast(eanglethird); + if (k < nlocal) ev.evdwl += static_cast(eanglethird); } } if (eflag_atom) { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (newton_bond || i < nlocal) v_eatom[i] += eanglethird; - if (newton_bond || j < nlocal) v_eatom[j] += eanglethird; - if (newton_bond || k < nlocal) v_eatom[k] += eanglethird; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(eanglethird); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(eanglethird); + if (newton_bond || k < nlocal) v_eatom[k] += static_cast(eanglethird); } } @@ -537,65 +537,65 @@ void AngleClass2Kokkos::ev_tally(EV_FLOAT &ev, const int i, const in if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(THIRD)*static_cast(v[0]); + ev.v[1] += static_cast(THIRD)*static_cast(v[1]); + ev.v[2] += static_cast(THIRD)*static_cast(v[2]); + ev.v[3] += static_cast(THIRD)*static_cast(v[3]); + ev.v[4] += static_cast(THIRD)*static_cast(v[4]); + ev.v[5] += static_cast(THIRD)*static_cast(v[5]); } if (j < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(THIRD)*static_cast(v[0]); + ev.v[1] += static_cast(THIRD)*static_cast(v[1]); + ev.v[2] += static_cast(THIRD)*static_cast(v[2]); + ev.v[3] += static_cast(THIRD)*static_cast(v[3]); + ev.v[4] += static_cast(THIRD)*static_cast(v[4]); + ev.v[5] += static_cast(THIRD)*static_cast(v[5]); } if (k < nlocal) { - ev.v[0] += THIRD*v[0]; + ev.v[0] += static_cast(THIRD)*static_cast(v[0]); - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[1] += static_cast(THIRD)*static_cast(v[1]); + ev.v[2] += static_cast(THIRD)*static_cast(v[2]); + ev.v[3] += static_cast(THIRD)*static_cast(v[3]); + ev.v[4] += static_cast(THIRD)*static_cast(v[4]); + ev.v[5] += static_cast(THIRD)*static_cast(v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += THIRD*v[0]; - v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; - v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; - v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(THIRD)*static_cast(v[0]); + v_vatom(i,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(i,2) += static_cast(THIRD)*static_cast(v[2]); + v_vatom(i,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(i,4) += static_cast(THIRD)*static_cast(v[4]); + v_vatom(i,5) += static_cast(THIRD)*static_cast(v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += THIRD*v[0]; - v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; - v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; - v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(THIRD)*static_cast(v[0]); + v_vatom(j,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(j,2) += static_cast(THIRD)*static_cast(v[2]); + v_vatom(j,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(j,4) += static_cast(THIRD)*static_cast(v[4]); + v_vatom(j,5) += static_cast(THIRD)*static_cast(v[5]); } if (newton_bond || k < nlocal) { - v_vatom(k,0) += THIRD*v[0]; - v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; - v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; - v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(THIRD)*static_cast(v[0]); + v_vatom(k,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(k,2) += static_cast(THIRD)*static_cast(v[2]); + v_vatom(k,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(k,4) += static_cast(THIRD)*static_cast(v[4]); + v_vatom(k,5) += static_cast(THIRD)*static_cast(v[5]); } } diff --git a/src/KOKKOS/angle_class2_p6_kokkos.cpp b/src/KOKKOS/angle_class2_p6_kokkos.cpp index b49e4bf8424..52fa473ef5d 100644 --- a/src/KOKKOS/angle_class2_p6_kokkos.cpp +++ b/src/KOKKOS/angle_class2_p6_kokkos.cpp @@ -169,7 +169,7 @@ void AngleClass2P6Kokkos::operator()(TagAngleClass2P6Compute::operator()(TagAngleClass2P6Compute::operator()(TagAngleClass2P6Compute static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); s = static_cast(1.0)/s; // angle term - const KK_FLOAT dtheta = acos(c) - d_theta0[type]; + const KK_FLOAT dtheta = Kokkos::acos(c) - d_theta0[type]; const KK_FLOAT dtheta2 = dtheta*dtheta; const KK_FLOAT dtheta3 = dtheta2*dtheta; const KK_FLOAT dtheta4 = dtheta3*dtheta; @@ -434,14 +434,14 @@ void AngleClass2P6Kokkos::ev_tally(EV_FLOAT &ev, if (eflag_global) { if (newton_bond) ev.evdwl += static_cast(eangle); else { - const KK_ACC_FLOAT et = static_cast(THIRD*eangle); + const KK_ACC_FLOAT et = static_cast(static_cast(THIRD)*eangle); if (i < nlocal) ev.evdwl += et; if (j < nlocal) ev.evdwl += et; if (k < nlocal) ev.evdwl += et; } } if (eflag_atom) { - const KK_ACC_FLOAT et = static_cast(THIRD*eangle); + const KK_ACC_FLOAT et = static_cast(static_cast(THIRD)*eangle); if (newton_bond || i < nlocal) v_eatom[i] += et; if (newton_bond || j < nlocal) v_eatom[j] += et; if (newton_bond || k < nlocal) v_eatom[k] += et; @@ -461,14 +461,14 @@ void AngleClass2P6Kokkos::ev_tally(EV_FLOAT &ev, if (newton_bond) { for (int m = 0; m < 6; m++) ev.v[m] += static_cast(v[m]); } else { - const KK_FLOAT vt = THIRD; + const KK_FLOAT vt = static_cast(THIRD); if (i < nlocal) for (int m = 0; m < 6; m++) ev.v[m] += static_cast(vt*v[m]); if (j < nlocal) for (int m = 0; m < 6; m++) ev.v[m] += static_cast(vt*v[m]); if (k < nlocal) for (int m = 0; m < 6; m++) ev.v[m] += static_cast(vt*v[m]); } } if (vflag_atom) { - const KK_FLOAT vt = THIRD; + const KK_FLOAT vt = static_cast(THIRD); if (newton_bond || i < nlocal) for (int m = 0; m < 6; m++) v_vatom(i,m) += static_cast(vt*v[m]); if (newton_bond || j < nlocal) diff --git a/src/KOKKOS/angle_class2xe_kokkos.cpp b/src/KOKKOS/angle_class2xe_kokkos.cpp index 81dcc99e9d6..5a4ba4799b9 100644 --- a/src/KOKKOS/angle_class2xe_kokkos.cpp +++ b/src/KOKKOS/angle_class2xe_kokkos.cpp @@ -129,14 +129,14 @@ void AngleClass2xeKokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -177,7 +177,7 @@ void AngleClass2xeKokkos::operator()(TagAngleClass2xeCompute::operator()(TagAngleClass2xeCompute::operator()(TagAngleClass2xeCompute static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); s = static_cast(1.0)/s; // force & energy for angle term - const KK_FLOAT dtheta = acos(c) - d_theta0[type]; + const KK_FLOAT dtheta = Kokkos::acos(c) - d_theta0[type]; const KK_FLOAT dtheta2 = dtheta*dtheta; const KK_FLOAT dtheta3 = dtheta2*dtheta; const KK_FLOAT dtheta4 = dtheta3*dtheta; @@ -231,8 +231,8 @@ void AngleClass2xeKokkos::operator()(TagAngleClass2xeCompute(1.0) - bb_ralpha1); const KK_FLOAT tk2 = d_bb_d0[type]*d_bb_alpha[type]*bb_ralpha1*(static_cast(1.0) - bb_ralpha2); @@ -250,8 +250,8 @@ void AngleClass2xeKokkos::operator()(TagAngleClass2xeCompute(1.0) - ba_ralpha1)*s; const KK_FLOAT aa2 = d_ba_d2[type]*(static_cast(1.0) - ba_ralpha2)*s; @@ -294,21 +294,21 @@ void AngleClass2xeKokkos::operator()(TagAngleClass2xeCompute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) -= f1[0] + f3[0]; - a_f(i2,1) -= f1[1] + f3[1]; - a_f(i2,2) -= f1[2] + f3[2]; + a_f(i2,0) -= static_cast(f1[0] + f3[0]); + a_f(i2,1) -= static_cast(f1[1] + f3[1]); + a_f(i2,2) -= static_cast(f1[2] + f3[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (EVFLAG) ev_tally(ev,i1,i2,i3,eangle,f1,f3, @@ -474,21 +474,21 @@ void AngleClass2xeKokkos::ev_tally(EV_FLOAT &ev, const int i, const if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eangle; + if (newton_bond) ev.evdwl += static_cast(eangle); else { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (i < nlocal) ev.evdwl += eanglethird; - if (j < nlocal) ev.evdwl += eanglethird; - if (k < nlocal) ev.evdwl += eanglethird; + if (i < nlocal) ev.evdwl += static_cast(eanglethird); + if (j < nlocal) ev.evdwl += static_cast(eanglethird); + if (k < nlocal) ev.evdwl += static_cast(eanglethird); } } if (eflag_atom) { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (newton_bond || i < nlocal) v_eatom[i] += eanglethird; - if (newton_bond || j < nlocal) v_eatom[j] += eanglethird; - if (newton_bond || k < nlocal) v_eatom[k] += eanglethird; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(eanglethird); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(eanglethird); + if (newton_bond || k < nlocal) v_eatom[k] += static_cast(eanglethird); } } @@ -502,64 +502,64 @@ void AngleClass2xeKokkos::ev_tally(EV_FLOAT &ev, const int i, const if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(THIRD)*static_cast(v[0]); + ev.v[1] += static_cast(THIRD)*static_cast(v[1]); + ev.v[2] += static_cast(THIRD)*static_cast(v[2]); + ev.v[3] += static_cast(THIRD)*static_cast(v[3]); + ev.v[4] += static_cast(THIRD)*static_cast(v[4]); + ev.v[5] += static_cast(THIRD)*static_cast(v[5]); } if (j < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(THIRD)*static_cast(v[0]); + ev.v[1] += static_cast(THIRD)*static_cast(v[1]); + ev.v[2] += static_cast(THIRD)*static_cast(v[2]); + ev.v[3] += static_cast(THIRD)*static_cast(v[3]); + ev.v[4] += static_cast(THIRD)*static_cast(v[4]); + ev.v[5] += static_cast(THIRD)*static_cast(v[5]); } if (k < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(THIRD)*static_cast(v[0]); + ev.v[1] += static_cast(THIRD)*static_cast(v[1]); + ev.v[2] += static_cast(THIRD)*static_cast(v[2]); + ev.v[3] += static_cast(THIRD)*static_cast(v[3]); + ev.v[4] += static_cast(THIRD)*static_cast(v[4]); + ev.v[5] += static_cast(THIRD)*static_cast(v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += THIRD*v[0]; - v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; - v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; - v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(THIRD)*static_cast(v[0]); + v_vatom(i,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(i,2) += static_cast(THIRD)*static_cast(v[2]); + v_vatom(i,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(i,4) += static_cast(THIRD)*static_cast(v[4]); + v_vatom(i,5) += static_cast(THIRD)*static_cast(v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += THIRD*v[0]; - v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; - v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; - v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(THIRD)*static_cast(v[0]); + v_vatom(j,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(j,2) += static_cast(THIRD)*static_cast(v[2]); + v_vatom(j,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(j,4) += static_cast(THIRD)*static_cast(v[4]); + v_vatom(j,5) += static_cast(THIRD)*static_cast(v[5]); } if (newton_bond || k < nlocal) { - v_vatom(k,0) += THIRD*v[0]; - v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; - v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; - v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(THIRD)*static_cast(v[0]); + v_vatom(k,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(k,2) += static_cast(THIRD)*static_cast(v[2]); + v_vatom(k,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(k,4) += static_cast(THIRD)*static_cast(v[4]); + v_vatom(k,5) += static_cast(THIRD)*static_cast(v[5]); } } } diff --git a/src/KOKKOS/angle_cosine_delta_kokkos.cpp b/src/KOKKOS/angle_cosine_delta_kokkos.cpp index fd970d4be32..87f2079da95 100644 --- a/src/KOKKOS/angle_cosine_delta_kokkos.cpp +++ b/src/KOKKOS/angle_cosine_delta_kokkos.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -static constexpr KK_FLOAT SMALL = 0.001; +static constexpr KK_FLOAT SMALL = static_cast(0.001); /* ---------------------------------------------------------------------- */ @@ -118,14 +118,14 @@ void AngleCosineDeltaKokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -166,7 +166,7 @@ void AngleCosineDeltaKokkos::operator()(TagAngleCosineDeltaCompute::operator()(TagAngleCosineDeltaCompute::operator()(TagAngleCosineDeltaCompute(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < SMALL) s = SMALL; const KK_FLOAT cot = c/s; @@ -221,21 +221,21 @@ void AngleCosineDeltaKokkos::operator()(TagAngleCosineDeltaCompute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) -= f1[0] + f3[0]; - a_f(i2,1) -= f1[1] + f3[1]; - a_f(i2,2) -= f1[2] + f3[2]; + a_f(i2,0) -= static_cast(f1[0] + f3[0]); + a_f(i2,1) -= static_cast(f1[1] + f3[1]); + a_f(i2,2) -= static_cast(f1[2] + f3[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (EVFLAG) ev_tally(ev,i1,i2,i3,eangle,f1,f3, @@ -334,21 +334,21 @@ void AngleCosineDeltaKokkos::ev_tally(EV_FLOAT &ev, const int i, con if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eangle; + if (newton_bond) ev.evdwl += static_cast(eangle); else { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (i < nlocal) ev.evdwl += eanglethird; - if (j < nlocal) ev.evdwl += eanglethird; - if (k < nlocal) ev.evdwl += eanglethird; + if (i < nlocal) ev.evdwl += static_cast(eanglethird); + if (j < nlocal) ev.evdwl += static_cast(eanglethird); + if (k < nlocal) ev.evdwl += static_cast(eanglethird); } } if (eflag_atom) { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (newton_bond || i < nlocal) v_eatom[i] += eanglethird; - if (newton_bond || j < nlocal) v_eatom[j] += eanglethird; - if (newton_bond || k < nlocal) v_eatom[k] += eanglethird; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(eanglethird); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(eanglethird); + if (newton_bond || k < nlocal) v_eatom[k] += static_cast(eanglethird); } } @@ -362,64 +362,64 @@ void AngleCosineDeltaKokkos::ev_tally(EV_FLOAT &ev, const int i, con if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (j < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (k < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += THIRD*v[0]; - v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; - v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; - v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(i,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(i,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(i,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(i,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(i,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += THIRD*v[0]; - v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; - v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; - v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(j,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(j,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(j,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(j,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(j,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || k < nlocal) { - v_vatom(k,0) += THIRD*v[0]; - v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; - v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; - v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(k,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(k,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(k,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(k,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(k,5) += static_cast(static_cast(THIRD)*v[5]); } } } diff --git a/src/KOKKOS/angle_cosine_kokkos.cpp b/src/KOKKOS/angle_cosine_kokkos.cpp index fdd71d088d1..438dc5271b1 100644 --- a/src/KOKKOS/angle_cosine_kokkos.cpp +++ b/src/KOKKOS/angle_cosine_kokkos.cpp @@ -113,14 +113,14 @@ void AngleCosineKokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -163,7 +163,7 @@ void AngleCosineKokkos::operator()(TagAngleCosineCompute::operator()(TagAngleCosineCompute 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = static_cast(1.0); + if (c < static_cast(-1.0)) c = static_cast(-1.0); // force & energy KK_FLOAT eangle = 0.0; - if (eflag) eangle = k*(1.0+c); + if (eflag) eangle = k*(static_cast(1.0)+c); const KK_FLOAT a = k; const KK_FLOAT a11 = a*c / rsq1; @@ -202,21 +202,21 @@ void AngleCosineKokkos::operator()(TagAngleCosineCompute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) -= f1[0] + f3[0]; - a_f(i2,1) -= f1[1] + f3[1]; - a_f(i2,2) -= f1[2] + f3[2]; + a_f(i2,0) -= static_cast(f1[0] + f3[0]); + a_f(i2,1) -= static_cast(f1[1] + f3[1]); + a_f(i2,2) -= static_cast(f1[2] + f3[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (EVFLAG) ev_tally(ev,i1,i2,i3,eangle,f1,f3, @@ -257,7 +257,7 @@ void AngleCosineKokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->nangletypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) - k_k.view_host()[i] = k[i]; + k_k.view_host()[i] = static_cast(k[i]); k_k.modify_host(); } @@ -273,7 +273,7 @@ void AngleCosineKokkos::read_restart(FILE *fp) int n = atom->nangletypes; for (int i = 1; i <= n; i++) - k_k.view_host()[i] = k[i]; + k_k.view_host()[i] = static_cast(k[i]); k_k.modify_host(); } @@ -301,21 +301,21 @@ void AngleCosineKokkos::ev_tally(EV_FLOAT &ev, const int i, const in if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eangle; + if (newton_bond) ev.evdwl += static_cast(eangle); else { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (i < nlocal) ev.evdwl += eanglethird; - if (j < nlocal) ev.evdwl += eanglethird; - if (k < nlocal) ev.evdwl += eanglethird; + if (i < nlocal) ev.evdwl += static_cast(eanglethird); + if (j < nlocal) ev.evdwl += static_cast(eanglethird); + if (k < nlocal) ev.evdwl += static_cast(eanglethird); } } if (eflag_atom) { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (newton_bond || i < nlocal) v_eatom[i] += eanglethird; - if (newton_bond || j < nlocal) v_eatom[j] += eanglethird; - if (newton_bond || k < nlocal) v_eatom[k] += eanglethird; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(eanglethird); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(eanglethird); + if (newton_bond || k < nlocal) v_eatom[k] += static_cast(eanglethird); } } @@ -329,65 +329,65 @@ void AngleCosineKokkos::ev_tally(EV_FLOAT &ev, const int i, const in if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(THIRD)*static_cast(v[0]); + ev.v[1] += static_cast(THIRD)*static_cast(v[1]); + ev.v[2] += static_cast(THIRD)*static_cast(v[2]); + ev.v[3] += static_cast(THIRD)*static_cast(v[3]); + ev.v[4] += static_cast(THIRD)*static_cast(v[4]); + ev.v[5] += static_cast(THIRD)*static_cast(v[5]); } if (j < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(THIRD)*static_cast(v[0]); + ev.v[1] += static_cast(THIRD)*static_cast(v[1]); + ev.v[2] += static_cast(THIRD)*static_cast(v[2]); + ev.v[3] += static_cast(THIRD)*static_cast(v[3]); + ev.v[4] += static_cast(THIRD)*static_cast(v[4]); + ev.v[5] += static_cast(THIRD)*static_cast(v[5]); } if (k < nlocal) { - ev.v[0] += THIRD*v[0]; + ev.v[0] += static_cast(THIRD)*static_cast(v[0]); - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[1] += static_cast(THIRD)*static_cast(v[1]); + ev.v[2] += static_cast(THIRD)*static_cast(v[2]); + ev.v[3] += static_cast(THIRD)*static_cast(v[3]); + ev.v[4] += static_cast(THIRD)*static_cast(v[4]); + ev.v[5] += static_cast(THIRD)*static_cast(v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += THIRD*v[0]; - v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; - v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; - v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(THIRD)*static_cast(v[0]); + v_vatom(i,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(i,2) += static_cast(THIRD)*static_cast(v[2]); + v_vatom(i,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(i,4) += static_cast(THIRD)*static_cast(v[4]); + v_vatom(i,5) += static_cast(THIRD)*static_cast(v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += THIRD*v[0]; - v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; - v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; - v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(THIRD)*static_cast(v[0]); + v_vatom(j,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(j,2) += static_cast(THIRD)*static_cast(v[2]); + v_vatom(j,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(j,4) += static_cast(THIRD)*static_cast(v[4]); + v_vatom(j,5) += static_cast(THIRD)*static_cast(v[5]); } if (newton_bond || k < nlocal) { - v_vatom(k,0) += THIRD*v[0]; - v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; - v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; - v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(THIRD)*static_cast(v[0]); + v_vatom(k,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(k,2) += static_cast(THIRD)*static_cast(v[2]); + v_vatom(k,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(k,4) += static_cast(THIRD)*static_cast(v[4]); + v_vatom(k,5) += static_cast(THIRD)*static_cast(v[5]); } } diff --git a/src/KOKKOS/angle_cosine_periodic_kokkos.cpp b/src/KOKKOS/angle_cosine_periodic_kokkos.cpp index 1739d96d5d6..5498411d42f 100644 --- a/src/KOKKOS/angle_cosine_periodic_kokkos.cpp +++ b/src/KOKKOS/angle_cosine_periodic_kokkos.cpp @@ -116,14 +116,14 @@ void AngleCosinePeriodicKokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -164,7 +164,7 @@ void AngleCosinePeriodicKokkos::operator()(TagAngleCosinePeriodicCom const KK_FLOAT delz1 = x(i1,2) - x22; const KK_FLOAT rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; - const KK_FLOAT r1 = sqrt(rsq1); + const KK_FLOAT r1 = Kokkos::sqrt(rsq1); // 2nd bond @@ -173,7 +173,7 @@ void AngleCosinePeriodicKokkos::operator()(TagAngleCosinePeriodicCom const KK_FLOAT delz2 = x(i3,2) - x22; const KK_FLOAT rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; - const KK_FLOAT r2 = sqrt(rsq2); + const KK_FLOAT r2 = Kokkos::sqrt(rsq2); // c = cosine of angle @@ -229,21 +229,21 @@ void AngleCosinePeriodicKokkos::operator()(TagAngleCosinePeriodicCom // apply force to each of 3 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) -= f1[0] + f3[0]; - a_f(i2,1) -= f1[1] + f3[1]; - a_f(i2,2) -= f1[2] + f3[2]; + a_f(i2,0) -= static_cast(f1[0] + f3[0]); + a_f(i2,1) -= static_cast(f1[1] + f3[1]); + a_f(i2,2) -= static_cast(f1[2] + f3[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (EVFLAG) ev_tally(ev,i1,i2,i3,eangle,f1,f3, @@ -342,21 +342,21 @@ void AngleCosinePeriodicKokkos::ev_tally(EV_FLOAT &ev, const int i, if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eangle; + if (newton_bond) ev.evdwl += static_cast(eangle); else { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (i < nlocal) ev.evdwl += eanglethird; - if (j < nlocal) ev.evdwl += eanglethird; - if (k < nlocal) ev.evdwl += eanglethird; + if (i < nlocal) ev.evdwl += static_cast(eanglethird); + if (j < nlocal) ev.evdwl += static_cast(eanglethird); + if (k < nlocal) ev.evdwl += static_cast(eanglethird); } } if (eflag_atom) { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (newton_bond || i < nlocal) v_eatom[i] += eanglethird; - if (newton_bond || j < nlocal) v_eatom[j] += eanglethird; - if (newton_bond || k < nlocal) v_eatom[k] += eanglethird; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(eanglethird); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(eanglethird); + if (newton_bond || k < nlocal) v_eatom[k] += static_cast(eanglethird); } } @@ -370,64 +370,64 @@ void AngleCosinePeriodicKokkos::ev_tally(EV_FLOAT &ev, const int i, if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (j < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (k < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += THIRD*v[0]; - v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; - v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; - v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(i,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(i,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(i,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(i,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(i,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += THIRD*v[0]; - v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; - v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; - v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(j,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(j,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(j,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(j,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(j,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || k < nlocal) { - v_vatom(k,0) += THIRD*v[0]; - v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; - v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; - v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(k,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(k,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(k,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(k,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(k,5) += static_cast(static_cast(THIRD)*v[5]); } } } diff --git a/src/KOKKOS/angle_cosine_shift_exp_kokkos.cpp b/src/KOKKOS/angle_cosine_shift_exp_kokkos.cpp index 72943490cff..4a5a6b5fae1 100644 --- a/src/KOKKOS/angle_cosine_shift_exp_kokkos.cpp +++ b/src/KOKKOS/angle_cosine_shift_exp_kokkos.cpp @@ -119,14 +119,14 @@ void AngleCosineShiftExpKokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -167,7 +167,7 @@ void AngleCosineShiftExpKokkos::operator()(TagAngleCosineShiftExpCom const KK_FLOAT delz1 = x(i1,2) - x22; const KK_FLOAT rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; - const KK_FLOAT r1 = sqrt(rsq1); + const KK_FLOAT r1 = Kokkos::sqrt(rsq1); // 2nd bond @@ -176,7 +176,7 @@ void AngleCosineShiftExpKokkos::operator()(TagAngleCosineShiftExpCom const KK_FLOAT delz2 = x(i3,2) - x22; const KK_FLOAT rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; - const KK_FLOAT r2 = sqrt(rsq2); + const KK_FLOAT r2 = Kokkos::sqrt(rsq2); // c = cosine of angle, s = sine @@ -185,7 +185,7 @@ void AngleCosineShiftExpKokkos::operator()(TagAngleCosineShiftExpCom if (c > static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(1e-12)) s = static_cast(1e-12); const KK_FLOAT cccpsss = c*d_cost[type] + s*d_sint[type]; @@ -204,7 +204,7 @@ void AngleCosineShiftExpKokkos::operator()(TagAngleCosineShiftExpCom ff = static_cast(0.25)*uumin*cssmscc*(static_cast(2.0)+aa*cccpsss)/s; } else { // full exponential formula - const KK_FLOAT exp2 = exp(static_cast(0.5)*aa*(static_cast(1.0)+cccpsss)); + const KK_FLOAT exp2 = Kokkos::exp(static_cast(0.5)*aa*(static_cast(1.0)+cccpsss)); if (eflag) eangle = d_opt1[type]*(static_cast(1.0)-exp2); ff = static_cast(0.5)*aa*d_opt1[type]*exp2*cssmscc/s; } @@ -224,21 +224,21 @@ void AngleCosineShiftExpKokkos::operator()(TagAngleCosineShiftExpCom // apply force to each of 3 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) -= f1[0] + f3[0]; - a_f(i2,1) -= f1[1] + f3[1]; - a_f(i2,2) -= f1[2] + f3[2]; + a_f(i2,0) -= static_cast(f1[0] + f3[0]); + a_f(i2,1) -= static_cast(f1[1] + f3[1]); + a_f(i2,2) -= static_cast(f1[2] + f3[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (EVFLAG) ev_tally(ev,i1,i2,i3,eangle,f1,f3, @@ -355,21 +355,21 @@ void AngleCosineShiftExpKokkos::ev_tally(EV_FLOAT &ev, const int i, if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eangle; + if (newton_bond) ev.evdwl += static_cast(eangle); else { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (i < nlocal) ev.evdwl += eanglethird; - if (j < nlocal) ev.evdwl += eanglethird; - if (k < nlocal) ev.evdwl += eanglethird; + if (i < nlocal) ev.evdwl += static_cast(eanglethird); + if (j < nlocal) ev.evdwl += static_cast(eanglethird); + if (k < nlocal) ev.evdwl += static_cast(eanglethird); } } if (eflag_atom) { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (newton_bond || i < nlocal) v_eatom[i] += eanglethird; - if (newton_bond || j < nlocal) v_eatom[j] += eanglethird; - if (newton_bond || k < nlocal) v_eatom[k] += eanglethird; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(eanglethird); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(eanglethird); + if (newton_bond || k < nlocal) v_eatom[k] += static_cast(eanglethird); } } @@ -383,64 +383,64 @@ void AngleCosineShiftExpKokkos::ev_tally(EV_FLOAT &ev, const int i, if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (j < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (k < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += THIRD*v[0]; - v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; - v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; - v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(i,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(i,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(i,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(i,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(i,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += THIRD*v[0]; - v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; - v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; - v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(j,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(j,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(j,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(j,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(j,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || k < nlocal) { - v_vatom(k,0) += THIRD*v[0]; - v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; - v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; - v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(k,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(k,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(k,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(k,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(k,5) += static_cast(static_cast(THIRD)*v[5]); } } } diff --git a/src/KOKKOS/angle_cosine_shift_kokkos.cpp b/src/KOKKOS/angle_cosine_shift_kokkos.cpp index b6e239ff1dc..efdefc24ff1 100644 --- a/src/KOKKOS/angle_cosine_shift_kokkos.cpp +++ b/src/KOKKOS/angle_cosine_shift_kokkos.cpp @@ -118,14 +118,14 @@ void AngleCosineShiftKokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -166,7 +166,7 @@ void AngleCosineShiftKokkos::operator()(TagAngleCosineShiftCompute::operator()(TagAngleCosineShiftCompute::operator()(TagAngleCosineShiftCompute static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); const KK_FLOAT cps = c/s; @@ -210,21 +210,21 @@ void AngleCosineShiftKokkos::operator()(TagAngleCosineShiftCompute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) -= f1[0] + f3[0]; - a_f(i2,1) -= f1[1] + f3[1]; - a_f(i2,2) -= f1[2] + f3[2]; + a_f(i2,0) -= static_cast(f1[0] + f3[0]); + a_f(i2,1) -= static_cast(f1[1] + f3[1]); + a_f(i2,2) -= static_cast(f1[2] + f3[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (EVFLAG) ev_tally(ev,i1,i2,i3,eangle,f1,f3, @@ -323,21 +323,21 @@ void AngleCosineShiftKokkos::ev_tally(EV_FLOAT &ev, const int i, con if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eangle; + if (newton_bond) ev.evdwl += static_cast(eangle); else { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (i < nlocal) ev.evdwl += eanglethird; - if (j < nlocal) ev.evdwl += eanglethird; - if (k < nlocal) ev.evdwl += eanglethird; + if (i < nlocal) ev.evdwl += static_cast(eanglethird); + if (j < nlocal) ev.evdwl += static_cast(eanglethird); + if (k < nlocal) ev.evdwl += static_cast(eanglethird); } } if (eflag_atom) { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (newton_bond || i < nlocal) v_eatom[i] += eanglethird; - if (newton_bond || j < nlocal) v_eatom[j] += eanglethird; - if (newton_bond || k < nlocal) v_eatom[k] += eanglethird; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(eanglethird); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(eanglethird); + if (newton_bond || k < nlocal) v_eatom[k] += static_cast(eanglethird); } } @@ -351,64 +351,64 @@ void AngleCosineShiftKokkos::ev_tally(EV_FLOAT &ev, const int i, con if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (j < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (k < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += THIRD*v[0]; - v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; - v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; - v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(i,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(i,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(i,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(i,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(i,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += THIRD*v[0]; - v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; - v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; - v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(j,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(j,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(j,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(j,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(j,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || k < nlocal) { - v_vatom(k,0) += THIRD*v[0]; - v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; - v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; - v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(k,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(k,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(k,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(k,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(k,5) += static_cast(static_cast(THIRD)*v[5]); } } } diff --git a/src/KOKKOS/angle_cosine_squared_kokkos.cpp b/src/KOKKOS/angle_cosine_squared_kokkos.cpp index 9f9cfa07568..fc3c35972c5 100644 --- a/src/KOKKOS/angle_cosine_squared_kokkos.cpp +++ b/src/KOKKOS/angle_cosine_squared_kokkos.cpp @@ -115,14 +115,14 @@ void AngleCosineSquaredKokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -163,7 +163,7 @@ void AngleCosineSquaredKokkos::operator()(TagAngleCosineSquaredCompu const KK_FLOAT delz1 = x(i1,2) - x22; const KK_FLOAT rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; - const KK_FLOAT r1 = sqrt(rsq1); + const KK_FLOAT r1 = Kokkos::sqrt(rsq1); // 2nd bond @@ -172,7 +172,7 @@ void AngleCosineSquaredKokkos::operator()(TagAngleCosineSquaredCompu const KK_FLOAT delz2 = x(i3,2) - x22; const KK_FLOAT rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; - const KK_FLOAT r2 = sqrt(rsq2); + const KK_FLOAT r2 = Kokkos::sqrt(rsq2); // c = cosine of angle @@ -205,21 +205,21 @@ void AngleCosineSquaredKokkos::operator()(TagAngleCosineSquaredCompu // apply force to each of 3 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) -= f1[0] + f3[0]; - a_f(i2,1) -= f1[1] + f3[1]; - a_f(i2,2) -= f1[2] + f3[2]; + a_f(i2,0) -= static_cast(f1[0] + f3[0]); + a_f(i2,1) -= static_cast(f1[1] + f3[1]); + a_f(i2,2) -= static_cast(f1[2] + f3[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (EVFLAG) ev_tally(ev,i1,i2,i3,eangle,f1,f3, @@ -312,21 +312,21 @@ void AngleCosineSquaredKokkos::ev_tally(EV_FLOAT &ev, const int i, c if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eangle; + if (newton_bond) ev.evdwl += static_cast(eangle); else { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (i < nlocal) ev.evdwl += eanglethird; - if (j < nlocal) ev.evdwl += eanglethird; - if (k < nlocal) ev.evdwl += eanglethird; + if (i < nlocal) ev.evdwl += static_cast(eanglethird); + if (j < nlocal) ev.evdwl += static_cast(eanglethird); + if (k < nlocal) ev.evdwl += static_cast(eanglethird); } } if (eflag_atom) { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (newton_bond || i < nlocal) v_eatom[i] += eanglethird; - if (newton_bond || j < nlocal) v_eatom[j] += eanglethird; - if (newton_bond || k < nlocal) v_eatom[k] += eanglethird; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(eanglethird); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(eanglethird); + if (newton_bond || k < nlocal) v_eatom[k] += static_cast(eanglethird); } } @@ -340,64 +340,64 @@ void AngleCosineSquaredKokkos::ev_tally(EV_FLOAT &ev, const int i, c if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (j < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (k < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += THIRD*v[0]; - v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; - v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; - v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(i,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(i,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(i,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(i,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(i,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += THIRD*v[0]; - v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; - v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; - v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(j,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(j,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(j,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(j,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(j,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || k < nlocal) { - v_vatom(k,0) += THIRD*v[0]; - v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; - v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; - v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(k,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(k,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(k,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(k,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(k,5) += static_cast(static_cast(THIRD)*v[5]); } } } diff --git a/src/KOKKOS/angle_cosine_squared_restricted_kokkos.cpp b/src/KOKKOS/angle_cosine_squared_restricted_kokkos.cpp index df697059142..59fb6adf2a2 100644 --- a/src/KOKKOS/angle_cosine_squared_restricted_kokkos.cpp +++ b/src/KOKKOS/angle_cosine_squared_restricted_kokkos.cpp @@ -115,14 +115,14 @@ void AngleCosineSquaredRestrictedKokkos::compute(int eflag_in, int v } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -163,7 +163,7 @@ void AngleCosineSquaredRestrictedKokkos::operator()(TagAngleCosineSq const KK_FLOAT delz1 = x(i1,2) - x22; const KK_FLOAT rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; - const KK_FLOAT r1 = sqrt(rsq1); + const KK_FLOAT r1 = Kokkos::sqrt(rsq1); // 2nd bond @@ -172,7 +172,7 @@ void AngleCosineSquaredRestrictedKokkos::operator()(TagAngleCosineSq const KK_FLOAT delz2 = x(i3,2) - x22; const KK_FLOAT rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; - const KK_FLOAT r2 = sqrt(rsq2); + const KK_FLOAT r2 = Kokkos::sqrt(rsq2); // c = cosine of angle @@ -207,21 +207,21 @@ void AngleCosineSquaredRestrictedKokkos::operator()(TagAngleCosineSq // apply force to each of 3 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) -= f1[0] + f3[0]; - a_f(i2,1) -= f1[1] + f3[1]; - a_f(i2,2) -= f1[2] + f3[2]; + a_f(i2,0) -= static_cast(f1[0] + f3[0]); + a_f(i2,1) -= static_cast(f1[1] + f3[1]); + a_f(i2,2) -= static_cast(f1[2] + f3[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (EVFLAG) ev_tally(ev,i1,i2,i3,eangle,f1,f3, @@ -314,21 +314,21 @@ void AngleCosineSquaredRestrictedKokkos::ev_tally(EV_FLOAT &ev, cons if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eangle; + if (newton_bond) ev.evdwl += static_cast(eangle); else { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (i < nlocal) ev.evdwl += eanglethird; - if (j < nlocal) ev.evdwl += eanglethird; - if (k < nlocal) ev.evdwl += eanglethird; + if (i < nlocal) ev.evdwl += static_cast(eanglethird); + if (j < nlocal) ev.evdwl += static_cast(eanglethird); + if (k < nlocal) ev.evdwl += static_cast(eanglethird); } } if (eflag_atom) { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (newton_bond || i < nlocal) v_eatom[i] += eanglethird; - if (newton_bond || j < nlocal) v_eatom[j] += eanglethird; - if (newton_bond || k < nlocal) v_eatom[k] += eanglethird; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(eanglethird); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(eanglethird); + if (newton_bond || k < nlocal) v_eatom[k] += static_cast(eanglethird); } } @@ -342,64 +342,64 @@ void AngleCosineSquaredRestrictedKokkos::ev_tally(EV_FLOAT &ev, cons if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (j < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (k < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += THIRD*v[0]; - v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; - v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; - v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(i,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(i,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(i,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(i,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(i,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += THIRD*v[0]; - v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; - v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; - v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(j,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(j,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(j,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(j,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(j,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || k < nlocal) { - v_vatom(k,0) += THIRD*v[0]; - v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; - v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; - v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(k,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(k,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(k,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(k,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(k,5) += static_cast(static_cast(THIRD)*v[5]); } } } diff --git a/src/KOKKOS/angle_cross_kokkos.cpp b/src/KOKKOS/angle_cross_kokkos.cpp index 968cddeb5be..cc41b8d5442 100644 --- a/src/KOKKOS/angle_cross_kokkos.cpp +++ b/src/KOKKOS/angle_cross_kokkos.cpp @@ -154,14 +154,14 @@ void AngleCrossKokkos::operator()(TagAngleCrossCompute::operator()(TagAngleCrossCompute static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); s = static_cast(1.0)/s; @@ -192,7 +192,7 @@ void AngleCrossKokkos::operator()(TagAngleCrossCompute::operator()(TagAngleDipoleCompute, co const KK_FLOAT r2 = delx*delx + dely*dely + delz*delz; if (r2 < static_cast(SMALL)*static_cast(SMALL)) return; - const KK_FLOAT r = sqrt(r2); + const KK_FLOAT r = Kokkos::sqrt(r2); const KK_FLOAT rmu = r * d_mu(iDip,3); const KK_FLOAT cosGamma = (d_mu(iDip,0)*delx + d_mu(iDip,1)*dely + d_mu(iDip,2)*delz) / rmu; - const KK_FLOAT deltaGamma = cosGamma - cos(d_gamma0[type]); + const KK_FLOAT deltaGamma = cosGamma - Kokkos::cos(d_gamma0[type]); const KK_FLOAT kdg = d_k[type] * deltaGamma; KK_FLOAT eangle = static_cast(0.0); @@ -182,7 +182,7 @@ void AngleDipoleKokkos::operator()(TagAngleDipoleCompute, co const KK_FLOAT len2 = fx*fx + fy*fy + fz*fz; if (len2 < static_cast(SMALL)*static_cast(SMALL)) return; - const KK_FLOAT fmod_len = sqrt(fmod2) / (r * sqrt(len2)); + const KK_FLOAT fmod_len = Kokkos::sqrt(fmod2) / (r * Kokkos::sqrt(len2)); KK_FLOAT fi[3], fj[3]; fi[0] = fx * fmod_len; diff --git a/src/KOKKOS/angle_fourier_kokkos.cpp b/src/KOKKOS/angle_fourier_kokkos.cpp index 7356d9a0934..c92d31decd1 100644 --- a/src/KOKKOS/angle_fourier_kokkos.cpp +++ b/src/KOKKOS/angle_fourier_kokkos.cpp @@ -150,14 +150,14 @@ void AngleFourierKokkos::operator()(TagAngleFourierCompute::operator()(TagAngleFourierSimpleCompu const KK_FLOAT delz1 = x(i1,2) - x(i2,2); const KK_FLOAT rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; - const KK_FLOAT r1 = sqrt(rsq1); + const KK_FLOAT r1 = Kokkos::sqrt(rsq1); const KK_FLOAT delx2 = x(i3,0) - x(i2,0); const KK_FLOAT dely2 = x(i3,1) - x(i2,1); const KK_FLOAT delz2 = x(i3,2) - x(i2,2); const KK_FLOAT rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; - const KK_FLOAT r2 = sqrt(rsq2); + const KK_FLOAT r2 = Kokkos::sqrt(rsq2); KK_FLOAT c = delx1*delx2 + dely1*dely2 + delz1*delz2; c /= r1*r2; @@ -166,16 +166,16 @@ void AngleFourierSimpleKokkos::operator()(TagAngleFourierSimpleCompu if (c > static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - const KK_FLOAT th = acos(c); + const KK_FLOAT th = Kokkos::acos(c); const KK_FLOAT nth = d_N[type] * th; - const KK_FLOAT cn = cos(nth); + const KK_FLOAT cn = Kokkos::cos(nth); KK_FLOAT eangle = static_cast(0.0); if (eflag) eangle = d_k[type] * (static_cast(1.0) + d_C[type] * cn); KK_FLOAT a; - if (fabs(c) - static_cast(1.0) > static_cast(SMALL)) { - a = d_k[type] * d_C[type] * d_N[type] * sin(nth) / sin(th); + if (Kokkos::fabs(c) - static_cast(1.0) > static_cast(SMALL)) { + a = d_k[type] * d_C[type] * d_N[type] * Kokkos::sin(nth) / Kokkos::sin(th); } else { KK_FLOAT term, sgn; if (c >= static_cast(0.0)) { diff --git a/src/KOKKOS/angle_gaussian_kokkos.cpp b/src/KOKKOS/angle_gaussian_kokkos.cpp index 29ba76b1b4d..9dcde567845 100644 --- a/src/KOKKOS/angle_gaussian_kokkos.cpp +++ b/src/KOKKOS/angle_gaussian_kokkos.cpp @@ -184,14 +184,14 @@ void AngleGaussianKokkos::operator()(TagAngleGaussianCompute::operator()(TagAngleGaussianCompute static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); s = static_cast(1.0)/s; - const KK_FLOAT theta = acos(c); + const KK_FLOAT theta = Kokkos::acos(c); KK_FLOAT sum_g_i = static_cast(0.0); KK_FLOAT sum_numerator = static_cast(0.0); @@ -211,9 +211,9 @@ void AngleGaussianKokkos::operator()(TagAngleGaussianCompute(MY_PI2))); + const KK_FLOAT prefactor = d_alpha(type,i) / (w * Kokkos::sqrt(static_cast(MY_PI2))); const KK_FLOAT exponent = static_cast(-2.0) * dtheta * dtheta / (w * w); - const KK_FLOAT g_i = prefactor * exp(exponent); + const KK_FLOAT g_i = prefactor * Kokkos::exp(exponent); sum_g_i += g_i; sum_numerator += g_i * dtheta / (w * w); } @@ -225,7 +225,7 @@ void AngleGaussianKokkos::operator()(TagAngleGaussianCompute(0.0); - if (eflag) eangle = -kbt * log(sum_g_i); + if (eflag) eangle = -kbt * Kokkos::log(sum_g_i); const KK_FLOAT a = static_cast(-4.0) * kbt * (sum_numerator / sum_g_i) * s; const KK_FLOAT a11 = a*c / rsq1; @@ -302,11 +302,11 @@ void AngleGaussianKokkos::coeff(int narg, char **arg) for (int i = ilo; i <= ihi; i++) { k_nterms.view_host()[i] = nterms[i]; - k_angle_temperature.view_host()[i] = angle_temperature[i]; + k_angle_temperature.view_host()[i] = static_cast(angle_temperature[i]); for (int j = 0; j < nterms[i]; j++) { - k_alpha.view_host()(i,j) = alpha[i][j]; - k_width.view_host()(i,j) = width[i][j]; - k_theta0.view_host()(i,j) = theta0[i][j]; + k_alpha.view_host()(i,j) = static_cast(alpha[i][j]); + k_width.view_host()(i,j) = static_cast(width[i][j]); + k_theta0.view_host()(i,j) = static_cast(theta0[i][j]); } } @@ -330,11 +330,11 @@ void AngleGaussianKokkos::read_restart(FILE *fp) int n = atom->nangletypes; for (int i = 1; i <= n; i++) { k_nterms.view_host()[i] = nterms[i]; - k_angle_temperature.view_host()[i] = angle_temperature[i]; + k_angle_temperature.view_host()[i] = static_cast(angle_temperature[i]); for (int j = 0; j < nterms[i]; j++) { - k_alpha.view_host()(i,j) = alpha[i][j]; - k_width.view_host()(i,j) = width[i][j]; - k_theta0.view_host()(i,j) = theta0[i][j]; + k_alpha.view_host()(i,j) = static_cast(alpha[i][j]); + k_width.view_host()(i,j) = static_cast(width[i][j]); + k_theta0.view_host()(i,j) = static_cast(theta0[i][j]); } } diff --git a/src/KOKKOS/angle_harmonic_kokkos.cpp b/src/KOKKOS/angle_harmonic_kokkos.cpp index 07c158d4f50..58530640d62 100644 --- a/src/KOKKOS/angle_harmonic_kokkos.cpp +++ b/src/KOKKOS/angle_harmonic_kokkos.cpp @@ -164,7 +164,7 @@ void AngleHarmonicKokkos::operator()(TagAngleHarmonicCompute::operator()(TagAngleHarmonicCompute::operator()(TagAngleHarmonicCompute static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); s = static_cast(1.0)/s; // force & energy - const KK_FLOAT dtheta = acos(c) - d_theta0[type]; + const KK_FLOAT dtheta = Kokkos::acos(c) - d_theta0[type]; const KK_FLOAT tk = d_k[type] * dtheta; KK_FLOAT eangle = 0; diff --git a/src/KOKKOS/angle_mm3_kokkos.cpp b/src/KOKKOS/angle_mm3_kokkos.cpp index 8bd1bf4573e..7020a50f8e1 100644 --- a/src/KOKKOS/angle_mm3_kokkos.cpp +++ b/src/KOKKOS/angle_mm3_kokkos.cpp @@ -158,7 +158,7 @@ void AngleMM3Kokkos::operator()(TagAngleMM3Compute::operator()(TagAngleMM3Compute::operator()(TagAngleMM3Compute static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); s = static_cast(1.0)/s; // force & energy for MM3 angle term (dtheta in radians) - const KK_FLOAT dtheta = acos(c) - d_theta0[type]; + const KK_FLOAT dtheta = Kokkos::acos(c) - d_theta0[type]; const KK_FLOAT dtheta2 = dtheta*dtheta; const KK_FLOAT dtheta3 = dtheta2*dtheta; const KK_FLOAT dtheta4 = dtheta3*dtheta; @@ -315,14 +315,14 @@ void AngleMM3Kokkos::ev_tally(EV_FLOAT &ev, if (eflag_global) { if (newton_bond) ev.evdwl += static_cast(eangle); else { - const KK_ACC_FLOAT et = static_cast(THIRD*eangle); + const KK_ACC_FLOAT et = static_cast(static_cast(THIRD)*eangle); if (i < nlocal) ev.evdwl += et; if (j < nlocal) ev.evdwl += et; if (k < nlocal) ev.evdwl += et; } } if (eflag_atom) { - const KK_ACC_FLOAT et = static_cast(THIRD*eangle); + const KK_ACC_FLOAT et = static_cast(static_cast(THIRD)*eangle); if (newton_bond || i < nlocal) v_eatom[i] += et; if (newton_bond || j < nlocal) v_eatom[j] += et; if (newton_bond || k < nlocal) v_eatom[k] += et; @@ -342,14 +342,14 @@ void AngleMM3Kokkos::ev_tally(EV_FLOAT &ev, if (newton_bond) { for (int m = 0; m < 6; m++) ev.v[m] += static_cast(v[m]); } else { - const KK_FLOAT vt = THIRD; + const KK_FLOAT vt = static_cast(THIRD); if (i < nlocal) for (int m = 0; m < 6; m++) ev.v[m] += static_cast(vt*v[m]); if (j < nlocal) for (int m = 0; m < 6; m++) ev.v[m] += static_cast(vt*v[m]); if (k < nlocal) for (int m = 0; m < 6; m++) ev.v[m] += static_cast(vt*v[m]); } } if (vflag_atom) { - const KK_FLOAT vt = THIRD; + const KK_FLOAT vt = static_cast(THIRD); if (newton_bond || i < nlocal) for (int m = 0; m < 6; m++) v_vatom(i,m) += static_cast(vt*v[m]); if (newton_bond || j < nlocal) diff --git a/src/KOKKOS/angle_mwlc_kokkos.cpp b/src/KOKKOS/angle_mwlc_kokkos.cpp index e53b3668e9e..25705ca1653 100644 --- a/src/KOKKOS/angle_mwlc_kokkos.cpp +++ b/src/KOKKOS/angle_mwlc_kokkos.cpp @@ -152,14 +152,14 @@ void AngleMWLCKokkos::operator()(TagAngleMWLCCompute::operator()(TagAngleMWLCCompute(-1.0)) c = static_cast(-1.0); const KK_FLOAT kbt = d_temp[type] * boltz; - const KK_FLOAT v_min = -kbt * log(static_cast(1.0) + exp(-d_mu[type] / kbt)); + const KK_FLOAT v_min = -kbt * Kokkos::log(static_cast(1.0) + Kokkos::exp(-d_mu[type] / kbt)); - const KK_FLOAT q = exp(-d_k1[type] * (static_cast(1.0) + c) / kbt); - const KK_FLOAT qm = exp((-d_k2[type] * (static_cast(1.0) + c) - d_mu[type]) / kbt); + const KK_FLOAT q = Kokkos::exp(-d_k1[type] * (static_cast(1.0) + c) / kbt); + const KK_FLOAT qm = Kokkos::exp((-d_k2[type] * (static_cast(1.0) + c) - d_mu[type]) / kbt); const KK_FLOAT Q = q + qm; KK_FLOAT eangle = static_cast(0.0); - if (eflag) eangle = -kbt * log(Q) - v_min; + if (eflag) eangle = -kbt * Kokkos::log(Q) - v_min; const KK_FLOAT a = (d_k1[type] * q + d_k2[type] * qm) / Q; const KK_FLOAT a11 = a*c / rsq1; diff --git a/src/KOKKOS/angle_quartic_kokkos.cpp b/src/KOKKOS/angle_quartic_kokkos.cpp index b4d18460fc6..51ee27280a6 100644 --- a/src/KOKKOS/angle_quartic_kokkos.cpp +++ b/src/KOKKOS/angle_quartic_kokkos.cpp @@ -152,14 +152,14 @@ void AngleQuarticKokkos::operator()(TagAngleQuarticCompute::operator()(TagAngleQuarticCompute static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); s = static_cast(1.0)/s; - const KK_FLOAT dtheta = acos(c) - d_theta0[type]; + const KK_FLOAT dtheta = Kokkos::acos(c) - d_theta0[type]; const KK_FLOAT dtheta2 = dtheta*dtheta; const KK_FLOAT dtheta3 = dtheta2*dtheta; const KK_FLOAT tk = static_cast(2.0)*d_k2[type]*dtheta diff --git a/src/KOKKOS/angle_spica_kokkos.cpp b/src/KOKKOS/angle_spica_kokkos.cpp index 95c92ba5ac3..1097f640a09 100644 --- a/src/KOKKOS/angle_spica_kokkos.cpp +++ b/src/KOKKOS/angle_spica_kokkos.cpp @@ -136,14 +136,14 @@ void AngleSPICAKokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -180,7 +180,7 @@ void AngleSPICAKokkos::operator()(TagAngleSPICACompute::operator()(TagAngleSPICACompute 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; - KK_FLOAT s = sqrt(1.0 - c*c); - if (s < SMALL) s = SMALL; - s = 1.0/s; + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); + if (s < static_cast(SMALL)) s = static_cast(SMALL); + s = static_cast(1.0)/s; // 1-3 LJ interaction. // we only want to use the repulsive part, @@ -227,7 +227,7 @@ void AngleSPICAKokkos::operator()(TagAngleSPICACompute(1.0)/rsq3; if (ljt == LJ12_4) { const KK_FLOAT r4inv=r2inv*r2inv; @@ -236,7 +236,7 @@ void AngleSPICAKokkos::operator()(TagAngleSPICACompute::operator()(TagAngleSPICACompute::operator()(TagAngleSPICACompute(2.0) * tk * s; const KK_FLOAT a11 = a*c / rsq1; const KK_FLOAT a12 = -a / (r1*r2); const KK_FLOAT a22 = a*c / rsq2; @@ -287,21 +287,21 @@ void AngleSPICAKokkos::operator()(TagAngleSPICACompute(f1[0] + f13*delx3); + a_f(i1,1) += static_cast(f1[1] + f13*dely3); + a_f(i1,2) += static_cast(f1[2] + f13*delz3); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) -= f1[0] + f3[0]; - a_f(i2,1) -= f1[1] + f3[1]; - a_f(i2,2) -= f1[2] + f3[2]; + a_f(i2,0) -= static_cast(f1[0] + f3[0]); + a_f(i2,1) -= static_cast(f1[1] + f3[1]); + a_f(i2,2) -= static_cast(f1[2] + f3[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0] - f13*delx3; - a_f(i3,1) += f3[1] - f13*dely3; - a_f(i3,2) += f3[2] - f13*delz3; + a_f(i3,0) += static_cast(f3[0] - f13*delx3); + a_f(i3,1) += static_cast(f3[1] - f13*dely3); + a_f(i3,2) += static_cast(f3[2] - f13*delz3); } if (EVFLAG) { @@ -380,12 +380,12 @@ void AngleSPICAKokkos::init_style() for (int i = 1; i <= ntypes; i++) { for (int j = 1; j <= ntypes; j++) { k_lj_type.view_host()(i,j) = lj_type[i][j]; - k_lj1.view_host()(i,j) = lj1[i][j]; - k_lj2.view_host()(i,j) = lj2[i][j]; - k_lj3.view_host()(i,j) = lj3[i][j]; - k_lj4.view_host()(i,j) = lj4[i][j]; - k_rminsq.view_host()(i,j) = rminsq[i][j]; - k_emin.view_host()(i,j) = emin[i][j]; + k_lj1.view_host()(i,j) = static_cast(lj1[i][j]); + k_lj2.view_host()(i,j) = static_cast(lj2[i][j]); + k_lj3.view_host()(i,j) = static_cast(lj3[i][j]); + k_lj4.view_host()(i,j) = static_cast(lj4[i][j]); + k_rminsq.view_host()(i,j) = static_cast(rminsq[i][j]); + k_emin.view_host()(i,j) = static_cast(emin[i][j]); } } @@ -411,9 +411,9 @@ void AngleSPICAKokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->nangletypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k.view_host()[i] = k[i]; - k_theta0.view_host()[i] = theta0[i]; - k_repscale.view_host()[i] = repscale[i]; + k_k.view_host()[i] = static_cast(k[i]); + k_theta0.view_host()[i] = static_cast(theta0[i]); + k_repscale.view_host()[i] = static_cast(repscale[i]); k_setflag.view_host()[i] = setflag[i]; } @@ -434,9 +434,9 @@ void AngleSPICAKokkos::read_restart(FILE *fp) int n = atom->nangletypes; for (int i = 1; i <= n; i++) { - k_k.view_host()[i] = k[i]; - k_theta0.view_host()[i] = theta0[i]; - k_repscale.view_host()[i] = repscale[i]; + k_k.view_host()[i] = static_cast(k[i]); + k_theta0.view_host()[i] = static_cast(theta0[i]); + k_repscale.view_host()[i] = static_cast(repscale[i]); k_setflag.view_host()[i] = setflag[i]; } @@ -469,21 +469,21 @@ void AngleSPICAKokkos::ev_tally(EV_FLOAT &ev, const int i, const int if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eangle; + if (newton_bond) ev.evdwl += static_cast(eangle); else { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (i < nlocal) ev.evdwl += eanglethird; - if (j < nlocal) ev.evdwl += eanglethird; - if (k < nlocal) ev.evdwl += eanglethird; + if (i < nlocal) ev.evdwl += static_cast(eanglethird); + if (j < nlocal) ev.evdwl += static_cast(eanglethird); + if (k < nlocal) ev.evdwl += static_cast(eanglethird); } } if (eflag_atom) { - eanglethird = THIRD*eangle; + eanglethird = static_cast(THIRD)*eangle; - if (newton_bond || i < nlocal) v_eatom[i] += eanglethird; - if (newton_bond || j < nlocal) v_eatom[j] += eanglethird; - if (newton_bond || k < nlocal) v_eatom[k] += eanglethird; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(eanglethird); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(eanglethird); + if (newton_bond || k < nlocal) v_eatom[k] += static_cast(eanglethird); } } @@ -497,65 +497,65 @@ void AngleSPICAKokkos::ev_tally(EV_FLOAT &ev, const int i, const int if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (j < nlocal) { - ev.v[0] += THIRD*v[0]; - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } if (k < nlocal) { - ev.v[0] += THIRD*v[0]; + ev.v[0] += static_cast(static_cast(THIRD)*v[0]); - ev.v[1] += THIRD*v[1]; - ev.v[2] += THIRD*v[2]; - ev.v[3] += THIRD*v[3]; - ev.v[4] += THIRD*v[4]; - ev.v[5] += THIRD*v[5]; + ev.v[1] += static_cast(static_cast(THIRD)*v[1]); + ev.v[2] += static_cast(static_cast(THIRD)*v[2]); + ev.v[3] += static_cast(static_cast(THIRD)*v[3]); + ev.v[4] += static_cast(static_cast(THIRD)*v[4]); + ev.v[5] += static_cast(static_cast(THIRD)*v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += THIRD*v[0]; - v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; - v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; - v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(i,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(i,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(i,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(i,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(i,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += THIRD*v[0]; - v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; - v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; - v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(j,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(j,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(j,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(j,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(j,5) += static_cast(static_cast(THIRD)*v[5]); } if (newton_bond || k < nlocal) { - v_vatom(k,0) += THIRD*v[0]; - v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; - v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; - v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(static_cast(THIRD)*v[0]); + v_vatom(k,1) += static_cast(static_cast(THIRD)*v[1]); + v_vatom(k,2) += static_cast(static_cast(THIRD)*v[2]); + v_vatom(k,3) += static_cast(static_cast(THIRD)*v[3]); + v_vatom(k,4) += static_cast(static_cast(THIRD)*v[4]); + v_vatom(k,5) += static_cast(static_cast(THIRD)*v[5]); } } @@ -580,17 +580,17 @@ void AngleSPICAKokkos::ev_tally13(EV_FLOAT &ev, const int i, const i if (eflag_either) { if (eflag_global) { if (newton_bond) { - ev.evdwl += evdwl; + ev.evdwl += static_cast(evdwl); } else { if (i < nlocal) - ev.evdwl += 0.5*evdwl; + ev.evdwl += static_cast(static_cast(0.5)*evdwl); if (j < nlocal) - ev.evdwl += 0.5*evdwl; + ev.evdwl += static_cast(static_cast(0.5)*evdwl); } } if (eflag_atom) { - if (newton_bond || i < nlocal) v_eatom[i] += 0.5*evdwl; - if (newton_bond || j < nlocal) v_eatom[j] += 0.5*evdwl; + if (newton_bond || i < nlocal) v_eatom[i] += static_cast(static_cast(0.5)*evdwl); + if (newton_bond || j < nlocal) v_eatom[j] += static_cast(static_cast(0.5)*evdwl); } } @@ -604,48 +604,48 @@ void AngleSPICAKokkos::ev_tally13(EV_FLOAT &ev, const int i, const i if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += 0.5*v[0]; - ev.v[1] += 0.5*v[1]; - ev.v[2] += 0.5*v[2]; - ev.v[3] += 0.5*v[3]; - ev.v[4] += 0.5*v[4]; - ev.v[5] += 0.5*v[5]; + ev.v[0] += static_cast(static_cast(0.5)*v[0]); + ev.v[1] += static_cast(static_cast(0.5)*v[1]); + ev.v[2] += static_cast(static_cast(0.5)*v[2]); + ev.v[3] += static_cast(static_cast(0.5)*v[3]); + ev.v[4] += static_cast(static_cast(0.5)*v[4]); + ev.v[5] += static_cast(static_cast(0.5)*v[5]); } if (j < nlocal) { - ev.v[0] += 0.5*v[0]; - ev.v[1] += 0.5*v[1]; - ev.v[2] += 0.5*v[2]; - ev.v[3] += 0.5*v[3]; - ev.v[4] += 0.5*v[4]; - ev.v[5] += 0.5*v[5]; + ev.v[0] += static_cast(static_cast(0.5)*v[0]); + ev.v[1] += static_cast(static_cast(0.5)*v[1]); + ev.v[2] += static_cast(static_cast(0.5)*v[2]); + ev.v[3] += static_cast(static_cast(0.5)*v[3]); + ev.v[4] += static_cast(static_cast(0.5)*v[4]); + ev.v[5] += static_cast(static_cast(0.5)*v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - v_vatom(i,0) += 0.5*v[0]; - v_vatom(i,1) += 0.5*v[1]; - v_vatom(i,2) += 0.5*v[2]; - v_vatom(i,3) += 0.5*v[3]; - v_vatom(i,4) += 0.5*v[4]; - v_vatom(i,5) += 0.5*v[5]; + v_vatom(i,0) += static_cast(static_cast(0.5)*v[0]); + v_vatom(i,1) += static_cast(static_cast(0.5)*v[1]); + v_vatom(i,2) += static_cast(static_cast(0.5)*v[2]); + v_vatom(i,3) += static_cast(static_cast(0.5)*v[3]); + v_vatom(i,4) += static_cast(static_cast(0.5)*v[4]); + v_vatom(i,5) += static_cast(static_cast(0.5)*v[5]); } if (newton_bond || j < nlocal) { - v_vatom(j,0) += 0.5*v[0]; - v_vatom(j,1) += 0.5*v[1]; - v_vatom(j,2) += 0.5*v[2]; - v_vatom(j,3) += 0.5*v[3]; - v_vatom(j,4) += 0.5*v[4]; - v_vatom(j,5) += 0.5*v[5]; + v_vatom(j,0) += static_cast(static_cast(0.5)*v[0]); + v_vatom(j,1) += static_cast(static_cast(0.5)*v[1]); + v_vatom(j,2) += static_cast(static_cast(0.5)*v[2]); + v_vatom(j,3) += static_cast(static_cast(0.5)*v[3]); + v_vatom(j,4) += static_cast(static_cast(0.5)*v[4]); + v_vatom(j,5) += static_cast(static_cast(0.5)*v[5]); } } } diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 113338a313b..070ff92e450 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -100,18 +100,18 @@ struct AtomVecKokkos_PackComm { const int j = _list(i); int m = 0; if constexpr (PBC_FLAG == 0) { - _buf(i,m++) = _x(j,0); - _buf(i,m++) = _x(j,1); - _buf(i,m++) = _x(j,2); + _buf(i,m++) = static_cast(_x(j,0)); + _buf(i,m++) = static_cast(_x(j,1)); + _buf(i,m++) = static_cast(_x(j,2)); } else { if (TRICLINIC == 0) { - _buf(i,m++) = _x(j,0) + _pbc[0]*_xprd; - _buf(i,m++) = _x(j,1) + _pbc[1]*_yprd; - _buf(i,m++) = _x(j,2) + _pbc[2]*_zprd; + _buf(i,m++) = static_cast(_x(j,0)) + _pbc[0]*_xprd; + _buf(i,m++) = static_cast(_x(j,1)) + _pbc[1]*_yprd; + _buf(i,m++) = static_cast(_x(j,2)) + _pbc[2]*_zprd; } else { - _buf(i,m++) = _x(j,0) + _pbc[0]*_xprd + _pbc[5]*_xy + _pbc[4]*_xz; - _buf(i,m++) = _x(j,1) + _pbc[1]*_yprd + _pbc[3]*_yz; - _buf(i,m++) = _x(j,2) + _pbc[2]*_zprd; + _buf(i,m++) = static_cast(_x(j,0)) + _pbc[0]*_xprd + _pbc[5]*_xy + _pbc[4]*_xz; + _buf(i,m++) = static_cast(_x(j,1)) + _pbc[1]*_yprd + _pbc[3]*_yz; + _buf(i,m++) = static_cast(_x(j,2)) + _pbc[2]*_zprd; } } @@ -120,27 +120,27 @@ struct AtomVecKokkos_PackComm { // DIPOLE package if (_datamask & MU_MASK) { - _buf(i,m++) = _mu(j,0); - _buf(i,m++) = _mu(j,1); - _buf(i,m++) = _mu(j,2); + _buf(i,m++) = static_cast(_mu(j,0)); + _buf(i,m++) = static_cast(_mu(j,1)); + _buf(i,m++) = static_cast(_mu(j,2)); } // SPIN package if (_datamask & SP_MASK) { - _buf(i,m++) = _sp(j,0); - _buf(i,m++) = _sp(j,1); - _buf(i,m++) = _sp(j,2); - _buf(i,m++) = _sp(j,3); + _buf(i,m++) = static_cast(_sp(j,0)); + _buf(i,m++) = static_cast(_sp(j,1)); + _buf(i,m++) = static_cast(_sp(j,2)); + _buf(i,m++) = static_cast(_sp(j,3)); } // DPD-REACT package if (_datamask & DPDTHETA_MASK) { - _buf(i,m++) = _dpdTheta(j); - _buf(i,m++) = _uCond(j); - _buf(i,m++) = _uMech(j); - _buf(i,m++) = _uChem(j); + _buf(i,m++) = static_cast(_dpdTheta(j)); + _buf(i,m++) = static_cast(_uCond(j)); + _buf(i,m++) = static_cast(_uMech(j)); + _buf(i,m++) = static_cast(_uChem(j)); } } } @@ -311,36 +311,36 @@ struct AtomVecKokkos_UnpackComm { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { int m = 0; - _x(i+_first,0) = _buf(i,m++); - _x(i+_first,1) = _buf(i,m++); - _x(i+_first,2) = _buf(i,m++); + _x(i+_first,0) = static_cast(_buf(i,m++)); + _x(i+_first,1) = static_cast(_buf(i,m++)); + _x(i+_first,2) = static_cast(_buf(i,m++)); if constexpr (!DEFAULT) { // DIPOLE package if (_datamask & MU_MASK) { - _mu(i+_first,0) = _buf(i,m++); - _mu(i+_first,1) = _buf(i,m++); - _mu(i+_first,2) = _buf(i,m++); + _mu(i+_first,0) = static_cast(_buf(i,m++)); + _mu(i+_first,1) = static_cast(_buf(i,m++)); + _mu(i+_first,2) = static_cast(_buf(i,m++)); } // SPIN package if (_datamask & SP_MASK) { - _sp(i+_first,0) = _buf(i,m++); - _sp(i+_first,1) = _buf(i,m++); - _sp(i+_first,2) = _buf(i,m++); - _sp(i+_first,3) = _buf(i,m++); + _sp(i+_first,0) = static_cast(_buf(i,m++)); + _sp(i+_first,1) = static_cast(_buf(i,m++)); + _sp(i+_first,2) = static_cast(_buf(i,m++)); + _sp(i+_first,3) = static_cast(_buf(i,m++)); } // DPD-REACT package if (_datamask & DPDTHETA_MASK) { - _dpdTheta(i+_first) = _buf(i,m++); - _uCond(i+_first) = _buf(i,m++); - _uMech(i+_first) = _buf(i,m++); - _uChem(i+_first) = _buf(i,m++); + _dpdTheta(i+_first) = static_cast(_buf(i,m++)); + _uCond(i+_first) = static_cast(_buf(i,m++)); + _uMech(i+_first) = static_cast(_buf(i,m++)); + _uChem(i+_first) = static_cast(_buf(i,m++)); } } } @@ -423,13 +423,13 @@ struct AtomVecKokkos_PackCommSelf { _x(i+_nfirst,2) = _x(j,2); } else { if (TRICLINIC == 0) { - _x(i+_nfirst,0) = _x(j,0) + _pbc[0]*_xprd; - _x(i+_nfirst,1) = _x(j,1) + _pbc[1]*_yprd; - _x(i+_nfirst,2) = _x(j,2) + _pbc[2]*_zprd; + _x(i+_nfirst,0) = _x(j,0) + static_cast(_pbc[0]*_xprd); + _x(i+_nfirst,1) = _x(j,1) + static_cast(_pbc[1]*_yprd); + _x(i+_nfirst,2) = _x(j,2) + static_cast(_pbc[2]*_zprd); } else { - _x(i+_nfirst,0) = _x(j,0) + _pbc[0]*_xprd + _pbc[5]*_xy + _pbc[4]*_xz; - _x(i+_nfirst,1) = _x(j,1) + _pbc[1]*_yprd + _pbc[3]*_yz; - _x(i+_nfirst,2) = _x(j,2) + _pbc[2]*_zprd; + _x(i+_nfirst,0) = _x(j,0) + static_cast(_pbc[0]*_xprd) + static_cast(_pbc[5]*_xy) + static_cast(_pbc[4]*_xz); + _x(i+_nfirst,1) = _x(j,1) + static_cast(_pbc[1]*_yprd) + static_cast(_pbc[3]*_yz); + _x(i+_nfirst,2) = _x(j,2) + static_cast(_pbc[2]*_zprd); } } @@ -660,13 +660,13 @@ struct AtomVecKokkos_PackCommSelfFused { _x(i+_nfirst,2) = _x(j,2); } else { if (TRICLINIC == 0) { - _x(i+_nfirst,0) = _x(j,0) + _pbc(ii,0)*_xprd; - _x(i+_nfirst,1) = _x(j,1) + _pbc(ii,1)*_yprd; - _x(i+_nfirst,2) = _x(j,2) + _pbc(ii,2)*_zprd; + _x(i+_nfirst,0) = _x(j,0) + static_cast(_pbc(ii,0)*_xprd); + _x(i+_nfirst,1) = _x(j,1) + static_cast(_pbc(ii,1)*_yprd); + _x(i+_nfirst,2) = _x(j,2) + static_cast(_pbc(ii,2)*_zprd); } else { - _x(i+_nfirst,0) = _x(j,0) + _pbc(ii,0)*_xprd + _pbc(ii,5)*_xy + _pbc(ii,4)*_xz; - _x(i+_nfirst,1) = _x(j,1) + _pbc(ii,1)*_yprd + _pbc(ii,3)*_yz; - _x(i+_nfirst,2) = _x(j,2) + _pbc(ii,2)*_zprd; + _x(i+_nfirst,0) = _x(j,0) + static_cast(_pbc(ii,0)*_xprd) + static_cast(_pbc(ii,5)*_xy) + static_cast(_pbc(ii,4)*_xz); + _x(i+_nfirst,1) = _x(j,1) + static_cast(_pbc(ii,1)*_yprd) + static_cast(_pbc(ii,3)*_yz); + _x(i+_nfirst,2) = _x(j,2) + static_cast(_pbc(ii,2)*_zprd); } } @@ -836,36 +836,36 @@ struct AtomVecKokkos_PackCommVel { int m = 0; const int j = _list(i); if constexpr (PBC_FLAG == 0) { - _buf(i,m++) = _x(j,0); - _buf(i,m++) = _x(j,1); - _buf(i,m++) = _x(j,2); - _buf(i,m++) = _v(j,0); - _buf(i,m++) = _v(j,1); - _buf(i,m++) = _v(j,2); + _buf(i,m++) = static_cast(_x(j,0)); + _buf(i,m++) = static_cast(_x(j,1)); + _buf(i,m++) = static_cast(_x(j,2)); + _buf(i,m++) = static_cast(_v(j,0)); + _buf(i,m++) = static_cast(_v(j,1)); + _buf(i,m++) = static_cast(_v(j,2)); } else { if (TRICLINIC == 0) { - _buf(i,m++) = _x(j,0) + _pbc[0]*_xprd; - _buf(i,m++) = _x(j,1) + _pbc[1]*_yprd; - _buf(i,m++) = _x(j,2) + _pbc[2]*_zprd; + _buf(i,m++) = static_cast(_x(j,0)) + _pbc[0]*_xprd; + _buf(i,m++) = static_cast(_x(j,1)) + _pbc[1]*_yprd; + _buf(i,m++) = static_cast(_x(j,2)) + _pbc[2]*_zprd; } else { - _buf(i,m++) = _x(j,0) + _pbc[0]*_xprd + _pbc[5]*_xy + _pbc[4]*_xz; - _buf(i,m++) = _x(j,1) + _pbc[1]*_yprd + _pbc[3]*_yz; - _buf(i,m++) = _x(j,2) + _pbc[2]*_zprd; + _buf(i,m++) = static_cast(_x(j,0)) + _pbc[0]*_xprd + _pbc[5]*_xy + _pbc[4]*_xz; + _buf(i,m++) = static_cast(_x(j,1)) + _pbc[1]*_yprd + _pbc[3]*_yz; + _buf(i,m++) = static_cast(_x(j,2)) + _pbc[2]*_zprd; } if constexpr (DEFORM_VREMAP == 0) { - _buf(i,m++) = _v(j,0); - _buf(i,m++) = _v(j,1); - _buf(i,m++) = _v(j,2); + _buf(i,m++) = static_cast(_v(j,0)); + _buf(i,m++) = static_cast(_v(j,1)); + _buf(i,m++) = static_cast(_v(j,2)); } else { if (_mask(i) & _deform_vremap) { - _buf(i,m++) = _v(j,0) + _pbc[0]*_h_rate[0] + _pbc[5]*_h_rate[5] + _pbc[4]*_h_rate[4]; - _buf(i,m++) = _v(j,1) + _pbc[1]*_h_rate[1] + _pbc[3]*_h_rate[3]; - _buf(i,m++) = _v(j,2) + _pbc[2]*_h_rate[2]; + _buf(i,m++) = static_cast(_v(j,0)) + _pbc[0]*_h_rate[0] + _pbc[5]*_h_rate[5] + _pbc[4]*_h_rate[4]; + _buf(i,m++) = static_cast(_v(j,1)) + _pbc[1]*_h_rate[1] + _pbc[3]*_h_rate[3]; + _buf(i,m++) = static_cast(_v(j,2)) + _pbc[2]*_h_rate[2]; } else { - _buf(i,m++) = _v(j,0); - _buf(i,m++) = _v(j,1); - _buf(i,m++) = _v(j,2); + _buf(i,m++) = static_cast(_v(j,0)); + _buf(i,m++) = static_cast(_v(j,1)); + _buf(i,m++) = static_cast(_v(j,2)); } } } @@ -873,43 +873,43 @@ struct AtomVecKokkos_PackCommVel { // angmom: included for ellipsoid if (_datamask & ANGMOM_MASK) { - _buf(i,m++) = _angmom(j,0); - _buf(i,m++) = _angmom(j,1); - _buf(i,m++) = _angmom(j,2); + _buf(i,m++) = static_cast(_angmom(j,0)); + _buf(i,m++) = static_cast(_angmom(j,1)); + _buf(i,m++) = static_cast(_angmom(j,2)); } // DIPOLE package if (_datamask & MU_MASK) { - _buf(i,m++) = _mu(j,0); - _buf(i,m++) = _mu(j,1); - _buf(i,m++) = _mu(j,2); + _buf(i,m++) = static_cast(_mu(j,0)); + _buf(i,m++) = static_cast(_mu(j,1)); + _buf(i,m++) = static_cast(_mu(j,2)); } // SPIN package if (_datamask & SP_MASK) { - _buf(i,m++) = _sp(j,0); - _buf(i,m++) = _sp(j,1); - _buf(i,m++) = _sp(j,2); - _buf(i,m++) = _sp(j,3); + _buf(i,m++) = static_cast(_sp(j,0)); + _buf(i,m++) = static_cast(_sp(j,1)); + _buf(i,m++) = static_cast(_sp(j,2)); + _buf(i,m++) = static_cast(_sp(j,3)); } // SPHERE package if (_datamask & OMEGA_MASK) { - _buf(i,m++) = _omega(j,0); - _buf(i,m++) = _omega(j,1); - _buf(i,m++) = _omega(j,2); + _buf(i,m++) = static_cast(_omega(j,0)); + _buf(i,m++) = static_cast(_omega(j,1)); + _buf(i,m++) = static_cast(_omega(j,2)); } // DPD-REACT package if (_datamask & DPDTHETA_MASK) { - _buf(i,m++) = _dpdTheta(j); - _buf(i,m++) = _uCond(j); - _buf(i,m++) = _uMech(j); - _buf(i,m++) = _uChem(j); + _buf(i,m++) = static_cast(_dpdTheta(j)); + _buf(i,m++) = static_cast(_uCond(j)); + _buf(i,m++) = static_cast(_uMech(j)); + _buf(i,m++) = static_cast(_uChem(j)); } } }; @@ -1091,55 +1091,55 @@ struct AtomVecKokkos_UnpackCommVel { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { int m = 0; - _x(i+_first,0) = _buf(i,m++); - _x(i+_first,1) = _buf(i,m++); - _x(i+_first,2) = _buf(i,m++); - _v(i+_first,0) = _buf(i,m++); - _v(i+_first,1) = _buf(i,m++); - _v(i+_first,2) = _buf(i,m++); + _x(i+_first,0) = static_cast(_buf(i,m++)); + _x(i+_first,1) = static_cast(_buf(i,m++)); + _x(i+_first,2) = static_cast(_buf(i,m++)); + _v(i+_first,0) = static_cast(_buf(i,m++)); + _v(i+_first,1) = static_cast(_buf(i,m++)); + _v(i+_first,2) = static_cast(_buf(i,m++)); if constexpr (!DEFAULT) { // angmom: included for ellipsoid if (_datamask & ANGMOM_MASK) { - _angmom(i+_first,0) = _buf(i,m++); - _angmom(i+_first,1) = _buf(i,m++); - _angmom(i+_first,2) = _buf(i,m++); + _angmom(i+_first,0) = static_cast(_buf(i,m++)); + _angmom(i+_first,1) = static_cast(_buf(i,m++)); + _angmom(i+_first,2) = static_cast(_buf(i,m++)); } // DIPOLE package if (_datamask & MU_MASK) { - _mu(i+_first,0) = _buf(i,m++); - _mu(i+_first,1) = _buf(i,m++); - _mu(i+_first,2) = _buf(i,m++); + _mu(i+_first,0) = static_cast(_buf(i,m++)); + _mu(i+_first,1) = static_cast(_buf(i,m++)); + _mu(i+_first,2) = static_cast(_buf(i,m++)); } // SPIN package if (_datamask & SP_MASK) { - _sp(i+_first,0) = _buf(i,m++); - _sp(i+_first,1) = _buf(i,m++); - _sp(i+_first,2) = _buf(i,m++); - _sp(i+_first,3) = _buf(i,m++); + _sp(i+_first,0) = static_cast(_buf(i,m++)); + _sp(i+_first,1) = static_cast(_buf(i,m++)); + _sp(i+_first,2) = static_cast(_buf(i,m++)); + _sp(i+_first,3) = static_cast(_buf(i,m++)); } // SPHERE package if (_datamask & OMEGA_MASK) { - _omega(i+_first,0) = _buf(i,m++); - _omega(i+_first,1) = _buf(i,m++); - _omega(i+_first,2) = _buf(i,m++); + _omega(i+_first,0) = static_cast(_buf(i,m++)); + _omega(i+_first,1) = static_cast(_buf(i,m++)); + _omega(i+_first,2) = static_cast(_buf(i,m++)); } // DPD-REACT package if (_datamask & DPDTHETA_MASK) { - _dpdTheta(i+_first) = _buf(i,m++); - _uCond(i+_first) = _buf(i,m++); - _uMech(i+_first) = _buf(i,m++); - _uChem(i+_first) = _buf(i,m++); + _dpdTheta(i+_first) = static_cast(_buf(i,m++)); + _uCond(i+_first) = static_cast(_buf(i,m++)); + _uMech(i+_first) = static_cast(_buf(i,m++)); + _uChem(i+_first) = static_cast(_buf(i,m++)); } } } @@ -1206,30 +1206,30 @@ struct AtomVecKokkos_PackReverse { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { int m = 0; - _buf(i,m++) = _f(i+_first,0); - _buf(i,m++) = _f(i+_first,1); - _buf(i,m++) = _f(i+_first,2); + _buf(i,m++) = static_cast(_f(i+_first,0)); + _buf(i,m++) = static_cast(_f(i+_first,1)); + _buf(i,m++) = static_cast(_f(i+_first,2)); if constexpr (!DEFAULT) { // DIPLE package if (_datamask & TORQUE_MASK) { - _buf(i,m++) = _torque(i+_first,0); - _buf(i,m++) = _torque(i+_first,1); - _buf(i,m++) = _torque(i+_first,2); + _buf(i,m++) = static_cast(_torque(i+_first,0)); + _buf(i,m++) = static_cast(_torque(i+_first,1)); + _buf(i,m++) = static_cast(_torque(i+_first,2)); } // SPIN package if (_datamask & FM_MASK) { - _buf(i,m++) = _fm(i+_first,0); - _buf(i,m++) = _fm(i+_first,1); - _buf(i,m++) = _fm(i+_first,2); + _buf(i,m++) = static_cast(_fm(i+_first,0)); + _buf(i,m++) = static_cast(_fm(i+_first,1)); + _buf(i,m++) = static_cast(_fm(i+_first,2)); - _buf(i,m++) = _fm_long(i+_first,0); - _buf(i,m++) = _fm_long(i+_first,1); - _buf(i,m++) = _fm_long(i+_first,2); + _buf(i,m++) = static_cast(_fm_long(i+_first,0)); + _buf(i,m++) = static_cast(_fm_long(i+_first,1)); + _buf(i,m++) = static_cast(_fm_long(i+_first,2)); } } } @@ -1296,30 +1296,30 @@ struct AtomVecKokkos_UnPackReverse { void operator() (const int& i) const { int m = 0; const int j = _list(i); - _f(j,0) += _buf(i,m++); - _f(j,1) += _buf(i,m++); - _f(j,2) += _buf(i,m++); + _f(j,0) += static_cast(_buf(i,m++)); + _f(j,1) += static_cast(_buf(i,m++)); + _f(j,2) += static_cast(_buf(i,m++)); if constexpr (!DEFAULT) { // DIPOLE package if (_datamask & TORQUE_MASK) { - _torque(j,0) += _buf(i,m++); - _torque(j,1) += _buf(i,m++); - _torque(j,2) += _buf(i,m++); + _torque(j,0) += static_cast(_buf(i,m++)); + _torque(j,1) += static_cast(_buf(i,m++)); + _torque(j,2) += static_cast(_buf(i,m++)); } // SPIN package if (_datamask & FM_MASK) { - _fm(j,0) += _buf(i,m++); - _fm(j,1) += _buf(i,m++); - _fm(j,2) += _buf(i,m++); + _fm(j,0) += static_cast(_buf(i,m++)); + _fm(j,1) += static_cast(_buf(i,m++)); + _fm(j,2) += static_cast(_buf(i,m++)); - _fm_long(j,0) += _buf(i,m++); - _fm_long(j,1) += _buf(i,m++); - _fm_long(j,2) += _buf(i,m++); + _fm_long(j,0) += static_cast(_buf(i,m++)); + _fm_long(j,1) += static_cast(_buf(i,m++)); + _fm_long(j,2) += static_cast(_buf(i,m++)); } } } @@ -1496,13 +1496,13 @@ struct AtomVecKokkos_PackBorder { const int j = _list(i); int m = 0; if constexpr (PBC_FLAG == 0) { - _buf(i,m++) = _x(j,0); - _buf(i,m++) = _x(j,1); - _buf(i,m++) = _x(j,2); + _buf(i,m++) = static_cast(_x(j,0)); + _buf(i,m++) = static_cast(_x(j,1)); + _buf(i,m++) = static_cast(_x(j,2)); } else { - _buf(i,m++) = _x(j,0) + _dx; - _buf(i,m++) = _x(j,1) + _dy; - _buf(i,m++) = _x(j,2) + _dz; + _buf(i,m++) = static_cast(_x(j,0)) + _dx; + _buf(i,m++) = static_cast(_x(j,1)) + _dy; + _buf(i,m++) = static_cast(_x(j,2)) + _dz; } _buf(i,m++) = d_ubuf(_tag(j)).d; @@ -1515,37 +1515,37 @@ struct AtomVecKokkos_PackBorder { _buf(i,m++) = d_ubuf(_molecule(j)).d; if (_datamask & Q_MASK) - _buf(i,m++) = _q(j); + _buf(i,m++) = static_cast(_q(j)); if (_datamask & MU_MASK) { - _buf(i,m++) = _mu(j,0); - _buf(i,m++) = _mu(j,1); - _buf(i,m++) = _mu(j,2); - _buf(i,m++) = _mu(j,3); + _buf(i,m++) = static_cast(_mu(j,0)); + _buf(i,m++) = static_cast(_mu(j,1)); + _buf(i,m++) = static_cast(_mu(j,2)); + _buf(i,m++) = static_cast(_mu(j,3)); } if (_datamask & SP_MASK) { - _buf(i,m++) = _sp(j,0); - _buf(i,m++) = _sp(j,1); - _buf(i,m++) = _sp(j,2); - _buf(i,m++) = _sp(j,3); + _buf(i,m++) = static_cast(_sp(j,0)); + _buf(i,m++) = static_cast(_sp(j,1)); + _buf(i,m++) = static_cast(_sp(j,2)); + _buf(i,m++) = static_cast(_sp(j,3)); } if (_datamask & RADIUS_MASK) - _buf(i,m++) = _radius(j); + _buf(i,m++) = static_cast(_radius(j)); if (_datamask & RMASS_MASK) - _buf(i,m++) = _rmass(j); + _buf(i,m++) = static_cast(_rmass(j)); // DPD-REACT package if (_datamask & DPDTHETA_MASK) { - _buf(i,m++) = _dpdTheta(j); - _buf(i,m++) = _uCond(j); - _buf(i,m++) = _uMech(j); - _buf(i,m++) = _uChem(j); - _buf(i,m++) = _uCG(j); - _buf(i,m++) = _uCGnew(j); + _buf(i,m++) = static_cast(_dpdTheta(j)); + _buf(i,m++) = static_cast(_uCond(j)); + _buf(i,m++) = static_cast(_uMech(j)); + _buf(i,m++) = static_cast(_uChem(j)); + _buf(i,m++) = static_cast(_uCG(j)); + _buf(i,m++) = static_cast(_uCGnew(j)); } } } @@ -1679,9 +1679,9 @@ struct AtomVecKokkos_UnpackBorder { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { int m = 0; - _x(i+_first,0) = _buf(i,m++); - _x(i+_first,1) = _buf(i,m++); - _x(i+_first,2) = _buf(i,m++); + _x(i+_first,0) = static_cast(_buf(i,m++)); + _x(i+_first,1) = static_cast(_buf(i,m++)); + _x(i+_first,2) = static_cast(_buf(i,m++)); _tag(i+_first) = (tagint) d_ubuf(_buf(i,m++)).i; _type(i+_first) = (int) d_ubuf(_buf(i,m++)).i; _mask(i+_first) = (int) d_ubuf(_buf(i,m++)).i; @@ -1692,37 +1692,37 @@ struct AtomVecKokkos_UnpackBorder { _molecule(i+_first) = (tagint) d_ubuf(_buf(i,m++)).i; if (_datamask & Q_MASK) - _q(i+_first) = _buf(i,m++); + _q(i+_first) = static_cast(_buf(i,m++)); if (_datamask & MU_MASK) { - _mu(i+_first,0) = _buf(i,m++); - _mu(i+_first,1) = _buf(i,m++); - _mu(i+_first,2) = _buf(i,m++); - _mu(i+_first,3) = _buf(i,m++); + _mu(i+_first,0) = static_cast(_buf(i,m++)); + _mu(i+_first,1) = static_cast(_buf(i,m++)); + _mu(i+_first,2) = static_cast(_buf(i,m++)); + _mu(i+_first,3) = static_cast(_buf(i,m++)); } if (_datamask & SP_MASK) { - _sp(i+_first,0) = _buf(i,m++); - _sp(i+_first,1) = _buf(i,m++); - _sp(i+_first,2) = _buf(i,m++); - _sp(i+_first,3) = _buf(i,m++); + _sp(i+_first,0) = static_cast(_buf(i,m++)); + _sp(i+_first,1) = static_cast(_buf(i,m++)); + _sp(i+_first,2) = static_cast(_buf(i,m++)); + _sp(i+_first,3) = static_cast(_buf(i,m++)); } if (_datamask & RADIUS_MASK) - _radius(i+_first) = _buf(i,m++); + _radius(i+_first) = static_cast(_buf(i,m++)); if (_datamask & RMASS_MASK) - _rmass(i+_first) = _buf(i,m++); + _rmass(i+_first) = static_cast(_buf(i,m++)); // DPD-REACT package if (_datamask & DPDTHETA_MASK) { - _dpdTheta(i+_first) = _buf(i,m++); - _uCond(i+_first) = _buf(i,m++); - _uMech(i+_first) = _buf(i,m++); - _uChem(i+_first) = _buf(i,m++); - _uCG(i+_first) = _buf(i,m++); - _uCGnew(i+_first) = _buf(i,m++); + _dpdTheta(i+_first) = static_cast(_buf(i,m++)); + _uCond(i+_first) = static_cast(_buf(i,m++)); + _uMech(i+_first) = static_cast(_buf(i,m++)); + _uChem(i+_first) = static_cast(_buf(i,m++)); + _uCG(i+_first) = static_cast(_buf(i,m++)); + _uCGnew(i+_first) = static_cast(_buf(i,m++)); } } } @@ -1833,13 +1833,13 @@ struct AtomVecKokkos_PackBorderVel { int m = 0; const int j = _list(i); if constexpr (PBC_FLAG == 0) { - _buf(i,m++) = _x(j,0); - _buf(i,m++) = _x(j,1); - _buf(i,m++) = _x(j,2); + _buf(i,m++) = static_cast(_x(j,0)); + _buf(i,m++) = static_cast(_x(j,1)); + _buf(i,m++) = static_cast(_x(j,2)); } else { - _buf(i,m++) = _x(j,0) + _dx; - _buf(i,m++) = _x(j,1) + _dy; - _buf(i,m++) = _x(j,2) + _dz; + _buf(i,m++) = static_cast(_x(j,0)) + _dx; + _buf(i,m++) = static_cast(_x(j,1)) + _dy; + _buf(i,m++) = static_cast(_x(j,2)) + _dz; } _buf(i,m++) = d_ubuf(_tag(j)).d; _buf(i,m++) = d_ubuf(_type(j)).d; @@ -1847,65 +1847,65 @@ struct AtomVecKokkos_PackBorderVel { if constexpr (DEFORM_VREMAP) { if (_mask(i) & _deform_groupbit) { - _buf(i,m++) = _v(j,0) + _dvx; - _buf(i,m++) = _v(j,1) + _dvy; - _buf(i,m++) = _v(j,2) + _dvz; + _buf(i,m++) = static_cast(_v(j,0)) + _dvx; + _buf(i,m++) = static_cast(_v(j,1)) + _dvy; + _buf(i,m++) = static_cast(_v(j,2)) + _dvz; } } else { - _buf(i,m++) = _v(j,0); - _buf(i,m++) = _v(j,1); - _buf(i,m++) = _v(j,2); + _buf(i,m++) = static_cast(_v(j,0)); + _buf(i,m++) = static_cast(_v(j,1)); + _buf(i,m++) = static_cast(_v(j,2)); } // angmom: included for ellipsoid if (_datamask & ANGMOM_MASK) { - _buf(i,m++) = _angmom(j,0); - _buf(i,m++) = _angmom(j,1); - _buf(i,m++) = _angmom(j,2); + _buf(i,m++) = static_cast(_angmom(j,0)); + _buf(i,m++) = static_cast(_angmom(j,1)); + _buf(i,m++) = static_cast(_angmom(j,2)); } if (_datamask & MOLECULE_MASK) _buf(i,m++) = d_ubuf(_molecule(j)).d; if (_datamask & Q_MASK) - _buf(i,m++) = _q(j); + _buf(i,m++) = static_cast(_q(j)); if (_datamask & MU_MASK) { - _buf(i,m++) = _mu(j,0); - _buf(i,m++) = _mu(j,1); - _buf(i,m++) = _mu(j,2); - _buf(i,m++) = _mu(j,3); + _buf(i,m++) = static_cast(_mu(j,0)); + _buf(i,m++) = static_cast(_mu(j,1)); + _buf(i,m++) = static_cast(_mu(j,2)); + _buf(i,m++) = static_cast(_mu(j,3)); } if (_datamask & SP_MASK) { - _buf(i,m++) = _sp(j,0); - _buf(i,m++) = _sp(j,1); - _buf(i,m++) = _sp(j,2); - _buf(i,m++) = _sp(j,3); + _buf(i,m++) = static_cast(_sp(j,0)); + _buf(i,m++) = static_cast(_sp(j,1)); + _buf(i,m++) = static_cast(_sp(j,2)); + _buf(i,m++) = static_cast(_sp(j,3)); } if (_datamask & RADIUS_MASK) - _buf(i,m++) = _radius(j); + _buf(i,m++) = static_cast(_radius(j)); if (_datamask & RMASS_MASK) - _buf(i,m++) = _rmass(j); + _buf(i,m++) = static_cast(_rmass(j)); if (_datamask & OMEGA_MASK) { - _buf(i,m++) = _omega(j,0); - _buf(i,m++) = _omega(j,1); - _buf(i,m++) = _omega(j,2); + _buf(i,m++) = static_cast(_omega(j,0)); + _buf(i,m++) = static_cast(_omega(j,1)); + _buf(i,m++) = static_cast(_omega(j,2)); } // DPD-REACT package if (_datamask & DPDTHETA_MASK) { - _buf(i,m++) = _dpdTheta(j); - _buf(i,m++) = _uCond(j); - _buf(i,m++) = _uMech(j); - _buf(i,m++) = _uChem(j); - _buf(i,m++) = _uCG(j); - _buf(i,m++) = _uCGnew(j); + _buf(i,m++) = static_cast(_dpdTheta(j)); + _buf(i,m++) = static_cast(_uCond(j)); + _buf(i,m++) = static_cast(_uMech(j)); + _buf(i,m++) = static_cast(_uChem(j)); + _buf(i,m++) = static_cast(_uCG(j)); + _buf(i,m++) = static_cast(_uCGnew(j)); } } }; @@ -2051,67 +2051,67 @@ struct AtomVecKokkos_UnpackBorderVel { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { int m = 0; - _x(i+_first,0) = _buf(i,m++); - _x(i+_first,1) = _buf(i,m++); - _x(i+_first,2) = _buf(i,m++); + _x(i+_first,0) = static_cast(_buf(i,m++)); + _x(i+_first,1) = static_cast(_buf(i,m++)); + _x(i+_first,2) = static_cast(_buf(i,m++)); _tag(i+_first) = static_cast(d_ubuf(_buf(i,m++)).i); _type(i+_first) = static_cast(d_ubuf(_buf(i,m++)).i); _mask(i+_first) = static_cast(d_ubuf(_buf(i,m++)).i); - _v(i+_first,0) = _buf(i,m++); - _v(i+_first,1) = _buf(i,m++); - _v(i+_first,2) = _buf(i,m++); + _v(i+_first,0) = static_cast(_buf(i,m++)); + _v(i+_first,1) = static_cast(_buf(i,m++)); + _v(i+_first,2) = static_cast(_buf(i,m++)); if constexpr (!DEFAULT) { // angmom: included for ellipsoid if (_datamask & ANGMOM_MASK) { - _angmom(i+_first,0) = _buf(i,m++); - _angmom(i+_first,1) = _buf(i,m++); - _angmom(i+_first,2) = _buf(i,m++); + _angmom(i+_first,0) = static_cast(_buf(i,m++)); + _angmom(i+_first,1) = static_cast(_buf(i,m++)); + _angmom(i+_first,2) = static_cast(_buf(i,m++)); } if (_datamask & MOLECULE_MASK) _molecule(i+_first) = (tagint) d_ubuf(_buf(i,m++)).i; if (_datamask & Q_MASK) - _q(i+_first) = _buf(i,m++); + _q(i+_first) = static_cast(_buf(i,m++)); if (_datamask & MU_MASK) { - _mu(i+_first,0) = _buf(i,m++); - _mu(i+_first,1) = _buf(i,m++); - _mu(i+_first,2) = _buf(i,m++); - _mu(i+_first,3) = _buf(i,m++); + _mu(i+_first,0) = static_cast(_buf(i,m++)); + _mu(i+_first,1) = static_cast(_buf(i,m++)); + _mu(i+_first,2) = static_cast(_buf(i,m++)); + _mu(i+_first,3) = static_cast(_buf(i,m++)); } if (_datamask & SP_MASK) { - _sp(i+_first,0) = _buf(i,m++); - _sp(i+_first,1) = _buf(i,m++); - _sp(i+_first,2) = _buf(i,m++); - _sp(i+_first,3) = _buf(i,m++); + _sp(i+_first,0) = static_cast(_buf(i,m++)); + _sp(i+_first,1) = static_cast(_buf(i,m++)); + _sp(i+_first,2) = static_cast(_buf(i,m++)); + _sp(i+_first,3) = static_cast(_buf(i,m++)); } if (_datamask & RADIUS_MASK) - _radius(i+_first) = _buf(i,m++); + _radius(i+_first) = static_cast(_buf(i,m++)); if (_datamask & RMASS_MASK) - _rmass(i+_first) = _buf(i,m++); + _rmass(i+_first) = static_cast(_buf(i,m++)); if (_datamask & OMEGA_MASK) { - _omega(i+_first,0) = _buf(i,m++); - _omega(i+_first,1) = _buf(i,m++); - _omega(i+_first,2) = _buf(i,m++); + _omega(i+_first,0) = static_cast(_buf(i,m++)); + _omega(i+_first,1) = static_cast(_buf(i,m++)); + _omega(i+_first,2) = static_cast(_buf(i,m++)); } // DPD-REACT package if (_datamask & DPDTHETA_MASK) { - _dpdTheta(i+_first) = _buf(i,m++); - _uCond(i+_first) = _buf(i,m++); - _uMech(i+_first) = _buf(i,m++); - _uChem(i+_first) = _buf(i,m++); - _uCG(i+_first) = _buf(i,m++); - _uCGnew(i+_first) = _buf(i,m++); + _dpdTheta(i+_first) = static_cast(_buf(i,m++)); + _uCond(i+_first) = static_cast(_buf(i,m++)); + _uMech(i+_first) = static_cast(_buf(i,m++)); + _uChem(i+_first) = static_cast(_buf(i,m++)); + _uCG(i+_first) = static_cast(_buf(i,m++)); + _uCGnew(i+_first) = static_cast(_buf(i,m++)); } } } @@ -2271,12 +2271,12 @@ struct AtomVecKokkos_PackExchangeFunctor { int m = 0; _buf(mysend,m++) = _size_exchange; - _buf(mysend,m++) = _x(i,0); - _buf(mysend,m++) = _x(i,1); - _buf(mysend,m++) = _x(i,2); - _buf(mysend,m++) = _v(i,0); - _buf(mysend,m++) = _v(i,1); - _buf(mysend,m++) = _v(i,2); + _buf(mysend,m++) = static_cast(_x(i,0)); + _buf(mysend,m++) = static_cast(_x(i,1)); + _buf(mysend,m++) = static_cast(_x(i,2)); + _buf(mysend,m++) = static_cast(_v(i,0)); + _buf(mysend,m++) = static_cast(_v(i,1)); + _buf(mysend,m++) = static_cast(_v(i,2)); _buf(mysend,m++) = d_ubuf(_tag(i)).d; _buf(mysend,m++) = d_ubuf(_type(i)).d; _buf(mysend,m++) = d_ubuf(_mask(i)).d; @@ -2285,7 +2285,7 @@ struct AtomVecKokkos_PackExchangeFunctor { if constexpr (!DEFAULT) { if (_datamask & Q_MASK) - _buf(mysend,m++) = _q(i); + _buf(mysend,m++) = static_cast(_q(i)); if (_datamask & MOLECULE_MASK) _buf(mysend,m++) = d_ubuf(_molecule(i)).d; @@ -2339,48 +2339,48 @@ struct AtomVecKokkos_PackExchangeFunctor { } if (_datamask & MU_MASK) { - _buf(mysend,m++) = _mu(i,0); - _buf(mysend,m++) = _mu(i,1); - _buf(mysend,m++) = _mu(i,2); - _buf(mysend,m++) = _mu(i,3); + _buf(mysend,m++) = static_cast(_mu(i,0)); + _buf(mysend,m++) = static_cast(_mu(i,1)); + _buf(mysend,m++) = static_cast(_mu(i,2)); + _buf(mysend,m++) = static_cast(_mu(i,3)); } if (_datamask & SP_MASK) { - _buf(mysend,m++) = _sp(i,0); - _buf(mysend,m++) = _sp(i,1); - _buf(mysend,m++) = _sp(i,2); - _buf(mysend,m++) = _sp(i,3); + _buf(mysend,m++) = static_cast(_sp(i,0)); + _buf(mysend,m++) = static_cast(_sp(i,1)); + _buf(mysend,m++) = static_cast(_sp(i,2)); + _buf(mysend,m++) = static_cast(_sp(i,3)); } if (_datamask & RADIUS_MASK) - _buf(mysend,m++) = _radius(i); + _buf(mysend,m++) = static_cast(_radius(i)); if (_datamask & RMASS_MASK) - _buf(mysend,m++) = _rmass(i); + _buf(mysend,m++) = static_cast(_rmass(i)); if (_datamask & OMEGA_MASK) { - _buf(mysend,m++) = _omega(i,0); - _buf(mysend,m++) = _omega(i,1); - _buf(mysend,m++) = _omega(i,2); + _buf(mysend,m++) = static_cast(_omega(i,0)); + _buf(mysend,m++) = static_cast(_omega(i,1)); + _buf(mysend,m++) = static_cast(_omega(i,2)); } // angmom: included for ellipsoid if (_datamask & ANGMOM_MASK) { - _buf(mysend,m++) = _angmom(i,0); - _buf(mysend,m++) = _angmom(i,1); - _buf(mysend,m++) = _angmom(i,2); + _buf(mysend,m++) = static_cast(_angmom(i,0)); + _buf(mysend,m++) = static_cast(_angmom(i,1)); + _buf(mysend,m++) = static_cast(_angmom(i,2)); } // DPD-REACT package if (_datamask & DPDTHETA_MASK) { - _buf(mysend,m++) = _dpdTheta(i); - _buf(mysend,m++) = _uCond(i); - _buf(mysend,m++) = _uMech(i); - _buf(mysend,m++) = _uChem(i); - _buf(mysend,m++) = _uCG(i); - _buf(mysend,m++) = _uCGnew(i); + _buf(mysend,m++) = static_cast(_dpdTheta(i)); + _buf(mysend,m++) = static_cast(_uCond(i)); + _buf(mysend,m++) = static_cast(_uMech(i)); + _buf(mysend,m++) = static_cast(_uChem(i)); + _buf(mysend,m++) = static_cast(_uCG(i)); + _buf(mysend,m++) = static_cast(_uCGnew(i)); } } @@ -2666,12 +2666,12 @@ struct AtomVecKokkos_UnpackExchangeFunctor { if (x >= _lo && x < _hi) { i = Kokkos::atomic_fetch_add(&_nlocal(0),1); int m = 1; - _x(i,0) = _buf(myrecv,m++); - _x(i,1) = _buf(myrecv,m++); - _x(i,2) = _buf(myrecv,m++); - _v(i,0) = _buf(myrecv,m++); - _v(i,1) = _buf(myrecv,m++); - _v(i,2) = _buf(myrecv,m++); + _x(i,0) = static_cast(_buf(myrecv,m++)); + _x(i,1) = static_cast(_buf(myrecv,m++)); + _x(i,2) = static_cast(_buf(myrecv,m++)); + _v(i,0) = static_cast(_buf(myrecv,m++)); + _v(i,1) = static_cast(_buf(myrecv,m++)); + _v(i,2) = static_cast(_buf(myrecv,m++)); _tag(i) = (tagint) d_ubuf(_buf(myrecv,m++)).i; _type(i) = (int) d_ubuf(_buf(myrecv,m++)).i; _mask(i) = (int) d_ubuf(_buf(myrecv,m++)).i; @@ -2680,7 +2680,7 @@ struct AtomVecKokkos_UnpackExchangeFunctor { if constexpr (!DEFAULT) { if (_datamask & Q_MASK) - _q(i) = _buf(myrecv,m++); + _q(i) = static_cast(_buf(myrecv,m++)); if (_datamask & MOLECULE_MASK) _molecule(i) = (tagint) d_ubuf(_buf(myrecv,m++)).i; @@ -2734,46 +2734,46 @@ struct AtomVecKokkos_UnpackExchangeFunctor { } if (_datamask & MU_MASK) { - _mu(i,0) = _buf(myrecv,m++); - _mu(i,1) = _buf(myrecv,m++); - _mu(i,2) = _buf(myrecv,m++); - _mu(i,3) = _buf(myrecv,m++); + _mu(i,0) = static_cast(_buf(myrecv,m++)); + _mu(i,1) = static_cast(_buf(myrecv,m++)); + _mu(i,2) = static_cast(_buf(myrecv,m++)); + _mu(i,3) = static_cast(_buf(myrecv,m++)); } if (_datamask & SP_MASK) { - _sp(i,0) = _buf(myrecv,m++); - _sp(i,1) = _buf(myrecv,m++); - _sp(i,2) = _buf(myrecv,m++); - _sp(i,3) = _buf(myrecv,m++); + _sp(i,0) = static_cast(_buf(myrecv,m++)); + _sp(i,1) = static_cast(_buf(myrecv,m++)); + _sp(i,2) = static_cast(_buf(myrecv,m++)); + _sp(i,3) = static_cast(_buf(myrecv,m++)); } if (_datamask & RADIUS_MASK) - _radius(i) = _buf(myrecv,m++); + _radius(i) = static_cast(_buf(myrecv,m++)); if (_datamask & RMASS_MASK) - _rmass(i) = _buf(myrecv,m++); + _rmass(i) = static_cast(_buf(myrecv,m++)); if (_datamask & OMEGA_MASK) { - _omega(i,0) = _buf(myrecv,m++); - _omega(i,1) = _buf(myrecv,m++); - _omega(i,2) = _buf(myrecv,m++); + _omega(i,0) = static_cast(_buf(myrecv,m++)); + _omega(i,1) = static_cast(_buf(myrecv,m++)); + _omega(i,2) = static_cast(_buf(myrecv,m++)); } if (_datamask & ANGMOM_MASK) { - _angmom(i,0) = _buf(myrecv,m++); - _angmom(i,1) = _buf(myrecv,m++); - _angmom(i,2) = _buf(myrecv,m++); + _angmom(i,0) = static_cast(_buf(myrecv,m++)); + _angmom(i,1) = static_cast(_buf(myrecv,m++)); + _angmom(i,2) = static_cast(_buf(myrecv,m++)); } // DPD-REACT package if (_datamask & DPDTHETA_MASK) { - _dpdTheta(i) = _buf(myrecv,m++); - _uCond(i) = _buf(myrecv,m++); - _uMech(i) = _buf(myrecv,m++); - _uChem(i) = _buf(myrecv,m++); - _uCG(i) = _buf(myrecv,m++); - _uCGnew(i) = _buf(myrecv,m++); + _dpdTheta(i) = static_cast(_buf(myrecv,m++)); + _uCond(i) = static_cast(_buf(myrecv,m++)); + _uMech(i) = static_cast(_buf(myrecv,m++)); + _uChem(i) = static_cast(_buf(myrecv,m++)); + _uCG(i) = static_cast(_buf(myrecv,m++)); + _uCGnew(i) = static_cast(_buf(myrecv,m++)); } } } diff --git a/src/KOKKOS/bond_class2_kokkos.cpp b/src/KOKKOS/bond_class2_kokkos.cpp index 113c7316a3b..6f25bc5cecc 100644 --- a/src/KOKKOS/bond_class2_kokkos.cpp +++ b/src/KOKKOS/bond_class2_kokkos.cpp @@ -129,14 +129,14 @@ void BondClass2Kokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -169,7 +169,7 @@ void BondClass2Kokkos::operator()(TagBondClass2Compute::operator()(TagBondClass2Compute 0.0) fbond = -de_bond/r; + de_bond = static_cast(2.0)*d_k2[type]*dr + static_cast(3.0)*d_k3[type]*dr2 + static_cast(4.0)*d_k4[type]*dr3; + if (r > static_cast(0.0)) fbond = -de_bond/r; else fbond = 0.0; if (eflag) ebond = d_k2[type]*dr2 + d_k3[type]*dr3 + d_k4[type]*dr4; @@ -188,15 +188,15 @@ void BondClass2Kokkos::operator()(TagBondClass2Compute(delx*fbond); + f(i1,1) += static_cast(dely*fbond); + f(i1,2) += static_cast(delz*fbond); } if (NEWTON_BOND || i2 < nlocal) { - f(i2,0) -= delx*fbond; - f(i2,1) -= dely*fbond; - f(i2,2) -= delz*fbond; + f(i2,0) -= static_cast(delx*fbond); + f(i2,1) -= static_cast(dely*fbond); + f(i2,2) -= static_cast(delz*fbond); } if (EVFLAG) ev_tally(ev,i1,i2,ebond,fbond,delx,dely,delz); @@ -250,10 +250,10 @@ void BondClass2Kokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->nbondtypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k2.view_host()[i] = k2[i]; - k_k3.view_host()[i] = k3[i]; - k_k4.view_host()[i] = k4[i]; - k_r0.view_host()[i] = r0[i]; + k_k2.view_host()[i] = static_cast(k2[i]); + k_k3.view_host()[i] = static_cast(k3[i]); + k_k4.view_host()[i] = static_cast(k4[i]); + k_r0.view_host()[i] = static_cast(r0[i]); } k_k2.modify_host(); @@ -287,10 +287,10 @@ void BondClass2Kokkos::read_restart(FILE *fp) d_r0 = k_r0.template view(); for (int i = 1; i <= n; i++) { - k_k2.view_host()[i] = k2[i]; - k_k3.view_host()[i] = k3[i]; - k_k4.view_host()[i] = k4[i]; - k_r0.view_host()[i] = r0[i]; + k_k2.view_host()[i] = static_cast(k2[i]); + k_k3.view_host()[i] = static_cast(k3[i]); + k_k4.view_host()[i] = static_cast(k4[i]); + k_r0.view_host()[i] = static_cast(r0[i]); } k_k2.modify_host(); @@ -320,17 +320,17 @@ void BondClass2Kokkos::ev_tally(EV_FLOAT &ev, const int &i, const in if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += ebond; + if (newton_bond) ev.evdwl += static_cast(ebond); else { - ebondhalf = 0.5*ebond; - if (i < nlocal) ev.evdwl += ebondhalf; - if (j < nlocal) ev.evdwl += ebondhalf; + ebondhalf = static_cast(0.5)*ebond; + if (i < nlocal) ev.evdwl += static_cast(ebondhalf); + if (j < nlocal) ev.evdwl += static_cast(ebondhalf); } } if (eflag_atom) { - ebondhalf = 0.5*ebond; - if (newton_bond || i < nlocal) d_eatom[i] += ebondhalf; - if (newton_bond || j < nlocal) d_eatom[j] += ebondhalf; + ebondhalf = static_cast(0.5)*ebond; + if (newton_bond || i < nlocal) d_eatom[i] += static_cast(ebondhalf); + if (newton_bond || j < nlocal) d_eatom[j] += static_cast(ebondhalf); } } @@ -344,48 +344,48 @@ void BondClass2Kokkos::ev_tally(EV_FLOAT &ev, const int &i, const in if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i < nlocal) { - ev.v[0] += 0.5*v[0]; - ev.v[1] += 0.5*v[1]; - ev.v[2] += 0.5*v[2]; - ev.v[3] += 0.5*v[3]; - ev.v[4] += 0.5*v[4]; - ev.v[5] += 0.5*v[5]; + ev.v[0] += static_cast(static_cast(0.5)*v[0]); + ev.v[1] += static_cast(static_cast(0.5)*v[1]); + ev.v[2] += static_cast(static_cast(0.5)*v[2]); + ev.v[3] += static_cast(static_cast(0.5)*v[3]); + ev.v[4] += static_cast(static_cast(0.5)*v[4]); + ev.v[5] += static_cast(static_cast(0.5)*v[5]); } if (j < nlocal) { - ev.v[0] += 0.5*v[0]; - ev.v[1] += 0.5*v[1]; - ev.v[2] += 0.5*v[2]; - ev.v[3] += 0.5*v[3]; - ev.v[4] += 0.5*v[4]; - ev.v[5] += 0.5*v[5]; + ev.v[0] += static_cast(static_cast(0.5)*v[0]); + ev.v[1] += static_cast(static_cast(0.5)*v[1]); + ev.v[2] += static_cast(static_cast(0.5)*v[2]); + ev.v[3] += static_cast(static_cast(0.5)*v[3]); + ev.v[4] += static_cast(static_cast(0.5)*v[4]); + ev.v[5] += static_cast(static_cast(0.5)*v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - d_vatom(i,0) += 0.5*v[0]; - d_vatom(i,1) += 0.5*v[1]; - d_vatom(i,2) += 0.5*v[2]; - d_vatom(i,3) += 0.5*v[3]; - d_vatom(i,4) += 0.5*v[4]; - d_vatom(i,5) += 0.5*v[5]; + d_vatom(i,0) += static_cast(static_cast(0.5)*v[0]); + d_vatom(i,1) += static_cast(static_cast(0.5)*v[1]); + d_vatom(i,2) += static_cast(static_cast(0.5)*v[2]); + d_vatom(i,3) += static_cast(static_cast(0.5)*v[3]); + d_vatom(i,4) += static_cast(static_cast(0.5)*v[4]); + d_vatom(i,5) += static_cast(static_cast(0.5)*v[5]); } if (newton_bond || j < nlocal) { - d_vatom(j,0) += 0.5*v[0]; - d_vatom(j,1) += 0.5*v[1]; - d_vatom(j,2) += 0.5*v[2]; - d_vatom(j,3) += 0.5*v[3]; - d_vatom(j,4) += 0.5*v[4]; - d_vatom(j,5) += 0.5*v[5]; + d_vatom(j,0) += static_cast(static_cast(0.5)*v[0]); + d_vatom(j,1) += static_cast(static_cast(0.5)*v[1]); + d_vatom(j,2) += static_cast(static_cast(0.5)*v[2]); + d_vatom(j,3) += static_cast(static_cast(0.5)*v[3]); + d_vatom(j,4) += static_cast(static_cast(0.5)*v[4]); + d_vatom(j,5) += static_cast(static_cast(0.5)*v[5]); } } } diff --git a/src/KOKKOS/bond_fene_expand_kokkos.cpp b/src/KOKKOS/bond_fene_expand_kokkos.cpp index bfae04c4435..c9229e2dc7a 100644 --- a/src/KOKKOS/bond_fene_expand_kokkos.cpp +++ b/src/KOKKOS/bond_fene_expand_kokkos.cpp @@ -178,7 +178,7 @@ void BondFENEExpandKokkos::operator()(TagBondFENEExpandCompute::operator()(TagBondFENEExpandCompute(0.5) * d_k[type] * r0sq * log(rlogarg); + ebond = -static_cast(0.5) * d_k[type] * r0sq * Kokkos::log(rlogarg); if (rshiftsq < static_cast(MY_CUBEROOT2) * sigma2) ebond += static_cast(4.0) * d_epsilon[type] * sr6 * (sr6 - static_cast(1.0)) + d_epsilon[type]; diff --git a/src/KOKKOS/bond_fene_kokkos.cpp b/src/KOKKOS/bond_fene_kokkos.cpp index 1412011c881..980a6d5e44b 100644 --- a/src/KOKKOS/bond_fene_kokkos.cpp +++ b/src/KOKKOS/bond_fene_kokkos.cpp @@ -221,7 +221,7 @@ void BondFENEKokkos::operator()(TagBondFENECompute(0.5) * k*r0sq*log(rlogarg); + ebond = -static_cast(0.5) * k*r0sq*Kokkos::log(rlogarg); if (rsq < static_cast(MY_CUBEROOT2)*sigma2) ebond += static_cast(4.0)*epsilon*sr6*(sr6-static_cast(1.0)) + epsilon; } diff --git a/src/KOKKOS/bond_fene_nm_kokkos.cpp b/src/KOKKOS/bond_fene_nm_kokkos.cpp index f95d9e794ff..3ee06ee3054 100644 --- a/src/KOKKOS/bond_fene_nm_kokkos.cpp +++ b/src/KOKKOS/bond_fene_nm_kokkos.cpp @@ -184,21 +184,21 @@ void BondFENENMKokkos::operator()(TagBondFENENMCompute(0.5) * d_k[type] * r0sq * log(rlogarg); + ebond = -static_cast(0.5) * d_k[type] * r0sq * Kokkos::log(rlogarg); if (rsq < sigma2) { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); ebond += (d_epsilon[type] / (d_nn[type] - d_mm[type])) * - (d_mm[type] * pow(d_sigma[type] / r, d_nn[type]) - - d_nn[type] * pow(d_sigma[type] / r, d_mm[type])); + (d_mm[type] * Kokkos::pow(d_sigma[type] / r, d_nn[type]) - + d_nn[type] * Kokkos::pow(d_sigma[type] / r, d_mm[type])); } } diff --git a/src/KOKKOS/bond_gaussian_kokkos.cpp b/src/KOKKOS/bond_gaussian_kokkos.cpp index ae1113352ce..18f00488040 100644 --- a/src/KOKKOS/bond_gaussian_kokkos.cpp +++ b/src/KOKKOS/bond_gaussian_kokkos.cpp @@ -162,7 +162,7 @@ void BondGaussianKokkos::operator()(TagBondGaussianCompute::operator()(TagBondGaussianCompute(0.0); KK_ACC_FLOAT sum_numerator = static_cast(0.0); for (int i = 0; i < nt; i++) { - const KK_ACC_FLOAT dr = r - d_r0(type,i); - const KK_ACC_FLOAT wsq = static_cast(d_width(type,i)) * d_width(type,i); - const KK_ACC_FLOAT prefactor = d_alpha(type,i) / (d_width(type,i) * sqrt(static_cast(MY_PI2))); + const KK_ACC_FLOAT dr = static_cast(r) - static_cast(d_r0(type,i)); + const KK_ACC_FLOAT wsq = static_cast(d_width(type,i)) * static_cast(d_width(type,i)); + const KK_ACC_FLOAT prefactor = static_cast(d_alpha(type,i)) / (static_cast(d_width(type,i)) * Kokkos::sqrt(static_cast(MY_PI2))); const KK_ACC_FLOAT exponent = -static_cast(2.0) * dr * dr / wsq; - const KK_ACC_FLOAT g_i = prefactor * exp(exponent); + const KK_ACC_FLOAT g_i = prefactor * Kokkos::exp(exponent); sum_g_i += g_i; sum_numerator += g_i * dr / wsq; } @@ -190,10 +190,10 @@ void BondGaussianKokkos::operator()(TagBondGaussianCompute(0.0); if (r > static_cast(0.0)) - fbond = static_cast(-static_cast(4.0) * kbT * (sum_numerator / sum_g_i) / r); + fbond = static_cast(-static_cast(4.0) * static_cast(kbT) * (sum_numerator / sum_g_i) / static_cast(r)); KK_FLOAT ebond = static_cast(0.0); - if (eflag) ebond = static_cast(-kbT * log(sum_g_i)); + if (eflag) ebond = static_cast(-static_cast(kbT) * Kokkos::log(sum_g_i)); // apply force to each of 2 atoms diff --git a/src/KOKKOS/bond_harmonic_kokkos.cpp b/src/KOKKOS/bond_harmonic_kokkos.cpp index b6b43af23a8..1da20d7d77c 100644 --- a/src/KOKKOS/bond_harmonic_kokkos.cpp +++ b/src/KOKKOS/bond_harmonic_kokkos.cpp @@ -166,7 +166,7 @@ void BondHarmonicKokkos::operator()(TagBondHarmonicCompute::operator()(TagBondHarmonicRestrainC KK_FLOAT dy0 = d_x0(i1,1) - d_x0(i2,1); KK_FLOAT dz0 = d_x0(i1,2) - d_x0(i2,2); minimum_image(dx0,dy0,dz0); - const KK_FLOAT r0 = sqrt(dx0*dx0 + dy0*dy0 + dz0*dz0); + const KK_FLOAT r0 = Kokkos::sqrt(dx0*dx0 + dy0*dy0 + dz0*dz0); const KK_FLOAT delx = x(i1,0) - x(i2,0); const KK_FLOAT dely = x(i1,1) - x(i2,1); const KK_FLOAT delz = x(i1,2) - x(i2,2); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT dr = r - r0; const KK_FLOAT rk = d_k[type] * dr; diff --git a/src/KOKKOS/bond_harmonic_shift_cut_kokkos.cpp b/src/KOKKOS/bond_harmonic_shift_cut_kokkos.cpp index 158842f858f..0bac2ed1f58 100644 --- a/src/KOKKOS/bond_harmonic_shift_cut_kokkos.cpp +++ b/src/KOKKOS/bond_harmonic_shift_cut_kokkos.cpp @@ -151,7 +151,7 @@ void BondHarmonicShiftCutKokkos::operator()(TagBondHarmonicShiftCutC const KK_FLOAT delz = x(i1,2) - x(i2,2); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); // cutoff check if (r > d_r1[type]) return; @@ -162,7 +162,7 @@ void BondHarmonicShiftCutKokkos::operator()(TagBondHarmonicShiftCutC // force & energy KK_FLOAT fbond = 0.0; - if (r > 0.0) fbond = -static_cast(2.0) * rk / r; + if (r > static_cast(0.0)) fbond = -static_cast(2.0) * rk / r; KK_FLOAT ebond = 0.0; if (eflag) { diff --git a/src/KOKKOS/bond_harmonic_shift_kokkos.cpp b/src/KOKKOS/bond_harmonic_shift_kokkos.cpp index f229c8dffa0..73e6bd1ca0f 100644 --- a/src/KOKKOS/bond_harmonic_shift_kokkos.cpp +++ b/src/KOKKOS/bond_harmonic_shift_kokkos.cpp @@ -151,14 +151,14 @@ void BondHarmonicShiftKokkos::operator()(TagBondHarmonicShiftCompute const KK_FLOAT delz = x(i1,2) - x(i2,2); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT dr = r - d_r0[type]; const KK_FLOAT rk = d_k[type] * dr; // force & energy KK_FLOAT fbond = 0.0; - if (r > 0.0) fbond = -static_cast(2.0) * rk / r; + if (r > static_cast(0.0)) fbond = -static_cast(2.0) * rk / r; KK_FLOAT ebond = 0.0; if (eflag) { diff --git a/src/KOKKOS/bond_mm3_kokkos.cpp b/src/KOKKOS/bond_mm3_kokkos.cpp index 0c776a7347b..6760233db34 100644 --- a/src/KOKKOS/bond_mm3_kokkos.cpp +++ b/src/KOKKOS/bond_mm3_kokkos.cpp @@ -157,7 +157,7 @@ void BondMM3Kokkos::operator()(TagBondMM3Compute const KK_FLOAT delz = x(i1,2) - x(i2,2); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT dr = r - d_r0[type]; const KK_FLOAT dr2 = dr*dr; diff --git a/src/KOKKOS/bond_morse_kokkos.cpp b/src/KOKKOS/bond_morse_kokkos.cpp index f921667803d..0033dfa02a7 100644 --- a/src/KOKKOS/bond_morse_kokkos.cpp +++ b/src/KOKKOS/bond_morse_kokkos.cpp @@ -151,14 +151,14 @@ void BondMorseKokkos::operator()(TagBondMorseCompute 0.0) + if (r > static_cast(0.0)) fbond = -static_cast(2.0) * d_d0[type] * d_alpha[type] * (static_cast(1.0) - ralpha) * ralpha / r; diff --git a/src/KOKKOS/bond_nonlinear_kokkos.cpp b/src/KOKKOS/bond_nonlinear_kokkos.cpp index bc5805ffb6c..0c07f910711 100644 --- a/src/KOKKOS/bond_nonlinear_kokkos.cpp +++ b/src/KOKKOS/bond_nonlinear_kokkos.cpp @@ -151,7 +151,7 @@ void BondNonlinearKokkos::operator()(TagBondNonlinearCompute::operator()( const KK_FLOAT delz = x(i1,2) - x(i2,2); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT dr = r - d_r0[type]; const KK_FLOAT dr2 = dr*dr; const KK_FLOAT dr3 = dr2*dr; @@ -173,22 +173,22 @@ void BondQuarticExpKokkos::operator()( static_cast(3.0)*d_k3[type]*dr2 + static_cast(4.0)*d_k4[type]*dr3; - if (r > 0.0) fbond = -de_bond/r; + if (r > static_cast(0.0)) fbond = -de_bond/r; if (eflag) ebond = d_k2[type]*dr2 + d_k3[type]*dr3 + d_k4[type]*dr4; // Exponential force and (optional) energy - if (d_A[type] != 0.0 && d_B[type] != 0.0) { + if (d_A[type] != static_cast(0.0) && d_B[type] != static_cast(0.0)) { const KK_FLOAT a = d_A[type]; const KK_FLOAT b = d_B[type]; - const KK_FLOAT ebond_exp = a * exp(-r/b); + const KK_FLOAT ebond_exp = a * Kokkos::exp(-r/b); if (eflag) ebond += ebond_exp; - if (r > 0.0) fbond += ebond_exp/(b*r); + if (r > static_cast(0.0)) fbond += ebond_exp/(b*r); } // apply force to each of 2 atoms diff --git a/src/KOKKOS/bond_quartic_kokkos.cpp b/src/KOKKOS/bond_quartic_kokkos.cpp index 19ee0b26097..38d12ae402c 100644 --- a/src/KOKKOS/bond_quartic_kokkos.cpp +++ b/src/KOKKOS/bond_quartic_kokkos.cpp @@ -265,7 +265,7 @@ void BondQuarticKokkos::operator()(TagBondQuarticCompute= _hi) { + if (static_cast(_x(i,_dim)) < _lo || static_cast(_x(i,_dim)) >= _hi) { const int mysend = Kokkos::atomic_fetch_add(&_nsend(0),1); if (mysend < (int)_sendlist.extent(0)) _sendlist(mysend) = i; @@ -1437,14 +1437,14 @@ struct BuildBorderListFunctor { const int teamend = (teamstart + chunk) < nlast?(teamstart + chunk):nlast; int mysend = 0; for (int i=teamstart + dev.team_rank(); i= lo && x(i,dim) <= hi) mysend++; + if (static_cast(x(i,dim)) >= lo && static_cast(x(i,dim)) <= hi) mysend++; } const int my_store_pos = dev.team_scan(mysend,&nsend()); if (my_store_pos+mysend < maxsendlist) { mysend = my_store_pos; for (int i=teamstart + dev.team_rank(); i= lo && x(i,dim) <= hi) { + if (static_cast(x(i,dim)) >= lo && static_cast(x(i,dim)) <= hi) { sendlist(iswap,mysend++) = i; } } diff --git a/src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp b/src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp index 4b420c000bb..ebc8f4a1cec 100644 --- a/src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp +++ b/src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp @@ -116,9 +116,9 @@ void ComputeAveSphereAtomKokkos::compute_peratom() mask = atomKK->k_mask.view(); adof = domain->dimension; - mvv2e = force->mvv2e; - mv2d = force->mv2d; - boltz = force->boltz; + mvv2e = static_cast(force->mvv2e); + mv2d = static_cast(force->mv2d); + boltz = static_cast(force->boltz); Kokkos::deep_copy(d_result,0.0); @@ -144,6 +144,8 @@ void ComputeAveSphereAtomKokkos::operator()(TagComputeAveSphereAtom, KK_FLOAT massone_i,massone_j; const int i = d_ilist[ii]; + const KK_FLOAT cutsq_kk = static_cast(cutsq); + const KK_FLOAT volume_kk = static_cast(volume); if (mask[i] & groupbit) { if (rmass.data()) massone_i = rmass[i]; else massone_i = mass[type[i]]; @@ -156,11 +158,11 @@ void ComputeAveSphereAtomKokkos::operator()(TagComputeAveSphereAtom, // i atom contribution int count = 1; - KK_ACC_FLOAT totalmass = massone_i; + KK_ACC_FLOAT totalmass = static_cast(massone_i); KK_ACC_FLOAT p[3]; - p[0] = v(i,0)*massone_i; - p[1] = v(i,1)*massone_i; - p[2] = v(i,2)*massone_i; + p[0] = static_cast(v(i,0)*massone_i); + p[1] = static_cast(v(i,1)*massone_i); + p[2] = static_cast(v(i,2)*massone_i); for (int jj = 0; jj < jnum; jj++) { int j = d_neighbors(i,jj); @@ -172,19 +174,19 @@ void ComputeAveSphereAtomKokkos::operator()(TagComputeAveSphereAtom, const KK_FLOAT dely = x(j,1) - ytmp; const KK_FLOAT delz = x(j,2) - ztmp; const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < cutsq) { + if (rsq < cutsq_kk) { count++; - totalmass += massone_j; - p[0] += v(j,0)*massone_j; - p[1] += v(j,1)*massone_j; - p[2] += v(j,2)*massone_j; + totalmass += static_cast(massone_j); + p[0] += static_cast(v(j,0)*massone_j); + p[1] += static_cast(v(j,1)*massone_j); + p[2] += static_cast(v(j,2)*massone_j); } } KK_FLOAT vcom[3]; - vcom[0] = p[0]/totalmass; - vcom[1] = p[1]/totalmass; - vcom[2] = p[2]/totalmass; + vcom[0] = static_cast(p[0]/totalmass); + vcom[1] = static_cast(p[1]/totalmass); + vcom[2] = static_cast(p[2]/totalmass); // i atom contribution @@ -192,7 +194,7 @@ void ComputeAveSphereAtomKokkos::operator()(TagComputeAveSphereAtom, vnet[0] = v(i,0) - vcom[0]; vnet[1] = v(i,1) - vcom[1]; vnet[2] = v(i,2) - vcom[2]; - KK_ACC_FLOAT ke_sum = massone_i * (vnet[0]*vnet[0] + vnet[1]*vnet[1] + vnet[2]*vnet[2]); + KK_ACC_FLOAT ke_sum = static_cast(massone_i * (vnet[0]*vnet[0] + vnet[1]*vnet[1] + vnet[2]*vnet[2])); for (int jj = 0; jj < jnum; jj++) { int j = d_neighbors(i,jj); @@ -204,15 +206,15 @@ void ComputeAveSphereAtomKokkos::operator()(TagComputeAveSphereAtom, const KK_FLOAT dely = x(j,1) - ytmp; const KK_FLOAT delz = x(j,2) - ztmp; const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < cutsq) { + if (rsq < cutsq_kk) { vnet[0] = v(j,0) - vcom[0]; vnet[1] = v(j,1) - vcom[1]; vnet[2] = v(j,2) - vcom[2]; - ke_sum += massone_j * (vnet[0]*vnet[0] + vnet[1]*vnet[1] + vnet[2]*vnet[2]); + ke_sum += static_cast(massone_j * (vnet[0]*vnet[0] + vnet[1]*vnet[1] + vnet[2]*vnet[2])); } } - KK_FLOAT density = mv2d*totalmass/volume; - KK_FLOAT temp = mvv2e*ke_sum/(adof*count*boltz); + KK_FLOAT density = static_cast(static_cast(mv2d)*totalmass/static_cast(volume_kk)); + KK_FLOAT temp = static_cast(static_cast(mvv2e)*ke_sum/static_cast(adof*count*boltz)); d_result(i,0) = density; d_result(i,1) = temp; } diff --git a/src/KOKKOS/compute_composition_atom_kokkos.cpp b/src/KOKKOS/compute_composition_atom_kokkos.cpp index c23429b6f01..4b9842c1768 100644 --- a/src/KOKKOS/compute_composition_atom_kokkos.cpp +++ b/src/KOKKOS/compute_composition_atom_kokkos.cpp @@ -118,6 +118,7 @@ KOKKOS_INLINE_FUNCTION void ComputeCompositionAtomKokkos::operator()(TagComputeCompositionAtom, const int &ii) const { const int i = d_ilist[ii]; + const KK_FLOAT cutsq_kk = static_cast(cutsq); if (mask[i] & groupbit) { @@ -143,9 +144,9 @@ void ComputeCompositionAtomKokkos::operator()(TagComputeCompositionA const KK_FLOAT dely = x(j,1) - ytmp; const KK_FLOAT delz = x(j,2) - ztmp; const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < cutsq) { + if (rsq < cutsq_kk) { count++; - d_result(i,jtype) += 1.0; + d_result(i,jtype) += static_cast(1.0); } } @@ -155,7 +156,7 @@ void ComputeCompositionAtomKokkos::operator()(TagComputeCompositionA // local comp fractions per atom type - KK_FLOAT lfac = 1.0 / count; + KK_FLOAT lfac = static_cast(1.0) / count; for (int n = 1; n < size_peratom_cols; n++) { d_result(i,n) *= lfac; diff --git a/src/KOKKOS/compute_coord_atom_kokkos.cpp b/src/KOKKOS/compute_coord_atom_kokkos.cpp index 7119f8dec65..843cf2a1f22 100644 --- a/src/KOKKOS/compute_coord_atom_kokkos.cpp +++ b/src/KOKKOS/compute_coord_atom_kokkos.cpp @@ -191,6 +191,8 @@ void ComputeCoordAtomKokkos::operator()(TagComputeCoordAtom(cutsq); + const KK_FLOAT threshold_kk = static_cast(threshold); int n = 0; for (int jj = 0; jj < jnum; jj++) { @@ -205,7 +207,7 @@ void ComputeCoordAtomKokkos::operator()(TagComputeCoordAtom= d_typelo[0] && jtype <= d_typehi[0]) @@ -213,14 +215,14 @@ void ComputeCoordAtomKokkos::operator()(TagComputeCoordAtom= d_typelo[m] && jtype <= d_typehi[m]) - d_carray(i,m) += 1.0; + d_carray(i,m) += static_cast(1.0); } } else if (CSTYLE == ORIENT) { KK_FLOAT dot_product = 0.0; for (int m=0; m < 2*(2*l+1); m++) { dot_product += d_normv(i,nqlist+m)*d_normv(j,nqlist+m); } - if (dot_product > threshold) n++; + if (dot_product > threshold_kk) n++; } } } diff --git a/src/KOKKOS/compute_erotate_asphere_kokkos.cpp b/src/KOKKOS/compute_erotate_asphere_kokkos.cpp index dc89c69a250..6a9df4afb34 100644 --- a/src/KOKKOS/compute_erotate_asphere_kokkos.cpp +++ b/src/KOKKOS/compute_erotate_asphere_kokkos.cpp @@ -95,9 +95,9 @@ double ComputeERotateAsphereKokkos::compute_scalar() // principal moments of inertia - inertia[0] = l_rmass(i) * ( (shape[1]*shape[1] + shape[2]*shape[2])/5.0 ); - inertia[1] = l_rmass(i) * ( (shape[0]*shape[0] + shape[2]*shape[2])/5.0 ); - inertia[2] = l_rmass(i) * ( (shape[0]*shape[0] + shape[1]*shape[1])/5.0 ); + inertia[0] = static_cast(static_cast(l_rmass(i)) * ( (shape[1]*shape[1] + shape[2]*shape[2])/5.0 )); + inertia[1] = static_cast(static_cast(l_rmass(i)) * ( (shape[0]*shape[0] + shape[2]*shape[2])/5.0 )); + inertia[2] = static_cast(static_cast(l_rmass(i)) * ( (shape[0]*shape[0] + shape[1]*shape[1])/5.0 )); // wbody = angular velocity in body frame diff --git a/src/KOKKOS/compute_gaussian_grid_local_kokkos.cpp b/src/KOKKOS/compute_gaussian_grid_local_kokkos.cpp index e2bc1084e7d..564abe1f90b 100644 --- a/src/KOKKOS/compute_gaussian_grid_local_kokkos.cpp +++ b/src/KOKKOS/compute_gaussian_grid_local_kokkos.cpp @@ -266,21 +266,21 @@ void ComputeGaussianGridLocalKokkos::operator() (TagComputeGaussianG d_alocal(igrid, 0) = ix; d_alocal(igrid, 1) = iy; d_alocal(igrid, 2) = iz; - d_alocal(igrid, 3) = xtmp; - d_alocal(igrid, 4) = ytmp; - d_alocal(igrid, 5) = ztmp; + d_alocal(igrid, 3) = static_cast(xtmp); + d_alocal(igrid, 4) = static_cast(ytmp); + d_alocal(igrid, 5) = static_cast(ztmp); // Looping over ntotal for now. for (int j = 0; j < ntotal; j++){ - const double dx = x(j,0) - xtmp; - const double dy = x(j,1) - ytmp; - const double dz = x(j,2) - ztmp; + const double dx = static_cast(x(j,0)) - xtmp; + const double dy = static_cast(x(j,1)) - ytmp; + const double dz = static_cast(x(j,2)) - ztmp; int jtype = type(j); const double rsq = dx*dx + dy*dy + dz*dz; if (rsq < rnd_cutsq(jtype, jtype) ) { int icol = size_local_cols_base + jtype - 1; - d_alocal(igrid, icol) += d_prefacelem(jtype-1) * exp(-rsq * d_argfacelem(jtype-1)); + d_alocal(igrid, icol) += static_cast(d_prefacelem(jtype-1) * exp(-rsq * d_argfacelem(jtype-1))); } } } diff --git a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp index 6d9315ef7cd..0eae0fb3e5b 100644 --- a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp +++ b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp @@ -66,8 +66,8 @@ ComputeOrientOrderAtomKokkos::ComputeOrientOrderAtomKokkos(LAMMPS *l auto h_qnormfac2 = Kokkos::create_mirror_view(d_qnormfac2); for (int il = 0; il < nqlist; il++) { - h_qnormfac[il] = qnormfac[il]; - h_qnormfac2[il] = qnormfac2[il]; + h_qnormfac[il] = static_cast(qnormfac[il]); + h_qnormfac2[il] = static_cast(qnormfac2[il]); } Kokkos::deep_copy(d_qnormfac,h_qnormfac); @@ -245,6 +245,7 @@ void ComputeOrientOrderAtomKokkos::operator() (TagComputeOrientOrder const KK_FLOAT ytmp = x(i,1); const KK_FLOAT ztmp = x(i,2); const int jnum = d_numneigh[i]; + const KK_FLOAT cutsq_kk = static_cast(cutsq); // loop over list of all neighbors within force cutoff // distsq[] = distance sq to each @@ -261,7 +262,7 @@ void ComputeOrientOrderAtomKokkos::operator() (TagComputeOrientOrder const KK_FLOAT dely = x(j,1) - ytmp; const KK_FLOAT delz = x(j,2) - ztmp; const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < cutsq) + if (rsq < cutsq_kk) count++; }); },ncount); @@ -277,7 +278,7 @@ void ComputeOrientOrderAtomKokkos::operator() (TagComputeOrientOrder const KK_FLOAT dely = x(j,1) - ytmp; const KK_FLOAT delz = x(j,2) - ztmp; const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < cutsq) { + if (rsq < cutsq_kk) { if (final) { d_distsq(ii,offset) = rsq; d_rlist(ii,offset,0) = delx; @@ -461,21 +462,21 @@ void ComputeOrientOrderAtomKokkos::calc_boop1(int /*ncount*/, int ii const KK_FLOAT r0 = d_rlist(ii,ineigh,0); const KK_FLOAT r1 = d_rlist(ii,ineigh,1); const KK_FLOAT r2 = d_rlist(ii,ineigh,2); - const KK_FLOAT rmag = sqrt(r0*r0 + r1*r1 + r2*r2); - if (rmag <= MY_EPSILON) { + const KK_FLOAT rmag = Kokkos::sqrt(r0*r0 + r1*r1 + r2*r2); + if (rmag <= static_cast(MY_EPSILON)) { return; } const KK_FLOAT costheta = r2 / rmag; - SNAcomplex expphi = {r0,r1}; - const KK_FLOAT rxymag = sqrt(expphi.re*expphi.re+expphi.im*expphi.im); - if (rxymag <= MY_EPSILON) { + SNAcomplex expphi = {static_cast(r0),static_cast(r1)}; + const KK_FLOAT rxymag = static_cast(sqrt(expphi.re*expphi.re+expphi.im*expphi.im)); + if (rxymag <= static_cast(MY_EPSILON)) { expphi.re = 1.0; expphi.im = 0.0; } else { - const KK_FLOAT rxymaginv = 1.0/rxymag; - expphi.re *= rxymaginv; - expphi.im *= rxymaginv; + const KK_FLOAT rxymaginv = static_cast(1.0)/rxymag; + expphi.re *= static_cast(rxymaginv); + expphi.im *= static_cast(rxymaginv); } for (int il = 0; il < nqlist; il++) { @@ -487,11 +488,11 @@ void ComputeOrientOrderAtomKokkos::calc_boop1(int /*ncount*/, int ii //d_qnm(ii,il,l).re += polar_prefactor(l, 0, costheta); const KK_FLOAT polar_pf = polar_prefactor(l, 0, costheta); - Kokkos::atomic_add(&(d_qnm(ii,il,0).re), polar_pf); + Kokkos::atomic_add(&(d_qnm(ii,il,0).re), static_cast(polar_pf)); SNAcomplex expphim = {expphi.re,expphi.im}; for (int m = 1; m <= +l; m++) { const KK_FLOAT prefactor = polar_prefactor(l, m, costheta); - SNAcomplex ylm = {prefactor * expphim.re, prefactor * expphim.im}; + SNAcomplex ylm = {static_cast(prefactor) * expphim.re, static_cast(prefactor) * expphim.im}; Kokkos::atomic_add(&(d_qnm(ii,il,m).re), ylm.re); Kokkos::atomic_add(&(d_qnm(ii,il,m).im), ylm.im); // Skip calculation of qnm for m<0 due to symmetry @@ -517,12 +518,12 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co // convert sums to averages - KK_FLOAT facn = 1.0 / ncount; + KK_FLOAT facn = static_cast(1.0) / ncount; for (int il = 0; il < nqlist; il++) { int l = d_qlist[il]; for (int m = 0; m < l+1; m++) { - d_qnm(ii,il,m).re *= facn; - d_qnm(ii,il,m).im *= facn; + d_qnm(ii,il,m).re *= static_cast(facn); + d_qnm(ii,il,m).im *= static_cast(facn); } } @@ -532,10 +533,10 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co int jj = 0; for (int il = 0; il < nqlist; il++) { int l = d_qlist[il]; - KK_ACC_FLOAT qm_sum = d_qnm(ii,il,0).re*d_qnm(ii,il,0).re; + KK_ACC_FLOAT qm_sum = static_cast(d_qnm(ii,il,0).re*d_qnm(ii,il,0).re); for (int m = 1; m < l+1; m++) - qm_sum += 2.0*(d_qnm(ii,il,m).re*d_qnm(ii,il,m).re + d_qnm(ii,il,m).im*d_qnm(ii,il,m).im); - d_qnarray(i,jj++) = d_qnormfac(il) * sqrt(qm_sum); + qm_sum += static_cast(2.0*(d_qnm(ii,il,m).re*d_qnm(ii,il,m).re + d_qnm(ii,il,m).im*d_qnm(ii,il,m).im)); + d_qnarray(i,jj++) = static_cast(static_cast(d_qnormfac(il)) * Kokkos::sqrt(qm_sum)); } // calculate W_l @@ -561,13 +562,13 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co SNAcomplex Q1Q2; Q1Q2.re = (d_qnm(ii,il,-m1).re*d_qnm(ii,il,m2).re + d_qnm(ii,il,-m1).im*d_qnm(ii,il,m2).im)*sgn; Q1Q2.im = (d_qnm(ii,il,-m1).re*d_qnm(ii,il,m2).im - d_qnm(ii,il,-m1).im*d_qnm(ii,il,m2).re)*sgn; - const KK_FLOAT Q1Q2Q3 = Q1Q2.re*d_qnm(ii,il,m3).re - Q1Q2.im*d_qnm(ii,il,m3).im; + const KK_FLOAT Q1Q2Q3 = static_cast(Q1Q2.re*d_qnm(ii,il,m3).re - Q1Q2.im*d_qnm(ii,il,m3).im); const KK_FLOAT c = d_w3jlist[widx_count++]; - wlsum += Q1Q2Q3*c; + wlsum += static_cast(Q1Q2Q3*c); } } - d_qnarray(i,jj++) = wlsum/d_qnormfac2(il); + d_qnarray(i,jj++) = static_cast(wlsum/static_cast(d_qnormfac2(il))); nterms++; } } @@ -578,7 +579,7 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co const int jptr = jj-nterms; if (!wlflag) jj = jptr; for (int il = 0; il < nqlist; il++) { - if (d_qnarray(i,il) < QEPSILON) + if (d_qnarray(i,il) < static_cast(QEPSILON)) d_qnarray(i,jj++) = 0.0; else { const KK_FLOAT qnfac = d_qnormfac(il)/d_qnarray(i,il); @@ -592,7 +593,7 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co if (qlcompflag) { const int il = iqlcomp; const int l = qlcomp; - if (d_qnarray(i,il) < QEPSILON) + if (d_qnarray(i,il) < static_cast(QEPSILON)) for (int m = 0; m < 2*l+1; m++) { d_qnarray(i,jj++) = 0.0; d_qnarray(i,jj++) = 0.0; @@ -603,12 +604,12 @@ void ComputeOrientOrderAtomKokkos::calc_boop2(int ncount, int ii) co // Computed only qnm for m>=0. // qnm[-m] = (-1)^m * conjg(qnm[m]) const int sgn = 1 - 2*(m&1); // sgn = (-1)^m - d_qnarray(i,jj++) = d_qnm(ii,il,-m).re * qnfac * sgn; - d_qnarray(i,jj++) = -d_qnm(ii,il,-m).im * qnfac * sgn; + d_qnarray(i,jj++) = static_cast(d_qnm(ii,il,-m).re) * qnfac * sgn; + d_qnarray(i,jj++) = -static_cast(d_qnm(ii,il,-m).im) * qnfac * sgn; } for (int m = 0; m < l+1; m++) { - d_qnarray(i,jj++) = d_qnm(ii,il,m).re * qnfac; - d_qnarray(i,jj++) = d_qnm(ii,il,m).im * qnfac; + d_qnarray(i,jj++) = static_cast(d_qnm(ii,il,m).re) * qnfac; + d_qnarray(i,jj++) = static_cast(d_qnm(ii,il,m).im) * qnfac; } } } @@ -631,7 +632,7 @@ KK_FLOAT ComputeOrientOrderAtomKokkos::polar_prefactor(int l, int m, for (int i=l-mabs+1; i < l+mabs+1; ++i) prefactor *= static_cast(i); - prefactor = sqrt(static_cast(2*l+1)/(MY_4PI*prefactor)) + prefactor = Kokkos::sqrt(static_cast(2*l+1)/(static_cast(MY_4PI)*prefactor)) * associated_legendre(l,mabs,costheta); if ((m < 0) && (m % 2)) prefactor = -prefactor; @@ -654,7 +655,7 @@ KK_FLOAT ComputeOrientOrderAtomKokkos::associated_legendre(int l, in KK_FLOAT p(1.0), pm1(0.0), pm2(0.0); if (m != 0) { - const KK_FLOAT msqx = -sqrt(1.0-x*x); + const KK_FLOAT msqx = -Kokkos::sqrt(static_cast(1.0)-x*x); for (int i=1; i < m+1; ++i) p *= static_cast(2*i-1) * msqx; } @@ -682,7 +683,7 @@ void ComputeOrientOrderAtomKokkos::init_wigner3j() auto h_w3jlist = Kokkos::create_mirror_view(d_w3jlist); for (int i = 0; i< widx_max; i++) - h_w3jlist(i) = w3jlist[i]; + h_w3jlist(i) = static_cast(w3jlist[i]); Kokkos::deep_copy(d_w3jlist,h_w3jlist); } diff --git a/src/KOKKOS/compute_temp_com_kokkos.cpp b/src/KOKKOS/compute_temp_com_kokkos.cpp index 59c10507391..b4321e936bb 100644 --- a/src/KOKKOS/compute_temp_com_kokkos.cpp +++ b/src/KOKKOS/compute_temp_com_kokkos.cpp @@ -93,16 +93,17 @@ KOKKOS_INLINE_FUNCTION void ComputeTempCOMKokkos::operator()(TagComputeTempCOMScalar, const int &i, CTEMP& t_kk) const { KK_FLOAT vthermal[3]; + const KK_FLOAT vbias_kk[3] = {static_cast(vbias[0]), static_cast(vbias[1]), static_cast(vbias[2])}; - vthermal[0] = v(i,0) - vbias[0]; - vthermal[1] = v(i,1) - vbias[1]; - vthermal[2] = v(i,2) - vbias[2]; + vthermal[0] = v(i,0) - vbias_kk[0]; + vthermal[1] = v(i,1) - vbias_kk[1]; + vthermal[2] = v(i,2) - vbias_kk[2]; if (RMASS) { if (mask[i] & groupbit) - t_kk.t0 += (vthermal[0]*vthermal[0] + vthermal[1]*vthermal[1] + vthermal[2]*vthermal[2]) * rmass[i]; + t_kk.t0 += static_cast((vthermal[0]*vthermal[0] + vthermal[1]*vthermal[1] + vthermal[2]*vthermal[2]) * rmass[i]); } else { if (mask[i] & groupbit) - t_kk.t0 += (vthermal[0]*vthermal[0] + vthermal[1]*vthermal[1] + vthermal[2]*vthermal[2]) * mass[type[i]]; + t_kk.t0 += static_cast((vthermal[0]*vthermal[0] + vthermal[1]*vthermal[1] + vthermal[2]*vthermal[2]) * mass[type[i]]); } } @@ -159,21 +160,22 @@ KOKKOS_INLINE_FUNCTION void ComputeTempCOMKokkos::operator()(TagComputeTempCOMVector, const int &i, CTEMP& t_kk) const { KK_FLOAT vthermal[3]; + const KK_FLOAT vbias_kk[3] = {static_cast(vbias[0]), static_cast(vbias[1]), static_cast(vbias[2])}; - vthermal[0] = v(i,0) - vbias[0]; - vthermal[1] = v(i,1) - vbias[1]; - vthermal[2] = v(i,2) - vbias[2]; + vthermal[0] = v(i,0) - vbias_kk[0]; + vthermal[1] = v(i,1) - vbias_kk[1]; + vthermal[2] = v(i,2) - vbias_kk[2]; if (mask[i] & groupbit) { KK_FLOAT massone = 0.0; if (RMASS) massone = rmass[i]; else massone = mass[type[i]]; - t_kk.t0 += massone * vthermal[0]*vthermal[0]; - t_kk.t1 += massone * vthermal[1]*vthermal[1]; - t_kk.t2 += massone * vthermal[2]*vthermal[2]; - t_kk.t3 += massone * vthermal[0]*vthermal[1]; - t_kk.t4 += massone * vthermal[0]*vthermal[2]; - t_kk.t5 += massone * vthermal[1]*vthermal[2]; + t_kk.t0 += static_cast(massone * vthermal[0]*vthermal[0]); + t_kk.t1 += static_cast(massone * vthermal[1]*vthermal[1]); + t_kk.t2 += static_cast(massone * vthermal[2]*vthermal[2]); + t_kk.t3 += static_cast(massone * vthermal[0]*vthermal[1]); + t_kk.t4 += static_cast(massone * vthermal[0]*vthermal[2]); + t_kk.t5 += static_cast(massone * vthermal[1]*vthermal[2]); } } @@ -208,9 +210,10 @@ template KOKKOS_INLINE_FUNCTION void ComputeTempCOMKokkos::operator()(TagComputeTempCOMRemoveBias, const int &i) const { if (mask[i] & groupbit) { - v(i,0) -= vbias[0]; - v(i,1) -= vbias[1]; - v(i,2) -= vbias[2]; + const KK_FLOAT vbias_kk[3] = {static_cast(vbias[0]), static_cast(vbias[1]), static_cast(vbias[2])}; + v(i,0) -= vbias_kk[0]; + v(i,1) -= vbias_kk[1]; + v(i,2) -= vbias_kk[2]; } } @@ -236,9 +239,10 @@ template KOKKOS_INLINE_FUNCTION void ComputeTempCOMKokkos::operator()(TagComputeTempCOMRestoreBias, const int &i) const { if (mask[i] & groupbit) { - v(i,0) += vbias[0]; - v(i,1) += vbias[1]; - v(i,2) += vbias[2]; + const KK_FLOAT vbias_kk[3] = {static_cast(vbias[0]), static_cast(vbias[1]), static_cast(vbias[2])}; + v(i,0) += vbias_kk[0]; + v(i,1) += vbias_kk[1]; + v(i,2) += vbias_kk[2]; } } diff --git a/src/KOKKOS/compute_temp_deform_kokkos.cpp b/src/KOKKOS/compute_temp_deform_kokkos.cpp index fb4a113a4c2..21da072d692 100644 --- a/src/KOKKOS/compute_temp_deform_kokkos.cpp +++ b/src/KOKKOS/compute_temp_deform_kokkos.cpp @@ -202,9 +202,9 @@ template KOKKOS_INLINE_FUNCTION void ComputeTempDeformKokkos::operator()(TagComputeTempDeformRemoveBias, const int &i) const { if (mask[i] & groupbit) { - vbiasall(i,0) = h_rate[0]*x(i,0) + h_rate[5]*x(i,1) + h_rate[4]*x(i,2) + h_ratelo[0]; - vbiasall(i,1) = h_rate[1]*x(i,1) + h_rate[3]*x(i,2) + h_ratelo[1]; - vbiasall(i,2) = h_rate[2]*x(i,2) + h_ratelo[2]; + vbiasall(i,0) = static_cast(h_rate[0]*static_cast(x(i,0)) + h_rate[5]*static_cast(x(i,1)) + h_rate[4]*static_cast(x(i,2)) + h_ratelo[0]); + vbiasall(i,1) = static_cast(h_rate[1]*static_cast(x(i,1)) + h_rate[3]*static_cast(x(i,2)) + h_ratelo[1]); + vbiasall(i,2) = static_cast(h_rate[2]*static_cast(x(i,2)) + h_ratelo[2]); v(i,0) -= vbiasall(i,0); v(i,1) -= vbiasall(i,1); v(i,2) -= vbiasall(i,2); @@ -294,9 +294,9 @@ template KOKKOS_INLINE_FUNCTION void ComputeTempDeformKokkos::operator()(TagComputeTempDeformApplyBias, const int &i) const { if (mask[i] & groupbit) { - v(i,0) += (x(i,0) - d_xref[0]) * d_grad_u[0] + (x(i,1) - d_xref[3]) * d_grad_u[5] + (x(i,2) - d_xref[4]) * d_grad_u[4]; - v(i,1) += (x(i,1) - d_xref[1]) * d_grad_u[1] + (x(i,2) - d_xref[4]) * d_grad_u[3]; - v(i,2) += (x(i,2) - d_xref[2]) * d_grad_u[2]; + v(i,0) += static_cast((static_cast(x(i,0)) - d_xref[0]) * d_grad_u[0] + (static_cast(x(i,1)) - d_xref[3]) * d_grad_u[5] + (static_cast(x(i,2)) - d_xref[4]) * d_grad_u[4]); + v(i,1) += static_cast((static_cast(x(i,1)) - d_xref[1]) * d_grad_u[1] + (static_cast(x(i,2)) - d_xref[4]) * d_grad_u[3]); + v(i,2) += static_cast((static_cast(x(i,2)) - d_xref[2]) * d_grad_u[2]); } } diff --git a/src/KOKKOS/compute_temp_kokkos.cpp b/src/KOKKOS/compute_temp_kokkos.cpp index f2e59027b5c..8d69ce94939 100644 --- a/src/KOKKOS/compute_temp_kokkos.cpp +++ b/src/KOKKOS/compute_temp_kokkos.cpp @@ -84,11 +84,11 @@ KOKKOS_INLINE_FUNCTION void ComputeTempKokkos::operator()(TagComputeTempScalar, const int &i, CTEMP& t_kk) const { if (RMASS) { if (mask[i] & groupbit) - t_kk.t0 += (v(i,0)*v(i,0) + v(i,1)*v(i,1) + v(i,2)*v(i,2)) * rmass[i]; + t_kk.t0 += static_cast((v(i,0)*v(i,0) + v(i,1)*v(i,1) + v(i,2)*v(i,2)) * rmass[i]); } else { if (mask[i] & groupbit) - t_kk.t0 += (v(i,0)*v(i,0) + v(i,1)*v(i,1) + v(i,2)*v(i,2)) * - mass[type[i]]; + t_kk.t0 += static_cast((v(i,0)*v(i,0) + v(i,1)*v(i,1) + v(i,2)*v(i,2)) * + mass[type[i]]); } } @@ -144,12 +144,12 @@ void ComputeTempKokkos::operator()(TagComputeTempVector, cons KK_FLOAT massone = 0.0; if (RMASS) massone = rmass[i]; else massone = mass[type[i]]; - t_kk.t0 += massone * v(i,0)*v(i,0); - t_kk.t1 += massone * v(i,1)*v(i,1); - t_kk.t2 += massone * v(i,2)*v(i,2); - t_kk.t3 += massone * v(i,0)*v(i,1); - t_kk.t4 += massone * v(i,0)*v(i,2); - t_kk.t5 += massone * v(i,1)*v(i,2); + t_kk.t0 += static_cast(massone * v(i,0)*v(i,0)); + t_kk.t1 += static_cast(massone * v(i,1)*v(i,1)); + t_kk.t2 += static_cast(massone * v(i,2)*v(i,2)); + t_kk.t3 += static_cast(massone * v(i,0)*v(i,1)); + t_kk.t4 += static_cast(massone * v(i,0)*v(i,2)); + t_kk.t5 += static_cast(massone * v(i,1)*v(i,2)); } } diff --git a/src/KOKKOS/compute_temp_sphere_kokkos.cpp b/src/KOKKOS/compute_temp_sphere_kokkos.cpp index 2bdd3cb62cd..0e89d19eb0e 100644 --- a/src/KOKKOS/compute_temp_sphere_kokkos.cpp +++ b/src/KOKKOS/compute_temp_sphere_kokkos.cpp @@ -96,13 +96,13 @@ void ComputeTempSphereKokkos::operator()(TagComputeTempSphereScalar< const int &i, CTEMP &t_kk) const { if (mask[i] & groupbit) { - const KK_FLOAT inertiaone = INERTIA * rmass_kk[i] * radius_kk[i] * radius_kk[i]; + const KK_FLOAT inertiaone = static_cast(INERTIA) * rmass_kk[i] * radius_kk[i] * radius_kk[i]; if (MODE) { // ALL: translational + rotational - t_kk.t0 += (v(i, 0) * v(i, 0) + v(i, 1) * v(i, 1) + v(i, 2) * v(i, 2)) * rmass_kk[i]; + t_kk.t0 += static_cast((v(i, 0) * v(i, 0) + v(i, 1) * v(i, 1) + v(i, 2) * v(i, 2)) * rmass_kk[i]); } - t_kk.t0 += (omega_kk(i, 0) * omega_kk(i, 0) + omega_kk(i, 1) * omega_kk(i, 1) + + t_kk.t0 += static_cast((omega_kk(i, 0) * omega_kk(i, 0) + omega_kk(i, 1) * omega_kk(i, 1) + omega_kk(i, 2) * omega_kk(i, 2)) * - inertiaone; + inertiaone); } } @@ -165,21 +165,21 @@ void ComputeTempSphereKokkos::operator()(TagComputeTempSphereVector< { if (mask[i] & groupbit) { const KK_FLOAT massone = rmass_kk[i]; - const KK_FLOAT inertiaone = INERTIA * massone * radius_kk[i] * radius_kk[i]; + const KK_FLOAT inertiaone = static_cast(INERTIA) * massone * radius_kk[i] * radius_kk[i]; if (MODE) { // ALL: translational + rotational - t_kk.t0 += massone * v(i, 0) * v(i, 0); - t_kk.t1 += massone * v(i, 1) * v(i, 1); - t_kk.t2 += massone * v(i, 2) * v(i, 2); - t_kk.t3 += massone * v(i, 0) * v(i, 1); - t_kk.t4 += massone * v(i, 0) * v(i, 2); - t_kk.t5 += massone * v(i, 1) * v(i, 2); + t_kk.t0 += static_cast(massone * v(i, 0) * v(i, 0)); + t_kk.t1 += static_cast(massone * v(i, 1) * v(i, 1)); + t_kk.t2 += static_cast(massone * v(i, 2) * v(i, 2)); + t_kk.t3 += static_cast(massone * v(i, 0) * v(i, 1)); + t_kk.t4 += static_cast(massone * v(i, 0) * v(i, 2)); + t_kk.t5 += static_cast(massone * v(i, 1) * v(i, 2)); } - t_kk.t0 += inertiaone * omega_kk(i, 0) * omega_kk(i, 0); - t_kk.t1 += inertiaone * omega_kk(i, 1) * omega_kk(i, 1); - t_kk.t2 += inertiaone * omega_kk(i, 2) * omega_kk(i, 2); - t_kk.t3 += inertiaone * omega_kk(i, 0) * omega_kk(i, 1); - t_kk.t4 += inertiaone * omega_kk(i, 0) * omega_kk(i, 2); - t_kk.t5 += inertiaone * omega_kk(i, 1) * omega_kk(i, 2); + t_kk.t0 += static_cast(inertiaone * omega_kk(i, 0) * omega_kk(i, 0)); + t_kk.t1 += static_cast(inertiaone * omega_kk(i, 1) * omega_kk(i, 1)); + t_kk.t2 += static_cast(inertiaone * omega_kk(i, 2) * omega_kk(i, 2)); + t_kk.t3 += static_cast(inertiaone * omega_kk(i, 0) * omega_kk(i, 1)); + t_kk.t4 += static_cast(inertiaone * omega_kk(i, 0) * omega_kk(i, 2)); + t_kk.t5 += static_cast(inertiaone * omega_kk(i, 1) * omega_kk(i, 2)); } } diff --git a/src/KOKKOS/dihedral_charmm_kokkos.cpp b/src/KOKKOS/dihedral_charmm_kokkos.cpp index cfa918f1669..acfcda152e6 100644 --- a/src/KOKKOS/dihedral_charmm_kokkos.cpp +++ b/src/KOKKOS/dihedral_charmm_kokkos.cpp @@ -249,14 +249,14 @@ void DihedralCharmmKokkos::operator()(TagDihedralCharmmCompute 0) rginv = static_cast(1.0)/rg; if (rasq > 0) ra2inv = static_cast(1.0)/rasq; if (rbsq > 0) rb2inv = static_cast(1.0)/rbsq; - const KK_FLOAT rabinv = sqrt(ra2inv*rb2inv); + const KK_FLOAT rabinv = Kokkos::sqrt(ra2inv*rb2inv); KK_FLOAT c = (ax*bx + ay*by + az*bz)*rabinv; KK_FLOAT s = rg*rabinv*(ax*vb3x + ay*vb3y + az*vb3z); @@ -379,7 +379,7 @@ void DihedralCharmmKokkos::operator()(TagDihedralCharmmCompute::compute(int eflag_in, int vflag_in) int ndihedrallist = neighborKK->ndihedrallist; nlocal = atom->nlocal; newton_bond = force->newton_bond; - qqrd2e = force->qqrd2e; + qqrd2e = static_cast(force->qqrd2e); h_warning_flag() = 0; k_warning_flag.modify_host(); @@ -154,24 +154,24 @@ void DihedralCharmmfswKokkos::compute(int eflag_in, int vflag_in) error->warning(FLERR,"Dihedral problem"); if (eflag_global) { - energy += evm.emol; - force->pair->eng_vdwl += evm.evdwl; - force->pair->eng_coul += evm.ecoul; + energy += static_cast(evm.emol); + force->pair->eng_vdwl += static_cast(evm.evdwl); + force->pair->eng_coul += static_cast(evm.ecoul); } if (vflag_global) { - virial[0] += evm.v[0]; - virial[1] += evm.v[1]; - virial[2] += evm.v[2]; - virial[3] += evm.v[3]; - virial[4] += evm.v[4]; - virial[5] += evm.v[5]; - - force->pair->virial[0] += evm.vp[0]; - force->pair->virial[1] += evm.vp[1]; - force->pair->virial[2] += evm.vp[2]; - force->pair->virial[3] += evm.vp[3]; - force->pair->virial[4] += evm.vp[4]; - force->pair->virial[5] += evm.vp[5]; + virial[0] += static_cast(evm.v[0]); + virial[1] += static_cast(evm.v[1]); + virial[2] += static_cast(evm.v[2]); + virial[3] += static_cast(evm.v[3]); + virial[4] += static_cast(evm.v[4]); + virial[5] += static_cast(evm.v[5]); + + force->pair->virial[0] += static_cast(evm.vp[0]); + force->pair->virial[1] += static_cast(evm.vp[1]); + force->pair->virial[2] += static_cast(evm.vp[2]); + force->pair->virial[3] += static_cast(evm.vp[3]); + force->pair->virial[4] += static_cast(evm.vp[4]); + force->pair->virial[5] += static_cast(evm.vp[5]); } // don't yet have dualviews for eatom and vatom in pair_kokkos, @@ -256,25 +256,25 @@ void DihedralCharmmfswKokkos::operator()(TagDihedralCharmmfswCompute const KK_FLOAT rasq = ax*ax + ay*ay + az*az; const KK_FLOAT rbsq = bx*bx + by*by + bz*bz; const KK_FLOAT rgsq = vb2xm*vb2xm + vb2ym*vb2ym + vb2zm*vb2zm; - const KK_FLOAT rg = sqrt(rgsq); + const KK_FLOAT rg = Kokkos::sqrt(rgsq); KK_FLOAT rginv,ra2inv,rb2inv; rginv = ra2inv = rb2inv = 0.0; - if (rg > 0) rginv = 1.0/rg; - if (rasq > 0) ra2inv = 1.0/rasq; - if (rbsq > 0) rb2inv = 1.0/rbsq; - const KK_FLOAT rabinv = sqrt(ra2inv*rb2inv); + if (rg > 0) rginv = static_cast(1.0)/rg; + if (rasq > 0) ra2inv = static_cast(1.0)/rasq; + if (rbsq > 0) rb2inv = static_cast(1.0)/rbsq; + const KK_FLOAT rabinv = Kokkos::sqrt(ra2inv*rb2inv); KK_FLOAT c = (ax*bx + ay*by + az*bz)*rabinv; KK_FLOAT s = rg*rabinv*(ax*vb3x + ay*vb3y + az*vb3z); // error check - if ((c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0 + TOLERANCE) || c < static_cast(-1.0 - TOLERANCE)) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; const int m = d_multiplicity[type]; KK_FLOAT p = 1.0; @@ -290,10 +290,10 @@ void DihedralCharmmfswKokkos::operator()(TagDihedralCharmmfswCompute p = p*d_cos_shift[type] + df1*d_sin_shift[type]; df1 = df1*d_cos_shift[type] - ddf1*d_sin_shift[type]; df1 *= -m; - p += 1.0; + p += static_cast(1.0); if (m == 0) { - p = 1.0 + d_cos_shift[type]; + p = static_cast(1.0) + d_cos_shift[type]; df1 = 0.0; } @@ -343,27 +343,27 @@ void DihedralCharmmfswKokkos::operator()(TagDihedralCharmmfswCompute // apply force to each of 4 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -373,22 +373,28 @@ void DihedralCharmmfswKokkos::operator()(TagDihedralCharmmfswCompute // 1-4 LJ and Coulomb interactions // tally energy/virial in pair, using newton_bond as newton flag - if (d_weight[type] > 0.0) { + if (d_weight[type] > static_cast(0.0)) { const int itype = atomtype[i1]; const int jtype = atomtype[i4]; + const KK_FLOAT cut_coulinv14_kk = static_cast(cut_coulinv14); + const KK_FLOAT cut_lj_inner6inv_kk = static_cast(cut_lj_inner6inv); + const KK_FLOAT cut_lj6inv_kk = static_cast(cut_lj6inv); + const KK_FLOAT cut_lj_inner3inv_kk = static_cast(cut_lj_inner3inv); + const KK_FLOAT cut_lj3inv_kk = static_cast(cut_lj3inv); + const KK_FLOAT delx = x(i1,0) - x(i4,0); const KK_FLOAT dely = x(i1,1) - x(i4,1); const KK_FLOAT delz = x(i1,2) - x(i4,2); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcecoul; if (implicit) forcecoul = qqrd2e * q[i1]*q[i4]*r2inv; - else if (dihedflag) forcecoul = qqrd2e * q[i1]*q[i4]*sqrt(r2inv); - else forcecoul = qqrd2e * q[i1]*q[i4]*(sqrt(r2inv) - r*cut_coulinv14*cut_coulinv14); + else if (dihedflag) forcecoul = qqrd2e * q[i1]*q[i4]*Kokkos::sqrt(r2inv); + else forcecoul = qqrd2e * q[i1]*q[i4]*(Kokkos::sqrt(r2inv) - r*cut_coulinv14_kk*cut_coulinv14_kk); const KK_FLOAT forcelj = r6inv * (d_lj14_1(itype,jtype)*r6inv - d_lj14_2(itype,jtype)); const KK_FLOAT fpair = d_weight[type] * (forcelj+forcecoul)*r2inv; @@ -400,24 +406,24 @@ void DihedralCharmmfswKokkos::operator()(TagDihedralCharmmfswCompute ecoul = d_weight[type] * forcecoul; else ecoul = d_weight[type] * qqrd2e * q[i1] * q[i4] * - (sqrt(r2inv) + r * cut_coulinv14 * cut_coulinv14 - 2.0 * cut_coulinv14); + (Kokkos::sqrt(r2inv) + r * cut_coulinv14_kk * cut_coulinv14_kk - static_cast(2.0) * cut_coulinv14_kk); evdwl14_12 = r6inv * d_lj14_3(itype,jtype) * r6inv - - d_lj14_3(itype,jtype) * cut_lj_inner6inv * cut_lj6inv; + d_lj14_3(itype,jtype) * cut_lj_inner6inv_kk * cut_lj6inv_kk; evdwl14_6 = - -d_lj14_4(itype,jtype) * r6inv + d_lj14_4(itype,jtype) * cut_lj_inner3inv * cut_lj3inv; + -d_lj14_4(itype,jtype) * r6inv + d_lj14_4(itype,jtype) * cut_lj_inner3inv_kk * cut_lj3inv_kk; evdwl = evdwl14_12 + evdwl14_6; evdwl *= d_weight[type]; } if (newton_bond || i1 < nlocal) { - a_f(i1,0) += delx*fpair; - a_f(i1,1) += dely*fpair; - a_f(i1,2) += delz*fpair; + a_f(i1,0) += static_cast(delx*fpair); + a_f(i1,1) += static_cast(dely*fpair); + a_f(i1,2) += static_cast(delz*fpair); } if (newton_bond || i4 < nlocal) { - a_f(i4,0) -= delx*fpair; - a_f(i4,1) -= dely*fpair; - a_f(i4,2) -= delz*fpair; + a_f(i4,0) -= static_cast(delx*fpair); + a_f(i4,1) -= static_cast(dely*fpair); + a_f(i4,2) -= static_cast(delz*fpair); } if (EVFLAG) ev_tally(evm,i1,i4,evdwl,ecoul,fpair,delx,dely,delz); @@ -471,12 +477,12 @@ void DihedralCharmmfswKokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k.view_host()[i] = k[i]; + k_k.view_host()[i] = static_cast(k[i]); k_multiplicity.view_host()[i] = multiplicity[i]; k_shift.view_host()[i] = shift[i]; - k_cos_shift.view_host()[i] = cos_shift[i]; - k_sin_shift.view_host()[i] = sin_shift[i]; - k_weight.view_host()[i] = weight[i]; + k_cos_shift.view_host()[i] = static_cast(cos_shift[i]); + k_sin_shift.view_host()[i] = static_cast(sin_shift[i]); + k_weight.view_host()[i] = static_cast(weight[i]); } k_k.modify_host(); @@ -519,10 +525,10 @@ void DihedralCharmmfswKokkos::init_style() int n = atom->ntypes; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { - k_lj14_1.view_host()(i,j) = lj14_1[i][j]; - k_lj14_2.view_host()(i,j) = lj14_2[i][j]; - k_lj14_3.view_host()(i,j) = lj14_3[i][j]; - k_lj14_4.view_host()(i,j) = lj14_4[i][j]; + k_lj14_1.view_host()(i,j) = static_cast(lj14_1[i][j]); + k_lj14_2.view_host()(i,j) = static_cast(lj14_2[i][j]); + k_lj14_3.view_host()(i,j) = static_cast(lj14_3[i][j]); + k_lj14_4.view_host()(i,j) = static_cast(lj14_4[i][j]); } } } @@ -564,12 +570,12 @@ void DihedralCharmmfswKokkos::read_restart(FILE *fp) int n = atom->ndihedraltypes; for (int i = 1; i <= n; i++) { - k_k.view_host()[i] = k[i]; + k_k.view_host()[i] = static_cast(k[i]); k_multiplicity.view_host()[i] = multiplicity[i]; k_shift.view_host()[i] = shift[i]; - k_cos_shift.view_host()[i] = cos_shift[i]; - k_sin_shift.view_host()[i] = sin_shift[i]; - k_weight.view_host()[i] = weight[i]; + k_cos_shift.view_host()[i] = static_cast(cos_shift[i]); + k_sin_shift.view_host()[i] = static_cast(sin_shift[i]); + k_weight.view_host()[i] = static_cast(weight[i]); } k_k.modify_host(); @@ -609,21 +615,21 @@ void DihedralCharmmfswKokkos::ev_tally(EVM_FLOAT &evm, const int i1, if (eflag_either) { if (eflag_global) { - if (newton_bond) evm.emol += edihedral; + if (newton_bond) evm.emol += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) evm.emol += edihedralquarter; - if (i2 < nlocal) evm.emol += edihedralquarter; - if (i3 < nlocal) evm.emol += edihedralquarter; - if (i4 < nlocal) evm.emol += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) evm.emol += static_cast(edihedralquarter); + if (i2 < nlocal) evm.emol += static_cast(edihedralquarter); + if (i3 < nlocal) evm.emol += static_cast(edihedralquarter); + if (i4 < nlocal) evm.emol += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) d_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) d_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) d_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) d_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) d_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) d_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) d_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) d_eatom[i4] += static_cast(edihedralquarter); } } @@ -637,80 +643,80 @@ void DihedralCharmmfswKokkos::ev_tally(EVM_FLOAT &evm, const int i1, if (vflag_global) { if (newton_bond) { - evm.v[0] += v[0]; - evm.v[1] += v[1]; - evm.v[2] += v[2]; - evm.v[3] += v[3]; - evm.v[4] += v[4]; - evm.v[5] += v[5]; + evm.v[0] += static_cast(v[0]); + evm.v[1] += static_cast(v[1]); + evm.v[2] += static_cast(v[2]); + evm.v[3] += static_cast(v[3]); + evm.v[4] += static_cast(v[4]); + evm.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - evm.v[0] += 0.25*v[0]; - evm.v[1] += 0.25*v[1]; - evm.v[2] += 0.25*v[2]; - evm.v[3] += 0.25*v[3]; - evm.v[4] += 0.25*v[4]; - evm.v[5] += 0.25*v[5]; + evm.v[0] += static_cast(static_cast(0.25)*v[0]); + evm.v[1] += static_cast(static_cast(0.25)*v[1]); + evm.v[2] += static_cast(static_cast(0.25)*v[2]); + evm.v[3] += static_cast(static_cast(0.25)*v[3]); + evm.v[4] += static_cast(static_cast(0.25)*v[4]); + evm.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i2 < nlocal) { - evm.v[0] += 0.25*v[0]; - evm.v[1] += 0.25*v[1]; - evm.v[2] += 0.25*v[2]; - evm.v[3] += 0.25*v[3]; - evm.v[4] += 0.25*v[4]; - evm.v[5] += 0.25*v[5]; + evm.v[0] += static_cast(static_cast(0.25)*v[0]); + evm.v[1] += static_cast(static_cast(0.25)*v[1]); + evm.v[2] += static_cast(static_cast(0.25)*v[2]); + evm.v[3] += static_cast(static_cast(0.25)*v[3]); + evm.v[4] += static_cast(static_cast(0.25)*v[4]); + evm.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i3 < nlocal) { - evm.v[0] += 0.25*v[0]; - evm.v[1] += 0.25*v[1]; - evm.v[2] += 0.25*v[2]; - evm.v[3] += 0.25*v[3]; - evm.v[4] += 0.25*v[4]; - evm.v[5] += 0.25*v[5]; + evm.v[0] += static_cast(static_cast(0.25)*v[0]); + evm.v[1] += static_cast(static_cast(0.25)*v[1]); + evm.v[2] += static_cast(static_cast(0.25)*v[2]); + evm.v[3] += static_cast(static_cast(0.25)*v[3]); + evm.v[4] += static_cast(static_cast(0.25)*v[4]); + evm.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i4 < nlocal) { - evm.v[0] += 0.25*v[0]; - evm.v[1] += 0.25*v[1]; - evm.v[2] += 0.25*v[2]; - evm.v[3] += 0.25*v[3]; - evm.v[4] += 0.25*v[4]; - evm.v[5] += 0.25*v[5]; + evm.v[0] += static_cast(static_cast(0.25)*v[0]); + evm.v[1] += static_cast(static_cast(0.25)*v[1]); + evm.v[2] += static_cast(static_cast(0.25)*v[2]); + evm.v[3] += static_cast(static_cast(0.25)*v[3]); + evm.v[4] += static_cast(static_cast(0.25)*v[4]); + evm.v[5] += static_cast(static_cast(0.25)*v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - d_vatom(i1,0) += 0.25*v[0]; - d_vatom(i1,1) += 0.25*v[1]; - d_vatom(i1,2) += 0.25*v[2]; - d_vatom(i1,3) += 0.25*v[3]; - d_vatom(i1,4) += 0.25*v[4]; - d_vatom(i1,5) += 0.25*v[5]; + d_vatom(i1,0) += static_cast(static_cast(0.25)*v[0]); + d_vatom(i1,1) += static_cast(static_cast(0.25)*v[1]); + d_vatom(i1,2) += static_cast(static_cast(0.25)*v[2]); + d_vatom(i1,3) += static_cast(static_cast(0.25)*v[3]); + d_vatom(i1,4) += static_cast(static_cast(0.25)*v[4]); + d_vatom(i1,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i2 < nlocal) { - d_vatom(i2,0) += 0.25*v[0]; - d_vatom(i2,1) += 0.25*v[1]; - d_vatom(i2,2) += 0.25*v[2]; - d_vatom(i2,3) += 0.25*v[3]; - d_vatom(i2,4) += 0.25*v[4]; - d_vatom(i2,5) += 0.25*v[5]; + d_vatom(i2,0) += static_cast(static_cast(0.25)*v[0]); + d_vatom(i2,1) += static_cast(static_cast(0.25)*v[1]); + d_vatom(i2,2) += static_cast(static_cast(0.25)*v[2]); + d_vatom(i2,3) += static_cast(static_cast(0.25)*v[3]); + d_vatom(i2,4) += static_cast(static_cast(0.25)*v[4]); + d_vatom(i2,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i3 < nlocal) { - d_vatom(i3,0) += 0.25*v[0]; - d_vatom(i3,1) += 0.25*v[1]; - d_vatom(i3,2) += 0.25*v[2]; - d_vatom(i3,3) += 0.25*v[3]; - d_vatom(i3,4) += 0.25*v[4]; - d_vatom(i3,5) += 0.25*v[5]; + d_vatom(i3,0) += static_cast(static_cast(0.25)*v[0]); + d_vatom(i3,1) += static_cast(static_cast(0.25)*v[1]); + d_vatom(i3,2) += static_cast(static_cast(0.25)*v[2]); + d_vatom(i3,3) += static_cast(static_cast(0.25)*v[3]); + d_vatom(i3,4) += static_cast(static_cast(0.25)*v[4]); + d_vatom(i3,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i4 < nlocal) { - d_vatom(i4,0) += 0.25*v[0]; - d_vatom(i4,1) += 0.25*v[1]; - d_vatom(i4,2) += 0.25*v[2]; - d_vatom(i4,3) += 0.25*v[3]; - d_vatom(i4,4) += 0.25*v[4]; - d_vatom(i4,5) += 0.25*v[5]; + d_vatom(i4,0) += static_cast(static_cast(0.25)*v[0]); + d_vatom(i4,1) += static_cast(static_cast(0.25)*v[1]); + d_vatom(i4,2) += static_cast(static_cast(0.25)*v[2]); + d_vatom(i4,3) += static_cast(static_cast(0.25)*v[3]); + d_vatom(i4,4) += static_cast(static_cast(0.25)*v[4]); + d_vatom(i4,5) += static_cast(static_cast(0.25)*v[5]); } } } @@ -735,25 +741,25 @@ void DihedralCharmmfswKokkos::ev_tally(EVM_FLOAT &evm, const int i, if (eflag_either) { if (eflag_global) { if (newton_bond) { - evm.evdwl += evdwl; - evm.ecoul += ecoul; + evm.evdwl += static_cast(evdwl); + evm.ecoul += static_cast(ecoul); } else { - evdwlhalf = 0.5*evdwl; - ecoulhalf = 0.5*ecoul; + evdwlhalf = static_cast(0.5)*evdwl; + ecoulhalf = static_cast(0.5)*ecoul; if (i < nlocal) { - evm.evdwl += evdwlhalf; - evm.ecoul += ecoulhalf; + evm.evdwl += static_cast(evdwlhalf); + evm.ecoul += static_cast(ecoulhalf); } if (j < nlocal) { - evm.evdwl += evdwlhalf; - evm.ecoul += ecoulhalf; + evm.evdwl += static_cast(evdwlhalf); + evm.ecoul += static_cast(ecoulhalf); } } } if (eflag_atom) { - epairhalf = 0.5 * (evdwl + ecoul); - if (newton_bond || i < nlocal) d_eatom_pair[i] += epairhalf; - if (newton_bond || j < nlocal) d_eatom_pair[j] += epairhalf; + epairhalf = static_cast(0.5) * (evdwl + ecoul); + if (newton_bond || i < nlocal) d_eatom_pair[i] += static_cast(epairhalf); + if (newton_bond || j < nlocal) d_eatom_pair[j] += static_cast(epairhalf); } } @@ -767,48 +773,48 @@ void DihedralCharmmfswKokkos::ev_tally(EVM_FLOAT &evm, const int i, if (vflag_global) { if (newton_bond) { - evm.vp[0] += v[0]; - evm.vp[1] += v[1]; - evm.vp[2] += v[2]; - evm.vp[3] += v[3]; - evm.vp[4] += v[4]; - evm.vp[5] += v[5]; + evm.vp[0] += static_cast(v[0]); + evm.vp[1] += static_cast(v[1]); + evm.vp[2] += static_cast(v[2]); + evm.vp[3] += static_cast(v[3]); + evm.vp[4] += static_cast(v[4]); + evm.vp[5] += static_cast(v[5]); } else { if (i < nlocal) { - evm.vp[0] += 0.5*v[0]; - evm.vp[1] += 0.5*v[1]; - evm.vp[2] += 0.5*v[2]; - evm.vp[3] += 0.5*v[3]; - evm.vp[4] += 0.5*v[4]; - evm.vp[5] += 0.5*v[5]; + evm.vp[0] += static_cast(static_cast(0.5)*v[0]); + evm.vp[1] += static_cast(static_cast(0.5)*v[1]); + evm.vp[2] += static_cast(static_cast(0.5)*v[2]); + evm.vp[3] += static_cast(static_cast(0.5)*v[3]); + evm.vp[4] += static_cast(static_cast(0.5)*v[4]); + evm.vp[5] += static_cast(static_cast(0.5)*v[5]); } if (j < nlocal) { - evm.vp[0] += 0.5*v[0]; - evm.vp[1] += 0.5*v[1]; - evm.vp[2] += 0.5*v[2]; - evm.vp[3] += 0.5*v[3]; - evm.vp[4] += 0.5*v[4]; - evm.vp[5] += 0.5*v[5]; + evm.vp[0] += static_cast(static_cast(0.5)*v[0]); + evm.vp[1] += static_cast(static_cast(0.5)*v[1]); + evm.vp[2] += static_cast(static_cast(0.5)*v[2]); + evm.vp[3] += static_cast(static_cast(0.5)*v[3]); + evm.vp[4] += static_cast(static_cast(0.5)*v[4]); + evm.vp[5] += static_cast(static_cast(0.5)*v[5]); } } } if (vflag_atom) { if (newton_bond || i < nlocal) { - d_vatom_pair(i,0) += 0.5*v[0]; - d_vatom_pair(i,1) += 0.5*v[1]; - d_vatom_pair(i,2) += 0.5*v[2]; - d_vatom_pair(i,3) += 0.5*v[3]; - d_vatom_pair(i,4) += 0.5*v[4]; - d_vatom_pair(i,5) += 0.5*v[5]; + d_vatom_pair(i,0) += static_cast(static_cast(0.5)*v[0]); + d_vatom_pair(i,1) += static_cast(static_cast(0.5)*v[1]); + d_vatom_pair(i,2) += static_cast(static_cast(0.5)*v[2]); + d_vatom_pair(i,3) += static_cast(static_cast(0.5)*v[3]); + d_vatom_pair(i,4) += static_cast(static_cast(0.5)*v[4]); + d_vatom_pair(i,5) += static_cast(static_cast(0.5)*v[5]); } if (newton_bond || j < nlocal) { - d_vatom_pair(j,0) += 0.5*v[0]; - d_vatom_pair(j,1) += 0.5*v[1]; - d_vatom_pair(j,2) += 0.5*v[2]; - d_vatom_pair(j,3) += 0.5*v[3]; - d_vatom_pair(j,4) += 0.5*v[4]; - d_vatom_pair(j,5) += 0.5*v[5]; + d_vatom_pair(j,0) += static_cast(static_cast(0.5)*v[0]); + d_vatom_pair(j,1) += static_cast(static_cast(0.5)*v[1]); + d_vatom_pair(j,2) += static_cast(static_cast(0.5)*v[2]); + d_vatom_pair(j,3) += static_cast(static_cast(0.5)*v[3]); + d_vatom_pair(j,4) += static_cast(static_cast(0.5)*v[4]); + d_vatom_pair(j,5) += static_cast(static_cast(0.5)*v[5]); } } } diff --git a/src/KOKKOS/dihedral_class2_kokkos.cpp b/src/KOKKOS/dihedral_class2_kokkos.cpp index cf8f8806592..4050803c4be 100644 --- a/src/KOKKOS/dihedral_class2_kokkos.cpp +++ b/src/KOKKOS/dihedral_class2_kokkos.cpp @@ -168,14 +168,14 @@ void DihedralClass2Kokkos::compute(int eflag_in, int vflag_in) if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -233,18 +233,18 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute(1.0)/r1mag2; + const KK_FLOAT rb1 = static_cast(1.0)/r1; + const KK_FLOAT sb2 = static_cast(1.0)/r2mag2; + const KK_FLOAT rb2 = static_cast(1.0)/r2; + const KK_FLOAT sb3 = static_cast(1.0)/r3mag2; + const KK_FLOAT rb3 = static_cast(1.0)/r3; KK_FLOAT c0 = (vb1x*vb3x + vb1y*vb3y + vb1z*vb3z) * rb1*rb3; @@ -256,22 +256,22 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute(1.0)), -static_cast(1.0)); + costh13 = MAX(MIN(costh13, static_cast(1.0)), -static_cast(1.0)); + costh23 = MAX(MIN(costh23, static_cast(1.0)), -static_cast(1.0)); c0 = costh13; // cos and sin of 2 angles and final c - KK_FLOAT sin2 = MAX(1.0 - costh12*costh12,0.0); - KK_FLOAT sc1 = sqrt(sin2); - if (sc1 < SMALL) sc1 = SMALL; - sc1 = 1.0/sc1; + KK_FLOAT sin2 = MAX(static_cast(1.0) - costh12*costh12,static_cast(0.0)); + KK_FLOAT sc1 = Kokkos::sqrt(sin2); + if (sc1 < static_cast(SMALL)) sc1 = static_cast(SMALL); + sc1 = static_cast(1.0)/sc1; - sin2 = MAX(1.0 - costh23*costh23,0.0); - KK_FLOAT sc2 = sqrt(sin2); - if (sc2 < SMALL) sc2 = SMALL; - sc2 = 1.0/sc2; + sin2 = MAX(static_cast(1.0) - costh23*costh23,static_cast(0.0)); + KK_FLOAT sc2 = Kokkos::sqrt(sin2); + if (sc2 < static_cast(SMALL)) sc2 = static_cast(SMALL); + sc2 = static_cast(1.0)/sc2; const KK_FLOAT s1 = sc1 * sc1; const KK_FLOAT s2 = sc2 * sc2; @@ -280,16 +280,16 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0) + static_cast(TOLERANCE) || c < (-static_cast(1.0) - static_cast(TOLERANCE))) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = static_cast(1.0); + if (c < -static_cast(1.0)) c = -static_cast(1.0); const KK_FLOAT cosphi = c; - KK_FLOAT phi = acos(c); + KK_FLOAT phi = Kokkos::acos(c); - KK_FLOAT sinphi = sqrt(1.0 - c*c); - sinphi = MAX(sinphi,SMALL); + KK_FLOAT sinphi = Kokkos::sqrt(static_cast(1.0) - c*c); + sinphi = MAX(sinphi,static_cast(SMALL)); // n123 = vb1 x vb2 @@ -297,13 +297,13 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute 0.0) { + if (n123_dot_vb3 > static_cast(0.0)) { phi = -phi; sinphi = -sinphi; } const KK_FLOAT a11 = -c*sb1*s1; - const KK_FLOAT a22 = sb2 * (2.0*costh13*s12 - c*(s1+s2)); + const KK_FLOAT a22 = sb2 * (static_cast(2.0)*costh13*s12 - c*(s1+s2)); const KK_FLOAT a33 = -c*sb3*s2; const KK_FLOAT a12 = r12c1 * (costh12*c*s1 + costh23*s12); const KK_FLOAT a13 = rb1*rb3*s12; @@ -345,15 +345,15 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute(2.0)*phi - d_phi2[type]; + const KK_FLOAT dphi3 = static_cast(3.0)*phi - d_phi3[type]; - if (eflag) edihedral = d_k1[type]*(1.0 - cos(dphi1)) + - d_k2[type]*(1.0 - cos(dphi2)) + - d_k3[type]*(1.0 - cos(dphi3)); + if (eflag) edihedral = d_k1[type]*(static_cast(1.0) - Kokkos::cos(dphi1)) + + d_k2[type]*(static_cast(1.0) - Kokkos::cos(dphi2)) + + d_k3[type]*(static_cast(1.0) - Kokkos::cos(dphi3)); - const KK_FLOAT de_dihedral = d_k1[type]*sin(dphi1) + 2.0*d_k2[type]*sin(dphi2) + - 3.0*d_k3[type]*sin(dphi3); + const KK_FLOAT de_dihedral = d_k1[type]*Kokkos::sin(dphi1) + static_cast(2.0)*d_k2[type]*Kokkos::sin(dphi2) + + static_cast(3.0)*d_k3[type]*Kokkos::sin(dphi3); // torsion forces on all 4 atoms @@ -450,8 +450,8 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute(2.0)*phi); + KK_FLOAT cos3phi = Kokkos::cos(static_cast(3.0)*phi); KK_FLOAT bt1 = d_mbt_f1[type] * cosphi; KK_FLOAT bt2 = d_mbt_f2[type] * cos2phi; @@ -463,8 +463,8 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute(2.0) * d_mbt_f2[type] * Kokkos::sin(static_cast(2.0)*phi); + bt3 = -static_cast(3.0) * d_mbt_f3[type] * Kokkos::sin(static_cast(3.0)*phi); KK_FLOAT sumbtf = bt1 + bt2 + bt3; for (int i = 0; i < 4; i++) @@ -485,8 +485,8 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute(2.0) * d_ebt_f2_1[type] * Kokkos::sin(static_cast(2.0)*phi); + bt3 = static_cast(3.0) * d_ebt_f3_1[type] * Kokkos::sin(static_cast(3.0)*phi); sumbtf = bt1 + bt2 + bt3; for (int i = 0; i < 4; i++) @@ -507,8 +507,8 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute(2.0) * d_ebt_f2_2[type] * Kokkos::sin(static_cast(2.0)*phi); + bt3 = -static_cast(3.0) * d_ebt_f3_2[type] * Kokkos::sin(static_cast(3.0)*phi); sumbtf = bt1 + bt2 + bt3; for (int i = 0; i < 4; i++) @@ -523,14 +523,14 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute(2.0) * d_at_f2_1[type] * Kokkos::sin(static_cast(2.0)*phi); + bt3 = static_cast(3.0) * d_at_f3_1[type] * Kokkos::sin(static_cast(3.0)*phi); sumbtf = bt1 + bt2 + bt3; for (int i = 0; i < 4; i++) @@ -544,14 +544,14 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute(2.0) * d_at_f2_2[type] * Kokkos::sin(static_cast(2.0)*phi); + bt3 = -static_cast(3.0) * d_at_f3_2[type] * Kokkos::sin(static_cast(3.0)*phi); sumbtf = bt1 + bt2 + bt3; for (int i = 0; i < 4; i++) @@ -560,8 +560,8 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute::operator()(TagDihedralClass2Compute SMALL) { + if (Kokkos::fabs(d_bb13t_k[type]) > static_cast(SMALL)) { const KK_FLOAT r1_0 = d_bb13t_r10[type]; const KK_FLOAT r3_0 = d_bb13t_r30[type]; @@ -613,27 +613,27 @@ void DihedralClass2Kokkos::operator()(TagDihedralClass2Compute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -752,38 +752,38 @@ void DihedralClass2Kokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k1.view_host()[i] = k1[i]; - k_k2.view_host()[i] = k2[i]; - k_k3.view_host()[i] = k3[i]; - k_phi1.view_host()[i] = phi1[i]; - k_phi2.view_host()[i] = phi2[i]; - k_phi3.view_host()[i] = phi3[i]; - k_mbt_f1.view_host()[i] = mbt_f1[i]; - k_mbt_f2.view_host()[i] = mbt_f2[i]; - k_mbt_f3.view_host()[i] = mbt_f3[i]; - k_mbt_r0.view_host()[i] = mbt_r0[i]; - k_ebt_f1_1.view_host()[i] = ebt_f1_1[i]; - k_ebt_f2_1.view_host()[i] = ebt_f2_1[i]; - k_ebt_f3_1.view_host()[i] = ebt_f3_1[i]; - k_ebt_r0_1.view_host()[i] = ebt_r0_1[i]; - k_ebt_f1_2.view_host()[i] = ebt_f1_2[i]; - k_ebt_f2_2.view_host()[i] = ebt_f2_2[i]; - k_ebt_f3_2.view_host()[i] = ebt_f3_2[i]; - k_ebt_r0_2.view_host()[i] = ebt_r0_2[i]; - k_at_f1_1.view_host()[i] = at_f1_1[i]; - k_at_f2_1.view_host()[i] = at_f2_1[i]; - k_at_f3_1.view_host()[i] = at_f3_1[i]; - k_at_f1_2.view_host()[i] = at_f1_2[i]; - k_at_f2_2.view_host()[i] = at_f2_2[i]; - k_at_f3_2.view_host()[i] = at_f3_2[i]; - k_at_theta0_1.view_host()[i] = at_theta0_1[i]; - k_at_theta0_2.view_host()[i] = at_theta0_2[i]; - k_aat_k.view_host()[i] = aat_k[i]; - k_aat_theta0_1.view_host()[i] = aat_theta0_1[i]; - k_aat_theta0_2.view_host()[i] = aat_theta0_2[i]; - k_bb13t_k.view_host()[i] = bb13t_k[i]; - k_bb13t_r10.view_host()[i] = bb13t_r10[i]; - k_bb13t_r30.view_host()[i] = bb13t_r30[i]; + k_k1.view_host()[i] = static_cast(k1[i]); + k_k2.view_host()[i] = static_cast(k2[i]); + k_k3.view_host()[i] = static_cast(k3[i]); + k_phi1.view_host()[i] = static_cast(phi1[i]); + k_phi2.view_host()[i] = static_cast(phi2[i]); + k_phi3.view_host()[i] = static_cast(phi3[i]); + k_mbt_f1.view_host()[i] = static_cast(mbt_f1[i]); + k_mbt_f2.view_host()[i] = static_cast(mbt_f2[i]); + k_mbt_f3.view_host()[i] = static_cast(mbt_f3[i]); + k_mbt_r0.view_host()[i] = static_cast(mbt_r0[i]); + k_ebt_f1_1.view_host()[i] = static_cast(ebt_f1_1[i]); + k_ebt_f2_1.view_host()[i] = static_cast(ebt_f2_1[i]); + k_ebt_f3_1.view_host()[i] = static_cast(ebt_f3_1[i]); + k_ebt_r0_1.view_host()[i] = static_cast(ebt_r0_1[i]); + k_ebt_f1_2.view_host()[i] = static_cast(ebt_f1_2[i]); + k_ebt_f2_2.view_host()[i] = static_cast(ebt_f2_2[i]); + k_ebt_f3_2.view_host()[i] = static_cast(ebt_f3_2[i]); + k_ebt_r0_2.view_host()[i] = static_cast(ebt_r0_2[i]); + k_at_f1_1.view_host()[i] = static_cast(at_f1_1[i]); + k_at_f2_1.view_host()[i] = static_cast(at_f2_1[i]); + k_at_f3_1.view_host()[i] = static_cast(at_f3_1[i]); + k_at_f1_2.view_host()[i] = static_cast(at_f1_2[i]); + k_at_f2_2.view_host()[i] = static_cast(at_f2_2[i]); + k_at_f3_2.view_host()[i] = static_cast(at_f3_2[i]); + k_at_theta0_1.view_host()[i] = static_cast(at_theta0_1[i]); + k_at_theta0_2.view_host()[i] = static_cast(at_theta0_2[i]); + k_aat_k.view_host()[i] = static_cast(aat_k[i]); + k_aat_theta0_1.view_host()[i] = static_cast(aat_theta0_1[i]); + k_aat_theta0_2.view_host()[i] = static_cast(aat_theta0_2[i]); + k_bb13t_k.view_host()[i] = static_cast(bb13t_k[i]); + k_bb13t_r10.view_host()[i] = static_cast(bb13t_r10[i]); + k_bb13t_r30.view_host()[i] = static_cast(bb13t_r30[i]); k_setflag_d.view_host()[i] = setflag_d[i]; k_setflag_mbt.view_host()[i] = setflag_mbt[i]; k_setflag_ebt.view_host()[i] = setflag_ebt[i]; @@ -922,38 +922,38 @@ void DihedralClass2Kokkos::read_restart(FILE *fp) d_setflag_bb13t = k_setflag_bb13t.template view(); for (int i = 1; i <= n; i++) { - k_k1.view_host()[i] = k1[i]; - k_k2.view_host()[i] = k2[i]; - k_k3.view_host()[i] = k3[i]; - k_phi1.view_host()[i] = phi1[i]; - k_phi2.view_host()[i] = phi2[i]; - k_phi3.view_host()[i] = phi3[i]; - k_mbt_f1.view_host()[i] = mbt_f1[i]; - k_mbt_f2.view_host()[i] = mbt_f2[i]; - k_mbt_f3.view_host()[i] = mbt_f3[i]; - k_mbt_r0.view_host()[i] = mbt_r0[i]; - k_ebt_f1_1.view_host()[i] = ebt_f1_1[i]; - k_ebt_f2_1.view_host()[i] = ebt_f2_1[i]; - k_ebt_f3_1.view_host()[i] = ebt_f3_1[i]; - k_ebt_r0_1.view_host()[i] = ebt_r0_1[i]; - k_ebt_f1_2.view_host()[i] = ebt_f1_2[i]; - k_ebt_f2_2.view_host()[i] = ebt_f2_2[i]; - k_ebt_f3_2.view_host()[i] = ebt_f3_2[i]; - k_ebt_r0_2.view_host()[i] = ebt_r0_2[i]; - k_at_f1_1.view_host()[i] = at_f1_1[i]; - k_at_f2_1.view_host()[i] = at_f2_1[i]; - k_at_f3_1.view_host()[i] = at_f3_1[i]; - k_at_f1_2.view_host()[i] = at_f1_2[i]; - k_at_f2_2.view_host()[i] = at_f2_2[i]; - k_at_f3_2.view_host()[i] = at_f3_2[i]; - k_at_theta0_1.view_host()[i] = at_theta0_1[i]; - k_at_theta0_2.view_host()[i] = at_theta0_2[i]; - k_aat_k.view_host()[i] = aat_k[i]; - k_aat_theta0_1.view_host()[i] = aat_theta0_1[i]; - k_aat_theta0_2.view_host()[i] = aat_theta0_2[i]; - k_bb13t_k.view_host()[i] = bb13t_k[i]; - k_bb13t_r10.view_host()[i] = bb13t_r10[i]; - k_bb13t_r30.view_host()[i] = bb13t_r30[i]; + k_k1.view_host()[i] = static_cast(k1[i]); + k_k2.view_host()[i] = static_cast(k2[i]); + k_k3.view_host()[i] = static_cast(k3[i]); + k_phi1.view_host()[i] = static_cast(phi1[i]); + k_phi2.view_host()[i] = static_cast(phi2[i]); + k_phi3.view_host()[i] = static_cast(phi3[i]); + k_mbt_f1.view_host()[i] = static_cast(mbt_f1[i]); + k_mbt_f2.view_host()[i] = static_cast(mbt_f2[i]); + k_mbt_f3.view_host()[i] = static_cast(mbt_f3[i]); + k_mbt_r0.view_host()[i] = static_cast(mbt_r0[i]); + k_ebt_f1_1.view_host()[i] = static_cast(ebt_f1_1[i]); + k_ebt_f2_1.view_host()[i] = static_cast(ebt_f2_1[i]); + k_ebt_f3_1.view_host()[i] = static_cast(ebt_f3_1[i]); + k_ebt_r0_1.view_host()[i] = static_cast(ebt_r0_1[i]); + k_ebt_f1_2.view_host()[i] = static_cast(ebt_f1_2[i]); + k_ebt_f2_2.view_host()[i] = static_cast(ebt_f2_2[i]); + k_ebt_f3_2.view_host()[i] = static_cast(ebt_f3_2[i]); + k_ebt_r0_2.view_host()[i] = static_cast(ebt_r0_2[i]); + k_at_f1_1.view_host()[i] = static_cast(at_f1_1[i]); + k_at_f2_1.view_host()[i] = static_cast(at_f2_1[i]); + k_at_f3_1.view_host()[i] = static_cast(at_f3_1[i]); + k_at_f1_2.view_host()[i] = static_cast(at_f1_2[i]); + k_at_f2_2.view_host()[i] = static_cast(at_f2_2[i]); + k_at_f3_2.view_host()[i] = static_cast(at_f3_2[i]); + k_at_theta0_1.view_host()[i] = static_cast(at_theta0_1[i]); + k_at_theta0_2.view_host()[i] = static_cast(at_theta0_2[i]); + k_aat_k.view_host()[i] = static_cast(aat_k[i]); + k_aat_theta0_1.view_host()[i] = static_cast(aat_theta0_1[i]); + k_aat_theta0_2.view_host()[i] = static_cast(aat_theta0_2[i]); + k_bb13t_k.view_host()[i] = static_cast(bb13t_k[i]); + k_bb13t_r10.view_host()[i] = static_cast(bb13t_r10[i]); + k_bb13t_r30.view_host()[i] = static_cast(bb13t_r30[i]); k_setflag_d.view_host()[i] = setflag_d[i]; k_setflag_mbt.view_host()[i] = setflag_mbt[i]; k_setflag_ebt.view_host()[i] = setflag_ebt[i]; @@ -1028,21 +1028,21 @@ void DihedralClass2Kokkos::ev_tally(EV_FLOAT &ev, const int i1, cons if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -1056,80 +1056,80 @@ void DihedralClass2Kokkos::ev_tally(EV_FLOAT &ev, const int i1, cons if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i1,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i1,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i1,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i1,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i1,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i2,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i2,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i2,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i2,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i2,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i3,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i3,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i3,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i3,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i3,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i4,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i4,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i4,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i4,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i4,5) += static_cast(0.25)*static_cast(v[5]); } } } diff --git a/src/KOKKOS/dihedral_class2xe_kokkos.cpp b/src/KOKKOS/dihedral_class2xe_kokkos.cpp index 721a1dbeee8..d38511a978b 100644 --- a/src/KOKKOS/dihedral_class2xe_kokkos.cpp +++ b/src/KOKKOS/dihedral_class2xe_kokkos.cpp @@ -173,14 +173,14 @@ void DihedralClass2xeKokkos::compute(int eflag_in, int vflag_in) if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -238,18 +238,18 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute(1.0)/r1mag2; + const KK_FLOAT rb1 = static_cast(1.0)/r1; + const KK_FLOAT sb2 = static_cast(1.0)/r2mag2; + const KK_FLOAT rb2 = static_cast(1.0)/r2; + const KK_FLOAT sb3 = static_cast(1.0)/r3mag2; + const KK_FLOAT rb3 = static_cast(1.0)/r3; KK_FLOAT c0 = (vb1x*vb3x + vb1y*vb3y + vb1z*vb3z) * rb1*rb3; @@ -261,22 +261,22 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute(1.0)), -static_cast(1.0)); + costh13 = MAX(MIN(costh13, static_cast(1.0)), -static_cast(1.0)); + costh23 = MAX(MIN(costh23, static_cast(1.0)), -static_cast(1.0)); c0 = costh13; // cos and sin of 2 angles and final c - KK_FLOAT sin2 = MAX(1.0 - costh12*costh12,0.0); - KK_FLOAT sc1 = sqrt(sin2); - if (sc1 < SMALL) sc1 = SMALL; - sc1 = 1.0/sc1; + KK_FLOAT sin2 = MAX(static_cast(1.0) - costh12*costh12,static_cast(0.0)); + KK_FLOAT sc1 = Kokkos::sqrt(sin2); + if (sc1 < static_cast(SMALL)) sc1 = static_cast(SMALL); + sc1 = static_cast(1.0)/sc1; - sin2 = MAX(1.0 - costh23*costh23,0.0); - KK_FLOAT sc2 = sqrt(sin2); - if (sc2 < SMALL) sc2 = SMALL; - sc2 = 1.0/sc2; + sin2 = MAX(static_cast(1.0) - costh23*costh23,static_cast(0.0)); + KK_FLOAT sc2 = Kokkos::sqrt(sin2); + if (sc2 < static_cast(SMALL)) sc2 = static_cast(SMALL); + sc2 = static_cast(1.0)/sc2; const KK_FLOAT s1 = sc1 * sc1; const KK_FLOAT s2 = sc2 * sc2; @@ -285,16 +285,16 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0) + static_cast(TOLERANCE) || c < (-static_cast(1.0) - static_cast(TOLERANCE))) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = static_cast(1.0); + if (c < -static_cast(1.0)) c = -static_cast(1.0); const KK_FLOAT cosphi = c; - KK_FLOAT phi = acos(c); + KK_FLOAT phi = Kokkos::acos(c); - KK_FLOAT sinphi = sqrt(1.0 - c*c); - sinphi = MAX(sinphi,SMALL); + KK_FLOAT sinphi = Kokkos::sqrt(static_cast(1.0) - c*c); + sinphi = MAX(sinphi,static_cast(SMALL)); // n123 = vb1 x vb2 @@ -302,13 +302,13 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute 0.0) { + if (n123_dot_vb3 > static_cast(0.0)) { phi = -phi; sinphi = -sinphi; } const KK_FLOAT a11 = -c*sb1*s1; - const KK_FLOAT a22 = sb2 * (2.0*costh13*s12 - c*(s1+s2)); + const KK_FLOAT a22 = sb2 * (static_cast(2.0)*costh13*s12 - c*(s1+s2)); const KK_FLOAT a33 = -c*sb3*s2; const KK_FLOAT a12 = r12c1 * (costh12*c*s1 + costh23*s12); const KK_FLOAT a13 = rb1*rb3*s12; @@ -350,15 +350,15 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute(2.0)*phi - d_phi2[type]; + const KK_FLOAT dphi3 = static_cast(3.0)*phi - d_phi3[type]; - if (EVFLAG && eflag) edihedral = d_k1[type]*(1.0 - cos(dphi1)) + - d_k2[type]*(1.0 - cos(dphi2)) + - d_k3[type]*(1.0 - cos(dphi3)); + if (EVFLAG && eflag) edihedral = d_k1[type]*(static_cast(1.0) - Kokkos::cos(dphi1)) + + d_k2[type]*(static_cast(1.0) - Kokkos::cos(dphi2)) + + d_k3[type]*(static_cast(1.0) - Kokkos::cos(dphi3)); - const KK_FLOAT de_dihedral = d_k1[type]*sin(dphi1) + 2.0*d_k2[type]*sin(dphi2) + - 3.0*d_k3[type]*sin(dphi3); + const KK_FLOAT de_dihedral = d_k1[type]*Kokkos::sin(dphi1) + static_cast(2.0)*d_k2[type]*Kokkos::sin(dphi2) + + static_cast(3.0)*d_k3[type]*Kokkos::sin(dphi3); // torsion forces on all 4 atoms @@ -455,23 +455,23 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute(2.0)*phi); + KK_FLOAT cos3phi = Kokkos::cos(static_cast(3.0)*phi); KK_FLOAT bt1 = d_mbt_f1[type] * cosphi; KK_FLOAT bt2 = d_mbt_f2[type] * cos2phi; KK_FLOAT bt3 = d_mbt_f3[type] * cos3phi; KK_FLOAT sumbte = bt1 + bt2 + bt3; KK_FLOAT mbt_dr2 = r2 - d_mbt_r0[type]; - KK_FLOAT mbt_ralpha2 = exp(-d_mbt_alpha2[type]*mbt_dr2); - KK_FLOAT db = 1.0 - mbt_ralpha2; + KK_FLOAT mbt_ralpha2 = Kokkos::exp(-d_mbt_alpha2[type]*mbt_dr2); + KK_FLOAT db = static_cast(1.0) - mbt_ralpha2; if (EVFLAG && eflag) edihedral += db * sumbte; // force on bond2 (Morse-type coupling) bt1 = -d_mbt_f1[type] * sinphi; - bt2 = -2.0 * d_mbt_f2[type] * sin(2.0*phi); - bt3 = -3.0 * d_mbt_f3[type] * sin(3.0*phi); + bt2 = -static_cast(2.0) * d_mbt_f2[type] * Kokkos::sin(static_cast(2.0)*phi); + bt3 = -static_cast(3.0) * d_mbt_f3[type] * Kokkos::sin(static_cast(3.0)*phi); KK_FLOAT sumbtf = bt1 + bt2 + bt3; for (int i = 0; i < 4; i++) @@ -488,15 +488,15 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute(1.0) - ebt_ralpha1; if (EVFLAG && eflag) edihedral += db * (bt1+bt2+bt3); // force on bond1 bt1 = d_ebt_f1_1[type] * sinphi; - bt2 = 2.0 * d_ebt_f2_1[type] * sin(2.0*phi); - bt3 = 3.0 * d_ebt_f3_1[type] * sin(3.0*phi); + bt2 = static_cast(2.0) * d_ebt_f2_1[type] * Kokkos::sin(static_cast(2.0)*phi); + bt3 = static_cast(3.0) * d_ebt_f3_1[type] * Kokkos::sin(static_cast(3.0)*phi); sumbtf = bt1 + bt2 + bt3; for (int i = 0; i < 4; i++) @@ -513,15 +513,15 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute(1.0) - ebt_ralpha3; if (EVFLAG && eflag) edihedral += db * (bt1+bt2+bt3); // force on bond3 bt1 = -d_ebt_f1_2[type] * sinphi; - bt2 = -2.0 * d_ebt_f2_2[type] * sin(2.0*phi); - bt3 = -3.0 * d_ebt_f3_2[type] * sin(3.0*phi); + bt2 = -static_cast(2.0) * d_ebt_f2_2[type] * Kokkos::sin(static_cast(2.0)*phi); + bt3 = -static_cast(3.0) * d_ebt_f3_2[type] * Kokkos::sin(static_cast(3.0)*phi); sumbtf = bt1 + bt2 + bt3; for (int i = 0; i < 4; i++) @@ -537,14 +537,14 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute(2.0) * d_at_f2_1[type] * Kokkos::sin(static_cast(2.0)*phi); + bt3 = static_cast(3.0) * d_at_f3_1[type] * Kokkos::sin(static_cast(3.0)*phi); sumbtf = bt1 + bt2 + bt3; for (int i = 0; i < 4; i++) @@ -558,14 +558,14 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute(2.0) * d_at_f2_2[type] * Kokkos::sin(static_cast(2.0)*phi); + bt3 = -static_cast(3.0) * d_at_f3_2[type] * Kokkos::sin(static_cast(3.0)*phi); sumbtf = bt1 + bt2 + bt3; for (int i = 0; i < 4; i++) @@ -574,8 +574,8 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute::operator()(TagDihedralClass2xeCompute SMALL) { + if (Kokkos::fabs(d_bb13t_d0[type]) > static_cast(SMALL)) { const KK_FLOAT bb13_dr1 = r1 - d_bb13t_r10[type]; const KK_FLOAT bb13_dr2 = r3 - d_bb13t_r30[type]; - const KK_FLOAT bb13_ralpha1 = exp(-d_bb13t_alpha[type]*bb13_dr1); - const KK_FLOAT bb13_ralpha2 = exp(-d_bb13t_alpha[type]*bb13_dr2); - const KK_FLOAT tk1 = -d_bb13t_d0[type]*d_bb13t_alpha[type]*bb13_ralpha2*(1.0 - bb13_ralpha1)/r3; - const KK_FLOAT tk2 = -d_bb13t_d0[type]*d_bb13t_alpha[type]*bb13_ralpha1*(1.0 - bb13_ralpha2)/r1; + const KK_FLOAT bb13_ralpha1 = Kokkos::exp(-d_bb13t_alpha[type]*bb13_dr1); + const KK_FLOAT bb13_ralpha2 = Kokkos::exp(-d_bb13t_alpha[type]*bb13_dr2); + const KK_FLOAT tk1 = -d_bb13t_d0[type]*d_bb13t_alpha[type]*bb13_ralpha2*(static_cast(1.0) - bb13_ralpha1)/r3; + const KK_FLOAT tk2 = -d_bb13t_d0[type]*d_bb13t_alpha[type]*bb13_ralpha1*(static_cast(1.0) - bb13_ralpha2)/r1; - if (EVFLAG && eflag) edihedral += d_bb13t_d0[type]*(1.0 - bb13_ralpha1)*(1.0 - bb13_ralpha2); + if (EVFLAG && eflag) edihedral += d_bb13t_d0[type]*(static_cast(1.0) - bb13_ralpha1)*(static_cast(1.0) - bb13_ralpha2); fabcd[0][0] += tk2 * vb1x; fabcd[0][1] += tk2 * vb1y; @@ -627,27 +627,27 @@ void DihedralClass2xeKokkos::operator()(TagDihedralClass2xeCompute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -774,42 +774,42 @@ void DihedralClass2xeKokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k1.view_host()[i] = k1[i]; - k_k2.view_host()[i] = k2[i]; - k_k3.view_host()[i] = k3[i]; - k_phi1.view_host()[i] = phi1[i]; - k_phi2.view_host()[i] = phi2[i]; - k_phi3.view_host()[i] = phi3[i]; - k_mbt_f1.view_host()[i] = mbt_f1[i]; - k_mbt_f2.view_host()[i] = mbt_f2[i]; - k_mbt_f3.view_host()[i] = mbt_f3[i]; - k_mbt_r0.view_host()[i] = mbt_r0[i]; - k_mbt_alpha2.view_host()[i] = mbt_alpha2[i]; - k_ebt_f1_1.view_host()[i] = ebt_f1_1[i]; - k_ebt_f2_1.view_host()[i] = ebt_f2_1[i]; - k_ebt_f3_1.view_host()[i] = ebt_f3_1[i]; - k_ebt_r0_1.view_host()[i] = ebt_r0_1[i]; - k_ebt_alpha1.view_host()[i] = ebt_alpha1[i]; - k_ebt_f1_2.view_host()[i] = ebt_f1_2[i]; - k_ebt_f2_2.view_host()[i] = ebt_f2_2[i]; - k_ebt_f3_2.view_host()[i] = ebt_f3_2[i]; - k_ebt_r0_2.view_host()[i] = ebt_r0_2[i]; - k_ebt_alpha3.view_host()[i] = ebt_alpha3[i]; - k_at_f1_1.view_host()[i] = at_f1_1[i]; - k_at_f2_1.view_host()[i] = at_f2_1[i]; - k_at_f3_1.view_host()[i] = at_f3_1[i]; - k_at_f1_2.view_host()[i] = at_f1_2[i]; - k_at_f2_2.view_host()[i] = at_f2_2[i]; - k_at_f3_2.view_host()[i] = at_f3_2[i]; - k_at_theta0_1.view_host()[i] = at_theta0_1[i]; - k_at_theta0_2.view_host()[i] = at_theta0_2[i]; - k_aat_k.view_host()[i] = aat_k[i]; - k_aat_theta0_1.view_host()[i] = aat_theta0_1[i]; - k_aat_theta0_2.view_host()[i] = aat_theta0_2[i]; - k_bb13t_d0.view_host()[i] = bb13t_d0[i]; - k_bb13t_alpha.view_host()[i] = bb13t_alpha[i]; - k_bb13t_r10.view_host()[i] = bb13t_r10[i]; - k_bb13t_r30.view_host()[i] = bb13t_r30[i]; + k_k1.view_host()[i] = static_cast(k1[i]); + k_k2.view_host()[i] = static_cast(k2[i]); + k_k3.view_host()[i] = static_cast(k3[i]); + k_phi1.view_host()[i] = static_cast(phi1[i]); + k_phi2.view_host()[i] = static_cast(phi2[i]); + k_phi3.view_host()[i] = static_cast(phi3[i]); + k_mbt_f1.view_host()[i] = static_cast(mbt_f1[i]); + k_mbt_f2.view_host()[i] = static_cast(mbt_f2[i]); + k_mbt_f3.view_host()[i] = static_cast(mbt_f3[i]); + k_mbt_r0.view_host()[i] = static_cast(mbt_r0[i]); + k_mbt_alpha2.view_host()[i] = static_cast(mbt_alpha2[i]); + k_ebt_f1_1.view_host()[i] = static_cast(ebt_f1_1[i]); + k_ebt_f2_1.view_host()[i] = static_cast(ebt_f2_1[i]); + k_ebt_f3_1.view_host()[i] = static_cast(ebt_f3_1[i]); + k_ebt_r0_1.view_host()[i] = static_cast(ebt_r0_1[i]); + k_ebt_alpha1.view_host()[i] = static_cast(ebt_alpha1[i]); + k_ebt_f1_2.view_host()[i] = static_cast(ebt_f1_2[i]); + k_ebt_f2_2.view_host()[i] = static_cast(ebt_f2_2[i]); + k_ebt_f3_2.view_host()[i] = static_cast(ebt_f3_2[i]); + k_ebt_r0_2.view_host()[i] = static_cast(ebt_r0_2[i]); + k_ebt_alpha3.view_host()[i] = static_cast(ebt_alpha3[i]); + k_at_f1_1.view_host()[i] = static_cast(at_f1_1[i]); + k_at_f2_1.view_host()[i] = static_cast(at_f2_1[i]); + k_at_f3_1.view_host()[i] = static_cast(at_f3_1[i]); + k_at_f1_2.view_host()[i] = static_cast(at_f1_2[i]); + k_at_f2_2.view_host()[i] = static_cast(at_f2_2[i]); + k_at_f3_2.view_host()[i] = static_cast(at_f3_2[i]); + k_at_theta0_1.view_host()[i] = static_cast(at_theta0_1[i]); + k_at_theta0_2.view_host()[i] = static_cast(at_theta0_2[i]); + k_aat_k.view_host()[i] = static_cast(aat_k[i]); + k_aat_theta0_1.view_host()[i] = static_cast(aat_theta0_1[i]); + k_aat_theta0_2.view_host()[i] = static_cast(aat_theta0_2[i]); + k_bb13t_d0.view_host()[i] = static_cast(bb13t_d0[i]); + k_bb13t_alpha.view_host()[i] = static_cast(bb13t_alpha[i]); + k_bb13t_r10.view_host()[i] = static_cast(bb13t_r10[i]); + k_bb13t_r30.view_host()[i] = static_cast(bb13t_r30[i]); k_setflag_d.view_host()[i] = setflag_d[i]; k_setflag_mbt.view_host()[i] = setflag_mbt[i]; k_setflag_ebt.view_host()[i] = setflag_ebt[i]; @@ -959,42 +959,42 @@ void DihedralClass2xeKokkos::read_restart(FILE *fp) d_setflag_bb13t = k_setflag_bb13t.template view(); for (int i = 1; i <= n; i++) { - k_k1.view_host()[i] = k1[i]; - k_k2.view_host()[i] = k2[i]; - k_k3.view_host()[i] = k3[i]; - k_phi1.view_host()[i] = phi1[i]; - k_phi2.view_host()[i] = phi2[i]; - k_phi3.view_host()[i] = phi3[i]; - k_mbt_f1.view_host()[i] = mbt_f1[i]; - k_mbt_f2.view_host()[i] = mbt_f2[i]; - k_mbt_f3.view_host()[i] = mbt_f3[i]; - k_mbt_r0.view_host()[i] = mbt_r0[i]; - k_mbt_alpha2.view_host()[i] = mbt_alpha2[i]; - k_ebt_f1_1.view_host()[i] = ebt_f1_1[i]; - k_ebt_f2_1.view_host()[i] = ebt_f2_1[i]; - k_ebt_f3_1.view_host()[i] = ebt_f3_1[i]; - k_ebt_r0_1.view_host()[i] = ebt_r0_1[i]; - k_ebt_alpha1.view_host()[i] = ebt_alpha1[i]; - k_ebt_f1_2.view_host()[i] = ebt_f1_2[i]; - k_ebt_f2_2.view_host()[i] = ebt_f2_2[i]; - k_ebt_f3_2.view_host()[i] = ebt_f3_2[i]; - k_ebt_r0_2.view_host()[i] = ebt_r0_2[i]; - k_ebt_alpha3.view_host()[i] = ebt_alpha3[i]; - k_at_f1_1.view_host()[i] = at_f1_1[i]; - k_at_f2_1.view_host()[i] = at_f2_1[i]; - k_at_f3_1.view_host()[i] = at_f3_1[i]; - k_at_f1_2.view_host()[i] = at_f1_2[i]; - k_at_f2_2.view_host()[i] = at_f2_2[i]; - k_at_f3_2.view_host()[i] = at_f3_2[i]; - k_at_theta0_1.view_host()[i] = at_theta0_1[i]; - k_at_theta0_2.view_host()[i] = at_theta0_2[i]; - k_aat_k.view_host()[i] = aat_k[i]; - k_aat_theta0_1.view_host()[i] = aat_theta0_1[i]; - k_aat_theta0_2.view_host()[i] = aat_theta0_2[i]; - k_bb13t_d0.view_host()[i] = bb13t_d0[i]; - k_bb13t_alpha.view_host()[i] = bb13t_alpha[i]; - k_bb13t_r10.view_host()[i] = bb13t_r10[i]; - k_bb13t_r30.view_host()[i] = bb13t_r30[i]; + k_k1.view_host()[i] = static_cast(k1[i]); + k_k2.view_host()[i] = static_cast(k2[i]); + k_k3.view_host()[i] = static_cast(k3[i]); + k_phi1.view_host()[i] = static_cast(phi1[i]); + k_phi2.view_host()[i] = static_cast(phi2[i]); + k_phi3.view_host()[i] = static_cast(phi3[i]); + k_mbt_f1.view_host()[i] = static_cast(mbt_f1[i]); + k_mbt_f2.view_host()[i] = static_cast(mbt_f2[i]); + k_mbt_f3.view_host()[i] = static_cast(mbt_f3[i]); + k_mbt_r0.view_host()[i] = static_cast(mbt_r0[i]); + k_mbt_alpha2.view_host()[i] = static_cast(mbt_alpha2[i]); + k_ebt_f1_1.view_host()[i] = static_cast(ebt_f1_1[i]); + k_ebt_f2_1.view_host()[i] = static_cast(ebt_f2_1[i]); + k_ebt_f3_1.view_host()[i] = static_cast(ebt_f3_1[i]); + k_ebt_r0_1.view_host()[i] = static_cast(ebt_r0_1[i]); + k_ebt_alpha1.view_host()[i] = static_cast(ebt_alpha1[i]); + k_ebt_f1_2.view_host()[i] = static_cast(ebt_f1_2[i]); + k_ebt_f2_2.view_host()[i] = static_cast(ebt_f2_2[i]); + k_ebt_f3_2.view_host()[i] = static_cast(ebt_f3_2[i]); + k_ebt_r0_2.view_host()[i] = static_cast(ebt_r0_2[i]); + k_ebt_alpha3.view_host()[i] = static_cast(ebt_alpha3[i]); + k_at_f1_1.view_host()[i] = static_cast(at_f1_1[i]); + k_at_f2_1.view_host()[i] = static_cast(at_f2_1[i]); + k_at_f3_1.view_host()[i] = static_cast(at_f3_1[i]); + k_at_f1_2.view_host()[i] = static_cast(at_f1_2[i]); + k_at_f2_2.view_host()[i] = static_cast(at_f2_2[i]); + k_at_f3_2.view_host()[i] = static_cast(at_f3_2[i]); + k_at_theta0_1.view_host()[i] = static_cast(at_theta0_1[i]); + k_at_theta0_2.view_host()[i] = static_cast(at_theta0_2[i]); + k_aat_k.view_host()[i] = static_cast(aat_k[i]); + k_aat_theta0_1.view_host()[i] = static_cast(aat_theta0_1[i]); + k_aat_theta0_2.view_host()[i] = static_cast(aat_theta0_2[i]); + k_bb13t_d0.view_host()[i] = static_cast(bb13t_d0[i]); + k_bb13t_alpha.view_host()[i] = static_cast(bb13t_alpha[i]); + k_bb13t_r10.view_host()[i] = static_cast(bb13t_r10[i]); + k_bb13t_r30.view_host()[i] = static_cast(bb13t_r30[i]); k_setflag_d.view_host()[i] = setflag_d[i]; k_setflag_mbt.view_host()[i] = setflag_mbt[i]; k_setflag_ebt.view_host()[i] = setflag_ebt[i]; @@ -1073,21 +1073,21 @@ void DihedralClass2xeKokkos::ev_tally(EV_FLOAT &ev, const int i1, co if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -1101,80 +1101,80 @@ void DihedralClass2xeKokkos::ev_tally(EV_FLOAT &ev, const int i1, co if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i1,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i1,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i1,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i1,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i1,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i2,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i2,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i2,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i2,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i2,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i3,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i3,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i3,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i3,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i3,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i4,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i4,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i4,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i4,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i4,5) += static_cast(0.25)*static_cast(v[5]); } } } diff --git a/src/KOKKOS/dihedral_cosine_shift_exp_kokkos.cpp b/src/KOKKOS/dihedral_cosine_shift_exp_kokkos.cpp index 2a5aabba501..586cc7c7c63 100644 --- a/src/KOKKOS/dihedral_cosine_shift_exp_kokkos.cpp +++ b/src/KOKKOS/dihedral_cosine_shift_exp_kokkos.cpp @@ -137,14 +137,14 @@ void DihedralCosineShiftExpKokkos::compute(int eflag_in, int vflag_i if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -209,25 +209,25 @@ void DihedralCosineShiftExpKokkos::operator()(TagDihedralCosineShift const KK_FLOAT rasq = ax*ax + ay*ay + az*az; const KK_FLOAT rbsq = bx*bx + by*by + bz*bz; const KK_FLOAT rgsq = vb2xm*vb2xm + vb2ym*vb2ym + vb2zm*vb2zm; - const KK_FLOAT rg = sqrt(rgsq); + const KK_FLOAT rg = Kokkos::sqrt(rgsq); KK_FLOAT rginv,ra2inv,rb2inv; rginv = ra2inv = rb2inv = 0.0; - if (rg > 0) rginv = 1.0/rg; - if (rasq > 0) ra2inv = 1.0/rasq; - if (rbsq > 0) rb2inv = 1.0/rbsq; - const KK_FLOAT rabinv = sqrt(ra2inv*rb2inv); + if (rg > 0) rginv = static_cast(1.0)/rg; + if (rasq > 0) ra2inv = static_cast(1.0)/rasq; + if (rbsq > 0) rb2inv = static_cast(1.0)/rbsq; + const KK_FLOAT rabinv = Kokkos::sqrt(ra2inv*rb2inv); KK_FLOAT c = (ax*bx + ay*by + az*bz)*rabinv; const KK_FLOAT s = rg*rabinv*(ax*vb3x + ay*vb3y + az*vb3z); // error check - if ((c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0 + TOLERANCE) || c < static_cast(-1.0 - TOLERANCE)) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; const KK_FLOAT aa = d_a[type]; const KK_FLOAT uumin = d_umin[type]; @@ -240,12 +240,12 @@ void DihedralCosineShiftExpKokkos::operator()(TagDihedralCosineShift if (d_doExpansion[type]) { // |a|<0.001 so use expansions, relative precision <1e-5 - if (EVFLAG && eflag) edihedral = -0.125*(1+cccpsss)*(4+aa*(cccpsss-1))*uumin; - df = 0.5*uumin*(cssmscc + 0.5*aa*cccpsss); + if (EVFLAG && eflag) edihedral = -static_cast(0.125)*(1+cccpsss)*(4+aa*(cccpsss-1))*uumin; + df = static_cast(0.5)*uumin*(cssmscc + static_cast(0.5)*aa*cccpsss); } else { - const KK_FLOAT exp2 = exp(0.5*aa*(1+cccpsss)); + const KK_FLOAT exp2 = Kokkos::exp(static_cast(0.5)*aa*(1+cccpsss)); if (EVFLAG && eflag) edihedral = d_opt1[type]*(1-exp2); - df = 0.5*d_opt1[type]*aa*(exp2*cssmscc); + df = static_cast(0.5)*d_opt1[type]*aa*(exp2*cssmscc); } const KK_FLOAT fg = vb1x*vb2xm + vb1y*vb2ym + vb1z*vb2zm; @@ -289,27 +289,27 @@ void DihedralCosineShiftExpKokkos::operator()(TagDihedralCosineShift // apply force to each of 4 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -362,11 +362,11 @@ void DihedralCosineShiftExpKokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_umin.view_host()[i] = umin[i]; - k_a.view_host()[i] = a[i]; - k_opt1.view_host()[i] = opt1[i]; - k_cost.view_host()[i] = cost[i]; - k_sint.view_host()[i] = sint[i]; + k_umin.view_host()[i] = static_cast(umin[i]); + k_a.view_host()[i] = static_cast(a[i]); + k_opt1.view_host()[i] = static_cast(opt1[i]); + k_cost.view_host()[i] = static_cast(cost[i]); + k_sint.view_host()[i] = static_cast(sint[i]); k_doExpansion.view_host()[i] = (int)doExpansion[i]; } @@ -389,11 +389,11 @@ void DihedralCosineShiftExpKokkos::read_restart(FILE *fp) int n = atom->ndihedraltypes; for (int i = 1; i <= n; i++) { - k_umin.view_host()[i] = umin[i]; - k_a.view_host()[i] = a[i]; - k_opt1.view_host()[i] = opt1[i]; - k_cost.view_host()[i] = cost[i]; - k_sint.view_host()[i] = sint[i]; + k_umin.view_host()[i] = static_cast(umin[i]); + k_a.view_host()[i] = static_cast(a[i]); + k_opt1.view_host()[i] = static_cast(opt1[i]); + k_cost.view_host()[i] = static_cast(cost[i]); + k_sint.view_host()[i] = static_cast(sint[i]); k_doExpansion.view_host()[i] = (int)doExpansion[i]; } @@ -431,21 +431,21 @@ void DihedralCosineShiftExpKokkos::ev_tally(EV_FLOAT &ev, const int if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -459,80 +459,80 @@ void DihedralCosineShiftExpKokkos::ev_tally(EV_FLOAT &ev, const int if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i1,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i1,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i1,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i1,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i1,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i2,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i2,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i2,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i2,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i2,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i3,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i3,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i3,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i3,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i3,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i4,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i4,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i4,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i4,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i4,5) += static_cast(static_cast(0.25)*v[5]); } } } diff --git a/src/KOKKOS/dihedral_cosine_squared_restricted_kokkos.cpp b/src/KOKKOS/dihedral_cosine_squared_restricted_kokkos.cpp index 659e153bb6e..7235530b9e9 100644 --- a/src/KOKKOS/dihedral_cosine_squared_restricted_kokkos.cpp +++ b/src/KOKKOS/dihedral_cosine_squared_restricted_kokkos.cpp @@ -135,14 +135,14 @@ void DihedralCosineSquaredRestrictedKokkos::compute(int eflag_in, in if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -197,43 +197,43 @@ void DihedralCosineSquaredRestrictedKokkos::operator()(TagDihedralCo // c0 calculation - const KK_FLOAT sb1 = 1.0 / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); - const KK_FLOAT sb2 = 1.0 / (vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); - const KK_FLOAT sb3 = 1.0 / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); + const KK_FLOAT sb1 = static_cast(1.0) / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + const KK_FLOAT sb2 = static_cast(1.0) / (vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); + const KK_FLOAT sb3 = static_cast(1.0) / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); - const KK_FLOAT rb1 = sqrt(sb1); - const KK_FLOAT rb3 = sqrt(sb3); + const KK_FLOAT rb1 = Kokkos::sqrt(sb1); + const KK_FLOAT rb3 = Kokkos::sqrt(sb3); const KK_FLOAT c0 = (vb1x*vb3x + vb1y*vb3y + vb1z*vb3z) * rb1*rb3; // 1st and 2nd angle - const KK_FLOAT b1mag2 = 1.0 / sb1; - const KK_FLOAT b1mag = sqrt(b1mag2); - const KK_FLOAT b2mag2 = 1.0 / sb2; - const KK_FLOAT b2mag = sqrt(b2mag2); - const KK_FLOAT b3mag2 = 1.0 / sb3; - const KK_FLOAT b3mag = sqrt(b3mag2); + const KK_FLOAT b1mag2 = static_cast(1.0) / sb1; + const KK_FLOAT b1mag = Kokkos::sqrt(b1mag2); + const KK_FLOAT b2mag2 = static_cast(1.0) / sb2; + const KK_FLOAT b2mag = Kokkos::sqrt(b2mag2); + const KK_FLOAT b3mag2 = static_cast(1.0) / sb3; + const KK_FLOAT b3mag = Kokkos::sqrt(b3mag2); const KK_FLOAT ctmp1 = vb1x*vb2x + vb1y*vb2y + vb1z*vb2z; - const KK_FLOAT r12c1 = 1.0 / (b1mag*b2mag); + const KK_FLOAT r12c1 = static_cast(1.0) / (b1mag*b2mag); const KK_FLOAT c1mag = ctmp1 * r12c1; const KK_FLOAT ctmp2 = vb2xm*vb3x + vb2ym*vb3y + vb2zm*vb3z; - const KK_FLOAT r12c2 = 1.0 / (b2mag*b3mag); + const KK_FLOAT r12c2 = static_cast(1.0) / (b2mag*b3mag); const KK_FLOAT c2mag = ctmp2 * r12c2; // cos and sin of 2 angles and final c - KK_FLOAT sin2 = MAX(1.0 - c1mag*c1mag, 0.0); - KK_FLOAT sc1 = sqrt(sin2); - if (sc1 < SMALL) sc1 = SMALL; - sc1 = 1.0 / sc1; + KK_FLOAT sin2 = MAX(static_cast(1.0) - c1mag*c1mag, static_cast(0.0)); + KK_FLOAT sc1 = Kokkos::sqrt(sin2); + if (sc1 < static_cast(SMALL)) sc1 = static_cast(SMALL); + sc1 = static_cast(1.0) / sc1; - sin2 = MAX(1.0 - c2mag*c2mag, 0.0); - KK_FLOAT sc2 = sqrt(sin2); - if (sc2 < SMALL) sc2 = SMALL; - sc2 = 1.0 / sc2; + sin2 = MAX(static_cast(1.0) - c2mag*c2mag, static_cast(0.0)); + KK_FLOAT sc2 = Kokkos::sqrt(sin2); + if (sc2 < static_cast(SMALL)) sc2 = static_cast(SMALL); + sc2 = static_cast(1.0) / sc2; const KK_FLOAT s1 = sc1 * sc1; const KK_FLOAT s2 = sc2 * sc2; @@ -242,18 +242,18 @@ void DihedralCosineSquaredRestrictedKokkos::operator()(TagDihedralCo // error check - if ((c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0 + TOLERANCE) || c < static_cast(-1.0 - TOLERANCE)) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; // force & energy - const KK_FLOAT p0 = cos(d_phi0[type]); - const KK_FLOAT sq_sin = 1.0 - c*c; + const KK_FLOAT p0 = Kokkos::cos(d_phi0[type]); + const KK_FLOAT sq_sin = static_cast(1.0) - c*c; - const KK_FLOAT pd = 2.0*d_k[type]*(c - p0)*(1.0 - c*p0) / (sq_sin*sq_sin); + const KK_FLOAT pd = static_cast(2.0)*d_k[type]*(c - p0)*(static_cast(1.0) - c*p0) / (sq_sin*sq_sin); KK_FLOAT edihedral = 0.0; if (EVFLAG && eflag) edihedral = d_k[type]*(c - p0)*(c - p0) / sq_sin; @@ -262,7 +262,7 @@ void DihedralCosineSquaredRestrictedKokkos::operator()(TagDihedralCo KK_FLOAT cs = c * a; KK_FLOAT s12a = s12 * a; const KK_FLOAT a11 = cs*sb1*s1; - const KK_FLOAT a22 = -sb2*(2.0*c0*s12a - cs*(s1+s2)); + const KK_FLOAT a22 = -sb2*(static_cast(2.0)*c0*s12a - cs*(s1+s2)); const KK_FLOAT a33 = cs*sb3*s2; const KK_FLOAT a12 = -r12c1*(c1mag*cs*s1 + c2mag*s12a); const KK_FLOAT a13 = -rb1*rb3*s12a; @@ -292,27 +292,27 @@ void DihedralCosineSquaredRestrictedKokkos::operator()(TagDihedralCo // apply force to each of 4 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -357,8 +357,8 @@ void DihedralCosineSquaredRestrictedKokkos::coeff(int narg, char **a utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k.view_host()[i] = k[i]; - k_phi0.view_host()[i] = phi0[i]; + k_k.view_host()[i] = static_cast(k[i]); + k_phi0.view_host()[i] = static_cast(phi0[i]); } k_k.modify_host(); @@ -376,8 +376,8 @@ void DihedralCosineSquaredRestrictedKokkos::read_restart(FILE *fp) int n = atom->ndihedraltypes; for (int i = 1; i <= n; i++) { - k_k.view_host()[i] = k[i]; - k_phi0.view_host()[i] = phi0[i]; + k_k.view_host()[i] = static_cast(k[i]); + k_phi0.view_host()[i] = static_cast(phi0[i]); } k_k.modify_host(); @@ -410,21 +410,21 @@ void DihedralCosineSquaredRestrictedKokkos::ev_tally(EV_FLOAT &ev, c if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -438,80 +438,80 @@ void DihedralCosineSquaredRestrictedKokkos::ev_tally(EV_FLOAT &ev, c if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i1,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i1,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i1,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i1,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i1,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i2,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i2,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i2,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i2,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i2,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i3,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i3,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i3,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i3,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i3,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i4,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i4,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i4,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i4,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i4,5) += static_cast(static_cast(0.25)*v[5]); } } } diff --git a/src/KOKKOS/dihedral_fourier_kokkos.cpp b/src/KOKKOS/dihedral_fourier_kokkos.cpp index 32e0ff55ea8..47522fe7783 100644 --- a/src/KOKKOS/dihedral_fourier_kokkos.cpp +++ b/src/KOKKOS/dihedral_fourier_kokkos.cpp @@ -138,14 +138,14 @@ void DihedralFourierKokkos::compute(int eflag_in, int vflag_in) if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -208,25 +208,25 @@ void DihedralFourierKokkos::operator()(TagDihedralFourierCompute 0) rginv = 1.0/rg; - if (rasq > 0) ra2inv = 1.0/rasq; - if (rbsq > 0) rb2inv = 1.0/rbsq; - const KK_FLOAT rabinv = sqrt(ra2inv*rb2inv); + if (rg > 0) rginv = static_cast(1.0)/rg; + if (rasq > 0) ra2inv = static_cast(1.0)/rasq; + if (rbsq > 0) rb2inv = static_cast(1.0)/rbsq; + const KK_FLOAT rabinv = Kokkos::sqrt(ra2inv*rb2inv); KK_FLOAT c = (ax*bx + ay*by + az*bz)*rabinv; const KK_FLOAT s = rg*rabinv*(ax*vb3x + ay*vb3y + az*vb3z); // error check - if ((c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0 + TOLERANCE) || c < static_cast(-1.0 - TOLERANCE)) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; // force and energy // p = sum(i=1,nterms) k_i*(1+cos(n_i*phi-d_i) @@ -250,10 +250,10 @@ void DihedralFourierKokkos::operator()(TagDihedralFourierCompute(1.0); if (m == 0) { - p_ = 1.0 + d_cos_shift(type,j); + p_ = static_cast(1.0) + d_cos_shift(type,j); df1_ = 0.0; } @@ -303,27 +303,27 @@ void DihedralFourierKokkos::operator()(TagDihedralFourierCompute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -386,9 +386,9 @@ void DihedralFourierKokkos::coeff(int narg, char **arg) for (int i = ilo; i <= ihi; i++) { k_nterms.view_host()[i] = nterms[i]; for (int j = 0; j < nterms[i]; j++) { - k_k.view_host()(i,j) = k[i][j]; - k_cos_shift.view_host()(i,j) = cos_shift[i][j]; - k_sin_shift.view_host()(i,j) = sin_shift[i][j]; + k_k.view_host()(i,j) = static_cast(k[i][j]); + k_cos_shift.view_host()(i,j) = static_cast(cos_shift[i][j]); + k_sin_shift.view_host()(i,j) = static_cast(sin_shift[i][j]); k_multiplicity.view_host()(i,j) = multiplicity[i][j]; } } @@ -414,9 +414,9 @@ void DihedralFourierKokkos::read_restart(FILE *fp) for (int i = 1; i <= n; i++) { k_nterms.view_host()[i] = nterms[i]; for (int j = 0; j < nterms[i]; j++) { - k_k.view_host()(i,j) = k[i][j]; - k_cos_shift.view_host()(i,j) = cos_shift[i][j]; - k_sin_shift.view_host()(i,j) = sin_shift[i][j]; + k_k.view_host()(i,j) = static_cast(k[i][j]); + k_cos_shift.view_host()(i,j) = static_cast(cos_shift[i][j]); + k_sin_shift.view_host()(i,j) = static_cast(sin_shift[i][j]); k_multiplicity.view_host()(i,j) = multiplicity[i][j]; } } @@ -454,21 +454,21 @@ void DihedralFourierKokkos::ev_tally(EV_FLOAT &ev, const int i1, con if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -482,80 +482,80 @@ void DihedralFourierKokkos::ev_tally(EV_FLOAT &ev, const int i1, con if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i1,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i1,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i1,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i1,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i1,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i2,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i2,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i2,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i2,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i2,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i3,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i3,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i3,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i3,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i3,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i4,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i4,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i4,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i4,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i4,5) += static_cast(static_cast(0.25)*v[5]); } } } diff --git a/src/KOKKOS/dihedral_harmonic_kokkos.cpp b/src/KOKKOS/dihedral_harmonic_kokkos.cpp index e670e69fbf2..b5aa96a9266 100644 --- a/src/KOKKOS/dihedral_harmonic_kokkos.cpp +++ b/src/KOKKOS/dihedral_harmonic_kokkos.cpp @@ -134,14 +134,14 @@ void DihedralHarmonicKokkos::compute(int eflag_in, int vflag_in) if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -206,25 +206,25 @@ void DihedralHarmonicKokkos::operator()(TagDihedralHarmonicCompute 0) rginv = 1.0/rg; - if (rasq > 0) ra2inv = 1.0/rasq; - if (rbsq > 0) rb2inv = 1.0/rbsq; - const KK_FLOAT rabinv = sqrt(ra2inv*rb2inv); + if (rg > 0) rginv = static_cast(1.0)/rg; + if (rasq > 0) ra2inv = static_cast(1.0)/rasq; + if (rbsq > 0) rb2inv = static_cast(1.0)/rbsq; + const KK_FLOAT rabinv = Kokkos::sqrt(ra2inv*rb2inv); KK_FLOAT c = (ax*bx + ay*by + az*bz)*rabinv; const KK_FLOAT s = rg*rabinv*(ax*vb3x + ay*vb3y + az*vb3z); // error check - if ((c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0 + TOLERANCE) || c < static_cast(-1.0 - TOLERANCE)) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; const int m = d_multiplicity[type]; KK_FLOAT p = 1.0; @@ -240,10 +240,10 @@ void DihedralHarmonicKokkos::operator()(TagDihedralHarmonicCompute(1.0); if (m == 0) { - p = 1.0 + d_cos_shift[type]; + p = static_cast(1.0) + d_cos_shift[type]; df1 = 0.0; } @@ -293,27 +293,27 @@ void DihedralHarmonicKokkos::operator()(TagDihedralHarmonicCompute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -364,9 +364,9 @@ void DihedralHarmonicKokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k.view_host()[i] = k[i]; - k_cos_shift.view_host()[i] = cos_shift[i]; - k_sin_shift.view_host()[i] = sin_shift[i]; + k_k.view_host()[i] = static_cast(k[i]); + k_cos_shift.view_host()[i] = static_cast(cos_shift[i]); + k_sin_shift.view_host()[i] = static_cast(sin_shift[i]); k_sign.view_host()[i] = sign[i]; k_multiplicity.view_host()[i] = multiplicity[i]; } @@ -389,9 +389,9 @@ void DihedralHarmonicKokkos::read_restart(FILE *fp) int n = atom->ndihedraltypes; for (int i = 1; i <= n; i++) { - k_k.view_host()[i] = k[i]; - k_cos_shift.view_host()[i] = cos_shift[i]; - k_sin_shift.view_host()[i] = sin_shift[i]; + k_k.view_host()[i] = static_cast(k[i]); + k_cos_shift.view_host()[i] = static_cast(cos_shift[i]); + k_sin_shift.view_host()[i] = static_cast(sin_shift[i]); k_sign.view_host()[i] = sign[i]; k_multiplicity.view_host()[i] = multiplicity[i]; } @@ -429,21 +429,21 @@ void DihedralHarmonicKokkos::ev_tally(EV_FLOAT &ev, const int i1, co if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -457,80 +457,80 @@ void DihedralHarmonicKokkos::ev_tally(EV_FLOAT &ev, const int i1, co if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i1,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i1,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i1,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i1,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i1,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i2,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i2,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i2,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i2,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i2,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i3,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i3,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i3,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i3,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i3,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i4,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i4,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i4,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i4,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i4,5) += static_cast(static_cast(0.25)*v[5]); } } } diff --git a/src/KOKKOS/dihedral_helix_kokkos.cpp b/src/KOKKOS/dihedral_helix_kokkos.cpp index f0f79ab8f80..5987fee5964 100644 --- a/src/KOKKOS/dihedral_helix_kokkos.cpp +++ b/src/KOKKOS/dihedral_helix_kokkos.cpp @@ -137,14 +137,14 @@ void DihedralHelixKokkos::compute(int eflag_in, int vflag_in) if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -199,43 +199,43 @@ void DihedralHelixKokkos::operator()(TagDihedralHelixCompute(1.0) / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + const KK_FLOAT sb2 = static_cast(1.0) / (vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); + const KK_FLOAT sb3 = static_cast(1.0) / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); - const KK_FLOAT rb1 = sqrt(sb1); - const KK_FLOAT rb3 = sqrt(sb3); + const KK_FLOAT rb1 = Kokkos::sqrt(sb1); + const KK_FLOAT rb3 = Kokkos::sqrt(sb3); const KK_FLOAT c0 = (vb1x*vb3x + vb1y*vb3y + vb1z*vb3z) * rb1*rb3; // 1st and 2nd angle - const KK_FLOAT b1mag2 = 1.0 / sb1; - const KK_FLOAT b1mag = sqrt(b1mag2); - const KK_FLOAT b2mag2 = 1.0 / sb2; - const KK_FLOAT b2mag = sqrt(b2mag2); - const KK_FLOAT b3mag2 = 1.0 / sb3; - const KK_FLOAT b3mag = sqrt(b3mag2); + const KK_FLOAT b1mag2 = static_cast(1.0) / sb1; + const KK_FLOAT b1mag = Kokkos::sqrt(b1mag2); + const KK_FLOAT b2mag2 = static_cast(1.0) / sb2; + const KK_FLOAT b2mag = Kokkos::sqrt(b2mag2); + const KK_FLOAT b3mag2 = static_cast(1.0) / sb3; + const KK_FLOAT b3mag = Kokkos::sqrt(b3mag2); const KK_FLOAT ctmp1 = vb1x*vb2x + vb1y*vb2y + vb1z*vb2z; - const KK_FLOAT r12c1 = 1.0 / (b1mag*b2mag); + const KK_FLOAT r12c1 = static_cast(1.0) / (b1mag*b2mag); const KK_FLOAT c1mag = ctmp1 * r12c1; const KK_FLOAT ctmp2 = vb2xm*vb3x + vb2ym*vb3y + vb2zm*vb3z; - const KK_FLOAT r12c2 = 1.0 / (b2mag*b3mag); + const KK_FLOAT r12c2 = static_cast(1.0) / (b2mag*b3mag); const KK_FLOAT c2mag = ctmp2 * r12c2; // cos and sin of 2 angles and final c - KK_FLOAT sin2 = MAX(1.0 - c1mag*c1mag, 0.0); - KK_FLOAT sc1 = sqrt(sin2); - if (sc1 < SMALL) sc1 = SMALL; - sc1 = 1.0 / sc1; + KK_FLOAT sin2 = MAX(static_cast(1.0) - c1mag*c1mag, static_cast(0.0)); + KK_FLOAT sc1 = Kokkos::sqrt(sin2); + if (sc1 < static_cast(SMALL)) sc1 = static_cast(SMALL); + sc1 = static_cast(1.0) / sc1; - sin2 = MAX(1.0 - c2mag*c2mag, 0.0); - KK_FLOAT sc2 = sqrt(sin2); - if (sc2 < SMALL) sc2 = SMALL; - sc2 = 1.0 / sc2; + sin2 = MAX(static_cast(1.0) - c2mag*c2mag, static_cast(0.0)); + KK_FLOAT sc2 = Kokkos::sqrt(sin2); + if (sc2 < static_cast(SMALL)) sc2 = static_cast(SMALL); + sc2 = static_cast(1.0) / sc2; const KK_FLOAT s1 = sc1 * sc1; const KK_FLOAT s2 = sc2 * sc2; @@ -245,27 +245,27 @@ void DihedralHelixKokkos::operator()(TagDihedralHelixCompute 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0 + TOLERANCE) || c < static_cast(-1.0 - TOLERANCE)) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; - KK_FLOAT phi = acos(c); - if (dx > 0.0) phi *= -1.0; - KK_FLOAT si = sin(phi); - if (fabs(si) < SMALLER) si = SMALLER; - const KK_FLOAT siinv = 1.0/si; + KK_FLOAT phi = Kokkos::acos(c); + if (dx > static_cast(0.0)) phi *= static_cast(-1.0); + KK_FLOAT si = Kokkos::sin(phi); + if (Kokkos::fabs(si) < static_cast(SMALLER)) si = static_cast(SMALLER); + const KK_FLOAT siinv = static_cast(1.0)/si; - const KK_FLOAT p = d_aphi[type]*(1.0 - c) + d_bphi[type]*(1.0 + cos(3.0*phi)) + - d_cphi[type]*(1.0 + cos(phi + MY_PI4)); - const KK_FLOAT pd = -d_aphi[type] + 3.0*d_bphi[type]*sin(3.0*phi)*siinv + - d_cphi[type]*sin(phi + MY_PI4)*siinv; + const KK_FLOAT p = d_aphi[type]*(static_cast(1.0) - c) + d_bphi[type]*(static_cast(1.0) + Kokkos::cos(static_cast(3.0)*phi)) + + d_cphi[type]*(static_cast(1.0) + Kokkos::cos(phi + static_cast(MY_PI4))); + const KK_FLOAT pd = -d_aphi[type] + static_cast(3.0)*d_bphi[type]*Kokkos::sin(static_cast(3.0)*phi)*siinv + + d_cphi[type]*Kokkos::sin(phi + static_cast(MY_PI4))*siinv; KK_FLOAT edihedral = 0.0; if (EVFLAG && eflag) edihedral = p; @@ -274,7 +274,7 @@ void DihedralHelixKokkos::operator()(TagDihedralHelixCompute(2.0)*c0*s12a - ca*(s1+s2)); const KK_FLOAT a33 = ca*sb3*s2; const KK_FLOAT a12 = -r12c1*(c1mag*ca*s1 + c2mag*s12a); const KK_FLOAT a13 = -rb1*rb3*s12a; @@ -304,27 +304,27 @@ void DihedralHelixKokkos::operator()(TagDihedralHelixCompute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -371,9 +371,9 @@ void DihedralHelixKokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_aphi.view_host()[i] = aphi[i]; - k_bphi.view_host()[i] = bphi[i]; - k_cphi.view_host()[i] = cphi[i]; + k_aphi.view_host()[i] = static_cast(aphi[i]); + k_bphi.view_host()[i] = static_cast(bphi[i]); + k_cphi.view_host()[i] = static_cast(cphi[i]); } k_aphi.modify_host(); @@ -392,9 +392,9 @@ void DihedralHelixKokkos::read_restart(FILE *fp) int n = atom->ndihedraltypes; for (int i = 1; i <= n; i++) { - k_aphi.view_host()[i] = aphi[i]; - k_bphi.view_host()[i] = bphi[i]; - k_cphi.view_host()[i] = cphi[i]; + k_aphi.view_host()[i] = static_cast(aphi[i]); + k_bphi.view_host()[i] = static_cast(bphi[i]); + k_cphi.view_host()[i] = static_cast(cphi[i]); } k_aphi.modify_host(); @@ -428,21 +428,21 @@ void DihedralHelixKokkos::ev_tally(EV_FLOAT &ev, const int i1, const if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -456,80 +456,80 @@ void DihedralHelixKokkos::ev_tally(EV_FLOAT &ev, const int i1, const if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i1,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i1,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i1,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i1,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i1,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i2,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i2,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i2,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i2,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i2,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i3,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i3,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i3,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i3,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i3,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i4,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i4,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i4,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i4,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i4,5) += static_cast(static_cast(0.25)*v[5]); } } } diff --git a/src/KOKKOS/dihedral_multi_harmonic_kokkos.cpp b/src/KOKKOS/dihedral_multi_harmonic_kokkos.cpp index 904f5f67af8..86a15cffbe5 100644 --- a/src/KOKKOS/dihedral_multi_harmonic_kokkos.cpp +++ b/src/KOKKOS/dihedral_multi_harmonic_kokkos.cpp @@ -135,14 +135,14 @@ void DihedralMultiHarmonicKokkos::compute(int eflag_in, int vflag_in if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -197,43 +197,43 @@ void DihedralMultiHarmonicKokkos::operator()(TagDihedralMultiHarmoni // c0 calculation - const KK_FLOAT sb1 = 1.0 / (vb1x * vb1x + vb1y * vb1y + vb1z * vb1z); - const KK_FLOAT sb2 = 1.0 / (vb2x * vb2x + vb2y * vb2y + vb2z * vb2z); - const KK_FLOAT sb3 = 1.0 / (vb3x * vb3x + vb3y * vb3y + vb3z * vb3z); + const KK_FLOAT sb1 = static_cast(1.0) / (vb1x * vb1x + vb1y * vb1y + vb1z * vb1z); + const KK_FLOAT sb2 = static_cast(1.0) / (vb2x * vb2x + vb2y * vb2y + vb2z * vb2z); + const KK_FLOAT sb3 = static_cast(1.0) / (vb3x * vb3x + vb3y * vb3y + vb3z * vb3z); - const KK_FLOAT rb1 = sqrt(sb1); - const KK_FLOAT rb3 = sqrt(sb3); + const KK_FLOAT rb1 = Kokkos::sqrt(sb1); + const KK_FLOAT rb3 = Kokkos::sqrt(sb3); KK_FLOAT c0 = (vb1x * vb3x + vb1y * vb3y + vb1z * vb3z) * rb1 * rb3; // 1st and 2nd angle KK_FLOAT b1mag2 = vb1x * vb1x + vb1y * vb1y + vb1z * vb1z; - KK_FLOAT b1mag = sqrt(b1mag2); + KK_FLOAT b1mag = Kokkos::sqrt(b1mag2); KK_FLOAT b2mag2 = vb2x * vb2x + vb2y * vb2y + vb2z * vb2z; - KK_FLOAT b2mag = sqrt(b2mag2); + KK_FLOAT b2mag = Kokkos::sqrt(b2mag2); KK_FLOAT b3mag2 = vb3x * vb3x + vb3y * vb3y + vb3z * vb3z; - KK_FLOAT b3mag = sqrt(b3mag2); + KK_FLOAT b3mag = Kokkos::sqrt(b3mag2); KK_FLOAT ctmp = vb1x * vb2x + vb1y * vb2y + vb1z * vb2z; - KK_FLOAT r12c1 = 1.0 / (b1mag * b2mag); + KK_FLOAT r12c1 = static_cast(1.0) / (b1mag * b2mag); KK_FLOAT c1mag = ctmp * r12c1; ctmp = vb2xm * vb3x + vb2ym * vb3y + vb2zm * vb3z; - KK_FLOAT r12c2 = 1.0 / (b2mag * b3mag); + KK_FLOAT r12c2 = static_cast(1.0) / (b2mag * b3mag); KK_FLOAT c2mag = ctmp * r12c2; // cos and sin of 2 angles and final c - KK_FLOAT sin2 = MAX(1.0 - c1mag * c1mag, 0.0); - KK_FLOAT sc1 = sqrt(sin2); - if (sc1 < SMALL) sc1 = SMALL; - sc1 = 1.0 / sc1; + KK_FLOAT sin2 = MAX(static_cast(1.0) - c1mag * c1mag, static_cast(0.0)); + KK_FLOAT sc1 = Kokkos::sqrt(sin2); + if (sc1 < static_cast(SMALL)) sc1 = static_cast(SMALL); + sc1 = static_cast(1.0) / sc1; - sin2 = MAX(1.0 - c2mag * c2mag, 0.0); - KK_FLOAT sc2 = sqrt(sin2); - if (sc2 < SMALL) sc2 = SMALL; - sc2 = 1.0 / sc2; + sin2 = MAX(static_cast(1.0) - c2mag * c2mag, static_cast(0.0)); + KK_FLOAT sc2 = Kokkos::sqrt(sin2); + if (sc2 < static_cast(SMALL)) sc2 = static_cast(SMALL); + sc2 = static_cast(1.0) / sc2; KK_FLOAT s1 = sc1 * sc1; KK_FLOAT s2 = sc2 * sc2; @@ -242,18 +242,18 @@ void DihedralMultiHarmonicKokkos::operator()(TagDihedralMultiHarmoni // error check - if ((c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0 + TOLERANCE) || c < static_cast(-1.0 - TOLERANCE)) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; // force & energy // p = sum (i=1,5) a_i * c**(i-1) // pd = dp/dc KK_FLOAT p = d_a1[type] + c * (d_a2[type] + c * (d_a3[type] + c * (d_a4[type] + c * d_a5[type]))); - KK_FLOAT pd = d_a2[type] + c * (2.0 * d_a3[type] + c * (3.0 * d_a4[type] + c * 4.0 * d_a5[type])); + KK_FLOAT pd = d_a2[type] + c * (static_cast(2.0) * d_a3[type] + c * (static_cast(3.0) * d_a4[type] + c * static_cast(4.0) * d_a5[type])); KK_FLOAT edihedral = 0.0; if (eflag) edihedral = p; @@ -262,7 +262,7 @@ void DihedralMultiHarmonicKokkos::operator()(TagDihedralMultiHarmoni c = c * a; s12 = s12 * a; const KK_FLOAT a11 = c * sb1 * s1; - const KK_FLOAT a22 = -sb2 * (2.0 * c0 * s12 - c * (s1 + s2)); + const KK_FLOAT a22 = -sb2 * (static_cast(2.0) * c0 * s12 - c * (s1 + s2)); const KK_FLOAT a33 = c * sb3 * s2; const KK_FLOAT a12 = -r12c1 * (c1mag * c * s1 + c2mag * s12); const KK_FLOAT a13 = -rb1 * rb3 * s12; @@ -292,27 +292,27 @@ void DihedralMultiHarmonicKokkos::operator()(TagDihedralMultiHarmoni // apply force to each of 4 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -363,11 +363,11 @@ void DihedralMultiHarmonicKokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_a1.view_host()[i] = a1[i]; - k_a2.view_host()[i] = a2[i]; - k_a3.view_host()[i] = a3[i]; - k_a4.view_host()[i] = a4[i]; - k_a5.view_host()[i] = a5[i]; + k_a1.view_host()[i] = static_cast(a1[i]); + k_a2.view_host()[i] = static_cast(a2[i]); + k_a3.view_host()[i] = static_cast(a3[i]); + k_a4.view_host()[i] = static_cast(a4[i]); + k_a5.view_host()[i] = static_cast(a5[i]); } k_a1.modify_host(); @@ -388,11 +388,11 @@ void DihedralMultiHarmonicKokkos::read_restart(FILE *fp) int n = atom->ndihedraltypes; for (int i = 1; i <= n; i++) { - k_a1.view_host()[i] = a1[i]; - k_a2.view_host()[i] = a2[i]; - k_a3.view_host()[i] = a3[i]; - k_a4.view_host()[i] = a4[i]; - k_a5.view_host()[i] = a5[i]; + k_a1.view_host()[i] = static_cast(a1[i]); + k_a2.view_host()[i] = static_cast(a2[i]); + k_a3.view_host()[i] = static_cast(a3[i]); + k_a4.view_host()[i] = static_cast(a4[i]); + k_a5.view_host()[i] = static_cast(a5[i]); } k_a1.modify_host(); @@ -428,21 +428,21 @@ void DihedralMultiHarmonicKokkos::ev_tally(EV_FLOAT &ev, const int i if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -456,80 +456,80 @@ void DihedralMultiHarmonicKokkos::ev_tally(EV_FLOAT &ev, const int i if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i1,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i1,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i1,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i1,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i1,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i2,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i2,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i2,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i2,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i2,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i3,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i3,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i3,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i3,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i3,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i4,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i4,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i4,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i4,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i4,5) += static_cast(static_cast(0.25)*v[5]); } } } diff --git a/src/KOKKOS/dihedral_nharmonic_kokkos.cpp b/src/KOKKOS/dihedral_nharmonic_kokkos.cpp index 2de03c673ef..a484f7300d1 100644 --- a/src/KOKKOS/dihedral_nharmonic_kokkos.cpp +++ b/src/KOKKOS/dihedral_nharmonic_kokkos.cpp @@ -135,14 +135,14 @@ void DihedralNHarmonicKokkos::compute(int eflag_in, int vflag_in) if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -197,43 +197,43 @@ void DihedralNHarmonicKokkos::operator()(TagDihedralNHarmonicCompute // c0 calculation - const KK_FLOAT sb1 = 1.0 / (vb1x * vb1x + vb1y * vb1y + vb1z * vb1z); - const KK_FLOAT sb2 = 1.0 / (vb2x * vb2x + vb2y * vb2y + vb2z * vb2z); - const KK_FLOAT sb3 = 1.0 / (vb3x * vb3x + vb3y * vb3y + vb3z * vb3z); + const KK_FLOAT sb1 = static_cast(1.0) / (vb1x * vb1x + vb1y * vb1y + vb1z * vb1z); + const KK_FLOAT sb2 = static_cast(1.0) / (vb2x * vb2x + vb2y * vb2y + vb2z * vb2z); + const KK_FLOAT sb3 = static_cast(1.0) / (vb3x * vb3x + vb3y * vb3y + vb3z * vb3z); - const KK_FLOAT rb1 = sqrt(sb1); - const KK_FLOAT rb3 = sqrt(sb3); + const KK_FLOAT rb1 = Kokkos::sqrt(sb1); + const KK_FLOAT rb3 = Kokkos::sqrt(sb3); KK_FLOAT c0 = (vb1x * vb3x + vb1y * vb3y + vb1z * vb3z) * rb1 * rb3; // 1st and 2nd angle KK_FLOAT b1mag2 = vb1x * vb1x + vb1y * vb1y + vb1z * vb1z; - KK_FLOAT b1mag = sqrt(b1mag2); + KK_FLOAT b1mag = Kokkos::sqrt(b1mag2); KK_FLOAT b2mag2 = vb2x * vb2x + vb2y * vb2y + vb2z * vb2z; - KK_FLOAT b2mag = sqrt(b2mag2); + KK_FLOAT b2mag = Kokkos::sqrt(b2mag2); KK_FLOAT b3mag2 = vb3x * vb3x + vb3y * vb3y + vb3z * vb3z; - KK_FLOAT b3mag = sqrt(b3mag2); + KK_FLOAT b3mag = Kokkos::sqrt(b3mag2); KK_FLOAT ctmp = vb1x * vb2x + vb1y * vb2y + vb1z * vb2z; - KK_FLOAT r12c1 = 1.0 / (b1mag * b2mag); + KK_FLOAT r12c1 = static_cast(1.0) / (b1mag * b2mag); KK_FLOAT c1mag = ctmp * r12c1; ctmp = vb2xm * vb3x + vb2ym * vb3y + vb2zm * vb3z; - KK_FLOAT r12c2 = 1.0 / (b2mag * b3mag); + KK_FLOAT r12c2 = static_cast(1.0) / (b2mag * b3mag); KK_FLOAT c2mag = ctmp * r12c2; // cos and sin of 2 angles and final c - KK_FLOAT sin2 = MAX(1.0 - c1mag * c1mag, 0.0); - KK_FLOAT sc1 = sqrt(sin2); - if (sc1 < SMALL) sc1 = SMALL; - sc1 = 1.0 / sc1; + KK_FLOAT sin2 = MAX(static_cast(1.0) - c1mag * c1mag, static_cast(0.0)); + KK_FLOAT sc1 = Kokkos::sqrt(sin2); + if (sc1 < static_cast(SMALL)) sc1 = static_cast(SMALL); + sc1 = static_cast(1.0) / sc1; - sin2 = MAX(1.0 - c2mag * c2mag, 0.0); - KK_FLOAT sc2 = sqrt(sin2); - if (sc2 < SMALL) sc2 = SMALL; - sc2 = 1.0 / sc2; + sin2 = MAX(static_cast(1.0) - c2mag * c2mag, static_cast(0.0)); + KK_FLOAT sc2 = Kokkos::sqrt(sin2); + if (sc2 < static_cast(SMALL)) sc2 = static_cast(SMALL); + sc2 = static_cast(1.0) / sc2; KK_FLOAT s1 = sc1 * sc1; KK_FLOAT s2 = sc2 * sc2; @@ -242,11 +242,11 @@ void DihedralNHarmonicKokkos::operator()(TagDihedralNHarmonicCompute // error check - if ((c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0 + TOLERANCE) || c < static_cast(-1.0 - TOLERANCE)) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; // force & energy // p = sum (i=1,n) a_i * c**(i-1) @@ -268,7 +268,7 @@ void DihedralNHarmonicKokkos::operator()(TagDihedralNHarmonicCompute c = c * pd; s12 = s12 * pd; const KK_FLOAT a11 = c * sb1 * s1; - const KK_FLOAT a22 = -sb2 * (2.0 * c0 * s12 - c * (s1 + s2)); + const KK_FLOAT a22 = -sb2 * (static_cast(2.0) * c0 * s12 - c * (s1 + s2)); const KK_FLOAT a33 = c * sb3 * s2; const KK_FLOAT a12 = -r12c1 * (c1mag * c * s1 + c2mag * s12); const KK_FLOAT a13 = -rb1 * rb3 * s12; @@ -298,27 +298,27 @@ void DihedralNHarmonicKokkos::operator()(TagDihedralNHarmonicCompute // apply force to each of 4 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -372,7 +372,7 @@ void DihedralNHarmonicKokkos::coeff(int narg, char **arg) for (int i = ilo; i <= ihi; i++) { k_nterms.view_host()[i] = nterms[i]; for (int j = 0; j < nterms[i]; j++) - k_a.view_host()(i,j) = a[i][j]; + k_a.view_host()(i,j) = static_cast(a[i][j]); } k_a.modify_host(); @@ -393,7 +393,7 @@ void DihedralNHarmonicKokkos::read_restart(FILE *fp) for (int i = 1; i <= n; i++) { k_nterms.view_host()[i] = nterms[i]; for (int j = 0; j < nterms[i]; j++) - k_a.view_host()(i,j) = a[i][j]; + k_a.view_host()(i,j) = static_cast(a[i][j]); } k_a.modify_host(); @@ -426,21 +426,21 @@ void DihedralNHarmonicKokkos::ev_tally(EV_FLOAT &ev, const int i1, c if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -454,80 +454,80 @@ void DihedralNHarmonicKokkos::ev_tally(EV_FLOAT &ev, const int i1, c if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i1,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i1,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i1,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i1,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i1,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i2,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i2,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i2,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i2,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i2,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i3,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i3,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i3,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i3,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i3,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i4,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i4,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i4,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i4,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i4,5) += static_cast(static_cast(0.25)*v[5]); } } } diff --git a/src/KOKKOS/dihedral_opls_kokkos.cpp b/src/KOKKOS/dihedral_opls_kokkos.cpp index 58d0f0c33c5..728192bef34 100644 --- a/src/KOKKOS/dihedral_opls_kokkos.cpp +++ b/src/KOKKOS/dihedral_opls_kokkos.cpp @@ -131,14 +131,14 @@ void DihedralOPLSKokkos::compute(int eflag_in, int vflag_in) if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -193,43 +193,43 @@ void DihedralOPLSKokkos::operator()(TagDihedralOPLSCompute(1.0) / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + const KK_FLOAT sb2 = static_cast(1.0) / (vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); + const KK_FLOAT sb3 = static_cast(1.0) / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); - const KK_FLOAT rb1 = sqrt(sb1); - const KK_FLOAT rb3 = sqrt(sb3); + const KK_FLOAT rb1 = Kokkos::sqrt(sb1); + const KK_FLOAT rb3 = Kokkos::sqrt(sb3); const KK_FLOAT c0 = (vb1x*vb3x + vb1y*vb3y + vb1z*vb3z) * rb1*rb3; // 1st and 2nd angle const KK_FLOAT b1mag2 = vb1x*vb1x + vb1y*vb1y + vb1z*vb1z; - const KK_FLOAT b1mag = sqrt(b1mag2); + const KK_FLOAT b1mag = Kokkos::sqrt(b1mag2); const KK_FLOAT b2mag2 = vb2x*vb2x + vb2y*vb2y + vb2z*vb2z; - const KK_FLOAT b2mag = sqrt(b2mag2); + const KK_FLOAT b2mag = Kokkos::sqrt(b2mag2); const KK_FLOAT b3mag2 = vb3x*vb3x + vb3y*vb3y + vb3z*vb3z; - const KK_FLOAT b3mag = sqrt(b3mag2); + const KK_FLOAT b3mag = Kokkos::sqrt(b3mag2); KK_FLOAT ctmp = vb1x*vb2x + vb1y*vb2y + vb1z*vb2z; - const KK_FLOAT r12c1 = 1.0 / (b1mag*b2mag); + const KK_FLOAT r12c1 = static_cast(1.0) / (b1mag*b2mag); const KK_FLOAT c1mag = ctmp * r12c1; ctmp = vb2xm*vb3x + vb2ym*vb3y + vb2zm*vb3z; - const KK_FLOAT r12c2 = 1.0 / (b2mag*b3mag); + const KK_FLOAT r12c2 = static_cast(1.0) / (b2mag*b3mag); const KK_FLOAT c2mag = ctmp * r12c2; // cos and sin of 2 angles and final c - KK_FLOAT sin2 = MAX(1.0 - c1mag*c1mag,0.0); - KK_FLOAT sc1 = sqrt(sin2); - if (sc1 < SMALL) sc1 = SMALL; - sc1 = 1.0/sc1; + KK_FLOAT sin2 = MAX(static_cast(1.0) - c1mag*c1mag,static_cast(0.0)); + KK_FLOAT sc1 = Kokkos::sqrt(sin2); + if (sc1 < static_cast(SMALL)) sc1 = static_cast(SMALL); + sc1 = static_cast(1.0)/sc1; - sin2 = MAX(1.0 - c2mag*c2mag,0.0); - KK_FLOAT sc2 = sqrt(sin2); - if (sc2 < SMALL) sc2 = SMALL; - sc2 = 1.0/sc2; + sin2 = MAX(static_cast(1.0) - c2mag*c2mag,static_cast(0.0)); + KK_FLOAT sc2 = Kokkos::sqrt(sin2); + if (sc2 < static_cast(SMALL)) sc2 = static_cast(SMALL); + sc2 = static_cast(1.0)/sc2; const KK_FLOAT s1 = sc1 * sc1; const KK_FLOAT s2 = sc2 * sc2; @@ -239,31 +239,31 @@ void DihedralOPLSKokkos::operator()(TagDihedralOPLSCompute 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0 + TOLERANCE) || c < static_cast(-1.0 - TOLERANCE)) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; // force & energy // p = sum (i=1,4) k_i * (1 + (-1)**(i+1)*cos(i*phi) ) // pd = dp/dc - KK_FLOAT phi = acos(c); - if (dx < 0.0) phi *= -1.0; - KK_FLOAT si = sin(phi); - if (fabs(si) < SMALLER) si = SMALLER; - const KK_FLOAT siinv = 1.0/si; + KK_FLOAT phi = Kokkos::acos(c); + if (dx < static_cast(0.0)) phi *= static_cast(-1.0); + KK_FLOAT si = Kokkos::sin(phi); + if (Kokkos::fabs(si) < static_cast(SMALLER)) si = static_cast(SMALLER); + const KK_FLOAT siinv = static_cast(1.0)/si; - const KK_FLOAT p = d_k1[type]*(1.0 + c) + d_k2[type]*(1.0 - cos(2.0*phi)) + - d_k3[type]*(1.0 + cos(3.0*phi)) + d_k4[type]*(1.0 - cos(4.0*phi)) ; - const KK_FLOAT pd = d_k1[type] - 2.0*d_k2[type]*sin(2.0*phi)*siinv + - 3.0*d_k3[type]*sin(3.0*phi)*siinv - 4.0*d_k4[type]*sin(4.0*phi)*siinv; + const KK_FLOAT p = d_k1[type]*(static_cast(1.0) + c) + d_k2[type]*(static_cast(1.0) - Kokkos::cos(static_cast(2.0)*phi)) + + d_k3[type]*(static_cast(1.0) + Kokkos::cos(static_cast(3.0)*phi)) + d_k4[type]*(static_cast(1.0) - Kokkos::cos(static_cast(4.0)*phi)) ; + const KK_FLOAT pd = d_k1[type] - static_cast(2.0)*d_k2[type]*Kokkos::sin(static_cast(2.0)*phi)*siinv + + static_cast(3.0)*d_k3[type]*Kokkos::sin(static_cast(3.0)*phi)*siinv - static_cast(4.0)*d_k4[type]*Kokkos::sin(static_cast(4.0)*phi)*siinv; KK_FLOAT edihedral = 0.0; if (eflag) edihedral = p; @@ -272,7 +272,7 @@ void DihedralOPLSKokkos::operator()(TagDihedralOPLSCompute(2.0)*c0*s12 - c*(s1+s2)); const KK_FLOAT a33 = c*sb3*s2; const KK_FLOAT a12 = -r12c1 * (c1mag*c*s1 + c2mag*s12); const KK_FLOAT a13 = -rb1*rb3*s12; @@ -302,27 +302,27 @@ void DihedralOPLSKokkos::operator()(TagDihedralOPLSCompute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -371,10 +371,10 @@ void DihedralOPLSKokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k1.view_host()[i] = k1[i]; - k_k2.view_host()[i] = k2[i]; - k_k3.view_host()[i] = k3[i]; - k_k4.view_host()[i] = k4[i]; + k_k1.view_host()[i] = static_cast(k1[i]); + k_k2.view_host()[i] = static_cast(k2[i]); + k_k3.view_host()[i] = static_cast(k3[i]); + k_k4.view_host()[i] = static_cast(k4[i]); } k_k1.modify_host(); @@ -394,10 +394,10 @@ void DihedralOPLSKokkos::read_restart(FILE *fp) int n = atom->ndihedraltypes; for (int i = 1; i <= n; i++) { - k_k1.view_host()[i] = k1[i]; - k_k2.view_host()[i] = k2[i]; - k_k3.view_host()[i] = k3[i]; - k_k4.view_host()[i] = k4[i]; + k_k1.view_host()[i] = static_cast(k1[i]); + k_k2.view_host()[i] = static_cast(k2[i]); + k_k3.view_host()[i] = static_cast(k3[i]); + k_k4.view_host()[i] = static_cast(k4[i]); } k_k1.modify_host(); @@ -432,21 +432,21 @@ void DihedralOPLSKokkos::ev_tally(EV_FLOAT &ev, const int i1, const if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -460,80 +460,80 @@ void DihedralOPLSKokkos::ev_tally(EV_FLOAT &ev, const int i1, const if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i1,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i1,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i1,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i1,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i1,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i2,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i2,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i2,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i2,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i2,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i3,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i3,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i3,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i3,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i3,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i4,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i4,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i4,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i4,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i4,5) += static_cast(static_cast(0.25)*v[5]); } } } diff --git a/src/KOKKOS/dihedral_quadratic_kokkos.cpp b/src/KOKKOS/dihedral_quadratic_kokkos.cpp index fa09a516a16..45039fca116 100644 --- a/src/KOKKOS/dihedral_quadratic_kokkos.cpp +++ b/src/KOKKOS/dihedral_quadratic_kokkos.cpp @@ -136,14 +136,14 @@ void DihedralQuadraticKokkos::compute(int eflag_in, int vflag_in) if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -198,43 +198,43 @@ void DihedralQuadraticKokkos::operator()(TagDihedralQuadraticCompute // c0 calculation - const KK_FLOAT sb1 = 1.0 / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); - const KK_FLOAT sb2 = 1.0 / (vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); - const KK_FLOAT sb3 = 1.0 / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); + const KK_FLOAT sb1 = static_cast(1.0) / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + const KK_FLOAT sb2 = static_cast(1.0) / (vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); + const KK_FLOAT sb3 = static_cast(1.0) / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); - const KK_FLOAT rb1 = sqrt(sb1); - const KK_FLOAT rb3 = sqrt(sb3); + const KK_FLOAT rb1 = Kokkos::sqrt(sb1); + const KK_FLOAT rb3 = Kokkos::sqrt(sb3); const KK_FLOAT c0 = (vb1x*vb3x + vb1y*vb3y + vb1z*vb3z) * rb1*rb3; // 1st and 2nd angle - const KK_FLOAT b1mag2 = 1.0 / sb1; - const KK_FLOAT b1mag = sqrt(b1mag2); - const KK_FLOAT b2mag2 = 1.0 / sb2; - const KK_FLOAT b2mag = sqrt(b2mag2); - const KK_FLOAT b3mag2 = 1.0 / sb3; - const KK_FLOAT b3mag = sqrt(b3mag2); + const KK_FLOAT b1mag2 = static_cast(1.0) / sb1; + const KK_FLOAT b1mag = Kokkos::sqrt(b1mag2); + const KK_FLOAT b2mag2 = static_cast(1.0) / sb2; + const KK_FLOAT b2mag = Kokkos::sqrt(b2mag2); + const KK_FLOAT b3mag2 = static_cast(1.0) / sb3; + const KK_FLOAT b3mag = Kokkos::sqrt(b3mag2); const KK_FLOAT ctmp1 = vb1x*vb2x + vb1y*vb2y + vb1z*vb2z; - const KK_FLOAT r12c1 = 1.0 / (b1mag*b2mag); + const KK_FLOAT r12c1 = static_cast(1.0) / (b1mag*b2mag); const KK_FLOAT c1mag = ctmp1 * r12c1; const KK_FLOAT ctmp2 = vb2xm*vb3x + vb2ym*vb3y + vb2zm*vb3z; - const KK_FLOAT r12c2 = 1.0 / (b2mag*b3mag); + const KK_FLOAT r12c2 = static_cast(1.0) / (b2mag*b3mag); const KK_FLOAT c2mag = ctmp2 * r12c2; // cos and sin of 2 angles and final c - KK_FLOAT sin2 = MAX(1.0 - c1mag*c1mag, 0.0); - KK_FLOAT sc1 = sqrt(sin2); - if (sc1 < SMALL) sc1 = SMALL; - sc1 = 1.0 / sc1; + KK_FLOAT sin2 = MAX(static_cast(1.0) - c1mag*c1mag, static_cast(0.0)); + KK_FLOAT sc1 = Kokkos::sqrt(sin2); + if (sc1 < static_cast(SMALL)) sc1 = static_cast(SMALL); + sc1 = static_cast(1.0) / sc1; - sin2 = MAX(1.0 - c2mag*c2mag, 0.0); - KK_FLOAT sc2 = sqrt(sin2); - if (sc2 < SMALL) sc2 = SMALL; - sc2 = 1.0 / sc2; + sin2 = MAX(static_cast(1.0) - c2mag*c2mag, static_cast(0.0)); + KK_FLOAT sc2 = Kokkos::sqrt(sin2); + if (sc2 < static_cast(SMALL)) sc2 = static_cast(SMALL); + sc2 = static_cast(1.0) / sc2; const KK_FLOAT s1 = sc1 * sc1; const KK_FLOAT s2 = sc2 * sc2; @@ -244,32 +244,32 @@ void DihedralQuadraticKokkos::operator()(TagDihedralQuadraticCompute const KK_FLOAT cx = vb1y*vb2z - vb1z*vb2y; const KK_FLOAT cy = vb1z*vb2x - vb1x*vb2z; const KK_FLOAT cz = vb1x*vb2y - vb1y*vb2x; - const KK_FLOAT cmag = sqrt(cx*cx + cy*cy + cz*cz); + const KK_FLOAT cmag = Kokkos::sqrt(cx*cx + cy*cy + cz*cz); const KK_FLOAT dx = (cx*vb3x + cy*vb3y + cz*vb3z)/cmag/b3mag; // error check - if ((c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + if ((c > static_cast(1.0 + TOLERANCE) || c < static_cast(-1.0 - TOLERANCE)) && !d_warning_flag()) d_warning_flag() = 1; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; + if (c > static_cast(1.0)) c = 1.0; + if (c < static_cast(-1.0)) c = -1.0; // force & energy // p = k ( phi- phi0)^2 // pd = dp/dc - KK_FLOAT phi = acos(c); - if (dx > 0.0) phi *= -1.0; - KK_FLOAT si = sin(phi); - if (fabs(si) < SMALLER) si = SMALLER; - const KK_FLOAT siinv = 1.0/si; + KK_FLOAT phi = Kokkos::acos(c); + if (dx > static_cast(0.0)) phi *= static_cast(-1.0); + KK_FLOAT si = Kokkos::sin(phi); + if (Kokkos::fabs(si) < static_cast(SMALLER)) si = static_cast(SMALLER); + const KK_FLOAT siinv = static_cast(1.0)/si; KK_FLOAT dphi = phi - d_phi0[type]; - if (dphi > MY_PI) dphi -= 2.0*MY_PI; - else if (dphi < -MY_PI) dphi += 2.0*MY_PI; + if (dphi > static_cast(MY_PI)) dphi -= static_cast(2.0*MY_PI); + else if (dphi < static_cast(-MY_PI)) dphi += static_cast(2.0*MY_PI); KK_FLOAT p_k = d_k[type]*dphi; - const KK_FLOAT pd = -2.0*p_k*siinv; + const KK_FLOAT pd = -static_cast(2.0)*p_k*siinv; p_k = p_k*dphi; KK_FLOAT edihedral = 0.0; @@ -279,7 +279,7 @@ void DihedralQuadraticKokkos::operator()(TagDihedralQuadraticCompute const KK_FLOAT ca = c * a; const KK_FLOAT s12a = s12 * a; const KK_FLOAT a11 = ca*sb1*s1; - const KK_FLOAT a22 = -sb2*(2.0*c0*s12a - ca*(s1+s2)); + const KK_FLOAT a22 = -sb2*(static_cast(2.0)*c0*s12a - ca*(s1+s2)); const KK_FLOAT a33 = ca*sb3*s2; const KK_FLOAT a12 = -r12c1*(c1mag*ca*s1 + c2mag*s12a); const KK_FLOAT a13 = -rb1*rb3*s12a; @@ -309,27 +309,27 @@ void DihedralQuadraticKokkos::operator()(TagDihedralQuadraticCompute // apply force to each of 4 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -374,8 +374,8 @@ void DihedralQuadraticKokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->ndihedraltypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k.view_host()[i] = k[i]; - k_phi0.view_host()[i] = phi0[i]; + k_k.view_host()[i] = static_cast(k[i]); + k_phi0.view_host()[i] = static_cast(phi0[i]); } k_k.modify_host(); @@ -393,8 +393,8 @@ void DihedralQuadraticKokkos::read_restart(FILE *fp) int n = atom->ndihedraltypes; for (int i = 1; i <= n; i++) { - k_k.view_host()[i] = k[i]; - k_phi0.view_host()[i] = phi0[i]; + k_k.view_host()[i] = static_cast(k[i]); + k_phi0.view_host()[i] = static_cast(phi0[i]); } k_k.modify_host(); @@ -427,21 +427,21 @@ void DihedralQuadraticKokkos::ev_tally(EV_FLOAT &ev, const int i1, c if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -455,80 +455,80 @@ void DihedralQuadraticKokkos::ev_tally(EV_FLOAT &ev, const int i1, c if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(static_cast(0.25)*v[0]); + ev.v[1] += static_cast(static_cast(0.25)*v[1]); + ev.v[2] += static_cast(static_cast(0.25)*v[2]); + ev.v[3] += static_cast(static_cast(0.25)*v[3]); + ev.v[4] += static_cast(static_cast(0.25)*v[4]); + ev.v[5] += static_cast(static_cast(0.25)*v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i1,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i1,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i1,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i1,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i1,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i2,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i2,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i2,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i2,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i2,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i3,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i3,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i3,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i3,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i3,5) += static_cast(static_cast(0.25)*v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(static_cast(0.25)*v[0]); + v_vatom(i4,1) += static_cast(static_cast(0.25)*v[1]); + v_vatom(i4,2) += static_cast(static_cast(0.25)*v[2]); + v_vatom(i4,3) += static_cast(static_cast(0.25)*v[3]); + v_vatom(i4,4) += static_cast(static_cast(0.25)*v[4]); + v_vatom(i4,5) += static_cast(static_cast(0.25)*v[5]); } } } diff --git a/src/KOKKOS/dihedral_spherical_kokkos.cpp b/src/KOKKOS/dihedral_spherical_kokkos.cpp index cb413aa64a2..fea9835d4df 100644 --- a/src/KOKKOS/dihedral_spherical_kokkos.cpp +++ b/src/KOKKOS/dihedral_spherical_kokkos.cpp @@ -143,14 +143,14 @@ void DihedralSphericalKokkos::compute(int eflag_in, int vflag_in) if (h_warning_flag()) error->warning(FLERR,"Dihedral problem"); - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -185,28 +185,28 @@ KK_FLOAT DihedralSphericalKokkos::CalcGeneralizedForcesKK( KK_FLOAT cp = 1.0; KK_FLOAT sp = 0.0; const KK_FLOAT pm = d_phi_mult(type,j); - if (pm != 0.0) { + if (pm != static_cast(0.0)) { const KK_FLOAT p = pm * (phi - d_phi_shift(type,j)); - cp = cos(p); - sp = sin(p); + cp = Kokkos::cos(p); + sp = Kokkos::sin(p); } KK_FLOAT ct1 = 1.0; KK_FLOAT st1 = 0.0; const KK_FLOAT t1m = d_theta1_mult(type,j); - if (t1m != 0.0) { + if (t1m != static_cast(0.0)) { const KK_FLOAT t1 = t1m * (theta1 - d_theta1_shift(type,j)); - ct1 = cos(t1); - st1 = sin(t1); + ct1 = Kokkos::cos(t1); + st1 = Kokkos::sin(t1); } KK_FLOAT ct2 = 1.0; KK_FLOAT st2 = 0.0; const KK_FLOAT t2m = d_theta2_mult(type,j); - if (t2m != 0.0) { + if (t2m != static_cast(0.0)) { const KK_FLOAT t2 = t2m * (theta2 - d_theta2_shift(type,j)); - ct2 = cos(t2); - st2 = sin(t2); + ct2 = Kokkos::cos(t2); + st2 = Kokkos::sin(t2); } const KK_FLOAT C = d_Ccoeff(type,j); @@ -265,28 +265,28 @@ void DihedralSphericalKokkos::operator()(TagDihedralSphericalCompute // Normalize n123 and n234 KK_FLOAT inv_scale; - inv_scale = sqrt(n123[0]*n123[0] + n123[1]*n123[1] + n123[2]*n123[2]); - if (inv_scale > 0.0) { - KK_FLOAT scale = 1.0/inv_scale; + inv_scale = Kokkos::sqrt(n123[0]*n123[0] + n123[1]*n123[1] + n123[2]*n123[2]); + if (inv_scale > static_cast(0.0)) { + KK_FLOAT scale = static_cast(1.0)/inv_scale; n123[0] *= scale; n123[1] *= scale; n123[2] *= scale; } - inv_scale = sqrt(n234[0]*n234[0] + n234[1]*n234[1] + n234[2]*n234[2]); - if (inv_scale > 0.0) { - KK_FLOAT scale = 1.0/inv_scale; + inv_scale = Kokkos::sqrt(n234[0]*n234[0] + n234[1]*n234[1] + n234[2]*n234[2]); + if (inv_scale > static_cast(0.0)) { + KK_FLOAT scale = static_cast(1.0)/inv_scale; n234[0] *= scale; n234[1] *= scale; n234[2] *= scale; } // Dihedral angle phi KK_FLOAT cos_phi = -(n123[0]*n234[0] + n123[1]*n234[1] + n123[2]*n234[2]); - if (cos_phi > 1.0) cos_phi = 1.0; - else if (cos_phi < -1.0) cos_phi = -1.0; - KK_FLOAT phi = acos(cos_phi); + if (cos_phi > static_cast(1.0)) cos_phi = 1.0; + else if (cos_phi < -static_cast(1.0)) cos_phi = -1.0; + KK_FLOAT phi = Kokkos::acos(cos_phi); // Determine sign: if n123 . vb34 > 0 => negative dihedral KK_FLOAT n123_dot_vb34 = n123[0]*vb34[0] + n123[1]*vb34[1] + n123[2]*vb34[2]; - if (n123_dot_vb34 > 0.0) { + if (n123_dot_vb34 > static_cast(0.0)) { phi = -phi; - phi += MY_2PI; + phi += static_cast(MY_2PI); } // Dot products needed for bond lengths @@ -297,16 +297,16 @@ void DihedralSphericalKokkos::operator()(TagDihedralSphericalCompute KK_FLOAT L23sqr = vb23[0]*vb23[0] + vb23[1]*vb23[1] + vb23[2]*vb23[2]; KK_FLOAT L34sqr = vb34[0]*vb34[0] + vb34[1]*vb34[1] + vb34[2]*vb34[2]; - KK_FLOAT L12 = sqrt(L12sqr); - KK_FLOAT L23 = sqrt(L23sqr); - KK_FLOAT L34 = sqrt(L34sqr); + KK_FLOAT L12 = Kokkos::sqrt(L12sqr); + KK_FLOAT L23 = Kokkos::sqrt(L23sqr); + KK_FLOAT L34 = Kokkos::sqrt(L34sqr); - KK_FLOAT inv_L12sqr = (L12sqr != 0.0) ? 1.0/L12sqr : 0.0; - KK_FLOAT inv_L12 = (L12sqr != 0.0) ? 1.0/L12 : 0.0; - KK_FLOAT inv_L23sqr = (L23sqr != 0.0) ? 1.0/L23sqr : 0.0; - KK_FLOAT inv_L23 = (L23sqr != 0.0) ? 1.0/L23 : 0.0; - KK_FLOAT inv_L34sqr = (L34sqr != 0.0) ? 1.0/L34sqr : 0.0; - KK_FLOAT inv_L34 = (L34sqr != 0.0) ? 1.0/L34 : 0.0; + KK_FLOAT inv_L12sqr = (L12sqr != static_cast(0.0)) ? static_cast(1.0)/L12sqr : static_cast(0.0); + KK_FLOAT inv_L12 = (L12sqr != static_cast(0.0)) ? static_cast(1.0)/L12 : static_cast(0.0); + KK_FLOAT inv_L23sqr = (L23sqr != static_cast(0.0)) ? static_cast(1.0)/L23sqr : static_cast(0.0); + KK_FLOAT inv_L23 = (L23sqr != static_cast(0.0)) ? static_cast(1.0)/L23 : static_cast(0.0); + KK_FLOAT inv_L34sqr = (L34sqr != static_cast(0.0)) ? static_cast(1.0)/L34sqr : static_cast(0.0); + KK_FLOAT inv_L34 = (L34sqr != static_cast(0.0)) ? static_cast(1.0)/L34 : static_cast(0.0); KK_FLOAT neg_inv_L23 = -inv_L23; @@ -333,15 +333,15 @@ void DihedralSphericalKokkos::operator()(TagDihedralSphericalCompute perp23on34[d] = vb23[d] - proj23on34[d]; } - KK_FLOAT perp12on23_len = sqrt(perp12on23[0]*perp12on23[0] + perp12on23[1]*perp12on23[1] + perp12on23[2]*perp12on23[2]); - KK_FLOAT perp34on23_len = sqrt(perp34on23[0]*perp34on23[0] + perp34on23[1]*perp34on23[1] + perp34on23[2]*perp34on23[2]); - KK_FLOAT perp23on12_len = sqrt(perp23on12[0]*perp23on12[0] + perp23on12[1]*perp23on12[1] + perp23on12[2]*perp23on12[2]); - KK_FLOAT perp23on34_len = sqrt(perp23on34[0]*perp23on34[0] + perp23on34[1]*perp23on34[1] + perp23on34[2]*perp23on34[2]); + KK_FLOAT perp12on23_len = Kokkos::sqrt(perp12on23[0]*perp12on23[0] + perp12on23[1]*perp12on23[1] + perp12on23[2]*perp12on23[2]); + KK_FLOAT perp34on23_len = Kokkos::sqrt(perp34on23[0]*perp34on23[0] + perp34on23[1]*perp34on23[1] + perp34on23[2]*perp34on23[2]); + KK_FLOAT perp23on12_len = Kokkos::sqrt(perp23on12[0]*perp23on12[0] + perp23on12[1]*perp23on12[1] + perp23on12[2]*perp23on12[2]); + KK_FLOAT perp23on34_len = Kokkos::sqrt(perp23on34[0]*perp23on34[0] + perp23on34[1]*perp23on34[1] + perp23on34[2]*perp23on34[2]); - KK_FLOAT inv_perp12on23 = (perp12on23_len != 0.0) ? 1.0/perp12on23_len : 0.0; - KK_FLOAT inv_perp34on23 = (perp34on23_len != 0.0) ? 1.0/perp34on23_len : 0.0; - KK_FLOAT inv_perp23on12 = (perp23on12_len != 0.0) ? 1.0/perp23on12_len : 0.0; - KK_FLOAT inv_perp23on34 = (perp23on34_len != 0.0) ? 1.0/perp23on34_len : 0.0; + KK_FLOAT inv_perp12on23 = (perp12on23_len != static_cast(0.0)) ? static_cast(1.0)/perp12on23_len : static_cast(0.0); + KK_FLOAT inv_perp34on23 = (perp34on23_len != static_cast(0.0)) ? static_cast(1.0)/perp34on23_len : static_cast(0.0); + KK_FLOAT inv_perp23on12 = (perp23on12_len != static_cast(0.0)) ? static_cast(1.0)/perp23on12_len : static_cast(0.0); + KK_FLOAT inv_perp23on34 = (perp23on34_len != static_cast(0.0)) ? static_cast(1.0)/perp23on34_len : static_cast(0.0); // Gradients of phi KK_FLOAT dphi_dx1[g_dim], dphi_dx2[g_dim], dphi_dx3[g_dim], dphi_dx4[g_dim]; @@ -385,14 +385,14 @@ void DihedralSphericalKokkos::operator()(TagDihedralSphericalCompute // Bond angles theta1 and theta2 KK_FLOAT ct1 = -dot123 * inv_L12 * inv_L23; - if (ct1 < -1.0) ct1 = -1.0; - else if (ct1 > 1.0) ct1 = 1.0; - KK_FLOAT theta1 = acos(ct1); + if (ct1 < -static_cast(1.0)) ct1 = -1.0; + else if (ct1 > static_cast(1.0)) ct1 = 1.0; + KK_FLOAT theta1 = Kokkos::acos(ct1); KK_FLOAT ct2 = -dot234 * inv_L23 * inv_L34; - if (ct2 < -1.0) ct2 = -1.0; - else if (ct2 > 1.0) ct2 = 1.0; - KK_FLOAT theta2 = acos(ct2); + if (ct2 < -static_cast(1.0)) ct2 = -1.0; + else if (ct2 > static_cast(1.0)) ct2 = 1.0; + KK_FLOAT theta2 = Kokkos::acos(ct2); // Generalized forces KK_FLOAT m_du_dth1 = 0.0, m_du_dth2 = 0.0, m_du_dphi = 0.0; @@ -411,27 +411,27 @@ void DihedralSphericalKokkos::operator()(TagDihedralSphericalCompute // Apply force to each of 4 atoms if (NEWTON_BOND || i1 < nlocal) { - a_f(i1,0) += f1[0]; - a_f(i1,1) += f1[1]; - a_f(i1,2) += f1[2]; + a_f(i1,0) += static_cast(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } // ev_tally uses vb12 as vb1, vb23 as vb2, vb34 as vb3 @@ -524,16 +524,16 @@ void DihedralSphericalKokkos::coeff(int narg, char **arg) for (int i = ilo; i <= ihi; i++) { k_nterms.view_host()[i] = nterms[i]; for (int j = 0; j < nterms[i]; j++) { - k_Ccoeff.view_host()(i,j) = Ccoeff[i][j]; - k_phi_mult.view_host()(i,j) = phi_mult[i][j]; - k_phi_shift.view_host()(i,j) = phi_shift[i][j]; - k_phi_offset.view_host()(i,j) = phi_offset[i][j]; - k_theta1_mult.view_host()(i,j) = theta1_mult[i][j]; - k_theta1_shift.view_host()(i,j) = theta1_shift[i][j]; - k_theta1_offset.view_host()(i,j) = theta1_offset[i][j]; - k_theta2_mult.view_host()(i,j) = theta2_mult[i][j]; - k_theta2_shift.view_host()(i,j) = theta2_shift[i][j]; - k_theta2_offset.view_host()(i,j) = theta2_offset[i][j]; + k_Ccoeff.view_host()(i,j) = static_cast(Ccoeff[i][j]); + k_phi_mult.view_host()(i,j) = static_cast(phi_mult[i][j]); + k_phi_shift.view_host()(i,j) = static_cast(phi_shift[i][j]); + k_phi_offset.view_host()(i,j) = static_cast(phi_offset[i][j]); + k_theta1_mult.view_host()(i,j) = static_cast(theta1_mult[i][j]); + k_theta1_shift.view_host()(i,j) = static_cast(theta1_shift[i][j]); + k_theta1_offset.view_host()(i,j) = static_cast(theta1_offset[i][j]); + k_theta2_mult.view_host()(i,j) = static_cast(theta2_mult[i][j]); + k_theta2_shift.view_host()(i,j) = static_cast(theta2_shift[i][j]); + k_theta2_offset.view_host()(i,j) = static_cast(theta2_offset[i][j]); } } @@ -564,16 +564,16 @@ void DihedralSphericalKokkos::read_restart(FILE *fp) for (int i = 1; i <= n; i++) { k_nterms.view_host()[i] = nterms[i]; for (int j = 0; j < nterms[i]; j++) { - k_Ccoeff.view_host()(i,j) = Ccoeff[i][j]; - k_phi_mult.view_host()(i,j) = phi_mult[i][j]; - k_phi_shift.view_host()(i,j) = phi_shift[i][j]; - k_phi_offset.view_host()(i,j) = phi_offset[i][j]; - k_theta1_mult.view_host()(i,j) = theta1_mult[i][j]; - k_theta1_shift.view_host()(i,j) = theta1_shift[i][j]; - k_theta1_offset.view_host()(i,j) = theta1_offset[i][j]; - k_theta2_mult.view_host()(i,j) = theta2_mult[i][j]; - k_theta2_shift.view_host()(i,j) = theta2_shift[i][j]; - k_theta2_offset.view_host()(i,j) = theta2_offset[i][j]; + k_Ccoeff.view_host()(i,j) = static_cast(Ccoeff[i][j]); + k_phi_mult.view_host()(i,j) = static_cast(phi_mult[i][j]); + k_phi_shift.view_host()(i,j) = static_cast(phi_shift[i][j]); + k_phi_offset.view_host()(i,j) = static_cast(phi_offset[i][j]); + k_theta1_mult.view_host()(i,j) = static_cast(theta1_mult[i][j]); + k_theta1_shift.view_host()(i,j) = static_cast(theta1_shift[i][j]); + k_theta1_offset.view_host()(i,j) = static_cast(theta1_offset[i][j]); + k_theta2_mult.view_host()(i,j) = static_cast(theta2_mult[i][j]); + k_theta2_shift.view_host()(i,j) = static_cast(theta2_shift[i][j]); + k_theta2_offset.view_host()(i,j) = static_cast(theta2_offset[i][j]); } } @@ -616,21 +616,21 @@ void DihedralSphericalKokkos::ev_tally(EV_FLOAT &ev, const int i1, c if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += edihedral; + if (newton_bond) ev.evdwl += static_cast(edihedral); else { - edihedralquarter = 0.25*edihedral; - if (i1 < nlocal) ev.evdwl += edihedralquarter; - if (i2 < nlocal) ev.evdwl += edihedralquarter; - if (i3 < nlocal) ev.evdwl += edihedralquarter; - if (i4 < nlocal) ev.evdwl += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (i1 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i2 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i3 < nlocal) ev.evdwl += static_cast(edihedralquarter); + if (i4 < nlocal) ev.evdwl += static_cast(edihedralquarter); } } if (eflag_atom) { - edihedralquarter = 0.25*edihedral; - if (newton_bond || i1 < nlocal) v_eatom[i1] += edihedralquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += edihedralquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += edihedralquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += edihedralquarter; + edihedralquarter = static_cast(0.25)*edihedral; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(edihedralquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(edihedralquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(edihedralquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(edihedralquarter); } } @@ -644,80 +644,80 @@ void DihedralSphericalKokkos::ev_tally(EV_FLOAT &ev, const int i1, c if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i1,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i1,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i1,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i1,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i1,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i2,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i2,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i2,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i2,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i2,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i3,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i3,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i3,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i3,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i3,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i4,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i4,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i4,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i4,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i4,5) += static_cast(0.25)*static_cast(v[5]); } } } diff --git a/src/KOKKOS/domain_kokkos.cpp b/src/KOKKOS/domain_kokkos.cpp index c256fca2167..1d8718c0694 100644 --- a/src/KOKKOS/domain_kokkos.cpp +++ b/src/KOKKOS/domain_kokkos.cpp @@ -72,12 +72,12 @@ struct DomainResetBoxFunctor{ // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void operator() (const int &i, value_type &dst) const { - dst.value[0][0] = MIN(dst.value[0][0],x(i,0)); - dst.value[0][1] = MAX(dst.value[0][1],x(i,0)); - dst.value[1][0] = MIN(dst.value[1][0],x(i,1)); - dst.value[1][1] = MAX(dst.value[1][1],x(i,1)); - dst.value[2][0] = MIN(dst.value[2][0],x(i,2)); - dst.value[2][1] = MAX(dst.value[2][1],x(i,2)); + dst.value[0][0] = MIN(dst.value[0][0],static_cast(x(i,0))); + dst.value[0][1] = MAX(dst.value[0][1],static_cast(x(i,0))); + dst.value[1][0] = MIN(dst.value[1][0],static_cast(x(i,1))); + dst.value[1][1] = MAX(dst.value[1][1],static_cast(x(i,1))); + dst.value[2][0] = MIN(dst.value[2][0],static_cast(x(i,2))); + dst.value[2][1] = MAX(dst.value[2][1],static_cast(x(i,2))); } }; @@ -251,19 +251,19 @@ struct DomainPBCFunctor { KOKKOS_INLINE_FUNCTION void operator() (const int &i) const { if (PERIODIC && xperiodic) { - if (x(i,0) < lo[0]) { - x(i,0) += period[0]; - if (DEFORM_VREMAP && (mask[i] & deform_groupbit)) v(i,0) += h_rate[0]; + if (x(i,0) < static_cast(lo[0])) { + x(i,0) += static_cast(period[0]); + if (DEFORM_VREMAP && (mask[i] & deform_groupbit)) v(i,0) += static_cast(h_rate[0]); imageint idim = image[i] & IMGMASK; const imageint otherdims = image[i] ^ idim; idim--; idim &= IMGMASK; image[i] = otherdims | idim; } - if (x(i,0) >= hi[0]) { - x(i,0) -= period[0]; - x(i,0) = MAX(x(i,0),lo[0]); - if (DEFORM_VREMAP && (mask[i] & deform_groupbit)) v(i,0) -= h_rate[0]; + if (x(i,0) >= static_cast(hi[0])) { + x(i,0) -= static_cast(period[0]); + x(i,0) = MAX(x(i,0),static_cast(lo[0])); + if (DEFORM_VREMAP && (mask[i] & deform_groupbit)) v(i,0) -= static_cast(h_rate[0]); imageint idim = image[i] & IMGMASK; const imageint otherdims = image[i] ^ idim; idim++; @@ -273,11 +273,11 @@ struct DomainPBCFunctor { } if (PERIODIC && yperiodic) { - if (x(i,1) < lo[1]) { - x(i,1) += period[1]; + if (x(i,1) < static_cast(lo[1])) { + x(i,1) += static_cast(period[1]); if (DEFORM_VREMAP && (mask[i] & deform_groupbit)) { - v(i,0) += h_rate[5]; - v(i,1) += h_rate[1]; + v(i,0) += static_cast(h_rate[5]); + v(i,1) += static_cast(h_rate[1]); } imageint idim = (image[i] >> IMGBITS) & IMGMASK; const imageint otherdims = image[i] ^ (idim << IMGBITS); @@ -285,12 +285,12 @@ struct DomainPBCFunctor { idim &= IMGMASK; image[i] = otherdims | (idim << IMGBITS); } - if (x(i,1) >= hi[1]) { - x(i,1) -= period[1]; - x(i,1) = MAX(x(i,1),lo[1]); + if (x(i,1) >= static_cast(hi[1])) { + x(i,1) -= static_cast(period[1]); + x(i,1) = MAX(x(i,1),static_cast(lo[1])); if (DEFORM_VREMAP && (mask[i] & deform_groupbit)) { - v(i,0) -= h_rate[5]; - v(i,1) -= h_rate[1]; + v(i,0) -= static_cast(h_rate[5]); + v(i,1) -= static_cast(h_rate[1]); } imageint idim = (image[i] >> IMGBITS) & IMGMASK; const imageint otherdims = image[i] ^ (idim << IMGBITS); @@ -301,12 +301,12 @@ struct DomainPBCFunctor { } if (PERIODIC && zperiodic) { - if (x(i,2) < lo[2]) { - x(i,2) += period[2]; + if (x(i,2) < static_cast(lo[2])) { + x(i,2) += static_cast(period[2]); if (DEFORM_VREMAP && (mask[i] & deform_groupbit)) { - v(i,0) += h_rate[4]; - v(i,1) += h_rate[3]; - v(i,2) += h_rate[2]; + v(i,0) += static_cast(h_rate[4]); + v(i,1) += static_cast(h_rate[3]); + v(i,2) += static_cast(h_rate[2]); } imageint idim = image[i] >> IMG2BITS; const imageint otherdims = image[i] ^ (idim << IMG2BITS); @@ -314,13 +314,13 @@ struct DomainPBCFunctor { idim &= IMGMASK; image[i] = otherdims | (idim << IMG2BITS); } - if (x(i,2) >= hi[2]) { - x(i,2) -= period[2]; - x(i,2) = MAX(x(i,2),lo[2]); + if (x(i,2) >= static_cast(hi[2])) { + x(i,2) -= static_cast(period[2]); + x(i,2) = MAX(x(i,2),static_cast(lo[2])); if (DEFORM_VREMAP && (mask[i] & deform_groupbit)) { - v(i,0) -= h_rate[4]; - v(i,1) -= h_rate[3]; - v(i,2) -= h_rate[2]; + v(i,0) -= static_cast(h_rate[4]); + v(i,1) -= static_cast(h_rate[3]); + v(i,2) -= static_cast(h_rate[2]); } imageint idim = image[i] >> IMG2BITS; const imageint otherdims = image[i] ^ (idim << IMG2BITS); @@ -424,15 +424,15 @@ void DomainKokkos::remap_all() if (triclinic == 0) { for (int i=0; i<3; i++) { - lo[i] = boxlo[i]; - hi[i] = boxhi[i]; - period[i] = prd[i]; + lo[i] = static_cast(boxlo[i]); + hi[i] = static_cast(boxhi[i]); + period[i] = static_cast(prd[i]); } } else { for (int i=0; i<3; i++) { - lo[i] = boxlo_lamda[i]; - hi[i] = boxhi_lamda[i]; - period[i] = prd_lamda[i]; + lo[i] = static_cast(boxlo_lamda[i]); + hi[i] = static_cast(boxhi_lamda[i]); + period[i] = static_cast(prd_lamda[i]); } x2lamda(nlocal); } @@ -599,9 +599,9 @@ KOKKOS_INLINE_FUNCTION void DomainKokkos::operator()(TagDomain_lamda2x, const int &i) const { const KK_FLOAT xi1 = x(i,1); const KK_FLOAT xi2 = x(i,2); - x(i,0) = h[0]*x(i,0) + h[5]*xi1 + h[4]*xi2 + boxlo[0]; - x(i,1) = h[1]*xi1 + h[3]*xi2 + boxlo[1]; - x(i,2) = h[2]*xi2 + boxlo[2]; + x(i,0) = static_cast(h[0])*x(i,0) + static_cast(h[5])*xi1 + static_cast(h[4])*xi2 + static_cast(boxlo[0]); + x(i,1) = static_cast(h[1])*xi1 + static_cast(h[3])*xi2 + static_cast(boxlo[1]); + x(i,2) = static_cast(h[2])*xi2 + static_cast(boxlo[2]); } // NOLINTNEXTLINE @@ -610,9 +610,9 @@ void DomainKokkos::operator()(TagDomain_lamda2x_group, const int &i) const { if (mask[i] & groupbit) { const KK_FLOAT xi1 = x(i,1); const KK_FLOAT xi2 = x(i,2); - x(i,0) = h[0]*x(i,0) + h[5]*xi1 + h[4]*xi2 + boxlo[0]; - x(i,1) = h[1]*xi1 + h[3]*xi2 + boxlo[1]; - x(i,2) = h[2]*xi2 + boxlo[2]; + x(i,0) = static_cast(h[0])*x(i,0) + static_cast(h[5])*xi1 + static_cast(h[4])*xi2 + static_cast(boxlo[0]); + x(i,1) = static_cast(h[1])*xi1 + static_cast(h[3])*xi2 + static_cast(boxlo[1]); + x(i,2) = static_cast(h[2])*xi2 + static_cast(boxlo[2]); } } @@ -651,13 +651,13 @@ void DomainKokkos::x2lamda(int n, int groupbit_in) KOKKOS_INLINE_FUNCTION void DomainKokkos::operator()(TagDomain_x2lamda, const int &i) const { KK_FLOAT delta[3]; - delta[0] = x(i,0) - boxlo[0]; - delta[1] = x(i,1) - boxlo[1]; - delta[2] = x(i,2) - boxlo[2]; + delta[0] = x(i,0) - static_cast(boxlo[0]); + delta[1] = x(i,1) - static_cast(boxlo[1]); + delta[2] = x(i,2) - static_cast(boxlo[2]); - x(i,0) = h_inv[0]*delta[0] + h_inv[5]*delta[1] + h_inv[4]*delta[2]; - x(i,1) = h_inv[1]*delta[1] + h_inv[3]*delta[2]; - x(i,2) = h_inv[2]*delta[2]; + x(i,0) = static_cast(h_inv[0])*delta[0] + static_cast(h_inv[5])*delta[1] + static_cast(h_inv[4])*delta[2]; + x(i,1) = static_cast(h_inv[1])*delta[1] + static_cast(h_inv[3])*delta[2]; + x(i,2) = static_cast(h_inv[2])*delta[2]; } // NOLINTNEXTLINE @@ -665,13 +665,13 @@ KOKKOS_INLINE_FUNCTION void DomainKokkos::operator()(TagDomain_x2lamda_group, const int &i) const { if (mask[i] & groupbit) { KK_FLOAT delta[3]; - delta[0] = x(i,0) - boxlo[0]; - delta[1] = x(i,1) - boxlo[1]; - delta[2] = x(i,2) - boxlo[2]; + delta[0] = x(i,0) - static_cast(boxlo[0]); + delta[1] = x(i,1) - static_cast(boxlo[1]); + delta[2] = x(i,2) - static_cast(boxlo[2]); - x(i,0) = h_inv[0]*delta[0] + h_inv[5]*delta[1] + h_inv[4]*delta[2]; - x(i,1) = h_inv[1]*delta[1] + h_inv[3]*delta[2]; - x(i,2) = h_inv[2]*delta[2]; + x(i,0) = static_cast(h_inv[0])*delta[0] + static_cast(h_inv[5])*delta[1] + static_cast(h_inv[4])*delta[2]; + x(i,1) = static_cast(h_inv[1])*delta[1] + static_cast(h_inv[3])*delta[2]; + x(i,2) = static_cast(h_inv[2])*delta[2]; } } diff --git a/src/KOKKOS/fix_addforce_kokkos.cpp b/src/KOKKOS/fix_addforce_kokkos.cpp index d5f5dbb5c1e..8944eae61a7 100644 --- a/src/KOKKOS/fix_addforce_kokkos.cpp +++ b/src/KOKKOS/fix_addforce_kokkos.cpp @@ -185,22 +185,25 @@ template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void FixAddForceKokkos::operator()(TagFixAddForceConstant, const int &i, value_type result) const { + const KK_FLOAT xvalue_kk = static_cast(xvalue); + const KK_FLOAT yvalue_kk = static_cast(yvalue); + const KK_FLOAT zvalue_kk = static_cast(zvalue); if (mask[i] & groupbit) { if (region && !d_match[i]) return; Few x_i; - x_i[0] = x(i,0); - x_i[1] = x(i,1); - x_i[2] = x(i,2); + x_i[0] = static_cast(x(i,0)); + x_i[1] = static_cast(x(i,1)); + x_i[2] = static_cast(x(i,2)); auto unwrapKK = DomainKokkos::unmap(prd,h,triclinic,x_i,image(i)); result[0] -= xvalue * unwrapKK[0] + yvalue * unwrapKK[1] + zvalue * unwrapKK[2]; - result[1] += f(i,0); - result[2] += f(i,1); - result[3] += f(i,2); - if (xstyle) f(i,0) += xvalue; - if (ystyle) f(i,1) += yvalue; - if (zstyle) f(i,2) += zvalue; + result[1] += static_cast(f(i,0)); + result[2] += static_cast(f(i,1)); + result[3] += static_cast(f(i,2)); + if (xstyle) f(i,0) += static_cast(xvalue_kk); + if (ystyle) f(i,1) += static_cast(yvalue_kk); + if (zstyle) f(i,2) += static_cast(zvalue_kk); } } @@ -208,34 +211,37 @@ template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void FixAddForceKokkos::operator()(TagFixAddForceNonConstant, const int &i, value_type result) const { + const KK_FLOAT xvalue_kk = static_cast(xvalue); + const KK_FLOAT yvalue_kk = static_cast(yvalue); + const KK_FLOAT zvalue_kk = static_cast(zvalue); if (mask[i] & groupbit) { if (region && !d_match[i]) return; Few x_i; - x_i[0] = x(i,0); - x_i[1] = x(i,1); - x_i[2] = x(i,2); + x_i[0] = static_cast(x(i,0)); + x_i[1] = static_cast(x(i,1)); + x_i[2] = static_cast(x(i,2)); auto unwrapKK = DomainKokkos::unmap(prd,h,triclinic,x_i,image(i)); if (estyle == ATOM) { - result[0] += d_sforce(i,3); + result[0] += static_cast(d_sforce(i,3)); } else { if (xstyle == EQUAL) result[0] -= xvalue * unwrapKK[0]; if (ystyle == EQUAL) result[0] -= yvalue * unwrapKK[1]; if (zstyle == EQUAL) result[0] -= zvalue * unwrapKK[2]; - if (xstyle == ATOM) result[0] -= d_sforce(i,0) * unwrapKK[0]; - if (ystyle == ATOM) result[0] -= d_sforce(i,1) * unwrapKK[1]; - if (zstyle == ATOM) result[0] -= d_sforce(i,2) * unwrapKK[2]; + if (xstyle == ATOM) result[0] -= static_cast(d_sforce(i,0)) * unwrapKK[0]; + if (ystyle == ATOM) result[0] -= static_cast(d_sforce(i,1)) * unwrapKK[1]; + if (zstyle == ATOM) result[0] -= static_cast(d_sforce(i,2)) * unwrapKK[2]; } - result[1] += f(i,0); - result[2] += f(i,1); - result[3] += f(i,2); - if (xstyle == ATOM) f(i,0) += d_sforce(i,0); - else if (xstyle) f(i,0) += xvalue; - if (ystyle == ATOM) f(i,1) += d_sforce(i,1); - else if (ystyle) f(i,1) += yvalue; - if (zstyle == ATOM) f(i,2) += d_sforce(i,2); - else if (zstyle) f(i,2) += zvalue; + result[1] += static_cast(f(i,0)); + result[2] += static_cast(f(i,1)); + result[3] += static_cast(f(i,2)); + if (xstyle == ATOM) f(i,0) += static_cast(d_sforce(i,0)); + else if (xstyle) f(i,0) += static_cast(xvalue_kk); + if (ystyle == ATOM) f(i,1) += static_cast(d_sforce(i,1)); + else if (ystyle) f(i,1) += static_cast(yvalue_kk); + if (zstyle == ATOM) f(i,2) += static_cast(d_sforce(i,2)); + else if (zstyle) f(i,2) += static_cast(zvalue_kk); } } @@ -256,12 +262,12 @@ KOKKOS_INLINE_FUNCTION void FixAddForceKokkos::v_tally(value_type result, int i, KK_FLOAT *v) const { if (vflag_global) { - result[4] += static_cast(v[0]); - result[5] += static_cast(v[1]); - result[6] += static_cast(v[2]); - result[7] += static_cast(v[3]); - result[8] += static_cast(v[4]); - result[9] += static_cast(v[5]); + result[4] += static_cast(v[0]); + result[5] += static_cast(v[1]); + result[6] += static_cast(v[2]); + result[7] += static_cast(v[3]); + result[8] += static_cast(v[4]); + result[9] += static_cast(v[5]); } if (vflag_atom) { diff --git a/src/KOKKOS/fix_aveforce_kokkos.cpp b/src/KOKKOS/fix_aveforce_kokkos.cpp index 7e1b043e192..035a4bfd72d 100644 --- a/src/KOKKOS/fix_aveforce_kokkos.cpp +++ b/src/KOKKOS/fix_aveforce_kokkos.cpp @@ -138,9 +138,9 @@ void FixAveForceKokkos::operator()(TagFixAveForceReduce, const int & { if (mask[i] & groupbit) { if (region && !d_match[i]) return; - result[0] += f(i,0); - result[1] += f(i,1); - result[2] += f(i,2); + result[0] += static_cast(f(i,0)); + result[1] += static_cast(f(i,1)); + result[2] += static_cast(f(i,2)); result[3] += 1.0; } } @@ -154,9 +154,9 @@ void FixAveForceKokkos::operator()(TagFixAveForceApply, const int &i { if (mask[i] & groupbit) { if (region && !d_match[i]) return; - if (xstyle) f(i,0) = m_fave[0]; - if (ystyle) f(i,1) = m_fave[1]; - if (zstyle) f(i,2) = m_fave[2]; + if (xstyle) f(i,0) = static_cast(m_fave[0]); + if (ystyle) f(i,1) = static_cast(m_fave[1]); + if (zstyle) f(i,2) = static_cast(m_fave[2]); } } diff --git a/src/KOKKOS/fix_cmap_kokkos.cpp b/src/KOKKOS/fix_cmap_kokkos.cpp index 8d8e57d3252..fd43c058d2c 100644 --- a/src/KOKKOS/fix_cmap_kokkos.cpp +++ b/src/KOKKOS/fix_cmap_kokkos.cpp @@ -273,15 +273,15 @@ void FixCMAPKokkos::operator()(TagFixCmapPostForce, const int n, dou KK_FLOAT vb21x = d_x(i2,0) - d_x(i1,0); KK_FLOAT vb21y = d_x(i2,1) - d_x(i1,1); KK_FLOAT vb21z = d_x(i2,2) - d_x(i1,2); - KK_FLOAT vb12x = -1.0*vb21x; - KK_FLOAT vb12y = -1.0*vb21y; - KK_FLOAT vb12z = -1.0*vb21z; + KK_FLOAT vb12x = static_cast(-1.0)*vb21x; + KK_FLOAT vb12y = static_cast(-1.0)*vb21y; + KK_FLOAT vb12z = static_cast(-1.0)*vb21z; KK_FLOAT vb32x = d_x(i3,0) - d_x(i2,0); KK_FLOAT vb32y = d_x(i3,1) - d_x(i2,1); KK_FLOAT vb32z = d_x(i3,2) - d_x(i2,2); - KK_FLOAT vb23x = -1.0*vb32x; - KK_FLOAT vb23y = -1.0*vb32y; - KK_FLOAT vb23z = -1.0*vb32z; + KK_FLOAT vb23x = static_cast(-1.0)*vb32x; + KK_FLOAT vb23y = static_cast(-1.0)*vb32y; + KK_FLOAT vb23z = static_cast(-1.0)*vb32z; KK_FLOAT vb34x = d_x(i3,0) - d_x(i4,0); KK_FLOAT vb34y = d_x(i3,1) - d_x(i4,1); @@ -290,9 +290,9 @@ void FixCMAPKokkos::operator()(TagFixCmapPostForce, const int n, dou // psi // bond vectors same as for phi: vb32 - KK_FLOAT vb43x = -1.0*vb34x; - KK_FLOAT vb43y = -1.0*vb34y; - KK_FLOAT vb43z = -1.0*vb34z; + KK_FLOAT vb43x = static_cast(-1.0)*vb34x; + KK_FLOAT vb43y = static_cast(-1.0)*vb34y; + KK_FLOAT vb43z = static_cast(-1.0)*vb34z; KK_FLOAT vb45x = d_x(i4,0) - d_x(i5,0); KK_FLOAT vb45y = d_x(i4,1) - d_x(i5,1); @@ -318,14 +318,14 @@ void FixCMAPKokkos::operator()(TagFixCmapPostForce, const int n, dou // calculate terms used later in calculations - KK_FLOAT r32 = sqrt(vb32x*vb32x + vb32y*vb32y + vb32z*vb32z); + KK_FLOAT r32 = Kokkos::sqrt(vb32x*vb32x + vb32y*vb32y + vb32z*vb32z); KK_FLOAT a1sq = a1x*a1x + a1y*a1y + a1z*a1z; KK_FLOAT b1sq = b1x*b1x + b1y*b1y + b1z*b1z; - KK_FLOAT r43 = sqrt(vb43x*vb43x + vb43y*vb43y + vb43z*vb43z); + KK_FLOAT r43 = Kokkos::sqrt(vb43x*vb43x + vb43y*vb43y + vb43z*vb43z); KK_FLOAT a2sq = a2x*a2x + a2y*a2y + a2z*a2z; KK_FLOAT b2sq = b2x*b2x + b2y*b2y + b2z*b2z; - if (a1sq<0.0001 || b1sq<0.0001 || a2sq<0.0001 || b2sq<0.0001) return; + if (a1sq(0.0001) || b1sq(0.0001) || a2sq(0.0001) || b2sq(0.0001)) return; // vectors needed to calculate the cross-term dihedral angles @@ -340,20 +340,20 @@ void FixCMAPKokkos::operator()(TagFixCmapPostForce, const int n, dou KK_FLOAT phi = dihedral_angle_atan2(vb21x,vb21y,vb21z,a1x,a1y,a1z,b1x,b1y,b1z,r32); KK_FLOAT psi = dihedral_angle_atan2(vb32x,vb32y,vb32z,a2x,a2y,a2z,b2x,b2y,b2z,r43); - if (phi == 180.0) phi= -180.0; - if (psi == 180.0) psi= -180.0; + if (phi == static_cast(180.0)) phi= -180.0; + if (psi == static_cast(180.0)) psi= -180.0; KK_FLOAT phi1 = phi; - if (phi1 < 0.0) phi1 += 360.0; + if (phi1 < static_cast(0.0)) phi1 += static_cast(360.0); KK_FLOAT psi1 = psi; - if (psi1 < 0.0) psi1 += 360.0; + if (psi1 < static_cast(0.0)) psi1 += static_cast(360.0); // find the neighbor grid point index - int li1 = int(((phi1+CMAPXMIN2)/CMAPDX)+((CMAPDIM*1.0)/2.0)); - int li2 = int(((psi1+CMAPXMIN2)/CMAPDX)+((CMAPDIM*1.0)/2.0)); - int li3 = int((phi-CMAPXMIN2)/CMAPDX); - int li4 = int((psi-CMAPXMIN2)/CMAPDX); + int li1 = int(((static_cast(phi1)+CMAPXMIN2)/CMAPDX)+((CMAPDIM*1.0)/2.0)); + int li2 = int(((static_cast(psi1)+CMAPXMIN2)/CMAPDX)+((CMAPDIM*1.0)/2.0)); + int li3 = int((static_cast(phi)-CMAPXMIN2)/CMAPDX); + int li4 = int((static_cast(psi)-CMAPXMIN2)/CMAPDX); int mli3 = li3 % CMAPDIM; int mli4 = li4 % CMAPDIM; int mli31 = (li3+1) % CMAPDIM; @@ -394,22 +394,22 @@ void FixCMAPKokkos::operator()(TagFixCmapPostForce, const int n, dou // sum up cmap energy contributions // needed for compute_scalar() - KK_FLOAT engfraction = 0.2 * E; - if (i1 < nlocal) ecmapKK += engfraction; - if (i2 < nlocal) ecmapKK += engfraction; - if (i3 < nlocal) ecmapKK += engfraction; - if (i4 < nlocal) ecmapKK += engfraction; - if (i5 < nlocal) ecmapKK += engfraction; + KK_FLOAT engfraction = static_cast(0.2) * E; + if (i1 < nlocal) ecmapKK += static_cast(engfraction); + if (i2 < nlocal) ecmapKK += static_cast(engfraction); + if (i3 < nlocal) ecmapKK += static_cast(engfraction); + if (i4 < nlocal) ecmapKK += static_cast(engfraction); + if (i5 < nlocal) ecmapKK += static_cast(engfraction); // calculate the derivatives dphi/dr_i - KK_FLOAT dphidr1x = 1.0*r32/a1sq*a1x; - KK_FLOAT dphidr1y = 1.0*r32/a1sq*a1y; - KK_FLOAT dphidr1z = 1.0*r32/a1sq*a1z; + KK_FLOAT dphidr1x = static_cast(1.0)*r32/a1sq*a1x; + KK_FLOAT dphidr1y = static_cast(1.0)*r32/a1sq*a1y; + KK_FLOAT dphidr1z = static_cast(1.0)*r32/a1sq*a1z; - KK_FLOAT dphidr2x = -1.0*r32/a1sq*a1x - dpr21r32/a1sq/r32*a1x + dpr34r32/b1sq/r32*b1x; - KK_FLOAT dphidr2y = -1.0*r32/a1sq*a1y - dpr21r32/a1sq/r32*a1y + dpr34r32/b1sq/r32*b1y; - KK_FLOAT dphidr2z = -1.0*r32/a1sq*a1z - dpr21r32/a1sq/r32*a1z + dpr34r32/b1sq/r32*b1z; + KK_FLOAT dphidr2x = static_cast(-1.0)*r32/a1sq*a1x - dpr21r32/a1sq/r32*a1x + dpr34r32/b1sq/r32*b1x; + KK_FLOAT dphidr2y = static_cast(-1.0)*r32/a1sq*a1y - dpr21r32/a1sq/r32*a1y + dpr34r32/b1sq/r32*b1y; + KK_FLOAT dphidr2z = static_cast(-1.0)*r32/a1sq*a1z - dpr21r32/a1sq/r32*a1z + dpr34r32/b1sq/r32*b1z; KK_FLOAT dphidr3x = dpr34r32/b1sq/r32*b1x - dpr21r32/a1sq/r32*a1x - r32/b1sq*b1x; KK_FLOAT dphidr3y = dpr34r32/b1sq/r32*b1y - dpr21r32/a1sq/r32*a1y - r32/b1sq*b1y; @@ -421,9 +421,9 @@ void FixCMAPKokkos::operator()(TagFixCmapPostForce, const int n, dou // calculate the derivatives dpsi/dr_i - KK_FLOAT dpsidr1x = 1.0*r43/a2sq*a2x; - KK_FLOAT dpsidr1y = 1.0*r43/a2sq*a2y; - KK_FLOAT dpsidr1z = 1.0*r43/a2sq*a2z; + KK_FLOAT dpsidr1x = static_cast(1.0)*r43/a2sq*a2x; + KK_FLOAT dpsidr1y = static_cast(1.0)*r43/a2sq*a2y; + KK_FLOAT dpsidr1z = static_cast(1.0)*r43/a2sq*a2z; KK_FLOAT dpsidr2x = r43/a2sq*a2x + dpr32r43/a2sq/r43*a2x - dpr45r43/b2sq/r43*b2x; KK_FLOAT dpsidr2y = r43/a2sq*a2y + dpr32r43/a2sq/r43*a2y - dpr45r43/b2sq/r43*b2y; @@ -441,29 +441,29 @@ void FixCMAPKokkos::operator()(TagFixCmapPostForce, const int n, dou // apply force to each of the 5 atoms if (i1 < nlocal) { - Kokkos::atomic_add(&d_f(i1,0), dEdPhi*dphidr1x); - Kokkos::atomic_add(&d_f(i1,1), dEdPhi*dphidr1y); - Kokkos::atomic_add(&d_f(i1,2), dEdPhi*dphidr1z); + Kokkos::atomic_add(&d_f(i1,0), static_cast(dEdPhi*dphidr1x)); + Kokkos::atomic_add(&d_f(i1,1), static_cast(dEdPhi*dphidr1y)); + Kokkos::atomic_add(&d_f(i1,2), static_cast(dEdPhi*dphidr1z)); } if (i2 < nlocal) { - Kokkos::atomic_add(&d_f(i2,0), dEdPhi*dphidr2x + dEdPsi*dpsidr1x); - Kokkos::atomic_add(&d_f(i2,1), dEdPhi*dphidr2y + dEdPsi*dpsidr1y); - Kokkos::atomic_add(&d_f(i2,2), dEdPhi*dphidr2z + dEdPsi*dpsidr1z); + Kokkos::atomic_add(&d_f(i2,0), static_cast(dEdPhi*dphidr2x + dEdPsi*dpsidr1x)); + Kokkos::atomic_add(&d_f(i2,1), static_cast(dEdPhi*dphidr2y + dEdPsi*dpsidr1y)); + Kokkos::atomic_add(&d_f(i2,2), static_cast(dEdPhi*dphidr2z + dEdPsi*dpsidr1z)); } if (i3 < nlocal) { - Kokkos::atomic_add(&d_f(i3,0), -dEdPhi*dphidr3x - dEdPsi*dpsidr2x); - Kokkos::atomic_add(&d_f(i3,1), -dEdPhi*dphidr3y - dEdPsi*dpsidr2y); - Kokkos::atomic_add(&d_f(i3,2), -dEdPhi*dphidr3z - dEdPsi*dpsidr2z); + Kokkos::atomic_add(&d_f(i3,0), static_cast(-dEdPhi*dphidr3x - dEdPsi*dpsidr2x)); + Kokkos::atomic_add(&d_f(i3,1), static_cast(-dEdPhi*dphidr3y - dEdPsi*dpsidr2y)); + Kokkos::atomic_add(&d_f(i3,2), static_cast(-dEdPhi*dphidr3z - dEdPsi*dpsidr2z)); } if (i4 < nlocal) { - Kokkos::atomic_add(&d_f(i4,0), -dEdPhi*dphidr4x - dEdPsi*dpsidr3x); - Kokkos::atomic_add(&d_f(i4,1), -dEdPhi*dphidr4y - dEdPsi*dpsidr3y); - Kokkos::atomic_add(&d_f(i4,2), -dEdPhi*dphidr4z - dEdPsi*dpsidr3z); + Kokkos::atomic_add(&d_f(i4,0), static_cast(-dEdPhi*dphidr4x - dEdPsi*dpsidr3x)); + Kokkos::atomic_add(&d_f(i4,1), static_cast(-dEdPhi*dphidr4y - dEdPsi*dpsidr3y)); + Kokkos::atomic_add(&d_f(i4,2), static_cast(-dEdPhi*dphidr4z - dEdPsi*dpsidr3z)); } if (i5 < nlocal) { - Kokkos::atomic_add(&d_f(i5,0), -dEdPsi*dpsidr4x); - Kokkos::atomic_add(&d_f(i5,1), -dEdPsi*dpsidr4y); - Kokkos::atomic_add(&d_f(i5,2), -dEdPsi*dpsidr4z); + Kokkos::atomic_add(&d_f(i5,0), static_cast(-dEdPsi*dpsidr4x)); + Kokkos::atomic_add(&d_f(i5,1), static_cast(-dEdPsi*dpsidr4y)); + Kokkos::atomic_add(&d_f(i5,2), static_cast(-dEdPsi*dpsidr4z)); } } @@ -825,7 +825,7 @@ KK_FLOAT FixCMAPKokkos::dihedral_angle_atan2(KK_FLOAT fx, KK_FLOAT f Kokkos::abort("CMAP: atan2 function cannot take 2 zero arguments"); else { angle = Kokkos::atan2(arg1,arg2); - angle = angle*180.0/MY_PI; + angle = angle*static_cast(180.0)/static_cast(MY_PI); } return angle; @@ -870,9 +870,9 @@ void FixCMAPKokkos::bc_interpol(KK_FLOAT x1, KK_FLOAT x2, int low1, for (i = 0; i < 4; i++) { x[i] = gs[i]; - x[i+4] = d1gs[i]*CMAPDX; - x[i+8] = d2gs[i]*CMAPDX; - x[i+12] = d12gs[i]*CMAPDX*CMAPDX; + x[i+4] = d1gs[i]*static_cast(CMAPDX); + x[i+8] = d2gs[i]*static_cast(CMAPDX); + x[i+12] = d12gs[i]*static_cast(CMAPDX)*static_cast(CMAPDX); } in = 0; @@ -897,19 +897,19 @@ void FixCMAPKokkos::bc_interpol(KK_FLOAT x1, KK_FLOAT x2, int low1, gs1l = d_g_axis(low1); gs2l = d_g_axis(low2); - t = (x1-gs1l)/CMAPDX; - u = (x2-gs2l)/CMAPDX; + t = (x1-gs1l)/static_cast(CMAPDX); + u = (x2-gs2l)/static_cast(CMAPDX); E = dEdPhi = dEdPsi = 0.0; for (i = 3; i >= 0; i--) { E = t*E + ((cij[i][3]*u+cij[i][2])*u+cij[i][1])*u+cij[i][0]; - dEdPhi = u*dEdPhi + (3.0*cij[3][i]*t+2.0*cij[2][i])*t+cij[1][i]; - dEdPsi = t*dEdPsi + (3.0*cij[i][3]*u+2.0*cij[i][2])*u+cij[i][1]; + dEdPhi = u*dEdPhi + (static_cast(3.0)*cij[3][i]*t+static_cast(2.0)*cij[2][i])*t+cij[1][i]; + dEdPsi = t*dEdPsi + (static_cast(3.0)*cij[i][3]*u+static_cast(2.0)*cij[i][2])*u+cij[i][1]; } - dEdPhi *= (180.0/MY_PI/CMAPDX); - dEdPsi *= (180.0/MY_PI/CMAPDX); + dEdPhi *= static_cast(180.0/MY_PI/CMAPDX); + dEdPsi *= static_cast(180.0/MY_PI/CMAPDX); } /* ---------------------------------------------------------------------- diff --git a/src/KOKKOS/fix_dpd_energy_kokkos.cpp b/src/KOKKOS/fix_dpd_energy_kokkos.cpp index a813246990c..f9ed362bf4f 100644 --- a/src/KOKKOS/fix_dpd_energy_kokkos.cpp +++ b/src/KOKKOS/fix_dpd_energy_kokkos.cpp @@ -57,12 +57,12 @@ void FixDPDenergyKokkos::take_half_step() pairDPDEKK->k_duMech.template sync(); typename AT::t_kkfloat_1d_const duMech = pairDPDEKK->k_duMech.template view(); - auto dt = update->dt; + const KK_FLOAT dt = static_cast(update->dt); Kokkos::parallel_for(Kokkos::RangePolicy(0,nlocal), LAMMPS_LAMBDA(int i) { - uCond(i) += 0.5*dt*duCond(i); - uMech(i) += 0.5*dt*duMech(i); + uCond(i) += static_cast(0.5)*dt*duCond(i); + uMech(i) += static_cast(0.5)*dt*duMech(i); }); atomKK->modified(execution_space, UCOND_MASK); diff --git a/src/KOKKOS/fix_drag_kokkos.cpp b/src/KOKKOS/fix_drag_kokkos.cpp index 62cc31f370c..e668e813695 100644 --- a/src/KOKKOS/fix_drag_kokkos.cpp +++ b/src/KOKKOS/fix_drag_kokkos.cpp @@ -116,18 +116,18 @@ void FixDragKokkos::operator()(TagFixDrag, const int &i, value_type if (!yflag) dy = 0.0; if (!zflag) dz = 0.0; minimum_image(dx, dy, dz); - KK_FLOAT r = sqrt(dx*dx + dy*dy + dz*dz); + KK_FLOAT r = Kokkos::sqrt(dx*dx + dy*dy + dz*dz); if (r > (KK_FLOAT) delta) { KK_FLOAT prefactor = (KK_FLOAT) f_mag / r; KK_FLOAT fx = prefactor * dx; KK_FLOAT fy = prefactor * dy; KK_FLOAT fz = prefactor * dz; - f(i,0) -= fx; - f(i,1) -= fy; - f(i,2) -= fz; - result[0] -= fx; - result[1] -= fy; - result[2] -= fz; + f(i,0) -= static_cast(fx); + f(i,1) -= static_cast(fy); + f(i,2) -= static_cast(fz); + result[0] -= static_cast(fx); + result[1] -= static_cast(fy); + result[2] -= static_cast(fz); } } } diff --git a/src/KOKKOS/fix_dt_reset_kokkos.cpp b/src/KOKKOS/fix_dt_reset_kokkos.cpp index 65a7eb42a6d..970bcb764e6 100644 --- a/src/KOKKOS/fix_dt_reset_kokkos.cpp +++ b/src/KOKKOS/fix_dt_reset_kokkos.cpp @@ -118,24 +118,26 @@ void FixDtResetKokkos::operator()(TagFixDtResetMass, const int &i, d if (mask[i] & groupbit) { - massinv = 1.0 / mass[type[i]]; + const KK_FLOAT xmax_kk = static_cast(xmax); + const KK_FLOAT ftm2v_kk = static_cast(ftm2v); + massinv = static_cast(1.0) / mass[type[i]]; vsq = v(i,0) * v(i,0) + v(i,1) * v(i,1) + v(i,2) * v(i,2); - fsq = f(i,0) * f(i,0) + f(i,1) * f(i,1) + f(i,2) * f(i,2); - dtv = dtf = dte = BIG; - if (vsq > 0.0) dtv = xmax / sqrt(vsq); - if (fsq > 0.0) dtf = sqrt(2.0 * xmax / (ftm2v * sqrt(fsq) * massinv)); + fsq = static_cast(f(i,0) * f(i,0) + f(i,1) * f(i,1) + f(i,2) * f(i,2)); + dtv = dtf = dte = static_cast(BIG); + if (vsq > static_cast(0.0)) dtv = xmax_kk / Kokkos::sqrt(vsq); + if (fsq > static_cast(0.0)) dtf = Kokkos::sqrt(static_cast(2.0) * xmax_kk / (ftm2v_kk * Kokkos::sqrt(fsq) * massinv)); dt = MIN(dtv, dtf); - if ((emax > 0.0) && (fsq * vsq > 0.0)) { - dte = emax / sqrt(fsq * vsq) / sqrt(ftm2v * mvv2e); + if ((emax > 0.0) && (fsq * vsq > static_cast(0.0))) { + dte = static_cast(emax) / Kokkos::sqrt(fsq * vsq) / Kokkos::sqrt(ftm2v_kk * static_cast(mvv2e)); dt = MIN(dt, dte); } dtsq = dt * dt; - delx = dt * v(i,0) + 0.5 * dtsq * massinv * f(i,0) * ftm2v; - dely = dt * v(i,1) + 0.5 * dtsq * massinv * f(i,1) * ftm2v; - delz = dt * v(i,2) + 0.5 * dtsq * massinv * f(i,2) * ftm2v; - delr = sqrt(delx * delx + dely * dely + delz * delz); - if (delr > xmax) dt *= xmax / delr; - dt_min = MIN(dt_min,dt); + delx = dt * v(i,0) + static_cast(0.5) * dtsq * massinv * static_cast(f(i,0)) * ftm2v_kk; + dely = dt * v(i,1) + static_cast(0.5) * dtsq * massinv * static_cast(f(i,1)) * ftm2v_kk; + delz = dt * v(i,2) + static_cast(0.5) * dtsq * massinv * static_cast(f(i,2)) * ftm2v_kk; + delr = Kokkos::sqrt(delx * delx + dely * dely + delz * delz); + if (delr > xmax_kk) dt *= xmax_kk / delr; + dt_min = MIN(dt_min,static_cast(dt)); } } @@ -152,24 +154,26 @@ void FixDtResetKokkos::operator()(TagFixDtResetRMass, const int &i, if (mask[i] & groupbit) { - massinv = 1.0 / rmass[i]; + const KK_FLOAT xmax_kk = static_cast(xmax); + const KK_FLOAT ftm2v_kk = static_cast(ftm2v); + massinv = static_cast(1.0) / rmass[i]; vsq = v(i,0) * v(i,0) + v(i,1) * v(i,1) + v(i,2) * v(i,2); - fsq = f(i,0) * f(i,0) + f(i,1) * f(i,1) + f(i,2) * f(i,2); - dtv = dtf = dte = BIG; - if (vsq > 0.0) dtv = xmax / sqrt(vsq); - if (fsq > 0.0) dtf = sqrt(2.0 * xmax / (ftm2v * sqrt(fsq) * massinv)); + fsq = static_cast(f(i,0) * f(i,0) + f(i,1) * f(i,1) + f(i,2) * f(i,2)); + dtv = dtf = dte = static_cast(BIG); + if (vsq > static_cast(0.0)) dtv = xmax_kk / Kokkos::sqrt(vsq); + if (fsq > static_cast(0.0)) dtf = Kokkos::sqrt(static_cast(2.0) * xmax_kk / (ftm2v_kk * Kokkos::sqrt(fsq) * massinv)); dt = MIN(dtv, dtf); - if ((emax > 0.0) && (fsq * vsq > 0.0)) { - dte = emax / sqrt(fsq * vsq) / sqrt(ftm2v * mvv2e); + if ((emax > 0.0) && (fsq * vsq > static_cast(0.0))) { + dte = static_cast(emax) / Kokkos::sqrt(fsq * vsq) / Kokkos::sqrt(ftm2v_kk * static_cast(mvv2e)); dt = MIN(dt, dte); } dtsq = dt * dt; - delx = dt * v(i,0) + 0.5 * dtsq * massinv * f(i,0) * ftm2v; - dely = dt * v(i,1) + 0.5 * dtsq * massinv * f(i,1) * ftm2v; - delz = dt * v(i,2) + 0.5 * dtsq * massinv * f(i,2) * ftm2v; - delr = sqrt(delx * delx + dely * dely + delz * delz); - if (delr > xmax) dt *= xmax / delr; - dt_min = MIN(dt_min,dt); + delx = dt * v(i,0) + static_cast(0.5) * dtsq * massinv * static_cast(f(i,0)) * ftm2v_kk; + dely = dt * v(i,1) + static_cast(0.5) * dtsq * massinv * static_cast(f(i,1)) * ftm2v_kk; + delz = dt * v(i,2) + static_cast(0.5) * dtsq * massinv * static_cast(f(i,2)) * ftm2v_kk; + delr = Kokkos::sqrt(delx * delx + dely * dely + delz * delz); + if (delr > xmax_kk) dt *= xmax_kk / delr; + dt_min = MIN(dt_min,static_cast(dt)); } } diff --git a/src/KOKKOS/fix_efield_kokkos.cpp b/src/KOKKOS/fix_efield_kokkos.cpp index 90b5ea72b0a..609045cb3f9 100644 --- a/src/KOKKOS/fix_efield_kokkos.cpp +++ b/src/KOKKOS/fix_efield_kokkos.cpp @@ -205,29 +205,29 @@ void FixEfieldKokkos::operator()(TagFixEfieldConstant, if (region && !d_match[i]) return; Few x_i; - x_i[0] = d_x(i,0); - x_i[1] = d_x(i,1); - x_i[2] = d_x(i,2); + x_i[0] = static_cast(d_x(i,0)); + x_i[1] = static_cast(d_x(i,1)); + x_i[2] = static_cast(d_x(i,2)); auto unwrapKK = DomainKokkos::unmap(prd,h,triclinic,x_i,d_image(i)); - const KK_FLOAT fx = d_q(i) * ex; - const KK_FLOAT fy = d_q(i) * ey; - const KK_FLOAT fz = d_q(i) * ez; - d_f(i,0) += fx; - d_f(i,1) += fy; - d_f(i,2) += fz; - result[0] -= fx * unwrapKK[0] + fy * unwrapKK[1] + fz * unwrapKK[2]; - result[1] += fx; - result[2] += fy; - result[3] += fz; + const KK_FLOAT fx = d_q(i) * static_cast(ex); + const KK_FLOAT fy = d_q(i) * static_cast(ey); + const KK_FLOAT fz = d_q(i) * static_cast(ez); + d_f(i,0) += static_cast(fx); + d_f(i,1) += static_cast(fy); + d_f(i,2) += static_cast(fz); + result[0] -= static_cast(fx) * unwrapKK[0] + static_cast(fy) * unwrapKK[1] + static_cast(fz) * unwrapKK[2]; + result[1] += static_cast(fx); + result[2] += static_cast(fy); + result[3] += static_cast(fz); if (evflag) { KK_FLOAT v[6]; - v[0] = fx * unwrapKK[0]; - v[1] = fy * unwrapKK[1]; - v[2] = fz * unwrapKK[2]; - v[3] = fx * unwrapKK[1]; - v[4] = fx * unwrapKK[2]; - v[5] = fy * unwrapKK[2]; + v[0] = fx * static_cast(unwrapKK[0]); + v[1] = fy * static_cast(unwrapKK[1]); + v[2] = fz * static_cast(unwrapKK[2]); + v[3] = fx * static_cast(unwrapKK[1]); + v[4] = fx * static_cast(unwrapKK[2]); + v[5] = fy * static_cast(unwrapKK[2]); v_tally(result, i, v); } @@ -235,10 +235,10 @@ void FixEfieldKokkos::operator()(TagFixEfieldConstant, if (MUFLAG && (d_mask(i) & groupbit)) { if (region && !d_match[i]) return; - d_torque(i,0) += ez * d_mu(i,1) - ey * d_mu(i,2); - d_torque(i,1) += ex * d_mu(i,2) - ez * d_mu(i,0); - d_torque(i,2) += ey * d_mu(i,0) - ex * d_mu(i,1); - result[0] -= d_mu(i,0) * ex + d_mu(i,1) * ey + d_mu(i,2) * ez; + d_torque(i,0) += static_cast(static_cast(ez) * d_mu(i,1) - static_cast(ey) * d_mu(i,2)); + d_torque(i,1) += static_cast(static_cast(ex) * d_mu(i,2) - static_cast(ez) * d_mu(i,0)); + d_torque(i,2) += static_cast(static_cast(ey) * d_mu(i,0) - static_cast(ex) * d_mu(i,1)); + result[0] -= static_cast(d_mu(i,0)) * ex + static_cast(d_mu(i,1)) * ey + static_cast(d_mu(i,2)) * ez; } } @@ -252,29 +252,29 @@ void FixEfieldKokkos::operator()(TagFixEfieldNonConstant(qe2f) * d_q(i) * d_efield(i,0); + else fx = d_q(i) * static_cast(ex); + if (ystyle == ATOM) fy = static_cast(qe2f) * d_q(i) * d_efield(i,1); + else fy = d_q(i) * static_cast(ey); + if (zstyle == ATOM) fz = static_cast(qe2f) * d_q(i) * d_efield(i,2); + else fz = d_q(i) * static_cast(ez); + + d_f(i,0) += static_cast(fx); + d_f(i,1) += static_cast(fy); + d_f(i,2) += static_cast(fz); + result[1] += static_cast(fx); + result[2] += static_cast(fy); + result[3] += static_cast(fz); + + if (pstyle == ATOM) result[0] += qe2f * static_cast(d_q(i)) * static_cast(d_efield(i,3)); + else if (estyle == ATOM) result[0] += static_cast(d_efield(i,3)); } if (MUFLAG && (d_mask(i) & groupbit)) { if (region && !d_match[i]) return; - d_torque(i,0) += ez * d_mu(i,1) - ey * d_mu(i,2); - d_torque(i,1) += ex * d_mu(i,2) - ez * d_mu(i,0); - d_torque(i,2) += ey * d_mu(i,0) - ex * d_mu(i,1); + d_torque(i,0) += static_cast(static_cast(ez) * d_mu(i,1) - static_cast(ey) * d_mu(i,2)); + d_torque(i,1) += static_cast(static_cast(ex) * d_mu(i,2) - static_cast(ez) * d_mu(i,0)); + d_torque(i,2) += static_cast(static_cast(ey) * d_mu(i,0) - static_cast(ex) * d_mu(i,1)); } } @@ -296,21 +296,21 @@ KOKKOS_INLINE_FUNCTION void FixEfieldKokkos::v_tally(value_type result, int i, KK_FLOAT *v) const { if (vflag_global) { - result[4] += v[0]; - result[5] += v[1]; - result[6] += v[2]; - result[7] += v[3]; - result[8] += v[4]; - result[9] += v[5]; + result[4] += static_cast(v[0]); + result[5] += static_cast(v[1]); + result[6] += static_cast(v[2]); + result[7] += static_cast(v[3]); + result[8] += static_cast(v[4]); + result[9] += static_cast(v[5]); } if (vflag_atom) { - Kokkos::atomic_add(&(d_vatom(i,0)),v[0]); - Kokkos::atomic_add(&(d_vatom(i,1)),v[1]); - Kokkos::atomic_add(&(d_vatom(i,2)),v[2]); - Kokkos::atomic_add(&(d_vatom(i,3)),v[3]); - Kokkos::atomic_add(&(d_vatom(i,4)),v[4]); - Kokkos::atomic_add(&(d_vatom(i,5)),v[5]); + Kokkos::atomic_add(&(d_vatom(i,0)),static_cast(v[0])); + Kokkos::atomic_add(&(d_vatom(i,1)),static_cast(v[1])); + Kokkos::atomic_add(&(d_vatom(i,2)),static_cast(v[2])); + Kokkos::atomic_add(&(d_vatom(i,3)),static_cast(v[3])); + Kokkos::atomic_add(&(d_vatom(i,4)),static_cast(v[4])); + Kokkos::atomic_add(&(d_vatom(i,5)),static_cast(v[5])); } } diff --git a/src/KOKKOS/fix_electron_stopping_kokkos.cpp b/src/KOKKOS/fix_electron_stopping_kokkos.cpp index f67718d7dda..0625061b7a7 100644 --- a/src/KOKKOS/fix_electron_stopping_kokkos.cpp +++ b/src/KOKKOS/fix_electron_stopping_kokkos.cpp @@ -140,8 +140,8 @@ FixElectronStoppingKokkos::operator()(TagFixElectronStopping, const if (region && !d_match(i)) return; int itype = type(i); - double massone = (d_rmass.data()) ? d_rmass(i) : d_mass(itype); - double v2 = v(i, 0) * v(i, 0) + v(i, 1) * v(i, 1) + v(i, 2) * v(i, 2); + double massone = (d_rmass.data()) ? static_cast(d_rmass(i)) : static_cast(d_mass(itype)); + double v2 = static_cast(v(i, 0) * v(i, 0) + v(i, 1) * v(i, 1) + v(i, 2) * v(i, 2)); double energy = 0.5 * mvv2e * massone * v2; if (energy < Ecut) return; @@ -174,9 +174,9 @@ FixElectronStoppingKokkos::operator()(TagFixElectronStopping, const double vabs = Kokkos::sqrt(v2); double factor = -Se / vabs; - f(i, 0) += v(i, 0) * factor; - f(i, 1) += v(i, 1) * factor; - f(i, 2) += v(i, 2) * factor; + f(i, 0) += static_cast(v(i, 0) * static_cast(factor)); + f(i, 1) += static_cast(v(i, 1) * static_cast(factor)); + f(i, 2) += static_cast(v(i, 2) * static_cast(factor)); seloss += Se * vabs * dt; } diff --git a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp index da800d43f4e..9ee9de6f175 100644 --- a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp +++ b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp @@ -60,10 +60,10 @@ FixEOStableRXKokkos::FixEOStableRXKokkos(LAMMPS *lmp, int narg, char k_tempCorrCoeff = DAT::tdual_kkfloat_1d("fix:tempCorrCoeff",nspecies); k_moleculeCorrCoeff = DAT::tdual_kkfloat_1d("fix:moleculeCorrCoeff",nspecies); for (int n = 0; n < nspecies; n++) { - k_dHf.view_host()(n) = dHf[n]; - k_energyCorr.view_host()(n) = energyCorr[n]; - k_tempCorrCoeff.view_host()(n) = tempCorrCoeff[n]; - k_moleculeCorrCoeff.view_host()(n) = moleculeCorrCoeff[n]; + k_dHf.view_host()(n) = static_cast(dHf[n]); + k_energyCorr.view_host()(n) = static_cast(energyCorr[n]); + k_tempCorrCoeff.view_host()(n) = static_cast(tempCorrCoeff[n]); + k_moleculeCorrCoeff.view_host()(n) = static_cast(moleculeCorrCoeff[n]); } k_dHf.modify_host(); @@ -207,7 +207,7 @@ KOKKOS_INLINE_FUNCTION void FixEOStableRXKokkos::operator()(TagFixEOStableRXInit, const int &i) const { KK_FLOAT tmp; if (mask[i] & groupbit) { - if (dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= static_cast(0.0)) k_error_flag.template view()() = 1; energy_lookup(i,dpdTheta[i],tmp); uCond[i] = 0.0; @@ -255,7 +255,7 @@ KOKKOS_INLINE_FUNCTION void FixEOStableRXKokkos::operator()(TagFixEOStableRXTemperatureLookup2, const int &i) const { if (mask[i] & groupbit) { temperature_lookup(i,uCond[i]+uMech[i]+uChem[i],dpdTheta[i]); - if (dpdTheta[i] <= 0.0) + if (dpdTheta[i] <= static_cast(0.0)) k_error_flag.template view()() = 1; } } @@ -320,7 +320,8 @@ void FixEOStableRXKokkos::energy_lookup(int id, KK_FLOAT thetai, KK_ { int itable, nPG; KK_FLOAT fraction, uTmp, nMolecules, nTotal, nTotalPG; - KK_FLOAT tolerance = 1.0e-10; + KK_FLOAT tolerance = static_cast(1.0e-10); + const KK_FLOAT boltz_kk = static_cast(boltz); ui = 0.0; nTotal = 0.0; @@ -332,7 +333,7 @@ void FixEOStableRXKokkos::energy_lookup(int id, KK_FLOAT thetai, KK_ const auto atom_ind = species_ind_to_atom_prop_ind(ispecies); nTotal += dvector(atom_ind,id); - if (fabs(d_moleculeCorrCoeff[ispecies]) > tolerance) { + if (Kokkos::fabs(d_moleculeCorrCoeff[ispecies]) > tolerance) { nPG++; nTotalPG += dvector(atom_ind,id); } @@ -370,7 +371,7 @@ void FixEOStableRXKokkos::energy_lookup(int id, KK_FLOAT thetai, KK_ ui += nMolecules*uTmp; } } - ui = ui - KK_FLOAT(nTotal+1.5)*boltz*thetai; + ui = ui - KK_FLOAT(nTotal+static_cast(1.5))*boltz_kk*thetai; } /* ---------------------------------------------------------------------- @@ -388,8 +389,8 @@ void FixEOStableRXKokkos::temperature_lookup(int id, KK_FLOAT ui, KK KK_FLOAT t1,t2,u1,u2,f1,f2; KK_FLOAT maxit = 100; KK_FLOAT temp; - KK_FLOAT delta = 0.001; - KK_FLOAT tolerance = 1.0e-10; + KK_FLOAT delta = static_cast(0.001); + KK_FLOAT tolerance = static_cast(1.0e-10); int lo = d_table_const.lo(0); int hi = d_table_const.hi(0); @@ -405,7 +406,7 @@ void FixEOStableRXKokkos::temperature_lookup(int id, KK_FLOAT ui, KK f1 = u1 - ui; // Compute guess of t2 - t2 = (1.0 + delta)*t1; + t2 = (static_cast(1.0) + delta)*t1; // Compute u2 at t2 energy_lookup(id,t2,u2); @@ -415,7 +416,7 @@ void FixEOStableRXKokkos::temperature_lookup(int id, KK_FLOAT ui, KK // Apply the Secant Method for (it=0; it(MY_EPSILON)) { if (std::isnan(f1) || std::isnan(f2)) k_error_flag.template view()() = 2; temp = t1; temp = MAX(temp,lo); @@ -424,7 +425,7 @@ void FixEOStableRXKokkos::temperature_lookup(int id, KK_FLOAT ui, KK break; } temp = t2 - f2*(t2-t1)/(f2-f1); - if (fabs(temp-t2) < tolerance) break; + if (Kokkos::fabs(temp-t2) < tolerance) break; f1 = f2; t1 = t2; t2 = temp; @@ -561,14 +562,14 @@ void FixEOStableRXKokkos::create_kokkos_tables() h_table->lo[i] = tb->lo; h_table->hi[i] = tb->hi; - h_table->invdelta[i] = tb->invdelta; + h_table->invdelta[i] = static_cast(tb->invdelta); for (int j = 0; j < (int)h_table->r.extent(1); j++) - h_table->r(i,j) = tb->r[j]; + h_table->r(i,j) = static_cast(tb->r[j]); for (int j = 0; j < (int)h_table->e.extent(1); j++) - h_table->e(i,j) = tb->e[j]; + h_table->e(i,j) = static_cast(tb->e[j]); for (int j = 0; j < (int)h_table->de.extent(1); j++) - h_table->de(i,j) = tb->de[j]; + h_table->de(i,j) = static_cast(tb->de[j]); } Kokkos::deep_copy(d_table->lo,h_table->lo); diff --git a/src/KOKKOS/fix_external_kokkos.cpp b/src/KOKKOS/fix_external_kokkos.cpp index 1d6cc92c502..a2eea86e0fb 100644 --- a/src/KOKKOS/fix_external_kokkos.cpp +++ b/src/KOKKOS/fix_external_kokkos.cpp @@ -117,9 +117,9 @@ template KOKKOS_INLINE_FUNCTION void FixExternalKokkos::operator()(TagFixExternal, const int &i) const { if (mask[i] & groupbit) { - f(i,0) += d_fexternal(i,0); - f(i,1) += d_fexternal(i,1); - f(i,2) += d_fexternal(i,2); + f(i,0) += static_cast(d_fexternal(i,0)); + f(i,1) += static_cast(d_fexternal(i,1)); + f(i,2) += static_cast(d_fexternal(i,2)); } } diff --git a/src/KOKKOS/fix_langevin_kokkos.cpp b/src/KOKKOS/fix_langevin_kokkos.cpp index 8cbec188bc9..e826868bb16 100644 --- a/src/KOKKOS/fix_langevin_kokkos.cpp +++ b/src/KOKKOS/fix_langevin_kokkos.cpp @@ -168,11 +168,11 @@ void FixLangevinKokkos::post_force(int /*vflag*/) k_gfactor2.template sync(); k_ratio.template sync(); - boltz = force->boltz; - dt = update->dt; - mvv2e = force->mvv2e; - ftm2v = force->ftm2v; - fran_prop_const = sqrt(24.0*boltz/t_period/dt/mvv2e); + boltz = static_cast(force->boltz); + dt = static_cast(update->dt); + mvv2e = static_cast(force->mvv2e); + ftm2v = static_cast(force->ftm2v); + fran_prop_const = Kokkos::sqrt(static_cast(24.0)*boltz/static_cast(t_period)/dt/mvv2e); compute_target(); // modifies tforce vector, hence sync here k_tforce.template sync(); @@ -378,9 +378,9 @@ void FixLangevinKokkos::post_force(int /*vflag*/) if (zeroflag) { fsum[0] = s_fsum.fx; fsum[1] = s_fsum.fy; fsum[2] = s_fsum.fz; MPI_Allreduce(fsum,fsumall,3,MPI_DOUBLE,MPI_SUM,world); - h_fsumall(0) = fsumall[0]/count; - h_fsumall(1) = fsumall[1]/count; - h_fsumall(2) = fsumall[2]/count; + h_fsumall(0) = static_cast(fsumall[0]/count); + h_fsumall(1) = static_cast(fsumall[1]/count); + h_fsumall(2) = static_cast(fsumall[2]/count); k_fsumall.modify_host(); k_fsumall.template sync(); // set total force zero in parallel on the device @@ -407,42 +407,42 @@ FSUM FixLangevinKokkos::post_force_item(int i) const FSUM fsum; KK_FLOAT fdrag[3],fran[3]; KK_FLOAT gamma1,gamma2; - KK_FLOAT tsqrt_t = tsqrt; + KK_FLOAT tsqrt_t = static_cast(tsqrt); if (mask[i] & groupbit) { rand_type rand_gen = rand_pool.get_state(); - if (Tp_TSTYLEATOM) tsqrt_t = sqrt(d_tforce[i]); + if (Tp_TSTYLEATOM) tsqrt_t = Kokkos::sqrt(d_tforce[i]); if (Tp_RMASS) { - gamma1 = -rmass[i] / t_period / ftm2v; - gamma2 = sqrt(rmass[i]) * fran_prop_const / ftm2v; - gamma1 *= 1.0/d_ratio[type[i]]; - gamma2 *= 1.0/sqrt(d_ratio[type[i]]) * tsqrt_t; + gamma1 = -rmass[i] / static_cast(t_period) / ftm2v; + gamma2 = Kokkos::sqrt(rmass[i]) * fran_prop_const / ftm2v; + gamma1 *= static_cast(1.0)/d_ratio[type[i]]; + gamma2 *= static_cast(1.0)/Kokkos::sqrt(d_ratio[type[i]]) * tsqrt_t; } else { gamma1 = d_gfactor1[type[i]]; gamma2 = d_gfactor2[type[i]] * tsqrt_t; } - fran[0] = gamma2 * (rand_gen.drand() - 0.5); //(random->uniform()-0.5); - fran[1] = gamma2 * (rand_gen.drand() - 0.5); //(random->uniform()-0.5); - fran[2] = gamma2 * (rand_gen.drand() - 0.5); //(random->uniform()-0.5); + fran[0] = gamma2 * static_cast(rand_gen.drand() - 0.5); //(random->uniform()-0.5); + fran[1] = gamma2 * static_cast(rand_gen.drand() - 0.5); //(random->uniform()-0.5); + fran[2] = gamma2 * static_cast(rand_gen.drand() - 0.5); //(random->uniform()-0.5); if (Tp_BIAS) { fdrag[0] = gamma1*v(i,0); fdrag[1] = gamma1*v(i,1); fdrag[2] = gamma1*v(i,2); - if (v(i,0) == 0.0) fran[0] = 0.0; - if (v(i,1) == 0.0) fran[1] = 0.0; - if (v(i,2) == 0.0) fran[2] = 0.0; + if (v(i,0) == static_cast(0.0)) fran[0] = 0.0; + if (v(i,1) == static_cast(0.0)) fran[1] = 0.0; + if (v(i,2) == static_cast(0.0)) fran[2] = 0.0; } else { fdrag[0] = gamma1*v(i,0); fdrag[1] = gamma1*v(i,1); fdrag[2] = gamma1*v(i,2); } - f(i,0) += fdrag[0] + fran[0]; - f(i,1) += fdrag[1] + fran[1]; - f(i,2) += fdrag[2] + fran[2]; + f(i,0) += static_cast(fdrag[0] + fran[0]); + f(i,1) += static_cast(fdrag[1] + fran[1]); + f(i,2) += static_cast(fdrag[2] + fran[2]); if (Tp_TALLY) { d_flangevin(i,0) = fdrag[0] + fran[0]; @@ -451,9 +451,9 @@ FSUM FixLangevinKokkos::post_force_item(int i) const } if (Tp_ZERO) { - fsum.fx = fran[0]; - fsum.fy = fran[1]; - fsum.fz = fran[2]; + fsum.fx = static_cast(fran[0]); + fsum.fy = static_cast(fran[1]); + fsum.fz = static_cast(fran[2]); } rand_pool.free_state(rand_gen); } @@ -469,9 +469,9 @@ KOKKOS_INLINE_FUNCTION void FixLangevinKokkos::zero_force_item(int i) const { if (mask[i] & groupbit) { - f(i,0) -= d_fsumall[0]; - f(i,1) -= d_fsumall[1]; - f(i,2) -= d_fsumall[2]; + f(i,0) -= static_cast(d_fsumall[0]); + f(i,1) -= static_cast(d_fsumall[1]); + f(i,2) -= static_cast(d_fsumall[2]); } } @@ -566,25 +566,25 @@ void FixLangevinKokkos::omega_thermostat_item(int i) const constexpr double SINERTIA = 0.4; // sphere: I = 2/5 m r^2 constexpr double tendivthree = 10.0/3.0; - if ((mask(i) & groupbit) && (d_radius(i) > 0.0)) { + if ((mask(i) & groupbit) && (d_radius(i) > static_cast(0.0))) { rand_type rand_gen = rand_pool.get_state(); double tsqrt_t = tsqrt; - if (Tp_TSTYLEATOM) tsqrt_t = sqrt(d_tforce[i]); + if (Tp_TSTYLEATOM) tsqrt_t = sqrt(static_cast(d_tforce[i])); // Calculate moment of inertia: I = 0.4 * r^2 * m - double inertiaone = SINERTIA * d_radius(i) * d_radius(i) * rmass(i); + double inertiaone = SINERTIA * static_cast(d_radius(i)) * static_cast(d_radius(i)) * static_cast(rmass(i)); // Drag prefactor gamma1 - double gamma1 = -tendivthree * inertiaone / t_period / ftm2v; + double gamma1 = -tendivthree * inertiaone / t_period / static_cast(ftm2v); // Random force prefactor gamma2 // Uses 80.0 to match the CPU version's rotational fluctuation-dissipation double gamma2 = sqrt(inertiaone) * - sqrt(80.0 * boltz / t_period / dt / mvv2e) / ftm2v; + sqrt(80.0 * static_cast(boltz) / t_period / static_cast(dt) / static_cast(mvv2e)) / static_cast(ftm2v); - gamma1 *= 1.0 / d_ratio(type(i)); - gamma2 *= 1.0 / sqrt(d_ratio(type(i))) * tsqrt_t; + gamma1 *= 1.0 / static_cast(d_ratio(type(i))); + gamma2 *= 1.0 / sqrt(static_cast(d_ratio(type(i)))) * tsqrt_t; // Generate random torque components double tran0 = gamma2 * (rand_gen.drand() - 0.5); @@ -592,9 +592,9 @@ void FixLangevinKokkos::omega_thermostat_item(int i) const double tran2 = gamma2 * (rand_gen.drand() - 0.5); // Apply updates to torque - d_torque(i,0) += gamma1 * d_omega(i,0) + tran0; - d_torque(i,1) += gamma1 * d_omega(i,1) + tran1; - d_torque(i,2) += gamma1 * d_omega(i,2) + tran2; + d_torque(i,0) += static_cast(gamma1 * static_cast(d_omega(i,0)) + tran0); + d_torque(i,1) += static_cast(gamma1 * static_cast(d_omega(i,1)) + tran1); + d_torque(i,2) += static_cast(gamma1 * static_cast(d_omega(i,2)) + tran2); rand_pool.free_state(rand_gen); } @@ -635,32 +635,34 @@ void FixLangevinKokkos::angmom_thermostat_item(int i) const double *shape, *quat; KK_FLOAT angm[3]; // local angmom vector to pass into mq_to_omega - KK_FLOAT tsqrt_t = tsqrt; + KK_FLOAT tsqrt_t = static_cast(tsqrt); + const KK_FLOAT ascale_kk = static_cast(ascale); + const KK_FLOAT t_period_kk = static_cast(t_period); if (mask[i] & groupbit) { rand_type rand_gen = rand_pool.get_state(); shape = bonus(ellipsoid(i)).shape; - inertia[0] = EINERTIA*rmass[i] * (shape[1]*shape[1]+shape[2]*shape[2]); - inertia[1] = EINERTIA*rmass[i] * (shape[0]*shape[0]+shape[2]*shape[2]); - inertia[2] = EINERTIA*rmass[i] * (shape[0]*shape[0]+shape[1]*shape[1]); + inertia[0] = static_cast(EINERTIA*static_cast(rmass[i]) * (shape[1]*shape[1]+shape[2]*shape[2])); + inertia[1] = static_cast(EINERTIA*static_cast(rmass[i]) * (shape[0]*shape[0]+shape[2]*shape[2])); + inertia[2] = static_cast(EINERTIA*static_cast(rmass[i]) * (shape[0]*shape[0]+shape[1]*shape[1])); quat = bonus(ellipsoid(i)).quat; angm[0] = angmom(i,0); angm[1] = angmom(i,1); angm[2] = angmom(i,2); MathExtraKokkos::mq_to_omega(angm,quat,inertia,omega); - if (tstyle == ATOM) tsqrt_t = sqrt(d_tforce[i]); - gamma1 = -ascale / t_period / ftm2v; - gamma2 = sqrt(ascale*24.0*boltz/t_period/dt/mvv2e) / ftm2v; - gamma1 *= 1.0/d_ratio[type[i]]; - gamma2 *= 1.0/sqrt(d_ratio[type[i]]) * tsqrt_t; - tran[0] = sqrt(inertia[0])*gamma2*(rand_gen.drand()-0.5); - tran[1] = sqrt(inertia[1])*gamma2*(rand_gen.drand()-0.5); - tran[2] = sqrt(inertia[2])*gamma2*(rand_gen.drand()-0.5); - torque(i,0) += inertia[0]*gamma1*omega[0] + tran[0]; - torque(i,1) += inertia[1]*gamma1*omega[1] + tran[1]; - torque(i,2) += inertia[2]*gamma1*omega[2] + tran[2]; + if (tstyle == ATOM) tsqrt_t = Kokkos::sqrt(d_tforce[i]); + gamma1 = -ascale_kk / t_period_kk / ftm2v; + gamma2 = Kokkos::sqrt(ascale_kk*static_cast(24.0)*boltz/t_period_kk/dt/mvv2e) / ftm2v; + gamma1 *= static_cast(1.0)/d_ratio[type[i]]; + gamma2 *= static_cast(1.0)/Kokkos::sqrt(d_ratio[type[i]]) * tsqrt_t; + tran[0] = Kokkos::sqrt(inertia[0])*gamma2*static_cast(rand_gen.drand()-0.5); + tran[1] = Kokkos::sqrt(inertia[1])*gamma2*static_cast(rand_gen.drand()-0.5); + tran[2] = Kokkos::sqrt(inertia[2])*gamma2*static_cast(rand_gen.drand()-0.5); + torque(i,0) += static_cast(inertia[0]*gamma1*omega[0] + tran[0]); + torque(i,1) += static_cast(inertia[1]*gamma1*omega[1] + tran[1]); + torque(i,2) += static_cast(inertia[2]*gamma1*omega[2] + tran[2]); rand_pool.free_state(rand_gen); } @@ -736,8 +738,8 @@ void FixLangevinKokkos::end_of_step() { if (!tallyflag) return; - dt = update->dt; - ftm2v = force->ftm2v; + dt = static_cast(update->dt); + ftm2v = static_cast(force->ftm2v); v = atomKK->k_v.template view(); rmass = atomKK->k_rmass.template view(); mass = atomKK->k_mass.template view(); diff --git a/src/KOKKOS/fix_langevin_kokkos.h b/src/KOKKOS/fix_langevin_kokkos.h index 6f40a6ba005..7eaae9a6a3e 100644 --- a/src/KOKKOS/fix_langevin_kokkos.h +++ b/src/KOKKOS/fix_langevin_kokkos.h @@ -242,7 +242,7 @@ void omega_thermostat_kokkos(); // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void operator()(const int i, value_type &energy) const { - energy += c.compute_energy_item(i); + energy += static_cast(c.compute_energy_item(i)); } // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION diff --git a/src/KOKKOS/fix_lineforce_kokkos.cpp b/src/KOKKOS/fix_lineforce_kokkos.cpp index 41170fbc2ae..d3a1346dcfa 100644 --- a/src/KOKKOS/fix_lineforce_kokkos.cpp +++ b/src/KOKKOS/fix_lineforce_kokkos.cpp @@ -73,10 +73,13 @@ KOKKOS_INLINE_FUNCTION void FixLineForceKokkos::operator()(TagFixLineForce, const int &i) const { if (mask[i] & groupbit) { - const double dot = f(i,0)*xdir + f(i,1)*ydir + f(i,2)*zdir; - f(i,0) = dot*xdir; - f(i,1) = dot*ydir; - f(i,2) = dot*zdir; + const KK_FLOAT xdir_kk = static_cast(xdir); + const KK_FLOAT ydir_kk = static_cast(ydir); + const KK_FLOAT zdir_kk = static_cast(zdir); + const KK_FLOAT dot = static_cast(f(i,0))*xdir_kk + static_cast(f(i,1))*ydir_kk + static_cast(f(i,2))*zdir_kk; + f(i,0) = static_cast(dot*xdir_kk); + f(i,1) = static_cast(dot*ydir_kk); + f(i,2) = static_cast(dot*zdir_kk); } } diff --git a/src/KOKKOS/fix_minimize_kokkos.cpp b/src/KOKKOS/fix_minimize_kokkos.cpp index 9d0338be883..b1d423c89d7 100644 --- a/src/KOKKOS/fix_minimize_kokkos.cpp +++ b/src/KOKKOS/fix_minimize_kokkos.cpp @@ -115,9 +115,9 @@ void FixMinimizeKokkos::reset_coords() Kokkos::parallel_for(nlocal, LAMMPS_LAMBDA(const int& i) { const int n = i*3; - double dx0 = l_x(i,0) - l_x0[n]; - double dy0 = l_x(i,1) - l_x0[n+1]; - double dz0 = l_x(i,2) - l_x0[n+2]; + double dx0 = static_cast(l_x(i,0) - l_x0[n]); + double dy0 = static_cast(l_x(i,1) - l_x0[n+1]); + double dz0 = static_cast(l_x(i,2) - l_x0[n+2]); double dx = dx0; double dy = dy0; double dz = dz0; @@ -176,9 +176,9 @@ void FixMinimizeKokkos::reset_coords() } } } // end domain->minimum_image(FLERR, dx,dy,dz); - if (dx != dx0) l_x0[n] = l_x(i,0) - dx; - if (dy != dy0) l_x0[n+1] = l_x(i,1) - dy; - if (dz != dz0) l_x0[n+2] = l_x(i,2) - dz; + if (dx != dx0) l_x0[n] = l_x(i,0) - static_cast(dx); + if (dy != dy0) l_x0[n+1] = l_x(i,1) - static_cast(dy); + if (dz != dz0) l_x0[n+2] = l_x(i,2) - static_cast(dz); }); } k_vectors.modify_device(); diff --git a/src/KOKKOS/fix_momentum_kokkos.cpp b/src/KOKKOS/fix_momentum_kokkos.cpp index 5278a406e25..9e6dc089656 100644 --- a/src/KOKKOS/fix_momentum_kokkos.cpp +++ b/src/KOKKOS/fix_momentum_kokkos.cpp @@ -62,8 +62,8 @@ static double get_kinetic_energy( Kokkos::parallel_reduce(Kokkos::RangePolicy(0,nlocal), LAMMPS_LAMBDA(int i, double& update) { if (mask(i) & groupbit) - update += rmass(i) * - (v(i,0)*v(i,0) + v(i,1)*v(i,1) + v(i,2)*v(i,2)); + update += static_cast(rmass(i) * + (v(i,0)*v(i,0) + v(i,1)*v(i,1) + v(i,2)*v(i,2))); }, ke); } else { // D.I. : why is there no MASS_MASK ? @@ -73,8 +73,8 @@ static double get_kinetic_energy( Kokkos::parallel_reduce(Kokkos::RangePolicy(0,nlocal), LAMMPS_LAMBDA(int i, double& update) { if (mask(i) & groupbit) - update += mass(type(i)) * - (v(i,0)*v(i,0) + v(i,1)*v(i,1) + v(i,2)*v(i,2)); + update += static_cast(mass(type(i)) * + (v(i,0)*v(i,0) + v(i,1)*v(i,1) + v(i,2)*v(i,2))); }, ke); } double ke_total; @@ -121,9 +121,9 @@ void FixMomentumKokkos::end_of_step() Kokkos::parallel_for(Kokkos::RangePolicy(0,nlocal), LAMMPS_LAMBDA(int i) { if (mask(i) & groupbit2) { - if (xflag2) v(i,0) -= vcm[0]; - if (yflag2) v(i,1) -= vcm[1]; - if (zflag2) v(i,2) -= vcm[2]; + if (xflag2) v(i,0) -= static_cast(vcm[0]); + if (yflag2) v(i,1) -= static_cast(vcm[1]); + if (zflag2) v(i,2) -= static_cast(vcm[2]); } }); atomKK->modified(execution_space, V_MASK); @@ -152,16 +152,16 @@ void FixMomentumKokkos::end_of_step() LAMMPS_LAMBDA(int i) { if (mask[i] & groupbit2) { Few x_i; - x_i[0] = x(i,0); - x_i[1] = x(i,1); - x_i[2] = x(i,2); + x_i[0] = static_cast(x(i,0)); + x_i[1] = static_cast(x(i,1)); + x_i[2] = static_cast(x(i,2)); auto unwrapKK = DomainKokkos::unmap(prd,h,triclinic,x_i,image(i)); auto dx = unwrapKK[0] - xcm[0]; auto dy = unwrapKK[1] - xcm[1]; auto dz = unwrapKK[2] - xcm[2]; - v(i,0) -= omega[1]*dz - omega[2]*dy; - v(i,1) -= omega[2]*dx - omega[0]*dz; - v(i,2) -= omega[0]*dy - omega[1]*dx; + v(i,0) -= static_cast(omega[1]*dz - omega[2]*dy); + v(i,1) -= static_cast(omega[2]*dx - omega[0]*dz); + v(i,2) -= static_cast(omega[0]*dy - omega[1]*dx); } }); atomKK->modified(execution_space, V_MASK); @@ -175,12 +175,13 @@ void FixMomentumKokkos::end_of_step() double factor = 1.0; if (ekin_new != 0.0) factor = sqrt(ekin_old/ekin_new); + const KK_FLOAT factor_kk = static_cast(factor); Kokkos::parallel_for(Kokkos::RangePolicy(0,nlocal), LAMMPS_LAMBDA(int i) { if (mask(i) & groupbit2) { - v(i,0) *= factor; - v(i,1) *= factor; - v(i,2) *= factor; + v(i,0) *= factor_kk; + v(i,1) *= factor_kk; + v(i,2) *= factor_kk; } }); atomKK->modified(execution_space, V_MASK); diff --git a/src/KOKKOS/fix_neigh_history_kokkos.cpp b/src/KOKKOS/fix_neigh_history_kokkos.cpp index dba4a934ec5..ea9cf5324da 100644 --- a/src/KOKKOS/fix_neigh_history_kokkos.cpp +++ b/src/KOKKOS/fix_neigh_history_kokkos.cpp @@ -388,7 +388,7 @@ void FixNeighHistoryKokkos::operator()(TagFixNeighHistoryPackExchang for (int p = 0; p < n; p++) { d_buf(m++) = d_ubuf(d_partner(i,p)).d; for (int v = 0; v < dnum; v++) { - d_buf(m++) = d_valuepartner(i,dnum*p+v); + d_buf(m++) = static_cast(d_valuepartner(i,dnum*p+v)); } } if (mysend == nsend-1) d_count() = m; @@ -468,7 +468,7 @@ void FixNeighHistoryKokkos::operator()(TagFixNeighHistoryUnpackExcha for (int p = 0; p < n; p++) { d_partner(index,p) = (tagint) d_ubuf(d_buf(m++)).i; for (int v = 0; v < dnum; v++) { - d_valuepartner(index,dnum*p+v) = d_buf(m++); + d_valuepartner(index,dnum*p+v) = static_cast(d_buf(m++)); } } } diff --git a/src/KOKKOS/fix_nh_kokkos.cpp b/src/KOKKOS/fix_nh_kokkos.cpp index 1f6fee0014f..0e8948de7ce 100644 --- a/src/KOKKOS/fix_nh_kokkos.cpp +++ b/src/KOKKOS/fix_nh_kokkos.cpp @@ -500,9 +500,9 @@ void FixNHKokkos::nh_v_press() int nlocal = atomKK->nlocal; if (igroup == atomKK->firstgroup) nlocal = atomKK->nfirst; - factor[0] = exp(-dt4*(omega_dot[0]+mtk_term2)); - factor[1] = exp(-dt4*(omega_dot[1]+mtk_term2)); - factor[2] = exp(-dt4*(omega_dot[2]+mtk_term2)); + factor[0] = static_cast(exp(-dt4*(omega_dot[0]+mtk_term2))); + factor[1] = static_cast(exp(-dt4*(omega_dot[1]+mtk_term2))); + factor[2] = static_cast(exp(-dt4*(omega_dot[2]+mtk_term2))); if (which == BIAS) { if (temperature->kokkosable) temperature->remove_bias_all_kk(); @@ -546,8 +546,12 @@ void FixNHKokkos::operator()(TagFixNH_nh_v_press, co v(i,1) *= factor[1]; v(i,2) *= factor[2]; if (TRICLINIC_FLAG) { - v(i,0) += -dthalf*(v(i,1)*omega_dot[5] + v(i,2)*omega_dot[4]); - v(i,1) += -dthalf*v(i,2)*omega_dot[3]; + const KK_FLOAT dthalf_kk = static_cast(dthalf); + const KK_FLOAT omega_dot3_kk = static_cast(omega_dot[3]); + const KK_FLOAT omega_dot4_kk = static_cast(omega_dot[4]); + const KK_FLOAT omega_dot5_kk = static_cast(omega_dot[5]); + v(i,0) += -dthalf_kk*(v(i,1)*omega_dot5_kk + v(i,2)*omega_dot4_kk); + v(i,1) += -dthalf_kk*v(i,2)*omega_dot3_kk; } v(i,0) *= factor[0]; v(i,1) *= factor[1]; @@ -588,19 +592,20 @@ template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void FixNHKokkos::operator()(TagFixNH_nve_v, const int &i) const { + const KK_FLOAT dtf_kk = static_cast(dtf); if (RMASS) { if (mask[i] & groupbit) { - const KK_FLOAT dtfm = dtf / rmass[i]; - v(i,0) += dtfm*f(i,0); - v(i,1) += dtfm*f(i,1); - v(i,2) += dtfm*f(i,2); + const KK_FLOAT dtfm = dtf_kk / rmass[i]; + v(i,0) += dtfm*static_cast(f(i,0)); + v(i,1) += dtfm*static_cast(f(i,1)); + v(i,2) += dtfm*static_cast(f(i,2)); } } else { if (mask[i] & groupbit) { - const KK_FLOAT dtfm = dtf / mass[type[i]]; - v(i,0) += dtfm*f(i,0); - v(i,1) += dtfm*f(i,1); - v(i,2) += dtfm*f(i,2); + const KK_FLOAT dtfm = dtf_kk / mass[type[i]]; + v(i,0) += dtfm*static_cast(f(i,0)); + v(i,1) += dtfm*static_cast(f(i,1)); + v(i,2) += dtfm*static_cast(f(i,2)); } } } @@ -632,10 +637,11 @@ template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void FixNHKokkos::operator()(TagFixNH_nve_x, const int &i) const { + const KK_FLOAT dtv_kk = static_cast(dtv); if (mask[i] & groupbit) { - x(i,0) += dtv * v(i,0); - x(i,1) += dtv * v(i,1); - x(i,2) += dtv * v(i,2); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); } } @@ -684,10 +690,11 @@ template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void FixNHKokkos::operator()(TagFixNH_nh_v_temp, const int &i) const { + const KK_FLOAT factor_eta_kk = static_cast(factor_eta); if (mask[i] & groupbit) { - v(i,0) *= factor_eta; - v(i,1) *= factor_eta; - v(i,2) *= factor_eta; + v(i,0) *= factor_eta_kk; + v(i,1) *= factor_eta_kk; + v(i,2) *= factor_eta_kk; } } diff --git a/src/KOKKOS/fix_nh_sphere_kokkos.cpp b/src/KOKKOS/fix_nh_sphere_kokkos.cpp index 1ee46a5aa27..766310e7772 100644 --- a/src/KOKKOS/fix_nh_sphere_kokkos.cpp +++ b/src/KOKKOS/fix_nh_sphere_kokkos.cpp @@ -107,12 +107,14 @@ template KOKKOS_INLINE_FUNCTION void FixNHSphereKokkos::operator()(TagFixNHSphere_nve_v_omega, const int &i) const { + const KK_FLOAT dtf_kk = static_cast(this->dtf); + const KK_FLOAT inertia_kk = static_cast(inertia); if (this->mask(i) & this->groupbit) { - const KK_FLOAT dtfrotate = this->dtf / inertia; + const KK_FLOAT dtfrotate = dtf_kk / inertia_kk; const KK_FLOAT dtirotate = dtfrotate / (radius_kk(i) * radius_kk(i) * this->rmass(i)); - omega_kk(i, 0) += dtirotate * torque_kk(i, 0); - omega_kk(i, 1) += dtirotate * torque_kk(i, 1); - omega_kk(i, 2) += dtirotate * torque_kk(i, 2); + omega_kk(i, 0) += dtirotate * static_cast(torque_kk(i, 0)); + omega_kk(i, 1) += dtirotate * static_cast(torque_kk(i, 1)); + omega_kk(i, 2) += dtirotate * static_cast(torque_kk(i, 2)); } } @@ -155,10 +157,11 @@ template KOKKOS_INLINE_FUNCTION void FixNHSphereKokkos::operator()(TagFixNHSphere_nve_x_dipole, const int &i) const { - if (this->mask(i) & this->groupbit && mu_kk(i, 3) > 0.0) { - const KK_FLOAT g0 = mu_kk(i, 0) + this->dtv * (omega_kk(i, 1) * mu_kk(i, 2) - omega_kk(i, 2) * mu_kk(i, 1)); - const KK_FLOAT g1 = mu_kk(i, 1) + this->dtv * (omega_kk(i, 2) * mu_kk(i, 0) - omega_kk(i, 0) * mu_kk(i, 2)); - const KK_FLOAT g2 = mu_kk(i, 2) + this->dtv * (omega_kk(i, 0) * mu_kk(i, 1) - omega_kk(i, 1) * mu_kk(i, 0)); + const KK_FLOAT dtv_kk = static_cast(this->dtv); + if (this->mask(i) & this->groupbit && mu_kk(i, 3) > static_cast(0.0)) { + const KK_FLOAT g0 = mu_kk(i, 0) + dtv_kk * (omega_kk(i, 1) * mu_kk(i, 2) - omega_kk(i, 2) * mu_kk(i, 1)); + const KK_FLOAT g1 = mu_kk(i, 1) + dtv_kk * (omega_kk(i, 2) * mu_kk(i, 0) - omega_kk(i, 0) * mu_kk(i, 2)); + const KK_FLOAT g2 = mu_kk(i, 2) + dtv_kk * (omega_kk(i, 0) * mu_kk(i, 1) - omega_kk(i, 1) * mu_kk(i, 0)); const KK_FLOAT msq = g0 * g0 + g1 * g1 + g2 * g2; const KK_FLOAT scale = mu_kk(i, 3) / Kokkos::sqrt(msq); mu_kk(i, 0) = g0 * scale; @@ -199,10 +202,11 @@ template KOKKOS_INLINE_FUNCTION void FixNHSphereKokkos::operator()(TagFixNHSphere_nh_v_temp_omega, const int &i) const { + const KK_FLOAT factor_eta_kk = static_cast(this->factor_eta); if (this->mask(i) & this->groupbit) { - omega_kk(i, 0) *= this->factor_eta; - omega_kk(i, 1) *= this->factor_eta; - omega_kk(i, 2) *= this->factor_eta; + omega_kk(i, 0) *= factor_eta_kk; + omega_kk(i, 1) *= factor_eta_kk; + omega_kk(i, 2) *= factor_eta_kk; } } diff --git a/src/KOKKOS/fix_nve_asphere_kokkos.cpp b/src/KOKKOS/fix_nve_asphere_kokkos.cpp index 0b12c8e6f49..400fc0bd288 100644 --- a/src/KOKKOS/fix_nve_asphere_kokkos.cpp +++ b/src/KOKKOS/fix_nve_asphere_kokkos.cpp @@ -92,35 +92,37 @@ void FixNVEAsphereKokkos::initial_integrate_item(const int i) const { // set timestep here since dt may have changed or come via rRESPA - const KK_FLOAT dtq = 0.5 * dtv; + const KK_FLOAT dtf_kk = static_cast(dtf); + const KK_FLOAT dtv_kk = static_cast(dtv); + const KK_FLOAT dtq = static_cast(0.5) * dtv_kk; KK_FLOAT inertia[3], omega[3]; double *shape, *quat; KK_FLOAT angm[3]; if (mask(i) & groupbit) { - const KK_FLOAT dtfm = dtf / rmass(i); - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); - x(i,0) += dtv * v(i,0); - x(i,1) += dtv * v(i,1); - x(i,2) += dtv * v(i,2); + const KK_FLOAT dtfm = dtf_kk / rmass(i); + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); // update angular momentum by 1/2 step into a local array - angm[0] = angmom(i,0) + dtf * torque(i,0); - angm[1] = angmom(i,1) + dtf * torque(i,1); - angm[2] = angmom(i,2) + dtf * torque(i,2); + angm[0] = angmom(i,0) + dtf_kk * static_cast(torque(i,0)); + angm[1] = angmom(i,1) + dtf_kk * static_cast(torque(i,1)); + angm[2] = angmom(i,2) + dtf_kk * static_cast(torque(i,2)); // principal moments of inertia quat = bonus(ellipsoid(i)).quat; shape = bonus(ellipsoid(i)).shape; - inertia[0] = INERTIA*rmass(i) * - (shape[1]*shape[1] + shape[2]*shape[2]); - inertia[1] = INERTIA*rmass(i) * - (shape[0]*shape[0] + shape[2]*shape[2]); - inertia[2] = INERTIA*rmass(i) * - (shape[0]*shape[0] + shape[1]*shape[1]); + inertia[0] = static_cast(INERTIA*static_cast(rmass(i)) * + (shape[1]*shape[1] + shape[2]*shape[2])); + inertia[1] = static_cast(INERTIA*static_cast(rmass(i)) * + (shape[0]*shape[0] + shape[2]*shape[2])); + inertia[2] = static_cast(INERTIA*static_cast(rmass(i)) * + (shape[0]*shape[0] + shape[1]*shape[1])); // compute omega at 1/2 step from angmom at 1/2 step and current q // update quaternion a full step via Richardson iteration @@ -165,15 +167,16 @@ template KOKKOS_INLINE_FUNCTION void FixNVEAsphereKokkos::final_integrate_item(const int i) const { + const KK_FLOAT dtf_kk = static_cast(dtf); if (mask(i) & groupbit) { - const KK_FLOAT dtfm = dtf / rmass(i); - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); - - angmom(i,0) += dtf * torque(i,0); - angmom(i,1) += dtf * torque(i,1); - angmom(i,2) += dtf * torque(i,2); + const KK_FLOAT dtfm = dtf_kk / rmass(i); + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); + + angmom(i,0) += dtf_kk * static_cast(torque(i,0)); + angmom(i,1) += dtf_kk * static_cast(torque(i,1)); + angmom(i,2) += dtf_kk * static_cast(torque(i,2)); } } @@ -212,39 +215,41 @@ template KOKKOS_INLINE_FUNCTION void FixNVEAsphereKokkos::fused_integrate_item(const int i) const { - const KK_FLOAT dtq = 0.5 * dtv; + const KK_FLOAT dtf_kk = static_cast(dtf); + const KK_FLOAT dtv_kk = static_cast(dtv); + const KK_FLOAT dtq = static_cast(0.5) * dtv_kk; KK_FLOAT inertia[3], omega[3]; double *shape, *quat; KK_FLOAT angm[3]; if (mask(i) & groupbit) { - const KK_FLOAT dtfm = 2.0 * dtf / rmass(i); - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); - angmom(i,0) += dtf * torque(i,0); - angmom(i,1) += dtf * torque(i,1); - angmom(i,2) += dtf * torque(i,2); - x(i,0) += dtv * v(i,0); - x(i,1) += dtv * v(i,1); - x(i,2) += dtv * v(i,2); + const KK_FLOAT dtfm = static_cast(2.0) * dtf_kk / rmass(i); + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); + angmom(i,0) += dtf_kk * static_cast(torque(i,0)); + angmom(i,1) += dtf_kk * static_cast(torque(i,1)); + angmom(i,2) += dtf_kk * static_cast(torque(i,2)); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); // update angular momentum by 1/2 step into a local array - angm[0] = angmom(i,0) + dtf * torque(i,0); - angm[1] = angmom(i,1) + dtf * torque(i,1); - angm[2] = angmom(i,2) + dtf * torque(i,2); + angm[0] = angmom(i,0) + dtf_kk * static_cast(torque(i,0)); + angm[1] = angmom(i,1) + dtf_kk * static_cast(torque(i,1)); + angm[2] = angmom(i,2) + dtf_kk * static_cast(torque(i,2)); // principal moments of inertia quat = bonus(ellipsoid(i)).quat; shape = bonus(ellipsoid(i)).shape; - inertia[0] = INERTIA*rmass(i) * - (shape[1]*shape[1] + shape[2]*shape[2]); - inertia[1] = INERTIA*rmass(i) * - (shape[0]*shape[0] + shape[2]*shape[2]); - inertia[2] = INERTIA*rmass(i) * - (shape[0]*shape[0] + shape[1]*shape[1]); + inertia[0] = static_cast(INERTIA*static_cast(rmass(i)) * + (shape[1]*shape[1] + shape[2]*shape[2])); + inertia[1] = static_cast(INERTIA*static_cast(rmass(i)) * + (shape[0]*shape[0] + shape[2]*shape[2])); + inertia[2] = static_cast(INERTIA*static_cast(rmass(i)) * + (shape[0]*shape[0] + shape[1]*shape[1])); // compute omega at 1/2 step from angmom at 1/2 step and current q // update quaternion a full step via Richardson iteration diff --git a/src/KOKKOS/fix_nve_kokkos.cpp b/src/KOKKOS/fix_nve_kokkos.cpp index 9e18c5d776a..a00de30cfbb 100644 --- a/src/KOKKOS/fix_nve_kokkos.cpp +++ b/src/KOKKOS/fix_nve_kokkos.cpp @@ -80,14 +80,16 @@ template KOKKOS_INLINE_FUNCTION void FixNVEKokkos::initial_integrate_item(int i) const { + const KK_FLOAT dtf_kk = static_cast(dtf); + const KK_FLOAT dtv_kk = static_cast(dtv); if (mask[i] & groupbit) { - const KK_FLOAT dtfm = dtf / mass[type[i]]; - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); - x(i,0) += dtv * v(i,0); - x(i,1) += dtv * v(i,1); - x(i,2) += dtv * v(i,2); + const KK_FLOAT dtfm = dtf_kk / mass[type[i]]; + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); } } @@ -96,14 +98,16 @@ template KOKKOS_INLINE_FUNCTION void FixNVEKokkos::initial_integrate_rmass_item(int i) const { + const KK_FLOAT dtf_kk = static_cast(dtf); + const KK_FLOAT dtv_kk = static_cast(dtv); if (mask[i] & groupbit) { - const KK_FLOAT dtfm = dtf / rmass[i]; - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); - x(i,0) += dtv * v(i,0); - x(i,1) += dtv * v(i,1); - x(i,2) += dtv * v(i,2); + const KK_FLOAT dtfm = dtf_kk / rmass[i]; + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); } } @@ -141,11 +145,12 @@ template KOKKOS_INLINE_FUNCTION void FixNVEKokkos::final_integrate_item(int i) const { + const KK_FLOAT dtf_kk = static_cast(dtf); if (mask[i] & groupbit) { - const KK_FLOAT dtfm = dtf / mass[type[i]]; - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); + const KK_FLOAT dtfm = dtf_kk / mass[type[i]]; + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); } } @@ -154,11 +159,12 @@ template KOKKOS_INLINE_FUNCTION void FixNVEKokkos::final_integrate_rmass_item(int i) const { + const KK_FLOAT dtf_kk = static_cast(dtf); if (mask[i] & groupbit) { - const KK_FLOAT dtfm = dtf / rmass[i]; - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); + const KK_FLOAT dtfm = dtf_kk / rmass[i]; + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); } } @@ -197,14 +203,16 @@ template KOKKOS_INLINE_FUNCTION void FixNVEKokkos::fused_integrate_item(int i) const { + const KK_FLOAT dtf_kk = static_cast(dtf); + const KK_FLOAT dtv_kk = static_cast(dtv); if (mask[i] & groupbit) { - const KK_FLOAT dtfm = 2.0 * dtf / mass[type[i]]; - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); - x(i,0) += dtv * v(i,0); - x(i,1) += dtv * v(i,1); - x(i,2) += dtv * v(i,2); + const KK_FLOAT dtfm = static_cast(2.0) * dtf_kk / mass[type[i]]; + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); } } @@ -213,14 +221,16 @@ template KOKKOS_INLINE_FUNCTION void FixNVEKokkos::fused_integrate_rmass_item(int i) const { + const KK_FLOAT dtf_kk = static_cast(dtf); + const KK_FLOAT dtv_kk = static_cast(dtv); if (mask[i] & groupbit) { - const KK_FLOAT dtfm = 2.0 * dtf / rmass[i]; - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); - x(i,0) += dtv * v(i,0); - x(i,1) += dtv * v(i,1); - x(i,2) += dtv * v(i,2); + const KK_FLOAT dtfm = static_cast(2.0) * dtf_kk / rmass[i]; + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); } } diff --git a/src/KOKKOS/fix_nve_limit_kokkos.cpp b/src/KOKKOS/fix_nve_limit_kokkos.cpp index 9cc8fb22b5e..e782526d85b 100644 --- a/src/KOKKOS/fix_nve_limit_kokkos.cpp +++ b/src/KOKKOS/fix_nve_limit_kokkos.cpp @@ -54,9 +54,9 @@ void FixNVELimitKokkos::initial_integrate(int /*vflag*/) auto d_f = atomKK->k_f.template view(); auto d_mask = atomKK->k_mask.template view(); auto l_groupbit = groupbit; - auto l_dtf = dtf; - auto l_dtv = dtv; - auto l_vlimitsq = vlimitsq; + const KK_FLOAT l_dtf = static_cast(dtf); + const KK_FLOAT l_dtv = static_cast(dtv); + const KK_FLOAT l_vlimitsq = static_cast(vlimitsq); int d_ncount; @@ -68,15 +68,15 @@ void FixNVELimitKokkos::initial_integrate(int /*vflag*/) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,nlocal), KOKKOS_LAMBDA(const int i, int &l_ncount) { if (d_mask[i] & l_groupbit) { - const double dtfm = l_dtf / d_rmass[i]; - d_v(i,0) += dtfm * d_f(i,0); - d_v(i,1) += dtfm * d_f(i,1); - d_v(i,2) += dtfm * d_f(i,2); + const KK_FLOAT dtfm = l_dtf / d_rmass[i]; + d_v(i,0) += dtfm * static_cast(d_f(i,0)); + d_v(i,1) += dtfm * static_cast(d_f(i,1)); + d_v(i,2) += dtfm * static_cast(d_f(i,2)); - const double vsq = d_v(i,0)*d_v(i,0) + d_v(i,1)*d_v(i,1) + d_v(i,2)*d_v(i,2); + const KK_FLOAT vsq = d_v(i,0)*d_v(i,0) + d_v(i,1)*d_v(i,1) + d_v(i,2)*d_v(i,2); if (vsq > l_vlimitsq) { l_ncount++; - const double scale = sqrt(l_vlimitsq/vsq); + const KK_FLOAT scale = Kokkos::sqrt(l_vlimitsq/vsq); d_v(i,0) *= scale; d_v(i,1) *= scale; d_v(i,2) *= scale; @@ -97,15 +97,15 @@ void FixNVELimitKokkos::initial_integrate(int /*vflag*/) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,nlocal), KOKKOS_LAMBDA(const int i, int &l_ncount) { if (d_mask[i] & l_groupbit) { - const double dtfm = l_dtf / d_mass[d_type[i]]; - d_v(i,0) += dtfm * d_f(i,0); - d_v(i,1) += dtfm * d_f(i,1); - d_v(i,2) += dtfm * d_f(i,2); + const KK_FLOAT dtfm = l_dtf / d_mass[d_type[i]]; + d_v(i,0) += dtfm * static_cast(d_f(i,0)); + d_v(i,1) += dtfm * static_cast(d_f(i,1)); + d_v(i,2) += dtfm * static_cast(d_f(i,2)); - const double vsq = d_v(i,0)*d_v(i,0) + d_v(i,1)*d_v(i,1) + d_v(i,2)*d_v(i,2); + const KK_FLOAT vsq = d_v(i,0)*d_v(i,0) + d_v(i,1)*d_v(i,1) + d_v(i,2)*d_v(i,2); if (vsq > l_vlimitsq) { l_ncount++; - const double scale = sqrt(l_vlimitsq/vsq); + const KK_FLOAT scale = Kokkos::sqrt(l_vlimitsq/vsq); d_v(i,0) *= scale; d_v(i,1) *= scale; d_v(i,2) *= scale; @@ -134,8 +134,8 @@ void FixNVELimitKokkos::final_integrate() auto d_f = atomKK->k_f.template view(); auto d_mask = atomKK->k_mask.template view(); auto l_groupbit = groupbit; - auto l_dtf = dtf; - auto l_vlimitsq = vlimitsq; + const KK_FLOAT l_dtf = static_cast(dtf); + const KK_FLOAT l_vlimitsq = static_cast(vlimitsq); int d_ncount; @@ -146,15 +146,15 @@ void FixNVELimitKokkos::final_integrate() Kokkos::parallel_reduce(Kokkos::RangePolicy(0,nlocal), KOKKOS_LAMBDA(const int i, int &l_ncount) { if (d_mask[i] & l_groupbit) { - const double dtfm = l_dtf / d_rmass[i]; - d_v(i,0) += dtfm * d_f(i,0); - d_v(i,1) += dtfm * d_f(i,1); - d_v(i,2) += dtfm * d_f(i,2); + const KK_FLOAT dtfm = l_dtf / d_rmass[i]; + d_v(i,0) += dtfm * static_cast(d_f(i,0)); + d_v(i,1) += dtfm * static_cast(d_f(i,1)); + d_v(i,2) += dtfm * static_cast(d_f(i,2)); - const double vsq = d_v(i,0)*d_v(i,0) + d_v(i,1)*d_v(i,1) + d_v(i,2)*d_v(i,2); + const KK_FLOAT vsq = d_v(i,0)*d_v(i,0) + d_v(i,1)*d_v(i,1) + d_v(i,2)*d_v(i,2); if (vsq > l_vlimitsq) { l_ncount++; - const double scale = sqrt(l_vlimitsq/vsq); + const KK_FLOAT scale = Kokkos::sqrt(l_vlimitsq/vsq); d_v(i,0) *= scale; d_v(i,1) *= scale; d_v(i,2) *= scale; @@ -170,15 +170,15 @@ void FixNVELimitKokkos::final_integrate() Kokkos::parallel_reduce(Kokkos::RangePolicy(0,nlocal), KOKKOS_LAMBDA(const int i, int &l_ncount) { if (d_mask[i] & l_groupbit) { - const double dtfm = l_dtf / d_mass[d_type[i]]; - d_v(i,0) += dtfm * d_f(i,0); - d_v(i,1) += dtfm * d_f(i,1); - d_v(i,2) += dtfm * d_f(i,2); + const KK_FLOAT dtfm = l_dtf / d_mass[d_type[i]]; + d_v(i,0) += dtfm * static_cast(d_f(i,0)); + d_v(i,1) += dtfm * static_cast(d_f(i,1)); + d_v(i,2) += dtfm * static_cast(d_f(i,2)); - const double vsq = d_v(i,0)*d_v(i,0) + d_v(i,1)*d_v(i,1) + d_v(i,2)*d_v(i,2); + const KK_FLOAT vsq = d_v(i,0)*d_v(i,0) + d_v(i,1)*d_v(i,1) + d_v(i,2)*d_v(i,2); if (vsq > l_vlimitsq) { l_ncount++; - const double scale = sqrt(l_vlimitsq/vsq); + const KK_FLOAT scale = Kokkos::sqrt(l_vlimitsq/vsq); d_v(i,0) *= scale; d_v(i,1) *= scale; d_v(i,2) *= scale; diff --git a/src/KOKKOS/fix_nve_noforce_kokkos.cpp b/src/KOKKOS/fix_nve_noforce_kokkos.cpp index e2f999e1828..415ca99639f 100644 --- a/src/KOKKOS/fix_nve_noforce_kokkos.cpp +++ b/src/KOKKOS/fix_nve_noforce_kokkos.cpp @@ -80,10 +80,11 @@ template KOKKOS_INLINE_FUNCTION void FixNVENoforceKokkos::operator()(TagFixNVENoforce, const int &i) const { + const KK_FLOAT dtv_kk = static_cast(dtv); if (mask[i] & groupbit) { - x(i,0) += dtv * v(i,0); - x(i,1) += dtv * v(i,1); - x(i,2) += dtv * v(i,2); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); } } diff --git a/src/KOKKOS/fix_nve_sphere_kokkos.cpp b/src/KOKKOS/fix_nve_sphere_kokkos.cpp index 00ceef4c2c5..0fda02715cd 100644 --- a/src/KOKKOS/fix_nve_sphere_kokkos.cpp +++ b/src/KOKKOS/fix_nve_sphere_kokkos.cpp @@ -93,28 +93,31 @@ template KOKKOS_INLINE_FUNCTION void FixNVESphereKokkos::initial_integrate_item(const int i) const { - const KK_FLOAT dtfrotate = dtf / inertia; + const KK_FLOAT dtf_kk = static_cast(dtf); + const KK_FLOAT dtv_kk = static_cast(dtv); + const KK_FLOAT inertia_kk = static_cast(inertia); + const KK_FLOAT dtfrotate = dtf_kk / inertia_kk; if (mask(i) & groupbit) { - const KK_FLOAT dtfm = dtf / rmass(i); - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); - x(i,0) += dtv * v(i,0); - x(i,1) += dtv * v(i,1); - x(i,2) += dtv * v(i,2); + const KK_FLOAT dtfm = dtf_kk / rmass(i); + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); const KK_FLOAT dtirotate = dtfrotate / (radius(i)*radius(i)*rmass(i)); - omega(i,0) += dtirotate * torque(i,0); - omega(i,1) += dtirotate * torque(i,1); - omega(i,2) += dtirotate * torque(i,2); + omega(i,0) += dtirotate * static_cast(torque(i,0)); + omega(i,1) += dtirotate * static_cast(torque(i,1)); + omega(i,2) += dtirotate * static_cast(torque(i,2)); if (extra == DIPOLE) { - const KK_FLOAT g0 = mu(i,0) + dtv * (omega(i,1) * mu(i,2) - omega(i,2) * mu(i,1)); - const KK_FLOAT g1 = mu(i,1) + dtv * (omega(i,2) * mu(i,0) - omega(i,0) * mu(i,2)); - const KK_FLOAT g2 = mu(i,2) + dtv * (omega(i,0) * mu(i,1) - omega(i,1) * mu(i,0)); + const KK_FLOAT g0 = mu(i,0) + dtv_kk * (omega(i,1) * mu(i,2) - omega(i,2) * mu(i,1)); + const KK_FLOAT g1 = mu(i,1) + dtv_kk * (omega(i,2) * mu(i,0) - omega(i,0) * mu(i,2)); + const KK_FLOAT g2 = mu(i,2) + dtv_kk * (omega(i,0) * mu(i,1) - omega(i,1) * mu(i,0)); const KK_FLOAT msq = g0*g0 + g1*g1 + g2*g2; - const KK_FLOAT scale = mu(i,3)/sqrt(msq); + const KK_FLOAT scale = mu(i,3)/Kokkos::sqrt(msq); mu(i,0) = g0*scale; mu(i,1) = g1*scale; mu(i,2) = g2*scale; @@ -153,18 +156,20 @@ template KOKKOS_INLINE_FUNCTION void FixNVESphereKokkos::final_integrate_item(const int i) const { - const KK_FLOAT dtfrotate = dtf / inertia; + const KK_FLOAT dtf_kk = static_cast(dtf); + const KK_FLOAT inertia_kk = static_cast(inertia); + const KK_FLOAT dtfrotate = dtf_kk / inertia_kk; if (mask(i) & groupbit) { - const KK_FLOAT dtfm = dtf / rmass(i); - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); + const KK_FLOAT dtfm = dtf_kk / rmass(i); + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); const KK_FLOAT dtirotate = dtfrotate / (radius(i)*radius(i)*rmass(i)); - omega(i,0) += dtirotate * torque(i,0); - omega(i,1) += dtirotate * torque(i,1); - omega(i,2) += dtirotate * torque(i,2); + omega(i,0) += dtirotate * static_cast(torque(i,0)); + omega(i,1) += dtirotate * static_cast(torque(i,1)); + omega(i,2) += dtirotate * static_cast(torque(i,2)); } } @@ -207,28 +212,31 @@ template KOKKOS_INLINE_FUNCTION void FixNVESphereKokkos::fused_integrate_item(const int i) const { - const KK_FLOAT dtfrotate = dtf / inertia; + const KK_FLOAT dtf_kk = static_cast(dtf); + const KK_FLOAT dtv_kk = static_cast(dtv); + const KK_FLOAT inertia_kk = static_cast(inertia); + const KK_FLOAT dtfrotate = dtf_kk / inertia_kk; if (mask(i) & groupbit) { - const KK_FLOAT dtfm = 2.0 * dtf / rmass(i); - v(i,0) += dtfm * f(i,0); - v(i,1) += dtfm * f(i,1); - v(i,2) += dtfm * f(i,2); - x(i,0) += dtv * v(i,0); - x(i,1) += dtv * v(i,1); - x(i,2) += dtv * v(i,2); - - const KK_FLOAT dtirotate = 2.0 * dtfrotate / (radius(i)*radius(i)*rmass(i)); - omega(i,0) += dtirotate * torque(i,0); - omega(i,1) += dtirotate * torque(i,1); - omega(i,2) += dtirotate * torque(i,2); + const KK_FLOAT dtfm = static_cast(2.0) * dtf_kk / rmass(i); + v(i,0) += dtfm * static_cast(f(i,0)); + v(i,1) += dtfm * static_cast(f(i,1)); + v(i,2) += dtfm * static_cast(f(i,2)); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); + + const KK_FLOAT dtirotate = static_cast(2.0) * dtfrotate / (radius(i)*radius(i)*rmass(i)); + omega(i,0) += dtirotate * static_cast(torque(i,0)); + omega(i,1) += dtirotate * static_cast(torque(i,1)); + omega(i,2) += dtirotate * static_cast(torque(i,2)); if (extra == DIPOLE) { - const KK_FLOAT g0 = mu(i,0) + dtv * (omega(i,1) * mu(i,2) - omega(i,2) * mu(i,1)); - const KK_FLOAT g1 = mu(i,1) + dtv * (omega(i,2) * mu(i,0) - omega(i,0) * mu(i,2)); - const KK_FLOAT g2 = mu(i,2) + dtv * (omega(i,0) * mu(i,1) - omega(i,1) * mu(i,0)); + const KK_FLOAT g0 = mu(i,0) + dtv_kk * (omega(i,1) * mu(i,2) - omega(i,2) * mu(i,1)); + const KK_FLOAT g1 = mu(i,1) + dtv_kk * (omega(i,2) * mu(i,0) - omega(i,0) * mu(i,2)); + const KK_FLOAT g2 = mu(i,2) + dtv_kk * (omega(i,0) * mu(i,1) - omega(i,1) * mu(i,0)); const KK_FLOAT msq = g0*g0 + g1*g1 + g2*g2; - const KK_FLOAT scale = mu(i,3)/sqrt(msq); + const KK_FLOAT scale = mu(i,3)/Kokkos::sqrt(msq); mu(i,0) = g0*scale; mu(i,1) = g1*scale; mu(i,2) = g2*scale; diff --git a/src/KOKKOS/fix_nvt_sllod_kokkos.cpp b/src/KOKKOS/fix_nvt_sllod_kokkos.cpp index f9bd3cf5dff..4cb12dd3190 100644 --- a/src/KOKKOS/fix_nvt_sllod_kokkos.cpp +++ b/src/KOKKOS/fix_nvt_sllod_kokkos.cpp @@ -254,52 +254,54 @@ template KOKKOS_INLINE_FUNCTION void FixNVTSllodKokkos::operator()(TagFixNVTSllod_nvex, const int& i) const { if (mask[i] & this->groupbit) { + const KK_FLOAT dthalf_kk = static_cast(this->dthalf); + const KK_FLOAT dtv_kk = static_cast(this->dtv); // first half sllod update if (PSLLOD) { - v(i,2) -= this->dthalf*this->d_h_two[2]*this->d_h_two[2]*x(i,2); - v(i,1) -= this->dthalf*this->d_h_two[3]*v(i,2) + this->dthalf*this->d_h_two[1]*this->d_h_two[1]*x(i,1); - v(i,0) -= this->dthalf*(this->d_h_two[5]*v(i,1) + this->d_h_two[4]*v(i,2)) - + this->dthalf*this->d_h_two[0]*this->d_h_two[0]*x(i,0); + v(i,2) -= dthalf_kk*static_cast(this->d_h_two[2])*static_cast(this->d_h_two[2])*x(i,2); + v(i,1) -= dthalf_kk*static_cast(this->d_h_two[3])*v(i,2) + dthalf_kk*static_cast(this->d_h_two[1])*static_cast(this->d_h_two[1])*x(i,1); + v(i,0) -= dthalf_kk*(static_cast(this->d_h_two[5])*v(i,1) + static_cast(this->d_h_two[4])*v(i,2)) + + dthalf_kk*static_cast(this->d_h_two[0])*static_cast(this->d_h_two[0])*x(i,0); } else { - v(i,1) -= this->dthalf*this->d_h_two[3]*v(i,2); - v(i,0) -= this->dthalf*(this->d_h_two[5]*v(i,1) + this->d_h_two[4]*v(i,2)); + v(i,1) -= dthalf_kk*static_cast(this->d_h_two[3])*v(i,2); + v(i,0) -= dthalf_kk*(static_cast(this->d_h_two[5])*v(i,1) + static_cast(this->d_h_two[4])*v(i,2)); } - v(i,0) *= this->d_vfac[0]; - v(i,1) *= this->d_vfac[1]; - v(i,2) *= this->d_vfac[2]; + v(i,0) *= static_cast(this->d_vfac[0]); + v(i,1) *= static_cast(this->d_vfac[1]); + v(i,2) *= static_cast(this->d_vfac[2]); - x(i,1) += this->dthalf * this->d_h_two[3]*(x(i,2) - this->d_xlo[2]); - x(i,0) += this->dthalf * (this->d_h_two[5]*(x(i,1) - this->d_xlo[1]) + this->d_h_two[4]*(x(i,2) - this->d_xlo[2])); - x(i,0) = this->d_xmid[0] + (x(i,0) - this->d_xmid[0])*this->d_xfac[0]; - x(i,1) = this->d_xmid[1] + (x(i,1) - this->d_xmid[1])*this->d_xfac[1]; - x(i,2) = this->d_xmid[2] + (x(i,2) - this->d_xmid[2])*this->d_xfac[2]; + x(i,1) += dthalf_kk * static_cast(this->d_h_two[3])*(x(i,2) - static_cast(this->d_xlo[2])); + x(i,0) += dthalf_kk * (static_cast(this->d_h_two[5])*(x(i,1) - static_cast(this->d_xlo[1])) + static_cast(this->d_h_two[4])*(x(i,2) - static_cast(this->d_xlo[2]))); + x(i,0) = static_cast(this->d_xmid[0]) + (x(i,0) - static_cast(this->d_xmid[0]))*static_cast(this->d_xfac[0]); + x(i,1) = static_cast(this->d_xmid[1]) + (x(i,1) - static_cast(this->d_xmid[1]))*static_cast(this->d_xfac[1]); + x(i,2) = static_cast(this->d_xmid[2]) + (x(i,2) - static_cast(this->d_xmid[2]))*static_cast(this->d_xfac[2]); // nve position update - x(i,0) += this->dtv * v(i,0); - x(i,1) += this->dtv * v(i,1); - x(i,2) += this->dtv * v(i,2); + x(i,0) += dtv_kk * v(i,0); + x(i,1) += dtv_kk * v(i,1); + x(i,2) += dtv_kk * v(i,2); // 2nd half sllod update - x(i,0) = this->d_xmid[0] + (x(i,0) - this->d_xmid[0])*this->d_xfac[0]; - x(i,1) = this->d_xmid[1] + (x(i,1) - this->d_xmid[1])*this->d_xfac[1]; - x(i,2) = this->d_xmid[2] + (x(i,2) - this->d_xmid[2])*this->d_xfac[2]; + x(i,0) = static_cast(this->d_xmid[0]) + (x(i,0) - static_cast(this->d_xmid[0]))*static_cast(this->d_xfac[0]); + x(i,1) = static_cast(this->d_xmid[1]) + (x(i,1) - static_cast(this->d_xmid[1]))*static_cast(this->d_xfac[1]); + x(i,2) = static_cast(this->d_xmid[2]) + (x(i,2) - static_cast(this->d_xmid[2]))*static_cast(this->d_xfac[2]); // d_xlo[3] is propagated xlo[1], d_xlo[4] is propagated xlo[2] - x(i,0) += this->dthalf * (this->d_h_two[5]*(x(i,1) - this->d_xlo[3]) + this->d_h_two[4]*(x(i,2) - this->d_xlo[4])); - x(i,1) += this->dthalf * this->d_h_two[3]*(x(i,2) - this->d_xlo[4]); + x(i,0) += dthalf_kk * (static_cast(this->d_h_two[5])*(x(i,1) - static_cast(this->d_xlo[3])) + static_cast(this->d_h_two[4])*(x(i,2) - static_cast(this->d_xlo[4]))); + x(i,1) += dthalf_kk * static_cast(this->d_h_two[3])*(x(i,2) - static_cast(this->d_xlo[4])); // second half sllod velocity step // apply here so streaming component matches x when storing in lab frame - v(i,0) *= this->d_vfac[0]; - v(i,1) *= this->d_vfac[1]; - v(i,2) *= this->d_vfac[2]; + v(i,0) *= static_cast(this->d_vfac[0]); + v(i,1) *= static_cast(this->d_vfac[1]); + v(i,2) *= static_cast(this->d_vfac[2]); if (PSLLOD) { - v(i,0) -= this->dthalf*(this->d_h_two[5]*v(i,1) + this->d_h_two[4]*v(i,2)) - + this->dthalf*this->d_h_two[0]*this->d_h_two[0]*x(i,0); - v(i,1) -= this->dthalf*this->d_h_two[3]*v(i,2) + this->dthalf*this->d_h_two[1]*this->d_h_two[1]*x(i,1); - v(i,2) -= this->dthalf*this->d_h_two[2]*this->d_h_two[2]*x(i,2); + v(i,0) -= dthalf_kk*(static_cast(this->d_h_two[5])*v(i,1) + static_cast(this->d_h_two[4])*v(i,2)) + + dthalf_kk*static_cast(this->d_h_two[0])*static_cast(this->d_h_two[0])*x(i,0); + v(i,1) -= dthalf_kk*static_cast(this->d_h_two[3])*v(i,2) + dthalf_kk*static_cast(this->d_h_two[1])*static_cast(this->d_h_two[1])*x(i,1); + v(i,2) -= dthalf_kk*static_cast(this->d_h_two[2])*static_cast(this->d_h_two[2])*x(i,2); } else { - v(i,0) -= this->dthalf*(this->d_h_two[5]*v(i,1) + this->d_h_two[4]*v(i,2)); - v(i,1) -= this->dthalf*this->d_h_two[3]*v(i,2); + v(i,0) -= dthalf_kk*(static_cast(this->d_h_two[5])*v(i,1) + static_cast(this->d_h_two[4])*v(i,2)); + v(i,1) -= dthalf_kk*static_cast(this->d_h_two[3])*v(i,2); } } } @@ -391,9 +393,9 @@ template KOKKOS_INLINE_FUNCTION void FixNVTSllodKokkos::operator()(TagFixNVTSllod_temp1, const int &i) const { if (mask[i] & this->groupbit) { - vdelu(i,0) = d_h_two[0]*v(i,0) + d_h_two[5]*v(i,1) + d_h_two[4]*v(i,2); - vdelu(i,1) = d_h_two[1]*v(i,1) + d_h_two[3]*v(i,2); - vdelu(i,2) = d_h_two[2]*v(i,2); + vdelu(i,0) = static_cast(d_h_two[0])*v(i,0) + static_cast(d_h_two[5])*v(i,1) + static_cast(d_h_two[4])*v(i,2); + vdelu(i,1) = static_cast(d_h_two[1])*v(i,1) + static_cast(d_h_two[3])*v(i,2); + vdelu(i,2) = static_cast(d_h_two[2])*v(i,2); } } @@ -402,9 +404,9 @@ template KOKKOS_INLINE_FUNCTION void FixNVTSllodKokkos::operator()(TagFixNVTSllod_temp2, const int &i) const { if (mask[i] & this->groupbit) { - v(i,0) = v(i,0)*this->factor_eta - this->dthalf*vdelu(i,0); - v(i,1) = v(i,1)*this->factor_eta - this->dthalf*vdelu(i,1); - v(i,2) = v(i,2)*this->factor_eta - this->dthalf*vdelu(i,2); + v(i,0) = v(i,0)*static_cast(this->factor_eta) - static_cast(this->dthalf)*vdelu(i,0); + v(i,1) = v(i,1)*static_cast(this->factor_eta) - static_cast(this->dthalf)*vdelu(i,1); + v(i,2) = v(i,2)*static_cast(this->factor_eta) - static_cast(this->dthalf)*vdelu(i,2); } } diff --git a/src/KOKKOS/fix_oneway_kokkos.cpp b/src/KOKKOS/fix_oneway_kokkos.cpp index e2d1009f1ae..b2630aded71 100644 --- a/src/KOKKOS/fix_oneway_kokkos.cpp +++ b/src/KOKKOS/fix_oneway_kokkos.cpp @@ -95,9 +95,9 @@ void FixOneWayKokkos::operator()(TagFixOneWay, const int &i) const // bits 0-1 = coordinate index (0=x, 1=y, 2=z), bit 2 = minus direction const int idx = direction & 3; if (direction & 4) { - if (v(i,idx) > 0.0) v(i,idx) = -v(i,idx); + if (v(i,idx) > static_cast(0.0)) v(i,idx) = -v(i,idx); } else { - if (v(i,idx) < 0.0) v(i,idx) = -v(i,idx); + if (v(i,idx) < static_cast(0.0)) v(i,idx) = -v(i,idx); } } } diff --git a/src/KOKKOS/fix_planeforce_kokkos.cpp b/src/KOKKOS/fix_planeforce_kokkos.cpp index cc041b61386..be81d687434 100644 --- a/src/KOKKOS/fix_planeforce_kokkos.cpp +++ b/src/KOKKOS/fix_planeforce_kokkos.cpp @@ -73,10 +73,13 @@ KOKKOS_INLINE_FUNCTION void FixPlaneForceKokkos::operator()(TagFixPlaneForce, const int &i) const { if (mask[i] & groupbit) { - const double dot = f(i,0)*xdir + f(i,1)*ydir + f(i,2)*zdir; - f(i,0) -= dot*xdir; - f(i,1) -= dot*ydir; - f(i,2) -= dot*zdir; + const KK_FLOAT xdir_kk = static_cast(xdir); + const KK_FLOAT ydir_kk = static_cast(ydir); + const KK_FLOAT zdir_kk = static_cast(zdir); + const KK_FLOAT dot = static_cast(f(i,0))*xdir_kk + static_cast(f(i,1))*ydir_kk + static_cast(f(i,2))*zdir_kk; + f(i,0) -= static_cast(dot*xdir_kk); + f(i,1) -= static_cast(dot*ydir_kk); + f(i,2) -= static_cast(dot*zdir_kk); } } diff --git a/src/KOKKOS/fix_recenter_kokkos.cpp b/src/KOKKOS/fix_recenter_kokkos.cpp index 3f67e0f65df..05d8c640894 100644 --- a/src/KOKKOS/fix_recenter_kokkos.cpp +++ b/src/KOKKOS/fix_recenter_kokkos.cpp @@ -102,9 +102,9 @@ void FixRecenterKokkos::initial_integrate(int /*vflag*/) auto d_x = atomKK->k_x.template view(); auto d_mask = atomKK->k_mask.template view(); auto l_group2bit = group2bit; - double l_shiftx = shift[0]; - double l_shifty = shift[1]; - double l_shiftz = shift[2]; + const KK_FLOAT l_shiftx = static_cast(shift[0]); + const KK_FLOAT l_shifty = static_cast(shift[1]); + const KK_FLOAT l_shiftz = static_cast(shift[2]); copymode = 1; diff --git a/src/KOKKOS/fix_rx_kokkos.cpp b/src/KOKKOS/fix_rx_kokkos.cpp index 6d4a2cfbe2d..b0f105dfb63 100644 --- a/src/KOKKOS/fix_rx_kokkos.cpp +++ b/src/KOKKOS/fix_rx_kokkos.cpp @@ -240,24 +240,24 @@ void FixRxKokkos::k_rk4(const double t_stop, VectorType& y, VectorTy // k2 for (int ispecies = 0; ispecies < nspecies; ispecies++) - yp[ispecies] = y[ispecies] + 0.5*h*k1[ispecies]; + yp[ispecies] = static_cast(static_cast(y[ispecies]) + 0.5*h*static_cast(k1[ispecies])); k_rhs(0.0,yp,k2, userData); // k3 for (int ispecies = 0; ispecies < nspecies; ispecies++) - yp[ispecies] = y[ispecies] + 0.5*h*k2[ispecies]; + yp[ispecies] = static_cast(static_cast(y[ispecies]) + 0.5*h*static_cast(k2[ispecies])); k_rhs(0.0,yp,k3, userData); // k4 for (int ispecies = 0; ispecies < nspecies; ispecies++) - yp[ispecies] = y[ispecies] + h*k3[ispecies]; + yp[ispecies] = static_cast(static_cast(y[ispecies]) + h*static_cast(k3[ispecies])); k_rhs(0.0,yp,k4, userData); for (int ispecies = 0; ispecies < nspecies; ispecies++) - y[ispecies] += h*(k1[ispecies]/6.0 + k2[ispecies]/3.0 + k3[ispecies]/3.0 + k4[ispecies]/6.0); + y[ispecies] += static_cast(h*(static_cast(k1[ispecies])/6.0 + static_cast(k2[ispecies])/3.0 + static_cast(k3[ispecies])/3.0 + static_cast(k4[ispecies])/6.0)); } // end for (int step... @@ -323,40 +323,40 @@ void FixRxKokkos::k_rkf45_step (const int neq, const double h, Vecto k_rhs (0.0, y, f1, userData); for (int k = 0; k < neq; k++) { - f1[k] *= h; - ytmp[k] = y[k] + c21 * f1[k]; + f1[k] = static_cast(static_cast(f1[k]) * h); + ytmp[k] = static_cast(static_cast(y[k]) + c21 * static_cast(f1[k])); } // 2) k_rhs(0.0, ytmp, f2, userData); for (int k = 0; k < neq; k++) { - f2[k] *= h; - ytmp[k] = y[k] + c31 * f1[k] + c32 * f2[k]; + f2[k] = static_cast(static_cast(f2[k]) * h); + ytmp[k] = static_cast(static_cast(y[k]) + c31 * static_cast(f1[k]) + c32 * static_cast(f2[k])); } // 3) k_rhs(0.0, ytmp, f3, userData); for (int k = 0; k < neq; k++) { - f3[k] *= h; - ytmp[k] = y[k] + c41 * f1[k] + c42 * f2[k] + c43 * f3[k]; + f3[k] = static_cast(static_cast(f3[k]) * h); + ytmp[k] = static_cast(static_cast(y[k]) + c41 * static_cast(f1[k]) + c42 * static_cast(f2[k]) + c43 * static_cast(f3[k])); } // 4) k_rhs(0.0, ytmp, f4, userData); for (int k = 0; k < neq; k++) { - f4[k] *= h; - ytmp[k] = y[k] + c51 * f1[k] + c52 * f2[k] + c53 * f3[k] + c54 * f4[k]; + f4[k] = static_cast(static_cast(f4[k]) * h); + ytmp[k] = static_cast(static_cast(y[k]) + c51 * static_cast(f1[k]) + c52 * static_cast(f2[k]) + c53 * static_cast(f3[k]) + c54 * static_cast(f4[k])); } // 5) k_rhs(0.0, ytmp, f5, userData); for (int k = 0; k < neq; k++) { - f5[k] *= h; - ytmp[k] = y[k] + c61*f1[k] + c62*f2[k] + c63*f3[k] + c64*f4[k] + c65*f5[k]; + f5[k] = static_cast(static_cast(f5[k]) * h); + ytmp[k] = static_cast(static_cast(y[k]) + c61*static_cast(f1[k]) + c62*static_cast(f2[k]) + c63*static_cast(f3[k]) + c64*static_cast(f4[k]) + c65*static_cast(f5[k])); } // 6) @@ -365,20 +365,20 @@ void FixRxKokkos::k_rkf45_step (const int neq, const double h, Vecto for (int k = 0; k < neq; k++) { //const double f6 = h * ydot[k]; - f6[k] *= h; + f6[k] = static_cast(static_cast(f6[k]) * h); // 5th-order solution. - const double r5 = b1*f1[k] + b3*f3[k] + b4*f4[k] + b5*f5[k] + b6*f6[k]; + const double r5 = b1*static_cast(f1[k]) + b3*static_cast(f3[k]) + b4*static_cast(f4[k]) + b5*static_cast(f5[k]) + b6*static_cast(f6[k]); // 4th-order solution. - const double r4 = a1*f1[k] + a3*f3[k] + a4*f4[k] + a5*f5[k]; + const double r4 = a1*static_cast(f1[k]) + a3*static_cast(f3[k]) + a4*static_cast(f4[k]) + a5*static_cast(f5[k]); // Truncation error: difference between 4th and 5th-order solutions. - rwk[k] = fabs(r5 - r4); + rwk[k] = static_cast(fabs(r5 - r4)); // Update solution. //y_out[k] = y[k] + r5; // Local extrapolation - y_out[k] = y[k] + r4; + y_out[k] = static_cast(static_cast(y[k]) + r4); } } @@ -421,7 +421,7 @@ int FixRxKokkos::k_rkf45_h0 (const int neq, const double t, const do // Estimate y'' with finite-difference ... for (int k = 0; k < neq; k++) - y1[k] = y[k] + hg * ydot[k]; + y1[k] = static_cast(static_cast(y[k]) + hg * static_cast(ydot[k])); // compute y' at t1 k_rhs (t + hg, y1, ydot1, userData); @@ -429,8 +429,8 @@ int FixRxKokkos::k_rkf45_h0 (const int neq, const double t, const do // Compute WRMS norm of y'' double yddnrm = 0.0; for (int k = 0; k < neq; k++) { - double ydd = (ydot1[k] - ydot[k]) / hg; - double wterr = ydd / (relTol * fabs( y[k] ) + absTol); + double ydd = static_cast(ydot1[k] - ydot[k]) / hg; + double wterr = ydd / (relTol * fabs( static_cast(y[k]) ) + absTol); yddnrm += wterr * wterr; } @@ -517,7 +517,7 @@ void FixRxKokkos::k_rkf45(const int neq, const double t_stop, Vector // ... weighted 2-norm of the error. double err2 = 0.0; for (int k = 0; k < neq; k++) { - const double wterr = eout[k] / (relTol * fabs( y[k] ) + absTol); + const double wterr = static_cast(eout[k]) / (relTol * fabs( static_cast(y[k]) ) + absTol); err2 += wterr * wterr; } @@ -900,7 +900,7 @@ int FixRxKokkos::rhs_dense(double /*t*/, const double *y, double *dy for (int ispecies=0; ispecies(d_kineticsData.stoichReactants(jrxn,ispecies)) ); } rxnRateLaw[jrxn] = rxnRateLawForward; } @@ -909,7 +909,7 @@ int FixRxKokkos::rhs_dense(double /*t*/, const double *y, double *dy for (int ispecies=0; ispecies(d_kineticsData.stoich(jrxn,ispecies)) *VDPD*rxnRateLaw[jrxn]; } return 0; @@ -949,11 +949,11 @@ int FixRxKokkos::rhs_sparse(double /*t*/, const double *y, double *d rxnRateLawForward *= powint( conc[k], inu(i,kk) ); } } else { - rxnRateLawForward = kFor[i] * pow( conc[ nuk(i,0) ], nu(i,0) ); + rxnRateLawForward = kFor[i] * pow( conc[ nuk(i,0) ], static_cast(nu(i,0)) ); for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; - rxnRateLawForward *= pow( conc[k], nu(i,kk) ); + rxnRateLawForward *= pow( conc[k], static_cast(nu(i,kk)) ); } } @@ -967,19 +967,19 @@ int FixRxKokkos::rhs_sparse(double /*t*/, const double *y, double *d for (int i = 0; i < nreactions; ++i) { // Reactants ... - dydt[ nuk(i,0) ] -= nu(i,0) * rxnRateLaw[i]; + dydt[ nuk(i,0) ] -= static_cast(nu(i,0)) * rxnRateLaw[i]; for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; - dydt[k] -= nu(i,kk) * rxnRateLaw[i]; + dydt[k] -= static_cast(nu(i,kk)) * rxnRateLaw[i]; } // Products ... - dydt[ nuk(i,maxReactants) ] += nu(i,maxReactants) * rxnRateLaw[i]; + dydt[ nuk(i,maxReactants) ] += static_cast(nu(i,maxReactants)) * rxnRateLaw[i]; for (int kk = maxReactants+1; kk < maxSpecies; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; - dydt[k] += nu(i,kk) * rxnRateLaw[i]; + dydt[k] += static_cast(nu(i,kk)) * rxnRateLaw[i]; } } @@ -1033,20 +1033,20 @@ int FixRxKokkos::k_rhs_dense(double /*t*/, const VectorType& y, Vect // Construct the reaction rate laws for (int jrxn=0; jrxn(kFor[jrxn]); for (int ispecies=0; ispecies(y[ispecies])/VDPD; + rxnRateLawForward *= pow( concentration, static_cast(d_kineticsData.stoichReactants(jrxn,ispecies)) ); } - rxnRateLaw[jrxn] = rxnRateLawForward; + rxnRateLaw[jrxn] = static_cast(rxnRateLawForward); } // Construct the reaction rates for each species for (int ispecies=0; ispecies(static_cast(d_kineticsData.stoich(jrxn,ispecies)) *VDPD*static_cast(rxnRateLaw[jrxn])); } #undef rxnRateLaw @@ -1076,29 +1076,29 @@ int FixRxKokkos::k_rhs_sparse(double /*t*/, const VectorType& y, Vec && this->d_kineticsData.isIntegral(idx) ) for (int k = 0; k < nspecies; ++k) - conc[k] = y[k] / VDPD; + conc[k] = static_cast(static_cast(y[k]) / VDPD); // Construct the reaction rate laws for (int i = 0; i < nreactions; ++i) { double rxnRateLawForward; if (isIntegral(i)) { - rxnRateLawForward = kFor[i] * powint( conc[ nuk(i,0) ], inu(i,0) ); + rxnRateLawForward = static_cast(kFor[i] * powint( conc[ nuk(i,0) ], inu(i,0) )); for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; - rxnRateLawForward *= powint( conc[k], inu(i,kk) ); + rxnRateLawForward *= static_cast(powint( conc[k], inu(i,kk) )); } } else { - rxnRateLawForward = kFor[i] * pow( conc[ nuk(i,0) ], nu(i,0) ); + rxnRateLawForward = static_cast(kFor[i] * Kokkos::pow( conc[ nuk(i,0) ], nu(i,0) )); for (int kk = 1; kk < maxReactants; ++kk) { const int k = nuk(i,kk); if (k == SparseKinetics_invalidIndex) break; - rxnRateLawForward *= pow( conc[k], nu(i,kk) ); + rxnRateLawForward *= static_cast(Kokkos::pow( conc[k], nu(i,kk) )); } } - rxnRateLaw[i] = rxnRateLawForward; + rxnRateLaw[i] = static_cast(rxnRateLawForward); } // Construct the reaction rates for each species from the @@ -1126,7 +1126,7 @@ int FixRxKokkos::k_rhs_sparse(double /*t*/, const VectorType& y, Vec // Add in the volume factor to convert to the proper units. for (int k = 0; k < nspecies; ++k) - dydt[k] *= VDPD; + dydt[k] = static_cast(static_cast(dydt[k]) * VDPD); #undef kFor #undef kRev @@ -1153,9 +1153,9 @@ void FixRxKokkos::create_kinetics_data() for (int i = 0; i < nreactions; ++i) { - h_kineticsData.Arr[i] = Arr[i]; - h_kineticsData.nArr[i] = nArr[i]; - h_kineticsData.Ea[i] = Ea[i]; + h_kineticsData.Arr[i] = static_cast(Arr[i]); + h_kineticsData.nArr[i] = static_cast(nArr[i]); + h_kineticsData.Ea[i] = static_cast(Ea[i]); } Kokkos::deep_copy( d_kineticsData.Arr, h_kineticsData.Arr ); @@ -1171,7 +1171,7 @@ void FixRxKokkos::create_kinetics_data() for (int i = 0; i < nreactions; ++i) for (int k = 0; k < sparseKinetics_maxSpecies; ++k) { - h_kineticsData.nu (i,k) = sparseKinetics_nu [i][k]; + h_kineticsData.nu (i,k) = static_cast(sparseKinetics_nu [i][k]); h_kineticsData.nuk(i,k) = sparseKinetics_nuk[i][k]; } @@ -1207,9 +1207,9 @@ void FixRxKokkos::create_kinetics_data() for (int i = 0; i < nreactions; ++i) for (int k = 0; k < nspecies; ++k) { - h_kineticsData.stoich(i,k) = stoich[i][k]; - h_kineticsData.stoichReactants(i,k) = stoichReactants[i][k]; - h_kineticsData.stoichProducts(i,k) = stoichProducts[i][k]; + h_kineticsData.stoich(i,k) = static_cast(stoich[i][k]); + h_kineticsData.stoichReactants(i,k) = static_cast(stoichReactants[i][k]); + h_kineticsData.stoichProducts(i,k) = static_cast(stoichProducts[i][k]); } Kokkos::deep_copy( d_kineticsData.stoich, h_kineticsData.stoich ); @@ -1272,7 +1272,7 @@ void FixRxKokkos::operator()(Tag_FixRxKokkos_solveSystems(d_dpdThetaLocal(i)) : static_cast(d_dpdTheta(i)); //Compute the reaction rate constants for (int irxn = 0; irxn < nreactions; irxn++) @@ -1281,9 +1281,9 @@ void FixRxKokkos::operator()(Tag_FixRxKokkos_solveSystems(static_cast(d_kineticsData.Arr(irxn)) * + pow(theta, static_cast(d_kineticsData.nArr(irxn))) * + exp(-static_cast(d_kineticsData.Ea(irxn)) / boltz / theta)); } } @@ -1293,9 +1293,9 @@ void FixRxKokkos::operator()(Tag_FixRxKokkos_solveSystems(d_dvector(atom_ind, i)); + d_dvector(atom_ind_old, i) = static_cast(tmp); + y[ispecies] = static_cast(tmp); } // Solver the ODE system. @@ -1317,13 +1317,13 @@ void FixRxKokkos::operator()(Tag_FixRxKokkos_solveSystems(-1.0e-10)) { //error->one(FLERR,"Computed concentration in RK solver is < -1.0e-10"); k_error_flag.template view()() = 2; // This should be an atomic update. } - else if (y[ispecies] < MY_EPSILON) + else if (y[ispecies] < static_cast(MY_EPSILON)) y[ispecies] = 0.0; const auto atom_ind = d_species_ind_to_atom_prop_ind(ispecies); @@ -1693,9 +1693,9 @@ void FixRxKokkos::operator()(Tag_FixRxKokkos_firstPairOperator(d_x(i,0)); + const double ytmp = static_cast(d_x(i,1)); + const double ztmp = static_cast(d_x(i,2)); const int itype = d_type(i); const int jnum = d_numneigh(i); @@ -1705,12 +1705,12 @@ void FixRxKokkos::operator()(Tag_FixRxKokkos_firstPairOperator(d_x(j,0)); + const double dely = ytmp - static_cast(d_x(j,1)); + const double delz = ztmp - static_cast(d_x(j,2)); const double rsq = delx*delx + dely*dely + delz*delz; - const double cutsq_ij = d_cutsq(itype,jtype); + const double cutsq_ij = static_cast(d_cutsq(itype,jtype)); if (rsq < cutsq_ij) { @@ -1724,20 +1724,20 @@ void FixRxKokkos::operator()(Tag_FixRxKokkos_firstPairOperator(d_dpdTheta(j)); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) - a_dpdThetaLocal(j) += wij / d_dpdTheta(i); + a_dpdThetaLocal(j) += static_cast(wij / static_cast(d_dpdTheta(i))); } i_sumWeights += wij; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) - a_sumWeights(j) += wij; + a_sumWeights(j) += static_cast(wij); } } // Update, don't assign, the array value (because another iteration may have hit it). - a_dpdThetaLocal(i) += i_dpdThetaLocal; - a_sumWeights(i) += i_sumWeights; + a_dpdThetaLocal(i) += static_cast(i_dpdThetaLocal); + a_sumWeights(i) += static_cast(i_sumWeights); } /* ---------------------------------------------------------------------- */ @@ -1754,15 +1754,15 @@ void FixRxKokkos::operator()(Tag_FixRxKokkos_2ndPairOperator(wij / static_cast(d_dpdTheta(i))); } - d_sumWeights(i) += wij; + d_sumWeights(i) += static_cast(wij); // Normalized local temperature d_dpdThetaLocal(i) = d_dpdThetaLocal(i) / d_sumWeights(i); if (LOCAL_TEMP_FLAG == HARMONIC) - d_dpdThetaLocal(i) = 1.0 / d_dpdThetaLocal(i); + d_dpdThetaLocal(i) = static_cast(1.0) / d_dpdThetaLocal(i); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_setforce_kokkos.cpp b/src/KOKKOS/fix_setforce_kokkos.cpp index 568831fccce..fb1c2c64d2d 100644 --- a/src/KOKKOS/fix_setforce_kokkos.cpp +++ b/src/KOKKOS/fix_setforce_kokkos.cpp @@ -151,14 +151,17 @@ template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void FixSetForceKokkos::operator()(TagFixSetForceConstant, const int &i, double_3& foriginal_kk) const { + const KK_FLOAT xvalue_kk = static_cast(xvalue); + const KK_FLOAT yvalue_kk = static_cast(yvalue); + const KK_FLOAT zvalue_kk = static_cast(zvalue); if (mask[i] & groupbit) { if (region && !d_match[i]) return; - foriginal_kk.d0 += f(i,0); - foriginal_kk.d1 += f(i,1); - foriginal_kk.d2 += f(i,2); - if (xstyle) f(i,0) = xvalue; - if (ystyle) f(i,1) = yvalue; - if (zstyle) f(i,2) = zvalue; + foriginal_kk.d0 += static_cast(f(i,0)); + foriginal_kk.d1 += static_cast(f(i,1)); + foriginal_kk.d2 += static_cast(f(i,2)); + if (xstyle) f(i,0) = static_cast(xvalue_kk); + if (ystyle) f(i,1) = static_cast(yvalue_kk); + if (zstyle) f(i,2) = static_cast(zvalue_kk); } } @@ -166,17 +169,20 @@ template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void FixSetForceKokkos::operator()(TagFixSetForceNonConstant, const int &i, double_3& foriginal_kk) const { + const KK_FLOAT xvalue_kk = static_cast(xvalue); + const KK_FLOAT yvalue_kk = static_cast(yvalue); + const KK_FLOAT zvalue_kk = static_cast(zvalue); if (mask[i] & groupbit) { if (region && !d_match[i]) return; - foriginal_kk.d0 += f(i,0); - foriginal_kk.d1 += f(i,1); - foriginal_kk.d2 += f(i,2); - if (xstyle == ATOM) f(i,0) = d_sforce(i,0); - else if (xstyle) f(i,0) = xvalue; - if (ystyle == ATOM) f(i,1) = d_sforce(i,1); - else if (ystyle) f(i,1) = yvalue; - if (zstyle == ATOM) f(i,2) = d_sforce(i,2); - else if (zstyle) f(i,2) = zvalue; + foriginal_kk.d0 += static_cast(f(i,0)); + foriginal_kk.d1 += static_cast(f(i,1)); + foriginal_kk.d2 += static_cast(f(i,2)); + if (xstyle == ATOM) f(i,0) = static_cast(d_sforce(i,0)); + else if (xstyle) f(i,0) = static_cast(xvalue_kk); + if (ystyle == ATOM) f(i,1) = static_cast(d_sforce(i,1)); + else if (ystyle) f(i,1) = static_cast(yvalue_kk); + if (zstyle == ATOM) f(i,2) = static_cast(d_sforce(i,2)); + else if (zstyle) f(i,2) = static_cast(zvalue_kk); } } diff --git a/src/KOKKOS/fix_shake_kokkos.cpp b/src/KOKKOS/fix_shake_kokkos.cpp index 13ee3341cc2..4fff360a394 100644 --- a/src/KOKKOS/fix_shake_kokkos.cpp +++ b/src/KOKKOS/fix_shake_kokkos.cpp @@ -411,7 +411,7 @@ void FixShakeKokkos::min_post_force(int vflag) if (need_dup) Kokkos::Experimental::contribute(d_f, dup_f); comm->reverse_comm(this); - this->ebond = ev.evdwl; + this->ebond = static_cast(ev.evdwl); if (vflag_global) { virial[0] += static_cast(ev.v[0]); @@ -452,10 +452,10 @@ void FixShakeKokkos::operator()(TagFixShakeMinPostForce 0.0) ? -2.0 * rk / r : 0.0; + const KK_FLOAT rk = static_cast(kbond) * dr; + const KK_FLOAT fbond = (r > static_cast(0.0)) ? static_cast(-2.0) * rk / r : static_cast(0.0); const KK_FLOAT eb = rk * dr; a_f(idx0, 0) += static_cast(delx * fbond); a_f(idx0, 1) += static_cast(dely * fbond); @@ -463,14 +463,14 @@ void FixShakeKokkos::operator()(TagFixShakeMinPostForce(delx * fbond); a_f(idx1, 1) -= static_cast(dely * fbond); a_f(idx1, 2) -= static_cast(delz * fbond); - ev.evdwl += eb; + ev.evdwl += static_cast(eb); if (VFLAG) { - ev.v[0] += static_cast(0.5 * delx * delx * fbond); - ev.v[1] += static_cast(0.5 * dely * dely * fbond); - ev.v[2] += static_cast(0.5 * delz * delz * fbond); - ev.v[3] += static_cast(0.5 * delx * dely * fbond); - ev.v[4] += static_cast(0.5 * delx * delz * fbond); - ev.v[5] += static_cast(0.5 * dely * delz * fbond); + ev.v[0] += static_cast(static_cast(0.5) * delx * delx * fbond); + ev.v[1] += static_cast(static_cast(0.5) * dely * dely * fbond); + ev.v[2] += static_cast(static_cast(0.5) * delz * delz * fbond); + ev.v[3] += static_cast(static_cast(0.5) * delx * dely * fbond); + ev.v[4] += static_cast(static_cast(0.5) * delx * delz * fbond); + ev.v[5] += static_cast(static_cast(0.5) * dely * delz * fbond); } if (output_every && !is_angle) { Kokkos::atomic_add(&d_b_stats(type_idx, 0), 1.0); @@ -499,12 +499,12 @@ void FixShakeKokkos::operator()(TagFixShakeMinPostForce(2.0)*r1*r2)) * static_cast(180.0)/static_cast(MY_PI); int mt = d_shake_type(m, 2); int count = (i0 < nlocal) + (i1 < nlocal) + (i2 < nlocal); if (count > 0) { Kokkos::atomic_add(&d_a_stats(mt, 0), (double)count); - Kokkos::atomic_add(&d_a_stats(mt, 1), (double)count * angle); + Kokkos::atomic_add(&d_a_stats(mt, 1), (double)count * static_cast(angle)); Kokkos::atomic_max(&d_a_stats(mt, 2), (double)angle); Kokkos::atomic_min(&d_a_stats(mt, 3), (double)angle); } @@ -875,10 +875,10 @@ void FixShakeKokkos::shake(int ilist, EV_FLOAT& ev) const // exact quadratic solution for lamda KK_FLOAT lamda,lamda1,lamda2; - lamda1 = (-b+sqrt(determ)) / (static_cast(2.0)*a); - lamda2 = (-b-sqrt(determ)) / (static_cast(2.0)*a); + lamda1 = (-b+Kokkos::sqrt(determ)) / (static_cast(2.0)*a); + lamda2 = (-b-Kokkos::sqrt(determ)) / (static_cast(2.0)*a); - if (fabs(lamda1) <= fabs(lamda2)) lamda = lamda1; + if (Kokkos::fabs(lamda1) <= Kokkos::fabs(lamda2)) lamda = lamda1; else lamda = lamda2; // update forces if atom is owned by this processor @@ -1040,14 +1040,14 @@ void FixShakeKokkos::shake3(int ilist, EV_FLOAT& ev) const lamda02_new = a21inv*b1 + a22inv*b2; done = 1; - if (fabs(lamda01_new-lamda01) > tolerance_kk) done = 0; - if (fabs(lamda02_new-lamda02) > tolerance_kk) done = 0; + if (Kokkos::fabs(lamda01_new-lamda01) > tolerance_kk) done = 0; + if (Kokkos::fabs(lamda02_new-lamda02) > tolerance_kk) done = 0; lamda01 = lamda01_new; lamda02 = lamda02_new; // stop iterations before we have a floating point overflow - if (fabs(lamda01) > overflow_kk || fabs(lamda02) > overflow_kk) done = 1; + if (Kokkos::fabs(lamda01) > overflow_kk || Kokkos::fabs(lamda02) > overflow_kk) done = 1; niter++; } @@ -1285,16 +1285,16 @@ void FixShakeKokkos::shake4(int ilist, EV_FLOAT& ev) const lamda03_new = a31inv*b1 + a32inv*b2 + a33inv*b3; done = 1; - if (fabs(lamda01_new-lamda01) > tolerance_kk) done = 0; - if (fabs(lamda02_new-lamda02) > tolerance_kk) done = 0; - if (fabs(lamda03_new-lamda03) > tolerance_kk) done = 0; + if (Kokkos::fabs(lamda01_new-lamda01) > tolerance_kk) done = 0; + if (Kokkos::fabs(lamda02_new-lamda02) > tolerance_kk) done = 0; + if (Kokkos::fabs(lamda03_new-lamda03) > tolerance_kk) done = 0; lamda01 = lamda01_new; lamda02 = lamda02_new; lamda03 = lamda03_new; // stop iterations before we have a floating point overflow - if (fabs(lamda01) > overflow_kk || fabs(lamda02) > overflow_kk || fabs(lamda03) > overflow_kk) done = 1; + if (Kokkos::fabs(lamda01) > overflow_kk || Kokkos::fabs(lamda02) > overflow_kk || Kokkos::fabs(lamda03) > overflow_kk) done = 1; niter++; } @@ -1538,16 +1538,16 @@ void FixShakeKokkos::shake3angle(int ilist, EV_FLOAT& ev) const lamda12_new = a31inv*b1 + a32inv*b2 + a33inv*b3; done = 1; - if (fabs(lamda01_new-lamda01) > tolerance_kk) done = 0; - if (fabs(lamda02_new-lamda02) > tolerance_kk) done = 0; - if (fabs(lamda12_new-lamda12) > tolerance_kk) done = 0; + if (Kokkos::fabs(lamda01_new-lamda01) > tolerance_kk) done = 0; + if (Kokkos::fabs(lamda02_new-lamda02) > tolerance_kk) done = 0; + if (Kokkos::fabs(lamda12_new-lamda12) > tolerance_kk) done = 0; lamda01 = lamda01_new; lamda02 = lamda02_new; lamda12 = lamda12_new; // stop iterations before we have a floating point overflow - if (fabs(lamda01) > overflow_kk || fabs(lamda02) > overflow_kk || fabs(lamda12) > overflow_kk) done = 1; + if (Kokkos::fabs(lamda01) > overflow_kk || Kokkos::fabs(lamda02) > overflow_kk || Kokkos::fabs(lamda12) > overflow_kk) done = 1; niter++; } diff --git a/src/KOKKOS/fix_shardlow_kokkos.cpp b/src/KOKKOS/fix_shardlow_kokkos.cpp index 972970636aa..8535e9e604d 100644 --- a/src/KOKKOS/fix_shardlow_kokkos.cpp +++ b/src/KOKKOS/fix_shardlow_kokkos.cpp @@ -142,17 +142,17 @@ void FixShardlowKokkos::init() for (int i = 1; i <= ntypes; i++) { for (int j = i; j <= ntypes; j++) { double cutone = k_pairDPDE->cut[i][j]; - if (cutone > EPSILON) k_params.view_host()(i,j).cutinv = 1.0/cutone; + if (cutone > EPSILON) k_params.view_host()(i,j).cutinv = static_cast(1.0/cutone); else k_params.view_host()(i,j).cutinv = FLT_MAX; - k_params.view_host()(i,j).halfsigma = 0.5*k_pairDPDE->sigma[i][j]; - k_params.view_host()(i,j).kappa = k_pairDPDE->kappa[i][j]; - k_params.view_host()(i,j).alpha = k_pairDPDE->alpha[i][j]; + k_params.view_host()(i,j).halfsigma = static_cast(0.5*k_pairDPDE->sigma[i][j]); + k_params.view_host()(i,j).kappa = static_cast(k_pairDPDE->kappa[i][j]); + k_params.view_host()(i,j).alpha = static_cast(k_pairDPDE->alpha[i][j]); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (ik_cutsq.view_host()(i,j); + m_cutsq[j][i] = m_cutsq[i][j] = static_cast(k_pairDPDE->k_cutsq.view_host()(i,j)); } } } @@ -411,10 +411,10 @@ void FixShardlowKokkos::ssa_update_dpde( KK_FLOAT uCond_i = uCond(i); const int itype = type(i); - const KK_FLOAT theta_i_inv = 1.0/dpdTheta(i); + const KK_FLOAT theta_i_inv = static_cast(1.0)/dpdTheta(i); const KK_FLOAT mass_i = masses(massPerI ? i : itype); - const KK_FLOAT massinv_i = 1.0 / mass_i; - const KK_FLOAT mass_i_div_neg4_ftm2v = mass_i*(-0.25)/ftm2v; + const KK_FLOAT massinv_i = static_cast(1.0) / mass_i; + const KK_FLOAT mass_i_div_neg4_ftm2v = mass_i*static_cast(-0.25)/ftm2v; // Loop over Directional Neighbors only for (int jj = 0; jj < jlen; jj++) { @@ -437,46 +437,46 @@ void FixShardlowKokkos::ssa_update_dpde( // NOTE: r can be 0.0 in DPD systems, so do EPSILON_SQUARED test if ((rsq < (STACKPARAMS?m_cutsq[itype][jtype]:d_cutsq(itype,jtype))) - && (rsq >= EPSILON_SQUARED)) { + && (rsq >= static_cast(EPSILON_SQUARED))) { #ifdef DEBUG_SSA_PAIR_CT if ((i < nlocal) && (j < nlocal)) Kokkos::atomic_inc(&(d_counters(1, 0))); else Kokkos::atomic_inc(&(d_counters(1, 1))); Kokkos::atomic_inc(&(d_counters(1, 2))); #endif - KK_FLOAT r = sqrt(rsq); - KK_FLOAT rinv = 1.0/r; + KK_FLOAT r = Kokkos::sqrt(rsq); + KK_FLOAT rinv = static_cast(1.0)/r; KK_FLOAT delx_rinv = delx*rinv; KK_FLOAT dely_rinv = dely*rinv; KK_FLOAT delz_rinv = delz*rinv; - KK_FLOAT wr = 1.0 - r*(STACKPARAMS?m_params[itype][jtype].cutinv:params(itype,jtype).cutinv); + KK_FLOAT wr = static_cast(1.0) - r*(STACKPARAMS?m_params[itype][jtype].cutinv:params(itype,jtype).cutinv); KK_FLOAT wdt = wr*wr*dt; // Compute the current temperature - KK_FLOAT theta_j_inv = 1.0/dpdTheta(j); - KK_FLOAT theta_ij_inv = 0.5*(theta_i_inv + theta_j_inv); + KK_FLOAT theta_j_inv = static_cast(1.0)/dpdTheta(j); + KK_FLOAT theta_ij_inv = static_cast(0.5)*(theta_i_inv + theta_j_inv); KK_FLOAT halfsigma_ij = STACKPARAMS?m_params[itype][jtype].halfsigma:params(itype,jtype).halfsigma; KK_FLOAT halfgamma_ij = halfsigma_ij*halfsigma_ij*boltz_inv*theta_ij_inv; - KK_FLOAT sigmaRand = halfsigma_ij*wr*dtsqrt*ftm2v * es_normal(RNGstate); + KK_FLOAT sigmaRand = halfsigma_ij*wr*dtsqrt*ftm2v * static_cast(es_normal(RNGstate)); const KK_FLOAT mass_j = masses(massPerI ? j : jtype); KK_FLOAT mass_ij_div_neg4_ftm2v = mass_j*mass_i_div_neg4_ftm2v; - KK_FLOAT massinv_j = 1.0 / mass_j; + KK_FLOAT massinv_j = static_cast(1.0) / mass_j; // Compute uCond KK_FLOAT kappa_ij = STACKPARAMS?m_params[itype][jtype].kappa:params(itype,jtype).kappa; KK_FLOAT alpha_ij = STACKPARAMS?m_params[itype][jtype].alpha:params(itype,jtype).alpha; - KK_FLOAT del_uCond = alpha_ij*wr*dtsqrt * es_normal(RNGstate); + KK_FLOAT del_uCond = alpha_ij*wr*dtsqrt * static_cast(es_normal(RNGstate)); del_uCond += kappa_ij*(theta_i_inv - theta_j_inv)*wdt; uCond[j] -= del_uCond; uCond_i += del_uCond; KK_FLOAT gammaFactor = halfgamma_ij*wdt*ftm2v; - KK_FLOAT inv_1p_mu_gammaFactor = 1.0/(1.0 + (massinv_i + massinv_j)*gammaFactor); + KK_FLOAT inv_1p_mu_gammaFactor = static_cast(1.0)/(static_cast(1.0) + (massinv_i + massinv_j)*gammaFactor); KK_FLOAT vxj = v(j, 0); KK_FLOAT vyj = v(j, 1); @@ -558,7 +558,7 @@ void FixShardlowKokkos::initial_integrate(int /*vflag*/) copymode = 1; - dtsqrt = sqrt(update->dt); + dtsqrt = static_cast(sqrt(update->dt)); NPairSSAKokkos *np_ssa = dynamic_cast*>(list->np); if (!np_ssa) error->one(FLERR, "NPair wasn't a NPairSSAKokkos object"); @@ -609,9 +609,9 @@ void FixShardlowKokkos::initial_integrate(int /*vflag*/) #endif //theta_ij_inv = 1.0/k_pairDPD->temperature; // independent of i,j - boltz_inv = 1.0/force->boltz; - ftm2v = force->ftm2v; - dt = update->dt; + boltz_inv = static_cast(1.0/force->boltz); + ftm2v = static_cast(force->ftm2v); + dt = static_cast(update->dt); k_params.template sync(); @@ -731,9 +731,9 @@ void FixShardlowKokkos::unpack_forward_comm(int n, int first, double m = 0; last = first + n ; for (ii = first; ii < last; ii++) { - h_v_t0(ii - nlocal, 0) = h_v(ii, 0) = buf[m++]; - h_v_t0(ii - nlocal, 1) = h_v(ii, 1) = buf[m++]; - h_v_t0(ii - nlocal, 2) = h_v(ii, 2) = buf[m++]; + h_v_t0(ii - nlocal, 0) = static_cast(h_v(ii, 0) = buf[m++]); + h_v_t0(ii - nlocal, 1) = static_cast(h_v(ii, 1) = buf[m++]); + h_v_t0(ii - nlocal, 2) = static_cast(h_v(ii, 2) = buf[m++]); } } @@ -747,9 +747,9 @@ int FixShardlowKokkos::pack_reverse_comm(int n, int first, double *b m = 0; last = first + n; for (i = first; i < last; i++) { - buf[m++] = h_v(i, 0) - h_v_t0(i - nlocal, 0); - buf[m++] = h_v(i, 1) - h_v_t0(i - nlocal, 1); - buf[m++] = h_v(i, 2) - h_v_t0(i - nlocal, 2); + buf[m++] = h_v(i, 0) - static_cast(h_v_t0(i - nlocal, 0)); + buf[m++] = h_v(i, 1) - static_cast(h_v_t0(i - nlocal, 1)); + buf[m++] = h_v(i, 2) - static_cast(h_v_t0(i - nlocal, 2)); if (k_pairDPDE) { buf[m++] = h_uCond(i); // for ghosts, this is an accumulated delta buf[m++] = h_uMech(i); // for ghosts, this is an accumulated delta diff --git a/src/KOKKOS/fix_spring_kokkos.cpp b/src/KOKKOS/fix_spring_kokkos.cpp index 6a2714747d5..076ec0b99d7 100644 --- a/src/KOKKOS/fix_spring_kokkos.cpp +++ b/src/KOKKOS/fix_spring_kokkos.cpp @@ -199,11 +199,14 @@ template KOKKOS_INLINE_FUNCTION void FixSpringKokkos::operator()(TagFixSpringTether, const int &i) const { + const KK_FLOAT l_fx_kk = static_cast(l_fx); + const KK_FLOAT l_fy_kk = static_cast(l_fy); + const KK_FLOAT l_fz_kk = static_cast(l_fz); if (mask[i] & groupbit) { - const double massone = mass[type[i]]; - f(i,0) -= l_fx * massone; - f(i,1) -= l_fy * massone; - f(i,2) -= l_fz * massone; + const KK_FLOAT massone = mass[type[i]]; + f(i,0) -= static_cast(l_fx_kk * massone); + f(i,1) -= static_cast(l_fy_kk * massone); + f(i,2) -= static_cast(l_fz_kk * massone); } } @@ -214,11 +217,14 @@ template KOKKOS_INLINE_FUNCTION void FixSpringKokkos::operator()(TagFixSpringTetherRmass, const int &i) const { + const KK_FLOAT l_fx_kk = static_cast(l_fx); + const KK_FLOAT l_fy_kk = static_cast(l_fy); + const KK_FLOAT l_fz_kk = static_cast(l_fz); if (mask[i] & groupbit) { - const double massone = rmass[i]; - f(i,0) -= l_fx * massone; - f(i,1) -= l_fy * massone; - f(i,2) -= l_fz * massone; + const KK_FLOAT massone = rmass[i]; + f(i,0) -= static_cast(l_fx_kk * massone); + f(i,1) -= static_cast(l_fy_kk * massone); + f(i,2) -= static_cast(l_fz_kk * massone); } } @@ -229,16 +235,22 @@ template KOKKOS_INLINE_FUNCTION void FixSpringKokkos::operator()(TagFixSpringCouple, const int &i) const { - const double massone = mass[type[i]]; + const KK_FLOAT l_fx_kk = static_cast(l_fx); + const KK_FLOAT l_fy_kk = static_cast(l_fy); + const KK_FLOAT l_fz_kk = static_cast(l_fz); + const KK_FLOAT l_fx2_kk = static_cast(l_fx2); + const KK_FLOAT l_fy2_kk = static_cast(l_fy2); + const KK_FLOAT l_fz2_kk = static_cast(l_fz2); + const KK_FLOAT massone = mass[type[i]]; if (mask[i] & groupbit) { - f(i,0) += l_fx * massone; - f(i,1) += l_fy * massone; - f(i,2) += l_fz * massone; + f(i,0) += static_cast(l_fx_kk * massone); + f(i,1) += static_cast(l_fy_kk * massone); + f(i,2) += static_cast(l_fz_kk * massone); } if (mask[i] & l_group2bit) { - f(i,0) -= l_fx2 * massone; - f(i,1) -= l_fy2 * massone; - f(i,2) -= l_fz2 * massone; + f(i,0) -= static_cast(l_fx2_kk * massone); + f(i,1) -= static_cast(l_fy2_kk * massone); + f(i,2) -= static_cast(l_fz2_kk * massone); } } @@ -249,16 +261,22 @@ template KOKKOS_INLINE_FUNCTION void FixSpringKokkos::operator()(TagFixSpringCoupleRmass, const int &i) const { - const double massone = rmass[i]; + const KK_FLOAT l_fx_kk = static_cast(l_fx); + const KK_FLOAT l_fy_kk = static_cast(l_fy); + const KK_FLOAT l_fz_kk = static_cast(l_fz); + const KK_FLOAT l_fx2_kk = static_cast(l_fx2); + const KK_FLOAT l_fy2_kk = static_cast(l_fy2); + const KK_FLOAT l_fz2_kk = static_cast(l_fz2); + const KK_FLOAT massone = rmass[i]; if (mask[i] & groupbit) { - f(i,0) += l_fx * massone; - f(i,1) += l_fy * massone; - f(i,2) += l_fz * massone; + f(i,0) += static_cast(l_fx_kk * massone); + f(i,1) += static_cast(l_fy_kk * massone); + f(i,2) += static_cast(l_fz_kk * massone); } if (mask[i] & l_group2bit) { - f(i,0) -= l_fx2 * massone; - f(i,1) -= l_fy2 * massone; - f(i,2) -= l_fz2 * massone; + f(i,0) -= static_cast(l_fx2_kk * massone); + f(i,1) -= static_cast(l_fy2_kk * massone); + f(i,2) -= static_cast(l_fz2_kk * massone); } } diff --git a/src/KOKKOS/fix_spring_self_kokkos.cpp b/src/KOKKOS/fix_spring_self_kokkos.cpp index efe07167110..3431130e9b5 100644 --- a/src/KOKKOS/fix_spring_self_kokkos.cpp +++ b/src/KOKKOS/fix_spring_self_kokkos.cpp @@ -127,19 +127,19 @@ void FixSpringSelfKokkos::post_force(int /*vflag*/) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,nlocal), LAMMPS_LAMBDA(const int& i, double& espring_kk) { if (l_mask[i] & l_groupbit) { Few x_i; - x_i[0] = l_x(i,0); - x_i[1] = l_x(i,1); - x_i[2] = l_x(i,2); + x_i[0] = static_cast(l_x(i,0)); + x_i[1] = static_cast(l_x(i,1)); + x_i[2] = static_cast(l_x(i,2)); auto unwrap = DomainKokkos::unmap(prd,h,triclinic,x_i,l_image(i)); - auto dx = unwrap[0] - l_xoriginal(i, 0); - auto dy = unwrap[1] - l_xoriginal(i, 1); - auto dz = unwrap[2] - l_xoriginal(i, 2); + auto dx = unwrap[0] - static_cast(l_xoriginal(i, 0)); + auto dy = unwrap[1] - static_cast(l_xoriginal(i, 1)); + auto dz = unwrap[2] - static_cast(l_xoriginal(i, 2)); if (!l_xflag) dx = 0.0; if (!l_yflag) dy = 0.0; if (!l_zflag) dz = 0.0; - l_f(i,0) -= l_k*dx; - l_f(i,1) -= l_k*dy; - l_f(i,2) -= l_k*dz; + l_f(i,0) -= static_cast(l_k*dx); + l_f(i,1) -= static_cast(l_k*dy); + l_f(i,2) -= static_cast(l_k*dz); espring_kk += l_k * (dx*dx + dy*dy + dz*dz); } },espring_kk); @@ -186,9 +186,9 @@ void FixSpringSelfKokkos::pack_exchange_item(const int &mysend, int int m = nsend + offset; d_buf[mysend] = m; - d_buf[m++] = d_xoriginal(i,0); - d_buf[m++] = d_xoriginal(i,1); - d_buf[m++] = d_xoriginal(i,2); + d_buf[m++] = static_cast(d_xoriginal(i,0)); + d_buf[m++] = static_cast(d_xoriginal(i,1)); + d_buf[m++] = static_cast(d_xoriginal(i,2)); if (mysend == nsend-1) d_count() = m; offset = m - nsend; diff --git a/src/KOKKOS/fix_temp_berendsen_kokkos.cpp b/src/KOKKOS/fix_temp_berendsen_kokkos.cpp index 2884fce747d..6c3f8b78dda 100644 --- a/src/KOKKOS/fix_temp_berendsen_kokkos.cpp +++ b/src/KOKKOS/fix_temp_berendsen_kokkos.cpp @@ -107,11 +107,12 @@ void FixTempBerendsenKokkos::end_of_step() atomKK->sync(execution_space,V_MASK|MASK_MASK); + const KK_FLOAT lamda_kk = static_cast(lamda); Kokkos::parallel_for(Kokkos::RangePolicy(0,nlocal), LAMMPS_LAMBDA(int i) { if (mask[i] & groupbit) { - v(i,0) *= lamda; - v(i,1) *= lamda; - v(i,2) *= lamda; + v(i,0) *= lamda_kk; + v(i,1) *= lamda_kk; + v(i,2) *= lamda_kk; } }); diff --git a/src/KOKKOS/fix_temp_rescale_kokkos.cpp b/src/KOKKOS/fix_temp_rescale_kokkos.cpp index 02ba4ff1e28..c1b0d378355 100644 --- a/src/KOKKOS/fix_temp_rescale_kokkos.cpp +++ b/src/KOKKOS/fix_temp_rescale_kokkos.cpp @@ -110,11 +110,12 @@ void FixTempRescaleKokkos::end_of_step() atomKK->sync(execution_space,V_MASK|MASK_MASK); + const KK_FLOAT factor_kk = static_cast(factor); Kokkos::parallel_for(Kokkos::RangePolicy(0,nlocal), LAMMPS_LAMBDA(int i) { if (mask[i] & groupbit) { - v(i,0) *= factor; - v(i,1) *= factor; - v(i,2) *= factor; + v(i,0) *= factor_kk; + v(i,1) *= factor_kk; + v(i,2) *= factor_kk; } }); diff --git a/src/KOKKOS/fix_viscous_kokkos.cpp b/src/KOKKOS/fix_viscous_kokkos.cpp index e92d6fc046a..00837a5e31d 100644 --- a/src/KOKKOS/fix_viscous_kokkos.cpp +++ b/src/KOKKOS/fix_viscous_kokkos.cpp @@ -52,7 +52,7 @@ void FixViscousKokkos::init() k_gamma = Kokkos::DualView("FixViscousKokkos:gamma",atom->ntypes+1); - for (int i = 1; i <= atom->ntypes; i++) k_gamma.view_host()(i) = gamma[i]; + for (int i = 1; i <= atom->ntypes; i++) k_gamma.view_host()(i) = static_cast(gamma[i]); k_gamma.modify_host(); k_gamma.template sync(); @@ -88,9 +88,9 @@ KOKKOS_INLINE_FUNCTION void FixViscousKokkos::operator()(TagFixViscous, const int &i) const { if (mask[i] & groupbit) { KK_FLOAT drag = k_gamma.view_device()(type[i]); - f(i,0) -= drag*v(i,0); - f(i,1) -= drag*v(i,1); - f(i,2) -= drag*v(i,2); + f(i,0) -= static_cast(drag*v(i,0)); + f(i,1) -= static_cast(drag*v(i,1)); + f(i,2) -= static_cast(drag*v(i,2)); } } diff --git a/src/KOKKOS/fix_viscous_sphere_kokkos.cpp b/src/KOKKOS/fix_viscous_sphere_kokkos.cpp index e6dbb5693a4..fbc401bfa39 100644 --- a/src/KOKKOS/fix_viscous_sphere_kokkos.cpp +++ b/src/KOKKOS/fix_viscous_sphere_kokkos.cpp @@ -106,9 +106,9 @@ void FixViscousSphereKokkos::operator()(TagFixViscousSphere, const i drag = k_eff_gamma.view_device()(type[i]); else drag = m_gamma; - torque(i,0) -= drag * omega(i,0); - torque(i,1) -= drag * omega(i,1); - torque(i,2) -= drag * omega(i,2); + torque(i,0) -= static_cast(drag * omega(i,0)); + torque(i,1) -= static_cast(drag * omega(i,1)); + torque(i,2) -= static_cast(drag * omega(i,2)); } } diff --git a/src/KOKKOS/fix_wall_flow_kokkos.cpp b/src/KOKKOS/fix_wall_flow_kokkos.cpp index adee4200b2f..60e52c5517c 100644 --- a/src/KOKKOS/fix_wall_flow_kokkos.cpp +++ b/src/KOKKOS/fix_wall_flow_kokkos.cpp @@ -44,7 +44,7 @@ FixWallFlowKokkos::FixWallFlowKokkos(LAMMPS *lmp, int narg, char **a d_walls = d_walls_t("FixWallFlowKokkos::walls", walls.size()); auto h_walls = Kokkos::create_mirror_view(d_walls); - for (int i = 0; i < (int) walls.size(); ++i) h_walls(i) = walls[i]; + for (int i = 0; i < (int) walls.size(); ++i) h_walls(i) = static_cast(walls[i]); Kokkos::deep_copy(d_walls, h_walls); } @@ -122,29 +122,31 @@ KOKKOS_INLINE_FUNCTION void FixWallFlowKokkos::generate_velocity_kk( { const int newton_iteration_count = 10; KK_FLOAT mass = get_mass(MTag(), atom_i); - const KK_FLOAT gamma = 1.0 / std::sqrt(2.0 * kT / mass); - KK_FLOAT delta = gamma * flowvel; + const KK_FLOAT kT_kk = static_cast(kT); + const KK_FLOAT flowvel_kk = static_cast(flowvel); + const KK_FLOAT gamma = static_cast(1.0) / Kokkos::sqrt(static_cast(2.0) * kT_kk / mass); + KK_FLOAT delta = gamma * flowvel_kk; - const KK_FLOAT edd = std::exp(-delta * delta) / MathConst::MY_PIS + delta * std::erf(delta); - const KK_FLOAT probability_threshold = 0.5 * (1. + delta / edd); + const KK_FLOAT edd = Kokkos::exp(-delta * delta) / static_cast(MathConst::MY_PIS) + delta * Kokkos::erf(delta); + const KK_FLOAT probability_threshold = static_cast(0.5) * (static_cast(1.) + delta / edd); KK_FLOAT direction = 1.0; rand_type_t rand_gen = rand_pool.get_state(); - if (/*random->uniform()*/ rand_gen.drand() > probability_threshold) { + if (/*random->uniform()*/ static_cast(rand_gen.drand()) > probability_threshold) { delta = -delta; direction = -direction; } - const KK_FLOAT xi_0 = rand_gen.drand(); //random->uniform(); + const KK_FLOAT xi_0 = static_cast(rand_gen.drand()); //random->uniform(); const KK_FLOAT F_inf = edd + delta; const KK_FLOAT xi = xi_0 * F_inf; - const KK_FLOAT x_0 = (std::sqrt(delta * delta + 2) - delta) * 0.5; + const KK_FLOAT x_0 = (Kokkos::sqrt(delta * delta + 2) - delta) * static_cast(0.5); KK_FLOAT x = x_0; for (int i = 0; i < newton_iteration_count; ++i) { - x -= (std::exp(x * x) * MathConst::MY_PIS * (xi - delta * std::erfc(x)) - 1.0) / (x + delta) * - 0.5; + x -= (Kokkos::exp(x * x) * static_cast(MathConst::MY_PIS) * (xi - delta * Kokkos::erfc(x)) - static_cast(1.0)) / (x + delta) * + static_cast(0.5); } const KK_FLOAT nu = x + delta; @@ -152,9 +154,9 @@ KOKKOS_INLINE_FUNCTION void FixWallFlowKokkos::generate_velocity_kk( d_v(atom_i, flowax) = v * direction; d_v(atom_i, (flowax + 1) % 3) = - /*random->gaussian()*/ rand_gen.normal() / (gamma * MathConst::MY_SQRT2); + /*random->gaussian()*/ static_cast(rand_gen.normal()) / (gamma * static_cast(MathConst::MY_SQRT2)); d_v(atom_i, (flowax + 2) % 3) = - /*random->gaussian()*/ rand_gen.normal() / (gamma * MathConst::MY_SQRT2); + /*random->gaussian()*/ static_cast(rand_gen.normal()) / (gamma * static_cast(MathConst::MY_SQRT2)); rand_pool.free_state(rand_gen); } @@ -218,7 +220,7 @@ KOKKOS_INLINE_FUNCTION void FixWallFlowKokkos::operator()(TagFixWall { const int send_i = d_sendlist(mysend); const int segment = d_current_segment(send_i); - d_buf(mysend) = static_cast(segment); + d_buf(mysend) = static_cast(segment); const int copy_i = d_copylist(mysend); if (copy_i > -1) { d_current_segment(send_i) = d_current_segment(copy_i); } diff --git a/src/KOKKOS/fix_wall_gran_kokkos.cpp b/src/KOKKOS/fix_wall_gran_kokkos.cpp index d00d25c94a1..1508af0b6f2 100644 --- a/src/KOKKOS/fix_wall_gran_kokkos.cpp +++ b/src/KOKKOS/fix_wall_gran_kokkos.cpp @@ -78,17 +78,17 @@ void FixWallGranKokkos::post_force(int /*vflag*/) // set position of wall to initial settings and velocity to 0.0 // if wiggle or shear, set wall position and velocity accordingly - wlo = lo; - whi = hi; + wlo = static_cast(lo); + whi = static_cast(hi); vwall[0] = vwall[1] = vwall[2] = 0.0; if (wiggle) { double arg = omega * (update->ntimestep - time_origin) * dt; if (wallstyle == axis) { - wlo = lo + amplitude - amplitude*cos(arg); - whi = hi + amplitude - amplitude*cos(arg); + wlo = static_cast(lo + amplitude - amplitude*cos(arg)); + whi = static_cast(hi + amplitude - amplitude*cos(arg)); } - vwall[axis] = amplitude*omega*sin(arg); - } else if (wshear) vwall[axis] = vshear; + vwall[axis] = static_cast(amplitude*omega*sin(arg)); + } else if (wshear) vwall[axis] = static_cast(vshear); x = atomKK->k_x.view(); v = atomKK->k_v.view(); @@ -136,6 +136,15 @@ void FixWallGranKokkos::operator()(TagFixWallGranHookeHistory(cylradius); + const KK_FLOAT vshear_kk = static_cast(vshear); + const KK_FLOAT gamman_kk = static_cast(gamman); + const KK_FLOAT gammat_kk = static_cast(gammat); + const KK_FLOAT kn_kk = static_cast(kn); + const KK_FLOAT kt_kk = static_cast(kt); + const KK_FLOAT xmu_kk = static_cast(xmu); + const KK_FLOAT dt_kk = static_cast(dt); + if (mask[i] & groupbit) { KK_FLOAT radius = d_radius(i); @@ -159,16 +168,16 @@ void FixWallGranKokkos::operator()(TagFixWallGranHookeHistory radius) { - dz = cylradius; + dz = cylradius_kk; } else { dx = -delr/delxy * x(i,0); dy = -delr/delxy * x(i,1); if (wshear && axis != 2) { - vwall_[0] += vshear * x(i,1)/delxy; - vwall_[1] += -vshear * x(i,0)/delxy; + vwall_[0] += vshear_kk * x(i,1)/delxy; + vwall_[1] += -vshear_kk * x(i,0)/delxy; vwall_[2] = 0.0; } } @@ -183,9 +192,9 @@ void FixWallGranKokkos::operator()(TagFixWallGranHookeHistory(1.0)/r; + KK_FLOAT rsqinv = static_cast(1.0)/rsq; // relative translational velocity @@ -214,8 +223,8 @@ void FixWallGranKokkos::operator()(TagFixWallGranHookeHistory::operator()(TagFixWallGranHookeHistory::operator()(TagFixWallGranHookeHistory fn) { - if (shrmag != 0.0) { - d_history_one(i,0) = (fn/fs) * (d_history_one(i,0) + meff*gammat*vtr1/kt) - - meff*gammat*vtr1/kt; - d_history_one(i,1) = (fn/fs) * (d_history_one(i,1) + meff*gammat*vtr2/kt) - - meff*gammat*vtr2/kt; - d_history_one(i,2) = (fn/fs) * (d_history_one(i,2) + meff*gammat*vtr3/kt) - - meff*gammat*vtr3/kt; + if (shrmag != static_cast(0.0)) { + d_history_one(i,0) = (fn/fs) * (d_history_one(i,0) + meff*gammat_kk*vtr1/kt_kk) - + meff*gammat_kk*vtr1/kt_kk; + d_history_one(i,1) = (fn/fs) * (d_history_one(i,1) + meff*gammat_kk*vtr2/kt_kk) - + meff*gammat_kk*vtr2/kt_kk; + d_history_one(i,2) = (fn/fs) * (d_history_one(i,2) + meff*gammat_kk*vtr3/kt_kk) - + meff*gammat_kk*vtr3/kt_kk; fs1 *= fn/fs ; fs2 *= fn/fs; fs3 *= fn/fs; @@ -274,16 +283,16 @@ void FixWallGranKokkos::operator()(TagFixWallGranHookeHistory(fx); + f(i,1) += static_cast(fy); + f(i,2) += static_cast(fz); KK_FLOAT tor1 = rinv * (dy*fs3 - dz*fs2); KK_FLOAT tor2 = rinv * (dz*fs1 - dx*fs3); KK_FLOAT tor3 = rinv * (dx*fs2 - dy*fs1); - torque(i,0) -= radius*tor1; - torque(i,1) -= radius*tor2; - torque(i,2) -= radius*tor3; + torque(i,0) -= static_cast(radius*tor1); + torque(i,1) -= static_cast(radius*tor2); + torque(i,2) -= static_cast(radius*tor3); } } } @@ -361,7 +370,7 @@ void FixWallGranKokkos::operator()(TagFixWallGranPackExchange, const const int i = d_sendlist(mysend); int m = i*size_history; for (int v = 0; v < size_history; v++) - d_buf(m++) = d_history_one(i,v); + d_buf(m++) = static_cast(d_history_one(i,v)); const int j = d_copylist(mysend); if (j > -1) { @@ -412,7 +421,7 @@ void FixWallGranKokkos::operator()(TagFixWallGranUnpackExchange, con if (index > -1) { int m = i*size_history; for (int v = 0; v < size_history; v++) - d_history_one(i,v) = d_buf(m++); + d_history_one(i,v) = static_cast(d_buf(m++)); } } diff --git a/src/KOKKOS/fix_wall_harmonic_kokkos.cpp b/src/KOKKOS/fix_wall_harmonic_kokkos.cpp index cab561d836f..49b9dc299f5 100644 --- a/src/KOKKOS/fix_wall_harmonic_kokkos.cpp +++ b/src/KOKKOS/fix_wall_harmonic_kokkos.cpp @@ -82,7 +82,7 @@ template void FixWallHarmonicKokkos::wall_particle(int m_in, int which, double coord_in) { m = m_in; - coord = coord_in; + coord = static_cast(coord_in); atomKK->sync(execution_space, datamask_read); d_x = atomKK->k_x.template view(); @@ -126,13 +126,13 @@ void FixWallHarmonicKokkos::operator()(const int &i, value_type resu if (side < 0) delta = d_x(i,dim) - coord; else delta = coord - d_x(i,dim); if (delta >= (KK_FLOAT) cutoff[m]) return; - if (delta <= 0.0) + if (delta <= static_cast(0.0)) Kokkos::abort("Particle on or inside fix wall surface"); KK_FLOAT dr = (KK_FLOAT) cutoff[m] - delta; - KK_FLOAT fwall = (KK_FLOAT) side * 2.0 * (KK_FLOAT) epsilon[m] * dr; - d_f(i,dim) -= fwall; - result[0] += (KK_FLOAT) epsilon[m] * dr * dr; - result[m+1] += fwall; + KK_FLOAT fwall = (KK_FLOAT) side * static_cast(2.0) * (KK_FLOAT) epsilon[m] * dr; + d_f(i,dim) -= static_cast(fwall); + result[0] += static_cast((KK_FLOAT) epsilon[m] * dr * dr); + result[m+1] += static_cast(fwall); if (evflag) { KK_FLOAT vn; @@ -154,10 +154,10 @@ void FixWallHarmonicKokkos::v_tally(value_type result, int n, int i, KK_FLOAT vn) const { if (vflag_global) - result[n+7] += vn; + result[n+7] += static_cast(vn); if (vflag_atom) - Kokkos::atomic_add(&(d_vatom(i,n)), vn); + Kokkos::atomic_add(&(d_vatom(i,n)), static_cast(vn)); } namespace LAMMPS_NS { diff --git a/src/KOKKOS/fix_wall_lj1043_kokkos.cpp b/src/KOKKOS/fix_wall_lj1043_kokkos.cpp index 79a9d602481..ba2b5c34e4e 100644 --- a/src/KOKKOS/fix_wall_lj1043_kokkos.cpp +++ b/src/KOKKOS/fix_wall_lj1043_kokkos.cpp @@ -146,7 +146,7 @@ template void FixWallLJ1043Kokkos::wall_particle(int m_in, int which, double coord_in) { m = m_in; - coord = coord_in; + coord = static_cast(coord_in); atomKK->sync(execution_space, datamask_read); d_x = atomKK->k_x.template view(); @@ -189,25 +189,25 @@ void FixWallLJ1043Kokkos::operator()(const int &i, value_type result KK_FLOAT delta; if (side < 0) delta = d_x(i,dim) - coord; else delta = coord - d_x(i,dim); - if (delta <= 0.0) return; + if (delta <= static_cast(0.0)) return; if (delta > d_cutoff(m)) return; - KK_FLOAT rinv = 1.0/delta; + KK_FLOAT rinv = static_cast(1.0)/delta; KK_FLOAT r2inv = rinv*rinv; KK_FLOAT r4inv = r2inv*r2inv; KK_FLOAT r10inv = r4inv*r4inv*r2inv; // replace powint(delta+coeff4, -N) with explicit products for device KK_FLOAT dc4 = delta + d_coeff4(m); - KK_FLOAT dc4inv = 1.0/dc4; + KK_FLOAT dc4inv = static_cast(1.0)/dc4; KK_FLOAT dc4inv3 = dc4inv*dc4inv*dc4inv; KK_FLOAT dc4inv4 = dc4inv3*dc4inv; KK_FLOAT fwall = (KK_FLOAT) side * (d_coeff5(m)*r10inv*rinv - d_coeff6(m)*r4inv*rinv - d_coeff7(m)*dc4inv4); - d_f(i,dim) -= fwall; - result[0] += d_coeff1(m)*r10inv - d_coeff2(m)*r4inv - d_coeff3(m)*dc4inv3 - d_offset(m); - result[m+1] += fwall; + d_f(i,dim) -= static_cast(fwall); + result[0] += static_cast(d_coeff1(m)*r10inv - d_coeff2(m)*r4inv - d_coeff3(m)*dc4inv3 - d_offset(m)); + result[m+1] += static_cast(fwall); if (evflag) { KK_FLOAT vn; @@ -229,10 +229,10 @@ void FixWallLJ1043Kokkos::v_tally(value_type result, int n, int i, KK_FLOAT vn) const { if (vflag_global) - result[n+7] += vn; + result[n+7] += static_cast(vn); if (vflag_atom) - Kokkos::atomic_add(&(d_vatom(i,n)), vn); + Kokkos::atomic_add(&(d_vatom(i,n)), static_cast(vn)); } namespace LAMMPS_NS { diff --git a/src/KOKKOS/fix_wall_lj126_kokkos.cpp b/src/KOKKOS/fix_wall_lj126_kokkos.cpp index 8fc78a5fcae..1ced7256191 100644 --- a/src/KOKKOS/fix_wall_lj126_kokkos.cpp +++ b/src/KOKKOS/fix_wall_lj126_kokkos.cpp @@ -125,7 +125,7 @@ template void FixWallLJ126Kokkos::wall_particle(int m_in, int which, double coord_in) { m = m_in; - coord = coord_in; + coord = static_cast(coord_in); atomKK->sync(execution_space, datamask_read); d_x = atomKK->k_x.template view(); @@ -169,15 +169,15 @@ void FixWallLJ126Kokkos::operator()(const int &i, value_type result) if (side < 0) delta = d_x(i,dim) - coord; else delta = coord - d_x(i,dim); if (delta >= d_cutoff(m)) return; - if (delta <= 0.0) + if (delta <= static_cast(0.0)) Kokkos::abort("Particle on or inside fix wall surface"); - KK_FLOAT rinv = 1.0/delta; + KK_FLOAT rinv = static_cast(1.0)/delta; KK_FLOAT r2inv = rinv*rinv; KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT fwall = (KK_FLOAT) side * r6inv * (d_coeff1(m)*r6inv - d_coeff2(m)) * rinv; - d_f(i,dim) -= fwall; - result[0] += r6inv * (d_coeff3(m)*r6inv - d_coeff4(m)) - d_offset(m); - result[m+1] += fwall; + d_f(i,dim) -= static_cast(fwall); + result[0] += static_cast(r6inv * (d_coeff3(m)*r6inv - d_coeff4(m)) - d_offset(m)); + result[m+1] += static_cast(fwall); if (evflag) { KK_FLOAT vn; @@ -199,10 +199,10 @@ void FixWallLJ126Kokkos::v_tally(value_type result, int n, int i, KK_FLOAT vn) const { if (vflag_global) - result[n+7] += vn; + result[n+7] += static_cast(vn); if (vflag_atom) - Kokkos::atomic_add(&(d_vatom(i,n)), vn); + Kokkos::atomic_add(&(d_vatom(i,n)), static_cast(vn)); } namespace LAMMPS_NS { diff --git a/src/KOKKOS/fix_wall_lj93_kokkos.cpp b/src/KOKKOS/fix_wall_lj93_kokkos.cpp index d8719b16614..d63ebfc4caf 100644 --- a/src/KOKKOS/fix_wall_lj93_kokkos.cpp +++ b/src/KOKKOS/fix_wall_lj93_kokkos.cpp @@ -135,7 +135,7 @@ template void FixWallLJ93Kokkos::wall_particle(int m_in, int which, double coord_in) { m = m_in; - coord = coord_in; + coord = static_cast(coord_in); atomKK->sync(execution_space,datamask_read); d_x = atomKK->k_x.template view(); @@ -176,16 +176,16 @@ void FixWallLJ93Kokkos::operator()(const int &i, value_type result) if (side < 0) delta = d_x(i,dim) - coord; else delta = coord - d_x(i,dim); if (delta >= d_cutoff(m)) return; - if (delta <= 0.0) + if (delta <= static_cast(0.0)) Kokkos::abort("Particle on or inside fix wall surface"); - KK_FLOAT rinv = 1.0/delta; + KK_FLOAT rinv = static_cast(1.0)/delta; KK_FLOAT r2inv = rinv*rinv; KK_FLOAT r4inv = r2inv*r2inv; KK_FLOAT r10inv = r4inv*r4inv*r2inv; KK_FLOAT fwall = side * (d_coeff1(m)*r10inv - d_coeff2(m)*r4inv); - d_f(i,dim) -= fwall; - result[0] += d_coeff3(m)*r4inv*r4inv*rinv - d_coeff4(m)*r2inv*rinv - d_offset(m); - result[m+1] += fwall; + d_f(i,dim) -= static_cast(fwall); + result[0] += static_cast(d_coeff3(m)*r4inv*r4inv*rinv - d_coeff4(m)*r2inv*rinv - d_offset(m)); + result[m+1] += static_cast(fwall); if (evflag) { KK_FLOAT vn; @@ -216,10 +216,10 @@ KOKKOS_INLINE_FUNCTION void FixWallLJ93Kokkos::v_tally(value_type result, int n, int i, KK_FLOAT vn) const { if (vflag_global) - result[n+7] += vn; + result[n+7] += static_cast(vn); if (vflag_atom) - Kokkos::atomic_add(&(d_vatom(i,n)),vn); + Kokkos::atomic_add(&(d_vatom(i,n)),static_cast(vn)); } namespace LAMMPS_NS { diff --git a/src/KOKKOS/fix_wall_morse_kokkos.cpp b/src/KOKKOS/fix_wall_morse_kokkos.cpp index 8960d5a0948..1f547f381f0 100644 --- a/src/KOKKOS/fix_wall_morse_kokkos.cpp +++ b/src/KOKKOS/fix_wall_morse_kokkos.cpp @@ -127,7 +127,7 @@ template void FixWallMorseKokkos::wall_particle(int m_in, int which, double coord_in) { m = m_in; - coord = coord_in; + coord = static_cast(coord_in); atomKK->sync(execution_space, datamask_read); d_x = atomKK->k_x.template view(); @@ -171,14 +171,14 @@ void FixWallMorseKokkos::operator()(const int &i, value_type result) if (side < 0) delta = d_x(i,dim) - coord; else delta = coord - d_x(i,dim); if (delta >= d_cutoff(m)) return; - if (delta <= 0.0) + if (delta <= static_cast(0.0)) Kokkos::abort("Particle on or inside fix wall surface"); KK_FLOAT dr = delta - d_sigma(m); KK_FLOAT dexp = Kokkos::exp(-d_alpha(m) * dr); KK_FLOAT fwall = (KK_FLOAT) side * d_coeff1(m) * (dexp*dexp - dexp); - d_f(i,dim) -= fwall; - result[0] += d_epsilon(m) * (dexp*dexp - 2.0*dexp) - d_offset(m); - result[m+1] += fwall; + d_f(i,dim) -= static_cast(fwall); + result[0] += static_cast(d_epsilon(m) * (dexp*dexp - static_cast(2.0)*dexp) - d_offset(m)); + result[m+1] += static_cast(fwall); if (evflag) { KK_FLOAT vn; @@ -200,10 +200,10 @@ void FixWallMorseKokkos::v_tally(value_type result, int n, int i, KK_FLOAT vn) const { if (vflag_global) - result[n+7] += vn; + result[n+7] += static_cast(vn); if (vflag_atom) - Kokkos::atomic_add(&(d_vatom(i,n)), vn); + Kokkos::atomic_add(&(d_vatom(i,n)), static_cast(vn)); } namespace LAMMPS_NS { diff --git a/src/KOKKOS/fix_wall_reflect_kokkos.cpp b/src/KOKKOS/fix_wall_reflect_kokkos.cpp index fd2dece6e6f..e895bdd34ec 100644 --- a/src/KOKKOS/fix_wall_reflect_kokkos.cpp +++ b/src/KOKKOS/fix_wall_reflect_kokkos.cpp @@ -56,19 +56,23 @@ void FixWallReflectKokkos::post_integrate() if (varflag) modify->clearstep_compute(); + const KK_FLOAT xscale_kk = static_cast(xscale); + const KK_FLOAT yscale_kk = static_cast(yscale); + const KK_FLOAT zscale_kk = static_cast(zscale); + for (int m = 0; m < nwall; m++) { if (wallstyle[m] == VARIABLE) { - coord = input->variable->compute_equal(varindex[m]); - if (wallwhich[m] < FixWall::YLO) coord *= xscale; - else if (wallwhich[m] < FixWall::ZLO) coord *= yscale; - else coord *= zscale; - } else coord = coord0[m]; + coord = static_cast(input->variable->compute_equal(varindex[m])); + if (wallwhich[m] < FixWall::YLO) coord *= xscale_kk; + else if (wallwhich[m] < FixWall::ZLO) coord *= yscale_kk; + else coord *= zscale_kk; + } else coord = static_cast(coord0[m]); dim = wallwhich[m] / 2; side = wallwhich[m] % 2; // record wall graphics objects for dump image - FixWall::update_image_plane(m, wallwhich[m], coord, imgparms, domain); + FixWall::update_image_plane(m, wallwhich[m], static_cast(coord), imgparms, domain); copymode = 1; Kokkos::parallel_for(Kokkos::RangePolicy(0,nlocal),*this); diff --git a/src/KOKKOS/fix_wall_region_kokkos.cpp b/src/KOKKOS/fix_wall_region_kokkos.cpp index 870697af9a6..cc8d876d043 100644 --- a/src/KOKKOS/fix_wall_region_kokkos.cpp +++ b/src/KOKKOS/fix_wall_region_kokkos.cpp @@ -155,7 +155,7 @@ KOKKOS_INLINE_FUNCTION void FixWallRegionKokkos::wall_particle(T regionKK, const int i, value_type result) const { if (d_mask(i) & groupbit) { - if (!regionKK->match_kokkos(d_x(i,0), d_x(i,1), d_x(i,2))) Kokkos::abort("Particle outside surface of region used in fix wall/region"); + if (!regionKK->match_kokkos(static_cast(d_x(i,0)), static_cast(d_x(i,1)), static_cast(d_x(i,2)))) Kokkos::abort("Particle outside surface of region used in fix wall/region"); KK_FLOAT rinv, tooclose; @@ -164,19 +164,19 @@ void FixWallRegionKokkos::wall_particle(T regionKK, const int i, val else tooclose = 0.0; - int n = regionKK->surface_kokkos(d_x(i,0), d_x(i,1), d_x(i,2), cutoff); + int n = regionKK->surface_kokkos(static_cast(d_x(i,0)), static_cast(d_x(i,1)), static_cast(d_x(i,2)), cutoff); for ( int m = 0; m < n; m++) { - KK_FLOAT r = regionKK->d_contact[m].r; - KK_FLOAT delx = regionKK->d_contact[m].delx; - KK_FLOAT dely = regionKK->d_contact[m].dely; - KK_FLOAT delz = regionKK->d_contact[m].delz; + KK_FLOAT r = static_cast(regionKK->d_contact[m].r); + KK_FLOAT delx = static_cast(regionKK->d_contact[m].delx); + KK_FLOAT dely = static_cast(regionKK->d_contact[m].dely); + KK_FLOAT delz = static_cast(regionKK->d_contact[m].delz); if (r <= tooclose) Kokkos::abort("Particle outside surface of region used in fix wall/region"); else - rinv = 1.0 / r; + rinv = static_cast(1.0) / r; KK_FLOAT fwallKK, engKK; @@ -190,13 +190,13 @@ void FixWallRegionKokkos::wall_particle(T regionKK, const int i, val KK_FLOAT fx = fwallKK * delx * rinv; KK_FLOAT fy = fwallKK * dely * rinv; KK_FLOAT fz = fwallKK * delz * rinv; - d_f(i,0) += fx; - d_f(i,1) += fy; - d_f(i,2) += fz; - result[1] -= fx; - result[2] -= fy; - result[3] -= fz; - result[0] += engKK; + d_f(i,0) += static_cast(fx); + d_f(i,1) += static_cast(fy); + d_f(i,2) += static_cast(fz); + result[1] -= static_cast(fx); + result[2] -= static_cast(fy); + result[3] -= static_cast(fz); + result[0] += static_cast(engKK); if (evflag) { KK_FLOAT v[6] = { fx * delx, @@ -222,12 +222,17 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT FixWallRegionKokkos::lj93(KK_FLOAT r, KK_FLOAT& fwallKK) const { - KK_FLOAT rinv = 1.0 / r; + const KK_FLOAT coeff1_kk = static_cast(coeff1); + const KK_FLOAT coeff2_kk = static_cast(coeff2); + const KK_FLOAT coeff3_kk = static_cast(coeff3); + const KK_FLOAT coeff4_kk = static_cast(coeff4); + const KK_FLOAT offset_kk = static_cast(offset); + KK_FLOAT rinv = static_cast(1.0) / r; KK_FLOAT r2inv = rinv * rinv; KK_FLOAT r4inv = r2inv * r2inv; KK_FLOAT r10inv = r4inv * r4inv * r2inv; - fwallKK = coeff1 * r10inv - coeff2 * r4inv; - return coeff3 * r4inv * r4inv * rinv - coeff4 * r2inv * rinv - offset; + fwallKK = coeff1_kk * r10inv - coeff2_kk * r4inv; + return coeff3_kk * r4inv * r4inv * rinv - coeff4_kk * r2inv * rinv - offset_kk; } /* ---------------------------------------------------------------------- @@ -240,11 +245,16 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT FixWallRegionKokkos::lj126(KK_FLOAT r, KK_FLOAT& fwallKK) const { - KK_FLOAT rinv = 1.0 / r; + const KK_FLOAT coeff1_kk = static_cast(coeff1); + const KK_FLOAT coeff2_kk = static_cast(coeff2); + const KK_FLOAT coeff3_kk = static_cast(coeff3); + const KK_FLOAT coeff4_kk = static_cast(coeff4); + const KK_FLOAT offset_kk = static_cast(offset); + KK_FLOAT rinv = static_cast(1.0) / r; KK_FLOAT r2inv = rinv * rinv; KK_FLOAT r6inv = r2inv * r2inv * r2inv; - fwallKK = r6inv * (coeff1 * r6inv - coeff2) * rinv; - return r6inv * (coeff3 * r6inv - coeff4) - offset; + fwallKK = r6inv * (coeff1_kk * r6inv - coeff2_kk) * rinv; + return r6inv * (coeff3_kk * r6inv - coeff4_kk) - offset_kk; } /* ---------------------------------------------------------------------- @@ -257,12 +267,20 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT FixWallRegionKokkos::lj1043(KK_FLOAT r, KK_FLOAT& fwallKK) const { - KK_FLOAT rinv = 1.0 / r; + const KK_FLOAT coeff1_kk = static_cast(coeff1); + const KK_FLOAT coeff2_kk = static_cast(coeff2); + const KK_FLOAT coeff3_kk = static_cast(coeff3); + const KK_FLOAT coeff4_kk = static_cast(coeff4); + const KK_FLOAT coeff5_kk = static_cast(coeff5); + const KK_FLOAT coeff6_kk = static_cast(coeff6); + const KK_FLOAT coeff7_kk = static_cast(coeff7); + const KK_FLOAT offset_kk = static_cast(offset); + KK_FLOAT rinv = static_cast(1.0) / r; KK_FLOAT r2inv = rinv * rinv; KK_FLOAT r4inv = r2inv * r2inv; KK_FLOAT r10inv = r4inv * r4inv * r2inv; - fwallKK = coeff5 * r10inv * rinv - coeff6 * r4inv * rinv - coeff7 * powint(r + coeff4, -4); - return coeff1 * r10inv - coeff2 * r4inv - coeff3 * powint(r + coeff4, -3) - offset; + fwallKK = coeff5_kk * r10inv * rinv - coeff6_kk * r4inv * rinv - coeff7_kk * powint(r + coeff4_kk, -4); + return coeff1_kk * r10inv - coeff2_kk * r4inv - coeff3_kk * powint(r + coeff4_kk, -3) - offset_kk; } /* ---------------------------------------------------------------------- @@ -275,10 +293,15 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT FixWallRegionKokkos::morse(KK_FLOAT r, KK_FLOAT& fwallKK) const { - KK_FLOAT dr = r - sigma; - KK_FLOAT dexp = exp(-alpha * dr); - fwallKK = coeff1 * (dexp * dexp - dexp); - return epsilon * (dexp * dexp - 2.0 * dexp) - offset; + const KK_FLOAT sigma_kk = static_cast(sigma); + const KK_FLOAT alpha_kk = static_cast(alpha); + const KK_FLOAT coeff1_kk = static_cast(coeff1); + const KK_FLOAT epsilon_kk = static_cast(epsilon); + const KK_FLOAT offset_kk = static_cast(offset); + KK_FLOAT dr = r - sigma_kk; + KK_FLOAT dexp = Kokkos::exp(-alpha_kk * dr); + fwallKK = coeff1_kk * (dexp * dexp - dexp); + return epsilon_kk * (dexp * dexp - static_cast(2.0) * dexp) - offset_kk; } /* ---------------------------------------------------------------------- @@ -291,35 +314,40 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT FixWallRegionKokkos::colloid(KK_FLOAT r, KK_FLOAT rad, KK_FLOAT& fwallKK) const { - KK_FLOAT new_coeff2 = coeff2 * rad * rad * rad; - KK_FLOAT diam = 2.0 * rad; + const KK_FLOAT coeff1_kk = static_cast(coeff1); + const KK_FLOAT coeff2_kk = static_cast(coeff2); + const KK_FLOAT coeff3_kk = static_cast(coeff3); + const KK_FLOAT coeff4_kk = static_cast(coeff4); + const KK_FLOAT offset_kk = static_cast(offset); + KK_FLOAT new_coeff2 = coeff2_kk * rad * rad * rad; + KK_FLOAT diam = static_cast(2.0) * rad; KK_FLOAT rad2 = rad * rad; KK_FLOAT rad4 = rad2 * rad2; KK_FLOAT rad8 = rad4 * rad4; KK_FLOAT delta2 = rad2 - r * r; - KK_FLOAT rinv = 1.0 / delta2; + KK_FLOAT rinv = static_cast(1.0) / delta2; KK_FLOAT r2inv = rinv * rinv; KK_FLOAT r4inv = r2inv * r2inv; KK_FLOAT r8inv = r4inv * r4inv; - fwallKK = coeff1 * - (rad8 * rad + 27.0 * rad4 * rad2 * rad * r * r + 63.0 * rad4 * rad * powint(r, 4) + - 21.0 * rad2 * rad * powint(r, 6)) * + fwallKK = coeff1_kk * + (rad8 * rad + static_cast(27.0) * rad4 * rad2 * rad * r * r + static_cast(63.0) * rad4 * rad * powint(r, 4) + + static_cast(21.0) * rad2 * rad * powint(r, 6)) * r8inv - new_coeff2 * r2inv; - KK_FLOAT r2 = 0.5 * diam - r; - KK_FLOAT rinv2 = 1.0 / r2; + KK_FLOAT r2 = static_cast(0.5) * diam - r; + KK_FLOAT rinv2 = static_cast(1.0) / r2; KK_FLOAT r2inv2 = rinv2 * rinv2; KK_FLOAT r4inv2 = r2inv2 * r2inv2; - KK_FLOAT r3 = r + 0.5 * diam; - KK_FLOAT rinv3 = 1.0 / r3; + KK_FLOAT r3 = r + static_cast(0.5) * diam; + KK_FLOAT rinv3 = static_cast(1.0) / r3; KK_FLOAT r2inv3 = rinv3 * rinv3; KK_FLOAT r4inv3 = r2inv3 * r2inv3; - return coeff3 * - ((-3.5 * diam + r) * r4inv2 * r2inv2 * rinv2 + - (3.5 * diam + r) * r4inv3 * r2inv3 * rinv3) - - coeff4 * ((-diam * r + r2 * r3 * (log(-r2) - log(r3))) * (-rinv2) * rinv3) - offset; + return coeff3_kk * + ((static_cast(-3.5) * diam + r) * r4inv2 * r2inv2 * rinv2 + + (static_cast(3.5) * diam + r) * r4inv3 * r2inv3 * rinv3) - + coeff4_kk * ((-diam * r + r2 * r3 * (Kokkos::log(-r2) - Kokkos::log(r3))) * (-rinv2) * rinv3) - offset_kk; } /* ---------------------------------------------------------------------- @@ -332,9 +360,11 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT FixWallRegionKokkos::harmonic(KK_FLOAT r, KK_FLOAT& fwallKK) const { - KK_FLOAT dr = cutoff - r; - fwallKK = 2.0 * epsilon * dr; - return epsilon * dr * dr; + const KK_FLOAT cutoff_kk = static_cast(cutoff); + const KK_FLOAT epsilon_kk = static_cast(epsilon); + KK_FLOAT dr = cutoff_kk - r; + fwallKK = static_cast(2.0) * epsilon_kk * dr; + return epsilon_kk * dr * dr; } /* ---------------------------------------------------------------------- @@ -354,21 +384,21 @@ KOKKOS_INLINE_FUNCTION void FixWallRegionKokkos::v_tally(value_type result, int i, KK_FLOAT *v) const { if (vflag_global) { - result[4] += v[0]; - result[5] += v[1]; - result[6] += v[2]; - result[7] += v[3]; - result[8] += v[4]; - result[9] += v[5]; + result[4] += static_cast(v[0]); + result[5] += static_cast(v[1]); + result[6] += static_cast(v[2]); + result[7] += static_cast(v[3]); + result[8] += static_cast(v[4]); + result[9] += static_cast(v[5]); } if (vflag_atom) { - Kokkos::atomic_add(&(d_vatom(i,0)),v[0]); - Kokkos::atomic_add(&(d_vatom(i,1)),v[1]); - Kokkos::atomic_add(&(d_vatom(i,2)),v[2]); - Kokkos::atomic_add(&(d_vatom(i,3)),v[3]); - Kokkos::atomic_add(&(d_vatom(i,4)),v[4]); - Kokkos::atomic_add(&(d_vatom(i,5)),v[5]); + Kokkos::atomic_add(&(d_vatom(i,0)),static_cast(v[0])); + Kokkos::atomic_add(&(d_vatom(i,1)),static_cast(v[1])); + Kokkos::atomic_add(&(d_vatom(i,2)),static_cast(v[2])); + Kokkos::atomic_add(&(d_vatom(i,3)),static_cast(v[3])); + Kokkos::atomic_add(&(d_vatom(i,4)),static_cast(v[4])); + Kokkos::atomic_add(&(d_vatom(i,5)),static_cast(v[5])); } } diff --git a/src/KOKKOS/group_kokkos.h b/src/KOKKOS/group_kokkos.h index 75c0601357f..a764098c04e 100644 --- a/src/KOKKOS/group_kokkos.h +++ b/src/KOKKOS/group_kokkos.h @@ -53,7 +53,7 @@ double mass_kk(int igroup) atomKK->sync(execution_space,MASK_MASK|RMASS_MASK); Kokkos::parallel_reduce(Kokkos::RangePolicy(0,atom->nlocal), KOKKOS_LAMBDA(const int i, double &l_one) { - if (d_mask(i) & groupbit) l_one += d_rmass(i); + if (d_mask(i) & groupbit) l_one += static_cast(d_rmass(i)); }, one); } else { @@ -64,7 +64,7 @@ double mass_kk(int igroup) atomKK->k_mass.template sync(); Kokkos::parallel_reduce(Kokkos::RangePolicy(0,atom->nlocal), KOKKOS_LAMBDA(const int i, double &l_one) { - if (d_mask(i) & groupbit) l_one += d_mass(d_type(i)); + if (d_mask(i) & groupbit) l_one += static_cast(d_mass(d_type(i))); }, one); } @@ -102,11 +102,11 @@ void xcm_kk(int igroup, double masstotal, double *xcm) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,atom->nlocal), KOKKOS_LAMBDA(const int i, double &l_cmx, double &l_cmy, double &l_cmz) { if (d_mask(i) & groupbit) { - double massone = d_rmass(i); + double massone = static_cast(d_rmass(i)); Few x_i; - x_i[0] = d_x(i,0); - x_i[1] = d_x(i,1); - x_i[2] = d_x(i,2); + x_i[0] = static_cast(d_x(i,0)); + x_i[1] = static_cast(d_x(i,1)); + x_i[2] = static_cast(d_x(i,2)); auto unwrapKK = DomainKokkos::unmap(l_prd,l_h,l_triclinic,x_i,d_image(i)); l_cmx += unwrapKK[0] * massone; l_cmy += unwrapKK[1] * massone; @@ -123,11 +123,11 @@ void xcm_kk(int igroup, double masstotal, double *xcm) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,atom->nlocal), KOKKOS_LAMBDA(const int i, double &l_cmx, double &l_cmy, double &l_cmz) { if (d_mask(i) & groupbit) { - double massone = d_mass(d_type(i)); + double massone = static_cast(d_mass(d_type(i))); Few x_i; - x_i[0] = d_x(i,0); - x_i[1] = d_x(i,1); - x_i[2] = d_x(i,2); + x_i[0] = static_cast(d_x(i,0)); + x_i[1] = static_cast(d_x(i,1)); + x_i[2] = static_cast(d_x(i,2)); auto unwrapKK = DomainKokkos::unmap(l_prd,l_h,l_triclinic,x_i,d_image(i)); l_cmx += unwrapKK[0] * massone; l_cmy += unwrapKK[1] * massone; @@ -169,10 +169,10 @@ void vcm_kk(int igroup, double masstotal, double *vcm) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,atom->nlocal), KOKKOS_LAMBDA(const int i, double &l_px, double &l_py, double &l_pz) { if (d_mask(i) & groupbit) { - double massone = d_rmass(i); - l_px += d_v(i,0) * massone; - l_py += d_v(i,1) * massone; - l_pz += d_v(i,2) * massone; + KK_FLOAT massone = d_rmass(i); + l_px += static_cast(d_v(i,0) * massone); + l_py += static_cast(d_v(i,1) * massone); + l_pz += static_cast(d_v(i,2) * massone); } }, p[0], p[1], p[2]); @@ -185,10 +185,10 @@ void vcm_kk(int igroup, double masstotal, double *vcm) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,atom->nlocal), KOKKOS_LAMBDA(const int i, double &l_px, double &l_py, double &l_pz) { if (d_mask(i) & groupbit) { - double massone = d_mass(d_type(i)); - l_px += d_v(i,0) * massone; - l_py += d_v(i,1) * massone; - l_pz += d_v(i,2) * massone; + KK_FLOAT massone = d_mass(d_type(i)); + l_px += static_cast(d_v(i,0) * massone); + l_py += static_cast(d_v(i,1) * massone); + l_pz += static_cast(d_v(i,2) * massone); } }, p[0], p[1], p[2]); @@ -233,18 +233,18 @@ void angmom_kk(int igroup, double *xcm, double *lmom) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,atom->nlocal), KOKKOS_LAMBDA(const int i, double &l_px, double &l_py, double &l_pz) { if (d_mask(i) & groupbit) { - double massone = d_rmass(i); + double massone = static_cast(d_rmass(i)); Few x_i; - x_i[0] = d_x(i,0); - x_i[1] = d_x(i,1); - x_i[2] = d_x(i,2); + x_i[0] = static_cast(d_x(i,0)); + x_i[1] = static_cast(d_x(i,1)); + x_i[2] = static_cast(d_x(i,2)); auto unwrapKK = DomainKokkos::unmap(l_prd,l_h,l_triclinic,x_i,d_image(i)); double dx = unwrapKK[0] - l_xcm0; double dy = unwrapKK[1] - l_xcm1; double dz = unwrapKK[2] - l_xcm2; - l_px += massone * (dy * d_v(i,2) - dz * d_v(i,1)); - l_py += massone * (dz * d_v(i,0) - dx * d_v(i,2)); - l_pz += massone * (dx * d_v(i,1) - dy * d_v(i,0)); + l_px += massone * (dy * static_cast(d_v(i,2)) - dz * static_cast(d_v(i,1))); + l_py += massone * (dz * static_cast(d_v(i,0)) - dx * static_cast(d_v(i,2))); + l_pz += massone * (dx * static_cast(d_v(i,1)) - dy * static_cast(d_v(i,0))); } }, p[0], p[1], p[2]); @@ -257,18 +257,18 @@ void angmom_kk(int igroup, double *xcm, double *lmom) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,atom->nlocal), KOKKOS_LAMBDA(const int i, double &l_px, double &l_py, double &l_pz) { if (d_mask(i) & groupbit) { - double massone = d_mass(d_type(i)); + double massone = static_cast(d_mass(d_type(i))); Few x_i; - x_i[0] = d_x(i,0); - x_i[1] = d_x(i,1); - x_i[2] = d_x(i,2); + x_i[0] = static_cast(d_x(i,0)); + x_i[1] = static_cast(d_x(i,1)); + x_i[2] = static_cast(d_x(i,2)); auto unwrapKK = DomainKokkos::unmap(l_prd,l_h,l_triclinic,x_i,d_image(i)); double dx = unwrapKK[0] - l_xcm0; double dy = unwrapKK[1] - l_xcm1; double dz = unwrapKK[2] - l_xcm2; - l_px += massone * (dy * d_v(i,2) - dz * d_v(i,1)); - l_py += massone * (dz * d_v(i,0) - dx * d_v(i,2)); - l_pz += massone * (dx * d_v(i,1) - dy * d_v(i,0)); + l_px += massone * (dy * static_cast(d_v(i,2)) - dz * static_cast(d_v(i,1))); + l_py += massone * (dz * static_cast(d_v(i,0)) - dx * static_cast(d_v(i,2))); + l_pz += massone * (dx * static_cast(d_v(i,1)) - dy * static_cast(d_v(i,0))); } }, p[0], p[1], p[2]); @@ -308,11 +308,11 @@ void inertia_kk(int igroup, double *xcm, double itensor[3][3]) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,atom->nlocal), KOKKOS_LAMBDA(const int i, double &l_i00, double &l_i11, double &l_i22, double &l_i01, double &l_i12, double &l_i02) { if (d_mask(i) & groupbit) { - double massone = d_rmass(i); + double massone = static_cast(d_rmass(i)); Few x_i; - x_i[0] = d_x(i,0); - x_i[1] = d_x(i,1); - x_i[2] = d_x(i,2); + x_i[0] = static_cast(d_x(i,0)); + x_i[1] = static_cast(d_x(i,1)); + x_i[2] = static_cast(d_x(i,2)); auto unwrapKK = DomainKokkos::unmap(l_prd,l_h,l_triclinic,x_i,d_image(i)); double dx = unwrapKK[0] - l_xcm0; double dy = unwrapKK[1] - l_xcm1; @@ -335,11 +335,11 @@ void inertia_kk(int igroup, double *xcm, double itensor[3][3]) Kokkos::parallel_reduce(Kokkos::RangePolicy(0,atom->nlocal), KOKKOS_LAMBDA(const int i, double &l_i00, double &l_i11, double &l_i22, double &l_i01, double &l_i12, double &l_i02) { if (d_mask(i) & groupbit) { - double massone = d_mass(d_type(i)); + double massone = static_cast(d_mass(d_type(i))); Few x_i; - x_i[0] = d_x(i,0); - x_i[1] = d_x(i,1); - x_i[2] = d_x(i,2); + x_i[0] = static_cast(d_x(i,0)); + x_i[1] = static_cast(d_x(i,1)); + x_i[2] = static_cast(d_x(i,2)); auto unwrapKK = DomainKokkos::unmap(l_prd,l_h,l_triclinic,x_i,d_image(i)); double dx = unwrapKK[0] - l_xcm0; double dy = unwrapKK[1] - l_xcm1; diff --git a/src/KOKKOS/improper_class2_kokkos.cpp b/src/KOKKOS/improper_class2_kokkos.cpp index b3139d67c48..c41e57b8ccf 100644 --- a/src/KOKKOS/improper_class2_kokkos.cpp +++ b/src/KOKKOS/improper_class2_kokkos.cpp @@ -131,15 +131,15 @@ void ImproperClass2Kokkos::compute(int eflag_in, int vflag_in) Kokkos::parallel_for(Kokkos::RangePolicy >(0,nimproperlist),*this); } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } // error check @@ -164,15 +164,15 @@ void ImproperClass2Kokkos::compute(int eflag_in, int vflag_in) Kokkos::parallel_for(Kokkos::RangePolicy >(0,nimproperlist),*this); } } - if (eflag_global) energy += ev.evdwl; + if (eflag_global) energy += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -227,7 +227,7 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2Compute(0.0)) { for (i = 0; i < 3; i++) for (j = 0; j < 4; j++) @@ -256,8 +256,8 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2Compute(1.0)/rmag[i]; } // angle ABC, CBD, ABD @@ -271,16 +271,16 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2Compute(1.0) || costheta[1] == -static_cast(1.0) || costheta[2] == -static_cast(1.0)) && !d_warning_flag()) d_warning_flag() = 1; for (i = 0; i < 3; i++) { - if (costheta[i] > 1.0) costheta[i] = 1.0; - if (costheta[i] < -1.0) costheta[i] = -1.0; - theta[i] = acos(costheta[i]); + if (costheta[i] > static_cast(1.0)) costheta[i] = 1.0; + if (costheta[i] < -static_cast(1.0)) costheta[i] = -1.0; + theta[i] = Kokkos::acos(costheta[i]); cossqtheta[i] = costheta[i]*costheta[i]; - sintheta[i] = sin(theta[i]); - invstheta[i] = 1.0/sintheta[i]; + sintheta[i] = Kokkos::sin(theta[i]); + invstheta[i] = static_cast(1.0)/sintheta[i]; sinsqtheta[i] = sintheta[i]*sintheta[i]; } @@ -311,7 +311,7 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2Compute(1.0)/t; invs3r[0] = invstheta[1] * inv3r; invs3r[1] = invstheta[2] * inv3r; invs3r[2] = invstheta[0] * inv3r; @@ -319,13 +319,13 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2Compute(3.0); deltachi = chi - d_chi0[type]; d2chi = deltachi * deltachi; @@ -368,7 +368,7 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2Compute(1.0) / Kokkos::sqrt(static_cast(1.0) - cossqtheta[0]); dthetadr[0][0][0] = sc1 * ((tt1 * delr[0][0]) - (delr[1][0] * rinvmag[0] * rinvmag[1])); @@ -400,7 +400,7 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2Compute(1.0) / Kokkos::sqrt(static_cast(1.0) - cossqtheta[1]); dthetadr[1][2][0] = sc1 * ((tt1 * delr[1][0]) - (delr[2][0] * rinvmag[1] * rinvmag[2])); @@ -431,7 +431,7 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2Compute(1.0) / Kokkos::sqrt(static_cast(1.0) - cossqtheta[2]); dthetadr[2][0][0] = sc1 * ((tt1 * delr[0][0]) - (delr[2][0] * rinvmag[0] * rinvmag[2])); @@ -572,17 +572,17 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2Compute(3.0); } for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) - fabcd[i][j] = -2.0*d_k0[type] * deltachi*dtotalchi[i][j]; + fabcd[i][j] = -static_cast(2.0)*d_k0[type] * deltachi*dtotalchi[i][j]; // apply force to each of 4 atoms @@ -596,27 +596,27 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2Compute(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -666,7 +666,7 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2AngleAngle(0.0)) || (d_aa_k2[type] != static_cast(0.0)) || (d_aa_k3[type] != static_cast(0.0))) { // difference vectors @@ -685,28 +685,28 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2AngleAngle 1.0) costhABC = 1.0; - if (costhABC < -1.0) costhABC = -1.0; - thetaABC = acos(costhABC); + if (costhABC > static_cast(1.0)) costhABC = 1.0; + if (costhABC < -static_cast(1.0)) costhABC = -1.0; + thetaABC = Kokkos::acos(costhABC); costhABD = (delxAB*delxBD + delyAB*delyBD + delzAB*delzBD) / (rAB * rBD); - if (costhABD > 1.0) costhABD = 1.0; - if (costhABD < -1.0) costhABD = -1.0; - thetaABD = acos(costhABD); + if (costhABD > static_cast(1.0)) costhABD = 1.0; + if (costhABD < -static_cast(1.0)) costhABD = -1.0; + thetaABD = Kokkos::acos(costhABD); costhCBD = (delxBC*delxBD + delyBC*delyBD + delzBC*delzBD) /(rBC * rBD); - if (costhCBD > 1.0) costhCBD = 1.0; - if (costhCBD < -1.0) costhCBD = -1.0; - thetaCBD = acos(costhCBD); + if (costhCBD > static_cast(1.0)) costhCBD = 1.0; + if (costhCBD < -static_cast(1.0)) costhCBD = -1.0; + thetaCBD = Kokkos::acos(costhCBD); dthABC = thetaABC - d_aa_theta0_1[type]; dthABD = thetaABD - d_aa_theta0_2[type]; @@ -727,10 +727,10 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2AngleAngle(1.0)/(static_cast(1.0) - costhABC*costhABC)); t1 = costhABC / rABmag2; t3 = costhABC / rBCmag2; - r12 = 1.0 / (rAB * rBC); + r12 = static_cast(1.0) / (rAB * rBC); dthetadr[0][0][0] = sc1 * ((t1 * delxAB) - (delxBC * r12)); dthetadr[0][0][1] = sc1 * ((t1 * delyAB) - (delyBC * r12)); @@ -747,10 +747,10 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2AngleAngle(1.0)/(static_cast(1.0) - costhCBD*costhCBD)); t1 = costhCBD / rBCmag2; t3 = costhCBD / rBDmag2; - r12 = 1.0 / (rBC * rBD); + r12 = static_cast(1.0) / (rBC * rBD); dthetadr[1][2][0] = sc1 * ((t1 * delxBC) - (delxBD * r12)); dthetadr[1][2][1] = sc1 * ((t1 * delyBC) - (delyBD * r12)); @@ -767,10 +767,10 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2AngleAngle(1.0)/(static_cast(1.0) - costhABD*costhABD)); t1 = costhABD / rABmag2; t3 = costhABD / rBDmag2; - r12 = 1.0 / (rAB * rBD); + r12 = static_cast(1.0) / (rAB * rBD); dthetadr[2][0][0] = sc1 * ((t1 * delxAB) - (delxBD * r12)); dthetadr[2][0][1] = sc1 * ((t1 * delyAB) - (delyBD * r12)); @@ -806,27 +806,27 @@ void ImproperClass2Kokkos::operator()(TagImproperClass2AngleAngle(f1[0]); + a_f(i1,1) += static_cast(f1[1]); + a_f(i1,2) += static_cast(f1[2]); } if (NEWTON_BOND || i2 < nlocal) { - a_f(i2,0) += f2[0]; - a_f(i2,1) += f2[1]; - a_f(i2,2) += f2[2]; + a_f(i2,0) += static_cast(f2[0]); + a_f(i2,1) += static_cast(f2[1]); + a_f(i2,2) += static_cast(f2[2]); } if (NEWTON_BOND || i3 < nlocal) { - a_f(i3,0) += f3[0]; - a_f(i3,1) += f3[1]; - a_f(i3,2) += f3[2]; + a_f(i3,0) += static_cast(f3[0]); + a_f(i3,1) += static_cast(f3[1]); + a_f(i3,2) += static_cast(f3[2]); } if (NEWTON_BOND || i4 < nlocal) { - a_f(i4,0) += f4[0]; - a_f(i4,1) += f4[1]; - a_f(i4,2) += f4[2]; + a_f(i4,0) += static_cast(f4[0]); + a_f(i4,1) += static_cast(f4[1]); + a_f(i4,2) += static_cast(f4[2]); } if (EVFLAG) @@ -897,14 +897,14 @@ void ImproperClass2Kokkos::coeff(int narg, char **arg) utils::bounds(FLERR,arg[0],1,atom->nimpropertypes,ilo,ihi,error); for (int i = ilo; i <= ihi; i++) { - k_k0.view_host()[i] = k0[i]; - k_chi0.view_host()[i] = chi0[i]; - k_aa_k1.view_host()[i] = aa_k1[i]; - k_aa_k2.view_host()[i] = aa_k2[i]; - k_aa_k3.view_host()[i] = aa_k3[i]; - k_aa_theta0_1.view_host()[i] = aa_theta0_1[i]; - k_aa_theta0_2.view_host()[i] = aa_theta0_2[i]; - k_aa_theta0_3.view_host()[i] = aa_theta0_3[i]; + k_k0.view_host()[i] = static_cast(k0[i]); + k_chi0.view_host()[i] = static_cast(chi0[i]); + k_aa_k1.view_host()[i] = static_cast(aa_k1[i]); + k_aa_k2.view_host()[i] = static_cast(aa_k2[i]); + k_aa_k3.view_host()[i] = static_cast(aa_k3[i]); + k_aa_theta0_1.view_host()[i] = static_cast(aa_theta0_1[i]); + k_aa_theta0_2.view_host()[i] = static_cast(aa_theta0_2[i]); + k_aa_theta0_3.view_host()[i] = static_cast(aa_theta0_3[i]); k_setflag.view_host()[i] = setflag[i]; k_setflag_i.view_host()[i] = setflag_i[i]; k_setflag_aa.view_host()[i] = setflag_aa[i]; @@ -958,14 +958,14 @@ void ImproperClass2Kokkos::read_restart(FILE *fp) d_setflag_aa = k_setflag_aa.template view(); for (int i = 1; i <= n; i++) { - k_k0.view_host()[i] = k0[i]; - k_chi0.view_host()[i] = chi0[i]; - k_aa_k1.view_host()[i] = aa_k1[i]; - k_aa_k2.view_host()[i] = aa_k2[i]; - k_aa_k3.view_host()[i] = aa_k3[i]; - k_aa_theta0_1.view_host()[i] = aa_theta0_1[i]; - k_aa_theta0_2.view_host()[i] = aa_theta0_2[i]; - k_aa_theta0_3.view_host()[i] = aa_theta0_3[i]; + k_k0.view_host()[i] = static_cast(k0[i]); + k_chi0.view_host()[i] = static_cast(chi0[i]); + k_aa_k1.view_host()[i] = static_cast(aa_k1[i]); + k_aa_k2.view_host()[i] = static_cast(aa_k2[i]); + k_aa_k3.view_host()[i] = static_cast(aa_k3[i]); + k_aa_theta0_1.view_host()[i] = static_cast(aa_theta0_1[i]); + k_aa_theta0_2.view_host()[i] = static_cast(aa_theta0_2[i]); + k_aa_theta0_3.view_host()[i] = static_cast(aa_theta0_3[i]); k_setflag.view_host()[i] = setflag[i]; k_setflag_i.view_host()[i] = setflag_i[i]; k_setflag_aa.view_host()[i] = setflag_aa[i]; @@ -1010,21 +1010,21 @@ void ImproperClass2Kokkos::ev_tally(EV_FLOAT &ev, const int i1, cons if (eflag_either) { if (eflag_global) { - if (newton_bond) ev.evdwl += eimproper; + if (newton_bond) ev.evdwl += static_cast(eimproper); else { - eimproperquarter = 0.25*eimproper; - if (i1 < nlocal) ev.evdwl += eimproperquarter; - if (i2 < nlocal) ev.evdwl += eimproperquarter; - if (i3 < nlocal) ev.evdwl += eimproperquarter; - if (i4 < nlocal) ev.evdwl += eimproperquarter; + eimproperquarter = static_cast(0.25)*eimproper; + if (i1 < nlocal) ev.evdwl += static_cast(eimproperquarter); + if (i2 < nlocal) ev.evdwl += static_cast(eimproperquarter); + if (i3 < nlocal) ev.evdwl += static_cast(eimproperquarter); + if (i4 < nlocal) ev.evdwl += static_cast(eimproperquarter); } } if (eflag_atom) { - eimproperquarter = 0.25*eimproper; - if (newton_bond || i1 < nlocal) v_eatom[i1] += eimproperquarter; - if (newton_bond || i2 < nlocal) v_eatom[i2] += eimproperquarter; - if (newton_bond || i3 < nlocal) v_eatom[i3] += eimproperquarter; - if (newton_bond || i4 < nlocal) v_eatom[i4] += eimproperquarter; + eimproperquarter = static_cast(0.25)*eimproper; + if (newton_bond || i1 < nlocal) v_eatom[i1] += static_cast(eimproperquarter); + if (newton_bond || i2 < nlocal) v_eatom[i2] += static_cast(eimproperquarter); + if (newton_bond || i3 < nlocal) v_eatom[i3] += static_cast(eimproperquarter); + if (newton_bond || i4 < nlocal) v_eatom[i4] += static_cast(eimproperquarter); } } @@ -1038,80 +1038,80 @@ void ImproperClass2Kokkos::ev_tally(EV_FLOAT &ev, const int i1, cons if (vflag_global) { if (newton_bond) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } else { if (i1 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i2 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i3 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } if (i4 < nlocal) { - ev.v[0] += 0.25*v[0]; - ev.v[1] += 0.25*v[1]; - ev.v[2] += 0.25*v[2]; - ev.v[3] += 0.25*v[3]; - ev.v[4] += 0.25*v[4]; - ev.v[5] += 0.25*v[5]; + ev.v[0] += static_cast(0.25)*static_cast(v[0]); + ev.v[1] += static_cast(0.25)*static_cast(v[1]); + ev.v[2] += static_cast(0.25)*static_cast(v[2]); + ev.v[3] += static_cast(0.25)*static_cast(v[3]); + ev.v[4] += static_cast(0.25)*static_cast(v[4]); + ev.v[5] += static_cast(0.25)*static_cast(v[5]); } } } if (vflag_atom) { if (newton_bond || i1 < nlocal) { - v_vatom(i1,0) += 0.25*v[0]; - v_vatom(i1,1) += 0.25*v[1]; - v_vatom(i1,2) += 0.25*v[2]; - v_vatom(i1,3) += 0.25*v[3]; - v_vatom(i1,4) += 0.25*v[4]; - v_vatom(i1,5) += 0.25*v[5]; + v_vatom(i1,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i1,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i1,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i1,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i1,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i1,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i2 < nlocal) { - v_vatom(i2,0) += 0.25*v[0]; - v_vatom(i2,1) += 0.25*v[1]; - v_vatom(i2,2) += 0.25*v[2]; - v_vatom(i2,3) += 0.25*v[3]; - v_vatom(i2,4) += 0.25*v[4]; - v_vatom(i2,5) += 0.25*v[5]; + v_vatom(i2,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i2,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i2,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i2,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i2,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i2,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i3 < nlocal) { - v_vatom(i3,0) += 0.25*v[0]; - v_vatom(i3,1) += 0.25*v[1]; - v_vatom(i3,2) += 0.25*v[2]; - v_vatom(i3,3) += 0.25*v[3]; - v_vatom(i3,4) += 0.25*v[4]; - v_vatom(i3,5) += 0.25*v[5]; + v_vatom(i3,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i3,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i3,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i3,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i3,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i3,5) += static_cast(0.25)*static_cast(v[5]); } if (newton_bond || i4 < nlocal) { - v_vatom(i4,0) += 0.25*v[0]; - v_vatom(i4,1) += 0.25*v[1]; - v_vatom(i4,2) += 0.25*v[2]; - v_vatom(i4,3) += 0.25*v[3]; - v_vatom(i4,4) += 0.25*v[4]; - v_vatom(i4,5) += 0.25*v[5]; + v_vatom(i4,0) += static_cast(0.25)*static_cast(v[0]); + v_vatom(i4,1) += static_cast(0.25)*static_cast(v[1]); + v_vatom(i4,2) += static_cast(0.25)*static_cast(v[2]); + v_vatom(i4,3) += static_cast(0.25)*static_cast(v[3]); + v_vatom(i4,4) += static_cast(0.25)*static_cast(v[4]); + v_vatom(i4,5) += static_cast(0.25)*static_cast(v[5]); } } } diff --git a/src/KOKKOS/improper_cossq_kokkos.cpp b/src/KOKKOS/improper_cossq_kokkos.cpp index 17e0f155d9d..f633eb69d33 100644 --- a/src/KOKKOS/improper_cossq_kokkos.cpp +++ b/src/KOKKOS/improper_cossq_kokkos.cpp @@ -166,7 +166,7 @@ void ImproperCossqKokkos::operator()(TagImproperCossqCompute::operator()(TagImproperCossqCompute::operator()(TagImproperCossqCompute static_cast(1.0)) cosphi -= static_cast(SMALL); if (cosphi < static_cast(-1.0)) cosphi += static_cast(SMALL); - const KK_FLOAT torangle = acos(cosphi); - cosphi = cos(torangle - d_chi[type]); + const KK_FLOAT torangle = Kokkos::acos(cosphi); + cosphi = Kokkos::cos(torangle - d_chi[type]); KK_FLOAT eimproper = static_cast(0.0); if (EVFLAG && eflag) eimproper = static_cast(0.5) * d_k[type] * cosphi * cosphi; @@ -200,7 +200,7 @@ void ImproperCossqKokkos::operator()(TagImproperCossqCompute::operator()(TagImproperCvffCompute(1.0) / (vb2x * vb2x + vb2y * vb2y + vb2z * vb2z); const KK_FLOAT sb3 = static_cast(1.0) / (vb3x * vb3x + vb3y * vb3y + vb3z * vb3z); - const KK_FLOAT rb1 = sqrt(sb1); - const KK_FLOAT rb3 = sqrt(sb3); + const KK_FLOAT rb1 = Kokkos::sqrt(sb1); + const KK_FLOAT rb3 = Kokkos::sqrt(sb3); const KK_FLOAT c0 = (vb1x * vb3x + vb1y * vb3y + vb1z * vb3z) * rb1 * rb3; // 1st and 2nd angle const KK_FLOAT b1mag2 = vb1x * vb1x + vb1y * vb1y + vb1z * vb1z; - const KK_FLOAT b1mag = sqrt(b1mag2); + const KK_FLOAT b1mag = Kokkos::sqrt(b1mag2); const KK_FLOAT b2mag2 = vb2x * vb2x + vb2y * vb2y + vb2z * vb2z; - const KK_FLOAT b2mag = sqrt(b2mag2); + const KK_FLOAT b2mag = Kokkos::sqrt(b2mag2); const KK_FLOAT b3mag2 = vb3x * vb3x + vb3y * vb3y + vb3z * vb3z; - const KK_FLOAT b3mag = sqrt(b3mag2); + const KK_FLOAT b3mag = Kokkos::sqrt(b3mag2); KK_FLOAT ctmp = vb1x * vb2x + vb1y * vb2y + vb1z * vb2z; const KK_FLOAT r12c1 = static_cast(1.0) / (b1mag * b2mag); @@ -221,11 +221,11 @@ void ImproperCvffKokkos::operator()(TagImproperCvffCompute(1.0) - c1mag * c1mag); + KK_FLOAT sc1 = Kokkos::sqrt(static_cast(1.0) - c1mag * c1mag); if (sc1 < static_cast(SMALL)) sc1 = static_cast(SMALL); sc1 = static_cast(1.0) / sc1; - KK_FLOAT sc2 = sqrt(static_cast(1.0) - c2mag * c2mag); + KK_FLOAT sc2 = Kokkos::sqrt(static_cast(1.0) - c2mag * c2mag); if (sc2 < static_cast(SMALL)) sc2 = static_cast(SMALL); sc2 = static_cast(1.0) / sc2; diff --git a/src/KOKKOS/improper_distance_kokkos.cpp b/src/KOKKOS/improper_distance_kokkos.cpp index f229ee4504c..41ce2c82c4b 100644 --- a/src/KOKKOS/improper_distance_kokkos.cpp +++ b/src/KOKKOS/improper_distance_kokkos.cpp @@ -174,7 +174,7 @@ void ImproperDistanceKokkos::operator()(TagImproperDistanceCompute(1.0) / sqrt(xna*xna + yna*yna + zna*zna); + const KK_FLOAT rna = static_cast(1.0) / Kokkos::sqrt(xna*xna + yna*yna + zna*zna); xna *= rna; yna *= rna; zna *= rna; diff --git a/src/KOKKOS/improper_distharm_kokkos.cpp b/src/KOKKOS/improper_distharm_kokkos.cpp index 8f56fbaccee..8ae6cddbcb0 100644 --- a/src/KOKKOS/improper_distharm_kokkos.cpp +++ b/src/KOKKOS/improper_distharm_kokkos.cpp @@ -172,7 +172,7 @@ void ImproperDistHarmKokkos::operator()(TagImproperDistHarmCompute(1.0) / sqrt(xna*xna + yna*yna + zna*zna); + const KK_FLOAT rna = static_cast(1.0) / Kokkos::sqrt(xna*xna + yna*yna + zna*zna); xna *= rna; yna *= rna; zna *= rna; diff --git a/src/KOKKOS/improper_fourier_kokkos.cpp b/src/KOKKOS/improper_fourier_kokkos.cpp index bae981e220e..367669321e3 100644 --- a/src/KOKKOS/improper_fourier_kokkos.cpp +++ b/src/KOKKOS/improper_fourier_kokkos.cpp @@ -222,8 +222,8 @@ void ImproperFourierKokkos::addone(EV_FLOAT &ev, az = vb1x*vb2y - vb1y*vb2x; ra2 = ax*ax + ay*ay + az*az; rh2 = vb3x*vb3x + vb3y*vb3y + vb3z*vb3z; - ra = sqrt(ra2); - rh = sqrt(rh2); + ra = Kokkos::sqrt(ra2); + rh = Kokkos::sqrt(rh2); if (ra < static_cast(SMALL)) ra = static_cast(SMALL); if (rh < static_cast(SMALL)) rh = static_cast(SMALL); @@ -245,14 +245,14 @@ void ImproperFourierKokkos::addone(EV_FLOAT &ev, if (c > static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - s = sqrt(static_cast(1.0) - c*c); + s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); cotphi = c/s; projhfg = (vb3x*vb1x + vb3y*vb1y + vb3z*vb1z) / - sqrt(vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + Kokkos::sqrt(vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); projhfg += (vb3x*vb2x + vb3y*vb2y + vb3z*vb2z) / - sqrt(vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); + Kokkos::sqrt(vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); if (projhfg > static_cast(0.0)) { s *= static_cast(-1.0); cotphi *= static_cast(-1.0); diff --git a/src/KOKKOS/improper_harmonic_kokkos.cpp b/src/KOKKOS/improper_harmonic_kokkos.cpp index 6fc8ebdf530..b92a2afbb88 100644 --- a/src/KOKKOS/improper_harmonic_kokkos.cpp +++ b/src/KOKKOS/improper_harmonic_kokkos.cpp @@ -186,9 +186,9 @@ void ImproperHarmonicKokkos::operator()(TagImproperHarmonicCompute(1.0) / (vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); const KK_FLOAT ss3 = static_cast(1.0) / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); - const KK_FLOAT r1 = sqrt(ss1); - const KK_FLOAT r2 = sqrt(ss2); - const KK_FLOAT r3 = sqrt(ss3); + const KK_FLOAT r1 = Kokkos::sqrt(ss1); + const KK_FLOAT r2 = Kokkos::sqrt(ss2); + const KK_FLOAT r3 = Kokkos::sqrt(ss3); // sin and cos of improper @@ -204,7 +204,7 @@ void ImproperHarmonicKokkos::operator()(TagImproperHarmonicCompute(SMALL)) s2 = static_cast(SMALL); s2 = static_cast(1.0) / s2; - KK_FLOAT s12 = sqrt(s1*s2); + KK_FLOAT s12 = Kokkos::sqrt(s1*s2); KK_FLOAT c = (c1*c2 + c0) * s12; // error check @@ -215,12 +215,12 @@ void ImproperHarmonicKokkos::operator()(TagImproperHarmonicCompute static_cast(1.0)) c = static_cast(1.0); if (c < -static_cast(1.0)) c = -static_cast(1.0); - KK_FLOAT s = sqrt(static_cast(1.0) - c*c); + KK_FLOAT s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); // force & energy - const KK_FLOAT domega = acos(c) - d_chi[type]; + const KK_FLOAT domega = Kokkos::acos(c) - d_chi[type]; KK_FLOAT a = d_k[type] * domega; KK_FLOAT eimproper = 0; diff --git a/src/KOKKOS/improper_inversion_harmonic_kokkos.cpp b/src/KOKKOS/improper_inversion_harmonic_kokkos.cpp index d0ed0674985..a51ed5eea1d 100644 --- a/src/KOKKOS/improper_inversion_harmonic_kokkos.cpp +++ b/src/KOKKOS/improper_inversion_harmonic_kokkos.cpp @@ -151,21 +151,21 @@ void ImproperInversionHarmonicKokkos::operator()(TagImproperInversio const KK_FLOAT vb1x = x(i2,0) - x(i1,0); const KK_FLOAT vb1y = x(i2,1) - x(i1,1); const KK_FLOAT vb1z = x(i2,2) - x(i1,2); - const KK_FLOAT rrvb1 = static_cast(1.0)/sqrt(vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + const KK_FLOAT rrvb1 = static_cast(1.0)/Kokkos::sqrt(vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); const KK_FLOAT rr2vb1 = rrvb1*rrvb1; // 2nd bond: IK const KK_FLOAT vb2x = x(i3,0) - x(i1,0); const KK_FLOAT vb2y = x(i3,1) - x(i1,1); const KK_FLOAT vb2z = x(i3,2) - x(i1,2); - const KK_FLOAT rrvb2 = static_cast(1.0)/sqrt(vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); + const KK_FLOAT rrvb2 = static_cast(1.0)/Kokkos::sqrt(vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); const KK_FLOAT rr2vb2 = rrvb2*rrvb2; // 3rd bond: IL const KK_FLOAT vb3x = x(i4,0) - x(i1,0); const KK_FLOAT vb3y = x(i4,1) - x(i1,1); const KK_FLOAT vb3z = x(i4,2) - x(i1,2); - const KK_FLOAT rrvb3 = static_cast(1.0)/sqrt(vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); + const KK_FLOAT rrvb3 = static_cast(1.0)/Kokkos::sqrt(vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); const KK_FLOAT rr2vb3 = rrvb3*rrvb3; invang(ev, i1,i2,i3,i4, type, @@ -221,28 +221,28 @@ void ImproperInversionHarmonicKokkos::invang(EV_FLOAT &ev, upx = vb2x*rrvb2 + vb1x*rrvb1; upy = vb2y*rrvb2 + vb1y*rrvb1; upz = vb2z*rrvb2 + vb1z*rrvb1; - upn = static_cast(1.0)/sqrt(upx*upx + upy*upy + upz*upz); + upn = static_cast(1.0)/Kokkos::sqrt(upx*upx + upy*upy + upz*upz); upx *= upn; upy *= upn; upz *= upn; rup = vb3x*upx + vb3y*upy + vb3z*upz; umx = vb2x*rrvb2 - vb1x*rrvb1; umy = vb2y*rrvb2 - vb1y*rrvb1; umz = vb2z*rrvb2 - vb1z*rrvb1; - umn = static_cast(1.0)/sqrt(umx*umx + umy*umy + umz*umz); + umn = static_cast(1.0)/Kokkos::sqrt(umx*umx + umy*umy + umz*umz); umx *= umn; umy *= umn; umz *= umn; rum = vb3x*umx + vb3y*umy + vb3z*umz; - wwr = sqrt(rup*rup + rum*rum); + wwr = Kokkos::sqrt(rup*rup + rum*rum); cosomega = wwr*rrvb3; if (cosomega > static_cast(1.0)) cosomega = static_cast(1.0); - omega = acos(cosomega); + omega = Kokkos::acos(cosomega); domega = omega - d_w0[type]; if (EVFLAG && eflag) eimproper = d_kw[type]*(domega*domega); gomega = static_cast(0.0); if (omega*omega > static_cast(1.0e-24)) - gomega = static_cast(2.0)*d_kw[type]*domega/sin(omega); + gomega = static_cast(2.0)*d_kw[type]*domega/Kokkos::sin(omega); rucb = rjk - rup*(vb2x*upx + vb2y*upy + vb2z*upz); rudb = rjl - rup*(vb1x*upx + vb1y*upy + vb1z*upz); diff --git a/src/KOKKOS/improper_ring_kokkos.cpp b/src/KOKKOS/improper_ring_kokkos.cpp index 59b26b1278b..58071b7fdef 100644 --- a/src/KOKKOS/improper_ring_kokkos.cpp +++ b/src/KOKKOS/improper_ring_kokkos.cpp @@ -181,12 +181,12 @@ void ImproperRingKokkos::operator()(TagImproperRingCompute::operator()(TagImproperRingCompute::operator()(TagImproperSQDistHarmCompu KK_FLOAT xna = ybc*zcd - zbc*ycd; KK_FLOAT yna = -(xbc*zcd - zbc*xcd); KK_FLOAT zna = xbc*ycd - ybc*xcd; - const KK_FLOAT rna = static_cast(1.0) / sqrt(xna*xna + yna*yna + zna*zna); + const KK_FLOAT rna = static_cast(1.0) / Kokkos::sqrt(xna*xna + yna*yna + zna*zna); xna *= rna; yna *= rna; zna *= rna; diff --git a/src/KOKKOS/improper_umbrella_kokkos.cpp b/src/KOKKOS/improper_umbrella_kokkos.cpp index 403b6de1657..def6da5ed0c 100644 --- a/src/KOKKOS/improper_umbrella_kokkos.cpp +++ b/src/KOKKOS/improper_umbrella_kokkos.cpp @@ -187,8 +187,8 @@ void ImproperUmbrellaKokkos::operator()(TagImproperUmbrellaCompute(SMALL)) ra = static_cast(SMALL); if (rh < static_cast(SMALL)) rh = static_cast(SMALL); @@ -206,12 +206,12 @@ void ImproperUmbrellaKokkos::operator()(TagImproperUmbrellaCompute static_cast(1.0)) c = static_cast(1.0); if (c < static_cast(-1.0)) c = static_cast(-1.0); - s = sqrt(static_cast(1.0) - c*c); + s = Kokkos::sqrt(static_cast(1.0) - c*c); if (s < static_cast(SMALL)) s = static_cast(SMALL); cotphi = c/s; - projhfg = (vb3x*vb1x + vb3y*vb1y + vb3z*vb1z)/sqrt(vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); - projhfg += (vb3x*vb2x + vb3y*vb2y + vb3z*vb2z)/sqrt(vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); + projhfg = (vb3x*vb1x + vb3y*vb1y + vb3z*vb1z)/Kokkos::sqrt(vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + projhfg += (vb3x*vb2x + vb3y*vb2y + vb3z*vb2z)/Kokkos::sqrt(vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); if (projhfg > static_cast(0.0)) { s *= static_cast(-1.0); cotphi *= static_cast(-1.0); @@ -221,7 +221,7 @@ void ImproperUmbrellaKokkos::operator()(TagImproperUmbrellaCompute(1.0) - s); a = -d_kw[type]; } else { - domega = s - cos(d_w0[type]); + domega = s - Kokkos::cos(d_w0[type]); a = static_cast(0.5)*d_C[type]*domega; if (EVFLAG && eflag) eimproper = a*domega; a *= static_cast(2.0); diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 16ef59f1df8..6de309eb326 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -566,9 +566,9 @@ struct BinOp3DLAMMPS { template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION int bin(ViewType& keys, const int& i) const { - int ix = static_cast ((keys(i, 0) - min_[0]) * mul_[0]); - int iy = static_cast ((keys(i, 1) - min_[1]) * mul_[1]); - int iz = static_cast ((keys(i, 2) - min_[2]) * mul_[2]); + int ix = static_cast ((static_cast(keys(i, 0)) - min_[0]) * mul_[0]); + int iy = static_cast ((static_cast(keys(i, 1)) - min_[1]) * mul_[1]); + int iz = static_cast ((static_cast(keys(i, 2)) - min_[2]) * mul_[2]); ix = MAX(ix,0); iy = MAX(iy,0); iz = MAX(iz,0); diff --git a/src/KOKKOS/math_extra_kokkos.h b/src/KOKKOS/math_extra_kokkos.h index 429695fb8a3..34f971a3a87 100644 --- a/src/KOKKOS/math_extra_kokkos.h +++ b/src/KOKKOS/math_extra_kokkos.h @@ -88,7 +88,7 @@ namespace MathExtraKokkos { KOKKOS_INLINE_FUNCTION void MathExtraKokkos::norm3(KK_FLOAT *v) { - KK_FLOAT scale = 1.0/sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); + KK_FLOAT scale = static_cast(1.0)/Kokkos::sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); v[0] *= scale; v[1] *= scale; v[2] *= scale; @@ -101,7 +101,7 @@ void MathExtraKokkos::norm3(KK_FLOAT *v) KOKKOS_INLINE_FUNCTION void MathExtraKokkos::normalize3(const KK_FLOAT *v, KK_FLOAT *ans) { - KK_FLOAT scale = 1.0/sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); + KK_FLOAT scale = static_cast(1.0)/Kokkos::sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); ans[0] = v[0]*scale; ans[1] = v[1]*scale; ans[2] = v[2]*scale; @@ -114,7 +114,7 @@ void MathExtraKokkos::normalize3(const KK_FLOAT *v, KK_FLOAT *ans) KOKKOS_INLINE_FUNCTION void MathExtraKokkos::snormalize3(const KK_FLOAT length, const KK_FLOAT *v, KK_FLOAT *ans) { - KK_FLOAT scale = length/sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); + KK_FLOAT scale = length/Kokkos::sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); ans[0] = v[0]*scale; ans[1] = v[1]*scale; ans[2] = v[2]*scale; @@ -187,7 +187,7 @@ void MathExtraKokkos::sub3(const KK_FLOAT *v1, const KK_FLOAT *v2, KK_FLOAT *ans KOKKOS_INLINE_FUNCTION KK_FLOAT MathExtraKokkos::len3(const KK_FLOAT *v) { - return sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + return Kokkos::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); } /* ---------------------------------------------------------------------- @@ -462,19 +462,19 @@ void MathExtraKokkos::richardson(double *q, KK_FLOAT *m, KK_FLOAT *w, KK_FLOAT * MathExtraKokkos::vecquat(w,q,wq); double qfull[4]; - qfull[0] = q[0] + dtq * wq[0]; - qfull[1] = q[1] + dtq * wq[1]; - qfull[2] = q[2] + dtq * wq[2]; - qfull[3] = q[3] + dtq * wq[3]; + qfull[0] = q[0] + static_cast(dtq * wq[0]); + qfull[1] = q[1] + static_cast(dtq * wq[1]); + qfull[2] = q[2] + static_cast(dtq * wq[2]); + qfull[3] = q[3] + static_cast(dtq * wq[3]); MathExtraKokkos::qnormalize(qfull); // 1st half update from dq/dt = 1/2 w q double qhalf[4]; - qhalf[0] = q[0] + 0.5*dtq * wq[0]; - qhalf[1] = q[1] + 0.5*dtq * wq[1]; - qhalf[2] = q[2] + 0.5*dtq * wq[2]; - qhalf[3] = q[3] + 0.5*dtq * wq[3]; + qhalf[0] = q[0] + static_cast(static_cast(0.5)*dtq * wq[0]); + qhalf[1] = q[1] + static_cast(static_cast(0.5)*dtq * wq[1]); + qhalf[2] = q[2] + static_cast(static_cast(0.5)*dtq * wq[2]); + qhalf[3] = q[3] + static_cast(static_cast(0.5)*dtq * wq[3]); MathExtraKokkos::qnormalize(qhalf); // re-compute omega at 1/2 step from m at 1/2 step and q at 1/2 step @@ -485,10 +485,10 @@ void MathExtraKokkos::richardson(double *q, KK_FLOAT *m, KK_FLOAT *w, KK_FLOAT * // 2nd half update from dq/dt = 1/2 w q - qhalf[0] += 0.5*dtq * wq[0]; - qhalf[1] += 0.5*dtq * wq[1]; - qhalf[2] += 0.5*dtq * wq[2]; - qhalf[3] += 0.5*dtq * wq[3]; + qhalf[0] += static_cast(static_cast(0.5)*dtq * wq[0]); + qhalf[1] += static_cast(static_cast(0.5)*dtq * wq[1]); + qhalf[2] += static_cast(static_cast(0.5)*dtq * wq[2]); + qhalf[3] += static_cast(static_cast(0.5)*dtq * wq[3]); MathExtraKokkos::qnormalize(qhalf); // corrected Richardson update @@ -506,7 +506,7 @@ void MathExtraKokkos::richardson(double *q, KK_FLOAT *m, KK_FLOAT *w, KK_FLOAT * KOKKOS_INLINE_FUNCTION void MathExtraKokkos::qnormalize(double *q) { - KK_FLOAT norm = 1.0 / sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]); + double norm = 1.0 / sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]); q[0] *= norm; q[1] *= norm; q[2] *= norm; @@ -532,10 +532,14 @@ void MathExtraKokkos::qconjugate(KK_FLOAT *q, KK_FLOAT *qc) KOKKOS_INLINE_FUNCTION void MathExtraKokkos::vecquat(KK_FLOAT *a, double *b, KK_FLOAT *c) { - c[0] = -a[0] * b[1] - a[1] * b[2] - a[2] * b[3]; - c[1] = b[0] * a[0] + a[1] * b[3] - a[2] * b[2]; - c[2] = b[0] * a[1] + a[2] * b[1] - a[0] * b[3]; - c[3] = b[0] * a[2] + a[0] * b[2] - a[1] * b[1]; + const KK_FLOAT b0 = static_cast(b[0]); + const KK_FLOAT b1 = static_cast(b[1]); + const KK_FLOAT b2 = static_cast(b[2]); + const KK_FLOAT b3 = static_cast(b[3]); + c[0] = -a[0] * b1 - a[1] * b2 - a[2] * b3; + c[1] = b0 * a[0] + a[1] * b3 - a[2] * b2; + c[2] = b0 * a[1] + a[2] * b1 - a[0] * b3; + c[3] = b0 * a[2] + a[0] * b2 - a[1] * b1; } /* ---------------------------------------------------------------------- @@ -546,9 +550,9 @@ KOKKOS_INLINE_FUNCTION void MathExtraKokkos::axisangle_to_quat(const KK_FLOAT *v, const KK_FLOAT angle, KK_FLOAT *quat) { - KK_FLOAT halfa = 0.5*angle; - KK_FLOAT sina = sin(halfa); - quat[0] = cos(halfa); + KK_FLOAT halfa = static_cast(0.5)*angle; + KK_FLOAT sina = Kokkos::sin(halfa); + quat[0] = Kokkos::cos(halfa); quat[1] = v[0]*sina; quat[2] = v[1]*sina; quat[3] = v[2]*sina; @@ -569,11 +573,11 @@ void MathExtraKokkos::mq_to_omega(KK_FLOAT *m, double *q, KK_FLOAT *moments, KK_ MathExtraKokkos::quat_to_mat(q,rot); MathExtraKokkos::transpose_matvec(rot,m,wbody); - if (moments[0] == 0.0) wbody[0] = 0.0; + if (moments[0] == static_cast(0.0)) wbody[0] = 0.0; else wbody[0] /= moments[0]; - if (moments[1] == 0.0) wbody[1] = 0.0; + if (moments[1] == static_cast(0.0)) wbody[1] = 0.0; else wbody[1] /= moments[1]; - if (moments[2] == 0.0) wbody[2] = 0.0; + if (moments[2] == static_cast(0.0)) wbody[2] = 0.0; else wbody[2] /= moments[2]; MathExtraKokkos::matvec(rot,wbody,w); } @@ -585,16 +589,16 @@ void MathExtraKokkos::mq_to_omega(KK_FLOAT *m, double *q, KK_FLOAT *moments, KK_ KOKKOS_INLINE_FUNCTION void MathExtraKokkos::quat_to_mat(const double *quat, KK_FLOAT mat[3][3]) { - KK_FLOAT w2 = quat[0]*quat[0]; - KK_FLOAT i2 = quat[1]*quat[1]; - KK_FLOAT j2 = quat[2]*quat[2]; - KK_FLOAT k2 = quat[3]*quat[3]; - KK_FLOAT twoij = 2.0*quat[1]*quat[2]; - KK_FLOAT twoik = 2.0*quat[1]*quat[3]; - KK_FLOAT twojk = 2.0*quat[2]*quat[3]; - KK_FLOAT twoiw = 2.0*quat[1]*quat[0]; - KK_FLOAT twojw = 2.0*quat[2]*quat[0]; - KK_FLOAT twokw = 2.0*quat[3]*quat[0]; + KK_FLOAT w2 = static_cast(quat[0]*quat[0]); + KK_FLOAT i2 = static_cast(quat[1]*quat[1]); + KK_FLOAT j2 = static_cast(quat[2]*quat[2]); + KK_FLOAT k2 = static_cast(quat[3]*quat[3]); + KK_FLOAT twoij = static_cast(2.0*quat[1]*quat[2]); + KK_FLOAT twoik = static_cast(2.0*quat[1]*quat[3]); + KK_FLOAT twojk = static_cast(2.0*quat[2]*quat[3]); + KK_FLOAT twoiw = static_cast(2.0*quat[1]*quat[0]); + KK_FLOAT twojw = static_cast(2.0*quat[2]*quat[0]); + KK_FLOAT twokw = static_cast(2.0*quat[3]*quat[0]); mat[0][0] = w2+i2-j2-k2; mat[0][1] = twoij-twokw; diff --git a/src/KOKKOS/math_special_kokkos.h b/src/KOKKOS/math_special_kokkos.h index 5ecb23a891e..2a51db4a867 100644 --- a/src/KOKKOS/math_special_kokkos.h +++ b/src/KOKKOS/math_special_kokkos.h @@ -130,7 +130,7 @@ namespace LAMMPS_NS::MathSpecialKokkos { { #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) if (x < -1022.0/FM_DOUBLE_LOG2OFE) return 0; - if (x > 1023.0/FM_DOUBLE_LOG2OFE) return INFINITY; + if (x > 1023.0/FM_DOUBLE_LOG2OFE) return static_cast(INFINITY); return exp2_x86(FM_DOUBLE_LOG2OFE * x); #else return ::exp(x); diff --git a/src/KOKKOS/meam_dens_final_kokkos.h b/src/KOKKOS/meam_dens_final_kokkos.h index e2b8109f317..054c2199257 100644 --- a/src/KOKKOS/meam_dens_final_kokkos.h +++ b/src/KOKKOS/meam_dens_final_kokkos.h @@ -63,21 +63,21 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT scaleii = d_scale(type[i],type[i]); d_rho1[i] = 0.0; if (msmeamflag) { - d_rho2[i] = -1.0 / 3.0 * (d_arho2b[i] * d_arho2b[i] + d_rho2[i] = static_cast(-1.0 / 3.0) * (d_arho2b[i] * d_arho2b[i] - d_arho2mb[i] * d_arho2mb[i]); } else{ - d_rho2[i] = -1.0 / 3.0 * d_arho2b[i] * d_arho2b[i]; + d_rho2[i] = static_cast(-1.0 / 3.0) * d_arho2b[i] * d_arho2b[i]; } d_rho3[i] = 0.0; for (int m = 0; m < 3; m++) { if (msmeamflag) { d_rho1[i] = d_rho1[i] + d_arho1(i, m) * d_arho1(i, m) - d_arho1m(i, m) * d_arho1m(i, m); - d_rho3[i] = d_rho3[i] - 3.0 / 5.0 * (d_arho3b(i, m) * d_arho3b(i, m) + d_rho3[i] = d_rho3[i] - static_cast(3.0 / 5.0) * (d_arho3b(i, m) * d_arho3b(i, m) - d_arho3mb(i, m) * d_arho3mb(i, m)); } else{ d_rho1[i] += d_arho1(i,m) * d_arho1(i,m); - d_rho3[i] -= 3.0 / 5.0 * d_arho3b(i,m) * d_arho3b(i,m); + d_rho3[i] -= static_cast(3.0 / 5.0) * d_arho3b(i,m) * d_arho3b(i,m); } } for (int m = 0; m < 6; m++){ @@ -100,15 +100,15 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT // with msmeam all t weights are already accounted for in rho d_gamma[i] = d_rho1[i] + d_rho2[i] + d_rho3[i]; } else{ - if (d_rho0[i] > 0.0) { + if (d_rho0[i] > static_cast(0.0)) { if (ialloy == 1) { d_t_ave(i,0) = fdiv_zero_kk(d_t_ave(i,0), d_tsq_ave(i,0)); d_t_ave(i,1) = fdiv_zero_kk(d_t_ave(i,1), d_tsq_ave(i,1)); d_t_ave(i,2) = fdiv_zero_kk(d_t_ave(i,2), d_tsq_ave(i,2)); } else if (ialloy == 2) { - d_t_ave(i,0) = t1_meam[elti]; - d_t_ave(i,1) = t2_meam[elti]; - d_t_ave(i,2) = t3_meam[elti]; + d_t_ave(i,0) = static_cast(t1_meam[elti]); + d_t_ave(i,1) = static_cast(t2_meam[elti]); + d_t_ave(i,2) = static_cast(t3_meam[elti]); } else { d_t_ave(i,0) /= d_rho0[i]; d_t_ave(i,1) /= d_rho0[i]; @@ -118,7 +118,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT d_gamma[i] = d_t_ave(i,0) * d_rho1[i] + d_t_ave(i,1) * d_rho2[i] + d_t_ave(i,2) * d_rho3[i]; } - if (d_rho0[i] > 0.0) + if (d_rho0[i] > static_cast(0.0)) d_gamma[i] /= (d_rho0[i] * d_rho0[i]); Z = get_Zij(lattce_meam[elti][elti]); @@ -127,7 +127,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT if (d_errorflag() != 0) return; - get_shpfcn(lattce_meam[elti][elti], stheta_meam[elti][elti], ctheta_meam[elti][elti], shp); + get_shpfcn(lattce_meam[elti][elti], static_cast(stheta_meam[elti][elti]), static_cast(ctheta_meam[elti][elti]), shp); if (ibar_meam[elti] <= 0) { Gbar = 1.0; dGbar = 0.0; @@ -135,7 +135,7 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT if (mix_ref_t == 1) gam = (d_t_ave(i,0) * shp[0] + d_t_ave(i,1) * shp[1] + d_t_ave(i,2) * shp[2]) / (Z * Z); else - gam = (t1_meam[elti] * shp[0] + t2_meam[elti] * shp[1] + t3_meam[elti] * shp[2]) / + gam = (static_cast(t1_meam[elti]) * shp[0] + static_cast(t2_meam[elti]) * shp[1] + static_cast(t3_meam[elti]) * shp[2]) / (Z * Z); Gbar = G_gam(gam, ibar_meam[elti], d_errorflag()); } @@ -149,15 +149,15 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT gam = (d_t_ave(i,0) * shp[0] + d_t_ave(i,1) * shp[1] + d_t_ave(i,2) * shp[2]) / (Z * Z); Gbar = dG_gam(gam, ibar_meam[elti], dGbar); } - rho_bkgd = rho0_meam[elti] * Z * Gbar; + rho_bkgd = static_cast(rho0_meam[elti]) * Z * Gbar; } else { if (bkgd_dyn == 1) - rho_bkgd = rho0_meam[elti] * Z; + rho_bkgd = static_cast(rho0_meam[elti]) * Z; else - rho_bkgd = rho_ref_meam[elti]; + rho_bkgd = static_cast(rho_ref_meam[elti]); } rhob = d_rho[i] / rho_bkgd; - denom = 1.0 / rho_bkgd; + denom = static_cast(1.0) / rho_bkgd; G = dG_gam(d_gamma[i], ibar_meam[elti], dG); @@ -176,15 +176,15 @@ void MEAMKokkos::operator()(TagMEAMDensFinal, const int &i, EV_FLOAT else d_dgamma3[i] = 0.0; - Fl = embedding(A_meam[elti], Ec_meam[elti][elti], rhob, d_frhop[i]); + Fl = embedding(static_cast(A_meam[elti]), static_cast(Ec_meam[elti][elti]), rhob, d_frhop[i]); if (eflag_either) { Fl *= scaleii; if (eflag_global) { - ev.evdwl += Fl; + ev.evdwl += static_cast(Fl); } if (eflag_atom) { - d_eatom[i] += Fl; + d_eatom[i] += static_cast(Fl); } } } diff --git a/src/KOKKOS/meam_dens_init_kokkos.h b/src/KOKKOS/meam_dens_init_kokkos.h index 17bfad5d79a..882fbbea9ac 100644 --- a/src/KOKKOS/meam_dens_init_kokkos.h +++ b/src/KOKKOS/meam_dens_init_kokkos.h @@ -292,7 +292,7 @@ void MEAMKokkos::getscreen(int i, int offset, typename AT::t_kkfloat_1d_3_lr x, typename AT::t_int_1d d_numneigh_half, typename AT::t_int_1d d_numneigh_full, int /*ntype*/, typename AT::t_int_1d type, typename AT::t_int_1d d_map) const { - const KK_FLOAT drinv = 1.0 / delr_meam; + const KK_FLOAT drinv = static_cast(1.0 / delr_meam); const int elti = d_map[type[i]]; if (elti < 0) return; @@ -316,7 +316,7 @@ const { const KK_FLOAT rij2 = delxij * delxij + delyij * delyij + delzij * delzij; - if (rij2 > cutforcesq) { + if (rij2 > static_cast(cutforcesq)) { d_dscrfcn[offset+jn] = 0.0; d_scrfcn[offset+jn] = 0.0; d_fcpair[offset+jn] = 0.0; @@ -324,9 +324,9 @@ const { } // Now compute derivatives - const KK_FLOAT rbound = ebound_meam[elti][eltj] * rij2; - const KK_FLOAT rij = sqrt(rij2); - const KK_FLOAT rnorm = (cutforce - rij) * drinv; + const KK_FLOAT rbound = static_cast(ebound_meam[elti][eltj]) * rij2; + const KK_FLOAT rij = Kokkos::sqrt(rij2); + const KK_FLOAT rnorm = (static_cast(cutforce) - rij) * drinv; KK_FLOAT sij = 1.0; // if rjk2 > ebound*rijsq, atom k is definitely outside the ellipse @@ -357,11 +357,11 @@ const { const KK_FLOAT a = 1 - (xik - xjk) * (xik - xjk); // if a < 0, then ellipse equation doesn't describe this case and // atom k can't possibly screen i-j - if (a <= 0.0) continue; + if (a <= static_cast(0.0)) continue; - KK_FLOAT cikj = (2.0 * (xik + xjk) + a - 2.0) / a; - const KK_FLOAT Cmax = Cmax_meam[elti][eltj][eltk]; - const KK_FLOAT Cmin = Cmin_meam[elti][eltj][eltk]; + KK_FLOAT cikj = (static_cast(2.0) * (xik + xjk) + a - static_cast(2.0)) / a; + const KK_FLOAT Cmax = static_cast(Cmax_meam[elti][eltj][eltk]); + const KK_FLOAT Cmin = static_cast(Cmin_meam[elti][eltj][eltk]); KK_FLOAT sikj; if (cikj >= Cmax) continue; // note that cikj may be slightly negative (within numerical @@ -410,11 +410,11 @@ const { const KK_FLOAT a = 1 - (xik - xjk) * (xik - xjk); // if a < 0, then ellipse equation doesn't describe this case and // atom k can't possibly screen i-j - if (a <= 0.0) continue; + if (a <= static_cast(0.0)) continue; - KK_FLOAT cikj = (2.0 * (xik + xjk) + a - 2.0) / a; - const KK_FLOAT Cmax = Cmax_meam[elti][eltj][eltk]; - const KK_FLOAT Cmin = Cmin_meam[elti][eltj][eltk]; + KK_FLOAT cikj = (static_cast(2.0) * (xik + xjk) + a - static_cast(2.0)) / a; + const KK_FLOAT Cmax = static_cast(Cmax_meam[elti][eltj][eltk]); + const KK_FLOAT Cmin = static_cast(Cmin_meam[elti][eltj][eltk]); if (cikj >= Cmax) { continue; // Note that cikj may be slightly negative (within numerical @@ -496,57 +496,57 @@ MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d ty delij[1] = x(j,1) - ytmp; delij[2] = x(j,2) - ztmp; const KK_FLOAT rij2 = delij[0] * delij[0] + delij[1] * delij[1] + delij[2] * delij[2]; - if (rij2 < cutforcesq) { + if (rij2 < static_cast(cutforcesq)) { const int eltj = d_map[type[j]]; - const KK_FLOAT rij = sqrt(rij2); - const KK_FLOAT ai = rij / re_meam[elti][elti] - 1.0; - const KK_FLOAT aj = rij / re_meam[eltj][eltj] - 1.0; - const KK_FLOAT ro0i = rho0_meam[elti]; - const KK_FLOAT ro0j = rho0_meam[eltj]; - const KK_FLOAT rhoa0j = ro0j * MathSpecialKokkos::fm_exp(-beta0_meam[eltj] * aj) * sij; - KK_FLOAT rhoa1j = ro0j * MathSpecialKokkos::fm_exp(-beta1_meam[eltj] * aj) * sij; - KK_FLOAT rhoa2j = ro0j * MathSpecialKokkos::fm_exp(-beta2_meam[eltj] * aj) * sij; - KK_FLOAT rhoa3j = ro0j * MathSpecialKokkos::fm_exp(-beta3_meam[eltj] * aj) * sij; - const KK_FLOAT rhoa0i = ro0i * MathSpecialKokkos::fm_exp(-beta0_meam[elti] * ai) * sij; - KK_FLOAT rhoa1i = ro0i * MathSpecialKokkos::fm_exp(-beta1_meam[elti] * ai) * sij; - KK_FLOAT rhoa2i = ro0i * MathSpecialKokkos::fm_exp(-beta2_meam[elti] * ai) * sij; - KK_FLOAT rhoa3i = ro0i * MathSpecialKokkos::fm_exp(-beta3_meam[elti] * ai) * sij; + const KK_FLOAT rij = Kokkos::sqrt(rij2); + const KK_FLOAT ai = rij / static_cast(re_meam[elti][elti]) - static_cast(1.0); + const KK_FLOAT aj = rij / static_cast(re_meam[eltj][eltj]) - static_cast(1.0); + const KK_FLOAT ro0i = static_cast(rho0_meam[elti]); + const KK_FLOAT ro0j = static_cast(rho0_meam[eltj]); + const KK_FLOAT rhoa0j = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta0_meam[eltj]) * aj))) * sij; + KK_FLOAT rhoa1j = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta1_meam[eltj]) * aj))) * sij; + KK_FLOAT rhoa2j = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta2_meam[eltj]) * aj))) * sij; + KK_FLOAT rhoa3j = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta3_meam[eltj]) * aj))) * sij; + const KK_FLOAT rhoa0i = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta0_meam[elti]) * ai))) * sij; + KK_FLOAT rhoa1i = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta1_meam[elti]) * ai))) * sij; + KK_FLOAT rhoa2i = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta2_meam[elti]) * ai))) * sij; + KK_FLOAT rhoa3i = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta3_meam[elti]) * ai))) * sij; // msmeam KK_FLOAT rhoa1mj, rhoa2mj, rhoa3mj, rhoa1mi, rhoa2mi, rhoa3mi; if (msmeamflag) { - rhoa1mj = ro0j * t1m_meam[eltj] * MathSpecialKokkos::fm_exp(-beta1m_meam[eltj] * aj) * sij; - rhoa2mj = ro0j * t2m_meam[eltj] * MathSpecialKokkos::fm_exp(-beta2m_meam[eltj] * aj) * sij; - rhoa3mj = ro0j * t3m_meam[eltj] * MathSpecialKokkos::fm_exp(-beta3m_meam[eltj] * aj) * sij; - rhoa1mi = ro0i * t1m_meam[elti] * MathSpecialKokkos::fm_exp(-beta1m_meam[elti] * ai) * sij; - rhoa2mi = ro0i * t2m_meam[elti] * MathSpecialKokkos::fm_exp(-beta2m_meam[elti] * ai) * sij; - rhoa3mi = ro0i * t3m_meam[elti] * MathSpecialKokkos::fm_exp(-beta3m_meam[elti] * ai) * sij; + rhoa1mj = ro0j * static_cast(t1m_meam[eltj]) * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta1m_meam[eltj]) * aj))) * sij; + rhoa2mj = ro0j * static_cast(t2m_meam[eltj]) * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta2m_meam[eltj]) * aj))) * sij; + rhoa3mj = ro0j * static_cast(t3m_meam[eltj]) * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta3m_meam[eltj]) * aj))) * sij; + rhoa1mi = ro0i * static_cast(t1m_meam[elti]) * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta1m_meam[elti]) * ai))) * sij; + rhoa2mi = ro0i * static_cast(t2m_meam[elti]) * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta2m_meam[elti]) * ai))) * sij; + rhoa3mi = ro0i * static_cast(t3m_meam[elti]) * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta3m_meam[elti]) * ai))) * sij; } if (ialloy == 1) { - rhoa1j *= t1_meam[eltj]; - rhoa2j *= t2_meam[eltj]; - rhoa3j *= t3_meam[eltj]; - rhoa1i *= t1_meam[elti]; - rhoa2i *= t2_meam[elti]; - rhoa3i *= t3_meam[elti]; + rhoa1j *= static_cast(t1_meam[eltj]); + rhoa2j *= static_cast(t2_meam[eltj]); + rhoa3j *= static_cast(t3_meam[eltj]); + rhoa1i *= static_cast(t1_meam[elti]); + rhoa2i *= static_cast(t2_meam[elti]); + rhoa3i *= static_cast(t3_meam[elti]); } a_rho0[i] += rhoa0j; a_rho0[j] += rhoa0i; // For ialloy = 2, use single-element value (not average) if (ialloy != 2) { - a_t_ave(i,0) += t1_meam[eltj] * rhoa0j; - a_t_ave(i,1) += t2_meam[eltj] * rhoa0j; - a_t_ave(i,2) += t3_meam[eltj] * rhoa0j; - a_t_ave(j,0) += t1_meam[elti] * rhoa0i; - a_t_ave(j,1) += t2_meam[elti] * rhoa0i; - a_t_ave(j,2) += t3_meam[elti] * rhoa0i; + a_t_ave(i,0) += static_cast(t1_meam[eltj]) * rhoa0j; + a_t_ave(i,1) += static_cast(t2_meam[eltj]) * rhoa0j; + a_t_ave(i,2) += static_cast(t3_meam[eltj]) * rhoa0j; + a_t_ave(j,0) += static_cast(t1_meam[elti]) * rhoa0i; + a_t_ave(j,1) += static_cast(t2_meam[elti]) * rhoa0i; + a_t_ave(j,2) += static_cast(t3_meam[elti]) * rhoa0i; } if (ialloy == 1) { - a_tsq_ave(i,0) += t1_meam[eltj] * t1_meam[eltj] * rhoa0j; - a_tsq_ave(i,1) += t2_meam[eltj] * t2_meam[eltj] * rhoa0j; - a_tsq_ave(i,2) += t3_meam[eltj] * t3_meam[eltj] * rhoa0j; - a_tsq_ave(j,0) += t1_meam[elti] * t1_meam[elti] * rhoa0i; - a_tsq_ave(j,1) += t2_meam[elti] * t2_meam[elti] * rhoa0i; - a_tsq_ave(j,2) += t3_meam[elti] * t3_meam[elti] * rhoa0i; + a_tsq_ave(i,0) += static_cast(t1_meam[eltj]) * static_cast(t1_meam[eltj]) * rhoa0j; + a_tsq_ave(i,1) += static_cast(t2_meam[eltj]) * static_cast(t2_meam[eltj]) * rhoa0j; + a_tsq_ave(i,2) += static_cast(t3_meam[eltj]) * static_cast(t3_meam[eltj]) * rhoa0j; + a_tsq_ave(j,0) += static_cast(t1_meam[elti]) * static_cast(t1_meam[elti]) * rhoa0i; + a_tsq_ave(j,1) += static_cast(t2_meam[elti]) * static_cast(t2_meam[elti]) * rhoa0i; + a_tsq_ave(j,2) += static_cast(t3_meam[elti]) * static_cast(t3_meam[elti]) * rhoa0i; } a_arho2b[i] += rhoa2j; a_arho2b[j] += rhoa2i; @@ -614,17 +614,17 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT MEAMKokkos::dfcut(const KK_FLOAT xi, KK_FLOAT& dfc) const { - if (xi >= 1.0) { + if (xi >= static_cast(1.0)) { dfc = 0.0; return 1.0; - } else if (xi <= 0.0) { + } else if (xi <= static_cast(0.0)) { dfc = 0.0; return 0.0; } else { - const KK_FLOAT a = 1.0 - xi; + const KK_FLOAT a = static_cast(1.0) - xi; const KK_FLOAT a3 = a * a * a; const KK_FLOAT a4 = a * a3; - const KK_FLOAT a1m4 = 1.0 - a4; + const KK_FLOAT a1m4 = static_cast(1.0) - a4; dfc = 8 * a1m4 * a3; return a1m4*a1m4; @@ -674,15 +674,15 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT MEAMKokkos::fcut(const KK_FLOAT xi) const { KK_FLOAT a; - if (xi >= 1.0) + if (xi >= static_cast(1.0)) return 1.0; - else if (xi <= 0.0) + else if (xi <= static_cast(0.0)) return 0.0; else { // ( 1.d0 - (1.d0 - xi)**4 )**2, but with better codegen - a = 1.0 - xi; + a = static_cast(1.0) - xi; a *= a; a *= a; - a = 1.0 - a; + a = static_cast(1.0) - a; return a * a; } } diff --git a/src/KOKKOS/meam_force_kokkos.h b/src/KOKKOS/meam_force_kokkos.h index 785cbab97ce..a644f5224c0 100644 --- a/src/KOKKOS/meam_force_kokkos.h +++ b/src/KOKKOS/meam_force_kokkos.h @@ -146,8 +146,8 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(1.0 / 3.0); + sixth = static_cast(1.0 / 6.0); elti = d_map[type[i]]; if (elti < 0) return; @@ -168,17 +168,17 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(cutforcesq)) { + rij = Kokkos::sqrt(rij2); + recip = static_cast(1.0) / rij; // Compute phi and phip ind = eltind[elti][eltj]; - pp = rij * rdrar; + pp = rij * static_cast(rdrar); kk = (int) pp; kk = (kk <= (nrar - 2)) ? kk : nrar - 2; pp = pp - kk; - pp = (pp <= 1.0) ? pp : 1.0; + pp = (pp <= static_cast(1.0)) ? pp : static_cast(1.0); phi = ((d_phirar3(ind, kk) * pp + d_phirar2(ind, kk)) * pp + d_phirar1(ind, kk)) * pp + d_phirar(ind, kk); phip = (d_phirar6(ind, kk) * pp + d_phirar5(ind, kk)) * pp + d_phirar4(ind, kk); @@ -186,10 +186,10 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(phi_sc * sij); if (eflag_atom) { - a_eatom[i] += 0.5 * phi * sij; - a_eatom[j] += 0.5 * phi * sij; + a_eatom[i] += static_cast(static_cast(0.5) * phi * sij); + a_eatom[j] += static_cast(static_cast(0.5) * phi * sij); } } @@ -197,45 +197,45 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(1.0 / re_meam[elti][elti]); + ai = rij * invrei - static_cast(1.0); + ro0i = static_cast(rho0_meam[elti]); + rhoa0i = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta0_meam[elti]) * ai))); + drhoa0i = -static_cast(beta0_meam[elti]) * invrei * rhoa0i; + rhoa1i = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta1_meam[elti]) * ai))); + drhoa1i = -static_cast(beta1_meam[elti]) * invrei * rhoa1i; + rhoa2i = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta2_meam[elti]) * ai))); + drhoa2i = -static_cast(beta2_meam[elti]) * invrei * rhoa2i; + rhoa3i = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta3_meam[elti]) * ai))); + drhoa3i = -static_cast(beta3_meam[elti]) * invrei * rhoa3i; if (msmeamflag) { - rhoa1mi = ro0i * MathSpecialKokkos::fm_exp(-beta1m_meam[elti] * ai) * t1m_meam[elti]; - drhoa1mi = -beta1m_meam[elti] * invrei * rhoa1mi; - rhoa2mi = ro0i * MathSpecialKokkos::fm_exp(-beta2m_meam[elti] * ai) * t2m_meam[elti]; - drhoa2mi = -beta2m_meam[elti] * invrei * rhoa2mi; - rhoa3mi = ro0i * MathSpecialKokkos::fm_exp(-beta3m_meam[elti] * ai) * t3m_meam[elti]; - drhoa3mi = -beta3m_meam[elti] * invrei * rhoa3mi; + rhoa1mi = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta1m_meam[elti]) * ai))) * static_cast(t1m_meam[elti]); + drhoa1mi = -static_cast(beta1m_meam[elti]) * invrei * rhoa1mi; + rhoa2mi = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta2m_meam[elti]) * ai))) * static_cast(t2m_meam[elti]); + drhoa2mi = -static_cast(beta2m_meam[elti]) * invrei * rhoa2mi; + rhoa3mi = ro0i * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta3m_meam[elti]) * ai))) * static_cast(t3m_meam[elti]); + drhoa3mi = -static_cast(beta3m_meam[elti]) * invrei * rhoa3mi; } if (elti != eltj) { - invrej = 1.0 / re_meam[eltj][eltj]; - aj = rij * invrej - 1.0; - ro0j = rho0_meam[eltj]; - rhoa0j = ro0j * MathSpecialKokkos::fm_exp(-beta0_meam[eltj] * aj); - drhoa0j = -beta0_meam[eltj] * invrej * rhoa0j; - rhoa1j = ro0j * MathSpecialKokkos::fm_exp(-beta1_meam[eltj] * aj); - drhoa1j = -beta1_meam[eltj] * invrej * rhoa1j; - rhoa2j = ro0j * MathSpecialKokkos::fm_exp(-beta2_meam[eltj] * aj); - drhoa2j = -beta2_meam[eltj] * invrej * rhoa2j; - rhoa3j = ro0j * MathSpecialKokkos::fm_exp(-beta3_meam[eltj] * aj); - drhoa3j = -beta3_meam[eltj] * invrej * rhoa3j; + invrej = static_cast(1.0 / re_meam[eltj][eltj]); + aj = rij * invrej - static_cast(1.0); + ro0j = static_cast(rho0_meam[eltj]); + rhoa0j = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta0_meam[eltj]) * aj))); + drhoa0j = -static_cast(beta0_meam[eltj]) * invrej * rhoa0j; + rhoa1j = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta1_meam[eltj]) * aj))); + drhoa1j = -static_cast(beta1_meam[eltj]) * invrej * rhoa1j; + rhoa2j = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta2_meam[eltj]) * aj))); + drhoa2j = -static_cast(beta2_meam[eltj]) * invrej * rhoa2j; + rhoa3j = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta3_meam[eltj]) * aj))); + drhoa3j = -static_cast(beta3_meam[eltj]) * invrej * rhoa3j; if (msmeamflag) { - rhoa1mj = ro0j * MathSpecialKokkos::fm_exp(-beta1m_meam[eltj] * aj) * t1m_meam[eltj]; - drhoa1mj = -beta1m_meam[eltj] * invrej * rhoa1mj; - rhoa2mj = ro0j * MathSpecialKokkos::fm_exp(-beta2m_meam[eltj] * aj) * t2m_meam[eltj]; - drhoa2mj = -beta2m_meam[eltj] * invrej * rhoa2mj; - rhoa3mj = ro0j * MathSpecialKokkos::fm_exp(-beta3m_meam[eltj] * aj) * t3m_meam[eltj]; - drhoa3mj = -beta3m_meam[eltj] * invrej * rhoa3mj; + rhoa1mj = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta1m_meam[eltj]) * aj))) * static_cast(t1m_meam[eltj]); + drhoa1mj = -static_cast(beta1m_meam[eltj]) * invrej * rhoa1mj; + rhoa2mj = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta2m_meam[eltj]) * aj))) * static_cast(t2m_meam[eltj]); + drhoa2mj = -static_cast(beta2m_meam[eltj]) * invrej * rhoa2mj; + rhoa3mj = ro0j * static_cast(MathSpecialKokkos::fm_exp(static_cast(-static_cast(beta3m_meam[eltj]) * aj))) * static_cast(t3m_meam[eltj]); + drhoa3mj = -static_cast(beta3m_meam[eltj]) * invrej * rhoa3mj; } } else { rhoa0j = rhoa0i; @@ -256,12 +256,12 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(t1_meam[elti]); + const KK_FLOAT t2mi = static_cast(t2_meam[elti]); + const KK_FLOAT t3mi = static_cast(t3_meam[elti]); + const KK_FLOAT t1mj = static_cast(t1_meam[eltj]); + const KK_FLOAT t2mj = static_cast(t2_meam[eltj]); + const KK_FLOAT t3mj = static_cast(t3_meam[eltj]); // ialloy mod not needed in MS-MEAM, but similarity here is that we multply rhos by t. // We did this above with rhoa1mj, rhoa2mj, etc. @@ -350,7 +350,7 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(2.0) * sij / rij; for (m = 0; m < 3; m++) { drho1drm1[m] = a1 * rhoa1j * d_arho1(i, m); drho1drm2[m] = -a1 * rhoa1i * d_arho1(j, m); @@ -359,9 +359,9 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(2.0 / 3.0) * d_arho2b[i] * drhoa2j * sij; drho2dr2 = - a2 * (drhoa2i - 2 * rhoa2i / rij) * arg1j2 - 2.0 / 3.0 * d_arho2b[j] * drhoa2i * sij; + a2 * (drhoa2i - 2 * rhoa2i / rij) * arg1j2 - static_cast(2.0 / 3.0) * d_arho2b[j] * drhoa2i * sij; a2 = 4 * sij / rij2; for (m = 0; m < 3; m++) { drho2drm1[m] = 0.0; @@ -377,7 +377,7 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(6.0 / 5.0) * sij / rij; drho3dr1 = a3 * (drhoa3j - 3 * rhoa3j / rij) * arg1i3 - a3a * (drhoa3j - rhoa3j / rij) * arg3i3; drho3dr2 = @@ -405,9 +405,9 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(-1.0); + drho1mdr2 *= static_cast(-1.0); + a1 = static_cast(2.0) * sij / rij; for (m = 0; m < 3; m++) { drho1mdrm1[m] = a1 * rhoa1mj * d_arho1m(i, m); drho1mdrm2[m] = -a1 * rhoa1mi * d_arho1m(j, m); @@ -415,8 +415,8 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(2.0 / 3.0) * d_arho2mb[i] * drhoa2mj * sij; + drho2mdr2 = a2 * (drhoa2mi - 2 * rhoa2mi / rij) * arg1j2m - static_cast(2.0 / 3.0) * d_arho2mb[j] * drhoa2mi * sij; a2 = 4 * sij / rij2; for (m = 0; m < 3; m++) { drho2mdrm1[m] = 0.0; @@ -432,11 +432,11 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(6.0 / 5.0) * sij / rij; drho3mdr1 = a3 * (drhoa3mj - 3 * rhoa3mj / rij) * arg1i3m - a3a * (drhoa3mj - rhoa3mj / rij) * arg3i3m; drho3mdr2 = a3 * (drhoa3mi - 3 * rhoa3mi / rij) * arg1j3m - a3a * (drhoa3mi - rhoa3mi / rij) * arg3j3m; - drho3mdr1 *= -1.0; - drho3mdr2 *= -1.0; + drho3mdr1 *= static_cast(-1.0); + drho3mdr2 *= static_cast(-1.0); a3 = 6 * sij / rij3; a3a = 6 * sij / (5 * rij); @@ -533,8 +533,8 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(stheta_meam[elti][elti]), static_cast(ctheta_meam[elti][elti]), shpi); + get_shpfcn(lattce_meam[eltj][eltj], static_cast(stheta_meam[elti][elti]), static_cast(ctheta_meam[elti][elti]), shpj); if (msmeamflag) { @@ -583,22 +583,22 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(2.0) / rij; drho1ds1 = a1 * rhoa1j * arg1i1; drho1ds2 = a1 * rhoa1i * arg1j1; - a2 = 2.0 / rij2; - drho2ds1 = a2 * rhoa2j * arg1i2 - 2.0 / 3.0 * d_arho2b[i] * rhoa2j; - drho2ds2 = a2 * rhoa2i * arg1j2 - 2.0 / 3.0 * d_arho2b[j] * rhoa2i; - a3 = 2.0 / rij3; - a3a = 6.0 / (5.0 * rij); + a2 = static_cast(2.0) / rij2; + drho2ds1 = a2 * rhoa2j * arg1i2 - static_cast(2.0 / 3.0) * d_arho2b[i] * rhoa2j; + drho2ds2 = a2 * rhoa2i * arg1j2 - static_cast(2.0 / 3.0) * d_arho2b[j] * rhoa2i; + a3 = static_cast(2.0) / rij3; + a3a = static_cast(6.0) / (static_cast(5.0) * rij); drho3ds1 = a3 * rhoa3j * arg1i3 - a3a * rhoa3j * arg3i3; drho3ds2 = a3 * rhoa3i * arg1j3 - a3a * rhoa3i * arg3j3; if (msmeamflag) { drho1mds1 = a1 * rhoa1mj * arg1i1m; drho1mds2 = a1 * rhoa1mi * arg1j1m; - drho2mds1 = a2 * rhoa2mj * arg1i2m - 2.0 / 3.0 * d_arho2mb[i] * rhoa2mj; - drho2mds2 = a2 * rhoa2mi * arg1j2m - 2.0 / 3.0 * d_arho2mb[j] * rhoa2mi; + drho2mds1 = a2 * rhoa2mj * arg1i2m - static_cast(2.0 / 3.0) * d_arho2mb[i] * rhoa2mj; + drho2mds2 = a2 * rhoa2mi * arg1j2m - static_cast(2.0 / 3.0) * d_arho2mb[j] * rhoa2mi; drho3mds1 = a3 * rhoa3mj * arg1i3m - a3a * rhoa3mj * arg3i3m; drho3mds2 = a3 * rhoa3mi * arg1j3m - a3a * rhoa3mi * arg3j3m; drho1mds1 *= -1; @@ -702,8 +702,8 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(forcem); + a_f(j, m) -= static_cast(forcem); } // Tabulate per-atom virial as symmetrized stress tensor @@ -712,20 +712,20 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(-0.5) * (delij[0] * fi[0]); + v[1] = static_cast(-0.5) * (delij[1] * fi[1]); + v[2] = static_cast(-0.5) * (delij[2] * fi[2]); + v[3] = static_cast(-0.25) * (delij[0] * fi[1] + delij[1] * fi[0]); + v[4] = static_cast(-0.25) * (delij[0] * fi[2] + delij[2] * fi[0]); + v[5] = static_cast(-0.25) * (delij[1] * fi[2] + delij[2] * fi[1]); if (vflag_global) - for (m = 0; m < 6; m++) ev.v[m] += 2.0 * v[m]; + for (m = 0; m < 6; m++) ev.v[m] += static_cast(static_cast(2.0) * v[m]); if (vflag_atom) { for (m = 0; m < 6; m++) { - a_vatom(i, m) += v[m]; - a_vatom(j, m) += v[m]; + a_vatom(i, m) += static_cast(v[m]); + a_vatom(j, m) += static_cast(v[m]); } } } @@ -746,13 +746,13 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(Cmax_meam[elti][eltj][eltk]); + const KK_FLOAT Cmin = static_cast(Cmin_meam[elti][eltj][eltk]); dsij1 = 0.0; dsij2 = 0.0; if (!iszero_kk(sij) && !isone_kk(sij)) { - const KK_FLOAT rbound = rij2 * ebound_meam[elti][eltj]; + const KK_FLOAT rbound = rij2 * static_cast(ebound_meam[elti][eltj]); delc = Cmax - Cmin; dxjk = x(k, 0) - x(j, 0); dyjk = x(k, 1) - x(j, 1); @@ -768,7 +768,7 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(2.0) * (xik + xjk) + a - static_cast(2.0)) / a; if (cikj >= Cmin && cikj <= Cmax) { cikj = (cikj - Cmin) / delc; sikj = dfcut(cikj, dfc); @@ -786,15 +786,15 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(force1 * dxik); + a_f(i, 1) += static_cast(force1 * dyik); + a_f(i, 2) += static_cast(force1 * dzik); + a_f(j, 0) += static_cast(force2 * dxjk); + a_f(j, 1) += static_cast(force2 * dyjk); + a_f(j, 2) += static_cast(force2 * dzjk); + a_f(k, 0) -= static_cast(force1 * dxik + force2 * dxjk); + a_f(k, 1) -= static_cast(force1 * dyik + force2 * dyjk); + a_f(k, 2) -= static_cast(force1 * dzik + force2 * dzjk); // Tabulate per-atom virial as symmetrized stress tensor @@ -813,13 +813,13 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce(static_cast(3.0) * v[m]); if (vflag_atom) { for (m = 0; m < 6; m++) { - a_vatom(i, m) += v[m]; - a_vatom(j, m) += v[m]; - a_vatom(k, m) += v[m]; + a_vatom(i, m) += static_cast(v[m]); + a_vatom(j, m) += static_cast(v[m]); + a_vatom(k, m) += static_cast(v[m]); } } } diff --git a/src/KOKKOS/meam_funcs_kokkos.h b/src/KOKKOS/meam_funcs_kokkos.h index 2a239b4daca..dfb4af279ee 100644 --- a/src/KOKKOS/meam_funcs_kokkos.h +++ b/src/KOKKOS/meam_funcs_kokkos.h @@ -38,29 +38,30 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT MEAMKokkos::G_gam(const KK_FLOAT gamma, const int ibar, int &errorflag) const { KK_FLOAT gsmooth_switchpoint; + const KK_FLOAT gsmooth_factor_kk = static_cast(gsmooth_factor); switch (ibar) { case 0: case 4: - gsmooth_switchpoint = -gsmooth_factor / (gsmooth_factor + 1); + gsmooth_switchpoint = -gsmooth_factor_kk / (gsmooth_factor_kk + 1); if (gamma < gsmooth_switchpoint) { // e.g. gsmooth_factor is 99, {: // gsmooth_switchpoint = -0.99 // G = 0.01*(-0.99/gamma)**99 - KK_FLOAT G = 1 / (gsmooth_factor + 1) * pow((gsmooth_switchpoint / gamma), gsmooth_factor); - return sqrt(G); + KK_FLOAT G = 1 / (gsmooth_factor_kk + 1) * Kokkos::pow((gsmooth_switchpoint / gamma), gsmooth_factor_kk); + return Kokkos::sqrt(G); } else { - return sqrt(1.0 + gamma); + return Kokkos::sqrt(static_cast(1.0) + gamma); } case 1: - return MathSpecialKokkos::fm_exp(gamma / 2.0); + return static_cast(MathSpecialKokkos::fm_exp(static_cast(gamma) / 2.0)); case 3: - return 2.0 / (1.0 + MathSpecialKokkos::fm_exp(-gamma)); + return static_cast(2.0 / (1.0 + MathSpecialKokkos::fm_exp(static_cast(-gamma)))); case -5: - if ((1.0 + gamma) >= 0) { - return sqrt(1.0 + gamma); + if ((static_cast(1.0) + gamma) >= 0) { + return Kokkos::sqrt(static_cast(1.0) + gamma); } else { - return -sqrt(-1.0 - gamma); + return -Kokkos::sqrt(static_cast(-1.0) - gamma); } } errorflag = 1; @@ -83,40 +84,41 @@ KK_FLOAT MEAMKokkos::dG_gam(const KK_FLOAT gamma, const int ibar, KK { KK_FLOAT gsmooth_switchpoint; KK_FLOAT G; + const KK_FLOAT gsmooth_factor_kk = static_cast(gsmooth_factor); switch (ibar) { case 0: case 4: - gsmooth_switchpoint = -gsmooth_factor / (gsmooth_factor + 1); + gsmooth_switchpoint = -gsmooth_factor_kk / (gsmooth_factor_kk + 1); if (gamma < gsmooth_switchpoint) { // e.g. gsmooth_factor is 99, {: // gsmooth_switchpoint = -0.99 // G = 0.01*(-0.99/gamma)**99 - G = 1 / (gsmooth_factor + 1) * pow((gsmooth_switchpoint / gamma), gsmooth_factor); - G = sqrt(G); - dG = -gsmooth_factor * G / (2.0 * gamma); + G = 1 / (gsmooth_factor_kk + 1) * Kokkos::pow((gsmooth_switchpoint / gamma), gsmooth_factor_kk); + G = Kokkos::sqrt(G); + dG = -gsmooth_factor_kk * G / (static_cast(2.0) * gamma); return G; } else { - G = sqrt(1.0 + gamma); - dG = 1.0 / (2.0 * G); + G = Kokkos::sqrt(static_cast(1.0) + gamma); + dG = static_cast(1.0) / (static_cast(2.0) * G); return G; } case 1: - G = MathSpecialKokkos::fm_exp(gamma / 2.0); - dG = G / 2.0; + G = static_cast(MathSpecialKokkos::fm_exp(static_cast(gamma) / 2.0)); + dG = G / static_cast(2.0); return G; case 3: - G = 2.0 / (1.0 + MathSpecialKokkos::fm_exp(-gamma)); - dG = G * (2.0 - G) / 2; + G = static_cast(2.0 / (1.0 + MathSpecialKokkos::fm_exp(static_cast(-gamma)))); + dG = G * (static_cast(2.0) - G) / 2; return G; case -5: - if ((1.0 + gamma) >= 0) { - G = sqrt(1.0 + gamma); - dG = 1.0 / (2.0 * G); + if ((static_cast(1.0) + gamma) >= 0) { + G = Kokkos::sqrt(static_cast(1.0) + gamma); + dG = static_cast(1.0) / (static_cast(2.0) * G); return G; } else { - G = -sqrt(-1.0 - gamma); - dG = -1.0 / (2.0 * G); + G = -Kokkos::sqrt(static_cast(-1.0) - gamma); + dG = static_cast(-1.0) / (static_cast(2.0) * G); return G; } } @@ -133,19 +135,19 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT MEAMKokkos::zbl(const KK_FLOAT r, const int z1, const int z2) const { int i; - const KK_FLOAT c[] = { 0.028171, 0.28022, 0.50986, 0.18175 }; - const KK_FLOAT d[] = { 0.20162, 0.40290, 0.94229, 3.1998 }; - const KK_FLOAT azero = 0.4685; - const KK_FLOAT cc = 14.3997; + const KK_FLOAT c[] = { static_cast(0.028171), static_cast(0.28022), static_cast(0.50986), static_cast(0.18175) }; + const KK_FLOAT d[] = { static_cast(0.20162), static_cast(0.40290), static_cast(0.94229), static_cast(3.1998) }; + const KK_FLOAT azero = static_cast(0.4685); + const KK_FLOAT cc = static_cast(14.3997); KK_FLOAT a, x; // azero = (9pi^2/128)^1/3 (0.529) Angstroms - a = azero / (pow(z1, 0.23) + pow(z2, 0.23)); + a = azero / static_cast(pow(z1, 0.23) + pow(z2, 0.23)); KK_FLOAT result = 0.0; x = r / a; for (i = 0; i <= 3; i++) { - result = result + c[i] * MathSpecialKokkos::fm_exp(-d[i] * x); + result = result + c[i] * static_cast(MathSpecialKokkos::fm_exp(static_cast(-d[i] * x))); } - if (r > 0.0) + if (r > static_cast(0.0)) result = result * z1 * z2 / r * cc; return result; } @@ -160,9 +162,9 @@ KK_FLOAT MEAMKokkos::embedding(const KK_FLOAT A, const KK_FLOAT Ec, { const KK_FLOAT AEc = A * Ec; - if (rhobar > 0.0) { - const KK_FLOAT lrb = log(rhobar); - dF = AEc * (1.0 + lrb); + if (rhobar > static_cast(0.0)) { + const KK_FLOAT lrb = Kokkos::log(rhobar); + dF = AEc * (static_cast(1.0) + lrb); return AEc * rhobar * lrb; } else { if (emb_lin_neg == 0) { @@ -187,8 +189,8 @@ KK_FLOAT MEAMKokkos::erose(const KK_FLOAT r, const KK_FLOAT re, cons KK_FLOAT astar, a3; KK_FLOAT result = 0.0; - if (r > 0.0) { - astar = alpha * (r / re - 1.0); + if (r > static_cast(0.0)) { + astar = alpha * (r / re - static_cast(1.0)); a3 = 0.0; if (astar >= 0) a3 = attrac; @@ -196,11 +198,11 @@ KK_FLOAT MEAMKokkos::erose(const KK_FLOAT r, const KK_FLOAT re, cons a3 = repuls; if (form == 1) - result = -Ec * (1 + astar + (-attrac + repuls / r) * MathSpecialKokkos::cube(astar)) * MathSpecialKokkos::fm_exp(-astar); + result = -Ec * (1 + astar + (-attrac + repuls / r) * MathSpecialKokkos::cube(astar)) * static_cast(MathSpecialKokkos::fm_exp(static_cast(-astar))); else if (form == 2) - result = -Ec * (1 + astar + a3 * MathSpecialKokkos::cube(astar)) * MathSpecialKokkos::fm_exp(-astar); + result = -Ec * (1 + astar + a3 * MathSpecialKokkos::cube(astar)) * static_cast(MathSpecialKokkos::fm_exp(static_cast(-astar))); else - result = -Ec * (1 + astar + a3 * MathSpecialKokkos::cube(astar) / (r / re)) * MathSpecialKokkos::fm_exp(-astar); + result = -Ec * (1 + astar + a3 * MathSpecialKokkos::cube(astar) / (r / re)) * static_cast(MathSpecialKokkos::fm_exp(static_cast(-astar))); } return result; } @@ -226,32 +228,32 @@ void MEAMKokkos::get_shpfcn(const lattice_t latt, const KK_FLOAT sth case HCP: s[0] = 0.0; s[1] = 0.0; - s[2] = 1.0 / 3.0; + s[2] = static_cast(1.0 / 3.0); break; case CH4: // CH4 actually needs shape factor for diamond for C, dimer for H case DIA: case DIA3: s[0] = 0.0; s[1] = 0.0; - s[2] = 32.0 / 9.0; + s[2] = static_cast(32.0 / 9.0); break; case DIM: s[0] = 1.0; - s[1] = 2.0 / 3.0; + s[1] = static_cast(2.0 / 3.0); // s(4) = 1.d0 // this should be 0.4 unless (1-legendre) is multiplied in the density calc. - s[2] = 0.40; // this is (1-legendre) where legendre = 0.6 in dynamo is accounted. + s[2] = static_cast(0.40); // this is (1-legendre) where legendre = 0.6 in dynamo is accounted. break; case LIN: // linear, theta being 180 s[0] = 0.0; - s[1] = 8.0 / 3.0; // 4*(co**4 + si**4 - 1.0/3.0) in zig become 4*(1-1/3) + s[1] = static_cast(8.0 / 3.0); // 4*(co**4 + si**4 - 1.0/3.0) in zig become 4*(1-1/3) s[2] = 0.0; break; case ZIG: //zig-zag case TRI: //trimer e.g. H2O - s[0] = 4.0*pow(cthe,2); - s[1] = 4.0*(pow(cthe,4) + pow(sthe,4) - 1.0/3.0); - s[2] = 4.0*(pow(cthe,2) * (3*pow(sthe,4) + pow(cthe,4))); - s[2] = s[2] - 0.6*s[0]; //legend in dyn, 0.6 is default value. + s[0] = static_cast(4.0) * Kokkos::pow(cthe,static_cast(2)); + s[1] = static_cast(4.0) * (Kokkos::pow(cthe,static_cast(4)) + Kokkos::pow(sthe,static_cast(4)) - static_cast(1.0/3.0)); + s[2] = static_cast(4.0) * (Kokkos::pow(cthe,static_cast(2)) * (3*Kokkos::pow(sthe,static_cast(4)) + Kokkos::pow(cthe,static_cast(4)))); + s[2] = s[2] - static_cast(0.6)*s[0]; //legend in dyn, 0.6 is default value. break; default: s[0] = 0.0; diff --git a/src/KOKKOS/meam_kokkos.h b/src/KOKKOS/meam_kokkos.h index 3d948f6e078..6a3677a2003 100644 --- a/src/KOKKOS/meam_kokkos.h +++ b/src/KOKKOS/meam_kokkos.h @@ -251,14 +251,14 @@ template class MEAMKokkos : public MEAM { KOKKOS_INLINE_FUNCTION static bool iszero_kk(const KK_FLOAT f) { - return fabs(f) < 1e-20; + return Kokkos::fabs(f) < static_cast(1e-20); } // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION static bool isone_kk(const KK_FLOAT f) { - return fabs(f - 1.0) < 1e-20; + return Kokkos::fabs(f - static_cast(1.0)) < static_cast(1e-20); } // NOLINTNEXTLINE diff --git a/src/KOKKOS/meam_setup_done_kokkos.h b/src/KOKKOS/meam_setup_done_kokkos.h index fa3cf7e085d..115e63cf973 100644 --- a/src/KOKKOS/meam_setup_done_kokkos.h +++ b/src/KOKKOS/meam_setup_done_kokkos.h @@ -39,14 +39,14 @@ void MEAMKokkos::meam_setup_done(double* cutmax) for (int i = 0; i <(neltypes * (neltypes + 1)) / 2; i++) for(int j = 0; j < nr; j++) { - h_phir(i,j) = phir[i][j]; - h_phirar(i,j) = phirar[i][j]; - h_phirar1(i,j) = phirar1[i][j]; - h_phirar2(i,j) = phirar2[i][j]; - h_phirar3(i,j) = phirar3[i][j]; - h_phirar4(i,j) = phirar4[i][j]; - h_phirar5(i,j) = phirar5[i][j]; - h_phirar6(i,j) = phirar6[i][j]; + h_phir(i,j) = static_cast(phir[i][j]); + h_phirar(i,j) = static_cast(phirar[i][j]); + h_phirar1(i,j) = static_cast(phirar1[i][j]); + h_phirar2(i,j) = static_cast(phirar2[i][j]); + h_phirar3(i,j) = static_cast(phirar3[i][j]); + h_phirar4(i,j) = static_cast(phirar4[i][j]); + h_phirar5(i,j) = static_cast(phirar5[i][j]); + h_phirar6(i,j) = static_cast(phirar6[i][j]); } Kokkos::deep_copy(d_phir,h_phir); diff --git a/src/KOKKOS/min_cg_kokkos.cpp b/src/KOKKOS/min_cg_kokkos.cpp index 2832270e274..69fb29c5b7e 100644 --- a/src/KOKKOS/min_cg_kokkos.cpp +++ b/src/KOKKOS/min_cg_kokkos.cpp @@ -68,20 +68,20 @@ int MinCGKokkos::iterate(int maxiter) if constexpr (F_LAYOUTRIGHT) { auto l_fvec = fvec; Kokkos::parallel_for(nvec, LAMMPS_LAMBDA(const int& i) { - l_h[i] = l_fvec[i]; - l_g[i] = l_fvec[i]; + l_h[i] = static_cast(l_fvec[i]); + l_g[i] = static_cast(l_fvec[i]); }); } else { auto l_f = atomKK->k_f.view_device(); Kokkos::parallel_for(atom->nlocal, LAMMPS_LAMBDA(const int& i) { const int j = i*3; - l_h[j] = l_f(i,0); - l_h[j+1] = l_f(i,1); - l_h[j+2] = l_f(i,2); + l_h[j] = static_cast(l_f(i,0)); + l_h[j+1] = static_cast(l_f(i,1)); + l_h[j+2] = static_cast(l_f(i,2)); - l_g[j] = l_f(i,0); - l_g[j+1] = l_f(i,1); - l_g[j+2] = l_f(i,2); + l_g[j] = static_cast(l_f(i,0)); + l_g[j+1] = static_cast(l_f(i,1)); + l_g[j+2] = static_cast(l_f(i,2)); }); } } @@ -125,25 +125,25 @@ int MinCGKokkos::iterate(int maxiter) if constexpr (F_LAYOUTRIGHT) { auto l_fvec = fvec; Kokkos::parallel_reduce(nvec, LAMMPS_LAMBDA(const int& i, s_KK_double2& sdot) { - sdot.d0 += l_fvec[i]*l_fvec[i]; - sdot.d1 += l_fvec[i]*l_g[i]; + sdot.d0 += static_cast(l_fvec[i]*l_fvec[i]); + sdot.d1 += static_cast(l_fvec[i])*l_g[i]; },sdot); } else { auto l_f = atomKK->k_f.view_device(); Kokkos::parallel_reduce(atom->nlocal, LAMMPS_LAMBDA(const int& i, s_KK_double2& sdot) { - sdot.d0 += l_f(i,0)*l_f(i,0); - sdot.d0 += l_f(i,1)*l_f(i,1); - sdot.d0 += l_f(i,2)*l_f(i,2); + sdot.d0 += static_cast(l_f(i,0)*l_f(i,0)); + sdot.d0 += static_cast(l_f(i,1)*l_f(i,1)); + sdot.d0 += static_cast(l_f(i,2)*l_f(i,2)); const int j = i*3; - sdot.d1 += l_f(i,0)*l_g[j]; - sdot.d1 += l_f(i,1)*l_g[j+1]; - sdot.d1 += l_f(i,2)*l_g[j+2]; + sdot.d1 += static_cast(l_f(i,0))*l_g[j]; + sdot.d1 += static_cast(l_f(i,1))*l_g[j+1]; + sdot.d1 += static_cast(l_f(i,2))*l_g[j+2]; },sdot); } } - dot[0] = sdot.d0; - dot[1] = sdot.d1; + dot[0] = static_cast(sdot.d0); + dot[1] = static_cast(sdot.d1); MPI_Allreduce(dot,dotall,2,MPI_DOUBLE,MPI_SUM,world); if (nextra_global) for (int i = 0; i < nextra_global; i++) { @@ -178,20 +178,20 @@ int MinCGKokkos::iterate(int maxiter) if constexpr (F_LAYOUTRIGHT) { auto l_fvec = fvec; Kokkos::parallel_for(nvec, LAMMPS_LAMBDA(const int& i) { - l_g[i] = l_fvec[i]; - l_h[i] = l_g[i] + beta*l_h[i]; + l_g[i] = static_cast(l_fvec[i]); + l_h[i] = l_g[i] + static_cast(beta)*l_h[i]; }); } else { auto l_f = atomKK->k_f.view_device(); Kokkos::parallel_for(atom->nlocal, LAMMPS_LAMBDA(const int& i) { const int j = i*3; - l_g[j] = l_f(i,0); - l_g[j+1] = l_f(i,1); - l_g[j+2] = l_f(i,2); + l_g[j] = static_cast(l_f(i,0)); + l_g[j+1] = static_cast(l_f(i,1)); + l_g[j+2] = static_cast(l_f(i,2)); }); Kokkos::parallel_for(nvec, LAMMPS_LAMBDA(const int& i) { - l_h[i] = l_g[i] + beta*l_h[i]; + l_h[i] = l_g[i] + static_cast(beta)*l_h[i]; }); } } @@ -212,7 +212,7 @@ int MinCGKokkos::iterate(int maxiter) auto l_g = g; Kokkos::parallel_reduce(nvec, LAMMPS_LAMBDA(const int& i, double& dot_0) { - dot_0 += l_g[i]*l_h[i]; + dot_0 += static_cast(l_g[i]*l_h[i]); },dot_0); } dot[0] = dot_0; diff --git a/src/KOKKOS/min_fire_kokkos.cpp b/src/KOKKOS/min_fire_kokkos.cpp index 4ab31ed9202..84f95aac1e0 100644 --- a/src/KOKKOS/min_fire_kokkos.cpp +++ b/src/KOKKOS/min_fire_kokkos.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; -static constexpr KK_FLOAT EPS_ENERGY = 1.0e-8; +static constexpr KK_FLOAT EPS_ENERGY = static_cast(1.0e-8); MinFireKokkos::MinFireKokkos(LAMMPS *lmp) : MinKokkos(lmp) { atomKK = (AtomKokkos *) atom; @@ -124,11 +124,12 @@ int MinFireKokkos::run_iterate(int maxiter) { energy_force(0); neval++; double dtf = -0.5 * dt * force->ftm2v; + const KK_FLOAT dtf_kk = static_cast(dtf); Kokkos::parallel_for("min_fire/leapfrog_init", atom->nlocal, LAMMPS_LAMBDA(const int i) { - KK_FLOAT dtfm = dtf / (l_rmass.data() ? l_rmass(i) : l_mass(l_type(i))); - l_v(i,0) = dtfm * l_f(i,0); - l_v(i,1) = dtfm * l_f(i,1); - l_v(i,2) = dtfm * l_f(i,2); + KK_FLOAT dtfm = dtf_kk / (l_rmass.data() ? l_rmass(i) : l_mass(l_type(i))); + l_v(i,0) = dtfm * static_cast(l_f(i,0)); + l_v(i,1) = dtfm * static_cast(l_f(i,1)); + l_v(i,2) = dtfm * static_cast(l_f(i,2)); }); } @@ -140,7 +141,7 @@ int MinFireKokkos::run_iterate(int maxiter) { vdotf_local = 0.0; Kokkos::parallel_reduce("min_fire/vdotf", nlocal, LAMMPS_LAMBDA(const int i, double &vdf) { - vdf += l_v(i,0)*l_f(i,0) + l_v(i,1)*l_f(i,1) + l_v(i,2)*l_f(i,2); + vdf += static_cast(static_cast(l_v(i,0))*l_f(i,0) + static_cast(l_v(i,1))*l_f(i,1) + static_cast(l_v(i,2))*l_f(i,2)); }, vdotf_local); MPI_Allreduce(&vdotf_local, &vdotfall, 1, MPI_DOUBLE, MPI_SUM, world); @@ -153,10 +154,10 @@ int MinFireKokkos::run_iterate(int maxiter) { vdotv_local = 0.0; fdotf_local = 0.0; Kokkos::parallel_reduce("min_fire/norms", nlocal, LAMMPS_LAMBDA(const int i, double &vv) { - vv += l_v(i,0)*l_v(i,0) + l_v(i,1)*l_v(i,1) + l_v(i,2)*l_v(i,2); + vv += static_cast(l_v(i,0)*l_v(i,0) + l_v(i,1)*l_v(i,1) + l_v(i,2)*l_v(i,2)); }, vdotv_local); Kokkos::parallel_reduce("min_fire/fnorms", nlocal, LAMMPS_LAMBDA(const int i, double &ff) { - ff += l_f(i,0)*l_f(i,0) + l_f(i,1)*l_f(i,1) + l_f(i,2)*l_f(i,2); + ff += static_cast(l_f(i,0)*l_f(i,0) + l_f(i,1)*l_f(i,1) + l_f(i,2)*l_f(i,2)); }, fdotf_local); MPI_Allreduce(&vdotv_local, &vdotvall, 1, MPI_DOUBLE, MPI_SUM, world); @@ -171,12 +172,12 @@ int MinFireKokkos::run_iterate(int maxiter) { if constexpr (ABCFLAG) { if (alpha < 1e-10) alpha = 1e-10; - KK_FLOAT abc = (1.0 - pow(1.0 - alpha, (KK_FLOAT)(ntimestep - last_negative))); - scale1 = (1.0 - alpha) / abc; - scale2 = (fdotfall <= 1e-20) ? 0.0 : (alpha * sqrt(vdotvall / fdotfall)) / abc; + double abc = (1.0 - pow(1.0 - alpha, (double)(ntimestep - last_negative))); + scale1 = static_cast((1.0 - alpha) / abc); + scale2 = static_cast((fdotfall <= 1e-20) ? 0.0 : (alpha * sqrt(vdotvall / fdotfall)) / abc); } else { - scale1 = 1.0 - alpha; - scale2 = (fdotfall <= 1e-20) ? 0.0 : alpha * sqrt(vdotvall / fdotfall); + scale1 = static_cast(1.0 - alpha); + scale2 = static_cast((fdotfall <= 1e-20) ? 0.0 : alpha * sqrt(vdotvall / fdotfall)); } if (ntimestep - last_negative > delaystep) { @@ -198,14 +199,14 @@ int MinFireKokkos::run_iterate(int maxiter) { vdotf_negatif++; if (max_vdotf_negatif > 0 && vdotf_negatif > max_vdotf_negatif) return MAXVDOTF; - auto l_dt = dt; + const KK_FLOAT l_dt = static_cast(dt); auto l_halfstepback_flag = halfstepback_flag; Kokkos::parallel_for("min_fire/inertia_reset", nlocal, LAMMPS_LAMBDA(const int i) { if (l_halfstepback_flag) { - l_x(i,0) -= 0.5 * l_dt * l_v(i,0); - l_x(i,1) -= 0.5 * l_dt * l_v(i,1); - l_x(i,2) -= 0.5 * l_dt * l_v(i,2); + l_x(i,0) -= static_cast(0.5) * l_dt * l_v(i,0); + l_x(i,1) -= static_cast(0.5) * l_dt * l_v(i,1); + l_x(i,2) -= static_cast(0.5) * l_dt * l_v(i,2); } l_v(i,0) = l_v(i,1) = l_v(i,2) = 0.0; }); @@ -216,11 +217,12 @@ int MinFireKokkos::run_iterate(int maxiter) { energy_force(0); neval++; double dtf_init = dt * force->ftm2v; + const KK_FLOAT dtf_init_kk = static_cast(dtf_init); Kokkos::parallel_for("min_fire/v_init", nlocal, LAMMPS_LAMBDA(const int i) { - KK_FLOAT dtfm = dtf_init / (l_rmass.data() ? l_rmass(i) : l_mass(l_type(i))); - l_v(i,0) = dtfm * l_f(i,0); - l_v(i,1) = dtfm * l_f(i,1); - l_v(i,2) = dtfm * l_f(i,2); + KK_FLOAT dtfm = dtf_init_kk / (l_rmass.data() ? l_rmass(i) : l_mass(l_type(i))); + l_v(i,0) = dtfm * static_cast(l_f(i,0)); + l_v(i,1) = dtfm * static_cast(l_f(i,1)); + l_v(i,2) = dtfm * static_cast(l_f(i,2)); }); } @@ -229,16 +231,17 @@ int MinFireKokkos::run_iterate(int maxiter) { double dtvone = dt; auto l_dmax = dmax; + const KK_FLOAT l_dmax_kk = static_cast(dmax); if constexpr (!ABCFLAG) { Kokkos::parallel_reduce("min_fire/dtv_limit", nlocal, LAMMPS_LAMBDA(const int i, double &dtmin_local) { - KK_FLOAT vmax = fmax(fabs(l_v(i,0)), fmax(fabs(l_v(i,1)), fabs(l_v(i,2)))); - if (dtmin_local * vmax > l_dmax) dtmin_local = l_dmax / vmax; + KK_FLOAT vmax = Kokkos::fmax(Kokkos::fabs(l_v(i,0)), Kokkos::fmax(Kokkos::fabs(l_v(i,1)), Kokkos::fabs(l_v(i,2)))); + if (dtmin_local * static_cast(vmax) > l_dmax) dtmin_local = l_dmax / static_cast(vmax); }, Kokkos::Min(dtvone)); dtvone = Kokkos::min(dtvone, dt); } MPI_Allreduce(&dtvone, &dtv, 1, MPI_DOUBLE, MPI_MIN, world); if (update->multireplica == 1) { - double dtv_tmp = dtv; + double dtv_tmp = static_cast(dtv); MPI_Allreduce(&dtv_tmp, &dtv, 1, MPI_DOUBLE, MPI_MIN, universe->uworld); } @@ -248,43 +251,43 @@ int MinFireKokkos::run_iterate(int maxiter) { }); } - KK_FLOAT dtf_final = dtv * force->ftm2v; - KK_FLOAT dtf_half = 0.5 * dtf_final; + KK_FLOAT dtf_final = dtv * static_cast(force->ftm2v); + KK_FLOAT dtf_half = static_cast(0.5) * dtf_final; Kokkos::parallel_for("min_fire/integrate", nlocal, LAMMPS_LAMBDA(const int i) { KK_FLOAT mass_val = (l_rmass.data() ? l_rmass(i) : l_mass(l_type(i))); KK_FLOAT dtfm = dtf_final / mass_val; KK_FLOAT dtfm_half = dtf_half / mass_val; if (INTEGRATOR == EULERIMPLICIT || INTEGRATOR == LEAPFROG) { - l_v(i,0) += dtfm * l_f(i,0); - l_v(i,1) += dtfm * l_f(i,1); - l_v(i,2) += dtfm * l_f(i,2); + l_v(i,0) += dtfm * static_cast(l_f(i,0)); + l_v(i,1) += dtfm * static_cast(l_f(i,1)); + l_v(i,2) += dtfm * static_cast(l_f(i,2)); if (vdotfall > 0.0) { - l_v(i,0) = scale1 * l_v(i,0) + scale2 * l_f(i,0); - l_v(i,1) = scale1 * l_v(i,1) + scale2 * l_f(i,1); - l_v(i,2) = scale1 * l_v(i,2) + scale2 * l_f(i,2); + l_v(i,0) = scale1 * l_v(i,0) + scale2 * static_cast(l_f(i,0)); + l_v(i,1) = scale1 * l_v(i,1) + scale2 * static_cast(l_f(i,1)); + l_v(i,2) = scale1 * l_v(i,2) + scale2 * static_cast(l_f(i,2)); if (ABCFLAG) { // make sure that the displacement is not larger than dmax - if (fabs(l_v(i,0)*dtv) > l_dmax) l_v(i,0) = l_dmax/dtv * l_v(i,0)/fabs(l_v(i,0)); - if (fabs(l_v(i,1)*dtv) > l_dmax) l_v(i,1) = l_dmax/dtv * l_v(i,1)/fabs(l_v(i,1)); - if (fabs(l_v(i,2)*dtv) > l_dmax) l_v(i,2) = l_dmax/dtv * l_v(i,2)/fabs(l_v(i,2)); + if (Kokkos::fabs(l_v(i,0)*dtv) > l_dmax_kk) l_v(i,0) = l_dmax_kk/dtv * l_v(i,0)/Kokkos::fabs(l_v(i,0)); + if (Kokkos::fabs(l_v(i,1)*dtv) > l_dmax_kk) l_v(i,1) = l_dmax_kk/dtv * l_v(i,1)/Kokkos::fabs(l_v(i,1)); + if (Kokkos::fabs(l_v(i,2)*dtv) > l_dmax_kk) l_v(i,2) = l_dmax_kk/dtv * l_v(i,2)/Kokkos::fabs(l_v(i,2)); } } l_x(i,0) += dtv * l_v(i,0); l_x(i,1) += dtv * l_v(i,1); l_x(i,2) += dtv * l_v(i,2); } else if (INTEGRATOR == VERLET) { - l_v(i,0) += dtfm_half * l_f(i,0); - l_v(i,1) += dtfm_half * l_f(i,1); - l_v(i,2) += dtfm_half * l_f(i,2); + l_v(i,0) += dtfm_half * static_cast(l_f(i,0)); + l_v(i,1) += dtfm_half * static_cast(l_f(i,1)); + l_v(i,2) += dtfm_half * static_cast(l_f(i,2)); if (vdotfall > 0.0) { - l_v(i,0) = scale1 * l_v(i,0) + scale2 * l_f(i,0); - l_v(i,1) = scale1 * l_v(i,1) + scale2 * l_f(i,1); - l_v(i,2) = scale1 * l_v(i,2) + scale2 * l_f(i,2); + l_v(i,0) = scale1 * l_v(i,0) + scale2 * static_cast(l_f(i,0)); + l_v(i,1) = scale1 * l_v(i,1) + scale2 * static_cast(l_f(i,1)); + l_v(i,2) = scale1 * l_v(i,2) + scale2 * static_cast(l_f(i,2)); if (ABCFLAG) { // make sure that the displacement is not larger than dmax - if (fabs(l_v(i,0)*dtv) > l_dmax) l_v(i,0) = l_dmax/dtv * l_v(i,0)/fabs(l_v(i,0)); - if (fabs(l_v(i,1)*dtv) > l_dmax) l_v(i,1) = l_dmax/dtv * l_v(i,1)/fabs(l_v(i,1)); - if (fabs(l_v(i,2)*dtv) > l_dmax) l_v(i,2) = l_dmax/dtv * l_v(i,2)/fabs(l_v(i,2)); + if (Kokkos::fabs(l_v(i,0)*dtv) > l_dmax_kk) l_v(i,0) = l_dmax_kk/dtv * l_v(i,0)/Kokkos::fabs(l_v(i,0)); + if (Kokkos::fabs(l_v(i,1)*dtv) > l_dmax_kk) l_v(i,1) = l_dmax_kk/dtv * l_v(i,1)/Kokkos::fabs(l_v(i,1)); + if (Kokkos::fabs(l_v(i,2)*dtv) > l_dmax_kk) l_v(i,2) = l_dmax_kk/dtv * l_v(i,2)/Kokkos::fabs(l_v(i,2)); } } l_x(i,0) += dtv * l_v(i,0); @@ -292,22 +295,22 @@ int MinFireKokkos::run_iterate(int maxiter) { l_x(i,2) += dtv * l_v(i,2); } else if (INTEGRATOR == EULEREXPLICIT) { if (vdotfall > 0.0) { - l_v(i,0) = scale1 * l_v(i,0) + scale2 * l_f(i,0); - l_v(i,1) = scale1 * l_v(i,1) + scale2 * l_f(i,1); - l_v(i,2) = scale1 * l_v(i,2) + scale2 * l_f(i,2); + l_v(i,0) = scale1 * l_v(i,0) + scale2 * static_cast(l_f(i,0)); + l_v(i,1) = scale1 * l_v(i,1) + scale2 * static_cast(l_f(i,1)); + l_v(i,2) = scale1 * l_v(i,2) + scale2 * static_cast(l_f(i,2)); if (ABCFLAG) { // make sure that the displacement is not larger than dmax - if (fabs(l_v(i,0)*dtv) > l_dmax) l_v(i,0) = l_dmax/dtv * l_v(i,0)/fabs(l_v(i,0)); - if (fabs(l_v(i,1)*dtv) > l_dmax) l_v(i,1) = l_dmax/dtv * l_v(i,1)/fabs(l_v(i,1)); - if (fabs(l_v(i,2)*dtv) > l_dmax) l_v(i,2) = l_dmax/dtv * l_v(i,2)/fabs(l_v(i,2)); + if (Kokkos::fabs(l_v(i,0)*dtv) > l_dmax_kk) l_v(i,0) = l_dmax_kk/dtv * l_v(i,0)/Kokkos::fabs(l_v(i,0)); + if (Kokkos::fabs(l_v(i,1)*dtv) > l_dmax_kk) l_v(i,1) = l_dmax_kk/dtv * l_v(i,1)/Kokkos::fabs(l_v(i,1)); + if (Kokkos::fabs(l_v(i,2)*dtv) > l_dmax_kk) l_v(i,2) = l_dmax_kk/dtv * l_v(i,2)/Kokkos::fabs(l_v(i,2)); } } l_x(i,0) += dtv * l_v(i,0); l_x(i,1) += dtv * l_v(i,1); l_x(i,2) += dtv * l_v(i,2); - l_v(i,0) += dtfm * l_f(i,0); - l_v(i,1) += dtfm * l_f(i,1); - l_v(i,2) += dtfm * l_f(i,2); + l_v(i,0) += dtfm * static_cast(l_f(i,0)); + l_v(i,1) += dtfm * static_cast(l_f(i,1)); + l_v(i,2) += dtfm * static_cast(l_f(i,2)); } }); @@ -320,9 +323,9 @@ int MinFireKokkos::run_iterate(int maxiter) { atomKK->sync(Device, V_MASK | F_MASK); Kokkos::parallel_for("min_fire/verlet_v_final", nlocal, LAMMPS_LAMBDA(const int i) { KK_FLOAT dtfm_half = dtf_half / (l_rmass.data() ? l_rmass(i) : l_mass(l_type(i))); - l_v(i,0) += dtfm_half * l_f(i,0); - l_v(i,1) += dtfm_half * l_f(i,1); - l_v(i,2) += dtfm_half * l_f(i,2); + l_v(i,0) += dtfm_half * static_cast(l_f(i,0)); + l_v(i,1) += dtfm_half * static_cast(l_f(i,1)); + l_v(i,2) += dtfm_half * static_cast(l_f(i,2)); }); atomKK->modified(Device, V_MASK); } @@ -333,7 +336,7 @@ int MinFireKokkos::run_iterate(int maxiter) { // ------------------------------------------------- if (update->etol > 0.0 && ntimestep - last_negative > delaystep) { bool local_converged = (fabs(ecurrent - eprevious) < - update->etol * 0.5 * (fabs(ecurrent) + fabs(eprevious) + EPS_ENERGY)); + update->etol * 0.5 * (fabs(ecurrent) + fabs(eprevious) + static_cast(EPS_ENERGY))); if (update->multireplica == 0) { if (local_converged) return ETOL; @@ -351,7 +354,7 @@ int MinFireKokkos::run_iterate(int maxiter) { // Corrected FTOL Check // ------------------------------------------------- if (update->ftol > 0.0) { - KK_FLOAT fdotf = (normstyle == MAX) ? fnorm_max() : (normstyle == INF ? fnorm_inf() : fnorm_sqr()); + double fdotf = (normstyle == MAX) ? fnorm_max() : (normstyle == INF ? fnorm_inf() : fnorm_sqr()); bool local_converged = (fdotf < update->ftol * update->ftol); if (update->multireplica == 0) { diff --git a/src/KOKKOS/min_kokkos.cpp b/src/KOKKOS/min_kokkos.cpp index 51f7512469f..9f6d47caf6c 100644 --- a/src/KOKKOS/min_kokkos.cpp +++ b/src/KOKKOS/min_kokkos.cpp @@ -624,14 +624,14 @@ double MinKokkos::fnorm_sqr() if constexpr (F_LAYOUTRIGHT) { auto l_fvec = fvec; Kokkos::parallel_reduce(nvec, LAMMPS_LAMBDA(int i, double& local_norm2_sqr) { - local_norm2_sqr += l_fvec[i]*l_fvec[i]; + local_norm2_sqr += static_cast(l_fvec[i]*l_fvec[i]); },local_norm2_sqr); } else { auto l_f = atomKK->k_f.view_device(); Kokkos::parallel_reduce(atom->nlocal, LAMMPS_LAMBDA(int i, double& local_norm2_sqr) { - local_norm2_sqr += l_f(i,0)*l_f(i,0); - local_norm2_sqr += l_f(i,1)*l_f(i,1); - local_norm2_sqr += l_f(i,2)*l_f(i,2); + local_norm2_sqr += static_cast(l_f(i,0)*l_f(i,0)); + local_norm2_sqr += static_cast(l_f(i,1)*l_f(i,1)); + local_norm2_sqr += static_cast(l_f(i,2)*l_f(i,2)); },local_norm2_sqr); } } @@ -661,14 +661,14 @@ double MinKokkos::fnorm_inf() if constexpr (F_LAYOUTRIGHT) { auto l_fvec = fvec; Kokkos::parallel_reduce(nvec, LAMMPS_LAMBDA(int i, double& local_norm_inf) { - local_norm_inf = MAX(l_fvec[i]*l_fvec[i],local_norm_inf); + local_norm_inf = MAX(static_cast(l_fvec[i]*l_fvec[i]),local_norm_inf); },Kokkos::Max(local_norm_inf)); } else { auto l_f = atomKK->k_f.view_device(); Kokkos::parallel_reduce(atom->nlocal, LAMMPS_LAMBDA(int i, double& local_norm_inf) { - local_norm_inf = MAX(l_f(i,0)*l_f(i,0),local_norm_inf); - local_norm_inf = MAX(l_f(i,1)*l_f(i,1),local_norm_inf); - local_norm_inf = MAX(l_f(i,2)*l_f(i,2),local_norm_inf); + local_norm_inf = MAX(static_cast(l_f(i,0)*l_f(i,0)),local_norm_inf); + local_norm_inf = MAX(static_cast(l_f(i,1)*l_f(i,1)),local_norm_inf); + local_norm_inf = MAX(static_cast(l_f(i,2)*l_f(i,2)),local_norm_inf); },Kokkos::Max(local_norm_inf)); } } @@ -698,13 +698,13 @@ double MinKokkos::fnorm_max() if constexpr (F_LAYOUTRIGHT) { auto l_fvec = fvec; Kokkos::parallel_reduce(nvec, LAMMPS_LAMBDA(int i, double& local_norm_max) { - double fdotf = l_fvec[i]*l_fvec[i]+l_fvec[i+1]*l_fvec[i+1]+l_fvec[i+2]*l_fvec[i+2]; + double fdotf = static_cast(l_fvec[i]*l_fvec[i]+l_fvec[i+1]*l_fvec[i+1]+l_fvec[i+2]*l_fvec[i+2]); local_norm_max = MAX(fdotf,local_norm_max); },Kokkos::Max(local_norm_max)); } else { auto l_f = atomKK->k_f.view_device(); Kokkos::parallel_reduce(atom->nlocal, LAMMPS_LAMBDA(int i, double& local_norm_max) { - double fdotf = l_f(i,0)*l_f(i,0)+l_f(i,1)*l_f(i,1)+l_f(i,2)*l_f(i,2); + double fdotf = static_cast(l_f(i,0)*l_f(i,0)+l_f(i,1)*l_f(i,1)+l_f(i,2)*l_f(i,2)); local_norm_max = MAX(fdotf,local_norm_max); },Kokkos::Max(local_norm_max)); } diff --git a/src/KOKKOS/min_linesearch_kokkos.cpp b/src/KOKKOS/min_linesearch_kokkos.cpp index 5e8ede0f88f..3b628c5baf7 100644 --- a/src/KOKKOS/min_linesearch_kokkos.cpp +++ b/src/KOKKOS/min_linesearch_kokkos.cpp @@ -191,15 +191,15 @@ int MinLineSearchKokkos::linemin_quadratic(double eoriginal, double &alpha) if constexpr (F_LAYOUTRIGHT) { auto l_fvec = fvec; Kokkos::parallel_reduce(nvec, LAMMPS_LAMBDA(const int& i, double& fdothme) { - fdothme += l_fvec[i]*l_h[i]; + fdothme += static_cast(l_fvec[i]*static_cast(l_h[i])); },fdothme); } else { auto l_f = atomKK->k_f.view_device(); Kokkos::parallel_reduce(atom->nlocal, LAMMPS_LAMBDA(const int& i, double& fdothme) { const int j = i*3; - fdothme += l_f(i,0)*l_h[j]; - fdothme += l_f(i,1)*l_h[j+1]; - fdothme += l_f(i,2)*l_h[j+2]; + fdothme += static_cast(l_f(i,0)*static_cast(l_h[j])); + fdothme += static_cast(l_f(i,1)*static_cast(l_h[j+1])); + fdothme += static_cast(l_f(i,2)*static_cast(l_h[j+2])); },fdothme); } } @@ -226,7 +226,7 @@ int MinLineSearchKokkos::linemin_quadratic(double eoriginal, double &alpha) auto l_h = h; Kokkos::parallel_reduce(nvec, LAMMPS_LAMBDA(const int& i, double& hme) { - hme = MAX(hme,fabs(l_h[i])); + hme = MAX(hme,fabs(static_cast(l_h[i]))); },Kokkos::Max(hme)); } MPI_Allreduce(&hme,&hmaxall,1,MPI_DOUBLE,MPI_MAX,world); @@ -286,24 +286,24 @@ int MinLineSearchKokkos::linemin_quadratic(double eoriginal, double &alpha) if constexpr (F_LAYOUTRIGHT) { auto l_fvec = fvec; Kokkos::parallel_reduce(nvec, LAMMPS_LAMBDA(const int& i, s_KK_double2& sdot) { - sdot.d0 += l_fvec[i]*l_fvec[i]; - sdot.d1 += l_fvec[i]*l_h[i]; + sdot.d0 += static_cast(l_fvec[i]*l_fvec[i]); + sdot.d1 += static_cast(l_fvec[i])*l_h[i]; },sdot); } else { auto l_f = atomKK->k_f.view_device(); Kokkos::parallel_reduce(atom->nlocal, LAMMPS_LAMBDA(const int& i, s_KK_double2& sdot) { - sdot.d0 += l_f(i,0)*l_f(i,0); - sdot.d0 += l_f(i,1)*l_f(i,1); - sdot.d0 += l_f(i,2)*l_f(i,2); + sdot.d0 += static_cast(l_f(i,0)*l_f(i,0)); + sdot.d0 += static_cast(l_f(i,1)*l_f(i,1)); + sdot.d0 += static_cast(l_f(i,2)*l_f(i,2)); const int j = i*3; - sdot.d1 += l_f(i,0)*l_h[j]; - sdot.d1 += l_f(i,1)*l_h[j+1]; - sdot.d1 += l_f(i,2)*l_h[j+2]; + sdot.d1 += static_cast(l_f(i,0))*l_h[j]; + sdot.d1 += static_cast(l_f(i,1))*l_h[j+1]; + sdot.d1 += static_cast(l_f(i,2))*l_h[j+2]; },sdot); } } - dot = sdot.d1; + dot = static_cast(sdot.d1); MPI_Allreduce(&dot,&dotall,1,MPI_DOUBLE,MPI_SUM,world); if (nextra_global) { @@ -408,7 +408,7 @@ double MinLineSearchKokkos::alpha_step(double alpha, int resetflag) auto l_h = h; Kokkos::parallel_for(nvec, LAMMPS_LAMBDA(const int& i) { - l_xvec[i] += alpha*l_h[i]; + l_xvec[i] += static_cast(alpha)*l_h[i]; }); } @@ -442,25 +442,25 @@ double MinLineSearchKokkos::compute_dir_deriv(double &ff) if constexpr (F_LAYOUTRIGHT) { auto l_fvec = fvec; Kokkos::parallel_reduce(nvec, LAMMPS_LAMBDA(const int& i, s_KK_double2& sdot) { - sdot.d0 += l_fvec[i]*l_fvec[i]; - sdot.d1 += l_fvec[i]*l_h[i]; + sdot.d0 += static_cast(l_fvec[i]*l_fvec[i]); + sdot.d1 += static_cast(l_fvec[i])*l_h[i]; },sdot); } else { auto l_f = atomKK->k_f.view_device(); Kokkos::parallel_reduce(atom->nlocal, LAMMPS_LAMBDA(const int& i, s_KK_double2& sdot) { - sdot.d0 += l_f(i,0)*l_f(i,0); - sdot.d0 += l_f(i,1)*l_f(i,1); - sdot.d0 += l_f(i,2)*l_f(i,2); + sdot.d0 += static_cast(l_f(i,0)*l_f(i,0)); + sdot.d0 += static_cast(l_f(i,1)*l_f(i,1)); + sdot.d0 += static_cast(l_f(i,2)*l_f(i,2)); const int j = i*3; - sdot.d1 += l_f(i,0)*l_h[j]; - sdot.d1 += l_f(i,1)*l_h[j+1]; - sdot.d1 += l_f(i,2)*l_h[j+2]; + sdot.d1 += static_cast(l_f(i,0))*l_h[j]; + sdot.d1 += static_cast(l_f(i,1))*l_h[j+1]; + sdot.d1 += static_cast(l_f(i,2))*l_h[j+2]; },sdot); } } - dot[0] = sdot.d0; - dot[1] = sdot.d1; + dot[0] = static_cast(sdot.d0); + dot[1] = static_cast(sdot.d1); MPI_Allreduce(dot,dotall,2,MPI_DOUBLE,MPI_SUM,world); if (nextra_global) { diff --git a/src/KOKKOS/nbin_kokkos.cpp b/src/KOKKOS/nbin_kokkos.cpp index 45b25bf2ce8..4469a1a599d 100644 --- a/src/KOKKOS/nbin_kokkos.cpp +++ b/src/KOKKOS/nbin_kokkos.cpp @@ -131,7 +131,7 @@ template KOKKOS_INLINE_FUNCTION void NBinKokkos::binatomsItem(const int &i) const { - const int ibin = coord2bin(x(i, 0), x(i, 1), x(i, 2)); + const int ibin = coord2bin(static_cast(x(i, 0)), static_cast(x(i, 1)), static_cast(x(i, 2))); atom2bin(i) = ibin; const int ac = Kokkos::atomic_fetch_add(&bincount[ibin], (int)1); diff --git a/src/KOKKOS/nbin_ssa_kokkos.cpp b/src/KOKKOS/nbin_ssa_kokkos.cpp index 596cd55077d..b709f9b3bb1 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.cpp +++ b/src/KOKKOS/nbin_ssa_kokkos.cpp @@ -225,7 +225,7 @@ KOKKOS_INLINE_FUNCTION void NBinSSAKokkos::binIDAtomsItem(const int &i, int &update) const { int loc[3]; - const int ibin = coord2bin(x(i, 0), x(i, 1), x(i, 2), &(loc[0])); + const int ibin = coord2bin(static_cast(x(i, 0)), static_cast(x(i, 1)), static_cast(x(i, 2)), &(loc[0])); binID(i) = ibin; // Find the bounding box of the local atoms in the bins @@ -245,7 +245,7 @@ template KOKKOS_INLINE_FUNCTION void NBinSSAKokkos::binIDGhostsItem(const int &i, int &update) const { - const int iAIR = coord2ssaAIR(x(i, 0), x(i, 1), x(i, 2)); + const int iAIR = coord2ssaAIR(static_cast(x(i, 0)), static_cast(x(i, 1)), static_cast(x(i, 2))); binID(i) = iAIR; if (iAIR > 0) { // include only ghost atoms in an AIR const int ac = Kokkos::atomic_fetch_add(&gbincount[iAIR], (int)1); diff --git a/src/KOKKOS/neigh_bond_kokkos.cpp b/src/KOKKOS/neigh_bond_kokkos.cpp index 4d1e5988b6e..b1205895eae 100644 --- a/src/KOKKOS/neigh_bond_kokkos.cpp +++ b/src/KOKKOS/neigh_bond_kokkos.cpp @@ -414,9 +414,9 @@ void NeighBondKokkos::operator()(TagNeighBondBondCheck, const int &m const int j = v_bondlist(m,1); double dxstart,dystart,dzstart; double dx,dy,dz; - dxstart = dx = x(i,0) - x(j,0); - dystart = dy = x(i,1) - x(j,1); - dzstart = dz = x(i,2) - x(j,2); + dxstart = dx = static_cast(x(i,0) - x(j,0)); + dystart = dy = static_cast(x(i,1) - x(j,1)); + dzstart = dz = static_cast(x(i,2) - x(j,2)); minimum_image(dx,dy,dz); if (dx != dxstart || dy != dystart || dz != dzstart) flag = 1; } @@ -617,19 +617,19 @@ void NeighBondKokkos::operator()(TagNeighBondAngleCheck, const int & const int k = v_anglelist(m,2); double dxstart,dystart,dzstart; double dx,dy,dz; - dxstart = dx = x(i,0) - x(j,0); - dystart = dy = x(i,1) - x(j,1); - dzstart = dz = x(i,2) - x(j,2); + dxstart = dx = static_cast(x(i,0) - x(j,0)); + dystart = dy = static_cast(x(i,1) - x(j,1)); + dzstart = dz = static_cast(x(i,2) - x(j,2)); minimum_image(dx,dy,dz); if (dx != dxstart || dy != dystart || dz != dzstart) flag = 1; - dxstart = dx = x(i,0) - x(k,0); - dystart = dy = x(i,1) - x(k,1); - dzstart = dz = x(i,2) - x(k,2); + dxstart = dx = static_cast(x(i,0) - x(k,0)); + dystart = dy = static_cast(x(i,1) - x(k,1)); + dzstart = dz = static_cast(x(i,2) - x(k,2)); minimum_image(dx,dy,dz); if (dx != dxstart || dy != dystart || dz != dzstart) flag = 1; - dxstart = dx = x(j,0) - x(k,0); - dystart = dy = x(j,1) - x(k,1); - dzstart = dz = x(j,2) - x(k,2); + dxstart = dx = static_cast(x(j,0) - x(k,0)); + dystart = dy = static_cast(x(j,1) - x(k,1)); + dzstart = dz = static_cast(x(j,2) - x(k,2)); minimum_image(dx,dy,dz); if (dx != dxstart || dy != dystart || dz != dzstart) flag = 1; } @@ -843,34 +843,34 @@ void NeighBondKokkos::operator()(TagNeighBondDihedralCheck, const in const int l = list(m,3); double dxstart,dystart,dzstart; double dx,dy,dz; - dxstart = dx = x(i,0) - x(j,0); - dystart = dy = x(i,1) - x(j,1); - dzstart = dz = x(i,2) - x(j,2); + dxstart = dx = static_cast(x(i,0) - x(j,0)); + dystart = dy = static_cast(x(i,1) - x(j,1)); + dzstart = dz = static_cast(x(i,2) - x(j,2)); minimum_image(dx,dy,dz); if (dx != dxstart || dy != dystart || dz != dzstart) flag = 1; - dxstart = dx = x(i,0) - x(k,0); - dystart = dy = x(i,1) - x(k,1); - dzstart = dz = x(i,2) - x(k,2); + dxstart = dx = static_cast(x(i,0) - x(k,0)); + dystart = dy = static_cast(x(i,1) - x(k,1)); + dzstart = dz = static_cast(x(i,2) - x(k,2)); minimum_image(dx,dy,dz); if (dx != dxstart || dy != dystart || dz != dzstart) flag = 1; - dxstart = dx = x(i,0) - x(l,0); - dystart = dy = x(i,1) - x(l,1); - dzstart = dz = x(i,2) - x(l,2); + dxstart = dx = static_cast(x(i,0) - x(l,0)); + dystart = dy = static_cast(x(i,1) - x(l,1)); + dzstart = dz = static_cast(x(i,2) - x(l,2)); minimum_image(dx,dy,dz); if (dx != dxstart || dy != dystart || dz != dzstart) flag = 1; - dxstart = dx = x(j,0) - x(k,0); - dystart = dy = x(j,1) - x(k,1); - dzstart = dz = x(j,2) - x(k,2); + dxstart = dx = static_cast(x(j,0) - x(k,0)); + dystart = dy = static_cast(x(j,1) - x(k,1)); + dzstart = dz = static_cast(x(j,2) - x(k,2)); minimum_image(dx,dy,dz); if (dx != dxstart || dy != dystart || dz != dzstart) flag = 1; - dxstart = dx = x(j,0) - x(l,0); - dystart = dy = x(j,1) - x(l,1); - dzstart = dz = x(j,2) - x(l,2); + dxstart = dx = static_cast(x(j,0) - x(l,0)); + dystart = dy = static_cast(x(j,1) - x(l,1)); + dzstart = dz = static_cast(x(j,2) - x(l,2)); minimum_image(dx,dy,dz); if (dx != dxstart || dy != dystart || dz != dzstart) flag = 1; - dxstart = dx = x(k,0) - x(l,0); - dystart = dy = x(k,1) - x(l,1); - dzstart = dz = x(k,2) - x(l,2); + dxstart = dx = static_cast(x(k,0) - x(l,0)); + dystart = dy = static_cast(x(k,1) - x(l,1)); + dzstart = dz = static_cast(x(k,2) - x(l,2)); minimum_image(dx,dy,dz); if (dx != dxstart || dy != dystart || dz != dzstart) flag = 1; } @@ -1061,22 +1061,22 @@ int NeighBondKokkos::closest_image(const int i, int j) const { if (j < 0) return j; - const double xi0 = x(i,0); - const double xi1 = x(i,1); - const double xi2 = x(i,2); + const double xi0 = static_cast(x(i,0)); + const double xi1 = static_cast(x(i,1)); + const double xi2 = static_cast(x(i,2)); int closest = j; - double delx = xi0 - x(j,0); - double dely = xi1 - x(j,1); - double delz = xi2 - x(j,2); + double delx = xi0 - static_cast(x(j,0)); + double dely = xi1 - static_cast(x(j,1)); + double delz = xi2 - static_cast(x(j,2)); double rsqmin = delx*delx + dely*dely + delz*delz; double rsq; while (d_sametag[j] >= 0) { j = d_sametag[j]; - delx = xi0 - x(j,0); - dely = xi1 - x(j,1); - delz = xi2 - x(j,2); + delx = xi0 - static_cast(x(j,0)); + dely = xi1 - static_cast(x(j,1)); + delz = xi2 - static_cast(x(j,2)); rsq = delx*delx + dely*dely + delz*delz; if (rsq < rsqmin) { rsqmin = rsq; diff --git a/src/KOKKOS/neighbor_kokkos.cpp b/src/KOKKOS/neighbor_kokkos.cpp index 41c5386bb8c..0777f7c1958 100644 --- a/src/KOKKOS/neighbor_kokkos.cpp +++ b/src/KOKKOS/neighbor_kokkos.cpp @@ -208,9 +208,9 @@ template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void NeighborKokkos::operator()(TagNeighborCheckDistance, const int &i, int &flag) const { - const double delx = x.view()(i,0) - xhold.view()(i,0); - const double dely = x.view()(i,1) - xhold.view()(i,1); - const double delz = x.view()(i,2) - xhold.view()(i,2); + const double delx = static_cast(x.view()(i,0) - xhold.view()(i,0)); + const double dely = static_cast(x.view()(i,1) - xhold.view()(i,1)); + const double delz = static_cast(x.view()(i,2) - xhold.view()(i,2)); const double rsq = delx*delx + dely*dely + delz*delz; if (rsq > deltasq) flag = 1; } diff --git a/src/KOKKOS/npair_halffull_kokkos.cpp b/src/KOKKOS/npair_halffull_kokkos.cpp index d25c21cd095..cd9486273d8 100644 --- a/src/KOKKOS/npair_halffull_kokkos.cpp +++ b/src/KOKKOS/npair_halffull_kokkos.cpp @@ -91,9 +91,9 @@ void NPairHalffullKokkos::operator()(TagNPairHalfful const int i = d_ilist_full(ii); double xtmp,ytmp,ztmp; if (NEWTON || TRIM) { - xtmp = x(i,0); - ytmp = x(i,1); - ztmp = x(i,2); + xtmp = static_cast(x(i,0)); + ytmp = static_cast(x(i,1)); + ztmp = static_cast(x(i,2)); } // loop over full neighbor list @@ -114,25 +114,25 @@ void NPairHalffullKokkos::operator()(TagNPairHalfful if (j < nlocal) { if (i > j) continue; } else if (TRI) { - if (fabs(x(j,2)-ztmp) > delta) { - if (x(j,2) < ztmp) continue; - } else if (fabs(x(j,1)-ytmp) > delta) { - if (x(j,1) < ytmp) continue; + if (fabs(static_cast(x(j,2))-ztmp) > delta) { + if (static_cast(x(j,2)) < ztmp) continue; + } else if (fabs(static_cast(x(j,1))-ytmp) > delta) { + if (static_cast(x(j,1)) < ytmp) continue; } else { - if (x(j,0) < xtmp) continue; + if (static_cast(x(j,0)) < xtmp) continue; } } else { - if (x(j,2) < ztmp) continue; - if (x(j,2) == ztmp) { - if (x(j,1) < ytmp) continue; - if (x(j,1) == ytmp && x(j,0) < xtmp) continue; + if (static_cast(x(j,2)) < ztmp) continue; + if (static_cast(x(j,2)) == ztmp) { + if (static_cast(x(j,1)) < ytmp) continue; + if (static_cast(x(j,1)) == ytmp && static_cast(x(j,0)) < xtmp) continue; } } if (TRIM) { - const double delx = xtmp - x(j,0); - const double dely = ytmp - x(j,1); - const double delz = ztmp - x(j,2); + const double delx = xtmp - static_cast(x(j,0)); + const double dely = ytmp - static_cast(x(j,1)); + const double delz = ztmp - static_cast(x(j,2)); const double rsq = delx*delx + dely*dely + delz*delz; if (rsq > cutsq_custom) continue; @@ -142,9 +142,9 @@ void NPairHalffullKokkos::operator()(TagNPairHalfful } else if (j > i) { if (TRIM) { - const double delx = xtmp - x(j,0); - const double dely = ytmp - x(j,1); - const double delz = ztmp - x(j,2); + const double delx = xtmp - static_cast(x(j,0)); + const double dely = ytmp - static_cast(x(j,1)); + const double delz = ztmp - static_cast(x(j,2)); const double rsq = delx*delx + dely*dely + delz*delz; if (rsq > cutsq_custom) continue; diff --git a/src/KOKKOS/npair_kokkos.cpp b/src/KOKKOS/npair_kokkos.cpp index 403cbeba8b9..aacb8a7d7d3 100644 --- a/src/KOKKOS/npair_kokkos.cpp +++ b/src/KOKKOS/npair_kokkos.cpp @@ -425,9 +425,9 @@ void NeighborKokkosExecute:: const AtomNeighbors neighbors_i = neigh_transpose ? neigh_list.get_neighbors_transpose(i) : neigh_list.get_neighbors(i); - const double xtmp = x(i, 0); - const double ytmp = x(i, 1); - const double ztmp = x(i, 2); + const double xtmp = static_cast(x(i, 0)); + const double ytmp = static_cast(x(i, 1)); + const double ztmp = static_cast(x(i, 2)); const int itype = type(i); tagint itag; if (HalfNeigh && Newton && Tri) itag = tag(i); @@ -447,22 +447,22 @@ void NeighborKokkosExecute:: if (j <= i) continue; if (j >= nlocal) { - if (x(j,2) < ztmp) continue; - if (x(j,2) == ztmp) { - if (x(j,1) < ytmp) continue; - if (x(j,1) == ytmp && x(j,0) < xtmp) continue; + if (static_cast(x(j,2)) < ztmp) continue; + if (static_cast(x(j,2)) == ztmp) { + if (static_cast(x(j,1)) < ytmp) continue; + if (static_cast(x(j,1)) == ytmp && static_cast(x(j,0)) < xtmp) continue; } } const int jtype = type(j); if (exclude && exclusion(i,j,itype,jtype)) continue; - const double delx = xtmp - x(j, 0); - const double dely = ytmp - x(j, 1); - const double delz = ztmp - x(j, 2); + const double delx = xtmp - static_cast(x(j, 0)); + const double dely = ytmp - static_cast(x(j, 1)); + const double delz = ztmp - static_cast(x(j, 2)); const double rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq(itype,jtype)) { + if (rsq <= static_cast(cutneighsq(itype,jtype))) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(i,j); @@ -517,12 +517,12 @@ void NeighborKokkosExecute:: } else if (itag < jtag) { if ((itag+jtag) % 2 == 1) continue; } else { - if (fabs(x(j,2)-ztmp) > delta) { - if (x(j,2) < ztmp) continue; - } else if (fabs(x(j,1)-ytmp) > delta) { - if (x(j,1) < ytmp) continue; + if (fabs(static_cast(x(j,2))-ztmp) > delta) { + if (static_cast(x(j,2)) < ztmp) continue; + } else if (fabs(static_cast(x(j,1))-ytmp) > delta) { + if (static_cast(x(j,1)) < ytmp) continue; } else { - if (x(j,0) < xtmp) continue; + if (static_cast(x(j,0)) < xtmp) continue; } } } @@ -531,12 +531,12 @@ void NeighborKokkosExecute:: const int jtype = type(j); if (exclude && exclusion(i,j,itype,jtype)) continue; - const double delx = xtmp - x(j, 0); - const double dely = ytmp - x(j, 1); - const double delz = ztmp - x(j, 2); + const double delx = xtmp - static_cast(x(j, 0)); + const double dely = ytmp - static_cast(x(j, 1)); + const double delz = ztmp - static_cast(x(j, 2)); const double rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq(itype,jtype)) { + if (rsq <= static_cast(cutneighsq(itype,jtype))) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = NeighborKokkosExecute::find_special(i,j); @@ -672,10 +672,10 @@ void NeighborKokkosExecute::build_ItemGPU(typename Kokkos::TeamPolic if (j <= i) continue; if (j >= nlocal) { - if (x(j,2) < ztmp) continue; - if (x(j,2) == ztmp) { - if (x(j,1) < ytmp) continue; - if (x(j,1) == ytmp && x(j,0) < xtmp) continue; + if (static_cast(x(j,2)) < ztmp) continue; + if (static_cast(x(j,2)) == ztmp) { + if (static_cast(x(j,1)) < ytmp) continue; + if (static_cast(x(j,1)) == ytmp && static_cast(x(j,0)) < xtmp) continue; } } @@ -687,7 +687,7 @@ void NeighborKokkosExecute::build_ItemGPU(typename Kokkos::TeamPolic const double delz = ztmp - other_x[m + 2 * atoms_per_bin]; const double rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq(itype,jtype)) { + if (rsq <= static_cast(cutneighsq(itype,jtype))) { if (molecular != Atom::ATOMIC) { int which = 0; if (!moltemplate) @@ -764,12 +764,12 @@ void NeighborKokkosExecute::build_ItemGPU(typename Kokkos::TeamPolic } else if (itag < jtag) { if ((itag+jtag) % 2 == 1) continue; } else { - if (fabs(x(j,2)-ztmp) > delta) { - if (x(j,2) < ztmp) continue; - } else if (fabs(x(j,1)-ytmp) > delta) { - if (x(j,1) < ytmp) continue; + if (fabs(static_cast(x(j,2))-ztmp) > delta) { + if (static_cast(x(j,2)) < ztmp) continue; + } else if (fabs(static_cast(x(j,1))-ytmp) > delta) { + if (static_cast(x(j,1)) < ytmp) continue; } else { - if (x(j,0) < xtmp) continue; + if (static_cast(x(j,0)) < xtmp) continue; } } } @@ -783,7 +783,7 @@ void NeighborKokkosExecute::build_ItemGPU(typename Kokkos::TeamPolic const double delz = ztmp - other_x[m + 2 * atoms_per_bin]; const double rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq(itype,jtype)) { + if (rsq <= static_cast(cutneighsq(itype,jtype))) { if (molecular != Atom::ATOMIC) { int which = 0; if (!moltemplate) @@ -846,9 +846,9 @@ void NeighborKokkosExecute:: const AtomNeighbors neighbors_i = neigh_transpose ? neigh_list.get_neighbors_transpose(i) : neigh_list.get_neighbors(i); - const double xtmp = x(i, 0); - const double ytmp = x(i, 1); - const double ztmp = x(i, 2); + const double xtmp = static_cast(x(i, 0)); + const double ytmp = static_cast(x(i, 1)); + const double ztmp = static_cast(x(i, 2)); const int itype = type(i); const typename AT::t_int_1d_const_um stencil @@ -874,12 +874,12 @@ void NeighborKokkosExecute:: const int jtype = type[j]; if (exclude && exclusion(i,j,itype,jtype)) continue; - const double delx = xtmp - x(j,0); - const double dely = ytmp - x(j,1); - const double delz = ztmp - x(j,2); + const double delx = xtmp - static_cast(x(j,0)); + const double dely = ytmp - static_cast(x(j,1)); + const double delz = ztmp - static_cast(x(j,2)); const double rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq(itype,jtype)) { + if (rsq <= static_cast(cutneighsq(itype,jtype))) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(i,j); @@ -929,12 +929,12 @@ void NeighborKokkosExecute:: const int jtype = type[j]; if (exclude && exclusion(i,j,itype,jtype)) continue; - const double delx = xtmp - x(j,0); - const double dely = ytmp - x(j,1); - const double delz = ztmp - x(j,2); + const double delx = xtmp - static_cast(x(j,0)); + const double dely = ytmp - static_cast(x(j,1)); + const double delz = ztmp - static_cast(x(j,2)); const double rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq(itype,jtype)) { + if (rsq <= static_cast(cutneighsq(itype,jtype))) { if (n < neigh_list.maxneighs) neighbors_i(n++) = j; else n++; } @@ -1078,7 +1078,7 @@ void NeighborKokkosExecute::build_ItemGhostGPU(typename Kokkos::Team const double delz = ztmp - other_x[m + 2 * atoms_per_bin]; const double rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq(itype,jtype)) { + if (rsq <= static_cast(cutneighsq(itype,jtype))) { if (molecular != Atom::ATOMIC && !ghost) { if (!moltemplate) which = NeighborKokkosExecute::find_special(i,j); @@ -1136,10 +1136,10 @@ void NeighborKokkosExecute:: const AtomNeighbors neighbors_i = neigh_transpose ? neigh_list.get_neighbors_transpose(i) : neigh_list.get_neighbors(i); - const double xtmp = x(i, 0); - const double ytmp = x(i, 1); - const double ztmp = x(i, 2); - const double radi = radius(i); + const double xtmp = static_cast(x(i, 0)); + const double ytmp = static_cast(x(i, 1)); + const double ztmp = static_cast(x(i, 2)); + const double radi = static_cast(radius(i)); const int itype = type(i); tagint itag; if (HalfNeigh && Newton && Tri) itag = tag(i); @@ -1162,21 +1162,21 @@ void NeighborKokkosExecute:: if (j <= i) continue; if (j >= nlocal) { - if (x(j,2) < ztmp) continue; - if (x(j,2) == ztmp) { - if (x(j,1) < ytmp) continue; - if (x(j,1) == ytmp && x(j,0) < xtmp) continue; + if (static_cast(x(j,2)) < ztmp) continue; + if (static_cast(x(j,2)) == ztmp) { + if (static_cast(x(j,1)) < ytmp) continue; + if (static_cast(x(j,1)) == ytmp && static_cast(x(j,0)) < xtmp) continue; } } const int jtype = type(j); if (exclude && exclusion(i,j,itype,jtype)) continue; - const double delx = xtmp - x(j, 0); - const double dely = ytmp - x(j, 1); - const double delz = ztmp - x(j, 2); + const double delx = xtmp - static_cast(x(j, 0)); + const double dely = ytmp - static_cast(x(j, 1)); + const double delz = ztmp - static_cast(x(j, 2)); const double rsq = delx*delx + dely*dely + delz*delz; - const double radsum = radi + radius(j); + const double radsum = radi + static_cast(radius(j)); const double cutsq = (radsum + skin) * (radsum + skin); if (rsq <= cutsq) { @@ -1242,12 +1242,12 @@ void NeighborKokkosExecute:: } else if (itag < jtag) { if ((itag+jtag) % 2 == 1) continue; } else { - if (fabs(x(j,2)-ztmp) > delta) { - if (x(j,2) < ztmp) continue; - } else if (fabs(x(j,1)-ytmp) > delta) { - if (x(j,1) < ytmp) continue; + if (fabs(static_cast(x(j,2))-ztmp) > delta) { + if (static_cast(x(j,2)) < ztmp) continue; + } else if (fabs(static_cast(x(j,1))-ytmp) > delta) { + if (static_cast(x(j,1)) < ytmp) continue; } else { - if (x(j,0) < xtmp) continue; + if (static_cast(x(j,0)) < xtmp) continue; } } } @@ -1256,11 +1256,11 @@ void NeighborKokkosExecute:: const int jtype = type(j); if (exclude && exclusion(i,j,itype,jtype)) continue; - const double delx = xtmp - x(j, 0); - const double dely = ytmp - x(j, 1); - const double delz = ztmp - x(j, 2); + const double delx = xtmp - static_cast(x(j, 0)); + const double dely = ytmp - static_cast(x(j, 1)); + const double delz = ztmp - static_cast(x(j, 2)); const double rsq = delx*delx + dely*dely + delz*delz; - const double radsum = radi + radius(j); + const double radsum = radi + static_cast(radius(j)); const double cutsq = (radsum + skin) * (radsum + skin); if (rsq <= cutsq) { @@ -1390,10 +1390,10 @@ void NeighborKokkosExecute::build_ItemSizeGPU(typename Kokkos::TeamP if (j <= i) continue; if (j >= nlocal) { - if (x(j,2) < ztmp) continue; - if (x(j,2) == ztmp) { - if (x(j,1) < ytmp) continue; - if (x(j,1) == ytmp && x(j,0) < xtmp) continue; + if (static_cast(x(j,2)) < ztmp) continue; + if (static_cast(x(j,2)) == ztmp) { + if (static_cast(x(j,1)) < ytmp) continue; + if (static_cast(x(j,1)) == ytmp && static_cast(x(j,0)) < xtmp) continue; } } @@ -1491,12 +1491,12 @@ void NeighborKokkosExecute::build_ItemSizeGPU(typename Kokkos::TeamP } else if (itag < jtag) { if ((itag+jtag) % 2 == 1) continue; } else { - if (fabs(x(j,2)-ztmp) > delta) { - if (x(j,2) < ztmp) continue; - } else if (fabs(x(j,1)-ytmp) > delta) { - if (x(j,1) < ytmp) continue; + if (fabs(static_cast(x(j,2))-ztmp) > delta) { + if (static_cast(x(j,2)) < ztmp) continue; + } else if (fabs(static_cast(x(j,1))-ytmp) > delta) { + if (static_cast(x(j,1)) < ytmp) continue; } else { - if (x(j,0) < xtmp) continue; + if (static_cast(x(j,0)) < xtmp) continue; } } } diff --git a/src/KOKKOS/npair_skip_kokkos.cpp b/src/KOKKOS/npair_skip_kokkos.cpp index 6e97a12d8d0..b3244aee75d 100644 --- a/src/KOKKOS/npair_skip_kokkos.cpp +++ b/src/KOKKOS/npair_skip_kokkos.cpp @@ -114,9 +114,9 @@ void NPairSkipKokkos::operator()(TagNPairSkipCompute, const int double xtmp,ytmp,ztmp; if (TRIM) { - xtmp = x(i,0); - ytmp = x(i,1); - ztmp = x(i,2); + xtmp = static_cast(x(i,0)); + ytmp = static_cast(x(i,1)); + ztmp = static_cast(x(i,2)); } if (!d_iskip(itype)) { @@ -137,9 +137,9 @@ void NPairSkipKokkos::operator()(TagNPairSkipCompute, const int if (d_ijskip(itype,type(j))) continue; if (TRIM) { - const double delx = xtmp - x(j,0); - const double dely = ytmp - x(j,1); - const double delz = ztmp - x(j,2); + const double delx = xtmp - static_cast(x(j,0)); + const double dely = ytmp - static_cast(x(j,1)); + const double delz = ztmp - static_cast(x(j,2)); const double rsq = delx*delx + dely*dely + delz*delz; if (rsq > cutsq_custom) continue; } diff --git a/src/KOKKOS/npair_ssa_kokkos.cpp b/src/KOKKOS/npair_ssa_kokkos.cpp index ab2427b4503..d92dee8ce08 100644 --- a/src/KOKKOS/npair_ssa_kokkos.cpp +++ b/src/KOKKOS/npair_ssa_kokkos.cpp @@ -557,9 +557,9 @@ void NPairSSAKokkosExecute::build_locals_onePhase(const bool firstTr int n = 0; const AtomNeighbors neighbors_i = neigh_list.get_neighbors(inum); - const double xtmp = x(i, 0); - const double ytmp = x(i, 1); - const double ztmp = x(i, 2); + const double xtmp = static_cast(x(i, 0)); + const double ytmp = static_cast(x(i, 1)); + const double ztmp = static_cast(x(i, 2)); const int itype = type(i); // loop over all local atoms in the current stencil "subphase" @@ -573,11 +573,11 @@ void NPairSSAKokkosExecute::build_locals_onePhase(const bool firstTr const int jtype = type(j); if (exclude && exclusion(i,j,itype,jtype)) continue; - const double delx = xtmp - x(j, 0); - const double dely = ytmp - x(j, 1); - const double delz = ztmp - x(j, 2); + const double delx = xtmp - static_cast(x(j, 0)); + const double dely = ytmp - static_cast(x(j, 1)); + const double delz = ztmp - static_cast(x(j, 2)); const double rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq(itype,jtype)) { + if (rsq <= static_cast(cutneighsq(itype,jtype))) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(i,j); @@ -678,13 +678,13 @@ void NPairSSAKokkosExecute::build_ghosts_onePhase(int workPhase) con int n = 0; const AtomNeighbors neighbors_i = neigh_list.get_neighbors(gNdx); - const double xtmp = x(i, 0); - const double ytmp = x(i, 1); - const double ztmp = x(i, 2); + const double xtmp = static_cast(x(i, 0)); + const double ytmp = static_cast(x(i, 1)); + const double ztmp = static_cast(x(i, 2)); const int itype = type(i); int loc[3]; - const int ibin = coord2bin(x(i, 0), x(i, 1), x(i, 2), &(loc[0])); + const int ibin = coord2bin(static_cast(x(i, 0)), static_cast(x(i, 1)), static_cast(x(i, 2)), &(loc[0])); // loop over AIR ghost atoms in all bins in "full" stencil // Note: the non-AIR ghost atoms have already been filtered out @@ -702,11 +702,11 @@ void NPairSSAKokkosExecute::build_ghosts_onePhase(int workPhase) con const int jtype = type(j); if (exclude && exclusion(i,j,itype,jtype)) continue; - const double delx = xtmp - x(j, 0); - const double dely = ytmp - x(j, 1); - const double delz = ztmp - x(j, 2); + const double delx = xtmp - static_cast(x(j, 0)); + const double dely = ytmp - static_cast(x(j, 1)); + const double delz = ztmp - static_cast(x(j, 2)); const double rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq(itype,jtype)) { + if (rsq <= static_cast(cutneighsq(itype,jtype))) { if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(j,i); diff --git a/src/KOKKOS/npair_trim_kokkos.cpp b/src/KOKKOS/npair_trim_kokkos.cpp index 3df6cf4038c..ae6e80bbc4a 100644 --- a/src/KOKKOS/npair_trim_kokkos.cpp +++ b/src/KOKKOS/npair_trim_kokkos.cpp @@ -91,9 +91,9 @@ void NPairTrimKokkos::operator()(TagNPairTrim, const int &ii) const int n = 0; const int i = d_ilist_copy(ii); - const double xtmp = x(i,0); - const double ytmp = x(i,1); - const double ztmp = x(i,2); + const double xtmp = static_cast(x(i,0)); + const double ytmp = static_cast(x(i,1)); + const double ztmp = static_cast(x(i,2)); // loop over copy neighbor list @@ -105,9 +105,9 @@ void NPairTrimKokkos::operator()(TagNPairTrim, const int &ii) const const int joriginal = d_neighbors_copy(i,jj); const int j = joriginal & NEIGHMASK; - const double delx = xtmp - x(j,0); - const double dely = ytmp - x(j,1); - const double delz = ztmp - x(j,2); + const double delx = xtmp - static_cast(x(j,0)); + const double dely = ytmp - static_cast(x(j,1)); + const double delz = ztmp - static_cast(x(j,2)); const double rsq = delx*delx + dely*dely + delz*delz; if (rsq > cutsq_custom) continue; diff --git a/src/KOKKOS/pair_adp_kokkos.cpp b/src/KOKKOS/pair_adp_kokkos.cpp index 1d924f1e725..1f8af47606b 100644 --- a/src/KOKKOS/pair_adp_kokkos.cpp +++ b/src/KOKKOS/pair_adp_kokkos.cpp @@ -206,7 +206,7 @@ void PairADPKokkos::compute(int eflag_in, int vflag_in) } if (eflag) { - eng_vdwl += ev.evdwl; + eng_vdwl += static_cast(ev.evdwl); ev.evdwl = 0.0; } @@ -267,14 +267,14 @@ void PairADPKokkos::compute(int eflag_in, int vflag_in) if (need_dup) Kokkos::Experimental::contribute(f, dup_f); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -441,31 +441,32 @@ void PairADPKokkos::array2spline() template void PairADPKokkos::interpolate(int n, double delta, double *f, t_hostkkfloat_2d_n7 h_spline, int i) { - for (int m = 1; m <= n; m++) h_spline(i,m,6) = f[m]; + for (int m = 1; m <= n; m++) h_spline(i,m,6) = static_cast(f[m]); h_spline(i,1,5) = h_spline(i,2,6) - h_spline(i,1,6); - h_spline(i,2,5) = 0.5 * (h_spline(i,3,6)-h_spline(i,1,6)); - h_spline(i,n-1,5) = 0.5 * (h_spline(i,n,6)-h_spline(i,n-2,6)); + h_spline(i,2,5) = static_cast(0.5) * (h_spline(i,3,6)-h_spline(i,1,6)); + h_spline(i,n-1,5) = static_cast(0.5) * (h_spline(i,n,6)-h_spline(i,n-2,6)); h_spline(i,n,5) = h_spline(i,n,6) - h_spline(i,n-1,6); for (int m = 3; m <= n-2; m++) h_spline(i,m,5) = ((h_spline(i,m-2,6)-h_spline(i,m+2,6)) + - 8.0*(h_spline(i,m+1,6)-h_spline(i,m-1,6))) / 12.0; + static_cast(8.0)*(h_spline(i,m+1,6)-h_spline(i,m-1,6))) / static_cast(12.0); for (int m = 1; m <= n-1; m++) { - h_spline(i,m,4) = 3.0*(h_spline(i,m+1,6)-h_spline(i,m,6)) - - 2.0*h_spline(i,m,5) - h_spline(i,m+1,5); + h_spline(i,m,4) = static_cast(3.0)*(h_spline(i,m+1,6)-h_spline(i,m,6)) - + static_cast(2.0)*h_spline(i,m,5) - h_spline(i,m+1,5); h_spline(i,m,3) = h_spline(i,m,5) + h_spline(i,m+1,5) - - 2.0*(h_spline(i,m+1,6)-h_spline(i,m,6)); + static_cast(2.0)*(h_spline(i,m+1,6)-h_spline(i,m,6)); } h_spline(i,n,4) = 0.0; h_spline(i,n,3) = 0.0; + const KK_FLOAT delta_kk = static_cast(delta); for (int m = 1; m <= n; m++) { - h_spline(i,m,2) = h_spline(i,m,5)/delta; - h_spline(i,m,1) = 2.0*h_spline(i,m,4)/delta; - h_spline(i,m,0) = 3.0*h_spline(i,m,3)/delta; + h_spline(i,m,2) = h_spline(i,m,5)/delta_kk; + h_spline(i,m,1) = static_cast(2.0)*h_spline(i,m,4)/delta_kk; + h_spline(i,m,0) = static_cast(3.0)*h_spline(i,m,3)/delta_kk; } } @@ -487,16 +488,16 @@ template KOKKOS_INLINE_FUNCTION void PairADPKokkos::operator()(TagPairADPPackForwardComm, const int &i) const { int j = d_sendlist(i); - v_buf[10 * i] = d_fp(j); - v_buf[10 * i + 1] = d_mu(j, 0); - v_buf[10 * i + 2] = d_mu(j, 1); - v_buf[10 * i + 3] = d_mu(j, 2); - v_buf[10 * i + 4] = d_lambda(j, 0); - v_buf[10 * i + 5] = d_lambda(j, 1); - v_buf[10 * i + 6] = d_lambda(j, 2); - v_buf[10 * i + 7] = d_lambda(j, 3); - v_buf[10 * i + 8] = d_lambda(j, 4); - v_buf[10 * i + 9] = d_lambda(j, 5); + v_buf[10 * i] = static_cast(d_fp(j)); + v_buf[10 * i + 1] = static_cast(d_mu(j, 0)); + v_buf[10 * i + 2] = static_cast(d_mu(j, 1)); + v_buf[10 * i + 3] = static_cast(d_mu(j, 2)); + v_buf[10 * i + 4] = static_cast(d_lambda(j, 0)); + v_buf[10 * i + 5] = static_cast(d_lambda(j, 1)); + v_buf[10 * i + 6] = static_cast(d_lambda(j, 2)); + v_buf[10 * i + 7] = static_cast(d_lambda(j, 3)); + v_buf[10 * i + 8] = static_cast(d_lambda(j, 4)); + v_buf[10 * i + 9] = static_cast(d_lambda(j, 5)); } /* ---------------------------------------------------------------------- */ @@ -513,16 +514,16 @@ template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void PairADPKokkos::operator()(TagPairADPUnpackForwardComm, const int &i) const { - d_fp(i + first) = v_buf[10 * i]; - d_mu(i + first, 0) = v_buf[10 * i + 1]; - d_mu(i + first, 1) = v_buf[10 * i + 2]; - d_mu(i + first, 2) = v_buf[10 * i + 3]; - d_lambda(i + first, 0) = v_buf[10 * i + 4]; - d_lambda(i + first, 1) = v_buf[10 * i + 5]; - d_lambda(i + first, 2) = v_buf[10 * i + 6]; - d_lambda(i + first, 3) = v_buf[10 * i + 7]; - d_lambda(i + first, 4) = v_buf[10 * i + 8]; - d_lambda(i + first, 5) = v_buf[10 * i + 9]; + d_fp(i + first) = static_cast(v_buf[10 * i]); + d_mu(i + first, 0) = static_cast(v_buf[10 * i + 1]); + d_mu(i + first, 1) = static_cast(v_buf[10 * i + 2]); + d_mu(i + first, 2) = static_cast(v_buf[10 * i + 3]); + d_lambda(i + first, 0) = static_cast(v_buf[10 * i + 4]); + d_lambda(i + first, 1) = static_cast(v_buf[10 * i + 5]); + d_lambda(i + first, 2) = static_cast(v_buf[10 * i + 6]); + d_lambda(i + first, 3) = static_cast(v_buf[10 * i + 7]); + d_lambda(i + first, 4) = static_cast(v_buf[10 * i + 8]); + d_lambda(i + first, 5) = static_cast(v_buf[10 * i + 9]); } /* ---------------------------------------------------------------------- */ @@ -540,16 +541,16 @@ int PairADPKokkos::pack_forward_comm(int n, int *list, double *buf, for (i = 0; i < n; i++) { j = list[i]; - buf[m++] = h_fp(j); - buf[m++] = h_mu(j, 0); - buf[m++] = h_mu(j, 1); - buf[m++] = h_mu(j, 2); - buf[m++] = h_lambda(j, 0); - buf[m++] = h_lambda(j, 1); - buf[m++] = h_lambda(j, 2); - buf[m++] = h_lambda(j, 3); - buf[m++] = h_lambda(j, 4); - buf[m++] = h_lambda(j, 5); + buf[m++] = static_cast(h_fp(j)); + buf[m++] = static_cast(h_mu(j, 0)); + buf[m++] = static_cast(h_mu(j, 1)); + buf[m++] = static_cast(h_mu(j, 2)); + buf[m++] = static_cast(h_lambda(j, 0)); + buf[m++] = static_cast(h_lambda(j, 1)); + buf[m++] = static_cast(h_lambda(j, 2)); + buf[m++] = static_cast(h_lambda(j, 3)); + buf[m++] = static_cast(h_lambda(j, 4)); + buf[m++] = static_cast(h_lambda(j, 5)); } return m; } @@ -567,16 +568,16 @@ void PairADPKokkos::unpack_forward_comm(int n, int first, double *bu m = 0; last = n + first; for (int i = first; i < last; i++) { - h_fp(i) = buf[m++]; - h_mu(i, 0) = buf[m++]; - h_mu(i, 1) = buf[m++]; - h_mu(i, 2) = buf[m++]; - h_lambda(i, 0) = buf[m++]; - h_lambda(i, 1) = buf[m++]; - h_lambda(i, 2) = buf[m++]; - h_lambda(i, 3) = buf[m++]; - h_lambda(i, 4) = buf[m++]; - h_lambda(i, 5) = buf[m++]; + h_fp(i) = static_cast(buf[m++]); + h_mu(i, 0) = static_cast(buf[m++]); + h_mu(i, 1) = static_cast(buf[m++]); + h_mu(i, 2) = static_cast(buf[m++]); + h_lambda(i, 0) = static_cast(buf[m++]); + h_lambda(i, 1) = static_cast(buf[m++]); + h_lambda(i, 2) = static_cast(buf[m++]); + h_lambda(i, 3) = static_cast(buf[m++]); + h_lambda(i, 4) = static_cast(buf[m++]); + h_lambda(i, 5) = static_cast(buf[m++]); } k_fp.modify_host(); @@ -598,16 +599,16 @@ int PairADPKokkos::pack_reverse_comm(int n, int first, double *buf) m = 0; last = first + n; for (i = first; i < last; i++) { - buf[m++] = h_rho(i); - buf[m++] = h_mu(i,0); - buf[m++] = h_mu(i,1); - buf[m++] = h_mu(i,2); - buf[m++] = h_lambda(i,0); - buf[m++] = h_lambda(i,1); - buf[m++] = h_lambda(i,2); - buf[m++] = h_lambda(i,3); - buf[m++] = h_lambda(i,4); - buf[m++] = h_lambda(i,5); + buf[m++] = static_cast(h_rho(i)); + buf[m++] = static_cast(h_mu(i,0)); + buf[m++] = static_cast(h_mu(i,1)); + buf[m++] = static_cast(h_mu(i,2)); + buf[m++] = static_cast(h_lambda(i,0)); + buf[m++] = static_cast(h_lambda(i,1)); + buf[m++] = static_cast(h_lambda(i,2)); + buf[m++] = static_cast(h_lambda(i,3)); + buf[m++] = static_cast(h_lambda(i,4)); + buf[m++] = static_cast(h_lambda(i,5)); } return m; } @@ -626,16 +627,16 @@ void PairADPKokkos::unpack_reverse_comm(int n, int *list, double *bu m = 0; for (i = 0; i < n; i++) { j = list[i]; - h_rho(j) += buf[m++]; - h_mu(j,0) += buf[m++]; - h_mu(j,1) += buf[m++]; - h_mu(j,2) += buf[m++]; - h_lambda(j,0) += buf[m++]; - h_lambda(j,1) += buf[m++]; - h_lambda(j,2) += buf[m++]; - h_lambda(j,3) += buf[m++]; - h_lambda(j,4) += buf[m++]; - h_lambda(j,5) += buf[m++]; + h_rho(j) += static_cast(buf[m++]); + h_mu(j,0) += static_cast(buf[m++]); + h_mu(j,1) += static_cast(buf[m++]); + h_mu(j,2) += static_cast(buf[m++]); + h_lambda(j,0) += static_cast(buf[m++]); + h_lambda(j,1) += static_cast(buf[m++]); + h_lambda(j,2) += static_cast(buf[m++]); + h_lambda(j,3) += static_cast(buf[m++]); + h_lambda(j,4) += static_cast(buf[m++]); + h_lambda(j,5) += static_cast(buf[m++]); } k_rho.modify_host(); @@ -691,6 +692,9 @@ void PairADPKokkos::operator()(TagPairADPKernelA(cutforcesq); + const KK_FLOAT rdr_kk = static_cast(rdr); + KK_ACC_FLOAT rhotmp = 0.0; KK_FLOAT mutmp[3] = {0.0,0.0,0.0}; KK_FLOAT lambdatmp[6] = {0.0,0.0,0.0,0.0,0.0,0.0}; @@ -704,16 +708,16 @@ void PairADPKokkos::operator()(TagPairADPKernelA(1.0); int m = static_cast (p); m = MIN(m,nr-1); p -= m; - p = MIN(p,1.0); + p = MIN(p,static_cast(1.0)); d_type_ji = d_type2rhor(jtype,itype); - rhotmp += ((d_rhor_spline(d_type_ji,m,3)*p + d_rhor_spline(d_type_ji,m,4))*p + - d_rhor_spline(d_type_ji,m,5))*p + d_rhor_spline(d_type_ji,m,6); + rhotmp += static_cast(((d_rhor_spline(d_type_ji,m,3)*p + d_rhor_spline(d_type_ji,m,4))*p + + d_rhor_spline(d_type_ji,m,5))*p + d_rhor_spline(d_type_ji,m,6)); d_type_ji = d_type2u2r(jtype,itype); KK_FLOAT u2 = ((d_u2r_spline(d_type_ji,m,3)*p + d_u2r_spline(d_type_ji,m,4))*p + @@ -758,7 +762,7 @@ void PairADPKokkos::operator()(TagPairADPKernelA(rhotmp); a_mu(i, 0) += mutmp[0]; a_mu(i, 1) += mutmp[1]; a_mu(i, 2) += mutmp[2]; @@ -784,25 +788,26 @@ void PairADPKokkos::operator()(TagPairADPKernelB, const int & const int i = d_ilist[ii]; const int itype = type(i); - KK_FLOAT p = d_rho[i]*rdrho + 1.0; + const KK_FLOAT rdrho_kk = static_cast(rdrho); + KK_FLOAT p = d_rho[i]*rdrho_kk + static_cast(1.0); int m = static_cast (p); m = MAX(1,MIN(m,nrho-1)); p -= m; - p = MIN(p,1.0); + p = MIN(p,static_cast(1.0)); const int d_type2frho_i = d_type2frho[itype]; d_fp[i] = (d_frho_spline(d_type2frho_i,m,0)*p + d_frho_spline(d_type2frho_i,m,1))*p + d_frho_spline(d_type2frho_i,m,2); if (EFLAG) { KK_FLOAT phi = ((d_frho_spline(d_type2frho_i,m,3)*p + d_frho_spline(d_type2frho_i,m,4))*p + d_frho_spline(d_type2frho_i,m,5))*p + d_frho_spline(d_type2frho_i,m,6); - phi += 0.5*(d_mu(i,0)*d_mu(i,0)+d_mu(i,1)*d_mu(i,1)+d_mu(i,2)*d_mu(i,2)); - phi += 0.5*(d_lambda(i,0)*d_lambda(i,0)+d_lambda(i,1)* + phi += static_cast(0.5)*(d_mu(i,0)*d_mu(i,0)+d_mu(i,1)*d_mu(i,1)+d_mu(i,2)*d_mu(i,2)); + phi += static_cast(0.5)*(d_lambda(i,0)*d_lambda(i,0)+d_lambda(i,1)* d_lambda(i,1)+d_lambda(i,2)*d_lambda(i,2)); - phi += 1.0*(d_lambda(i,3)*d_lambda(i,3)+d_lambda(i,4)* + phi += static_cast(1.0)*(d_lambda(i,3)*d_lambda(i,3)+d_lambda(i,4)* d_lambda(i,4)+d_lambda(i,5)*d_lambda(i,5)); - phi -= 1.0/6.0*(d_lambda(i,0)+d_lambda(i,1)+d_lambda(i,2))* + phi -= static_cast(1.0/6.0)*(d_lambda(i,0)+d_lambda(i,1)+d_lambda(i,2))* (d_lambda(i,0)+d_lambda(i,1)+d_lambda(i,2)); - if (eflag_global) ev.evdwl += phi; - if (eflag_atom) d_eatom[i] += phi; + if (eflag_global) ev.evdwl += static_cast(phi); + if (eflag_atom) d_eatom[i] += static_cast(phi); } } @@ -835,6 +840,10 @@ void PairADPKokkos::operator()(TagPairADPKernelAB, const int const int jnum = d_numneigh[i]; + const KK_FLOAT cutforcesq_kk = static_cast(cutforcesq); + const KK_FLOAT rdr_kk = static_cast(rdr); + const KK_FLOAT rdrho_kk = static_cast(rdrho); + KK_ACC_FLOAT rhotmp = 0.0; KK_ACC_FLOAT mutmp[3] = {0.0,0.0,0.0}; KK_ACC_FLOAT lambdatmp[6] = {0.0,0.0,0.0,0.0,0.0,0.0}; @@ -850,71 +859,71 @@ void PairADPKokkos::operator()(TagPairADPKernelAB, const int const int jtype = type(j); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < cutforcesq) { - KK_FLOAT p = sqrt(rsq)*rdr + 1.0; + if (rsq < cutforcesq_kk) { + KK_FLOAT p = Kokkos::sqrt(rsq)*rdr_kk + static_cast(1.0); int m = static_cast (p); m = MIN(m,nr-1); p -= m; - p = MIN(p,1.0); + p = MIN(p,static_cast(1.0)); d_type_ji = d_type2rhor(jtype,itype); - rhotmp += ((d_rhor_spline(d_type_ji,m,3)*p + d_rhor_spline(d_type_ji,m,4))*p + - d_rhor_spline(d_type_ji,m,5))*p + d_rhor_spline(d_type_ji,m,6); + rhotmp += static_cast(((d_rhor_spline(d_type_ji,m,3)*p + d_rhor_spline(d_type_ji,m,4))*p + + d_rhor_spline(d_type_ji,m,5))*p + d_rhor_spline(d_type_ji,m,6)); d_type_ji = d_type2u2r(jtype,itype); KK_FLOAT u2 = ((d_u2r_spline(d_type_ji,m,3)*p + d_u2r_spline(d_type_ji,m,4))*p + d_u2r_spline(d_type_ji,m,5))*p + d_u2r_spline(d_type_ji,m,6); - mutmp[0] += u2*delx; - mutmp[1] += u2*dely; - mutmp[2] += u2*delz; + mutmp[0] += static_cast(u2*delx); + mutmp[1] += static_cast(u2*dely); + mutmp[2] += static_cast(u2*delz); d_type_ji = d_type2w2r(jtype,itype); KK_FLOAT w2 = ((d_w2r_spline(d_type_ji,m,3)*p + d_w2r_spline(d_type_ji,m,4))*p + d_w2r_spline(d_type_ji,m,5))*p + d_w2r_spline(d_type_ji,m,6); - lambdatmp[0] += w2*delx*delx; - lambdatmp[1] += w2*dely*dely; - lambdatmp[2] += w2*delz*delz; - lambdatmp[3] += w2*dely*delz; - lambdatmp[4] += w2*delx*delz; - lambdatmp[5] += w2*delx*dely; + lambdatmp[0] += static_cast(w2*delx*delx); + lambdatmp[1] += static_cast(w2*dely*dely); + lambdatmp[2] += static_cast(w2*delz*delz); + lambdatmp[3] += static_cast(w2*dely*delz); + lambdatmp[4] += static_cast(w2*delx*delz); + lambdatmp[5] += static_cast(w2*delx*dely); } } - d_rho[i] += rhotmp; + d_rho[i] += static_cast(rhotmp); - d_mu(i, 0) += mutmp[0]; - d_mu(i, 1) += mutmp[1]; - d_mu(i, 2) += mutmp[2]; + d_mu(i, 0) += static_cast(mutmp[0]); + d_mu(i, 1) += static_cast(mutmp[1]); + d_mu(i, 2) += static_cast(mutmp[2]); - d_lambda(i, 0) += lambdatmp[0]; - d_lambda(i, 1) += lambdatmp[1]; - d_lambda(i, 2) += lambdatmp[2]; - d_lambda(i, 3) += lambdatmp[3]; - d_lambda(i, 4) += lambdatmp[4]; - d_lambda(i, 5) += lambdatmp[5]; + d_lambda(i, 0) += static_cast(lambdatmp[0]); + d_lambda(i, 1) += static_cast(lambdatmp[1]); + d_lambda(i, 2) += static_cast(lambdatmp[2]); + d_lambda(i, 3) += static_cast(lambdatmp[3]); + d_lambda(i, 4) += static_cast(lambdatmp[4]); + d_lambda(i, 5) += static_cast(lambdatmp[5]); // fp = derivative of embedding energy at each atom // phi = embedding energy at each atom - KK_FLOAT p = d_rho[i]*rdrho + 1.0; + KK_FLOAT p = d_rho[i]*rdrho_kk + static_cast(1.0); int m = static_cast (p); m = MAX(1,MIN(m,nrho-1)); p -= m; - p = MIN(p,1.0); + p = MIN(p,static_cast(1.0)); const int d_type2frho_i = d_type2frho[itype]; d_fp[i] = (d_frho_spline(d_type2frho_i,m,0)*p + d_frho_spline(d_type2frho_i,m,1))*p + d_frho_spline(d_type2frho_i,m,2); if (EFLAG) { KK_FLOAT phi = ((d_frho_spline(d_type2frho_i,m,3)*p + d_frho_spline(d_type2frho_i,m,4))*p + d_frho_spline(d_type2frho_i,m,5))*p + d_frho_spline(d_type2frho_i,m,6); - phi += 0.5*(d_mu(i,0)*d_mu(i,0)+d_mu(i,1)*d_mu(i,1)+d_mu(i,2)*d_mu(i,2)); - phi += 0.5*(d_lambda(i,0)*d_lambda(i,0)+d_lambda(i,1)* + phi += static_cast(0.5)*(d_mu(i,0)*d_mu(i,0)+d_mu(i,1)*d_mu(i,1)+d_mu(i,2)*d_mu(i,2)); + phi += static_cast(0.5)*(d_lambda(i,0)*d_lambda(i,0)+d_lambda(i,1)* d_lambda(i,1)+d_lambda(i,2)*d_lambda(i,2)); - phi += 1.0*(d_lambda(i,3)*d_lambda(i,3)+d_lambda(i,4)* + phi += static_cast(1.0)*(d_lambda(i,3)*d_lambda(i,3)+d_lambda(i,4)* d_lambda(i,4)+d_lambda(i,5)*d_lambda(i,5)); - phi -= 1.0/6.0*(d_lambda(i,0)+d_lambda(i,1)+d_lambda(i,2))* + phi -= static_cast(1.0/6.0)*(d_lambda(i,0)+d_lambda(i,1)+d_lambda(i,2))* (d_lambda(i,0)+d_lambda(i,1)+d_lambda(i,2)); - if (eflag_global) ev.evdwl += phi; - if (eflag_atom) d_eatom[i] += phi; + if (eflag_global) ev.evdwl += static_cast(phi); + if (eflag_atom) d_eatom[i] += static_cast(phi); } } @@ -950,6 +959,9 @@ void PairADPKokkos::operator()(TagPairADPKernelC(cutforcesq); + const KK_FLOAT rdr_kk = static_cast(rdr); + KK_ACC_FLOAT fxtmp = 0.0; KK_ACC_FLOAT fytmp = 0.0; KK_ACC_FLOAT fztmp = 0.0; @@ -963,13 +975,13 @@ void PairADPKokkos::operator()(TagPairADPKernelC(1.0); int m = static_cast (p); m = MIN(m,nr-1); p -= m; - p = MIN(p,1.0); + p = MIN(p,static_cast(1.0)); // rhoip = derivative of (density at atom j due to atom i) // rhojp = derivative of (density at atom i due to atom j) @@ -1013,7 +1025,7 @@ void PairADPKokkos::operator()(TagPairADPKernelC(1.0)/r; const KK_FLOAT phi = z2*recip; const KK_FLOAT phip = z2p*recip - phi*recip; const KK_FLOAT psip = d_fp[i]*rhojp + d_fp[j]*rhoip + phip; @@ -1031,37 +1043,37 @@ void PairADPKokkos::operator()(TagPairADPKernelC(2.0)*sumlamxy*delx*dely+ + static_cast(2.0)*sumlamxz*delx*delz+static_cast(2.0)*sumlamyz*dely*delz; const KK_FLOAT nu = sumlamxx+sumlamyy+sumlamzz; - const KK_FLOAT adpx = -1.0*(delmux*u2 + trdelmu*u2p*delx*recip + - 2.0*w2*(sumlamxx*delx+sumlamxy*dely+sumlamxz*delz) + - w2p*delx*recip*tradellam - 1.0/3.0*nu*(w2p*r+2.0*w2)*delx); - const KK_FLOAT adpy = -1.0*(delmuy*u2 + trdelmu*u2p*dely*recip + - 2.0*w2*(sumlamxy*delx+sumlamyy*dely+sumlamyz*delz) + - w2p*dely*recip*tradellam - 1.0/3.0*nu*(w2p*r+2.0*w2)*dely); - const KK_FLOAT adpz = -1.0*(delmuz*u2 + trdelmu*u2p*delz*recip + - 2.0*w2*(sumlamxz*delx+sumlamyz*dely+sumlamzz*delz) + - w2p*delz*recip*tradellam - 1.0/3.0*nu*(w2p*r+2.0*w2)*delz); + const KK_FLOAT adpx = static_cast(-1.0)*(delmux*u2 + trdelmu*u2p*delx*recip + + static_cast(2.0)*w2*(sumlamxx*delx+sumlamxy*dely+sumlamxz*delz) + + w2p*delx*recip*tradellam - static_cast(1.0/3.0)*nu*(w2p*r+static_cast(2.0)*w2)*delx); + const KK_FLOAT adpy = static_cast(-1.0)*(delmuy*u2 + trdelmu*u2p*dely*recip + + static_cast(2.0)*w2*(sumlamxy*delx+sumlamyy*dely+sumlamyz*delz) + + w2p*dely*recip*tradellam - static_cast(1.0/3.0)*nu*(w2p*r+static_cast(2.0)*w2)*dely); + const KK_FLOAT adpz = static_cast(-1.0)*(delmuz*u2 + trdelmu*u2p*delz*recip + + static_cast(2.0)*w2*(sumlamxz*delx+sumlamyz*dely+sumlamzz*delz) + + w2p*delz*recip*tradellam - static_cast(1.0/3.0)*nu*(w2p*r+static_cast(2.0)*w2)*delz); KK_FLOAT fx = delx*fpair + adpx; KK_FLOAT fy = dely*fpair + adpy; KK_FLOAT fz = delz*fpair + adpz; - fxtmp += fx; - fytmp += fy; - fztmp += fz; + fxtmp += static_cast(fx); + fytmp += static_cast(fy); + fztmp += static_cast(fz); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) -= fx; - a_f(j,1) -= fy; - a_f(j,2) -= fz; + a_f(j,0) -= static_cast(fx); + a_f(j,1) -= static_cast(fy); + a_f(j,2) -= static_cast(fz); } if (EVFLAG) { if (eflag) { - ev.evdwl += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(1.0):static_cast(0.5))*static_cast(phi); } if (vflag_either || eflag_atom) this->template ev_tally_xyz(ev,i,j,phi,fx,fy,fz,delx,dely,delz); @@ -1107,12 +1119,12 @@ void PairADPKokkos::ev_tally_xyz(EV_FLOAT &ev, const int &i, const i if (EFLAG) { if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; if (NEIGHFLAG!=FULL) { - if (NEWTON_PAIR || i < nlocal) a_eatom[i] += epairhalf; - if (NEWTON_PAIR || j < nlocal) a_eatom[j] += epairhalf; + if (NEWTON_PAIR || i < nlocal) a_eatom[i] += static_cast(epairhalf); + if (NEWTON_PAIR || j < nlocal) a_eatom[j] += static_cast(epairhalf); } else { - a_eatom[i] += epairhalf; + a_eatom[i] += static_cast(epairhalf); } } } @@ -1128,56 +1140,56 @@ void PairADPKokkos::ev_tally_xyz(EV_FLOAT &ev, const int &i, const i if (vflag_global) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } if (NEWTON_PAIR || j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } if (vflag_atom) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; + a_vatom(i,0) += static_cast(0.5)*static_cast(v0); + a_vatom(i,1) += static_cast(0.5)*static_cast(v1); + a_vatom(i,2) += static_cast(0.5)*static_cast(v2); + a_vatom(i,3) += static_cast(0.5)*static_cast(v3); + a_vatom(i,4) += static_cast(0.5)*static_cast(v4); + a_vatom(i,5) += static_cast(0.5)*static_cast(v5); } if (NEWTON_PAIR || j < nlocal) { - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; + a_vatom(j,0) += static_cast(0.5)*static_cast(v0); + a_vatom(j,1) += static_cast(0.5)*static_cast(v1); + a_vatom(j,2) += static_cast(0.5)*static_cast(v2); + a_vatom(j,3) += static_cast(0.5)*static_cast(v3); + a_vatom(j,4) += static_cast(0.5)*static_cast(v4); + a_vatom(j,5) += static_cast(0.5)*static_cast(v5); } } else { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; + a_vatom(i,0) += static_cast(0.5)*static_cast(v0); + a_vatom(i,1) += static_cast(0.5)*static_cast(v1); + a_vatom(i,2) += static_cast(0.5)*static_cast(v2); + a_vatom(i,3) += static_cast(0.5)*static_cast(v3); + a_vatom(i,4) += static_cast(0.5)*static_cast(v4); + a_vatom(i,5) += static_cast(0.5)*static_cast(v5); } } } diff --git a/src/KOKKOS/pair_beck_kokkos.cpp b/src/KOKKOS/pair_beck_kokkos.cpp index 86feb783284..c755eb3d5b8 100644 --- a/src/KOKKOS/pair_beck_kokkos.cpp +++ b/src/KOKKOS/pair_beck_kokkos.cpp @@ -101,24 +101,24 @@ void PairBeckKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms copymode = 1; EV_FLOAT ev = pair_compute,void >(this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -148,7 +148,7 @@ compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c const KK_FLOAT alpha = STACKPARAMS ? m_params[itype][jtype].alpha : params(itype,jtype).alpha; const KK_FLOAT beta = STACKPARAMS ? m_params[itype][jtype].beta : params(itype,jtype).beta; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT r5 = rsq*rsq*r; const KK_FLOAT rinv = static_cast(1.0) / r; const KK_FLOAT term1 = aaij*aaij + rsq; @@ -157,7 +157,7 @@ compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c + static_cast(6.0)*rsq; const KK_FLOAT term4 = alpha + r5*beta; const KK_FLOAT term5 = alpha + static_cast(6.0)*r5*beta; - const KK_FLOAT force_beck = AA*exp(static_cast(-1.0)*r*term4)*term5 + const KK_FLOAT force_beck = AA*Kokkos::exp(static_cast(-1.0)*r*term4)*term5 - BB*r*term2*term3; return force_beck * rinv; } @@ -174,13 +174,13 @@ compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c const KK_FLOAT alpha = STACKPARAMS ? m_params[itype][jtype].alpha : params(itype,jtype).alpha; const KK_FLOAT beta = STACKPARAMS ? m_params[itype][jtype].beta : params(itype,jtype).beta; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT r5 = rsq*rsq*r; const KK_FLOAT term1 = aaij*aaij + rsq; const KK_FLOAT term1inv = static_cast(1.0) / term1; const KK_FLOAT term4 = alpha + r5*beta; const KK_FLOAT term6 = powint(term1,-3); - return AA*exp(static_cast(-1.0)*r*term4) + return AA*Kokkos::exp(static_cast(-1.0)*r*term4) - BB*term6*(static_cast(1.0) + (static_cast(2.709) + static_cast(3.0)*aaij*aaij)*term1inv); } diff --git a/src/KOKKOS/pair_bondval_kokkos.cpp b/src/KOKKOS/pair_bondval_kokkos.cpp index 97c68a0f8ba..7fb1a363519 100644 --- a/src/KOKKOS/pair_bondval_kokkos.cpp +++ b/src/KOKKOS/pair_bondval_kokkos.cpp @@ -194,7 +194,7 @@ void PairBondValKokkos::compute(int eflag_in, int vflag_in) } if (eflag) { - eng_vdwl += ev.evdwl; + eng_vdwl += static_cast(ev.evdwl); ev.evdwl = 0.0; } @@ -275,14 +275,14 @@ void PairBondValKokkos::compute(int eflag_in, int vflag_in) if (need_dup) Kokkos::Experimental::contribute(f, dup_f); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -372,19 +372,19 @@ double PairBondValKokkos::init_one(int i, int j) { double cutone = PairBondVal::init_one(i,j); - k_params.view_host()(i,j).r0 = r0[i][j]; - k_params.view_host()(i,j).alpha = alpha[i][j]; - k_params.view_host()(i,j).sparam = sparam[i][j]; - k_params.view_host()(i,j).v0 = v0[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).r0 = static_cast(r0[i][j]); + k_params.view_host()(i,j).alpha = static_cast(alpha[i][j]); + k_params.view_host()(i,j).sparam = static_cast(sparam[i][j]); + k_params.view_host()(i,j).v0 = static_cast(v0[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } if (i==j){ - k_energy0.view_host()(i) = energy0[i]; + k_energy0.view_host()(i) = static_cast(energy0[i]); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; @@ -412,7 +412,7 @@ template KOKKOS_INLINE_FUNCTION void PairBondValKokkos::operator()(TagPairBondValPackForwardComm, const int &i) const { int j = d_sendlist(i); - v_buf[i] = d_fp[j]; + v_buf[i] = static_cast(d_fp[j]); } /* ---------------------------------------------------------------------- */ @@ -428,7 +428,7 @@ void PairBondValKokkos::unpack_forward_comm_kokkos(int n, int first_ template KOKKOS_INLINE_FUNCTION void PairBondValKokkos::operator()(TagPairBondValUnpackForwardComm, const int &i) const { - d_fp[i + first] = v_buf[i]; + d_fp[i + first] = static_cast(v_buf[i]); } /* ---------------------------------------------------------------------- */ @@ -443,7 +443,7 @@ int PairBondValKokkos::pack_forward_comm(int n, int *list, double *b for (i = 0; i < n; i++) { j = list[i]; - buf[i] = h_fp[j]; + buf[i] = static_cast(h_fp[j]); } return n; } @@ -456,7 +456,7 @@ void PairBondValKokkos::unpack_forward_comm(int n, int first, double k_fp.sync_host(); for (int i = 0; i < n; i++) { - h_fp[i + first] = buf[i]; + h_fp[i + first] = static_cast(buf[i]); } k_fp.modify_host(); @@ -473,7 +473,7 @@ int PairBondValKokkos::pack_reverse_comm(int n, int first, double *b m = 0; last = first + n; - for (i = first; i < last; i++) buf[m++] = h_s0[i]; + for (i = first; i < last; i++) buf[m++] = static_cast(h_s0[i]); return m; } @@ -489,7 +489,7 @@ void PairBondValKokkos::unpack_reverse_comm(int n, int *list, double m = 0; for (i = 0; i < n; i++) { j = list[i]; - h_s0[j] += buf[m++]; + h_s0[j] += static_cast(buf[m++]); } k_s0.modify_host(); @@ -538,12 +538,12 @@ void PairBondValKokkos::operator()(TagPairBondValKernelA(0.0)){ if (rsq < (d_cutsq(itype,jtype))) { - KK_FLOAT r = sqrt(rsq); - s0tmp += pow((params(itype,jtype).r0)/r,(params(itype,jtype).alpha)); + KK_FLOAT r = Kokkos::sqrt(rsq); + s0tmp += static_cast(Kokkos::pow((params(itype,jtype).r0)/r,(params(itype,jtype).alpha))); if (NEWTON_PAIR || j < nlocal) { - a_s0[j] += pow((params(jtype,itype).r0)/r,(params(jtype,itype).alpha)); + a_s0[j] += static_cast(Kokkos::pow((params(jtype,itype).r0)/r,(params(jtype,itype).alpha))); } } } @@ -566,13 +566,14 @@ void PairBondValKokkos::operator()(TagPairBondValKernelB, con const int i = d_ilist[ii]; const int itype = type(i); - KK_FLOAT s = d_s0[i] - (params(itype,itype).v0); + const KK_FLOAT power_global_kk = static_cast(power_global); + KK_FLOAT s = static_cast(d_s0[i]) - (params(itype,itype).v0); KK_FLOAT ss = s*s; - d_fp[i] = (params(itype,itype).sparam)*power_global*s; + d_fp[i] = (params(itype,itype).sparam)*power_global_kk*s; if (EFLAG) { KK_FLOAT phi = (params(itype,itype).sparam)*ss+(d_energy0(itype)); - if (eflag_global) ev.evdwl += phi; - if (eflag_atom) d_eatom[i] += phi; + if (eflag_global) ev.evdwl += static_cast(phi); + if (eflag_atom) d_eatom[i] += static_cast(phi); } } @@ -614,10 +615,10 @@ void PairBondValKokkos::operator()(TagPairBondValKernelAB, co const int jtype = type(j); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if((params(itype,jtype).alpha)!=0.0){ + if((params(itype,jtype).alpha)!=static_cast(0.0)){ if (rsq < (d_cutsq(itype,jtype))) { - KK_FLOAT r = sqrt(rsq); - s0tmp += pow((params(itype,jtype).r0)/r,(params(itype,jtype).alpha)); + KK_FLOAT r = Kokkos::sqrt(rsq); + s0tmp += static_cast(Kokkos::pow((params(itype,jtype).r0)/r,(params(itype,jtype).alpha))); } } } @@ -627,13 +628,14 @@ void PairBondValKokkos::operator()(TagPairBondValKernelAB, co // fp = derivative of embedding energy at each atom // phi = embedding energy at each atom - KK_FLOAT s = d_s0[i]- (params(itype,itype).v0); + const KK_FLOAT power_global_kk = static_cast(power_global); + KK_FLOAT s = static_cast(d_s0[i])- (params(itype,itype).v0); KK_FLOAT ss = s*s; - d_fp[i] = (params(itype,itype).sparam)*power_global*s; + d_fp[i] = (params(itype,itype).sparam)*power_global_kk*s; if (EFLAG) { KK_FLOAT phi = (params(itype,itype).sparam)*ss+(d_energy0(itype)); - if (eflag_global) ev.evdwl += phi; - if (eflag_atom) d_eatom[i] += phi; + if (eflag_global) ev.evdwl += static_cast(phi); + if (eflag_atom) d_eatom[i] += static_cast(phi); } } @@ -680,27 +682,27 @@ void PairBondValKokkos::operator()(TagPairBondValKernelC(0.0)){ if (rsq < (d_cutsq(itype,jtype))) { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT recip = 1.0/r; - const KK_FLOAT Aij = (params(itype,jtype).alpha)*pow((params(itype,jtype).r0)*recip,(params(itype,jtype).alpha))*recip; + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT recip = static_cast(1.0)/r; + const KK_FLOAT Aij = (params(itype,jtype).alpha)*Kokkos::pow((params(itype,jtype).r0)*recip,(params(itype,jtype).alpha))*recip; const KK_FLOAT psip = (d_fp[i]+d_fp[j])*Aij; const KK_FLOAT fpair = psip*recip; - fxtmp += delx*fpair; - fytmp += dely*fpair; - fztmp += delz*fpair; + fxtmp += static_cast(delx*fpair); + fytmp += static_cast(dely*fpair); + fztmp += static_cast(delz*fpair); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) -= delx*fpair; - a_f(j,1) -= dely*fpair; - a_f(j,2) -= delz*fpair; + a_f(j,0) -= static_cast(delx*fpair); + a_f(j,1) -= static_cast(dely*fpair); + a_f(j,2) -= static_cast(delz*fpair); } if (EVFLAG) { if (eflag) { - ev.evdwl += 0.0; + ev.evdwl += static_cast(0.0); } if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,0.0,fpair,delx,dely,delz); @@ -746,12 +748,12 @@ void PairBondValKokkos::ev_tally(EV_FLOAT &ev, const int &i, const i if (EFLAG) { if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; if (NEIGHFLAG!=FULL) { - if (NEWTON_PAIR || i < nlocal) a_eatom[i] += epairhalf; - if (NEWTON_PAIR || j < nlocal) a_eatom[j] += epairhalf; + if (NEWTON_PAIR || i < nlocal) a_eatom[i] += static_cast(epairhalf); + if (NEWTON_PAIR || j < nlocal) a_eatom[j] += static_cast(epairhalf); } else { - a_eatom[i] += epairhalf; + a_eatom[i] += static_cast(epairhalf); } } } @@ -767,56 +769,56 @@ void PairBondValKokkos::ev_tally(EV_FLOAT &ev, const int &i, const i if (vflag_global) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } if (NEWTON_PAIR || j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } } if (vflag_atom) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; + a_vatom(i,0) += static_cast(static_cast(0.5)*v0); + a_vatom(i,1) += static_cast(static_cast(0.5)*v1); + a_vatom(i,2) += static_cast(static_cast(0.5)*v2); + a_vatom(i,3) += static_cast(static_cast(0.5)*v3); + a_vatom(i,4) += static_cast(static_cast(0.5)*v4); + a_vatom(i,5) += static_cast(static_cast(0.5)*v5); } if (NEWTON_PAIR || j < nlocal) { - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; + a_vatom(j,0) += static_cast(static_cast(0.5)*v0); + a_vatom(j,1) += static_cast(static_cast(0.5)*v1); + a_vatom(j,2) += static_cast(static_cast(0.5)*v2); + a_vatom(j,3) += static_cast(static_cast(0.5)*v3); + a_vatom(j,4) += static_cast(static_cast(0.5)*v4); + a_vatom(j,5) += static_cast(static_cast(0.5)*v5); } } else { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; + a_vatom(i,0) += static_cast(static_cast(0.5)*v0); + a_vatom(i,1) += static_cast(static_cast(0.5)*v1); + a_vatom(i,2) += static_cast(static_cast(0.5)*v2); + a_vatom(i,3) += static_cast(static_cast(0.5)*v3); + a_vatom(i,4) += static_cast(static_cast(0.5)*v4); + a_vatom(i,5) += static_cast(static_cast(0.5)*v5); } } } diff --git a/src/KOKKOS/pair_bondval_vec_kokkos.cpp b/src/KOKKOS/pair_bondval_vec_kokkos.cpp index 75a14cb30f1..03694480862 100644 --- a/src/KOKKOS/pair_bondval_vec_kokkos.cpp +++ b/src/KOKKOS/pair_bondval_vec_kokkos.cpp @@ -196,7 +196,7 @@ void PairBondValVecKokkos::compute(int eflag_in, int vflag_in) } if (eflag) { - eng_vdwl += ev.evdwl; + eng_vdwl += static_cast(ev.evdwl); ev.evdwl = 0.0; } @@ -277,14 +277,14 @@ void PairBondValVecKokkos::compute(int eflag_in, int vflag_in) if (need_dup) Kokkos::Experimental::contribute(f, dup_f); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -369,16 +369,16 @@ double PairBondValVecKokkos::init_one(int i, int j) { double cutone = PairBondValVec::init_one(i,j); - k_params.view_host()(i,j).r0 = r0[i][j]; - k_params.view_host()(i,j).alpha = alpha[i][j]; - k_params.view_host()(i,j).bvvsparam = bvvsparam[i][j]; - k_params.view_host()(i,j).bvvv0 = bvvv0[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).r0 = static_cast(r0[i][j]); + k_params.view_host()(i,j).alpha = static_cast(alpha[i][j]); + k_params.view_host()(i,j).bvvsparam = static_cast(bvvsparam[i][j]); + k_params.view_host()(i,j).bvvv0 = static_cast(bvvv0[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; @@ -409,9 +409,9 @@ template KOKKOS_INLINE_FUNCTION void PairBondValVecKokkos::operator()(TagPairBondValVecPackForwardComm, const int &i) const { int j = d_sendlist(i); - v_buf[i*3+0] = d_Di(j,0); - v_buf[i*3+1] = d_Di(j,1); - v_buf[i*3+2] = d_Di(j,2); + v_buf[i*3+0] = static_cast(d_Di(j,0)); + v_buf[i*3+1] = static_cast(d_Di(j,1)); + v_buf[i*3+2] = static_cast(d_Di(j,2)); } /* ---------------------------------------------------------------------- */ @@ -427,9 +427,9 @@ void PairBondValVecKokkos::unpack_forward_comm_kokkos(int n, int fir template KOKKOS_INLINE_FUNCTION void PairBondValVecKokkos::operator()(TagPairBondValVecUnpackForwardComm, const int &i) const { - d_Di(i + first,0) = v_buf[i*3+0]; - d_Di(i + first,1) = v_buf[i*3+1]; - d_Di(i + first,2) = v_buf[i*3+2]; + d_Di(i + first,0) = static_cast(v_buf[i*3+0]); + d_Di(i + first,1) = static_cast(v_buf[i*3+1]); + d_Di(i + first,2) = static_cast(v_buf[i*3+2]); } /* ---------------------------------------------------------------------- */ @@ -445,9 +445,9 @@ int PairBondValVecKokkos::pack_forward_comm(int n, int *list, double for (i = 0; i < n; i++) { j = list[i]; - buf[m++] = h_Di(j,0); - buf[m++] = h_Di(j,1); - buf[m++] = h_Di(j,2); + buf[m++] = static_cast(h_Di(j,0)); + buf[m++] = static_cast(h_Di(j,1)); + buf[m++] = static_cast(h_Di(j,2)); } return m; @@ -461,9 +461,9 @@ void PairBondValVecKokkos::unpack_forward_comm(int n, int first, dou k_Di.sync_host(); int m = 0; for (int i = 0; i < n; i++) { - h_Di(i + first,0) = buf[m++]; - h_Di(i + first,1) = buf[m++]; - h_Di(i + first,2) = buf[m++]; + h_Di(i + first,0) = static_cast(buf[m++]); + h_Di(i + first,1) = static_cast(buf[m++]); + h_Di(i + first,2) = static_cast(buf[m++]); } k_Di.modify_host(); @@ -481,9 +481,9 @@ int PairBondValVecKokkos::pack_reverse_comm(int n, int first, double m = 0; last = first + n; for (i = first; i < last; i++){ - buf[m++]= h_s0(i,0); - buf[m++]= h_s0(i,1); - buf[m++]= h_s0(i,2); + buf[m++]= static_cast(h_s0(i,0)); + buf[m++]= static_cast(h_s0(i,1)); + buf[m++]= static_cast(h_s0(i,2)); } return m; } @@ -500,9 +500,9 @@ void PairBondValVecKokkos::unpack_reverse_comm(int n, int *list, dou m = 0; for (i = 0; i < n; i++) { j = list[i]; - h_s0(j,0) += buf[m++]; - h_s0(j,1) += buf[m++]; - h_s0(j,2) += buf[m++]; + h_s0(j,0) += static_cast(buf[m++]); + h_s0(j,1) += static_cast(buf[m++]); + h_s0(j,2) += static_cast(buf[m++]); } k_s0.modify_host(); @@ -557,16 +557,16 @@ void PairBondValVecKokkos::operator()(TagPairBondValVecKernelA(1.0)/Kokkos::sqrt(rsq); - const KK_FLOAT Aij = pow((params(itype,jtype).r0)*recip,(params(itype,jtype).alpha))*recip; - s0xtmp += Aij * (delx); - s0ytmp += Aij * (dely); - s0ztmp += Aij * (delz); + const KK_FLOAT Aij = Kokkos::pow((params(itype,jtype).r0)*recip,(params(itype,jtype).alpha))*recip; + s0xtmp += static_cast(Aij * (delx)); + s0ytmp += static_cast(Aij * (dely)); + s0ztmp += static_cast(Aij * (delz)); if (NEWTON_PAIR || j < nlocal) { - a_s0(j,0) -= Aij * (delx); - a_s0(j,1) -= Aij * (dely); - a_s0(j,2) -= Aij * (delz); + a_s0(j,0) -= static_cast(Aij * (delx)); + a_s0(j,1) -= static_cast(Aij * (dely)); + a_s0(j,2) -= static_cast(Aij * (delz)); } } } @@ -589,18 +589,22 @@ void PairBondValVecKokkos::operator()(TagPairBondValVecKernelB(power_global); + const KK_FLOAT s0x_kk = static_cast(d_s0(i,0)); + const KK_FLOAT s0y_kk = static_cast(d_s0(i,1)); + const KK_FLOAT s0z_kk = static_cast(d_s0(i,2)); + KK_FLOAT s = s0x_kk*s0x_kk+s0y_kk*s0y_kk+s0z_kk*s0z_kk-(params(itype,itype).bvvv0)*(params(itype,itype).bvvv0); KK_FLOAT ss = s*s; - d_Di(i,0) = (params(itype,itype).bvvsparam)*power_global*2.0*d_s0(i,0)*s; - d_Di(i,1) = (params(itype,itype).bvvsparam)*power_global*2.0*d_s0(i,1)*s; - d_Di(i,2) = (params(itype,itype).bvvsparam)*power_global*2.0*d_s0(i,2)*s; + d_Di(i,0) = (params(itype,itype).bvvsparam)*power_global_kk*static_cast(2.0)*s0x_kk*s; + d_Di(i,1) = (params(itype,itype).bvvsparam)*power_global_kk*static_cast(2.0)*s0y_kk*s; + d_Di(i,2) = (params(itype,itype).bvvsparam)*power_global_kk*static_cast(2.0)*s0z_kk*s; //printf("i: %d, d_Di(i,0): %f, d_Di(i,1): %f, d_Di(i,2): %f\n", i, d_Di(i,0), d_Di(i,1), d_Di(i,2)); if (EFLAG) { KK_FLOAT phi = (params(itype,itype).bvvsparam)*ss; //printf("i: %d, phi: %f", i, phi); - if (eflag_global) ev.evdwl += phi; - if (eflag_atom) d_eatom[i] += phi; + if (eflag_global) ev.evdwl += static_cast(phi); + if (eflag_atom) d_eatom[i] += static_cast(phi); } } @@ -646,27 +650,31 @@ void PairBondValVecKokkos::operator()(TagPairBondValVecKernelAB(1.0)/Kokkos::sqrt(rsq); + const KK_FLOAT Aij = Kokkos::pow((params(itype,jtype).r0)*recip,(params(itype,jtype).alpha))*recip; + s0xtmp += static_cast(Aij * (delx)); + s0ytmp += static_cast(Aij * (dely)); + s0ztmp += static_cast(Aij * (delz)); } } d_s0(i,0) += s0xtmp; d_s0(i,1) += s0ytmp; d_s0(i,2) += s0ztmp; - KK_FLOAT s = d_s0(i,0)*d_s0(i,0)+d_s0(i,1)*d_s0(i,1)+d_s0(i,2)*d_s0(i,2)-(params(itype,itype).bvvv0)*(params(itype,itype).bvvv0); + const KK_FLOAT power_global_kk = static_cast(power_global); + const KK_FLOAT s0x_kk = static_cast(d_s0(i,0)); + const KK_FLOAT s0y_kk = static_cast(d_s0(i,1)); + const KK_FLOAT s0z_kk = static_cast(d_s0(i,2)); + KK_FLOAT s = s0x_kk*s0x_kk+s0y_kk*s0y_kk+s0z_kk*s0z_kk-(params(itype,itype).bvvv0)*(params(itype,itype).bvvv0); KK_FLOAT ss = s*s; - d_Di(i,0) = (params(itype,itype).bvvsparam)*power_global*2.0*d_s0(i,0)*s; - d_Di(i,1) = (params(itype,itype).bvvsparam)*power_global*2.0*d_s0(i,1)*s; - d_Di(i,2) = (params(itype,itype).bvvsparam)*power_global*2.0*d_s0(i,2)*s; + d_Di(i,0) = (params(itype,itype).bvvsparam)*power_global_kk*static_cast(2.0)*s0x_kk*s; + d_Di(i,1) = (params(itype,itype).bvvsparam)*power_global_kk*static_cast(2.0)*s0y_kk*s; + d_Di(i,2) = (params(itype,itype).bvvsparam)*power_global_kk*static_cast(2.0)*s0z_kk*s; if (EFLAG) { KK_FLOAT phi = (params(itype,itype).bvvsparam)*ss; - if (eflag_global) ev.evdwl += phi; - if (eflag_atom) d_eatom[i] += phi; + if (eflag_global) ev.evdwl += static_cast(phi); + if (eflag_atom) d_eatom[i] += static_cast(phi); } } @@ -715,42 +723,42 @@ void PairBondValVecKokkos::operator()(TagPairBondValVecKernelC(1.0)/r; const KK_FLOAT recip2 = recip*recip; - const KK_FLOAT Aij = pow((params(itype,jtype).r0)*recip,(params(itype,jtype).alpha))*recip; - const KK_FLOAT Eij = ((params(itype,jtype).alpha)+1.0)*recip2; + const KK_FLOAT Aij = Kokkos::pow((params(itype,jtype).r0)*recip,(params(itype,jtype).alpha))*recip; + const KK_FLOAT Eij = ((params(itype,jtype).alpha)+static_cast(1.0))*recip2; KK_FLOAT fx = (d_Di(j,0)-d_Di(i,0))*Aij + (d_Di(i,0)-d_Di(j,0))*Eij*delx*delx*Aij + (d_Di(i,1)-d_Di(j,1))*Eij*delx*dely*Aij + (d_Di(i,2)-d_Di(j,2))*Eij*delx*delz*Aij; - fxtmp += fx; + fxtmp += static_cast(fx); KK_FLOAT fy = (d_Di(j,1)-d_Di(i,1))*Aij + (d_Di(i,1)-d_Di(j,1))*Eij*dely*dely*Aij + (d_Di(i,2)-d_Di(j,2))*Eij*dely*delz*Aij + (d_Di(i,0)-d_Di(j,0))*Eij*dely*delx*Aij; - fytmp += fy; + fytmp += static_cast(fy); KK_FLOAT fz = (d_Di(j,2)-d_Di(i,2))*Aij + (d_Di(i,2)-d_Di(j,2))*Eij*delz*delz*Aij + (d_Di(i,0)-d_Di(j,0))*Eij*delz*delx*Aij + (d_Di(i,1)-d_Di(j,1))*Eij*delz*dely*Aij; - fztmp += fz; + fztmp += static_cast(fz); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) -= fx; - a_f(j,1) -= fy; - a_f(j,2) -= fz; + a_f(j,0) -= static_cast(fx); + a_f(j,1) -= static_cast(fy); + a_f(j,2) -= static_cast(fz); } if (EVFLAG) { if (eflag) { - ev.evdwl += 0.0; + ev.evdwl += static_cast(0.0); } if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,0.0,fx,fy,fz,delx,dely,delz); @@ -794,12 +802,12 @@ void PairBondValVecKokkos::ev_tally(EV_FLOAT &ev, const int &i, cons if (EFLAG) { if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; if (NEIGHFLAG!=FULL) { - if (NEWTON_PAIR || i < nlocal) a_eatom[i] += epairhalf; - if (NEWTON_PAIR || j < nlocal) a_eatom[j] += epairhalf; + if (NEWTON_PAIR || i < nlocal) a_eatom[i] += static_cast(epairhalf); + if (NEWTON_PAIR || j < nlocal) a_eatom[j] += static_cast(epairhalf); } else { - a_eatom[i] += epairhalf; + a_eatom[i] += static_cast(epairhalf); } } } @@ -815,56 +823,56 @@ void PairBondValVecKokkos::ev_tally(EV_FLOAT &ev, const int &i, cons if (vflag_global) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } if (NEWTON_PAIR || j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } } if (vflag_atom) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; + a_vatom(i,0) += static_cast(static_cast(0.5)*v0); + a_vatom(i,1) += static_cast(static_cast(0.5)*v1); + a_vatom(i,2) += static_cast(static_cast(0.5)*v2); + a_vatom(i,3) += static_cast(static_cast(0.5)*v3); + a_vatom(i,4) += static_cast(static_cast(0.5)*v4); + a_vatom(i,5) += static_cast(static_cast(0.5)*v5); } if (NEWTON_PAIR || j < nlocal) { - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; + a_vatom(j,0) += static_cast(static_cast(0.5)*v0); + a_vatom(j,1) += static_cast(static_cast(0.5)*v1); + a_vatom(j,2) += static_cast(static_cast(0.5)*v2); + a_vatom(j,3) += static_cast(static_cast(0.5)*v3); + a_vatom(j,4) += static_cast(static_cast(0.5)*v4); + a_vatom(j,5) += static_cast(static_cast(0.5)*v5); } } else { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; + a_vatom(i,0) += static_cast(static_cast(0.5)*v0); + a_vatom(i,1) += static_cast(static_cast(0.5)*v1); + a_vatom(i,2) += static_cast(static_cast(0.5)*v2); + a_vatom(i,3) += static_cast(static_cast(0.5)*v3); + a_vatom(i,4) += static_cast(static_cast(0.5)*v4); + a_vatom(i,5) += static_cast(static_cast(0.5)*v5); } } } diff --git a/src/KOKKOS/pair_born_coul_long_kokkos.cpp b/src/KOKKOS/pair_born_coul_long_kokkos.cpp index 94d979e32e6..2615b26dda2 100644 --- a/src/KOKKOS/pair_born_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_born_coul_long_kokkos.cpp @@ -167,13 +167,13 @@ compute_fpair(const KK_FLOAT &rsq, const int & /*i*/, const int & /*j*/, if (rsq >= cut_ljsq) return static_cast(0.0); const KK_FLOAT r2inv = static_cast(1.0) / rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rhoinv = STACKPARAMS ? m_params[itype][jtype].rhoinv : params(itype,jtype).rhoinv; const KK_FLOAT sigma = STACKPARAMS ? m_params[itype][jtype].sigma : params(itype,jtype).sigma; const KK_FLOAT born1 = STACKPARAMS ? m_params[itype][jtype].born1 : params(itype,jtype).born1; const KK_FLOAT born2 = STACKPARAMS ? m_params[itype][jtype].born2 : params(itype,jtype).born2; const KK_FLOAT born3 = STACKPARAMS ? m_params[itype][jtype].born3 : params(itype,jtype).born3; - const KK_FLOAT rexp = exp((sigma - r) * rhoinv); + const KK_FLOAT rexp = Kokkos::exp((sigma - r) * rhoinv); const KK_FLOAT forceborn = born1*r*rexp - born2*r6inv + born3*r2inv*r6inv; return forceborn*r2inv; } @@ -203,9 +203,9 @@ compute_fcoul(const KK_FLOAT &rsq, const int & /*i*/, const int &j, } return forcecoul/rsq; } else { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT grij = g_ewald_kk * r; - const KK_FLOAT expm2 = exp(-grij*grij); + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]/r; @@ -229,14 +229,14 @@ compute_evdwl(const KK_FLOAT &rsq, const int & /*i*/, const int & /*j*/, if (rsq >= cut_ljsq) return static_cast(0.0); const KK_FLOAT r2inv = static_cast(1.0) / rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rhoinv = STACKPARAMS ? m_params[itype][jtype].rhoinv : params(itype,jtype).rhoinv; const KK_FLOAT sigma = STACKPARAMS ? m_params[itype][jtype].sigma : params(itype,jtype).sigma; const KK_FLOAT a = STACKPARAMS ? m_params[itype][jtype].a : params(itype,jtype).a; const KK_FLOAT born2 = STACKPARAMS ? m_params[itype][jtype].born2 : params(itype,jtype).born2; const KK_FLOAT born3 = STACKPARAMS ? m_params[itype][jtype].born3 : params(itype,jtype).born3; const KK_FLOAT offset = STACKPARAMS ? m_params[itype][jtype].offset : params(itype,jtype).offset; - const KK_FLOAT rexp = exp((sigma - r) * rhoinv); + const KK_FLOAT rexp = Kokkos::exp((sigma - r) * rhoinv); // born2 = 6*c, born3 = 8*d return a*rexp - (born2/static_cast(6.0))*r6inv + (born3/static_cast(8.0))*r6inv*r2inv - offset; @@ -267,9 +267,9 @@ compute_ecoul(const KK_FLOAT &rsq, const int & /*i*/, const int &j, } return ecoul; } else { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT grij = g_ewald_kk * r; - const KK_FLOAT expm2 = exp(-grij*grij); + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]/r; diff --git a/src/KOKKOS/pair_born_coul_wolf_kokkos.cpp b/src/KOKKOS/pair_born_coul_wolf_kokkos.cpp index 139d6651698..72edf6434d7 100644 --- a/src/KOKKOS/pair_born_coul_wolf_kokkos.cpp +++ b/src/KOKKOS/pair_born_coul_wolf_kokkos.cpp @@ -95,7 +95,7 @@ void PairBornCoulWolfKokkos::compute(int eflag_in, int vflag_in) // Wolf self-energy shift factors (computed on host, used as scalars in kernel) m_alf = static_cast(alf); e_shift = static_cast(erfc(alf*cut_coul)/cut_coul); - f_shift = static_cast(-(e_shift + 2.0*alf/MY_PIS * + f_shift = static_cast(-(static_cast(e_shift) + 2.0*alf/MY_PIS * exp(-alf*alf*cut_coul*cut_coul)) / cut_coul); x = atomKK->k_x.view(); @@ -105,21 +105,21 @@ void PairBornCoulWolfKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // Wolf self-energy per atom for (int i = 0; i < nlocal; i++) { double qisq = atom->q[i]*atom->q[i]; - eng_coul += -(e_shift/2.0 + m_alf/MY_PIS) * qisq * qqrd2e; + eng_coul += -(static_cast(e_shift)/2.0 + static_cast(m_alf)/MY_PIS) * qisq * static_cast(qqrd2e); } EV_FLOAT ev; @@ -130,16 +130,16 @@ void PairBornCoulWolfKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -148,7 +148,7 @@ void PairBornCoulWolfKokkos::compute(int eflag_in, int vflag_in) // Add Wolf self-energy to per-atom energy after device sync for (int i = 0; i < nlocal; i++) { double qisq = atom->q[i]*atom->q[i]; - eatom[i] += -(e_shift/2.0 + m_alf/MY_PIS) * qisq * qqrd2e; + eatom[i] += -(static_cast(e_shift)/2.0 + static_cast(m_alf)/MY_PIS) * qisq * static_cast(qqrd2e); } } @@ -174,7 +174,7 @@ KK_FLOAT PairBornCoulWolfKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rhoinv = STACKPARAMS ? m_params[itype][jtype].rhoinv : params(itype,jtype).rhoinv; @@ -200,12 +200,12 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int& j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT prefactor = qqrd2e * qtmp * q(j) / r; - const KK_FLOAT erfcc = erfc(m_alf*r); + const KK_FLOAT erfcc = Kokkos::erfc(m_alf*r); const KK_FLOAT erfcd = Kokkos::exp(-m_alf*m_alf*rsq); - const KK_FLOAT dvdrr = (erfcc*r2inv + 2.0*m_alf/MY_PIS * erfcd/r) + f_shift; + const KK_FLOAT dvdrr = (erfcc*r2inv + static_cast(2.0)*m_alf/static_cast(MY_PIS) * erfcd/r) + f_shift; KK_FLOAT forcecoul = dvdrr * rsq * prefactor; if (factor_coul < static_cast(1.0)) forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; return forcecoul * r2inv; @@ -223,7 +223,7 @@ KK_FLOAT PairBornCoulWolfKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rhoinv = STACKPARAMS ? m_params[itype][jtype].rhoinv : params(itype,jtype).rhoinv; @@ -251,7 +251,7 @@ compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int& j, { const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT prefactor = qqrd2e * qtmp * q(j) / r; - const KK_FLOAT erfcc = erfc(m_alf*r); + const KK_FLOAT erfcc = Kokkos::erfc(m_alf*r); KK_FLOAT ecoul = (erfcc - e_shift*r) * prefactor; if (factor_coul < static_cast(1.0)) ecoul -= (static_cast(1.0)-factor_coul)*prefactor; return ecoul; @@ -292,7 +292,7 @@ void PairBornCoulWolfKokkos::init_style() { PairBornCoulWolf::init_style(); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); if (update->whichflag == 1 && utils::strmatch(update->integrate_style,"^respa")) { int respa = 0; @@ -320,24 +320,24 @@ double PairBornCoulWolfKokkos::init_one(int i, int j) double cutone = PairBornCoulWolf::init_one(i,j); double cut_ljsqm = cut_ljsq[i][j]; - k_params.view_host()(i,j).a = a[i][j]; - k_params.view_host()(i,j).c = c[i][j]; - k_params.view_host()(i,j).d = d[i][j]; - k_params.view_host()(i,j).sigma = sigma[i][j]; - k_params.view_host()(i,j).rhoinv = rhoinv[i][j]; - k_params.view_host()(i,j).born1 = born1[i][j]; - k_params.view_host()(i,j).born2 = born2[i][j]; - k_params.view_host()(i,j).born3 = born3[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).a = static_cast(a[i][j]); + k_params.view_host()(i,j).c = static_cast(c[i][j]); + k_params.view_host()(i,j).d = static_cast(d[i][j]); + k_params.view_host()(i,j).sigma = static_cast(sigma[i][j]); + k_params.view_host()(i,j).rhoinv = static_cast(rhoinv[i][j]); + k_params.view_host()(i,j).born1 = static_cast(born1[i][j]); + k_params.view_host()(i,j).born2 = static_cast(born2[i][j]); + k_params.view_host()(i,j).born3 = static_cast(born3[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_born_kokkos.cpp b/src/KOKKOS/pair_born_kokkos.cpp index 08b8c7be199..6939b7bd0d6 100644 --- a/src/KOKKOS/pair_born_kokkos.cpp +++ b/src/KOKKOS/pair_born_kokkos.cpp @@ -99,24 +99,24 @@ void PairBornKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms copymode = 1; EV_FLOAT ev = pair_compute,void >(this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -142,13 +142,13 @@ KK_FLOAT PairBornKokkos:: compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { const KK_FLOAT r2inv = static_cast(1.0) / rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rhoinv = STACKPARAMS ? m_params[itype][jtype].rhoinv : params(itype,jtype).rhoinv; const KK_FLOAT sigma = STACKPARAMS ? m_params[itype][jtype].sigma : params(itype,jtype).sigma; const KK_FLOAT born1 = STACKPARAMS ? m_params[itype][jtype].born1 : params(itype,jtype).born1; const KK_FLOAT born2 = STACKPARAMS ? m_params[itype][jtype].born2 : params(itype,jtype).born2; const KK_FLOAT born3 = STACKPARAMS ? m_params[itype][jtype].born3 : params(itype,jtype).born3; - const KK_FLOAT rexp = exp((sigma - r) * rhoinv); + const KK_FLOAT rexp = Kokkos::exp((sigma - r) * rhoinv); const KK_FLOAT forceborn = born1*r*rexp - born2*r6inv + born3*r2inv*r6inv; return forceborn*r2inv; } @@ -161,14 +161,14 @@ KK_FLOAT PairBornKokkos:: compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { const KK_FLOAT r2inv = static_cast(1.0) / rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rhoinv = STACKPARAMS ? m_params[itype][jtype].rhoinv : params(itype,jtype).rhoinv; const KK_FLOAT sigma = STACKPARAMS ? m_params[itype][jtype].sigma : params(itype,jtype).sigma; const KK_FLOAT a = STACKPARAMS ? m_params[itype][jtype].a : params(itype,jtype).a; const KK_FLOAT born2 = STACKPARAMS ? m_params[itype][jtype].born2 : params(itype,jtype).born2; const KK_FLOAT born3 = STACKPARAMS ? m_params[itype][jtype].born3 : params(itype,jtype).born3; const KK_FLOAT offset = STACKPARAMS ? m_params[itype][jtype].offset : params(itype,jtype).offset; - const KK_FLOAT rexp = exp((sigma - r) * rhoinv); + const KK_FLOAT rexp = Kokkos::exp((sigma - r) * rhoinv); // born2 = 6*c, born3 = 8*d return a*rexp - (born2/static_cast(6.0))*r6inv + (born3/static_cast(8.0))*r6inv*r2inv - offset; diff --git a/src/KOKKOS/pair_brownian_kokkos.cpp b/src/KOKKOS/pair_brownian_kokkos.cpp index e01336994f6..07c435c2f9a 100644 --- a/src/KOKKOS/pair_brownian_kokkos.cpp +++ b/src/KOKKOS/pair_brownian_kokkos.cpp @@ -156,8 +156,8 @@ void PairBrownianKokkos::compute(int eflag_in, int vflag_in) // scale factor for Brownian moments - prethermostat = sqrt(24.0 * force->boltz * t_target / update->dt); - prethermostat *= sqrt(force->vxmu2f / force->ftm2v / force->mvv2e); + prethermostat = static_cast(sqrt(24.0 * force->boltz * t_target / update->dt)); + prethermostat *= static_cast(sqrt(force->vxmu2f / force->ftm2v / force->mvv2e)); // reallocate per-atom arrays if necessary @@ -182,7 +182,7 @@ void PairBrownianKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - vxmu2f = force->vxmu2f; + vxmu2f = static_cast(force->vxmu2f); // loop over neighbors of my atoms @@ -247,12 +247,12 @@ void PairBrownianKokkos::compute(int eflag_in, int vflag_in) } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_atom) { @@ -297,13 +297,15 @@ void PairBrownianKokkos::operator()(TagPairBrownianCompute(R0); + fx_i = static_cast(prethermostat * Kokkos::sqrt(R0_kk) * static_cast(rand_gen.drand() - 0.5)); + fy_i = static_cast(prethermostat * Kokkos::sqrt(R0_kk) * static_cast(rand_gen.drand() - 0.5)); + fz_i = static_cast(prethermostat * Kokkos::sqrt(R0_kk) * static_cast(rand_gen.drand() - 0.5)); if (flaglog) { - torquex_i = prethermostat * sqrt(RT0) * (rand_gen.drand() - 0.5); - torquey_i = prethermostat * sqrt(RT0) * (rand_gen.drand() - 0.5); - torquez_i = prethermostat * sqrt(RT0) * (rand_gen.drand() - 0.5); + const KK_FLOAT RT0_kk = static_cast(RT0); + torquex_i = static_cast(prethermostat * Kokkos::sqrt(RT0_kk) * static_cast(rand_gen.drand() - 0.5)); + torquey_i = static_cast(prethermostat * Kokkos::sqrt(RT0_kk) * static_cast(rand_gen.drand() - 0.5)); + torquez_i = static_cast(prethermostat * Kokkos::sqrt(RT0_kk) * static_cast(rand_gen.drand() - 0.5)); } } @@ -321,34 +323,35 @@ void PairBrownianKokkos::operator()(TagPairBrownianCompute(2.0) * radi; // if less than minimum gap, use minimum gap instead - if (r < d_cut_inner(itype,jtype)) h_sep = d_cut_inner(itype,jtype) - 2.0 * radi; + if (r < d_cut_inner(itype,jtype)) h_sep = d_cut_inner(itype,jtype) - static_cast(2.0) * radi; // scale h_sep by radi h_sep = h_sep / radi; + const KK_FLOAT mu_kk = static_cast(mu); if (flaglog) { - a_sq = 6.0 * MY_PI * mu * radi * (1.0 / 4.0 / h_sep + 9.0 / 40.0 * log(1.0 / h_sep)); - a_sh = 6.0 * MY_PI * mu * radi * (1.0 / 6.0 * log(1.0 / h_sep)); - a_pu = 8.0 * MY_PI * mu * cube(radi) * (3.0 / 160.0 * log(1.0 / h_sep)); + a_sq = static_cast(6.0) * static_cast(MY_PI) * mu_kk * radi * (static_cast(1.0) / static_cast(4.0) / h_sep + static_cast(9.0) / static_cast(40.0) * Kokkos::log(static_cast(1.0) / h_sep)); + a_sh = static_cast(6.0) * static_cast(MY_PI) * mu_kk * radi * (static_cast(1.0) / static_cast(6.0) * Kokkos::log(static_cast(1.0) / h_sep)); + a_pu = static_cast(8.0) * static_cast(MY_PI) * mu_kk * cube(radi) * (static_cast(3.0) / static_cast(160.0) * Kokkos::log(static_cast(1.0) / h_sep)); } else - a_sq = 6.0 * MY_PI * mu * radi * (1.0 / 4.0 / h_sep); + a_sq = static_cast(6.0) * static_cast(MY_PI) * mu_kk * radi * (static_cast(1.0) / static_cast(4.0) / h_sep); // generate the Pairwise Brownian Force: a_sq - KK_FLOAT Fbmag = prethermostat * sqrt(a_sq); + KK_FLOAT Fbmag = prethermostat * Kokkos::sqrt(a_sq); // generate a random number - KK_FLOAT randr = rand_gen.drand() - 0.5; + KK_FLOAT randr = static_cast(rand_gen.drand() - 0.5); // contribution due to Brownian motion @@ -369,17 +372,17 @@ void PairBrownianKokkos::operator()(TagPairBrownianCompute(rand_gen.drand() - 0.5); fx += Fbmag * randr * p2[0]; fy += Fbmag * randr * p2[1]; fz += Fbmag * randr * p2[2]; - randr = rand_gen.drand() - 0.5; + randr = static_cast(rand_gen.drand() - 0.5); fx += Fbmag * randr * p3[0]; fy += Fbmag * randr * p3[1]; @@ -394,14 +397,14 @@ void PairBrownianKokkos::operator()(TagPairBrownianCompute(fx); + fy_i -= static_cast(fy); + fz_i -= static_cast(fz); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) += fx; - a_f(j,1) += fy; - a_f(j,2) += fz; + a_f(j,0) += static_cast(fx); + a_f(j,1) += static_cast(fy); + a_f(j,2) += static_cast(fz); } // torque due to the Brownian Force @@ -422,29 +425,29 @@ void PairBrownianKokkos::operator()(TagPairBrownianCompute(tx); + torquey_i -= static_cast(ty); + torquez_i -= static_cast(tz); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_torque(j,0) -= tx; - a_torque(j,1) -= ty; - a_torque(j,2) -= tz; + a_torque(j,0) -= static_cast(tx); + a_torque(j,1) -= static_cast(ty); + a_torque(j,2) -= static_cast(tz); } // torque due to a_pu - Fbmag = prethermostat * sqrt(a_pu); + Fbmag = prethermostat * Kokkos::sqrt(a_pu); // force in each direction - randr = rand_gen.drand() - 0.5; + randr = static_cast(rand_gen.drand() - 0.5); tx = Fbmag * randr * p2[0]; ty = Fbmag * randr * p2[1]; tz = Fbmag * randr * p2[2]; - randr = rand_gen.drand() - 0.5; + randr = static_cast(rand_gen.drand() - 0.5); tx += Fbmag * randr * p3[0]; ty += Fbmag * randr * p3[1]; @@ -452,14 +455,14 @@ void PairBrownianKokkos::operator()(TagPairBrownianCompute(tx); + torquey_i -= static_cast(ty); + torquez_i -= static_cast(tz); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_torque(j,0) += tx; - a_torque(j,1) += ty; - a_torque(j,2) += tz; + a_torque(j,0) += static_cast(tx); + a_torque(j,1) += static_cast(ty); + a_torque(j,2) += static_cast(tz); } } @@ -512,57 +515,57 @@ void PairBrownianKokkos::ev_tally_xyz(EV_FLOAT & ev, int i, int j, if (vflag_global) { if (NEIGHFLAG != FULL) { if (NEWTON_PAIR) { // neigh half, newton on - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } else { // neigh half, newton off if (i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } if (j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } } else { //neigh full - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } if (vflag_atom) { if (NEIGHFLAG == FULL || NEWTON_PAIR || i < nlocal) { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*static_cast(v0); + v_vatom(i,1) += static_cast(0.5)*static_cast(v1); + v_vatom(i,2) += static_cast(0.5)*static_cast(v2); + v_vatom(i,3) += static_cast(0.5)*static_cast(v3); + v_vatom(i,4) += static_cast(0.5)*static_cast(v4); + v_vatom(i,5) += static_cast(0.5)*static_cast(v5); } if (NEIGHFLAG != FULL && (NEWTON_PAIR || j < nlocal)) { - v_vatom(j,0) += 0.5*v0; - v_vatom(j,1) += 0.5*v1; - v_vatom(j,2) += 0.5*v2; - v_vatom(j,3) += 0.5*v3; - v_vatom(j,4) += 0.5*v4; - v_vatom(j,5) += 0.5*v5; + v_vatom(j,0) += static_cast(0.5)*static_cast(v0); + v_vatom(j,1) += static_cast(0.5)*static_cast(v1); + v_vatom(j,2) += static_cast(0.5)*static_cast(v2); + v_vatom(j,3) += static_cast(0.5)*static_cast(v3); + v_vatom(j,4) += static_cast(0.5)*static_cast(v4); + v_vatom(j,5) += static_cast(0.5)*static_cast(v5); } } } diff --git a/src/KOKKOS/pair_brownian_kokkos.h b/src/KOKKOS/pair_brownian_kokkos.h index 3b70ed22a28..3b648e710fc 100644 --- a/src/KOKKOS/pair_brownian_kokkos.h +++ b/src/KOKKOS/pair_brownian_kokkos.h @@ -105,7 +105,7 @@ class PairBrownianKokkos : public PairBrownian, public KokkosBase { // find the index of maximum magnitude and store it in iz - if (fabs(p1[0]) > fabs(p1[1])) { + if (Kokkos::fabs(p1[0]) > Kokkos::fabs(p1[1])) { iz = 0; ix = 1; iy = 2; @@ -116,13 +116,13 @@ class PairBrownianKokkos : public PairBrownian, public KokkosBase { } if (iz == 0) { - if (fabs(p1[0]) < fabs(p1[2])) { + if (Kokkos::fabs(p1[0]) < Kokkos::fabs(p1[2])) { iz = 2; ix = 0; iy = 1; } } else { - if (fabs(p1[1]) < fabs(p1[2])) { + if (Kokkos::fabs(p1[1]) < Kokkos::fabs(p1[2])) { iz = 2; ix = 0; iy = 1; @@ -137,7 +137,7 @@ class PairBrownianKokkos : public PairBrownian, public KokkosBase { // normalize p2 - norm = sqrt(p2[0] * p2[0] + p2[1] * p2[1] + p2[2] * p2[2]); + norm = Kokkos::sqrt(p2[0] * p2[0] + p2[1] * p2[1] + p2[2] * p2[2]); p2[0] = p2[0] / norm; p2[1] = p2[1] / norm; diff --git a/src/KOKKOS/pair_buck6d_coul_gauss_dsf_kokkos.cpp b/src/KOKKOS/pair_buck6d_coul_gauss_dsf_kokkos.cpp index ce6c561e47c..b87e15b706a 100644 --- a/src/KOKKOS/pair_buck6d_coul_gauss_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_buck6d_coul_gauss_dsf_kokkos.cpp @@ -97,15 +97,15 @@ void PairBuck6dCoulGaussDSFKokkos::compute(int eflag_in, int vflag_i type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; EV_FLOAT ev; @@ -116,16 +116,16 @@ void PairBuck6dCoulGaussDSFKokkos::compute(int eflag_in, int vflag_i (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -156,7 +156,7 @@ compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { const KK_FLOAT r = Kokkos::sqrt(rsq); - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; const KK_FLOAT r14inv = r6inv*r6inv*r2inv; @@ -169,10 +169,10 @@ compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const KK_FLOAT term1 = b3*r6inv; const KK_FLOAT term2 = b4*r14inv; const KK_FLOAT term3 = term2*term2; - const KK_FLOAT term4 = 1.0/(1.0 + term2); - const KK_FLOAT term5 = 1.0/(1.0 + 2.0*term2 + term3); + const KK_FLOAT term4 = static_cast(1.0)/(static_cast(1.0) + term2); + const KK_FLOAT term5 = static_cast(1.0)/(static_cast(1.0) + static_cast(2.0)*term2 + term3); KK_FLOAT forcebuck6d = b1*b2*r*rexp; - forcebuck6d -= term1*(6.0*term4 - term5*14.0*term2); + forcebuck6d -= term1*(static_cast(6.0)*term4 - term5*static_cast(14.0)*term2); KK_FLOAT ebuck6d = b1*rexp - term1*term4; // optional polynomial smoothing near cutoff @@ -187,7 +187,7 @@ compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const KK_FLOAT c4v = STACKPARAMS ? m_params[itype][jtype].c4 : params(itype,jtype).c4; const KK_FLOAT c5v = STACKPARAMS ? m_params[itype][jtype].c5 : params(itype,jtype).c5; const KK_FLOAT sme = c5v*rqu*r + c4v*rqu + c3v*rcu + c2v*rsq + c1v*r + c0v; - const KK_FLOAT smf = 5.0*c5v*rqu + 4.0*c4v*rcu + 3.0*c3v*rsq + 2.0*c2v*r + c1v; + const KK_FLOAT smf = static_cast(5.0)*c5v*rqu + static_cast(4.0)*c4v*rcu + static_cast(3.0)*c3v*rsq + static_cast(2.0)*c2v*r + c1v; forcebuck6d = forcebuck6d*sme - ebuck6d*smf*r; // ebuck6d *= sme; // not needed for force path } @@ -209,7 +209,7 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int& j, const int& itype, const int& jtype, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT alpha = STACKPARAMS ? m_params[itype][jtype].alpha_ij : params(itype,jtype).alpha_ij; const KK_FLOAT f_sh = STACKPARAMS ? m_params[itype][jtype].f_shift_ij : params(itype,jtype).f_shift_ij; @@ -219,9 +219,9 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int& j, const KK_FLOAT erfcc = Kokkos::erf(arg); // force: erf(alpha*r)/r -> d/dr = -erf/r^2 + 2*alpha*erfcd/(sqrt(pi)*r) // so fpair = prefactor * (erfcc/r - 2*alpha/MY_PIS*erfcd + r*f_shift) / rsq - KK_FLOAT forcecoul = prefactor * (erfcc/r - 2.0*alpha/MY_PIS * erfcd + r*f_sh); + KK_FLOAT forcecoul = prefactor * (erfcc/r - static_cast(2.0)*alpha/static_cast(MY_PIS) * erfcd + r*f_sh); // special bonds scaling removes only the undamped 1/r Coulomb part - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor/r; + if (factor_coul < static_cast(1.0)) forcecoul -= (static_cast(1.0)-factor_coul)*prefactor/r; return forcecoul * r2inv; } @@ -238,7 +238,7 @@ compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { const KK_FLOAT r = Kokkos::sqrt(rsq); - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; const KK_FLOAT r14inv = r6inv*r6inv*r2inv; @@ -251,7 +251,7 @@ compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const KK_FLOAT rexp = Kokkos::exp(-r*b2); const KK_FLOAT term1 = b3*r6inv; const KK_FLOAT term2 = b4*r14inv; - const KK_FLOAT term4 = 1.0/(1.0 + term2); + const KK_FLOAT term4 = static_cast(1.0)/(static_cast(1.0) + term2); KK_FLOAT ebuck6d = b1*rexp - term1*term4; const KK_FLOAT rsmooth_sq_val = STACKPARAMS ? m_params[itype][jtype].rsmooth_sq : params(itype,jtype).rsmooth_sq; @@ -294,7 +294,7 @@ compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int& j, const KK_FLOAT erfcc = Kokkos::erf(arg); KK_FLOAT ecoul = prefactor * (erfcc - r*e_sh - rsq*f_sh); // special bonds scaling removes only the undamped 1/r Coulomb part - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + if (factor_coul < static_cast(1.0)) ecoul -= (static_cast(1.0)-factor_coul)*prefactor; return ecoul; } @@ -333,7 +333,7 @@ void PairBuck6dCoulGaussDSFKokkos::init_style() { PairBuck6dCoulGaussDSF::init_style(); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); if (update->whichflag == 1 && utils::strmatch(update->integrate_style,"^respa")) { int respa = 0; @@ -382,9 +382,9 @@ double PairBuck6dCoulGaussDSFKokkos::init_one(int i, int j) k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_buck6d_coul_gauss_long_kokkos.cpp b/src/KOKKOS/pair_buck6d_coul_gauss_long_kokkos.cpp index 98fe7be6490..673176e8821 100644 --- a/src/KOKKOS/pair_buck6d_coul_gauss_long_kokkos.cpp +++ b/src/KOKKOS/pair_buck6d_coul_gauss_long_kokkos.cpp @@ -125,16 +125,16 @@ void PairBuck6dCoulGaussLongKokkos::compute(int eflag_in, int vflag_ (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -434,9 +434,9 @@ double PairBuck6dCoulGaussLongKokkos::init_one(int i, int j) k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp index 4153b420fee..7362a66b8df 100644 --- a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp @@ -105,16 +105,16 @@ void PairBuckCoulCutKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - qqrd2e = force->qqrd2e; + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); // loop over neighbors of my atoms @@ -124,16 +124,16 @@ void PairBuckCoulCutKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -161,10 +161,10 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairBuckCoulCutKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT rexp = exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT rexp = Kokkos::exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); const KK_FLOAT forcebuck = (STACKPARAMS?m_params[itype][jtype].buck1:params(itype,jtype).buck1)*r*rexp - @@ -183,10 +183,10 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairBuckCoulCutKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT rexp = exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT rexp = Kokkos::exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); return (STACKPARAMS?m_params[itype][jtype].a:params(itype,jtype).a)*rexp - (STACKPARAMS?m_params[itype][jtype].c:params(itype,jtype).c)*r6inv - @@ -203,8 +203,8 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairBuckCoulCutKokkos:: compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); KK_FLOAT forcecoul; forcecoul = qqrd2e*qtmp*q(j) *rinv; @@ -222,8 +222,8 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairBuckCoulCutKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int& j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); return factor_coul*qqrd2e*qtmp*q(j)*rinv; @@ -296,21 +296,21 @@ double PairBuckCoulCutKokkos::init_one(int i, int j) double cut_ljsqm = cut_ljsq[i][j]; double cut_coulsqm = cut_coulsq[i][j]; - k_params.view_host()(i,j).a = a[i][j]; - k_params.view_host()(i,j).c = c[i][j]; - k_params.view_host()(i,j).rhoinv = rhoinv[i][j]; - k_params.view_host()(i,j).buck1 = buck1[i][j]; - k_params.view_host()(i,j).buck2 = buck2[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsqm; + k_params.view_host()(i,j).a = static_cast(a[i][j]); + k_params.view_host()(i,j).c = static_cast(c[i][j]); + k_params.view_host()(i,j).rhoinv = static_cast(rhoinv[i][j]); + k_params.view_host()(i,j).buck1 = static_cast(buck1[i][j]); + k_params.view_host()(i,j).buck2 = static_cast(buck2[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsqm); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsqm); } k_cutsq.view_host()(i,j) = cutone*cutone; k_cutsq.modify_host(); diff --git a/src/KOKKOS/pair_buck_coul_long_kokkos.cpp b/src/KOKKOS/pair_buck_coul_long_kokkos.cpp index 35c797827e8..4ee2bb0526b 100644 --- a/src/KOKKOS/pair_buck_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_long_kokkos.cpp @@ -105,16 +105,16 @@ void PairBuckCoulLongKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - qqrd2e = force->qqrd2e; + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); // loop over neighbors of my atoms @@ -130,16 +130,16 @@ void PairBuckCoulLongKokkos::compute(int eflag_in, int vflag_in) if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -157,10 +157,10 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairBuckCoulLongKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT rexp = exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT rexp = Kokkos::exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); const KK_FLOAT forcebuck = (STACKPARAMS?m_params[itype][jtype].buck1:params(itype,jtype).buck1)*r*rexp - @@ -179,10 +179,10 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairBuckCoulLongKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT rexp = exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT rexp = Kokkos::exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); return (STACKPARAMS?m_params[itype][jtype].a:params(itype,jtype).a)*rexp - (STACKPARAMS?m_params[itype][jtype].c:params(itype,jtype).c)*r6inv - @@ -201,29 +201,31 @@ KK_FLOAT PairBuckCoulLongKokkos:: compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_ftable[itable] + fraction*d_dftable[itable]; KK_FLOAT forcecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - forcecoul -= (1.0-factor_coul)*prefactor; + forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return forcecoul/rsq; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT rinv = 1.0/r; - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT rinv = static_cast(1.0)/r; + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]*rinv; - KK_FLOAT forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + KK_FLOAT forcecoul = prefactor * (erfc + static_cast(EWALD_F)*grij*expm2); + if (factor_coul < static_cast(1.0)) forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; return forcecoul*rinv*rinv; } @@ -241,28 +243,30 @@ KK_FLOAT PairBuckCoulLongKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_etable[itable] + fraction*d_detable[itable]; KK_FLOAT ecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - ecoul -= (1.0-factor_coul)*prefactor; + ecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return ecoul; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]/r; KK_FLOAT ecoul = prefactor * erfc; - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + if (factor_coul < static_cast(1.0)) ecoul -= (static_cast(1.0)-factor_coul)*prefactor; return ecoul; } } @@ -309,7 +313,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = rtable[i]; + h_table(i) = static_cast(rtable[i]); } Kokkos::deep_copy(d_table,h_table); d_rtable = d_table; @@ -319,7 +323,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = drtable[i]; + h_table(i) = static_cast(drtable[i]); } Kokkos::deep_copy(d_table,h_table); d_drtable = d_table; @@ -331,7 +335,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu // Copy ftable and dftable for (int i = 0; i < ntable; i++) { - h_table(i) = ftable[i]; + h_table(i) = static_cast(ftable[i]); } Kokkos::deep_copy(d_table,h_table); d_ftable = d_table; @@ -342,7 +346,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dftable[i]; + h_table(i) = static_cast(dftable[i]); } Kokkos::deep_copy(d_table,h_table); d_dftable = d_table; @@ -354,7 +358,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu // Copy ctable and dctable for (int i = 0; i < ntable; i++) { - h_table(i) = ctable[i]; + h_table(i) = static_cast(ctable[i]); } Kokkos::deep_copy(d_table,h_table); d_ctable = d_table; @@ -365,7 +369,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dctable[i]; + h_table(i) = static_cast(dctable[i]); } Kokkos::deep_copy(d_table,h_table); d_dctable = d_table; @@ -377,7 +381,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu // Copy etable and detable for (int i = 0; i < ntable; i++) { - h_table(i) = etable[i]; + h_table(i) = static_cast(etable[i]); } Kokkos::deep_copy(d_table,h_table); d_etable = d_table; @@ -388,7 +392,7 @@ void PairBuckCoulLongKokkos::init_tables(double cut_coul, double *cu table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = detable[i]; + h_table(i) = static_cast(detable[i]); } Kokkos::deep_copy(d_table,h_table); d_detable = d_table; @@ -404,7 +408,7 @@ void PairBuckCoulLongKokkos::init_style() { PairBuckCoulLong::init_style(); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); // error if rRESPA with inner levels @@ -436,21 +440,21 @@ double PairBuckCoulLongKokkos::init_one(int i, int j) double cutone = PairBuckCoulLong::init_one(i,j); double cut_ljsqm = cut_ljsq[i][j]; - k_params.view_host()(i,j).a = a[i][j]; - k_params.view_host()(i,j).c = c[i][j]; - k_params.view_host()(i,j).rhoinv = rhoinv[i][j]; - k_params.view_host()(i,j).buck1 = buck1[i][j]; - k_params.view_host()(i,j).buck2 = buck2[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).a = static_cast(a[i][j]); + k_params.view_host()(i,j).c = static_cast(c[i][j]); + k_params.view_host()(i,j).rhoinv = static_cast(rhoinv[i][j]); + k_params.view_host()(i,j).buck1 = static_cast(buck1[i][j]); + k_params.view_host()(i,j).buck2 = static_cast(buck2[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = cutone*cutone; diff --git a/src/KOKKOS/pair_buck_kokkos.cpp b/src/KOKKOS/pair_buck_kokkos.cpp index 7f1ae64e9a0..c026d3f4809 100644 --- a/src/KOKKOS/pair_buck_kokkos.cpp +++ b/src/KOKKOS/pair_buck_kokkos.cpp @@ -99,24 +99,24 @@ void PairBuckKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms copymode = 1; EV_FLOAT ev = pair_compute,void >(this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -140,10 +140,10 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairBuckKokkos:: compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT rexp = exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT rexp = Kokkos::exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); const KK_FLOAT forcebuck = (STACKPARAMS?m_params[itype][jtype].buck1:params(itype,jtype).buck1)*r*rexp - @@ -158,10 +158,10 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairBuckKokkos:: compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT rexp = exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT rexp = Kokkos::exp(-r*(STACKPARAMS?m_params[itype][jtype].rhoinv:params(itype,jtype).rhoinv)); return (STACKPARAMS?m_params[itype][jtype].a:params(itype,jtype).a)*rexp - @@ -223,17 +223,17 @@ double PairBuckKokkos::init_one(int i, int j) { double cutone = PairBuck::init_one(i,j); - k_params.view_host()(i,j).a = a[i][j]; - k_params.view_host()(i,j).c = c[i][j]; - k_params.view_host()(i,j).rhoinv = rhoinv[i][j]; - k_params.view_host()(i,j).buck1 = buck1[i][j]; - k_params.view_host()(i,j).buck2 = buck2[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).a = static_cast(a[i][j]); + k_params.view_host()(i,j).c = static_cast(c[i][j]); + k_params.view_host()(i,j).rhoinv = static_cast(rhoinv[i][j]); + k_params.view_host()(i,j).buck1 = static_cast(buck1[i][j]); + k_params.view_host()(i,j).buck2 = static_cast(buck2[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } k_cutsq.view_host()(i,j) = cutone*cutone; k_cutsq.modify_host(); diff --git a/src/KOKKOS/pair_colloid_kokkos.cpp b/src/KOKKOS/pair_colloid_kokkos.cpp index a4e998d8b7f..dde42e4ebc2 100644 --- a/src/KOKKOS/pair_colloid_kokkos.cpp +++ b/src/KOKKOS/pair_colloid_kokkos.cpp @@ -101,24 +101,24 @@ void PairColloidKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms copymode = 1; EV_FLOAT ev = pair_compute,void >(this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -173,7 +173,7 @@ compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c * sigma6/K6 - static_cast(5.0)) / K0; } else { // LARGE_LARGE - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT c1 = ppA1; const KK_FLOAT c2 = ppA2; const KK_FLOAT K0 = c1*c2; @@ -244,7 +244,7 @@ compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c * sigma6/K6) - offset; } else { // LARGE_LARGE - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT c1 = ppA1; const KK_FLOAT c2 = ppA2; const KK_FLOAT K0 = c1*c2; @@ -267,7 +267,7 @@ compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c const KK_FLOAT fR = a12*sigma6/r/static_cast(37800.0); return fR*(h0-h1-h2+h3) + a12/static_cast(6.0) - *(static_cast(2.0)*K0*(K7+K8)-log(K8/K7)) - offset; + *(static_cast(2.0)*K0*(K7+K8)-Kokkos::log(K8/K7)) - offset; } } diff --git a/src/KOKKOS/pair_coul_cut_kokkos.cpp b/src/KOKKOS/pair_coul_cut_kokkos.cpp index 873109d8ede..8cb24d5824b 100644 --- a/src/KOKKOS/pair_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_coul_cut_kokkos.cpp @@ -95,29 +95,29 @@ void PairCoulCutKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); // loop over neighbors of my atoms EV_FLOAT ev = pair_compute,void > (this,(NeighListKokkos*)list); - if (eflag) eng_coul += ev.ecoul; + if (eflag) eng_coul += static_cast(ev.ecoul); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -140,8 +140,8 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairCoulCutKokkos:: compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& itype, const int& jtype, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); KK_FLOAT forcecoul; forcecoul = qqrd2e*(STACKPARAMS?m_params[itype][jtype].scale:params(itype,jtype).scale)* @@ -157,8 +157,8 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairCoulCutKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& itype, const int& jtype, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); return factor_coul*qqrd2e * (STACKPARAMS?m_params[itype][jtype].scale:params(itype,jtype).scale) * qtmp *q(j)*rinv; @@ -215,21 +215,21 @@ double PairCoulCutKokkos::init_one(int i, int j) { double cutone = PairCoulCut::init_one(i,j); - k_params.view_host()(i,j).scale = scale[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).scale = static_cast(scale[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cutone*cutone); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cutone*cutone); } k_cutsq.view_host()(i,j) = cutone*cutone; k_cutsq.modify_host(); - k_cut_ljsq.view_host()(i,j) = cutone*cutone; + k_cut_ljsq.view_host()(i,j) = static_cast(cutone*cutone); k_cut_ljsq.modify_host(); - k_cut_coulsq.view_host()(i,j) = cutone*cutone; + k_cut_coulsq.view_host()(i,j) = static_cast(cutone*cutone); k_cut_coulsq.modify_host(); k_params.modify_host(); diff --git a/src/KOKKOS/pair_coul_debye_kokkos.cpp b/src/KOKKOS/pair_coul_debye_kokkos.cpp index cf268adfda3..917012a66c7 100644 --- a/src/KOKKOS/pair_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_coul_debye_kokkos.cpp @@ -99,15 +99,15 @@ void PairCoulDebyeKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -116,15 +116,15 @@ void PairCoulDebyeKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) - eng_coul += ev.ecoul; + eng_coul += static_cast(ev.ecoul); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -151,13 +151,14 @@ KK_FLOAT PairCoulDebyeKokkos:: compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& itype, const int& jtype, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); - const KK_FLOAT r = 1.0/rinv; - const KK_FLOAT screening = exp(-kappa*r); + const KK_FLOAT kappa_kk = static_cast(kappa); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); + const KK_FLOAT r = static_cast(1.0)/rinv; + const KK_FLOAT screening = Kokkos::exp(-kappa_kk*r); KK_FLOAT forcecoul; - forcecoul = qqrd2e * qtmp * q(j) * screening * (kappa + rinv) * + forcecoul = qqrd2e * qtmp * q(j) * screening * (kappa_kk + rinv) * (STACKPARAMS?m_params[itype][jtype].scale:params(itype,jtype).scale); return factor_coul*forcecoul*r2inv; @@ -175,10 +176,11 @@ KK_FLOAT PairCoulDebyeKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& itype, const int& jtype, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); - const KK_FLOAT r = 1.0/rinv; - const KK_FLOAT screening = exp(-kappa*r); + const KK_FLOAT kappa_kk = static_cast(kappa); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); + const KK_FLOAT r = static_cast(1.0)/rinv; + const KK_FLOAT screening = Kokkos::exp(-kappa_kk*r); return factor_coul * qqrd2e * qtmp * q(j) * rinv * screening * (STACKPARAMS?m_params[itype][jtype].scale:params(itype,jtype).scale); @@ -236,21 +238,21 @@ double PairCoulDebyeKokkos::init_one(int i, int j) { double cutone = PairCoulDebye::init_one(i,j); - k_params.view_host()(i,j).scale = scale[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).scale = static_cast(scale[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cutone*cutone); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cutone*cutone); } k_cutsq.view_host()(i,j) = cutone*cutone; k_cutsq.modify_host(); - k_cut_ljsq.view_host()(i,j) = cutone*cutone; + k_cut_ljsq.view_host()(i,j) = static_cast(cutone*cutone); k_cut_ljsq.modify_host(); - k_cut_coulsq.view_host()(i,j) = cutone*cutone; + k_cut_coulsq.view_host()(i,j) = static_cast(cutone*cutone); k_cut_coulsq.modify_host(); k_params.modify_host(); diff --git a/src/KOKKOS/pair_coul_diel_kokkos.cpp b/src/KOKKOS/pair_coul_diel_kokkos.cpp index 770e4c4f01a..f101578bb9d 100644 --- a/src/KOKKOS/pair_coul_diel_kokkos.cpp +++ b/src/KOKKOS/pair_coul_diel_kokkos.cpp @@ -107,15 +107,15 @@ void PairCoulDielKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; EV_FLOAT ev; @@ -125,14 +125,14 @@ void PairCoulDielKokkos::compute(int eflag_in, int vflag_in) ev = pair_compute,void> (this,(NeighListKokkos*)list); - if (eflag) eng_coul += ev.ecoul; + if (eflag) eng_coul += static_cast(ev.ecoul); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -268,16 +268,16 @@ double PairCoulDielKokkos::init_one(int i, int j) k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutsqm); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cutsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cutsqm); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutsqm; k_cutsq.modify_host(); - k_cut_ljsq.view_host()(i,j) = k_cut_ljsq.view_host()(j,i) = cutsqm; + k_cut_ljsq.view_host()(i,j) = k_cut_ljsq.view_host()(j,i) = static_cast(cutsqm); k_cut_ljsq.modify_host(); - k_cut_coulsq.view_host()(i,j) = k_cut_coulsq.view_host()(j,i) = cutsqm; + k_cut_coulsq.view_host()(i,j) = k_cut_coulsq.view_host()(j,i) = static_cast(cutsqm); k_cut_coulsq.modify_host(); k_params.modify_host(); diff --git a/src/KOKKOS/pair_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_coul_dsf_kokkos.cpp index a9b50b6d60a..ddcb9eb21b0 100644 --- a/src/KOKKOS/pair_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_coul_dsf_kokkos.cpp @@ -101,11 +101,11 @@ void PairCoulDSFKokkos::compute(int eflag_in, int vflag_in) d_neighbors = k_list->d_neighbors; d_ilist = k_list->d_ilist; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); int inum = list->inum; @@ -159,14 +159,14 @@ void PairCoulDSFKokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) eng_coul += ev.ecoul; + if (eflag_global) eng_coul += static_cast(ev.ecoul); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -216,6 +216,11 @@ void PairCoulDSFKokkos::operator()(TagPairCoulDSFKernelA::value,Kokkos::MemoryTraits::value> > a_f = f; Kokkos::View::value,Kokkos::MemoryTraits::value> > v_eatom = d_eatom; + const KK_FLOAT cut_coulsq_kk = static_cast(cut_coulsq); + const KK_FLOAT alpha_kk = static_cast(alpha); + const KK_FLOAT e_shift_kk = static_cast(e_shift); + const KK_FLOAT f_shift_kk = static_cast(f_shift); + const int i = d_ilist[ii]; const KK_FLOAT xtmp = x(i,0); const KK_FLOAT ytmp = x(i,1); @@ -223,11 +228,11 @@ void PairCoulDSFKokkos::operator()(TagPairCoulDSFKernelA(2.0) + alpha_kk/static_cast(MY_PIS)) * qtmp*qtmp*qqrd2e; if (eflag_global) - ev.ecoul += e_self; + ev.ecoul += static_cast(e_self); if (eflag_atom) - v_eatom[i] += e_self; + v_eatom[i] += static_cast(e_self); } //const AtomNeighborsConst d_neighbors_i = k_list.get_neighbors_const(i); @@ -247,34 +252,34 @@ void PairCoulDSFKokkos::operator()(TagPairCoulDSFKernelA(1.0)/rsq; + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT prefactor = factor_coul * qqrd2e*qtmp*q[j]/r; - const KK_FLOAT erfcd = exp(-alpha*alpha*rsq); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*alpha*r); - const KK_FLOAT erfcc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * erfcd; - const KK_FLOAT forcecoul = prefactor * (erfcc/r + 2.0*alpha/MY_PIS * erfcd + - r*f_shift) * r; + const KK_FLOAT erfcd = Kokkos::exp(-alpha_kk*alpha_kk*rsq); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*alpha_kk*r); + const KK_FLOAT erfcc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * erfcd; + const KK_FLOAT forcecoul = prefactor * (erfcc/r + static_cast(2.0)*alpha_kk/static_cast(MY_PIS) * erfcd + + r*f_shift_kk) * r; const KK_FLOAT fpair = forcecoul * r2inv; - fxtmp += delx*fpair; - fytmp += dely*fpair; - fztmp += delz*fpair; + fxtmp += static_cast(delx*fpair); + fytmp += static_cast(dely*fpair); + fztmp += static_cast(delz*fpair); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) -= delx*fpair; - a_f(j,1) -= dely*fpair; - a_f(j,2) -= delz*fpair; + a_f(j,0) -= static_cast(delx*fpair); + a_f(j,1) -= static_cast(dely*fpair); + a_f(j,2) -= static_cast(delz*fpair); } if (EVFLAG) { KK_FLOAT ecoul = 0.0; if (eflag) { - ecoul = prefactor * (erfcc - r*e_shift - rsq*f_shift); - ev.ecoul += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j((((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(1.0):static_cast(0.5))*ecoul); } if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,ecoul,fpair,delx,dely,delz); @@ -316,12 +321,12 @@ void PairCoulDSFKokkos::ev_tally(EV_FLOAT &ev, const int &i, const i if (EFLAG) { if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; if (NEIGHFLAG!=FULL) { - if (NEWTON_PAIR || i < nlocal) v_eatom[i] += epairhalf; - if (NEWTON_PAIR || j < nlocal) v_eatom[j] += epairhalf; + if (NEWTON_PAIR || i < nlocal) v_eatom[i] += static_cast(epairhalf); + if (NEWTON_PAIR || j < nlocal) v_eatom[j] += static_cast(epairhalf); } else { - v_eatom[i] += epairhalf; + v_eatom[i] += static_cast(epairhalf); } } } @@ -337,56 +342,56 @@ void PairCoulDSFKokkos::ev_tally(EV_FLOAT &ev, const int &i, const i if (vflag_global) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } if (NEWTON_PAIR || j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } } if (vflag_atom) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(static_cast(0.5)*v0); + v_vatom(i,1) += static_cast(static_cast(0.5)*v1); + v_vatom(i,2) += static_cast(static_cast(0.5)*v2); + v_vatom(i,3) += static_cast(static_cast(0.5)*v3); + v_vatom(i,4) += static_cast(static_cast(0.5)*v4); + v_vatom(i,5) += static_cast(static_cast(0.5)*v5); } if (NEWTON_PAIR || j < nlocal) { - v_vatom(j,0) += 0.5*v0; - v_vatom(j,1) += 0.5*v1; - v_vatom(j,2) += 0.5*v2; - v_vatom(j,3) += 0.5*v3; - v_vatom(j,4) += 0.5*v4; - v_vatom(j,5) += 0.5*v5; + v_vatom(j,0) += static_cast(static_cast(0.5)*v0); + v_vatom(j,1) += static_cast(static_cast(0.5)*v1); + v_vatom(j,2) += static_cast(static_cast(0.5)*v2); + v_vatom(j,3) += static_cast(static_cast(0.5)*v3); + v_vatom(j,4) += static_cast(static_cast(0.5)*v4); + v_vatom(j,5) += static_cast(static_cast(0.5)*v5); } } else { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(static_cast(0.5)*v0); + v_vatom(i,1) += static_cast(static_cast(0.5)*v1); + v_vatom(i,2) += static_cast(static_cast(0.5)*v2); + v_vatom(i,3) += static_cast(static_cast(0.5)*v3); + v_vatom(i,4) += static_cast(static_cast(0.5)*v4); + v_vatom(i,5) += static_cast(static_cast(0.5)*v5); } } } diff --git a/src/KOKKOS/pair_coul_long_kokkos.cpp b/src/KOKKOS/pair_coul_long_kokkos.cpp index ab9cd857b6f..fa8b82e62ec 100644 --- a/src/KOKKOS/pair_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_coul_long_kokkos.cpp @@ -103,16 +103,16 @@ void PairCoulLongKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - qqrd2e = force->qqrd2e; + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); // loop over neighbors of my atoms @@ -128,16 +128,16 @@ void PairCoulLongKokkos::compute(int eflag_in, int vflag_in) if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -167,29 +167,31 @@ KK_FLOAT PairCoulLongKokkos:: compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_ftable[itable] + fraction*d_dftable[itable]; KK_FLOAT forcecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - forcecoul -= (1.0-factor_coul)*prefactor; + forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return forcecoul/rsq; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT rinv = 1.0/r; - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT rinv = static_cast(1.0)/r; + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]*rinv; - KK_FLOAT forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + KK_FLOAT forcecoul = prefactor * (erfc + static_cast(EWALD_F)*grij*expm2); + if (factor_coul < static_cast(1.0)) forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; return forcecoul*rinv*rinv; } @@ -207,28 +209,30 @@ KK_FLOAT PairCoulLongKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_etable[itable] + fraction*d_detable[itable]; KK_FLOAT ecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - ecoul -= (1.0-factor_coul)*prefactor; + ecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return ecoul; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]/r; KK_FLOAT ecoul = prefactor * erfc; - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + if (factor_coul < static_cast(1.0)) ecoul -= (static_cast(1.0)-factor_coul)*prefactor; return ecoul; } } @@ -272,7 +276,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = rtable[i]; + h_table(i) = static_cast(rtable[i]); } Kokkos::deep_copy(d_table,h_table); d_rtable = d_table; @@ -282,7 +286,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = drtable[i]; + h_table(i) = static_cast(drtable[i]); } Kokkos::deep_copy(d_table,h_table); d_drtable = d_table; @@ -294,7 +298,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re // Copy ftable and dftable for (int i = 0; i < ntable; i++) { - h_table(i) = ftable[i]; + h_table(i) = static_cast(ftable[i]); } Kokkos::deep_copy(d_table,h_table); d_ftable = d_table; @@ -305,7 +309,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dftable[i]; + h_table(i) = static_cast(dftable[i]); } Kokkos::deep_copy(d_table,h_table); d_dftable = d_table; @@ -317,7 +321,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re // Copy ctable and dctable for (int i = 0; i < ntable; i++) { - h_table(i) = ctable[i]; + h_table(i) = static_cast(ctable[i]); } Kokkos::deep_copy(d_table,h_table); d_ctable = d_table; @@ -328,7 +332,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dctable[i]; + h_table(i) = static_cast(dctable[i]); } Kokkos::deep_copy(d_table,h_table); d_dctable = d_table; @@ -340,7 +344,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re // Copy etable and detable for (int i = 0; i < ntable; i++) { - h_table(i) = etable[i]; + h_table(i) = static_cast(etable[i]); } Kokkos::deep_copy(d_table,h_table); d_etable = d_table; @@ -351,7 +355,7 @@ void PairCoulLongKokkos::init_tables(double cut_coul, double *cut_re table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = detable[i]; + h_table(i) = static_cast(detable[i]); } Kokkos::deep_copy(d_table,h_table); d_detable = d_table; @@ -367,8 +371,8 @@ void PairCoulLongKokkos::init_style() { PairCoulLong::init_style(); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); - Kokkos::deep_copy(d_cut_ljsq,cut_coulsq); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); + Kokkos::deep_copy(d_cut_ljsq,static_cast(cut_coulsq)); // error if rRESPA with inner levels @@ -399,14 +403,14 @@ double PairCoulLongKokkos::init_one(int i, int j) { double cutone = PairCoulLong::init_one(i,j); - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = cutone*cutone; diff --git a/src/KOKKOS/pair_coul_shield_kokkos.cpp b/src/KOKKOS/pair_coul_shield_kokkos.cpp index 113ac4f8559..017a0e5e797 100644 --- a/src/KOKKOS/pair_coul_shield_kokkos.cpp +++ b/src/KOKKOS/pair_coul_shield_kokkos.cpp @@ -105,15 +105,15 @@ void PairCoulShieldKokkos::compute(int eflag_in, int vflag_in) molecule = atomKK->k_molecule.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; EV_FLOAT ev; @@ -123,14 +123,14 @@ void PairCoulShieldKokkos::compute(int eflag_in, int vflag_in) ev = pair_compute,void> (this,(NeighListKokkos*)list); - if (eflag) eng_coul += ev.ecoul; + if (eflag) eng_coul += static_cast(ev.ecoul); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -317,16 +317,16 @@ double PairCoulShieldKokkos::init_one(int i, int j) k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutsqm); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cutsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cutsqm); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutsqm; k_cutsq.modify_host(); - k_cut_ljsq.view_host()(i,j) = k_cut_ljsq.view_host()(j,i) = cutsqm; + k_cut_ljsq.view_host()(i,j) = k_cut_ljsq.view_host()(j,i) = static_cast(cutsqm); k_cut_ljsq.modify_host(); - k_cut_coulsq.view_host()(i,j) = k_cut_coulsq.view_host()(j,i) = cutsqm; + k_cut_coulsq.view_host()(i,j) = k_cut_coulsq.view_host()(j,i) = static_cast(cutsqm); k_cut_coulsq.modify_host(); k_params.modify_host(); diff --git a/src/KOKKOS/pair_coul_slater_long_kokkos.cpp b/src/KOKKOS/pair_coul_slater_long_kokkos.cpp index 54b1bb0c4ce..26a843bd2d1 100644 --- a/src/KOKKOS/pair_coul_slater_long_kokkos.cpp +++ b/src/KOKKOS/pair_coul_slater_long_kokkos.cpp @@ -158,13 +158,13 @@ KK_FLOAT PairCoulSlaterLongKokkos:: compute_fcoul(const KK_FLOAT &rsq, const int & /*i*/, const int &j, const int &itype, const int &jtype, const KK_FLOAT &factor_coul, const KK_FLOAT &qtmp) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT r2inv = static_cast(1.0) / rsq; const KK_FLOAT grij = g_ewald_kk * r; - const KK_FLOAT expm2 = exp(-grij*grij); + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; - const KK_FLOAT slater_term = exp(-static_cast(2.0)*r/lamda_kk) + const KK_FLOAT slater_term = Kokkos::exp(-static_cast(2.0)*r/lamda_kk) * (static_cast(1.0) + (static_cast(2.0)*r/lamda_kk*(static_cast(1.0)+r/lamda_kk))); const KK_FLOAT scale = STACKPARAMS ? m_params[itype][jtype].scale : params(itype,jtype).scale; const KK_FLOAT prefactor = qqrd2e * scale * qtmp * q[j] / r; @@ -185,17 +185,17 @@ KK_FLOAT PairCoulSlaterLongKokkos:: compute_ecoul(const KK_FLOAT &rsq, const int & /*i*/, const int &j, const int &itype, const int &jtype, const KK_FLOAT &factor_coul, const KK_FLOAT &qtmp) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT grij = g_ewald_kk * r; - const KK_FLOAT expm2 = exp(-grij*grij); + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT scale = STACKPARAMS ? m_params[itype][jtype].scale : params(itype,jtype).scale; const KK_FLOAT prefactor = qqrd2e * scale * qtmp * q[j] / r; - KK_FLOAT ecoul = prefactor * (erfc - (static_cast(1.0) + r/lamda_kk) * exp(-static_cast(2.0)*r/lamda_kk)); + KK_FLOAT ecoul = prefactor * (erfc - (static_cast(1.0) + r/lamda_kk) * Kokkos::exp(-static_cast(2.0)*r/lamda_kk)); if (factor_coul < static_cast(1.0)) ecoul -= (static_cast(1.0) - factor_coul) * prefactor - * (static_cast(1.0) - (static_cast(1.0) + r/lamda_kk) * exp(-static_cast(2.0)*r/lamda_kk)); + * (static_cast(1.0) - (static_cast(1.0) + r/lamda_kk) * Kokkos::exp(-static_cast(2.0)*r/lamda_kk)); return ecoul; } diff --git a/src/KOKKOS/pair_coul_wolf_kokkos.cpp b/src/KOKKOS/pair_coul_wolf_kokkos.cpp index 432b07ca6db..3df662e3228 100644 --- a/src/KOKKOS/pair_coul_wolf_kokkos.cpp +++ b/src/KOKKOS/pair_coul_wolf_kokkos.cpp @@ -89,9 +89,9 @@ void PairCoulWolfKokkos::compute(int eflag_in, int vflag_in) // shifted coulombic energy - e_shift = erfc(alf*cut_coul)/cut_coul; - f_shift = -(e_shift+ 2.0*alf/MY_PIS * exp(-alf*alf*cut_coul*cut_coul)) / - cut_coul; + e_shift = static_cast(erfc(alf*cut_coul)/cut_coul); + f_shift = static_cast(-(static_cast(e_shift)+ 2.0*alf/MY_PIS * exp(-alf*alf*cut_coul*cut_coul)) / + cut_coul); x = atomKK->k_x.view(); f = atomKK->k_f.view(); @@ -105,11 +105,11 @@ void PairCoulWolfKokkos::compute(int eflag_in, int vflag_in) d_neighbors = k_list->d_neighbors; d_ilist = k_list->d_ilist; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); int inum = list->inum; @@ -163,14 +163,14 @@ void PairCoulWolfKokkos::compute(int eflag_in, int vflag_in) } } - if (eflag_global) eng_coul += ev.ecoul; + if (eflag_global) eng_coul += static_cast(ev.ecoul); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -220,6 +220,9 @@ void PairCoulWolfKokkos::operator()(TagPairCoulWolfKernelA::value,Kokkos::MemoryTraits::value> > a_f = f; Kokkos::View::value,Kokkos::MemoryTraits::value> > v_eatom = d_eatom; + const KK_FLOAT cut_coulsq_kk = static_cast(cut_coulsq); + const KK_FLOAT alf_kk = static_cast(alf); + const int i = d_ilist[ii]; const KK_FLOAT xtmp = x(i,0); const KK_FLOAT ytmp = x(i,1); @@ -228,11 +231,11 @@ void PairCoulWolfKokkos::operator()(TagPairCoulWolfKernelA(2.0) + alf_kk/static_cast(MY_PIS)) * qisq*qqrd2e; if (eflag_global) - ev.ecoul += e_self; + ev.ecoul += static_cast(e_self); if (eflag_atom) - v_eatom[i] += e_self; + v_eatom[i] += static_cast(e_self); } //const AtomNeighborsConst d_neighbors_i = k_list.get_neighbors_const(i); @@ -252,34 +255,34 @@ void PairCoulWolfKokkos::operator()(TagPairCoulWolfKernelA(2.0)*alf_kk/static_cast(MY_PIS) * erfcd/r) + f_shift; KK_FLOAT forcecoul = dvdrr*rsq*prefactor; - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + if (factor_coul < static_cast(1.0)) forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; const KK_FLOAT fpair = forcecoul / rsq; - fxtmp += delx*fpair; - fytmp += dely*fpair; - fztmp += delz*fpair; + fxtmp += static_cast(delx*fpair); + fytmp += static_cast(dely*fpair); + fztmp += static_cast(delz*fpair); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) -= delx*fpair; - a_f(j,1) -= dely*fpair; - a_f(j,2) -= delz*fpair; + a_f(j,0) -= static_cast(delx*fpair); + a_f(j,1) -= static_cast(dely*fpair); + a_f(j,2) -= static_cast(delz*fpair); } if (EVFLAG) { KK_FLOAT ecoul = v_sh; if (eflag) { - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; - ev.ecoul += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(1.0)) ecoul -= (static_cast(1.0)-factor_coul)*prefactor; + ev.ecoul += static_cast((((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(1.0):static_cast(0.5))*ecoul); } if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,ecoul,fpair,delx,dely,delz); @@ -321,12 +324,12 @@ void PairCoulWolfKokkos::ev_tally(EV_FLOAT &ev, const int &i, const if (EFLAG) { if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; if (NEIGHFLAG!=FULL) { - if (NEWTON_PAIR || i < nlocal) v_eatom[i] += epairhalf; - if (NEWTON_PAIR || j < nlocal) v_eatom[j] += epairhalf; + if (NEWTON_PAIR || i < nlocal) v_eatom[i] += static_cast(epairhalf); + if (NEWTON_PAIR || j < nlocal) v_eatom[j] += static_cast(epairhalf); } else { - v_eatom[i] += epairhalf; + v_eatom[i] += static_cast(epairhalf); } } } @@ -342,56 +345,56 @@ void PairCoulWolfKokkos::ev_tally(EV_FLOAT &ev, const int &i, const if (vflag_global) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } if (NEWTON_PAIR || j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(static_cast(0.5)*v0); + ev.v[1] += static_cast(static_cast(0.5)*v1); + ev.v[2] += static_cast(static_cast(0.5)*v2); + ev.v[3] += static_cast(static_cast(0.5)*v3); + ev.v[4] += static_cast(static_cast(0.5)*v4); + ev.v[5] += static_cast(static_cast(0.5)*v5); } } if (vflag_atom) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(static_cast(0.5)*v0); + v_vatom(i,1) += static_cast(static_cast(0.5)*v1); + v_vatom(i,2) += static_cast(static_cast(0.5)*v2); + v_vatom(i,3) += static_cast(static_cast(0.5)*v3); + v_vatom(i,4) += static_cast(static_cast(0.5)*v4); + v_vatom(i,5) += static_cast(static_cast(0.5)*v5); } if (NEWTON_PAIR || j < nlocal) { - v_vatom(j,0) += 0.5*v0; - v_vatom(j,1) += 0.5*v1; - v_vatom(j,2) += 0.5*v2; - v_vatom(j,3) += 0.5*v3; - v_vatom(j,4) += 0.5*v4; - v_vatom(j,5) += 0.5*v5; + v_vatom(j,0) += static_cast(static_cast(0.5)*v0); + v_vatom(j,1) += static_cast(static_cast(0.5)*v1); + v_vatom(j,2) += static_cast(static_cast(0.5)*v2); + v_vatom(j,3) += static_cast(static_cast(0.5)*v3); + v_vatom(j,4) += static_cast(static_cast(0.5)*v4); + v_vatom(j,5) += static_cast(static_cast(0.5)*v5); } } else { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(static_cast(0.5)*v0); + v_vatom(i,1) += static_cast(static_cast(0.5)*v1); + v_vatom(i,2) += static_cast(static_cast(0.5)*v2); + v_vatom(i,3) += static_cast(static_cast(0.5)*v3); + v_vatom(i,4) += static_cast(static_cast(0.5)*v4); + v_vatom(i,5) += static_cast(static_cast(0.5)*v5); } } } diff --git a/src/KOKKOS/pair_dpd_ext_kokkos.cpp b/src/KOKKOS/pair_dpd_ext_kokkos.cpp index 602b18d14fa..8f06e77f06f 100644 --- a/src/KOKKOS/pair_dpd_ext_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_ext_kokkos.cpp @@ -130,17 +130,17 @@ void PairDPDExtKokkos::compute(int eflagin, int vflagin) k_cutsq.template sync(); k_params.template sync(); - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_rf[0] = sqrt(force->special_lj[0]); - special_rf[1] = sqrt(force->special_lj[1]); - special_rf[2] = sqrt(force->special_lj[2]); - special_rf[3] = sqrt(force->special_lj[3]); + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_rf[0] = static_cast(sqrt(force->special_lj[0])); + special_rf[1] = static_cast(sqrt(force->special_lj[1])); + special_rf[2] = static_cast(sqrt(force->special_lj[2])); + special_rf[3] = static_cast(sqrt(force->special_lj[3])); nlocal = atom->nlocal; - dtinvsqrt = 1.0/sqrt(update->dt); + dtinvsqrt = static_cast(1.0/sqrt(update->dt)); NeighListKokkos* k_list = static_cast*>(list); d_numneigh = k_list->d_numneigh; @@ -174,14 +174,14 @@ void PairDPDExtKokkos::compute(int eflagin, int vflagin) if (need_dup) Kokkos::Experimental::contribute(f, dup_f); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -265,34 +265,34 @@ void PairDPDExtKokkos::operator() (TagDPDExtKokkos rsq = delx*delx + dely*dely + delz*delz; jtype = type(j); if (rsq < d_cutsq(itype,jtype)) { - r = sqrt(rsq); - if (r < EPSILON) continue; // r can be 0.0 in DPD systems - rinv = 1.0/r; + r = Kokkos::sqrt(rsq); + if (r < static_cast(EPSILON)) continue; // r can be 0.0 in DPD systems + rinv = static_cast(1.0)/r; delvx = vxtmp - v(j,0); delvy = vytmp - v(j,1); delvz = vztmp - v(j,2); dot = delx*delvx + dely*delvy + delz*delvz; - P[0][0] = 1.0 - delx*delx*rinv*rinv; + P[0][0] = static_cast(1.0) - delx*delx*rinv*rinv; P[0][1] = - delx*dely*rinv*rinv; P[0][2] = - delx*delz*rinv*rinv; P[1][0] = P[0][1]; - P[1][1] = 1.0 - dely*dely*rinv*rinv; + P[1][1] = static_cast(1.0) - dely*dely*rinv*rinv; P[1][2] = - dely*delz*rinv*rinv; P[2][0] = P[0][2]; P[2][1] = P[1][2]; - P[2][2] = 1.0 - delz*delz*rinv*rinv; + P[2][2] = static_cast(1.0) - delz*delz*rinv*rinv; - wd = 1.0 - r/params(itype,jtype).cut; - wdPar = pow(wd,params(itype,jtype).ws); - wdPerp = pow(wd,params(itype,jtype).wsT); + wd = static_cast(1.0) - r/params(itype,jtype).cut; + wdPar = Kokkos::pow(wd,params(itype,jtype).ws); + wdPerp = Kokkos::pow(wd,params(itype,jtype).wsT); - randnum = rand_gen.normal(); - randnumx = rand_gen.normal(); - randnumy = rand_gen.normal(); - randnumz = rand_gen.normal(); + randnum = static_cast(rand_gen.normal()); + randnumx = static_cast(rand_gen.normal()); + randnumy = static_cast(rand_gen.normal()); + randnumz = static_cast(rand_gen.normal()); // conservative force fpair = params(itype,jtype).a0*wd; @@ -323,26 +323,26 @@ void PairDPDExtKokkos::operator() (TagDPDExtKokkos fx += fpairx; fy += fpairy; fz += fpairz; - a_f(j,0) -= fpairx; - a_f(j,1) -= fpairy; - a_f(j,2) -= fpairz; + a_f(j,0) -= static_cast(fpairx); + a_f(j,1) -= static_cast(fpairy); + a_f(j,2) -= static_cast(fpairz); if (EVFLAG && eflag) { // unshifted eng of conservative term: // evdwl = -a0[itype][jtype]*r * (1.0-0.5*r/cut[itype][jtype]); // eng shifted to 0.0 at cutoff - evdwl = 0.5*params(itype,jtype).a0*params(itype,jtype).cut* wd*wd; + evdwl = static_cast(0.5)*params(itype,jtype).a0*params(itype,jtype).cut* wd*wd; evdwl *= factor_dpd; if (EVFLAG && eflag_global) - ev.evdwl += evdwl; + ev.evdwl += static_cast(evdwl); } if (EVFLAG && (eflag_atom || vflag_either)) this->template ev_tally_xyz(ev,i,j,evdwl,fpairx,fpairy,fpairz,delx,dely,delz); } } - a_f(i,0) += fx; - a_f(i,1) += fy; - a_f(i,2) += fz; + a_f(i,0) += static_cast(fx); + a_f(i,1) += static_cast(fy); + a_f(i,2) += static_cast(fz); rand_pool.free_state(rand_gen); } @@ -366,9 +366,9 @@ void PairDPDExtKokkos::ev_tally_xyz(EV_FLOAT &ev, const int &i, cons auto a_vatom = v_vatom.template access>(); if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; - a_eatom[i] += epairhalf; - a_eatom[j] += epairhalf; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; + a_eatom[i] += static_cast(epairhalf); + a_eatom[j] += static_cast(epairhalf); } if (vflag_either) { @@ -380,27 +380,27 @@ void PairDPDExtKokkos::ev_tally_xyz(EV_FLOAT &ev, const int &i, cons const KK_FLOAT v5 = dely*fz; if (vflag_global) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } if (vflag_atom) { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; + a_vatom(i,0) += static_cast(0.5)*static_cast(v0); + a_vatom(i,1) += static_cast(0.5)*static_cast(v1); + a_vatom(i,2) += static_cast(0.5)*static_cast(v2); + a_vatom(i,3) += static_cast(0.5)*static_cast(v3); + a_vatom(i,4) += static_cast(0.5)*static_cast(v4); + a_vatom(i,5) += static_cast(0.5)*static_cast(v5); + a_vatom(j,0) += static_cast(0.5)*static_cast(v0); + a_vatom(j,1) += static_cast(0.5)*static_cast(v1); + a_vatom(j,2) += static_cast(0.5)*static_cast(v2); + a_vatom(j,3) += static_cast(0.5)*static_cast(v3); + a_vatom(j,4) += static_cast(0.5)*static_cast(v4); + a_vatom(j,5) += static_cast(0.5)*static_cast(v5); } } } @@ -439,14 +439,14 @@ double PairDPDExtKokkos::init_one(int i, int j) { double cutone = PairDPDExt::init_one(i,j); - k_params.view_host()(i,j).cut = cut[i][j]; - k_params.view_host()(i,j).ws = ws[i][j]; - k_params.view_host()(i,j).wsT = wsT[i][j]; - k_params.view_host()(i,j).a0 = a0[i][j]; - k_params.view_host()(i,j).gamma = gamma[i][j]; - k_params.view_host()(i,j).sigma = sigma[i][j]; - k_params.view_host()(i,j).gammaT = gammaT[i][j]; - k_params.view_host()(i,j).sigmaT = sigmaT[i][j]; + k_params.view_host()(i,j).cut = static_cast(cut[i][j]); + k_params.view_host()(i,j).ws = static_cast(ws[i][j]); + k_params.view_host()(i,j).wsT = static_cast(wsT[i][j]); + k_params.view_host()(i,j).a0 = static_cast(a0[i][j]); + k_params.view_host()(i,j).gamma = static_cast(gamma[i][j]); + k_params.view_host()(i,j).sigma = static_cast(sigma[i][j]); + k_params.view_host()(i,j).gammaT = static_cast(gammaT[i][j]); + k_params.view_host()(i,j).sigmaT = static_cast(sigmaT[i][j]); k_params.view_host()(j,i) = k_params.view_host()(i,j); k_params.modify_host(); diff --git a/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp b/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp index 4512d46933c..7b2c5f665d5 100644 --- a/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp @@ -117,7 +117,7 @@ void PairDPDExtTstatKokkos::compute(int eflagin, int vflagin) for (int i = 1; i <= atom->ntypes; i++) for (int j = i; j <= atom->ntypes; j++) { k_params.view_host()(i,j).sigma = k_params.view_host()(j,i).sigma = - sqrt(2.0*boltz*temperature*gamma[i][j]); + static_cast(sqrt(2.0*boltz*temperature*gamma[i][j])); } } k_params.modify_host(); @@ -145,17 +145,17 @@ void PairDPDExtTstatKokkos::compute(int eflagin, int vflagin) k_cutsq.template sync(); k_params.template sync(); - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_rf[0] = sqrt(force->special_lj[0]); - special_rf[1] = sqrt(force->special_lj[1]); - special_rf[2] = sqrt(force->special_lj[2]); - special_rf[3] = sqrt(force->special_lj[3]); + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_rf[0] = static_cast(sqrt(force->special_lj[0])); + special_rf[1] = static_cast(sqrt(force->special_lj[1])); + special_rf[2] = static_cast(sqrt(force->special_lj[2])); + special_rf[3] = static_cast(sqrt(force->special_lj[3])); nlocal = atom->nlocal; - dtinvsqrt = 1.0/sqrt(update->dt); + dtinvsqrt = static_cast(1.0/sqrt(update->dt)); NeighListKokkos* k_list = static_cast*>(list); d_numneigh = k_list->d_numneigh; @@ -188,12 +188,12 @@ void PairDPDExtTstatKokkos::compute(int eflagin, int vflagin) Kokkos::Experimental::contribute(f, dup_f); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -269,34 +269,34 @@ void PairDPDExtTstatKokkos::operator() (TagDPDExtTstatKokkos(EPSILON)) continue; // r can be 0.0 in DPD systems + rinv = static_cast(1.0)/r; delvx = vxtmp - v(j,0); delvy = vytmp - v(j,1); delvz = vztmp - v(j,2); dot = delx*delvx + dely*delvy + delz*delvz; - P[0][0] = 1.0 - delx*delx*rinv*rinv; + P[0][0] = static_cast(1.0) - delx*delx*rinv*rinv; P[0][1] = - delx*dely*rinv*rinv; P[0][2] = - delx*delz*rinv*rinv; P[1][0] = P[0][1]; - P[1][1] = 1.0 - dely*dely*rinv*rinv; + P[1][1] = static_cast(1.0) - dely*dely*rinv*rinv; P[1][2] = - dely*delz*rinv*rinv; P[2][0] = P[0][2]; P[2][1] = P[1][2]; - P[2][2] = 1.0 - delz*delz*rinv*rinv; + P[2][2] = static_cast(1.0) - delz*delz*rinv*rinv; - wd = 1.0 - r/params(itype,jtype).cut; - wdPar = pow(wd,params(itype,jtype).ws); - wdPerp = pow(wd,params(itype,jtype).wsT); + wd = static_cast(1.0) - r/params(itype,jtype).cut; + wdPar = Kokkos::pow(wd,params(itype,jtype).ws); + wdPerp = Kokkos::pow(wd,params(itype,jtype).wsT); - randnum = rand_gen.normal(); - randnumx = rand_gen.normal(); - randnumy = rand_gen.normal(); - randnumz = rand_gen.normal(); + randnum = static_cast(rand_gen.normal()); + randnumx = static_cast(rand_gen.normal()); + randnumy = static_cast(rand_gen.normal()); + randnumz = static_cast(rand_gen.normal()); // drag force - parallel fpair = params(itype,jtype).gamma*wdPar*wdPar*dot*rinv; @@ -324,17 +324,17 @@ void PairDPDExtTstatKokkos::operator() (TagDPDExtTstatKokkos(fpairx); + a_f(j,1) -= static_cast(fpairy); + a_f(j,2) -= static_cast(fpairz); if (VFLAG) this->template v_tally_xyz(ev,i,j,fpairx,fpairy,fpairz,delx,dely,delz); } } - a_f(i,0) += fx; - a_f(i,1) += fy; - a_f(i,2) += fz; + a_f(i,0) += static_cast(fx); + a_f(i,1) += static_cast(fy); + a_f(i,2) += static_cast(fz); rand_pool.free_state(rand_gen); } @@ -362,27 +362,27 @@ void PairDPDExtTstatKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const KK_FLOAT v5 = dely*fz; if (vflag_global) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } if (vflag_atom) { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; + a_vatom(i,0) += static_cast(0.5)*static_cast(v0); + a_vatom(i,1) += static_cast(0.5)*static_cast(v1); + a_vatom(i,2) += static_cast(0.5)*static_cast(v2); + a_vatom(i,3) += static_cast(0.5)*static_cast(v3); + a_vatom(i,4) += static_cast(0.5)*static_cast(v4); + a_vatom(i,5) += static_cast(0.5)*static_cast(v5); + a_vatom(j,0) += static_cast(0.5)*static_cast(v0); + a_vatom(j,1) += static_cast(0.5)*static_cast(v1); + a_vatom(j,2) += static_cast(0.5)*static_cast(v2); + a_vatom(j,3) += static_cast(0.5)*static_cast(v3); + a_vatom(j,4) += static_cast(0.5)*static_cast(v4); + a_vatom(j,5) += static_cast(0.5)*static_cast(v5); } } @@ -420,13 +420,13 @@ double PairDPDExtTstatKokkos::init_one(int i, int j) { double cutone = PairDPDExt::init_one(i,j); - k_params.view_host()(i,j).cut = cut[i][j]; - k_params.view_host()(i,j).ws = ws[i][j]; - k_params.view_host()(i,j).wsT = wsT[i][j]; - k_params.view_host()(i,j).gamma = gamma[i][j]; - k_params.view_host()(i,j).sigma = sigma[i][j]; - k_params.view_host()(i,j).gammaT = gammaT[i][j]; - k_params.view_host()(i,j).sigmaT = sigmaT[i][j]; + k_params.view_host()(i,j).cut = static_cast(cut[i][j]); + k_params.view_host()(i,j).ws = static_cast(ws[i][j]); + k_params.view_host()(i,j).wsT = static_cast(wsT[i][j]); + k_params.view_host()(i,j).gamma = static_cast(gamma[i][j]); + k_params.view_host()(i,j).sigma = static_cast(sigma[i][j]); + k_params.view_host()(i,j).gammaT = static_cast(gammaT[i][j]); + k_params.view_host()(i,j).sigmaT = static_cast(sigmaT[i][j]); k_params.view_host()(j,i) = k_params.view_host()(i,j); k_params.modify_host(); diff --git a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp index 2ba9e1f79e8..e0291f72476 100644 --- a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp @@ -167,10 +167,10 @@ void PairDPDfdtEnergyKokkos::compute(int eflag_in, int vflag_in) if (evflag) atomKK->modified(execution_space,F_MASK | ENERGY_MASK | VIRIAL_MASK); else atomKK->modified(execution_space,F_MASK); - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); nlocal = atom->nlocal; int nghost = atom->nghost; @@ -330,14 +330,14 @@ void PairDPDfdtEnergyKokkos::compute(int eflag_in, int vflag_in) comm->reverse_comm(this); } - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -400,11 +400,11 @@ void PairDPDfdtEnergyKokkos::operator()(TagPairDPDfdtEnergyComputeSp KK_FLOAT cutsq_ij = STACKPARAMS?m_cutsq[itype][jtype]:d_cutsq(itype,jtype); if (rsq < cutsq_ij) { - r = sqrt(rsq); - if (r < EPSILON) continue; // r can be 0.0 in DPD systems - rinv = 1.0/r; + r = Kokkos::sqrt(rsq); + if (r < static_cast(EPSILON)) continue; // r can be 0.0 in DPD systems + rinv = static_cast(1.0)/r; KK_FLOAT cut_ij = STACKPARAMS?m_params[itype][jtype].cut:params(itype,jtype).cut; - wr = 1.0 - r/cut_ij; + wr = static_cast(1.0) - r/cut_ij; wd = wr*wr; // conservative force = a0 * wr @@ -416,28 +416,28 @@ void PairDPDfdtEnergyKokkos::operator()(TagPairDPDfdtEnergyComputeSp fy_i += dely*fpair; fz_i += delz*fpair; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) -= delx*fpair; - a_f(j,1) -= dely*fpair; - a_f(j,2) -= delz*fpair; + a_f(j,0) -= static_cast(delx*fpair); + a_f(j,1) -= static_cast(dely*fpair); + a_f(j,2) -= static_cast(delz*fpair); } if (eflag) { // unshifted eng of conservative term: // evdwl = -a0[itype][jtype]*r * (1.0-0.5*r/d_cut(itype,jtype)); // eng shifted to 0.0 at cutoff - evdwl = 0.5*a0_ij*cut_ij * wd; + evdwl = static_cast(0.5)*a0_ij*cut_ij * wd; evdwl *= factor_dpd; if (EVFLAG) - ev.evdwl += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR||(j(1.0):static_cast(0.5))*static_cast(evdwl); } if (EVFLAG) this->template ev_tally(ev,i,j,evdwl,fpair,delx,dely,delz); } } - a_f(i,0) += fx_i; - a_f(i,1) += fy_i; - a_f(i,2) += fz_i; + a_f(i,0) += static_cast(fx_i); + a_f(i,1) += static_cast(fy_i); + a_f(i,2) += static_cast(fz_i); } template @@ -473,6 +473,10 @@ void PairDPDfdtEnergyKokkos::operator()(TagPairDPDfdtEnergyComputeNo rand_type rand_gen = rand_pool.get_state(); + const KK_FLOAT boltz_kk = static_cast(boltz); + const KK_FLOAT ftm2v_kk = static_cast(ftm2v); + const KK_FLOAT dtinvsqrt_kk = static_cast(dtinvsqrt); + i = d_ilist[ii]; xtmp = x(i,0); ytmp = x(i,1); @@ -500,26 +504,26 @@ void PairDPDfdtEnergyKokkos::operator()(TagPairDPDfdtEnergyComputeNo KK_FLOAT cutsq_ij = STACKPARAMS?m_cutsq[itype][jtype]:d_cutsq(itype,jtype); if (rsq < cutsq_ij) { - r = sqrt(rsq); - if (r < EPSILON) continue; // r can be 0.0 in DPD systems - rinv = 1.0/r; + r = Kokkos::sqrt(rsq); + if (r < static_cast(EPSILON)) continue; // r can be 0.0 in DPD systems + rinv = static_cast(1.0)/r; KK_FLOAT cut_ij = STACKPARAMS?m_params[itype][jtype].cut:params(itype,jtype).cut; - wr = 1.0 - r/cut_ij; + wr = static_cast(1.0) - r/cut_ij; wd = wr*wr; delvx = vxtmp - v(j,0); delvy = vytmp - v(j,1); delvz = vztmp - v(j,2); dot = delx*delvx + dely*delvy + delz*delvz; - randnum = rand_gen.normal(); + randnum = static_cast(rand_gen.normal()); // Compute the current temperature - theta_ij = 0.5*(1.0/dpdTheta[i] + 1.0/dpdTheta[j]); - theta_ij = 1.0/theta_ij; + theta_ij = static_cast(0.5)*(static_cast(1.0)/dpdTheta[i] + static_cast(1.0)/dpdTheta[j]); + theta_ij = static_cast(1.0)/theta_ij; KK_FLOAT sigma_ij = STACKPARAMS?m_params[itype][jtype].sigma:params(itype,jtype).sigma; gamma_ij = sigma_ij*sigma_ij - / (2.0*boltz*theta_ij); + / (static_cast(2.0)*boltz_kk*theta_ij); // conservative force = a0 * wr // drag force = -gamma * wr^2 * (delx dot delv) / r @@ -528,16 +532,16 @@ void PairDPDfdtEnergyKokkos::operator()(TagPairDPDfdtEnergyComputeNo KK_FLOAT a0_ij = STACKPARAMS?m_params[itype][jtype].a0:params(itype,jtype).a0; fpair = a0_ij*wr; fpair -= gamma_ij*wd*dot*rinv; - fpair += sigma_ij*wr*randnum*dtinvsqrt; + fpair += sigma_ij*wr*randnum*dtinvsqrt_kk; fpair *= factor_dpd*rinv; fx_i += delx*fpair; fy_i += dely*fpair; fz_i += delz*fpair; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) -= delx*fpair; - a_f(j,1) -= dely*fpair; - a_f(j,2) -= delz*fpair; + a_f(j,0) -= static_cast(delx*fpair); + a_f(j,1) -= static_cast(dely*fpair); + a_f(j,2) -= static_cast(delz*fpair); } if (rmass.data()) { @@ -547,17 +551,17 @@ void PairDPDfdtEnergyKokkos::operator()(TagPairDPDfdtEnergyComputeNo mass_i = mass[itype]; mass_j = mass[jtype]; } - massinv_i = 1.0 / mass_i; - massinv_j = 1.0 / mass_j; + massinv_i = static_cast(1.0) / mass_i; + massinv_j = static_cast(1.0) / mass_j; // Compute the mechanical and conductive energy, uMech and uCond mu_ij = massinv_i + massinv_j; - mu_ij *= ftm2v; + mu_ij *= ftm2v_kk; uTmp = gamma_ij*wd*rinv*rinv*dot*dot - - 0.5*sigma_ij*sigma_ij*mu_ij*wd; - uTmp -= sigma_ij*wr*rinv*dot*randnum*dtinvsqrt; - uTmp *= 0.5; + - static_cast(0.5)*sigma_ij*sigma_ij*mu_ij*wd; + uTmp -= sigma_ij*wr*rinv*dot*randnum*dtinvsqrt_kk; + uTmp *= static_cast(0.5); a_duMech[i] += uTmp; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { @@ -565,12 +569,12 @@ void PairDPDfdtEnergyKokkos::operator()(TagPairDPDfdtEnergyComputeNo } // Compute uCond - randnum = rand_gen.normal(); + randnum = static_cast(rand_gen.normal()); kappa_ij = STACKPARAMS?m_params[itype][jtype].kappa:params(itype,jtype).kappa; alpha_ij = STACKPARAMS?m_params[itype][jtype].alpha:params(itype,jtype).alpha; - randPair = alpha_ij*wr*randnum*dtinvsqrt; + randPair = alpha_ij*wr*randnum*dtinvsqrt_kk; - uTmp = kappa_ij*(1.0/dpdTheta[i] - 1.0/dpdTheta[j])*wd; + uTmp = kappa_ij*(static_cast(1.0)/dpdTheta[i] - static_cast(1.0)/dpdTheta[j])*wd; uTmp += randPair; a_duCond[i] += uTmp; @@ -582,19 +586,19 @@ void PairDPDfdtEnergyKokkos::operator()(TagPairDPDfdtEnergyComputeNo // unshifted eng of conservative term: // evdwl = -a0[itype][jtype]*r * (1.0-0.5*r/d_cut(itype,jtype)); // eng shifted to 0.0 at cutoff - evdwl = 0.5*a0_ij*cut_ij * wd; + evdwl = static_cast(0.5)*a0_ij*cut_ij * wd; evdwl *= factor_dpd; if (EVFLAG) - ev.evdwl += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR||(j(1.0):static_cast(0.5))*static_cast(evdwl); } if (EVFLAG) this->template ev_tally(ev,i,j,evdwl,fpair,delx,dely,delz); } } - a_f(i,0) += fx_i; - a_f(i,1) += fy_i; - a_f(i,2) += fz_i; + a_f(i,0) += static_cast(fx_i); + a_f(i,1) += static_cast(fy_i); + a_f(i,2) += static_cast(fz_i); rand_pool.free_state(rand_gen); } @@ -649,15 +653,15 @@ double PairDPDfdtEnergyKokkos::init_one(int i, int j) { double cutone = PairDPDfdtEnergy::init_one(i,j); - k_params.view_host()(i,j).cut = cut[i][j]; - k_params.view_host()(i,j).a0 = a0[i][j]; - k_params.view_host()(i,j).sigma = sigma[i][j]; - k_params.view_host()(i,j).kappa = kappa[i][j]; - k_params.view_host()(i,j).alpha = alpha[i][j]; + k_params.view_host()(i,j).cut = static_cast(cut[i][j]); + k_params.view_host()(i,j).a0 = static_cast(a0[i][j]); + k_params.view_host()(i,j).sigma = static_cast(sigma[i][j]); + k_params.view_host()(i,j).kappa = static_cast(kappa[i][j]); + k_params.view_host()(i,j).alpha = static_cast(alpha[i][j]); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } k_cutsq.view_host()(i,j) = cutone*cutone; @@ -687,75 +691,75 @@ void PairDPDfdtEnergyKokkos::ev_tally(EV_FLOAT &ev, const int &i, co if (EFLAG) { if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; if (NEIGHFLAG!=FULL) { - if (NEWTON_PAIR || i < nlocal) v_eatom[i] += epairhalf; - if (NEWTON_PAIR || j < nlocal) v_eatom[j] += epairhalf; + if (NEWTON_PAIR || i < nlocal) v_eatom[i] += static_cast(epairhalf); + if (NEWTON_PAIR || j < nlocal) v_eatom[j] += static_cast(epairhalf); } else { - v_eatom[i] += epairhalf; + v_eatom[i] += static_cast(epairhalf); } } } if (VFLAG) { - const KK_FLOAT v0 = delx*delx*fpair; - const KK_FLOAT v1 = dely*dely*fpair; - const KK_FLOAT v2 = delz*delz*fpair; - const KK_FLOAT v3 = delx*dely*fpair; - const KK_FLOAT v4 = delx*delz*fpair; - const KK_FLOAT v5 = dely*delz*fpair; + const KK_ACC_FLOAT v0 = static_cast(delx*delx*fpair); + const KK_ACC_FLOAT v1 = static_cast(dely*dely*fpair); + const KK_ACC_FLOAT v2 = static_cast(delz*delz*fpair); + const KK_ACC_FLOAT v3 = static_cast(delx*dely*fpair); + const KK_ACC_FLOAT v4 = static_cast(delx*delz*fpair); + const KK_ACC_FLOAT v5 = static_cast(dely*delz*fpair); if (vflag_global) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*v0; + ev.v[1] += static_cast(0.5)*v1; + ev.v[2] += static_cast(0.5)*v2; + ev.v[3] += static_cast(0.5)*v3; + ev.v[4] += static_cast(0.5)*v4; + ev.v[5] += static_cast(0.5)*v5; } if (NEWTON_PAIR || j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*v0; + ev.v[1] += static_cast(0.5)*v1; + ev.v[2] += static_cast(0.5)*v2; + ev.v[3] += static_cast(0.5)*v3; + ev.v[4] += static_cast(0.5)*v4; + ev.v[5] += static_cast(0.5)*v5; } } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*v0; + ev.v[1] += static_cast(0.5)*v1; + ev.v[2] += static_cast(0.5)*v2; + ev.v[3] += static_cast(0.5)*v3; + ev.v[4] += static_cast(0.5)*v4; + ev.v[5] += static_cast(0.5)*v5; } } if (vflag_atom) { if (NEIGHFLAG!=FULL) { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*v0; + v_vatom(i,1) += static_cast(0.5)*v1; + v_vatom(i,2) += static_cast(0.5)*v2; + v_vatom(i,3) += static_cast(0.5)*v3; + v_vatom(i,4) += static_cast(0.5)*v4; + v_vatom(i,5) += static_cast(0.5)*v5; if (NEWTON_PAIR || j < nlocal) { - v_vatom(j,0) += 0.5*v0; - v_vatom(j,1) += 0.5*v1; - v_vatom(j,2) += 0.5*v2; - v_vatom(j,3) += 0.5*v3; - v_vatom(j,4) += 0.5*v4; - v_vatom(j,5) += 0.5*v5; + v_vatom(j,0) += static_cast(0.5)*v0; + v_vatom(j,1) += static_cast(0.5)*v1; + v_vatom(j,2) += static_cast(0.5)*v2; + v_vatom(j,3) += static_cast(0.5)*v3; + v_vatom(j,4) += static_cast(0.5)*v4; + v_vatom(j,5) += static_cast(0.5)*v5; } } else { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*v0; + v_vatom(i,1) += static_cast(0.5)*v1; + v_vatom(i,2) += static_cast(0.5)*v2; + v_vatom(i,3) += static_cast(0.5)*v3; + v_vatom(i,4) += static_cast(0.5)*v4; + v_vatom(i,5) += static_cast(0.5)*v5; } } } diff --git a/src/KOKKOS/pair_dpd_kokkos.cpp b/src/KOKKOS/pair_dpd_kokkos.cpp index 74dbf0ec713..af0073033ad 100644 --- a/src/KOKKOS/pair_dpd_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_kokkos.cpp @@ -78,7 +78,7 @@ static constexpr double EPSILON = 1.0e-10; } \ unsigned int v = (state ^ (state>>26)) + wstate; \ unsigned int s = (signed int)((v^(v>>20))*g5); \ - randnum = SQRT3*(s*(TWO_N32)*2.0-1.0); \ + randnum = static_cast(SQRT3*(s*(TWO_N32)*2.0-1.0)); \ } template @@ -181,17 +181,17 @@ void PairDPDKokkos::compute(int eflagin, int vflagin) k_cutsq.template sync(); k_params.template sync(); - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_rf[0] = sqrt(force->special_lj[0]); - special_rf[1] = sqrt(force->special_lj[1]); - special_rf[2] = sqrt(force->special_lj[2]); - special_rf[3] = sqrt(force->special_lj[3]); + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_rf[0] = static_cast(sqrt(force->special_lj[0])); + special_rf[1] = static_cast(sqrt(force->special_lj[1])); + special_rf[2] = static_cast(sqrt(force->special_lj[2])); + special_rf[3] = static_cast(sqrt(force->special_lj[3])); nlocal = atom->nlocal; - dtinvsqrt = 1.0/sqrt(update->dt); + dtinvsqrt = static_cast(1.0/sqrt(update->dt)); NeighListKokkos* k_list = static_cast*>(list); d_numneigh = k_list->d_numneigh; @@ -246,14 +246,14 @@ void PairDPDKokkos::compute(int eflagin, int vflagin) if (need_dup) Kokkos::Experimental::contribute(f, dup_f); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -335,17 +335,17 @@ void PairDPDKokkos::operator() (TagDPDKokkos, cons rsq = delx*delx + dely*dely + delz*delz; jtype = type(j); if (rsq < d_cutsq(itype,jtype)) { - r = sqrt(rsq); - if (r < EPSILON) continue; // r can be 0.0 in DPD systems - rinv = 1.0/r; + r = Kokkos::sqrt(rsq); + if (r < static_cast(EPSILON)) continue; // r can be 0.0 in DPD systems + rinv = static_cast(1.0)/r; delvx = vxtmp - v(j,0); delvy = vytmp - v(j,1); delvz = vztmp - v(j,2); dot = delx*delvx + dely*delvy + delz*delvz; - wd = 1.0 - r/params(itype,jtype).cut; + wd = static_cast(1.0) - r/params(itype,jtype).cut; - randnum = rand_gen.normal(); + randnum = static_cast(rand_gen.normal()); // conservative force fpair = params(itype,jtype).a0*wd; @@ -362,25 +362,25 @@ void PairDPDKokkos::operator() (TagDPDKokkos, cons fy += fpair*dely; fz += fpair*delz; - a_f(j,0) -= fpair*delx; - a_f(j,1) -= fpair*dely; - a_f(j,2) -= fpair*delz; + a_f(j,0) -= static_cast(fpair*delx); + a_f(j,1) -= static_cast(fpair*dely); + a_f(j,2) -= static_cast(fpair*delz); if (EVFLAG && eflag_global) { // unshifted eng of conservative term: // evdwl = -a0[itype][jtype]*r * (1.0-0.5*r/cut[itype][jtype]); // eng shifted to 0.0 at cutoff - evdwl = 0.5*params(itype,jtype).a0*params(itype,jtype).cut* wd*wd; + evdwl = static_cast(0.5)*params(itype,jtype).a0*params(itype,jtype).cut* wd*wd; evdwl *= factor_dpd; - ev.evdwl += evdwl; + ev.evdwl += static_cast(evdwl); } if (EVFLAG && (eflag_atom || vflag_either)) this->template ev_tally(ev,i,j,evdwl,fpair,delx,dely,delz); } } - a_f(i,0) += fx; - a_f(i,1) += fy; - a_f(i,2) += fz; + a_f(i,0) += static_cast(fx); + a_f(i,1) += static_cast(fy); + a_f(i,2) += static_cast(fz); rand_pool.free_state(rand_gen); } @@ -450,15 +450,15 @@ void PairDPDKokkos::operator()(TagDPDKokkos, } if (rsq < d_cutsq(itype,jtype)) { - r = sqrt(rsq); - if (r < EPSILON) return; // r can be 0.0 in DPD systems - rinv = 1.0/r; + r = Kokkos::sqrt(rsq); + if (r < static_cast(EPSILON)) return; // r can be 0.0 in DPD systems + rinv = static_cast(1.0)/r; delvx = vxtmp - v(j,0); delvy = vytmp - v(j,1); delvz = vztmp - v(j,2); dot = delx*delvx + dely*delvy + delz*delvz; - wd = 1.0 - r/params(itype,jtype).cut; + wd = static_cast(1.0) - r/params(itype,jtype).cut; // random number from SARU randnum = 0; @@ -479,17 +479,17 @@ void PairDPDKokkos::operator()(TagDPDKokkos, fy += fpair*dely; fz += fpair*delz; - a_f(j,0) -= fpair*delx; - a_f(j,1) -= fpair*dely; - a_f(j,2) -= fpair*delz; + a_f(j,0) -= static_cast(fpair*delx); + a_f(j,1) -= static_cast(fpair*dely); + a_f(j,2) -= static_cast(fpair*delz); if (EVFLAG && eflag_global) { // unshifted eng of conservative term: // evdwl = -a0[itype][jtype]*r * (1.0-0.5*r/cut[itype][jtype]); // eng shifted to 0.0 at cutoff - evdwl = 0.5*params(itype,jtype).a0*params(itype,jtype).cut* wd*wd; + evdwl = static_cast(0.5)*params(itype,jtype).a0*params(itype,jtype).cut* wd*wd; evdwl *= factor_dpd; - ev.evdwl += evdwl; + ev.evdwl += static_cast(evdwl); } if (EVFLAG && (eflag_atom || vflag_either)) this->template ev_tally(ev,i,j,evdwl,fpair,delx,dely,delz); @@ -497,9 +497,9 @@ void PairDPDKokkos::operator()(TagDPDKokkos, }, fxtmp, fytmp, fztmp); Kokkos::single(Kokkos::PerTeam(team), [&] () { - a_f(i,0) += fxtmp; - a_f(i,1) += fytmp; - a_f(i,2) += fztmp; + a_f(i,0) += static_cast(fxtmp); + a_f(i,1) += static_cast(fytmp); + a_f(i,2) += static_cast(fztmp); }); } @@ -523,9 +523,9 @@ void PairDPDKokkos::ev_tally(EV_FLOAT &ev, const int &i, const int & auto a_vatom = v_vatom.template access>(); if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; - a_eatom[i] += epairhalf; - a_eatom[j] += epairhalf; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; + a_eatom[i] += static_cast(epairhalf); + a_eatom[j] += static_cast(epairhalf); } if (vflag_either) { @@ -537,27 +537,27 @@ void PairDPDKokkos::ev_tally(EV_FLOAT &ev, const int &i, const int & const KK_FLOAT v5 = dely*delz*fpair; if (vflag_global) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } if (vflag_atom) { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; + a_vatom(i,0) += static_cast(0.5)*static_cast(v0); + a_vatom(i,1) += static_cast(0.5)*static_cast(v1); + a_vatom(i,2) += static_cast(0.5)*static_cast(v2); + a_vatom(i,3) += static_cast(0.5)*static_cast(v3); + a_vatom(i,4) += static_cast(0.5)*static_cast(v4); + a_vatom(i,5) += static_cast(0.5)*static_cast(v5); + a_vatom(j,0) += static_cast(0.5)*static_cast(v0); + a_vatom(j,1) += static_cast(0.5)*static_cast(v1); + a_vatom(j,2) += static_cast(0.5)*static_cast(v2); + a_vatom(j,3) += static_cast(0.5)*static_cast(v3); + a_vatom(j,4) += static_cast(0.5)*static_cast(v4); + a_vatom(j,5) += static_cast(0.5)*static_cast(v5); } } } @@ -596,10 +596,10 @@ double PairDPDKokkos::init_one(int i, int j) { double cutone = PairDPD::init_one(i,j); - k_params.view_host()(i,j).cut = cut[i][j]; - k_params.view_host()(i,j).a0 = a0[i][j]; - k_params.view_host()(i,j).gamma = gamma[i][j]; - k_params.view_host()(i,j).sigma = sigma[i][j]; + k_params.view_host()(i,j).cut = static_cast(cut[i][j]); + k_params.view_host()(i,j).a0 = static_cast(a0[i][j]); + k_params.view_host()(i,j).gamma = static_cast(gamma[i][j]); + k_params.view_host()(i,j).sigma = static_cast(sigma[i][j]); k_params.view_host()(j,i) = k_params.view_host()(i,j); k_params.modify_host(); diff --git a/src/KOKKOS/pair_dpd_tstat_kokkos.cpp b/src/KOKKOS/pair_dpd_tstat_kokkos.cpp index b13053942b3..9c92724cae8 100644 --- a/src/KOKKOS/pair_dpd_tstat_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_tstat_kokkos.cpp @@ -117,7 +117,7 @@ void PairDPDTstatKokkos::compute(int eflagin, int vflagin) for (int i = 1; i <= atom->ntypes; i++) for (int j = i; j <= atom->ntypes; j++) { k_params.view_host()(i,j).sigma = k_params.view_host()(j,i).sigma = - sqrt(2.0*boltz*temperature*gamma[i][j]); + static_cast(sqrt(2.0*boltz*temperature*gamma[i][j])); } } k_params.modify_host(); @@ -144,17 +144,17 @@ void PairDPDTstatKokkos::compute(int eflagin, int vflagin) k_cutsq.template sync(); k_params.template sync(); - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_rf[0] = sqrt(force->special_lj[0]); - special_rf[1] = sqrt(force->special_lj[1]); - special_rf[2] = sqrt(force->special_lj[2]); - special_rf[3] = sqrt(force->special_lj[3]); + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_rf[0] = static_cast(sqrt(force->special_lj[0])); + special_rf[1] = static_cast(sqrt(force->special_lj[1])); + special_rf[2] = static_cast(sqrt(force->special_lj[2])); + special_rf[3] = static_cast(sqrt(force->special_lj[3])); nlocal = atom->nlocal; - dtinvsqrt = 1.0/sqrt(update->dt); + dtinvsqrt = static_cast(1.0/sqrt(update->dt)); NeighListKokkos* k_list = static_cast*>(list); d_numneigh = k_list->d_numneigh; @@ -187,12 +187,12 @@ void PairDPDTstatKokkos::compute(int eflagin, int vflagin) Kokkos::Experimental::contribute(f, dup_f); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -266,17 +266,17 @@ void PairDPDTstatKokkos::operator() (TagDPDTstatKokkos(EPSILON)) continue; // r can be 0.0 in DPD systems + rinv = static_cast(1.0)/r; delvx = vxtmp - v(j,0); delvy = vytmp - v(j,1); delvz = vztmp - v(j,2); dot = delx*delvx + dely*delvy + delz*delvz; - wd = 1.0 - r/params(itype,jtype).cut; + wd = static_cast(1.0) - r/params(itype,jtype).cut; - randnum = rand_gen.normal(); + randnum = static_cast(rand_gen.normal()); // drag force - parallel fpair = -params(itype,jtype).gamma*wd*wd*dot*rinv; @@ -290,17 +290,17 @@ void PairDPDTstatKokkos::operator() (TagDPDTstatKokkos(fpair*delx); + a_f(j,1) -= static_cast(fpair*dely); + a_f(j,2) -= static_cast(fpair*delz); if (VFLAG) this->template v_tally(ev,i,j,fpair,delx,dely,delz); } } - a_f(i,0) += fx; - a_f(i,1) += fy; - a_f(i,2) += fz; + a_f(i,0) += static_cast(fx); + a_f(i,1) += static_cast(fy); + a_f(i,2) += static_cast(fz); rand_pool.free_state(rand_gen); } @@ -328,27 +328,27 @@ void PairDPDTstatKokkos::v_tally(EV_FLOAT &ev, const int &i, const i const KK_FLOAT v5 = dely*delz*fpair; if (vflag_global) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } if (vflag_atom) { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; + a_vatom(i,0) += static_cast(0.5)*static_cast(v0); + a_vatom(i,1) += static_cast(0.5)*static_cast(v1); + a_vatom(i,2) += static_cast(0.5)*static_cast(v2); + a_vatom(i,3) += static_cast(0.5)*static_cast(v3); + a_vatom(i,4) += static_cast(0.5)*static_cast(v4); + a_vatom(i,5) += static_cast(0.5)*static_cast(v5); + a_vatom(j,0) += static_cast(0.5)*static_cast(v0); + a_vatom(j,1) += static_cast(0.5)*static_cast(v1); + a_vatom(j,2) += static_cast(0.5)*static_cast(v2); + a_vatom(j,3) += static_cast(0.5)*static_cast(v3); + a_vatom(j,4) += static_cast(0.5)*static_cast(v4); + a_vatom(j,5) += static_cast(0.5)*static_cast(v5); } } @@ -386,9 +386,9 @@ double PairDPDTstatKokkos::init_one(int i, int j) { double cutone = PairDPD::init_one(i,j); - k_params.view_host()(i,j).cut = cut[i][j]; - k_params.view_host()(i,j).gamma = gamma[i][j]; - k_params.view_host()(i,j).sigma = sigma[i][j]; + k_params.view_host()(i,j).cut = static_cast(cut[i][j]); + k_params.view_host()(i,j).gamma = static_cast(gamma[i][j]); + k_params.view_host()(i,j).sigma = static_cast(sigma[i][j]); k_params.view_host()(j,i) = k_params.view_host()(i,j); k_params.modify_host(); diff --git a/src/KOKKOS/pair_eam_kokkos.cpp b/src/KOKKOS/pair_eam_kokkos.cpp index fc20a880c50..aacac1d3161 100644 --- a/src/KOKKOS/pair_eam_kokkos.cpp +++ b/src/KOKKOS/pair_eam_kokkos.cpp @@ -599,7 +599,7 @@ void PairEAMKokkos::operator()(TagPairEAMKernelA(1.0); + KK_FLOAT p = Kokkos::sqrt(rsq)*rdr_kk + static_cast(1.0); int m = static_cast (p); m = MIN(m,nr-1); p -= static_cast(m); @@ -693,7 +693,7 @@ void PairEAMKokkos::operator()(TagPairEAMKernelAB, const int const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (rsq < cutforcesq_kk) { - KK_FLOAT p = sqrt(rsq)*rdr_kk + static_cast(1.0); + KK_FLOAT p = Kokkos::sqrt(rsq)*rdr_kk + static_cast(1.0); int m = static_cast (p); m = MIN(m,nr-1); p -= static_cast(m); @@ -773,7 +773,7 @@ void PairEAMKokkos::operator()(TagPairEAMKernelC(1.0); int m = static_cast (p); m = MIN(m,nr-1); @@ -898,7 +898,7 @@ void PairEAMKokkos::operator()(TagPairEAMKernelAB, const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (rsq < cutforcesq_kk) { - KK_FLOAT p = sqrt(rsq)*rdr_kk + static_cast(1.0); + KK_FLOAT p = Kokkos::sqrt(rsq)*rdr_kk + static_cast(1.0); int m = static_cast (p); m = MIN(m,nr-1); p -= m; diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index 6fb5288b020..027fcd0a101 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -141,10 +141,10 @@ void PairExp6rxKokkos::compute(int eflag_in, int vflag_in) rx_fixKK->get_k_species_ind_to_atom_prop_ind_old().template view(); nlocal = atom->nlocal; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); newton_pair = force->newton_pair; atomKK->sync(execution_space,X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK | UCG_MASK | UCGNEW_MASK | DVECTOR_MASK); @@ -321,14 +321,14 @@ void PairExp6rxKokkos::compute(int eflag_in, int vflag_in) if (k_error_flag.view_host()()) error->all(FLERR,"alpha_ij is 6.0 in pair exp6"); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -444,7 +444,7 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute(1.05); KK_FLOAT rin1, aRep, uin1, win1, uin1rep, rin1exp, rin6, rin6inv; evdwlOld = 0.0; @@ -495,14 +495,14 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute(1.0)/rsq; r6inv = r2inv*r2inv*r2inv; - r = sqrt(rsq); + r = Kokkos::sqrt(rsq); rCut2inv = 1.0/d_cutsq(itype,jtype); rCut6inv = rCut2inv*rCut2inv*rCut2inv; rCut = sqrt(d_cutsq(itype,jtype)); - rCutInv = 1.0/rCut; + rCutInv = static_cast(1.0)/rCut; // // A. Compute the exp-6 potential @@ -530,19 +530,19 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute(0.5)*(rmOld1_i + rmOld2_j); + epsilonOld12_ij = Kokkos::sqrt(epsilonOld1_i*epsilonOld2_j); + alphaOld21_ij = Kokkos::sqrt(alphaOld2_i*alphaOld1_j); + rmOld21_ij = static_cast(0.5)*(rmOld2_i + rmOld1_j); + epsilonOld21_ij = Kokkos::sqrt(epsilonOld2_i*epsilonOld1_j); + + alpha12_ij = Kokkos::sqrt(alpha1_i*alpha2_j); + rm12_ij = static_cast(0.5)*(rm1_i + rm2_j); + epsilon12_ij = Kokkos::sqrt(epsilon1_i*epsilon2_j); + alpha21_ij = Kokkos::sqrt(alpha2_i*alpha1_j); + rm21_ij = static_cast(0.5)*(rm2_i + rm1_j); + epsilon21_ij = Kokkos::sqrt(epsilon2_i*epsilon1_j); evdwlOldEXP6_12 = 0.0; evdwlOldEXP6_21 = 0.0; @@ -551,30 +551,30 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute(0.0) && rmOld21_ij!=static_cast(0.0)) { + if (alphaOld21_ij == static_cast(6.0) || alphaOld12_ij == static_cast(6.0)) k_error_flag.template view()() = 1; // A3. Compute some convenient quantities for evaluating the force - rminv = 1.0/rmOld12_ij; - buck1 = epsilonOld12_ij / (alphaOld12_ij - 6.0); + rminv = static_cast(1.0)/rmOld12_ij; + buck1 = epsilonOld12_ij / (alphaOld12_ij - static_cast(6.0)); rexp = expValue(alphaOld12_ij*(1.0-r*rminv)); rm2ij = rmOld12_ij*rmOld12_ij; rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential rCutExp = expValue(alphaOld12_ij*(1.0-rCut*rminv)); - buck2 = 6.0*alphaOld12_ij; - urc = buck1*(6.0*rCutExp - alphaOld12_ij*rm6ij*rCut6inv); + buck2 = static_cast(6.0)*alphaOld12_ij; + urc = buck1*(static_cast(6.0)*rCutExp - alphaOld12_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld12_ij*func_rin(alphaOld12_ij); if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - rin6inv = 1.0/rin6; + rin6inv = static_cast(1.0)/rin6; rin1exp = expValue(alphaOld12_ij*(1.0-rin1*rminv)); - uin1 = buck1*(6.0*rin1exp - alphaOld12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + uin1 = buck1*(static_cast(6.0)*rin1exp - alphaOld12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -590,31 +590,31 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute(6.0)*rexp - alphaOld12_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } // A3. Compute some convenient quantities for evaluating the force - rminv = 1.0/rmOld21_ij; - buck1 = epsilonOld21_ij / (alphaOld21_ij - 6.0); - buck2 = 6.0*alphaOld21_ij; + rminv = static_cast(1.0)/rmOld21_ij; + buck1 = epsilonOld21_ij / (alphaOld21_ij - static_cast(6.0)); + buck2 = static_cast(6.0)*alphaOld21_ij; rexp = expValue(alphaOld21_ij*(1.0-r*rminv)); rm2ij = rmOld21_ij*rmOld21_ij; rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential rCutExp = expValue(alphaOld21_ij*(1.0-rCut*rminv)); - buck2 = 6.0*alphaOld21_ij; - urc = buck1*(6.0*rCutExp - alphaOld21_ij*rm6ij*rCut6inv); + buck2 = static_cast(6.0)*alphaOld21_ij; + urc = buck1*(static_cast(6.0)*rCutExp - alphaOld21_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld21_ij*func_rin(alphaOld21_ij); if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - rin6inv = 1.0/rin6; + rin6inv = static_cast(1.0)/rin6; rin1exp = expValue(alphaOld21_ij*(1.0-rin1*rminv)); - uin1 = buck1*(6.0*rin1exp - alphaOld21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + uin1 = buck1*(static_cast(6.0)*rin1exp - alphaOld21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -630,46 +630,46 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute(6.0)*rexp - alphaOld21_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } if (isite1 == isite2) - evdwlOld = sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12; + evdwlOld = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12; else - evdwlOld = sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12 + sqrt(mixWtSite2old_i*mixWtSite1old_j)*evdwlOldEXP6_21; + evdwlOld = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12 + Kokkos::sqrt(mixWtSite2old_i*mixWtSite1old_j)*evdwlOldEXP6_21; evdwlOld *= factor_lj; - uCG_i += 0.5*evdwlOld; + uCG_i += static_cast(0.5)*evdwlOld; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) a_uCG[j] += 0.5*evdwlOld; } - if (rm12_ij!=0.0 && rm21_ij!=0.0) { - if (alpha21_ij == 6.0 || alpha12_ij == 6.0) + if (rm12_ij!=static_cast(0.0) && rm21_ij!=static_cast(0.0)) { + if (alpha21_ij == static_cast(6.0) || alpha12_ij == static_cast(6.0)) k_error_flag.template view()() = 1; // A3. Compute some convenient quantities for evaluating the force - rminv = 1.0/rm12_ij; - buck1 = epsilon12_ij / (alpha12_ij - 6.0); - buck2 = 6.0*alpha12_ij; + rminv = static_cast(1.0)/rm12_ij; + buck1 = epsilon12_ij / (alpha12_ij - static_cast(6.0)); + buck2 = static_cast(6.0)*alpha12_ij; rexp = expValue(alpha12_ij*(1.0-r*rminv)); rm2ij = rm12_ij*rm12_ij; rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential rCutExp = expValue(alpha12_ij*(1.0-rCut*rminv)); - urc = buck1*(6.0*rCutExp - alpha12_ij*rm6ij*rCut6inv); + urc = buck1*(static_cast(6.0)*rCutExp - alpha12_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm12_ij*func_rin(alpha12_ij); if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - rin6inv = 1.0/rin6; + rin6inv = static_cast(1.0)/rin6; rin1exp = expValue(alpha12_ij*(1.0-rin1*rminv)); - uin1 = buck1*(6.0*rin1exp - alpha12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + uin1 = buck1*(static_cast(6.0)*rin1exp - alpha12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -679,29 +679,29 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute(6.0)*rexp - alpha12_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } - rminv = 1.0/rm21_ij; - buck1 = epsilon21_ij / (alpha21_ij - 6.0); - buck2 = 6.0*alpha21_ij; + rminv = static_cast(1.0)/rm21_ij; + buck1 = epsilon21_ij / (alpha21_ij - static_cast(6.0)); + buck2 = static_cast(6.0)*alpha21_ij; rexp = expValue(alpha21_ij*(1.0-r*rminv)); rm2ij = rm21_ij*rm21_ij; rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential rCutExp = expValue(alpha21_ij*(1.0-rCut*rminv)); - urc = buck1*(6.0*rCutExp - alpha21_ij*rm6ij*rCut6inv); + urc = buck1*(static_cast(6.0)*rCutExp - alpha21_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm21_ij*func_rin(alpha21_ij); if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - rin6inv = 1.0/rin6; + rin6inv = static_cast(1.0)/rin6; rin1exp = expValue(alpha21_ij*(1.0-rin1*rminv)); - uin1 = buck1*(6.0*rin1exp - alpha21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + uin1 = buck1*(static_cast(6.0)*rin1exp - alpha21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -711,15 +711,15 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute(6.0)*rexp - alpha21_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } } // // Apply Mixing Rule to get the overall force for the CG pair // - if (isite1 == isite2) fpair = sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12; - else fpair = sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12 + sqrt(mixWtSite2old_i*mixWtSite1old_j)*fpairOldEXP6_21; + if (isite1 == isite2) fpair = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12; + else fpair = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12 + Kokkos::sqrt(mixWtSite2old_i*mixWtSite1old_j)*fpairOldEXP6_21; fx_i += delx*fpair; fy_i += dely*fpair; @@ -730,11 +730,11 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxCompute(0.5)*evdwl; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) a_uCGnew[j] += 0.5*evdwl; evdwl = evdwlOld; @@ -820,7 +820,7 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics(1.05); KK_FLOAT rin1, aRep, uin1, win1, uin1rep, rin1exp, rin6, rin6inv; evdwlOld = 0.0; @@ -871,14 +871,14 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics(1.0)/rsq; r6inv = r2inv*r2inv*r2inv; - r = sqrt(rsq); - rCut2inv = 1.0/d_cutsq(itype,jtype); + r = Kokkos::sqrt(rsq); + rCut2inv = static_cast(1.0)/d_cutsq(itype,jtype); rCut6inv = rCut2inv*rCut2inv*rCut2inv; - rCut = sqrt(d_cutsq(itype,jtype)); - rCutInv = 1.0/rCut; + rCut = Kokkos::sqrt(d_cutsq(itype,jtype)); + rCutInv = static_cast(1.0)/rCut; // // A. Compute the exp-6 potential @@ -906,19 +906,19 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics(0.5)*(rmOld1_i + rmOld2_j); + epsilonOld12_ij = Kokkos::sqrt(epsilonOld1_i*epsilonOld2_j); + alphaOld21_ij = Kokkos::sqrt(alphaOld2_i*alphaOld1_j); + rmOld21_ij = static_cast(0.5)*(rmOld2_i + rmOld1_j); + epsilonOld21_ij = Kokkos::sqrt(epsilonOld2_i*epsilonOld1_j); + + alpha12_ij = Kokkos::sqrt(alpha1_i*alpha2_j); + rm12_ij = static_cast(0.5)*(rm1_i + rm2_j); + epsilon12_ij = Kokkos::sqrt(epsilon1_i*epsilon2_j); + alpha21_ij = Kokkos::sqrt(alpha2_i*alpha1_j); + rm21_ij = static_cast(0.5)*(rm2_i + rm1_j); + epsilon21_ij = Kokkos::sqrt(epsilon2_i*epsilon1_j); evdwlOldEXP6_12 = 0.0; evdwlOldEXP6_21 = 0.0; @@ -927,30 +927,30 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics(0.0) && rmOld21_ij!=static_cast(0.0)) { + if (alphaOld21_ij == static_cast(6.0) || alphaOld12_ij == static_cast(6.0)) k_error_flag.template view()() = 1; // A3. Compute some convenient quantities for evaluating the force - rminv = 1.0/rmOld12_ij; - buck1 = epsilonOld12_ij / (alphaOld12_ij - 6.0); - rexp = expValue(alphaOld12_ij*(1.0-r*rminv)); + rminv = static_cast(1.0)/rmOld12_ij; + buck1 = epsilonOld12_ij / (alphaOld12_ij - static_cast(6.0)); + rexp = expValue(alphaOld12_ij*(static_cast(1.0)-r*rminv)); rm2ij = rmOld12_ij*rmOld12_ij; rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential - rCutExp = expValue(alphaOld12_ij*(1.0-rCut*rminv)); - buck2 = 6.0*alphaOld12_ij; - urc = buck1*(6.0*rCutExp - alphaOld12_ij*rm6ij*rCut6inv); + rCutExp = expValue(alphaOld12_ij*(static_cast(1.0)-rCut*rminv)); + buck2 = static_cast(6.0)*alphaOld12_ij; + urc = buck1*(static_cast(6.0)*rCutExp - alphaOld12_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld12_ij*func_rin(alphaOld12_ij); if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - rin6inv = 1.0/rin6; + rin6inv = static_cast(1.0)/rin6; - rin1exp = expValue(alphaOld12_ij*(1.0-rin1*rminv)); + rin1exp = expValue(alphaOld12_ij*(static_cast(1.0)-rin1*rminv)); - uin1 = buck1*(6.0*rin1exp - alphaOld12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + uin1 = buck1*(static_cast(6.0)*rin1exp - alphaOld12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -966,31 +966,31 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics(6.0)*rexp - alphaOld12_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } // A3. Compute some convenient quantities for evaluating the force - rminv = 1.0/rmOld21_ij; - buck1 = epsilonOld21_ij / (alphaOld21_ij - 6.0); - buck2 = 6.0*alphaOld21_ij; - rexp = expValue(alphaOld21_ij*(1.0-r*rminv)); + rminv = static_cast(1.0)/rmOld21_ij; + buck1 = epsilonOld21_ij / (alphaOld21_ij - static_cast(6.0)); + buck2 = static_cast(6.0)*alphaOld21_ij; + rexp = expValue(alphaOld21_ij*(static_cast(1.0)-r*rminv)); rm2ij = rmOld21_ij*rmOld21_ij; rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential - rCutExp = expValue(alphaOld21_ij*(1.0-rCut*rminv)); - buck2 = 6.0*alphaOld21_ij; - urc = buck1*(6.0*rCutExp - alphaOld21_ij*rm6ij*rCut6inv); + rCutExp = expValue(alphaOld21_ij*(static_cast(1.0)-rCut*rminv)); + buck2 = static_cast(6.0)*alphaOld21_ij; + urc = buck1*(static_cast(6.0)*rCutExp - alphaOld21_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld21_ij*func_rin(alphaOld21_ij); if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - rin6inv = 1.0/rin6; + rin6inv = static_cast(1.0)/rin6; - rin1exp = expValue(alphaOld21_ij*(1.0-rin1*rminv)); + rin1exp = expValue(alphaOld21_ij*(static_cast(1.0)-rin1*rminv)); - uin1 = buck1*(6.0*rin1exp - alphaOld21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + uin1 = buck1*(static_cast(6.0)*rin1exp - alphaOld21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -1006,46 +1006,46 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics(6.0)*rexp - alphaOld21_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } if (isite1 == isite2) - evdwlOld = sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12; + evdwlOld = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12; else - evdwlOld = sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12 + sqrt(mixWtSite2old_i*mixWtSite1old_j)*evdwlOldEXP6_21; + evdwlOld = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12 + Kokkos::sqrt(mixWtSite2old_i*mixWtSite1old_j)*evdwlOldEXP6_21; evdwlOld *= factor_lj; - uCG_i += 0.5*evdwlOld; + uCG_i += static_cast(0.5)*evdwlOld; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) - t_uCG(tid,j) += 0.5*evdwlOld; + t_uCG(tid,j) += static_cast(0.5)*evdwlOld; } - if (rm12_ij!=0.0 && rm21_ij!=0.0) { - if (alpha21_ij == 6.0 || alpha12_ij == 6.0) + if (rm12_ij!=static_cast(0.0) && rm21_ij!=static_cast(0.0)) { + if (alpha21_ij == static_cast(6.0) || alpha12_ij == static_cast(6.0)) k_error_flag.template view()() = 1; // A3. Compute some convenient quantities for evaluating the force - rminv = 1.0/rm12_ij; - buck1 = epsilon12_ij / (alpha12_ij - 6.0); - buck2 = 6.0*alpha12_ij; - rexp = expValue(alpha12_ij*(1.0-r*rminv)); + rminv = static_cast(1.0)/rm12_ij; + buck1 = epsilon12_ij / (alpha12_ij - static_cast(6.0)); + buck2 = static_cast(6.0)*alpha12_ij; + rexp = expValue(alpha12_ij*(static_cast(1.0)-r*rminv)); rm2ij = rm12_ij*rm12_ij; rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential - rCutExp = expValue(alpha12_ij*(1.0-rCut*rminv)); - urc = buck1*(6.0*rCutExp - alpha12_ij*rm6ij*rCut6inv); + rCutExp = expValue(alpha12_ij*(static_cast(1.0)-rCut*rminv)); + urc = buck1*(static_cast(6.0)*rCutExp - alpha12_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm12_ij*func_rin(alpha12_ij); if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - rin6inv = 1.0/rin6; + rin6inv = static_cast(1.0)/rin6; - rin1exp = expValue(alpha12_ij*(1.0-rin1*rminv)); + rin1exp = expValue(alpha12_ij*(static_cast(1.0)-rin1*rminv)); - uin1 = buck1*(6.0*rin1exp - alpha12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + uin1 = buck1*(static_cast(6.0)*rin1exp - alpha12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -1055,29 +1055,29 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics(6.0)*rexp - alpha12_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } - rminv = 1.0/rm21_ij; - buck1 = epsilon21_ij / (alpha21_ij - 6.0); - buck2 = 6.0*alpha21_ij; - rexp = expValue(alpha21_ij*(1.0-r*rminv)); + rminv = static_cast(1.0)/rm21_ij; + buck1 = epsilon21_ij / (alpha21_ij - static_cast(6.0)); + buck2 = static_cast(6.0)*alpha21_ij; + rexp = expValue(alpha21_ij*(static_cast(1.0)-r*rminv)); rm2ij = rm21_ij*rm21_ij; rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential - rCutExp = expValue(alpha21_ij*(1.0-rCut*rminv)); - urc = buck1*(6.0*rCutExp - alpha21_ij*rm6ij*rCut6inv); + rCutExp = expValue(alpha21_ij*(static_cast(1.0)-rCut*rminv)); + urc = buck1*(static_cast(6.0)*rCutExp - alpha21_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm21_ij*func_rin(alpha21_ij); if (r < rin1) { rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - rin6inv = 1.0/rin6; + rin6inv = static_cast(1.0)/rin6; - rin1exp = expValue(alpha21_ij*(1.0-rin1*rminv)); + rin1exp = expValue(alpha21_ij*(static_cast(1.0)-rin1*rminv)); - uin1 = buck1*(6.0*rin1exp - alpha21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + uin1 = buck1*(static_cast(6.0)*rin1exp - alpha21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -1087,15 +1087,15 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics(6.0)*rexp - alpha21_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } } // // Apply Mixing Rule to get the overall force for the CG pair // - if (isite1 == isite2) fpair = sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12; - else fpair = sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12 + sqrt(mixWtSite2old_i*mixWtSite1old_j)*fpairOldEXP6_21; + if (isite1 == isite2) fpair = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12; + else fpair = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12 + Kokkos::sqrt(mixWtSite2old_i*mixWtSite1old_j)*fpairOldEXP6_21; fx_i += delx*fpair; fy_i += dely*fpair; @@ -1106,16 +1106,16 @@ void PairExp6rxKokkos::operator()(TagPairExp6rxComputeNoAtomics(0.5)*evdwl; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) - t_uCGnew(tid,j) += 0.5*evdwl; + t_uCGnew(tid,j) += static_cast(0.5)*evdwl; evdwl = evdwlOld; if (EVFLAG) - ev.evdwl += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR||(j(1.0):static_cast(0.5))*static_cast(evdwl); //if (vflag_either || eflag_atom) if (EVFLAG) this->template ev_tally(ev,i,j,evdwl,fpair,delx,dely,delz); } @@ -1170,7 +1170,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& #endif const int nRep = 12; - const KK_FLOAT shift = 1.05; + const KK_FLOAT shift = static_cast(1.05); const int i = d_ilist[ii]; const KK_FLOAT xtmp = x(i,0); @@ -1204,10 +1204,10 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& const KK_FLOAT mixWtSite2old_i = PairExp6ParamData.mixWtSite2old[i]; const KK_FLOAT cutsq_type11 = d_cutsq(1,1); - const KK_FLOAT rCut2inv_type11 = 1.0/ cutsq_type11; + const KK_FLOAT rCut2inv_type11 = static_cast(1.0)/ cutsq_type11; const KK_FLOAT rCut6inv_type11 = rCut2inv_type11*rCut2inv_type11*rCut2inv_type11; - const KK_FLOAT rCut_type11 = sqrt( cutsq_type11 ); - const KK_FLOAT rCutInv_type11 = 1.0/rCut_type11; + const KK_FLOAT rCut_type11 = Kokkos::sqrt( cutsq_type11 ); + const KK_FLOAT rCutInv_type11 = static_cast(1.0)/rCut_type11; // Do error testing locally. bool hasError = false; @@ -1288,14 +1288,14 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& // if (rsq < d_cutsq(itype,jtype)) // optimize { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT rCut2inv = (OneType) ? rCut2inv_type11 : (1.0/ cutsq_j[jlane]); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT rCut2inv = (OneType) ? rCut2inv_type11 : (static_cast(1.0)/ cutsq_j[jlane]); const KK_FLOAT rCut6inv = (OneType) ? rCut6inv_type11 : (rCut2inv*rCut2inv*rCut2inv); - const KK_FLOAT rCut = (OneType) ? rCut_type11 : (sqrt( cutsq_j[jlane] )); - const KK_FLOAT rCutInv = (OneType) ? rCutInv_type11 : (1.0/rCut); + const KK_FLOAT rCut = (OneType) ? rCut_type11 : (Kokkos::sqrt( cutsq_j[jlane] )); + const KK_FLOAT rCutInv = (OneType) ? rCutInv_type11 : (static_cast(1.0)/rCut); // // A. Compute the exp-6 potential @@ -1321,19 +1321,19 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& const KK_FLOAT mixWtSite2old_j = PairExp6ParamData.mixWtSite2old[j]; // A2. Apply Lorentz-Berthelot mixing rules for the i-j pair - const KK_FLOAT alphaOld12_ij = sqrt(alphaOld1_i*alphaOld2_j); - const KK_FLOAT rmOld12_ij = 0.5*(rmOld1_i + rmOld2_j); - const KK_FLOAT epsilonOld12_ij = sqrt(epsilonOld1_i*epsilonOld2_j); - const KK_FLOAT alphaOld21_ij = sqrt(alphaOld2_i*alphaOld1_j); - const KK_FLOAT rmOld21_ij = 0.5*(rmOld2_i + rmOld1_j); - const KK_FLOAT epsilonOld21_ij = sqrt(epsilonOld2_i*epsilonOld1_j); - - const KK_FLOAT alpha12_ij = sqrt(alpha1_i*alpha2_j); - const KK_FLOAT rm12_ij = 0.5*(rm1_i + rm2_j); - const KK_FLOAT epsilon12_ij = sqrt(epsilon1_i*epsilon2_j); - const KK_FLOAT alpha21_ij = sqrt(alpha2_i*alpha1_j); - const KK_FLOAT rm21_ij = 0.5*(rm2_i + rm1_j); - const KK_FLOAT epsilon21_ij = sqrt(epsilon2_i*epsilon1_j); + const KK_FLOAT alphaOld12_ij = Kokkos::sqrt(alphaOld1_i*alphaOld2_j); + const KK_FLOAT rmOld12_ij = static_cast(0.5)*(rmOld1_i + rmOld2_j); + const KK_FLOAT epsilonOld12_ij = Kokkos::sqrt(epsilonOld1_i*epsilonOld2_j); + const KK_FLOAT alphaOld21_ij = Kokkos::sqrt(alphaOld2_i*alphaOld1_j); + const KK_FLOAT rmOld21_ij = static_cast(0.5)*(rmOld2_i + rmOld1_j); + const KK_FLOAT epsilonOld21_ij = Kokkos::sqrt(epsilonOld2_i*epsilonOld1_j); + + const KK_FLOAT alpha12_ij = Kokkos::sqrt(alpha1_i*alpha2_j); + const KK_FLOAT rm12_ij = static_cast(0.5)*(rm1_i + rm2_j); + const KK_FLOAT epsilon12_ij = Kokkos::sqrt(epsilon1_i*epsilon2_j); + const KK_FLOAT alpha21_ij = Kokkos::sqrt(alpha2_i*alpha1_j); + const KK_FLOAT rm21_ij = static_cast(0.5)*(rm2_i + rm1_j); + const KK_FLOAT epsilon21_ij = Kokkos::sqrt(epsilon2_i*epsilon1_j); KK_FLOAT evdwlOldEXP6_12 = 0.0; KK_FLOAT evdwlOldEXP6_21 = 0.0; @@ -1342,31 +1342,31 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& KK_FLOAT fpairOldEXP6_12 = 0.0; KK_FLOAT fpairOldEXP6_21 = 0.0; - if (rmOld12_ij!=0.0 && rmOld21_ij!=0.0) + if (rmOld12_ij!=static_cast(0.0) && rmOld21_ij!=static_cast(0.0)) { - hasError |= (alphaOld21_ij == 6.0 || alphaOld12_ij == 6.0); + hasError |= (alphaOld21_ij == static_cast(6.0) || alphaOld12_ij == static_cast(6.0)); // A3. Compute some convenient quantities for evaluating the force - KK_FLOAT rminv = 1.0/rmOld12_ij; - KK_FLOAT buck1 = epsilonOld12_ij / (alphaOld12_ij - 6.0); - KK_FLOAT rexp = expValue(alphaOld12_ij*(1.0-r*rminv)); + KK_FLOAT rminv = static_cast(1.0)/rmOld12_ij; + KK_FLOAT buck1 = epsilonOld12_ij / (alphaOld12_ij - static_cast(6.0)); + KK_FLOAT rexp = expValue(alphaOld12_ij*(static_cast(1.0)-r*rminv)); KK_FLOAT rm2ij = rmOld12_ij*rmOld12_ij; KK_FLOAT rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential - KK_FLOAT rCutExp = expValue(alphaOld12_ij*(1.0-rCut*rminv)); - KK_FLOAT buck2 = 6.0*alphaOld12_ij; - KK_FLOAT urc = buck1*(6.0*rCutExp - alphaOld12_ij*rm6ij*rCut6inv); + KK_FLOAT rCutExp = expValue(alphaOld12_ij*(static_cast(1.0)-rCut*rminv)); + KK_FLOAT buck2 = static_cast(6.0)*alphaOld12_ij; + KK_FLOAT urc = buck1*(static_cast(6.0)*rCutExp - alphaOld12_ij*rm6ij*rCut6inv); KK_FLOAT durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); KK_FLOAT rin1 = shift*rmOld12_ij*func_rin(alphaOld12_ij); if (r < rin1) { const KK_FLOAT rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - const KK_FLOAT rin6inv = 1.0/rin6; + const KK_FLOAT rin6inv = static_cast(1.0)/rin6; - const KK_FLOAT rin1exp = expValue(alphaOld12_ij*(1.0-rin1*rminv)); + const KK_FLOAT rin1exp = expValue(alphaOld12_ij*(static_cast(1.0)-rin1*rminv)); - const KK_FLOAT uin1 = buck1*(6.0*rin1exp - alphaOld12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + const KK_FLOAT uin1 = buck1*(static_cast(6.0)*rin1exp - alphaOld12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); const KK_FLOAT win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -1382,31 +1382,31 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& const KK_FLOAT forceExp6 = buck1*buck2*(r*rexp*rminv - rm6ij*r6inv) + r*durc; fpairOldEXP6_12 = factor_lj*forceExp6*r2inv; - evdwlOldEXP6_12 = buck1*(6.0*rexp - alphaOld12_ij*rm6ij*r6inv) - urc - durc*(r-rCut); + evdwlOldEXP6_12 = buck1*(static_cast(6.0)*rexp - alphaOld12_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } // A3. Compute some convenient quantities for evaluating the force - rminv = 1.0/rmOld21_ij; - buck1 = epsilonOld21_ij / (alphaOld21_ij - 6.0); - buck2 = 6.0*alphaOld21_ij; - rexp = expValue(alphaOld21_ij*(1.0-r*rminv)); + rminv = static_cast(1.0)/rmOld21_ij; + buck1 = epsilonOld21_ij / (alphaOld21_ij - static_cast(6.0)); + buck2 = static_cast(6.0)*alphaOld21_ij; + rexp = expValue(alphaOld21_ij*(static_cast(1.0)-r*rminv)); rm2ij = rmOld21_ij*rmOld21_ij; rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential - rCutExp = expValue(alphaOld21_ij*(1.0-rCut*rminv)); - buck2 = 6.0*alphaOld21_ij; - urc = buck1*(6.0*rCutExp - alphaOld21_ij*rm6ij*rCut6inv); + rCutExp = expValue(alphaOld21_ij*(static_cast(1.0)-rCut*rminv)); + buck2 = static_cast(6.0)*alphaOld21_ij; + urc = buck1*(static_cast(6.0)*rCutExp - alphaOld21_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp* rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rmOld21_ij*func_rin(alphaOld21_ij); if (r < rin1) { const KK_FLOAT rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - const KK_FLOAT rin6inv = 1.0/rin6; + const KK_FLOAT rin6inv = static_cast(1.0)/rin6; - const KK_FLOAT rin1exp = expValue(alphaOld21_ij*(1.0-rin1*rminv)); + const KK_FLOAT rin1exp = expValue(alphaOld21_ij*(static_cast(1.0)-rin1*rminv)); - const KK_FLOAT uin1 = buck1*(6.0*rin1exp - alphaOld21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + const KK_FLOAT uin1 = buck1*(static_cast(6.0)*rin1exp - alphaOld21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); const KK_FLOAT win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -1422,47 +1422,47 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& const KK_FLOAT forceExp6 = buck1*buck2*(r*rexp*rminv - rm6ij*r6inv) + r*durc; fpairOldEXP6_21 = factor_lj*forceExp6*r2inv; - evdwlOldEXP6_21 = buck1*(6.0*rexp - alphaOld21_ij*rm6ij*r6inv) - urc - durc*(r-rCut); + evdwlOldEXP6_21 = buck1*(static_cast(6.0)*rexp - alphaOld21_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } KK_FLOAT evdwlOld; if (Site1EqSite2) - evdwlOld = sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12; + evdwlOld = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12; else - evdwlOld = sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12 + sqrt(mixWtSite2old_i*mixWtSite1old_j)*evdwlOldEXP6_21; + evdwlOld = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwlOldEXP6_12 + Kokkos::sqrt(mixWtSite2old_i*mixWtSite1old_j)*evdwlOldEXP6_21; evdwlOld *= factor_lj; - uCG_i += 0.5*evdwlOld; + uCG_i += static_cast(0.5)*evdwlOld; evdwlOld_j[jlane] = evdwlOld; } - if (rm12_ij!=0.0 && rm21_ij!=0.0) + if (rm12_ij!=static_cast(0.0) && rm21_ij!=static_cast(0.0)) { - hasError |= (alpha21_ij == 6.0 || alpha12_ij == 6.0); + hasError |= (alpha21_ij == static_cast(6.0) || alpha12_ij == static_cast(6.0)); // A3. Compute some convenient quantities for evaluating the force - KK_FLOAT rminv = 1.0/rm12_ij; - KK_FLOAT buck1 = epsilon12_ij / (alpha12_ij - 6.0); - KK_FLOAT buck2 = 6.0*alpha12_ij; - KK_FLOAT rexp = expValue(alpha12_ij*(1.0-r*rminv)); + KK_FLOAT rminv = static_cast(1.0)/rm12_ij; + KK_FLOAT buck1 = epsilon12_ij / (alpha12_ij - static_cast(6.0)); + KK_FLOAT buck2 = static_cast(6.0)*alpha12_ij; + KK_FLOAT rexp = expValue(alpha12_ij*(static_cast(1.0)-r*rminv)); KK_FLOAT rm2ij = rm12_ij*rm12_ij; KK_FLOAT rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential - KK_FLOAT rCutExp = expValue(alpha12_ij*(1.0-rCut*rminv)); - KK_FLOAT urc = buck1*(6.0*rCutExp - alpha12_ij*rm6ij*rCut6inv); + KK_FLOAT rCutExp = expValue(alpha12_ij*(static_cast(1.0)-rCut*rminv)); + KK_FLOAT urc = buck1*(static_cast(6.0)*rCutExp - alpha12_ij*rm6ij*rCut6inv); KK_FLOAT durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); KK_FLOAT rin1 = shift*rm12_ij*func_rin(alpha12_ij); if (r < rin1) { const KK_FLOAT rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - const KK_FLOAT rin6inv = 1.0/rin6; + const KK_FLOAT rin6inv = static_cast(1.0)/rin6; - const KK_FLOAT rin1exp = expValue(alpha12_ij*(1.0-rin1*rminv)); + const KK_FLOAT rin1exp = expValue(alpha12_ij*(static_cast(1.0)-rin1*rminv)); - const KK_FLOAT uin1 = buck1*(6.0*rin1exp - alpha12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + const KK_FLOAT uin1 = buck1*(static_cast(6.0)*rin1exp - alpha12_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); const KK_FLOAT win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -1472,29 +1472,29 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& evdwlEXP6_12 = uin1 - uin1rep + aRep/__powint<12>(r,nRep); } else { - evdwlEXP6_12 = buck1*(6.0*rexp - alpha12_ij*rm6ij*r6inv) - urc - durc*(r-rCut); + evdwlEXP6_12 = buck1*(static_cast(6.0)*rexp - alpha12_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } - rminv = 1.0/rm21_ij; - buck1 = epsilon21_ij / (alpha21_ij - 6.0); - buck2 = 6.0*alpha21_ij; - rexp = expValue(alpha21_ij*(1.0-r*rminv)); + rminv = static_cast(1.0)/rm21_ij; + buck1 = epsilon21_ij / (alpha21_ij - static_cast(6.0)); + buck2 = static_cast(6.0)*alpha21_ij; + rexp = expValue(alpha21_ij*(static_cast(1.0)-r*rminv)); rm2ij = rm21_ij*rm21_ij; rm6ij = rm2ij*rm2ij*rm2ij; // Compute the shifted potential - rCutExp = expValue(alpha21_ij*(1.0-rCut*rminv)); - urc = buck1*(6.0*rCutExp - alpha21_ij*rm6ij*rCut6inv); + rCutExp = expValue(alpha21_ij*(static_cast(1.0)-rCut*rminv)); + urc = buck1*(static_cast(6.0)*rCutExp - alpha21_ij*rm6ij*rCut6inv); durc = -buck1*buck2*(rCutExp*rminv - rCutInv*rm6ij*rCut6inv); rin1 = shift*rm21_ij*func_rin(alpha21_ij); if (r < rin1) { const KK_FLOAT rin6 = rin1*rin1*rin1*rin1*rin1*rin1; - const KK_FLOAT rin6inv = 1.0/rin6; + const KK_FLOAT rin6inv = static_cast(1.0)/rin6; - const KK_FLOAT rin1exp = expValue(alpha21_ij*(1.0-rin1*rminv)); + const KK_FLOAT rin1exp = expValue(alpha21_ij*(static_cast(1.0)-rin1*rminv)); - const KK_FLOAT uin1 = buck1*(6.0*rin1exp - alpha21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); + const KK_FLOAT uin1 = buck1*(static_cast(6.0)*rin1exp - alpha21_ij*rm6ij*rin6inv) - urc - durc*(rin1-rCut); const KK_FLOAT win1 = buck1*buck2*(rin1*rin1exp*rminv - rm6ij*rin6inv) + rin1*durc; @@ -1504,7 +1504,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& evdwlEXP6_21 = uin1 - uin1rep + aRep/__powint<12>(r,nRep); } else { - evdwlEXP6_21 = buck1*(6.0*rexp - alpha21_ij*rm6ij*r6inv) - urc - durc*(r-rCut); + evdwlEXP6_21 = buck1*(static_cast(6.0)*rexp - alpha21_ij*rm6ij*r6inv) - urc - durc*(r-rCut); } } @@ -1513,15 +1513,15 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& // KK_FLOAT fpair; if (Site1EqSite2) - fpair = sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12; + fpair = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12; else - fpair = sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12 + sqrt(mixWtSite2old_i*mixWtSite1old_j)*fpairOldEXP6_21; + fpair = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpairOldEXP6_12 + Kokkos::sqrt(mixWtSite2old_i*mixWtSite1old_j)*fpairOldEXP6_21; KK_FLOAT evdwl; if (Site1EqSite2) - evdwl = sqrt(mixWtSite1_i*mixWtSite2_j)*evdwlEXP6_12; + evdwl = Kokkos::sqrt(mixWtSite1_i*mixWtSite2_j)*evdwlEXP6_12; else - evdwl = sqrt(mixWtSite1_i*mixWtSite2_j)*evdwlEXP6_12 + sqrt(mixWtSite2_i*mixWtSite1_j)*evdwlEXP6_21; + evdwl = Kokkos::sqrt(mixWtSite1_i*mixWtSite2_j)*evdwlEXP6_12 + Kokkos::sqrt(mixWtSite2_i*mixWtSite1_j)*evdwlEXP6_21; evdwl *= factor_lj; @@ -1531,9 +1531,9 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& fy_i += dely*fpair; fz_i += delz*fpair; - uCGnew_i += 0.5*evdwl; + uCGnew_i += static_cast(0.5)*evdwl; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)) - uCGnew_j[jlane] = 0.5*evdwl; + uCGnew_j[jlane] = static_cast(0.5)*evdwl; } // if rsq < cutsq @@ -1545,9 +1545,9 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { if (UseAtomics) { - a_uCG(j) += 0.5*evdwlOld_j[jlane]; + a_uCG(j) += static_cast(0.5)*evdwlOld_j[jlane]; } else { - t_uCG(tid,j) += 0.5*evdwlOld_j[jlane]; + t_uCG(tid,j) += static_cast(0.5)*evdwlOld_j[jlane]; } } if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { @@ -1559,9 +1559,9 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& } if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { if (UseAtomics) { - a_f(j,0) -= delx_j[jlane]*fpair_j[jlane]; - a_f(j,1) -= dely_j[jlane]*fpair_j[jlane]; - a_f(j,2) -= delz_j[jlane]*fpair_j[jlane]; + a_f(j,0) -= static_cast(delx_j[jlane]*fpair_j[jlane]); + a_f(j,1) -= static_cast(dely_j[jlane]*fpair_j[jlane]); + a_f(j,2) -= static_cast(delz_j[jlane]*fpair_j[jlane]); } else { t_f(tid,j,0) -= delx_j[jlane]*fpair_j[jlane]; t_f(tid,j,1) -= dely_j[jlane]*fpair_j[jlane]; @@ -1571,7 +1571,7 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& KK_FLOAT evdwl = evdwlOld_j[jlane]; if (EVFLAG) - ev.evdwl += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR||(j(1.0):static_cast(0.5))*static_cast(evdwl); //if (vflag_either || eflag_atom) if (EVFLAG) this->template ev_tally(ev,i,j,evdwl,fpair_j[jlane],delx_j[jlane],dely_j[jlane],delz_j[jlane]); } @@ -1582,9 +1582,9 @@ void PairExp6rxKokkos::vectorized_operator(const int &ii, EV_FLOAT& if (UseAtomics) { - a_f(i,0) += fx_i; - a_f(i,1) += fy_i; - a_f(i,2) += fz_i; + a_f(i,0) += static_cast(fx_i); + a_f(i,1) += static_cast(fy_i); + a_f(i,2) += static_cast(fz_i); a_uCG(i) += uCG_i; a_uCGnew(i) += uCGnew_i; } @@ -1616,9 +1616,9 @@ template KOKKOS_INLINE_FUNCTION void PairExp6rxKokkos::operator()(TagPairExp6rxCollapseDupViews, const int &i) const { for (int n = 0; n < nthreads; n++) { - f(i,0) += t_f(n,i,0); - f(i,1) += t_f(n,i,1); - f(i,2) += t_f(n,i,2); + f(i,0) += static_cast(t_f(n,i,0)); + f(i,1) += static_cast(t_f(n,i,1)); + f(i,2) += static_cast(t_f(n,i,2)); uCG(i) += t_uCG(n,i); uCGnew(i) += t_uCGnew(n,i); } @@ -1786,7 +1786,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK nMoleculesOFA += dvector(atom_ind,id); } } - if (nTotal < MY_EPSILON || nTotalold < MY_EPSILON) + if (nTotal < static_cast(MY_EPSILON) || nTotalold < static_cast(MY_EPSILON)) k_error_flag.template view()() = 1; // Compute the mole fraction of molecules within the fluid portion of the particle (One Fluid Approximation) @@ -1802,12 +1802,12 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK // If Site1 matches a pure species, then grab the parameters if (isite1 == d_params[iparam].ispecies) { - rm1_old = d_params[iparam].rm; - rm1 = d_params[iparam].rm; - epsilon1_old = d_params[iparam].epsilon; - epsilon1 = d_params[iparam].epsilon; - alpha1_old = d_params[iparam].alpha; - alpha1 = d_params[iparam].alpha; + rm1_old = static_cast(d_params[iparam].rm); + rm1 = static_cast(d_params[iparam].rm); + epsilon1_old = static_cast(d_params[iparam].epsilon); + epsilon1 = static_cast(d_params[iparam].epsilon); + alpha1_old = static_cast(d_params[iparam].alpha); + alpha1 = static_cast(d_params[iparam].alpha); // Compute the mole fraction of Site1 nMoleculesOld1 = dvector(atom_ind_old,id); @@ -1818,12 +1818,12 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK // If Site2 matches a pure species, then grab the parameters if (isite2 == d_params[iparam].ispecies) { - rm2_old = d_params[iparam].rm; - rm2 = d_params[iparam].rm; - epsilon2_old = d_params[iparam].epsilon; - epsilon2 = d_params[iparam].epsilon; - alpha2_old = d_params[iparam].alpha; - alpha2 = d_params[iparam].alpha; + rm2_old = static_cast(d_params[iparam].rm); + rm2 = static_cast(d_params[iparam].rm); + epsilon2_old = static_cast(d_params[iparam].epsilon); + epsilon2 = static_cast(d_params[iparam].epsilon); + alpha2_old = static_cast(d_params[iparam].alpha); + alpha2 = static_cast(d_params[iparam].alpha); // Compute the mole fraction of Site2 nMoleculesOld2 = dvector(atom_ind_old,id); @@ -1835,12 +1835,12 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK // If Site1 or Site2 matches is a fluid, then compute the parameters if (isOneFluidApprox(isite1) || isOneFluidApprox(isite2)) { if (isite1 == d_params[iparam].ispecies || isite2 == d_params[iparam].ispecies) continue; - rmi = d_params[iparam].rm; - epsiloni = d_params[iparam].epsilon; - alphai = d_params[iparam].alpha; - if (nMoleculesOFA(d_params[iparam].rm); + epsiloni = static_cast(d_params[iparam].epsilon); + alphai = static_cast(d_params[iparam].alpha); + if (nMoleculesOFA(MY_EPSILON)) xMolei = static_cast(0.0); else xMolei = dvector(atom_ind,id)/nMoleculesOFA; - if (nMoleculesOFAold(MY_EPSILON)) xMolei_old = static_cast(0.0); else xMolei_old = dvector(atom_ind_old,id)/nMoleculesOFAold; for (int jspecies = 0; jspecies < nspecies; jspecies++) { @@ -1850,25 +1850,25 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK jparam = d_mol2param[jspecies]; if (jparam < 0 || d_params[jparam].potentialType != PotentialType::exp6 ) continue; if (isite1 == d_params[jparam].ispecies || isite2 == d_params[jparam].ispecies) continue; - rmj = d_params[jparam].rm; - epsilonj = d_params[jparam].epsilon; - alphaj = d_params[jparam].alpha; - if (nMoleculesOFA(d_params[jparam].rm); + epsilonj = static_cast(d_params[jparam].epsilon); + alphaj = static_cast(d_params[jparam].alpha); + if (nMoleculesOFA(MY_EPSILON)) xMolej = static_cast(0.0); else xMolej = dvector(atom_ind_inner,id)/nMoleculesOFA; - if (nMoleculesOFAold(MY_EPSILON)) xMolej_old = static_cast(0.0); else xMolej_old = dvector(atom_ind_old_inner,id)/nMoleculesOFAold; - rmij = (rmi+rmj)/2.0; + rmij = (rmi+rmj)/static_cast(2.0); rm3ij = rmij*rmij*rmij; - epsilonij = sqrt(epsiloni*epsilonj); - alphaij = sqrt(alphai*alphaj); + epsilonij = Kokkos::sqrt(epsiloni*epsilonj); + alphaij = Kokkos::sqrt(alphai*alphaj); - if (fractionOFAold > 0.0) { + if (fractionOFAold > static_cast(0.0)) { rm3_old += xMolei_old*xMolej_old*rm3ij; epsilon_old += xMolei_old*xMolej_old*rm3ij*epsilonij; alpha_old += xMolei_old*xMolej_old*rm3ij*epsilonij*alphaij; } - if (fractionOFA > 0.0) { + if (fractionOFA > static_cast(0.0)) { rm3 += xMolei*xMolej*rm3ij; epsilon += xMolei*xMolej*rm3ij*epsilonij; alpha += xMolei*xMolej*rm3ij*epsilonij*alphaij; @@ -1878,8 +1878,8 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK } if (isOneFluidApprox(isite1)) { - rm1 = cbrt(rm3); - if (rm1 < MY_EPSILON) { + rm1 = Kokkos::cbrt(rm3); + if (rm1 < static_cast(MY_EPSILON)) { rm1 = 0.0; epsilon1 = 0.0; alpha1 = 0.0; @@ -1887,11 +1887,11 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK epsilon1 = epsilon / rm3; alpha1 = alpha / epsilon1 / rm3; } - nMolecules1 = 1.0-(nTotal-nMoleculesOFA); + nMolecules1 = static_cast(1.0)-(nTotal-nMoleculesOFA); fraction1 = fractionOFA; - rm1_old = cbrt(rm3_old); - if (rm1_old < MY_EPSILON) { + rm1_old = Kokkos::cbrt(rm3_old); + if (rm1_old < static_cast(MY_EPSILON)) { rm1_old = 0.0; epsilon1_old = 0.0; alpha1_old = 0.0; @@ -1899,7 +1899,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK epsilon1_old = epsilon_old / rm3_old; alpha1_old = alpha_old / epsilon1_old / rm3_old; } - nMoleculesOld1 = 1.0-(nTotalold-nMoleculesOFAold); + nMoleculesOld1 = static_cast(1.0)-(nTotalold-nMoleculesOFAold); fractionOld1 = fractionOFAold; if (scalingFlag == EXPONENT) { @@ -1912,8 +1912,8 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK } if (isOneFluidApprox(isite2)) { - rm2 = cbrt(rm3); - if (rm2 < MY_EPSILON) { + rm2 = Kokkos::cbrt(rm3); + if (rm2 < static_cast(MY_EPSILON)) { rm2 = 0.0; epsilon2 = 0.0; alpha2 = 0.0; @@ -1921,11 +1921,11 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK epsilon2 = epsilon / rm3; alpha2 = alpha / epsilon2 / rm3; } - nMolecules2 = 1.0-(nTotal-nMoleculesOFA); + nMolecules2 = static_cast(1.0)-(nTotal-nMoleculesOFA); fraction2 = fractionOFA; - rm2_old = cbrt(rm3_old); - if (rm2_old < MY_EPSILON) { + rm2_old = Kokkos::cbrt(rm3_old); + if (rm2_old < static_cast(MY_EPSILON)) { rm2_old = 0.0; epsilon2_old = 0.0; alpha2_old = 0.0; @@ -1933,7 +1933,7 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK epsilon2_old = epsilon_old / rm3_old; alpha2_old = alpha_old / epsilon2_old / rm3_old; } - nMoleculesOld2 = 1.0-(nTotalold-nMoleculesOFAold); + nMoleculesOld2 = static_cast(1.0)-(nTotalold-nMoleculesOFAold); fractionOld2 = fractionOFAold; if (scalingFlag == EXPONENT) { @@ -1946,29 +1946,29 @@ void PairExp6rxKokkos::getMixingWeights(int id,KK_FLOAT &epsilon1,KK } // Check that no fractions are less than zero - if (fraction1 < 0.0 || nMolecules1 < 0.0) { - if (fraction1 < -MY_EPSILON || nMolecules1 < -MY_EPSILON) { + if (fraction1 < static_cast(0.0) || nMolecules1 < static_cast(0.0)) { + if (fraction1 < -static_cast(MY_EPSILON) || nMolecules1 < -static_cast(MY_EPSILON)) { k_error_flag.template view()() = 2; } nMolecules1 = 0.0; fraction1 = 0.0; } - if (fraction2 < 0.0 || nMolecules2 < 0.0) { - if (fraction2 < -MY_EPSILON || nMolecules2 < -MY_EPSILON) { + if (fraction2 < static_cast(0.0) || nMolecules2 < static_cast(0.0)) { + if (fraction2 < -static_cast(MY_EPSILON) || nMolecules2 < -static_cast(MY_EPSILON)) { k_error_flag.template view()() = 2; } nMolecules2 = 0.0; fraction2 = 0.0; } - if (fractionOld1 < 0.0 || nMoleculesOld1 < 0.0) { - if (fractionOld1 < -MY_EPSILON || nMoleculesOld1 < -MY_EPSILON) { + if (fractionOld1 < static_cast(0.0) || nMoleculesOld1 < static_cast(0.0)) { + if (fractionOld1 < -static_cast(MY_EPSILON) || nMoleculesOld1 < -static_cast(MY_EPSILON)) { k_error_flag.template view()() = 2; } nMoleculesOld1 = 0.0; fractionOld1 = 0.0; } - if (fractionOld2 < 0.0 || nMoleculesOld2 < 0.0) { - if (fractionOld2 < -MY_EPSILON || nMoleculesOld2 < -MY_EPSILON) { + if (fractionOld2 < static_cast(0.0) || nMoleculesOld2 < static_cast(0.0)) { + if (fractionOld2 < -static_cast(MY_EPSILON) || nMoleculesOld2 < -static_cast(MY_EPSILON)) { k_error_flag.template view()() = 2; } nMoleculesOld2 = 0.0; @@ -2119,7 +2119,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - if (nTotal[id] < MY_EPSILON || nTotalold[id] < MY_EPSILON) + if (nTotal[id] < static_cast(MY_EPSILON) || nTotalold[id] < static_cast(MY_EPSILON)) errorFlag1 = 1; // Compute the mole fraction of molecules within the fluid portion of the particle (One Fluid Approximation) @@ -2142,12 +2142,12 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - rm1_old[id] = d_params[iparam].rm; - rm1[id] = d_params[iparam].rm; - epsilon1_old[id] = d_params[iparam].epsilon; - epsilon1[id] = d_params[iparam].epsilon; - alpha1_old[id] = d_params[iparam].alpha; - alpha1[id] = d_params[iparam].alpha; + rm1_old[id] = static_cast(d_params[iparam].rm); + rm1[id] = static_cast(d_params[iparam].rm); + epsilon1_old[id] = static_cast(d_params[iparam].epsilon); + epsilon1[id] = static_cast(d_params[iparam].epsilon); + alpha1_old[id] = static_cast(d_params[iparam].alpha); + alpha1[id] = static_cast(d_params[iparam].alpha); // Compute the mole fraction of Site1 nMoleculesOld1[id] = dvector(atom_ind_old,id); @@ -2165,12 +2165,12 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - rm2_old[id] = d_params[iparam].rm; - rm2[id] = d_params[iparam].rm; - epsilon2_old[id] = d_params[iparam].epsilon; - epsilon2[id] = d_params[iparam].epsilon; - alpha2_old[id] = d_params[iparam].alpha; - alpha2[id] = d_params[iparam].alpha; + rm2_old[id] = static_cast(d_params[iparam].rm); + rm2[id] = static_cast(d_params[iparam].rm); + epsilon2_old[id] = static_cast(d_params[iparam].epsilon); + epsilon2[id] = static_cast(d_params[iparam].epsilon); + alpha2_old[id] = static_cast(d_params[iparam].alpha); + alpha2[id] = static_cast(d_params[iparam].alpha); // Compute the mole fraction of Site2 nMoleculesOld2[id] = dvector(atom_ind_old,id); @@ -2184,18 +2184,18 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int if (isOneFluidApprox(isite1) || isOneFluidApprox(isite2)) { if (isite1 == d_params[iparam].ispecies || isite2 == d_params[iparam].ispecies) continue; - const KK_FLOAT rmi = d_params[iparam].rm; - const KK_FLOAT epsiloni = d_params[iparam].epsilon; - const KK_FLOAT alphai = d_params[iparam].alpha; + const KK_FLOAT rmi = static_cast(d_params[iparam].rm); + const KK_FLOAT epsiloni = static_cast(d_params[iparam].epsilon); + const KK_FLOAT alphai = static_cast(d_params[iparam].alpha); #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP #pragma ivdep #endif for (int id = idx_begin; id < idx_end; ++id) { - if (nMoleculesOFA[id](MY_EPSILON)) xMolei[id] = static_cast(0.0); else xMolei[id] = dvector(atom_ind,id)/nMoleculesOFA[id]; - if (nMoleculesOFAold[id](MY_EPSILON)) xMolei_old[id] = static_cast(0.0); else xMolei_old[id] = dvector(atom_ind_old,id)/nMoleculesOFAold[id]; } @@ -2207,14 +2207,14 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int if (jparam < 0 || d_params[jparam].potentialType != PotentialType::exp6 ) continue; if (isite1 == d_params[jparam].ispecies || isite2 == d_params[jparam].ispecies) continue; - const KK_FLOAT rmj = d_params[jparam].rm; - const KK_FLOAT epsilonj = d_params[jparam].epsilon; - const KK_FLOAT alphaj = d_params[jparam].alpha; + const KK_FLOAT rmj = static_cast(d_params[jparam].rm); + const KK_FLOAT epsilonj = static_cast(d_params[jparam].epsilon); + const KK_FLOAT alphaj = static_cast(d_params[jparam].alpha); - const KK_FLOAT rmij = (rmi+rmj)/2.0; + const KK_FLOAT rmij = (rmi+rmj)/static_cast(2.0); const KK_FLOAT rm3ij = rmij*rmij*rmij; - const KK_FLOAT epsilonij = sqrt(epsiloni*epsilonj); - const KK_FLOAT alphaij = sqrt(alphai*alphaj); + const KK_FLOAT epsilonij = Kokkos::sqrt(epsiloni*epsilonj); + const KK_FLOAT alphaij = Kokkos::sqrt(alphai*alphaj); #ifdef KOKKOS_ENABLE_PRAGMA_IVDEP #pragma ivdep @@ -2222,17 +2222,17 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int for (int id = idx_begin; id < idx_end; ++id) { KK_FLOAT xMolej, xMolej_old; - if (nMoleculesOFA[id](MY_EPSILON)) xMolej = static_cast(0.0); else xMolej = dvector(atom_ind_inner,id)/nMoleculesOFA[id]; - if (nMoleculesOFAold[id](MY_EPSILON)) xMolej_old = static_cast(0.0); else xMolej_old = dvector(atom_ind_old_inner,id)/nMoleculesOFAold[id]; - if (fractionOFAold[id] > 0.0) { + if (fractionOFAold[id] > static_cast(0.0)) { rm3_old[id] += xMolei_old[id]*xMolej_old*rm3ij; epsilon_old[id] += xMolei_old[id]*xMolej_old*rm3ij*epsilonij; alpha_old[id] += xMolei_old[id]*xMolej_old*rm3ij*epsilonij*alphaij; } - if (fractionOFA[id] > 0.0) { + if (fractionOFA[id] > static_cast(0.0)) { rm3[id] += xMolei[id]*xMolej*rm3ij; epsilon[id] += xMolei[id]*xMolej*rm3ij*epsilonij; alpha[id] += xMolei[id]*xMolej*rm3ij*epsilonij*alphaij; @@ -2249,8 +2249,8 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - rm1[id] = cbrt(rm3[id]); - if (rm1[id] < MY_EPSILON) { + rm1[id] = Kokkos::cbrt(rm3[id]); + if (rm1[id] < static_cast(MY_EPSILON)) { rm1[id] = 0.0; epsilon1[id] = 0.0; alpha1[id] = 0.0; @@ -2258,11 +2258,11 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int epsilon1[id] = epsilon[id] / rm3[id]; alpha1[id] = alpha[id] / epsilon1[id] / rm3[id]; } - nMolecules1[id] = 1.0-(nTotal[id]-nMoleculesOFA[id]); + nMolecules1[id] = static_cast(1.0)-(nTotal[id]-nMoleculesOFA[id]); fraction1[id] = fractionOFA[id]; - rm1_old[id] = cbrt(rm3_old[id]); - if (rm1_old[id] < MY_EPSILON) { + rm1_old[id] = Kokkos::cbrt(rm3_old[id]); + if (rm1_old[id] < static_cast(MY_EPSILON)) { rm1_old[id] = 0.0; epsilon1_old[id] = 0.0; alpha1_old[id] = 0.0; @@ -2270,7 +2270,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int epsilon1_old[id] = epsilon_old[id] / rm3_old[id]; alpha1_old[id] = alpha_old[id] / epsilon1_old[id] / rm3_old[id]; } - nMoleculesOld1[id] = 1.0-(nTotalold[id]-nMoleculesOFAold[id]); + nMoleculesOld1[id] = static_cast(1.0)-(nTotalold[id]-nMoleculesOFAold[id]); fractionOld1[id] = fractionOFAold[id]; } @@ -2303,8 +2303,8 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - rm2[id] = cbrt(rm3[id]); - if (rm2[id] < MY_EPSILON) { + rm2[id] = Kokkos::cbrt(rm3[id]); + if (rm2[id] < static_cast(MY_EPSILON)) { rm2[id] = 0.0; epsilon2[id] = 0.0; alpha2[id] = 0.0; @@ -2312,11 +2312,11 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int epsilon2[id] = epsilon[id] / rm3[id]; alpha2[id] = alpha[id] / epsilon2[id] / rm3[id]; } - nMolecules2[id] = 1.0-(nTotal[id]-nMoleculesOFA[id]); + nMolecules2[id] = static_cast(1.0)-(nTotal[id]-nMoleculesOFA[id]); fraction2[id] = fractionOFA[id]; - rm2_old[id] = cbrt(rm3_old[id]); - if (rm2_old[id] < MY_EPSILON) { + rm2_old[id] = Kokkos::cbrt(rm3_old[id]); + if (rm2_old[id] < static_cast(MY_EPSILON)) { rm2_old[id] = 0.0; epsilon2_old[id] = 0.0; alpha2_old[id] = 0.0; @@ -2324,7 +2324,7 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int epsilon2_old[id] = epsilon_old[id] / rm3_old[id]; alpha2_old[id] = alpha_old[id] / epsilon2_old[id] / rm3_old[id]; } - nMoleculesOld2[id] = 1.0-(nTotalold[id]-nMoleculesOFAold[id]); + nMoleculesOld2[id] = static_cast(1.0)-(nTotalold[id]-nMoleculesOFAold[id]); fractionOld2[id] = fractionOFAold[id]; } @@ -2356,29 +2356,29 @@ void PairExp6rxKokkos::getMixingWeightsVect(const int np_total, int #endif for (int id = idx_begin; id < idx_end; ++id) { - if (fraction1[id] < 0.0 || nMolecules1[id] < 0.0) { - if (fraction1[id] < -MY_EPSILON || nMolecules1[id] < -MY_EPSILON) { + if (fraction1[id] < static_cast(0.0) || nMolecules1[id] < static_cast(0.0)) { + if (fraction1[id] < -static_cast(MY_EPSILON) || nMolecules1[id] < -static_cast(MY_EPSILON)) { errorFlag2 = 2; } nMolecules1[id] = 0.0; fraction1[id] = 0.0; } - if (fraction2[id] < 0.0 || nMolecules2[id] < 0.0) { - if (fraction2[id] < -MY_EPSILON || nMolecules2[id] < -MY_EPSILON) { + if (fraction2[id] < static_cast(0.0) || nMolecules2[id] < static_cast(0.0)) { + if (fraction2[id] < -static_cast(MY_EPSILON) || nMolecules2[id] < -static_cast(MY_EPSILON)) { errorFlag2 = 2; } nMolecules2[id] = 0.0; fraction2[id] = 0.0; } - if (fractionOld1[id] < 0.0 || nMoleculesOld1[id] < 0.0) { - if (fractionOld1[id] < -MY_EPSILON || nMoleculesOld1[id] < -MY_EPSILON) { + if (fractionOld1[id] < static_cast(0.0) || nMoleculesOld1[id] < static_cast(0.0)) { + if (fractionOld1[id] < -static_cast(MY_EPSILON) || nMoleculesOld1[id] < -static_cast(MY_EPSILON)) { errorFlag2 = 2; } nMoleculesOld1[id] = 0.0; fractionOld1[id] = 0.0; } - if (fractionOld2[id] < 0.0 || nMoleculesOld2[id] < 0.0) { - if (fractionOld2[id] < -MY_EPSILON || nMoleculesOld2[id] < -MY_EPSILON) { + if (fractionOld2[id] < static_cast(0.0) || nMoleculesOld2[id] < static_cast(0.0)) { + if (fractionOld2[id] < -static_cast(MY_EPSILON) || nMoleculesOld2[id] < -static_cast(MY_EPSILON)) { errorFlag2 = 2; } nMoleculesOld2[id] = 0.0; @@ -2416,21 +2416,23 @@ KOKKOS_INLINE_FUNCTION void PairExp6rxKokkos::exponentScaling(KK_FLOAT phi, KK_FLOAT &epsilon, KK_FLOAT &rm) const { KK_FLOAT powfuch; + const KK_FLOAT exponentEpsilon_kk = static_cast(exponentEpsilon); + const KK_FLOAT exponentR_kk = static_cast(exponentR); if (exponentEpsilon < 0.0) { - powfuch = pow(phi,-exponentEpsilon); - if (powfuch(MY_EPSILON)) epsilon = 0.0; + else epsilon *= static_cast(1.0)/powfuch; } else { - epsilon *= pow(phi,exponentEpsilon); + epsilon *= Kokkos::pow(phi,exponentEpsilon_kk); } if (exponentR < 0.0) { - powfuch = pow(phi,-exponentR); - if (powfuch(MY_EPSILON)) rm = 0.0; + else rm *= static_cast(1.0)/powfuch; } else { - rm *= pow(phi,exponentR); + rm *= Kokkos::pow(phi,exponentR_kk); } } @@ -2446,9 +2448,9 @@ void PairExp6rxKokkos::polynomialScaling(KK_FLOAT phi, KK_FLOAT &alp KK_FLOAT phi4 = phi2*phi2; KK_FLOAT phi5 = phi2*phi3; - alpha = (s_coeffAlpha[0]*phi5 + s_coeffAlpha[1]*phi4 + s_coeffAlpha[2]*phi3 + s_coeffAlpha[3]*phi2 + s_coeffAlpha[4]*phi + s_coeffAlpha[5]); - epsilon *= (s_coeffEps[0]*phi5 + s_coeffEps[1]*phi4 + s_coeffEps[2]*phi3 + s_coeffEps[3]*phi2 + s_coeffEps[4]*phi + s_coeffEps[5]); - rm *= (s_coeffRm[0]*phi5 + s_coeffRm[1]*phi4 + s_coeffRm[2]*phi3 + s_coeffRm[3]*phi2 + s_coeffRm[4]*phi + s_coeffRm[5]); + alpha = (static_cast(s_coeffAlpha[0])*phi5 + static_cast(s_coeffAlpha[1])*phi4 + static_cast(s_coeffAlpha[2])*phi3 + static_cast(s_coeffAlpha[3])*phi2 + static_cast(s_coeffAlpha[4])*phi + static_cast(s_coeffAlpha[5])); + epsilon *= (static_cast(s_coeffEps[0])*phi5 + static_cast(s_coeffEps[1])*phi4 + static_cast(s_coeffEps[2])*phi3 + static_cast(s_coeffEps[3])*phi2 + static_cast(s_coeffEps[4])*phi + static_cast(s_coeffEps[5])); + rm *= (static_cast(s_coeffRm[0])*phi5 + static_cast(s_coeffRm[1])*phi4 + static_cast(s_coeffRm[2])*phi3 + static_cast(s_coeffRm[3])*phi2 + static_cast(s_coeffRm[4])*phi + static_cast(s_coeffRm[5])); } /* ---------------------------------------------------------------------- */ @@ -2460,10 +2462,10 @@ KK_FLOAT PairExp6rxKokkos::func_rin(const KK_FLOAT &alpha) const { KK_FLOAT function; - const KK_FLOAT a = 3.7682065; - const KK_FLOAT b = -1.4308614; + const KK_FLOAT a = static_cast(3.7682065); + const KK_FLOAT b = -static_cast(1.4308614); - function = a+b*sqrt(alpha); + function = a+b*Kokkos::sqrt(alpha); function = expValue(function); return function; @@ -2478,7 +2480,7 @@ KK_FLOAT PairExp6rxKokkos::expValue(KK_FLOAT value) const { KK_FLOAT returnValue; if (value < DBL_MIN_EXP) returnValue = 0.0; - else returnValue = exp(value); + else returnValue = Kokkos::exp(value); return returnValue; } @@ -2502,12 +2504,12 @@ void PairExp6rxKokkos::ev_tally(EV_FLOAT &ev, const int &i, const in if (EFLAG) { if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; if (NEIGHFLAG!=FULL) { - if (NEWTON_PAIR || i < nlocal) v_eatom[i] += epairhalf; - if (NEWTON_PAIR || j < nlocal) v_eatom[j] += epairhalf; + if (NEWTON_PAIR || i < nlocal) v_eatom[i] += static_cast(epairhalf); + if (NEWTON_PAIR || j < nlocal) v_eatom[j] += static_cast(epairhalf); } else { - v_eatom[i] += epairhalf; + v_eatom[i] += static_cast(epairhalf); } } } @@ -2523,56 +2525,56 @@ void PairExp6rxKokkos::ev_tally(EV_FLOAT &ev, const int &i, const in if (vflag_global) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } if (NEWTON_PAIR || j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } if (vflag_atom) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*static_cast(v0); + v_vatom(i,1) += static_cast(0.5)*static_cast(v1); + v_vatom(i,2) += static_cast(0.5)*static_cast(v2); + v_vatom(i,3) += static_cast(0.5)*static_cast(v3); + v_vatom(i,4) += static_cast(0.5)*static_cast(v4); + v_vatom(i,5) += static_cast(0.5)*static_cast(v5); } if (NEWTON_PAIR || j < nlocal) { - v_vatom(j,0) += 0.5*v0; - v_vatom(j,1) += 0.5*v1; - v_vatom(j,2) += 0.5*v2; - v_vatom(j,3) += 0.5*v3; - v_vatom(j,4) += 0.5*v4; - v_vatom(j,5) += 0.5*v5; + v_vatom(j,0) += static_cast(0.5)*static_cast(v0); + v_vatom(j,1) += static_cast(0.5)*static_cast(v1); + v_vatom(j,2) += static_cast(0.5)*static_cast(v2); + v_vatom(j,3) += static_cast(0.5)*static_cast(v3); + v_vatom(j,4) += static_cast(0.5)*static_cast(v4); + v_vatom(j,5) += static_cast(0.5)*static_cast(v5); } } else { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*static_cast(v0); + v_vatom(i,1) += static_cast(0.5)*static_cast(v1); + v_vatom(i,2) += static_cast(0.5)*static_cast(v2); + v_vatom(i,3) += static_cast(0.5)*static_cast(v3); + v_vatom(i,4) += static_cast(0.5)*static_cast(v4); + v_vatom(i,5) += static_cast(0.5)*static_cast(v5); } } } diff --git a/src/KOKKOS/pair_gauss_kokkos.cpp b/src/KOKKOS/pair_gauss_kokkos.cpp index 81fa0747999..ff3804e778a 100644 --- a/src/KOKKOS/pair_gauss_kokkos.cpp +++ b/src/KOKKOS/pair_gauss_kokkos.cpp @@ -104,24 +104,24 @@ void PairGaussKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms copymode = 1; EV_FLOAT ev = pair_compute,void >(this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -147,7 +147,7 @@ KK_FLOAT PairGaussKokkos:: compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { const KK_FLOAT a = STACKPARAMS ? m_params[itype][jtype].a : params(itype,jtype).a; const KK_FLOAT b = STACKPARAMS ? m_params[itype][jtype].b : params(itype,jtype).b; - return static_cast(-2.0) * a * b * exp(-b * rsq); + return static_cast(-2.0) * a * b * Kokkos::exp(-b * rsq); } template @@ -159,7 +159,7 @@ compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c const KK_FLOAT a = STACKPARAMS ? m_params[itype][jtype].a : params(itype,jtype).a; const KK_FLOAT b = STACKPARAMS ? m_params[itype][jtype].b : params(itype,jtype).b; const KK_FLOAT offset = STACKPARAMS ? m_params[itype][jtype].offset : params(itype,jtype).offset; - return -(a * exp(-b * rsq) - offset); + return -(a * Kokkos::exp(-b * rsq) - offset); } /* ---------------------------------------------------------------------- diff --git a/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp b/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp index 14c9841c54a..0f7db00dcf0 100644 --- a/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp +++ b/src/KOKKOS/pair_gran_hooke_history_kokkos.cpp @@ -320,7 +320,7 @@ void PairGranHookeHistoryKokkos::operator()(TagPairGranHookeHistoryC d_firsttouch(i,jj) = 1; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rinv = static_cast(1.0)/r; const KK_FLOAT rsqinv = static_cast(1.0)/rsq; @@ -374,7 +374,7 @@ void PairGranHookeHistoryKokkos::operator()(TagPairGranHookeHistoryC shear2 += vtr2*dt_kk; shear3 += vtr3*dt_kk; } - KK_FLOAT shrmag = sqrt(shear1*shear1 + shear2*shear2 + + KK_FLOAT shrmag = Kokkos::sqrt(shear1*shear1 + shear2*shear2 + shear3*shear3); if (SHEARUPDATE) { @@ -396,8 +396,8 @@ void PairGranHookeHistoryKokkos::operator()(TagPairGranHookeHistoryC // rescale frictional displacements and forces if needed - KK_FLOAT fs = sqrt(fs1*fs1 + fs2*fs2 + fs3*fs3); - KK_FLOAT fn = xmu_kk * fabs(ccel*r); + KK_FLOAT fs = Kokkos::sqrt(fs1*fs1 + fs2*fs2 + fs3*fs3); + KK_FLOAT fn = xmu_kk * Kokkos::fabs(ccel*r); if (fs > fn) { if (shrmag != static_cast(0.0)) { diff --git a/src/KOKKOS/pair_kokkos.h b/src/KOKKOS/pair_kokkos.h index d8d3d7adaf5..2b26af987ed 100644 --- a/src/KOKKOS/pair_kokkos.h +++ b/src/KOKKOS/pair_kokkos.h @@ -161,7 +161,7 @@ struct PairComputeFunctor { const int jtype = c.type(j); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < static_cast(STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { const KK_FLOAT fpair = factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); @@ -238,7 +238,7 @@ struct PairComputeFunctor { const int jtype = c.type(j); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < static_cast(STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { KK_FLOAT fpair = KK_FLOAT(); @@ -331,7 +331,7 @@ struct PairComputeFunctor { const int jtype = c.type(j); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < static_cast(STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { const KK_FLOAT fpair = factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); @@ -409,7 +409,7 @@ struct PairComputeFunctor { const int jtype = c.type(j); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < static_cast(STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { KK_FLOAT fpair = KK_FLOAT(); @@ -494,7 +494,7 @@ struct PairComputeFunctor { const int jtype = c.type(j); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < static_cast(STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { const KK_FLOAT fpair = factor_lj*c.template compute_fpair(rsq,i,j,itype,jtype); @@ -638,7 +638,7 @@ struct PairComputeFunctor { const int jtype = c.type(j); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < (STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { + if (rsq < static_cast(STACKPARAMS?c.m_cutsq[itype][jtype]:c.d_cutsq(itype,jtype))) { KK_FLOAT fpair = KK_FLOAT(); diff --git a/src/KOKKOS/pair_lj96_cut_kokkos.cpp b/src/KOKKOS/pair_lj96_cut_kokkos.cpp index ae7898d1522..d1d9a598a6f 100644 --- a/src/KOKKOS/pair_lj96_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj96_cut_kokkos.cpp @@ -137,7 +137,7 @@ KK_FLOAT PairLJ96CutKokkos:: compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { const KK_FLOAT r2inv = static_cast(1.0) / rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r3inv = sqrt(r6inv); + const KK_FLOAT r3inv = Kokkos::sqrt(r6inv); const KK_FLOAT forcelj = r6inv * ((STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1)*r3inv - @@ -154,7 +154,7 @@ KK_FLOAT PairLJ96CutKokkos:: compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { const KK_FLOAT r2inv = static_cast(1.0) / rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r3inv = sqrt(r6inv); + const KK_FLOAT r3inv = Kokkos::sqrt(r6inv); return r6inv*((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r3inv - (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)) - diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp index 36752d24fdd..8f8cf5b6201 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp @@ -102,15 +102,15 @@ void PairLJCharmmCoulCharmmImplicitKokkos::compute(int eflag_in, int type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -127,16 +127,16 @@ void PairLJCharmmCoulCharmmImplicitKokkos::compute(int eflag_in, int if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -164,7 +164,10 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCharmmCoulCharmmImplicitKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT cut_lj_innersq_kk = static_cast(cut_lj_innersq); + const KK_FLOAT cut_ljsq_kk = static_cast(cut_ljsq); + const KK_FLOAT denom_lj_kk = static_cast(denom_lj); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcelj, switch1, switch2, englj; @@ -172,10 +175,10 @@ compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, ((STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj2:params(itype,jtype).lj2)); - if (rsq > cut_lj_innersq) { - switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) * - (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; - switch2 = 12.0*rsq * (cut_ljsq-rsq) * (rsq-cut_lj_innersq) / denom_lj; + if (rsq > cut_lj_innersq_kk) { + switch1 = (cut_ljsq_kk-rsq) * (cut_ljsq_kk-rsq) * + (cut_ljsq_kk + static_cast(2.0)*rsq - static_cast(3.0)*cut_lj_innersq_kk) / denom_lj_kk; + switch2 = static_cast(12.0)*rsq * (cut_ljsq_kk-rsq) * (rsq-cut_lj_innersq_kk) / denom_lj_kk; englj = r6inv * ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); @@ -195,7 +198,10 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCharmmCoulCharmmImplicitKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT cut_lj_innersq_kk = static_cast(cut_lj_innersq); + const KK_FLOAT cut_ljsq_kk = static_cast(cut_ljsq); + const KK_FLOAT denom_lj_kk = static_cast(denom_lj); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT englj, switch1; @@ -203,9 +209,9 @@ compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); - if (rsq > cut_lj_innersq) { - switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) * - (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; + if (rsq > cut_lj_innersq_kk) { + switch1 = (cut_ljsq_kk-rsq) * (cut_ljsq_kk-rsq) * + (cut_ljsq_kk + static_cast(2.0)*rsq - static_cast(3.0)*cut_lj_innersq_kk) / denom_lj_kk; englj *= switch1; } @@ -225,16 +231,19 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT cut_coul_innersq_kk = static_cast(cut_coul_innersq); + const KK_FLOAT cut_coulsq_kk = static_cast(cut_coulsq); + const KK_FLOAT denom_coul_kk = static_cast(denom_coul); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; KK_FLOAT forcecoul, switch1, switch2; - forcecoul = 2.0 * qqrd2e * qtmp*q(j) * r2inv; + forcecoul = static_cast(2.0) * qqrd2e * qtmp*q(j) * r2inv; - if (rsq > cut_coul_innersq) { - switch1 = (cut_coulsq-rsq) * (cut_coulsq-rsq) * - (cut_coulsq + 2.0*rsq - 3.0*cut_coul_innersq) / denom_coul; - switch2 = 12.0*rsq * (cut_coulsq-rsq) * (rsq-cut_coul_innersq) / denom_coul; - forcecoul *= switch1 + 0.5*switch2; + if (rsq > cut_coul_innersq_kk) { + switch1 = (cut_coulsq_kk-rsq) * (cut_coulsq_kk-rsq) * + (cut_coulsq_kk + static_cast(2.0)*rsq - static_cast(3.0)*cut_coul_innersq_kk) / denom_coul_kk; + switch2 = static_cast(12.0)*rsq * (cut_coulsq_kk-rsq) * (rsq-cut_coul_innersq_kk) / denom_coul_kk; + forcecoul *= switch1 + static_cast(0.5)*switch2; } return forcecoul * r2inv * factor_coul; @@ -252,14 +261,17 @@ KK_FLOAT PairLJCharmmCoulCharmmImplicitKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT cut_coul_innersq_kk = static_cast(cut_coul_innersq); + const KK_FLOAT cut_coulsq_kk = static_cast(cut_coulsq); + const KK_FLOAT denom_coul_kk = static_cast(denom_coul); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; KK_FLOAT ecoul, switch1; ecoul = qqrd2e * qtmp * q(j) * r2inv; - if (rsq > cut_coul_innersq) { - switch1 = (cut_coulsq-rsq) * (cut_coulsq-rsq) * - (cut_coulsq + 2.0*rsq - 3.0*cut_coul_innersq) / - denom_coul; + if (rsq > cut_coul_innersq_kk) { + switch1 = (cut_coulsq_kk-rsq) * (cut_coulsq_kk-rsq) * + (cut_coulsq_kk + static_cast(2.0)*rsq - static_cast(3.0)*cut_coul_innersq_kk) / + denom_coul_kk; ecoul *= switch1; } @@ -307,7 +319,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = rtable[i]; + h_table(i) = static_cast(rtable[i]); } Kokkos::deep_copy(d_table,h_table); d_rtable = d_table; @@ -317,7 +329,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = drtable[i]; + h_table(i) = static_cast(drtable[i]); } Kokkos::deep_copy(d_table,h_table); d_drtable = d_table; @@ -329,7 +341,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co // Copy ftable and dftable for (int i = 0; i < ntable; i++) { - h_table(i) = ftable[i]; + h_table(i) = static_cast(ftable[i]); } Kokkos::deep_copy(d_table,h_table); d_ftable = d_table; @@ -340,7 +352,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dftable[i]; + h_table(i) = static_cast(dftable[i]); } Kokkos::deep_copy(d_table,h_table); d_dftable = d_table; @@ -352,7 +364,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co // Copy ctable and dctable for (int i = 0; i < ntable; i++) { - h_table(i) = ctable[i]; + h_table(i) = static_cast(ctable[i]); } Kokkos::deep_copy(d_table,h_table); d_ctable = d_table; @@ -363,7 +375,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dctable[i]; + h_table(i) = static_cast(dctable[i]); } Kokkos::deep_copy(d_table,h_table); d_dctable = d_table; @@ -375,7 +387,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co // Copy etable and detable for (int i = 0; i < ntable; i++) { - h_table(i) = etable[i]; + h_table(i) = static_cast(etable[i]); } Kokkos::deep_copy(d_table,h_table); d_etable = d_table; @@ -386,7 +398,7 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_tables(double cut_co table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = detable[i]; + h_table(i) = static_cast(detable[i]); } Kokkos::deep_copy(d_table,h_table); d_detable = d_table; @@ -402,8 +414,8 @@ void PairLJCharmmCoulCharmmImplicitKokkos::init_style() { PairLJCharmmCoulCharmmImplicit::init_style(); - Kokkos::deep_copy(d_cut_ljsq,cut_ljsq); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_ljsq,static_cast(cut_ljsq)); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); // error if rRESPA with inner levels @@ -434,20 +446,20 @@ double PairLJCharmmCoulCharmmImplicitKokkos::init_one(int i, int j) { double cutone = PairLJCharmmCoulCharmmImplicit::init_one(i,j); - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); //k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsq; - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsq); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsq); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp index db22bab350e..9e3fb7a1c6d 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp @@ -103,15 +103,15 @@ void PairLJCharmmCoulCharmmKokkos::compute(int eflag_in, int vflag_i type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -128,16 +128,16 @@ void PairLJCharmmCoulCharmmKokkos::compute(int eflag_in, int vflag_i if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -165,7 +165,10 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCharmmCoulCharmmKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT cut_lj_innersq_kk = static_cast(cut_lj_innersq); + const KK_FLOAT cut_ljsq_kk = static_cast(cut_ljsq); + const KK_FLOAT denom_lj_kk = static_cast(denom_lj); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcelj, switch1, switch2, englj; @@ -173,10 +176,10 @@ compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, ((STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj2:params(itype,jtype).lj2)); - if (rsq > cut_lj_innersq) { - switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) * - (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; - switch2 = 12.0*rsq * (cut_ljsq-rsq) * (rsq-cut_lj_innersq) / denom_lj; + if (rsq > cut_lj_innersq_kk) { + switch1 = (cut_ljsq_kk-rsq) * (cut_ljsq_kk-rsq) * + (cut_ljsq_kk + static_cast(2.0)*rsq - static_cast(3.0)*cut_lj_innersq_kk) / denom_lj_kk; + switch2 = static_cast(12.0)*rsq * (cut_ljsq_kk-rsq) * (rsq-cut_lj_innersq_kk) / denom_lj_kk; englj = r6inv * ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); @@ -196,7 +199,10 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCharmmCoulCharmmKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT cut_lj_innersq_kk = static_cast(cut_lj_innersq); + const KK_FLOAT cut_ljsq_kk = static_cast(cut_ljsq); + const KK_FLOAT denom_lj_kk = static_cast(denom_lj); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT englj, switch1; @@ -204,9 +210,9 @@ compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); - if (rsq > cut_lj_innersq) { - switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) * - (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; + if (rsq > cut_lj_innersq_kk) { + switch1 = (cut_ljsq_kk-rsq) * (cut_ljsq_kk-rsq) * + (cut_ljsq_kk + static_cast(2.0)*rsq - static_cast(3.0)*cut_lj_innersq_kk) / denom_lj_kk; englj *= switch1; } @@ -225,15 +231,18 @@ KK_FLOAT PairLJCharmmCoulCharmmKokkos:: compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT cut_coul_innersq_kk = static_cast(cut_coul_innersq); + const KK_FLOAT cut_coulsq_kk = static_cast(cut_coulsq); + const KK_FLOAT denom_coul_kk = static_cast(denom_coul); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); KK_FLOAT forcecoul, switch1; forcecoul = qqrd2e*qtmp*q(j) *rinv; - if (rsq > cut_coul_innersq) { - switch1 = (cut_coulsq-rsq) * (cut_coulsq-rsq) * - (cut_coulsq + 2.0*rsq - 3.0*cut_coul_innersq) / denom_coul; + if (rsq > cut_coul_innersq_kk) { + switch1 = (cut_coulsq_kk-rsq) * (cut_coulsq_kk-rsq) * + (cut_coulsq_kk + static_cast(2.0)*rsq - static_cast(3.0)*cut_coul_innersq_kk) / denom_coul_kk; forcecoul *= switch1; } @@ -252,15 +261,18 @@ KK_FLOAT PairLJCharmmCoulCharmmKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT cut_coul_innersq_kk = static_cast(cut_coul_innersq); + const KK_FLOAT cut_coulsq_kk = static_cast(cut_coulsq); + const KK_FLOAT denom_coul_kk = static_cast(denom_coul); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); KK_FLOAT ecoul, switch1; ecoul = qqrd2e * qtmp * q(j) * rinv; - if (rsq > cut_coul_innersq) { - switch1 = (cut_coulsq-rsq) * (cut_coulsq-rsq) * - (cut_coulsq + 2.0*rsq - 3.0*cut_coul_innersq) / - denom_coul; + if (rsq > cut_coul_innersq_kk) { + switch1 = (cut_coulsq_kk-rsq) * (cut_coulsq_kk-rsq) * + (cut_coulsq_kk + static_cast(2.0)*rsq - static_cast(3.0)*cut_coul_innersq_kk) / + denom_coul_kk; ecoul *= switch1; } @@ -308,7 +320,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = rtable[i]; + h_table(i) = static_cast(rtable[i]); } Kokkos::deep_copy(d_table,h_table); d_rtable = d_table; @@ -318,7 +330,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = drtable[i]; + h_table(i) = static_cast(drtable[i]); } Kokkos::deep_copy(d_table,h_table); d_drtable = d_table; @@ -330,7 +342,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub // Copy ftable and dftable for (int i = 0; i < ntable; i++) { - h_table(i) = ftable[i]; + h_table(i) = static_cast(ftable[i]); } Kokkos::deep_copy(d_table,h_table); d_ftable = d_table; @@ -341,7 +353,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dftable[i]; + h_table(i) = static_cast(dftable[i]); } Kokkos::deep_copy(d_table,h_table); d_dftable = d_table; @@ -353,7 +365,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub // Copy ctable and dctable for (int i = 0; i < ntable; i++) { - h_table(i) = ctable[i]; + h_table(i) = static_cast(ctable[i]); } Kokkos::deep_copy(d_table,h_table); d_ctable = d_table; @@ -364,7 +376,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dctable[i]; + h_table(i) = static_cast(dctable[i]); } Kokkos::deep_copy(d_table,h_table); d_dctable = d_table; @@ -376,7 +388,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub // Copy etable and detable for (int i = 0; i < ntable; i++) { - h_table(i) = etable[i]; + h_table(i) = static_cast(etable[i]); } Kokkos::deep_copy(d_table,h_table); d_etable = d_table; @@ -387,7 +399,7 @@ void PairLJCharmmCoulCharmmKokkos::init_tables(double cut_coul, doub table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = detable[i]; + h_table(i) = static_cast(detable[i]); } Kokkos::deep_copy(d_table,h_table); d_detable = d_table; @@ -403,8 +415,8 @@ void PairLJCharmmCoulCharmmKokkos::init_style() { PairLJCharmmCoulCharmm::init_style(); - Kokkos::deep_copy(d_cut_ljsq,cut_ljsq); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_ljsq,static_cast(cut_ljsq)); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); // error if rRESPA with inner levels @@ -435,20 +447,20 @@ double PairLJCharmmCoulCharmmKokkos::init_one(int i, int j) { double cutone = PairLJCharmmCoulCharmm::init_one(i,j); - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); //k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsq; - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsq); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsq); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp index e3ed2470d2b..4c397548484 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp @@ -248,9 +248,9 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, } return forcecoul/rsq; } else { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT grij = g_ewald_kk * r; - const KK_FLOAT expm2 = exp(-grij*grij); + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); const KK_FLOAT rinv = static_cast(1.0) / r; const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; @@ -286,9 +286,9 @@ compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, } return ecoul; } else { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT grij = g_ewald_kk * r; - const KK_FLOAT expm2 = exp(-grij*grij); + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]/r; diff --git a/src/KOKKOS/pair_lj_charmmfsw_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_charmmfsw_coul_long_kokkos.cpp index 78027355699..8048d7fc0c2 100644 --- a/src/KOKKOS/pair_lj_charmmfsw_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmmfsw_coul_long_kokkos.cpp @@ -108,15 +108,15 @@ void PairLJCharmmfswCoulLongKokkos::compute(int eflag_in, int vflag_ type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -133,16 +133,16 @@ void PairLJCharmmfswCoulLongKokkos::compute(int eflag_in, int vflag_ if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -170,7 +170,10 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCharmmfswCoulLongKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT cut_lj_innersq_kk = static_cast(cut_lj_innersq); + const KK_FLOAT cut_ljsq_kk = static_cast(cut_ljsq); + const KK_FLOAT denom_lj_kk = static_cast(denom_lj); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcelj, switch1; @@ -178,9 +181,9 @@ compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, ((STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj2:params(itype,jtype).lj2)); - if (rsq > cut_lj_innersq) { - switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) * - (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; + if (rsq > cut_lj_innersq_kk) { + switch1 = (cut_ljsq_kk-rsq) * (cut_ljsq_kk-rsq) * + (cut_ljsq_kk + static_cast(2.0)*rsq - static_cast(3.0)*cut_lj_innersq_kk) / denom_lj_kk; forcelj = forcelj*switch1; } @@ -197,25 +200,34 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCharmmfswCoulLongKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT cut_lj_innersq_kk = static_cast(cut_lj_innersq); + const KK_FLOAT cut_lj6_kk = static_cast(cut_lj6); + const KK_FLOAT cut_lj6inv_kk = static_cast(cut_lj6inv); + const KK_FLOAT cut_lj3_kk = static_cast(cut_lj3); + const KK_FLOAT cut_lj3inv_kk = static_cast(cut_lj3inv); + const KK_FLOAT cut_lj_inner6inv_kk = static_cast(cut_lj_inner6inv); + const KK_FLOAT cut_lj_inner3inv_kk = static_cast(cut_lj_inner3inv); + const KK_FLOAT denom_lj12_kk = static_cast(denom_lj12); + const KK_FLOAT denom_lj6_kk = static_cast(denom_lj6); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT rinv = 1.0/r; + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT rinv = static_cast(1.0)/r; const KK_FLOAT r3inv = rinv*rinv*rinv; KK_FLOAT englj, englj12, englj6; - if (rsq > cut_lj_innersq) { - englj12 = (STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*cut_lj6* - denom_lj12 * (r6inv - cut_lj6inv)*(r6inv - cut_lj6inv); + if (rsq > cut_lj_innersq_kk) { + englj12 = (STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*cut_lj6_kk* + denom_lj12_kk * (r6inv - cut_lj6inv_kk)*(r6inv - cut_lj6inv_kk); englj6 = -(STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)* - cut_lj3*denom_lj6 * (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv); + cut_lj3_kk*denom_lj6_kk * (r3inv - cut_lj3inv_kk)*(r3inv - cut_lj3inv_kk); englj = englj12 + englj6; } else { englj12 = r6inv*(STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - - (STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*cut_lj_inner6inv*cut_lj6inv; + (STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*cut_lj_inner6inv_kk*cut_lj6inv_kk; englj6 = -(STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)*r6inv + (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)* - cut_lj_inner3inv*cut_lj3inv; + cut_lj_inner3inv_kk*cut_lj3inv_kk; englj = englj12 + englj6; } return englj; @@ -232,29 +244,31 @@ KK_FLOAT PairLJCharmmfswCoulLongKokkos:: compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_ftable[itable] + fraction*d_dftable[itable]; KK_FLOAT forcecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - forcecoul -= (1.0-factor_coul)*prefactor; + forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return forcecoul/rsq; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT rinv = 1.0/r; - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT rinv = static_cast(1.0)/r; + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]*rinv; - KK_FLOAT forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + KK_FLOAT forcecoul = prefactor * (erfc + static_cast(EWALD_F)*grij*expm2); + if (factor_coul < static_cast(1.0)) forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; return forcecoul*rinv*rinv; } @@ -270,28 +284,30 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCharmmfswCoulLongKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_etable[itable] + fraction*d_detable[itable]; KK_FLOAT ecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - ecoul -= (1.0-factor_coul)*prefactor; + ecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return ecoul; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]/r; KK_FLOAT ecoul = prefactor * erfc; - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + if (factor_coul < static_cast(1.0)) ecoul -= (static_cast(1.0)-factor_coul)*prefactor; return ecoul; } } @@ -336,7 +352,7 @@ void PairLJCharmmfswCoulLongKokkos::init_tables(double cut_coul, dou host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = rtable[i]; + h_table(i) = static_cast(rtable[i]); } Kokkos::deep_copy(d_table,h_table); d_rtable = d_table; @@ -346,7 +362,7 @@ void PairLJCharmmfswCoulLongKokkos::init_tables(double cut_coul, dou host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = drtable[i]; + h_table(i) = static_cast(drtable[i]); } Kokkos::deep_copy(d_table,h_table); d_drtable = d_table; @@ -358,7 +374,7 @@ void PairLJCharmmfswCoulLongKokkos::init_tables(double cut_coul, dou // Copy ftable and dftable for (int i = 0; i < ntable; i++) { - h_table(i) = ftable[i]; + h_table(i) = static_cast(ftable[i]); } Kokkos::deep_copy(d_table,h_table); d_ftable = d_table; @@ -369,7 +385,7 @@ void PairLJCharmmfswCoulLongKokkos::init_tables(double cut_coul, dou table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dftable[i]; + h_table(i) = static_cast(dftable[i]); } Kokkos::deep_copy(d_table,h_table); d_dftable = d_table; @@ -381,7 +397,7 @@ void PairLJCharmmfswCoulLongKokkos::init_tables(double cut_coul, dou // Copy ctable and dctable for (int i = 0; i < ntable; i++) { - h_table(i) = ctable[i]; + h_table(i) = static_cast(ctable[i]); } Kokkos::deep_copy(d_table,h_table); d_ctable = d_table; @@ -392,7 +408,7 @@ void PairLJCharmmfswCoulLongKokkos::init_tables(double cut_coul, dou table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dctable[i]; + h_table(i) = static_cast(dctable[i]); } Kokkos::deep_copy(d_table,h_table); d_dctable = d_table; @@ -404,7 +420,7 @@ void PairLJCharmmfswCoulLongKokkos::init_tables(double cut_coul, dou // Copy etable and detable for (int i = 0; i < ntable; i++) { - h_table(i) = etable[i]; + h_table(i) = static_cast(etable[i]); } Kokkos::deep_copy(d_table,h_table); d_etable = d_table; @@ -415,7 +431,7 @@ void PairLJCharmmfswCoulLongKokkos::init_tables(double cut_coul, dou table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = detable[i]; + h_table(i) = static_cast(detable[i]); } Kokkos::deep_copy(d_table,h_table); d_detable = d_table; @@ -431,8 +447,8 @@ void PairLJCharmmfswCoulLongKokkos::init_style() { PairLJCharmmfswCoulLong::init_style(); - Kokkos::deep_copy(d_cut_ljsq,cut_ljsq); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_ljsq,static_cast(cut_ljsq)); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); // error if rRESPA with inner levels @@ -463,19 +479,19 @@ double PairLJCharmmfswCoulLongKokkos::init_one(int i, int j) { double cutone = PairLJCharmmfswCoulLong::init_one(i,j); - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsq; - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsq); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsq); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp index a744b0f2f5d..1d67b18f1fe 100644 --- a/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_coul_cut_kokkos.cpp @@ -102,15 +102,15 @@ void PairLJClass2CoulCutKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -121,16 +121,16 @@ void PairLJClass2CoulCutKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -158,8 +158,8 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJClass2CoulCutKokkos:: compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); const KK_FLOAT r3inv = r2inv*rinv; const KK_FLOAT r6inv = r3inv*r3inv; @@ -181,8 +181,8 @@ KK_FLOAT PairLJClass2CoulCutKokkos:: compute_fcoul(const KK_FLOAT &rsq, const int &/*i*/, const int &j, const int &/*itype*/, const int &/*jtype*/, const KK_FLOAT &factor_coul, const KK_FLOAT &qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); KK_FLOAT forcecoul; forcecoul = qqrd2e*qtmp*q(j) *rinv; @@ -202,8 +202,8 @@ compute_evdwl(const KK_FLOAT& rsq, const int& i, const int&j, const int& itype, const int& jtype) const { (void) i; (void) j; - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); const KK_FLOAT r3inv = r2inv*rinv; const KK_FLOAT r6inv = r3inv*r3inv; @@ -223,8 +223,8 @@ KK_FLOAT PairLJClass2CoulCutKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); return factor_coul*qqrd2e*qtmp*q(j)*rinv; @@ -293,20 +293,20 @@ double PairLJClass2CoulCutKokkos::init_one(int i, int j) double cut_ljsqm = cut_ljsq[i][j]; double cut_coulsqm = cut_coulsq[i][j]; - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsqm; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsqm); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsqm); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp index 7917b3fdb23..43b3ac1666b 100644 --- a/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp @@ -101,15 +101,15 @@ void PairLJClass2CoulLongKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -126,16 +126,16 @@ void PairLJClass2CoulLongKokkos::compute(int eflag_in, int vflag_in) if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -163,8 +163,8 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJClass2CoulLongKokkos:: compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); const KK_FLOAT r3inv = r2inv*rinv; const KK_FLOAT r6inv = r3inv*r3inv; @@ -186,29 +186,31 @@ KK_FLOAT PairLJClass2CoulLongKokkos:: compute_fcoul(const KK_FLOAT &rsq, const int &/*i*/, const int &j, const int &/*itype*/, const int &/*jtype*/, const KK_FLOAT &factor_coul, const KK_FLOAT &qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_ftable[itable] + fraction*d_dftable[itable]; KK_FLOAT forcecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - forcecoul -= (1.0-factor_coul)*prefactor; + forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return forcecoul/rsq; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT rinv = 1.0/r; - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT rinv = static_cast(1.0)/r; + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]*rinv; - KK_FLOAT forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + KK_FLOAT forcecoul = prefactor * (erfc + static_cast(EWALD_F)*grij*expm2); + if (factor_coul < static_cast(1.0)) forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; return forcecoul*rinv*rinv; } @@ -226,8 +228,8 @@ compute_evdwl(const KK_FLOAT& rsq, const int& i, const int&j, const int& itype, const int& jtype) const { (void) i; (void) j; - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); const KK_FLOAT r3inv = r2inv*rinv; const KK_FLOAT r6inv = r3inv*r3inv; @@ -247,28 +249,30 @@ KK_FLOAT PairLJClass2CoulLongKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_etable[itable] + fraction*d_detable[itable]; KK_FLOAT ecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - ecoul -= (1.0-factor_coul)*prefactor; + ecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return ecoul; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]/r; KK_FLOAT ecoul = prefactor * erfc; - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + if (factor_coul < static_cast(1.0)) ecoul -= (static_cast(1.0)-factor_coul)*prefactor; return ecoul; } } @@ -315,7 +319,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = rtable[i]; + h_table(i) = static_cast(rtable[i]); } Kokkos::deep_copy(d_table,h_table); d_rtable = d_table; @@ -325,7 +329,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = drtable[i]; + h_table(i) = static_cast(drtable[i]); } Kokkos::deep_copy(d_table,h_table); d_drtable = d_table; @@ -337,7 +341,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double // Copy ftable and dftable for (int i = 0; i < ntable; i++) { - h_table(i) = ftable[i]; + h_table(i) = static_cast(ftable[i]); } Kokkos::deep_copy(d_table,h_table); d_ftable = d_table; @@ -348,7 +352,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dftable[i]; + h_table(i) = static_cast(dftable[i]); } Kokkos::deep_copy(d_table,h_table); d_dftable = d_table; @@ -360,7 +364,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double // Copy ctable and dctable for (int i = 0; i < ntable; i++) { - h_table(i) = ctable[i]; + h_table(i) = static_cast(ctable[i]); } Kokkos::deep_copy(d_table,h_table); d_ctable = d_table; @@ -371,7 +375,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dctable[i]; + h_table(i) = static_cast(dctable[i]); } Kokkos::deep_copy(d_table,h_table); d_dctable = d_table; @@ -383,7 +387,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double // Copy etable and detable for (int i = 0; i < ntable; i++) { - h_table(i) = etable[i]; + h_table(i) = static_cast(etable[i]); } Kokkos::deep_copy(d_table,h_table); d_etable = d_table; @@ -394,7 +398,7 @@ void PairLJClass2CoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = detable[i]; + h_table(i) = static_cast(detable[i]); } Kokkos::deep_copy(d_table,h_table); d_detable = d_table; @@ -410,7 +414,7 @@ void PairLJClass2CoulLongKokkos::init_style() { PairLJClass2CoulLong::init_style(); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); // error if rRESPA with inner levels @@ -442,20 +446,20 @@ double PairLJClass2CoulLongKokkos::init_one(int i, int j) double cutone = PairLJClass2CoulLong::init_one(i,j); double cut_ljsqm = cut_ljsq[i][j]; - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_class2_kokkos.cpp b/src/KOKKOS/pair_lj_class2_kokkos.cpp index ed4e41cee1f..c8a92020528 100644 --- a/src/KOKKOS/pair_lj_class2_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_kokkos.cpp @@ -102,23 +102,23 @@ void PairLJClass2Kokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms EV_FLOAT ev = pair_compute,void >(this,(NeighListKokkos*)list); - if (eflag) eng_vdwl += ev.evdwl; + if (eflag) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -141,8 +141,8 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJClass2Kokkos:: compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); const KK_FLOAT r3inv = r2inv*rinv; const KK_FLOAT r6inv = r3inv*r3inv; @@ -160,8 +160,8 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJClass2Kokkos:: compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); const KK_FLOAT r3inv = r2inv*rinv; const KK_FLOAT r6inv = r3inv*r3inv; @@ -225,16 +225,16 @@ double PairLJClass2Kokkos::init_one(int i, int j) { double cutone = PairLJClass2::init_one(i,j); - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; k_cutsq.modify_host(); diff --git a/src/KOKKOS/pair_lj_cubic_kokkos.cpp b/src/KOKKOS/pair_lj_cubic_kokkos.cpp index ad993fa0a0f..6f0299ea2fc 100644 --- a/src/KOKKOS/pair_lj_cubic_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cubic_kokkos.cpp @@ -155,7 +155,7 @@ compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, ((STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj2:params(itype,jtype).lj2)); } else { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rmin = (STACKPARAMS?m_params[itype][jtype].sigma:params(itype,jtype).sigma) * static_cast(RT6TWO); const KK_FLOAT t = (r - (STACKPARAMS?m_params[itype][jtype].cut_inner:params(itype,jtype).cut_inner)) / rmin; @@ -183,7 +183,7 @@ compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); } else { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rmin = (STACKPARAMS?m_params[itype][jtype].sigma:params(itype,jtype).sigma) * static_cast(RT6TWO); const KK_FLOAT t = (r - (STACKPARAMS?m_params[itype][jtype].cut_inner:params(itype,jtype).cut_inner)) / rmin; @@ -265,7 +265,7 @@ double PairLJCubicKokkos::init_one(int i, int j) m_cutsq[j][i] = m_cutsq[i][j] = static_cast(cutone*cutone); } - k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = static_cast(cutone*cutone); + k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; k_cutsq.modify_host(); k_params.modify_host(); diff --git a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp index 0245d878384..907e4ea5954 100644 --- a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp @@ -99,15 +99,15 @@ void PairLJCutCoulCutKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -116,16 +116,16 @@ void PairLJCutCoulCutKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -152,7 +152,7 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCutCoulCutKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcelj; @@ -174,8 +174,8 @@ KK_FLOAT PairLJCutCoulCutKokkos:: compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); KK_FLOAT forcecoul; forcecoul = qqrd2e*qtmp*q(j) *rinv; @@ -193,7 +193,7 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCutCoulCutKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; return r6inv* @@ -214,8 +214,8 @@ KK_FLOAT PairLJCutCoulCutKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); return factor_coul*qqrd2e*qtmp*q(j)*rinv; @@ -284,20 +284,20 @@ double PairLJCutCoulCutKokkos::init_one(int i, int j) double cut_ljsqm = cut_ljsq[i][j]; double cut_coulsqm = cut_coulsq[i][j]; - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsqm; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsqm); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsqm); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp index 2f99f9fbdd8..e26385c5d2e 100644 --- a/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_debye_kokkos.cpp @@ -105,15 +105,15 @@ void PairLJCutCoulDebyeKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -124,16 +124,16 @@ void PairLJCutCoulDebyeKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -161,7 +161,7 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCutCoulDebyeKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcelj; @@ -184,13 +184,14 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); - const KK_FLOAT r = 1.0/rinv; - const KK_FLOAT screening = exp(-kappa*r); + const KK_FLOAT kappa_kk = static_cast(kappa); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); + const KK_FLOAT r = static_cast(1.0)/rinv; + const KK_FLOAT screening = Kokkos::exp(-kappa_kk*r); KK_FLOAT forcecoul; - forcecoul = qqrd2e * qtmp * q(j) * screening * (kappa + rinv); + forcecoul = qqrd2e * qtmp * q(j) * screening * (kappa_kk + rinv); return factor_coul*forcecoul*r2inv; @@ -206,7 +207,7 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCutCoulDebyeKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; return r6inv* @@ -228,10 +229,11 @@ compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); - const KK_FLOAT r = 1.0/rinv; - const KK_FLOAT screening = exp(-kappa*r); + const KK_FLOAT kappa_kk = static_cast(kappa); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); + const KK_FLOAT r = static_cast(1.0)/rinv; + const KK_FLOAT screening = Kokkos::exp(-kappa_kk*r); return factor_coul * qqrd2e * qtmp * q(j) * rinv * screening; } @@ -300,20 +302,20 @@ double PairLJCutCoulDebyeKokkos::init_one(int i, int j) double cut_ljsqm = cut_ljsq[i][j]; double cut_coulsqm = cut_coulsq[i][j]; - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsqm; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsqm); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsqm); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp index 7313abe91e1..d0cede05b53 100644 --- a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp @@ -107,15 +107,15 @@ void PairLJCutCoulDSFKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -129,23 +129,23 @@ void PairLJCutCoulDSFKokkos::compute(int eflag_in, int vflag_in) for (int ii = 0; ii < inum; ii ++) { //int i = list->ilist[ii]; double qtmp = atom->q[ii]; - eng_coul += -(e_shift/2.0 + alpha/MY_PIS) * qtmp*qtmp*qqrd2e; + eng_coul += -(e_shift/2.0 + alpha/MY_PIS) * qtmp*qtmp*static_cast(qqrd2e); } ev = pair_compute,void > (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -173,7 +173,7 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCutCoulDSFKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcelj; @@ -194,7 +194,7 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJCutCoulDSFKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; return r6inv* @@ -216,14 +216,16 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT alpha_kk = static_cast(alpha); + const KK_FLOAT f_shift_kk = static_cast(f_shift); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT prefactor = factor_coul * qqrd2e * qtmp * q(j); - const KK_FLOAT erfcd = exp(-alpha*alpha*rsq); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*alpha*r); - const KK_FLOAT erfcc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * erfcd; + const KK_FLOAT erfcd = Kokkos::exp(-alpha_kk*alpha_kk*rsq); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*alpha_kk*r); + const KK_FLOAT erfcc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * erfcd; - return prefactor * (erfcc/r + 2.0*alpha/MY_PIS * erfcd + r*f_shift) * + return prefactor * (erfcc/r + static_cast(2.0)*alpha_kk/static_cast(MY_PIS) * erfcd + r*f_shift_kk) * r2inv; } @@ -239,13 +241,16 @@ compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT alpha_kk = static_cast(alpha); + const KK_FLOAT e_shift_kk = static_cast(e_shift); + const KK_FLOAT f_shift_kk = static_cast(f_shift); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT prefactor = factor_coul * qqrd2e * qtmp * q(j); - const KK_FLOAT erfcd = exp(-alpha*alpha*rsq); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*alpha*r); - const KK_FLOAT erfcc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * erfcd; + const KK_FLOAT erfcd = Kokkos::exp(-alpha_kk*alpha_kk*rsq); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*alpha_kk*r); + const KK_FLOAT erfcc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * erfcd; - return prefactor * (erfcc - r*e_shift - rsq*f_shift) / r; + return prefactor * (erfcc - r*e_shift_kk - rsq*f_shift_kk) / r; } @@ -283,7 +288,7 @@ void PairLJCutCoulDSFKokkos::init_style() { PairLJCutCoulDSF::init_style(); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); // error if rRESPA with inner levels @@ -315,20 +320,20 @@ double PairLJCutCoulDSFKokkos::init_one(int i, int j) double cutone = PairLJCutCoulDSF::init_one(i,j); double cut_ljsqm = cut_ljsq[i][j]; - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp index 92ceaef53b8..c3ebe92598b 100644 --- a/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp @@ -208,9 +208,9 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, } return forcecoul/rsq; } else { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT grij = g_ewald_kk * r; - const KK_FLOAT expm2 = exp(-grij*grij); + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); const KK_FLOAT rinv = static_cast(1.0) / r; const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+ @@ -269,9 +269,9 @@ compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, } return ecoul; } else { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT grij = g_ewald_kk * r; - const KK_FLOAT expm2 = exp(-grij*grij); + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+ t * (static_cast(A3)+t*(static_cast(A4)+ diff --git a/src/KOKKOS/pair_lj_cut_coul_wolf_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_wolf_kokkos.cpp index 75b75e74ab7..af085530a92 100644 --- a/src/KOKKOS/pair_lj_cut_coul_wolf_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_wolf_kokkos.cpp @@ -95,7 +95,7 @@ void PairLJCutCoulWolfKokkos::compute(int eflag_in, int vflag_in) // Wolf self-energy shift factors (computed on host, used as scalars in kernel) m_alf = static_cast(alf); e_shift = static_cast(erfc(alf*cut_coul)/cut_coul); - f_shift = static_cast(-(e_shift + 2.0*alf/MY_PIS * + f_shift = static_cast(-(static_cast(e_shift) + 2.0*alf/MY_PIS * exp(-alf*alf*cut_coul*cut_coul)) / cut_coul); x = atomKK->k_x.view(); @@ -105,21 +105,21 @@ void PairLJCutCoulWolfKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // Wolf self-energy per atom for (int i = 0; i < nlocal; i++) { double qisq = atom->q[i]*atom->q[i]; - eng_coul += -(e_shift/2.0 + m_alf/MY_PIS) * qisq * qqrd2e; + eng_coul += -(static_cast(e_shift)/2.0 + static_cast(m_alf)/MY_PIS) * qisq * static_cast(qqrd2e); } EV_FLOAT ev; @@ -130,16 +130,16 @@ void PairLJCutCoulWolfKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -148,7 +148,7 @@ void PairLJCutCoulWolfKokkos::compute(int eflag_in, int vflag_in) // Add Wolf self-energy to per-atom energy after device sync for (int i = 0; i < nlocal; i++) { double qisq = atom->q[i]*atom->q[i]; - eatom[i] += -(e_shift/2.0 + m_alf/MY_PIS) * qisq * qqrd2e; + eatom[i] += -(static_cast(e_shift)/2.0 + static_cast(m_alf)/MY_PIS) * qisq * static_cast(qqrd2e); } } @@ -174,7 +174,7 @@ KK_FLOAT PairLJCutCoulWolfKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; const KK_FLOAT forcelj = r6inv * ((STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1)*r6inv - @@ -195,12 +195,12 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int& j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT prefactor = qqrd2e * qtmp * q(j) / r; - const KK_FLOAT erfcc = erfc(m_alf*r); + const KK_FLOAT erfcc = Kokkos::erfc(m_alf*r); const KK_FLOAT erfcd = Kokkos::exp(-m_alf*m_alf*rsq); - const KK_FLOAT dvdrr = (erfcc*r2inv + 2.0*m_alf/MY_PIS * erfcd/r) + f_shift; + const KK_FLOAT dvdrr = (erfcc*r2inv + static_cast(2.0)*m_alf/static_cast(MY_PIS) * erfcd/r) + f_shift; KK_FLOAT forcecoul = dvdrr * rsq * prefactor; if (factor_coul < static_cast(1.0)) forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; return forcecoul * r2inv; @@ -218,7 +218,7 @@ KK_FLOAT PairLJCutCoulWolfKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; return r6inv* ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv @@ -241,7 +241,7 @@ compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int& j, { const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT prefactor = qqrd2e * qtmp * q(j) / r; - const KK_FLOAT erfcc = erfc(m_alf*r); + const KK_FLOAT erfcc = Kokkos::erfc(m_alf*r); KK_FLOAT ecoul = (erfcc - e_shift*r) * prefactor; if (factor_coul < static_cast(1.0)) ecoul -= (static_cast(1.0)-factor_coul)*prefactor; return ecoul; @@ -282,7 +282,7 @@ void PairLJCutCoulWolfKokkos::init_style() { PairLJCutCoulWolf::init_style(); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); if (update->whichflag == 1 && utils::strmatch(update->integrate_style,"^respa")) { int respa = 0; @@ -310,20 +310,20 @@ double PairLJCutCoulWolfKokkos::init_one(int i, int j) double cutone = PairLJCutCoulWolf::init_one(i,j); double cut_ljsqm = cut_ljsq[i][j]; - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_cut_dipole_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_dipole_cut_kokkos.cpp index 5eb21919916..8f8460126ed 100644 --- a/src/KOKKOS/pair_lj_cut_dipole_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_dipole_cut_kokkos.cpp @@ -113,15 +113,15 @@ void PairLJCutDipoleCutKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // get the neighbor list and neighbors used in operator() @@ -204,17 +204,17 @@ void PairLJCutDipoleCutKokkos::compute(int eflag_in, int vflag_in) } if (eflag_global) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -279,7 +279,7 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne KK_FLOAT cutsq_ij = STACKPARAMS?m_cutsq[itype][jtype]:d_cutsq(itype,jtype); if (rsq < cutsq_ij) { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcelj = 0; KK_FLOAT evdwl = 0; @@ -309,7 +309,7 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)) - (STACKPARAMS?m_params[itype][jtype].offset:params(itype,jtype).offset); evdwl *= factor_lj; - ev.evdwl += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(1.0):static_cast(0.5))*static_cast(evdwl); } } // cutsq_ljsq_ij @@ -319,14 +319,14 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne if (rsq < cut_coulsq_ij) { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); const KK_FLOAT qj = q[j]; KK_FLOAT r3inv = r2inv*rinv; // charge-charge - if (qtmp != 0.0 && qj != 0.0) { + if (qtmp != static_cast(0.0) && qj != static_cast(0.0)) { KK_FLOAT pre1 = qtmp*qj*r3inv; forcecoulx += pre1*delx; forcecouly += pre1*dely; @@ -338,7 +338,7 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne KK_FLOAT pdotp, pidotr, pjdotr; KK_FLOAT r5inv = r3inv*r2inv; - if (mui > 0.0 && muj > 0.0) { + if (mui > static_cast(0.0) && muj > static_cast(0.0)) { KK_FLOAT r7inv = r5inv*r2inv; @@ -346,10 +346,10 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne pidotr = mu(i,0)*delx + mu(i,1)*dely + mu(i,2)*delz; pjdotr = mu(j,0)*delx + mu(j,1)*dely + mu(j,2)*delz; - KK_FLOAT pre1 = 3.0*r5inv*pdotp - 15.0*r7inv*pidotr*pjdotr; - KK_FLOAT pre2 = 3.0*r5inv*pjdotr; - KK_FLOAT pre3 = 3.0*r5inv*pidotr; - KK_FLOAT pre4 = -1.0*r3inv; + KK_FLOAT pre1 = static_cast(3.0)*r5inv*pdotp - static_cast(15.0)*r7inv*pidotr*pjdotr; + KK_FLOAT pre2 = static_cast(3.0)*r5inv*pjdotr; + KK_FLOAT pre3 = static_cast(3.0)*r5inv*pidotr; + KK_FLOAT pre4 = static_cast(-1.0)*r3inv; forcecoulx += pre1*delx + pre2*mu(i,0) + pre3*mu(j,0); forcecouly += pre1*dely + pre2*mu(i,1) + pre3*mu(j,1); @@ -371,7 +371,7 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne if (mui > 0 && qj != 0) { pidotr = mu(i,0)*delx + mu(i,1)*dely + mu(i,2)*delz; - KK_FLOAT pre1 = 3.0*qj*r5inv * pidotr; + KK_FLOAT pre1 = static_cast(3.0)*qj*r5inv * pidotr; KK_FLOAT pre2 = qj*r3inv; forcecoulx += pre2*mu(i,0) - pre1*delx; @@ -386,7 +386,7 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne if (qtmp != 0 && muj > 0) { pjdotr = mu(j,0)*delx + mu(j,1)*dely + mu(j,2)*delz; - KK_FLOAT pre1 = 3.0*qtmp*r5inv * pjdotr; + KK_FLOAT pre1 = static_cast(3.0)*qtmp*r5inv * pjdotr; KK_FLOAT pre2 = qtmp*r3inv; forcecoulx += pre1*delx - pre2*mu(j,0); @@ -404,32 +404,32 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne // force & torque accumulation - fx_i += fx; - fy_i += fy; - fz_i += fz; - torquex_i += fq*tixcoul; - torquey_i += fq*tiycoul; - torquez_i += fq*tizcoul; + fx_i += static_cast(fx); + fy_i += static_cast(fy); + fz_i += static_cast(fz); + torquex_i += static_cast(fq*tixcoul); + torquey_i += static_cast(fq*tiycoul); + torquez_i += static_cast(fq*tizcoul); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) -= fx; - a_f(j,1) -= fy; - a_f(j,2) -= fz; - a_torque(j,0) += fq*tjxcoul; - a_torque(j,1) += fq*tjycoul; - a_torque(j,2) += fq*tjzcoul; + a_f(j,0) -= static_cast(fx); + a_f(j,1) -= static_cast(fy); + a_f(j,2) -= static_cast(fz); + a_torque(j,0) += static_cast(fq*tjxcoul); + a_torque(j,1) += static_cast(fq*tjycoul); + a_torque(j,2) += static_cast(fq*tjzcoul); } if (EVFLAG && eflag_global) { ecoul = qtmp*qj*rinv; - if (mu(i,3) > 0.0 && mu(j,3) > 0.0) - ecoul += r3inv*pdotp - 3.0*r5inv*pidotr*pjdotr; - if (mu(i,3) > 0.0 && qj != 0.0) + if (mu(i,3) > static_cast(0.0) && mu(j,3) > static_cast(0.0)) + ecoul += r3inv*pdotp - static_cast(3.0)*r5inv*pidotr*pjdotr; + if (mu(i,3) > static_cast(0.0) && qj != static_cast(0.0)) ecoul += -qj*r3inv*pidotr; - if (mu(j,3) > 0.0 && qtmp != 0.0) + if (mu(j,3) > static_cast(0.0) && qtmp != static_cast(0.0)) ecoul += qtmp*r3inv*pjdotr; ecoul *= factor_coul*qqrd2e; - ev.ecoul += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(1.0):static_cast(0.5))*static_cast(ecoul); } } // cutsq_coulsq_ij @@ -522,7 +522,7 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne KK_FLOAT tz = 0.0; if (rsq < cutsq_ij) { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcelj = 0; KK_FLOAT evdwl = 0; @@ -550,7 +550,7 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)) - (STACKPARAMS?m_params[itype][jtype].offset:params(itype,jtype).offset); evdwl *= factor_lj; - ev.evdwl += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(1.0):static_cast(0.5))*static_cast(evdwl); } } // cutsq_ljsq_ij @@ -560,14 +560,14 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne if (rsq < cut_coulsq_ij) { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); const KK_FLOAT qj = q[j]; KK_FLOAT r3inv = r2inv*rinv; // charge-charge - if (qtmp != 0.0 && qj != 0.0) { + if (qtmp != static_cast(0.0) && qj != static_cast(0.0)) { KK_FLOAT pre1 = qtmp*qj*r3inv; forcecoulx += pre1*delx; forcecouly += pre1*dely; @@ -579,7 +579,7 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne KK_FLOAT pdotp, pidotr, pjdotr; KK_FLOAT r5inv = r3inv*r2inv; - if (mui > 0.0 && muj > 0.0) { + if (mui > static_cast(0.0) && muj > static_cast(0.0)) { KK_FLOAT r7inv = r5inv*r2inv; @@ -587,10 +587,10 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne pidotr = mu(i,0)*delx + mu(i,1)*dely + mu(i,2)*delz; pjdotr = mu(j,0)*delx + mu(j,1)*dely + mu(j,2)*delz; - KK_FLOAT pre1 = 3.0*r5inv*pdotp - 15.0*r7inv*pidotr*pjdotr; - KK_FLOAT pre2 = 3.0*r5inv*pjdotr; - KK_FLOAT pre3 = 3.0*r5inv*pidotr; - KK_FLOAT pre4 = -1.0*r3inv; + KK_FLOAT pre1 = static_cast(3.0)*r5inv*pdotp - static_cast(15.0)*r7inv*pidotr*pjdotr; + KK_FLOAT pre2 = static_cast(3.0)*r5inv*pjdotr; + KK_FLOAT pre3 = static_cast(3.0)*r5inv*pidotr; + KK_FLOAT pre4 = static_cast(-1.0)*r3inv; forcecoulx += pre1*delx + pre2*mu(i,0) + pre3*mu(j,0); forcecouly += pre1*dely + pre2*mu(i,1) + pre3*mu(j,1); @@ -612,7 +612,7 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne if (mui > 0 && qj != 0) { pidotr = mu(i,0)*delx + mu(i,1)*dely + mu(i,2)*delz; - KK_FLOAT pre1 = 3.0*qj*r5inv * pidotr; + KK_FLOAT pre1 = static_cast(3.0)*qj*r5inv * pidotr; KK_FLOAT pre2 = qj*r3inv; forcecoulx += pre2*mu(i,0) - pre1*delx; @@ -627,7 +627,7 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne if (qtmp != 0 && muj > 0) { pjdotr = mu(j,0)*delx + mu(j,1)*dely + mu(j,2)*delz; - KK_FLOAT pre1 = 3.0*qtmp*r5inv * pjdotr; + KK_FLOAT pre1 = static_cast(3.0)*qtmp*r5inv * pjdotr; KK_FLOAT pre2 = qtmp*r3inv; forcecoulx += pre1*delx - pre2*mu(j,0); @@ -647,36 +647,36 @@ void PairLJCutDipoleCutKokkos::operator()(TagPairLJCutDipoleCutKerne tz = fq*tizcoul; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) -= fx; - a_f(j,1) -= fy; - a_f(j,2) -= fz; - a_torque(j,0) += fq*tjxcoul; - a_torque(j,1) += fq*tjycoul; - a_torque(j,2) += fq*tjzcoul; + a_f(j,0) -= static_cast(fx); + a_f(j,1) -= static_cast(fy); + a_f(j,2) -= static_cast(fz); + a_torque(j,0) += static_cast(fq*tjxcoul); + a_torque(j,1) += static_cast(fq*tjycoul); + a_torque(j,2) += static_cast(fq*tjzcoul); } if (EVFLAG && eflag_global) { ecoul = qtmp*qj*rinv; - if (mu(i,3) > 0.0 && mu(j,3) > 0.0) - ecoul += r3inv*pdotp - 3.0*r5inv*pidotr*pjdotr; - if (mu(i,3) > 0.0 && qj != 0.0) + if (mu(i,3) > static_cast(0.0) && mu(j,3) > static_cast(0.0)) + ecoul += r3inv*pdotp - static_cast(3.0)*r5inv*pidotr*pjdotr; + if (mu(i,3) > static_cast(0.0) && qj != static_cast(0.0)) ecoul += -qj*r3inv*pidotr; - if (mu(j,3) > 0.0 && qtmp != 0.0) + if (mu(j,3) > static_cast(0.0) && qtmp != static_cast(0.0)) ecoul += qtmp*r3inv*pjdotr; ecoul *= factor_coul*qqrd2e; - ev.ecoul += (((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD)&&(NEWTON_PAIR||(j(1.0):static_cast(0.5))*static_cast(ecoul); } } // cutsq_coulsq_ij if (EVFLAG && (eflag_atom || vflag_either)) ev_tally_xyz(ev, i, j, ecoul+evdwl, fx, fy, fz, delx, dely, delz); - fx_acc += fx; - fy_acc += fy; - fz_acc += fz; - tx_acc += tx; - ty_acc += ty; - tz_acc += tz; + fx_acc += static_cast(fx); + fy_acc += static_cast(fy); + fz_acc += static_cast(fz); + tx_acc += static_cast(tx); + ty_acc += static_cast(ty); + tz_acc += static_cast(tz); } // cutsq_ij }, fx_i, fy_i, fz_i, torquex_i, torquey_i, torquez_i); @@ -703,7 +703,7 @@ void PairLJCutDipoleCutKokkos::ev_tally_xyz(EV_FLOAT & ev, int i, in Kokkos::View::value,Kokkos::MemoryTraits::value> > v_vatom = d_vatom; if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; + const KK_ACC_FLOAT epairhalf = static_cast(0.5) * static_cast(epair); if (NEIGHFLAG == FULL || newton_pair || i < nlocal) v_eatom[i] += epairhalf; if (NEIGHFLAG != FULL && (newton_pair || j < nlocal)) @@ -711,12 +711,12 @@ void PairLJCutDipoleCutKokkos::ev_tally_xyz(EV_FLOAT & ev, int i, in } if (vflag_either) { - const KK_FLOAT v0 = delx*fx; - const KK_FLOAT v1 = dely*fy; - const KK_FLOAT v2 = delz*fz; - const KK_FLOAT v3 = delx*fy; - const KK_FLOAT v4 = delx*fz; - const KK_FLOAT v5 = dely*fz; + const KK_ACC_FLOAT v0 = static_cast(delx*fx); + const KK_ACC_FLOAT v1 = static_cast(dely*fy); + const KK_ACC_FLOAT v2 = static_cast(delz*fz); + const KK_ACC_FLOAT v3 = static_cast(delx*fy); + const KK_ACC_FLOAT v4 = static_cast(delx*fz); + const KK_ACC_FLOAT v5 = static_cast(dely*fz); if (vflag_global) { if (NEIGHFLAG != FULL) { @@ -729,49 +729,49 @@ void PairLJCutDipoleCutKokkos::ev_tally_xyz(EV_FLOAT & ev, int i, in ev.v[5] += v5; } else { // neigh half, newton off if (i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*v0; + ev.v[1] += static_cast(0.5)*v1; + ev.v[2] += static_cast(0.5)*v2; + ev.v[3] += static_cast(0.5)*v3; + ev.v[4] += static_cast(0.5)*v4; + ev.v[5] += static_cast(0.5)*v5; } if (j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*v0; + ev.v[1] += static_cast(0.5)*v1; + ev.v[2] += static_cast(0.5)*v2; + ev.v[3] += static_cast(0.5)*v3; + ev.v[4] += static_cast(0.5)*v4; + ev.v[5] += static_cast(0.5)*v5; } } } else { //neigh full - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*v0; + ev.v[1] += static_cast(0.5)*v1; + ev.v[2] += static_cast(0.5)*v2; + ev.v[3] += static_cast(0.5)*v3; + ev.v[4] += static_cast(0.5)*v4; + ev.v[5] += static_cast(0.5)*v5; } } if (vflag_atom) { if (NEIGHFLAG == FULL || NEWTON_PAIR || i < nlocal) { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*v0; + v_vatom(i,1) += static_cast(0.5)*v1; + v_vatom(i,2) += static_cast(0.5)*v2; + v_vatom(i,3) += static_cast(0.5)*v3; + v_vatom(i,4) += static_cast(0.5)*v4; + v_vatom(i,5) += static_cast(0.5)*v5; } if (NEIGHFLAG != FULL && (NEWTON_PAIR || j < nlocal)) { - v_vatom(j,0) += 0.5*v0; - v_vatom(j,1) += 0.5*v1; - v_vatom(j,2) += 0.5*v2; - v_vatom(j,3) += 0.5*v3; - v_vatom(j,4) += 0.5*v4; - v_vatom(j,5) += 0.5*v5; + v_vatom(j,0) += static_cast(0.5)*v0; + v_vatom(j,1) += static_cast(0.5)*v1; + v_vatom(j,2) += static_cast(0.5)*v2; + v_vatom(j,3) += static_cast(0.5)*v3; + v_vatom(j,4) += static_cast(0.5)*v4; + v_vatom(j,5) += static_cast(0.5)*v5; } } } @@ -848,20 +848,20 @@ double PairLJCutDipoleCutKokkos::init_one(int i, int j) double cut_ljsqm = cut_ljsq[i][j]; double cut_coulsqm = cut_coulsq[i][j]; - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsqm; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsqm); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsqm); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_cut_sphere_kokkos.cpp b/src/KOKKOS/pair_lj_cut_sphere_kokkos.cpp index 1b17c417623..8b4284d206f 100644 --- a/src/KOKKOS/pair_lj_cut_sphere_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_sphere_kokkos.cpp @@ -103,10 +103,10 @@ void PairLJCutSphereKokkos::compute(int eflag_in, int vflag_in) radius = atomKK->k_radius.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); newton_pair = force->newton_pair; EV_FLOAT ev; @@ -116,14 +116,14 @@ void PairLJCutSphereKokkos::compute(int eflag_in, int vflag_in) ev = pair_compute,void> (this,(NeighListKokkos*)list); - if (eflag) eng_vdwl += ev.evdwl; + if (eflag) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -287,13 +287,13 @@ double PairLJCutSphereKokkos::init_one(int i, int j) k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutsqm); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cutsqm); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutsqm; k_cutsq.modify_host(); - k_cut_ljsq.view_host()(i,j) = k_cut_ljsq.view_host()(j,i) = cutsqm; + k_cut_ljsq.view_host()(i,j) = k_cut_ljsq.view_host()(j,i) = static_cast(cutsqm); k_cut_ljsq.modify_host(); k_params.modify_host(); diff --git a/src/KOKKOS/pair_lj_cut_tip4p_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_tip4p_cut_kokkos.cpp index 04977edfec7..1ba2f6f0bdd 100644 --- a/src/KOKKOS/pair_lj_cut_tip4p_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_tip4p_cut_kokkos.cpp @@ -48,9 +48,12 @@ void PairLJCutTIP4PCutKokkos::compute(int eflag_in, int vflag_in) auto h_cut_ljsq = Kokkos::create_mirror_view(d_cut_ljsq); for (int i = 1; i < ntp1; i++) for (int j = 1; j < ntp1; j++) { - h_lj1(i,j) = this->lj1[i][j]; h_lj2(i,j) = this->lj2[i][j]; - h_lj3(i,j) = this->lj3[i][j]; h_lj4(i,j) = this->lj4[i][j]; - h_offset(i,j) = this->offset[i][j]; h_cut_ljsq(i,j) = this->cut_ljsq[i][j]; + h_lj1(i,j) = static_cast(this->lj1[i][j]); + h_lj2(i,j) = static_cast(this->lj2[i][j]); + h_lj3(i,j) = static_cast(this->lj3[i][j]); + h_lj4(i,j) = static_cast(this->lj4[i][j]); + h_offset(i,j) = static_cast(this->offset[i][j]); + h_cut_ljsq(i,j) = static_cast(this->cut_ljsq[i][j]); } Kokkos::deep_copy(d_lj1,h_lj1); Kokkos::deep_copy(d_lj2,h_lj2); Kokkos::deep_copy(d_lj3,h_lj3); Kokkos::deep_copy(d_lj4,h_lj4); @@ -71,7 +74,7 @@ void PairLJCutTIP4PCutKokkos::compute(int eflag_in, int vflag_in) this->copymode = 0; - if (this->eflag_global) this->eng_vdwl += ev.evdwl; + if (this->eflag_global) this->eng_vdwl += static_cast(ev.evdwl); this->finalize(ev); } diff --git a/src/KOKKOS/pair_lj_cut_tip4p_long_kokkos.cpp b/src/KOKKOS/pair_lj_cut_tip4p_long_kokkos.cpp index 2a0186776af..01aa59d4a3c 100644 --- a/src/KOKKOS/pair_lj_cut_tip4p_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_tip4p_long_kokkos.cpp @@ -50,9 +50,12 @@ void PairLJCutTIP4PLongKokkos::compute(int eflag_in, int vflag_in) auto h_cut_ljsq = Kokkos::create_mirror_view(d_cut_ljsq); for (int i = 1; i < ntp1; i++) for (int j = 1; j < ntp1; j++) { - h_lj1(i,j) = this->lj1[i][j]; h_lj2(i,j) = this->lj2[i][j]; - h_lj3(i,j) = this->lj3[i][j]; h_lj4(i,j) = this->lj4[i][j]; - h_offset(i,j) = this->offset[i][j]; h_cut_ljsq(i,j) = this->cut_ljsq[i][j]; + h_lj1(i,j) = static_cast(this->lj1[i][j]); + h_lj2(i,j) = static_cast(this->lj2[i][j]); + h_lj3(i,j) = static_cast(this->lj3[i][j]); + h_lj4(i,j) = static_cast(this->lj4[i][j]); + h_offset(i,j) = static_cast(this->offset[i][j]); + h_cut_ljsq(i,j) = static_cast(this->cut_ljsq[i][j]); } Kokkos::deep_copy(d_lj1,h_lj1); Kokkos::deep_copy(d_lj2,h_lj2); Kokkos::deep_copy(d_lj3,h_lj3); Kokkos::deep_copy(d_lj4,h_lj4); @@ -73,7 +76,7 @@ void PairLJCutTIP4PLongKokkos::compute(int eflag_in, int vflag_in) this->copymode = 0; - if (this->eflag_global) this->eng_vdwl += ev.evdwl; + if (this->eflag_global) this->eng_vdwl += static_cast(ev.evdwl); this->finalize(ev); } diff --git a/src/KOKKOS/pair_lj_expand_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_expand_coul_long_kokkos.cpp index daba83cc732..7afa03265ff 100644 --- a/src/KOKKOS/pair_lj_expand_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_expand_coul_long_kokkos.cpp @@ -107,15 +107,15 @@ void PairLJExpandCoulLongKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -132,16 +132,16 @@ void PairLJExpandCoulLongKokkos::compute(int eflag_in, int vflag_in) if (eflag_global) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -169,10 +169,10 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJExpandCoulLongKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rshift = r - (STACKPARAMS?m_params[itype][jtype].shift:params(itype,jtype).shift); const KK_FLOAT rshiftsq = rshift*rshift; - const KK_FLOAT r2inv = 1.0/rshiftsq; + const KK_FLOAT r2inv = static_cast(1.0)/rshiftsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; const KK_FLOAT forcelj = r6inv * @@ -192,29 +192,31 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJExpandCoulLongKokkos:: compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_ftable[itable] + fraction*d_dftable[itable]; KK_FLOAT forcecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - forcecoul -= (1.0-factor_coul)*prefactor; + forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return forcecoul/rsq; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT rinv = 1.0/r; - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT rinv = static_cast(1.0)/r; + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]*rinv; - KK_FLOAT forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + KK_FLOAT forcecoul = prefactor * (erfc + static_cast(EWALD_F)*grij*expm2); + if (factor_coul < static_cast(1.0)) forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; return forcecoul*rinv*rinv; } @@ -231,10 +233,10 @@ KK_FLOAT PairLJExpandCoulLongKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rshift = r - (STACKPARAMS?m_params[itype][jtype].shift:params(itype,jtype).shift); const KK_FLOAT rshiftsq = rshift*rshift; - const KK_FLOAT r2inv = 1.0/rshiftsq; + const KK_FLOAT r2inv = static_cast(1.0)/rshiftsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; return r6inv*((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv @@ -253,28 +255,30 @@ KK_FLOAT PairLJExpandCoulLongKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_etable[itable] + fraction*d_detable[itable]; KK_FLOAT ecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - ecoul -= (1.0-factor_coul)*prefactor; + ecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return ecoul; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]/r; KK_FLOAT ecoul = prefactor * erfc; - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + if (factor_coul < static_cast(1.0)) ecoul -= (static_cast(1.0)-factor_coul)*prefactor; return ecoul; } } @@ -320,7 +324,7 @@ void PairLJExpandCoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = rtable[i]; + h_table(i) = static_cast(rtable[i]); } Kokkos::deep_copy(d_table,h_table); d_rtable = d_table; @@ -330,7 +334,7 @@ void PairLJExpandCoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = drtable[i]; + h_table(i) = static_cast(drtable[i]); } Kokkos::deep_copy(d_table,h_table); d_drtable = d_table; @@ -342,7 +346,7 @@ void PairLJExpandCoulLongKokkos::init_tables(double cut_coul, double // Copy ftable and dftable for (int i = 0; i < ntable; i++) { - h_table(i) = ftable[i]; + h_table(i) = static_cast(ftable[i]); } Kokkos::deep_copy(d_table,h_table); d_ftable = d_table; @@ -353,7 +357,7 @@ void PairLJExpandCoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dftable[i]; + h_table(i) = static_cast(dftable[i]); } Kokkos::deep_copy(d_table,h_table); d_dftable = d_table; @@ -365,7 +369,7 @@ void PairLJExpandCoulLongKokkos::init_tables(double cut_coul, double // Copy ctable and dctable for (int i = 0; i < ntable; i++) { - h_table(i) = ctable[i]; + h_table(i) = static_cast(ctable[i]); } Kokkos::deep_copy(d_table,h_table); d_ctable = d_table; @@ -376,7 +380,7 @@ void PairLJExpandCoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dctable[i]; + h_table(i) = static_cast(dctable[i]); } Kokkos::deep_copy(d_table,h_table); d_dctable = d_table; @@ -388,7 +392,7 @@ void PairLJExpandCoulLongKokkos::init_tables(double cut_coul, double // Copy etable and detable for (int i = 0; i < ntable; i++) { - h_table(i) = etable[i]; + h_table(i) = static_cast(etable[i]); } Kokkos::deep_copy(d_table,h_table); d_etable = d_table; @@ -399,7 +403,7 @@ void PairLJExpandCoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = detable[i]; + h_table(i) = static_cast(detable[i]); } Kokkos::deep_copy(d_table,h_table); d_detable = d_table; @@ -415,7 +419,7 @@ void PairLJExpandCoulLongKokkos::init_style() { PairLJExpandCoulLong::init_style(); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); // error if rRESPA with inner levels @@ -447,21 +451,21 @@ double PairLJExpandCoulLongKokkos::init_one(int i, int j) double cutone = PairLJExpandCoulLong::init_one(i,j); double cut_ljsqm = cut_ljsq[i][j]; - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).shift = shift[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).shift = static_cast(shift[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_expand_kokkos.cpp b/src/KOKKOS/pair_lj_expand_kokkos.cpp index f2cb4dd6a39..374b2357b45 100644 --- a/src/KOKKOS/pair_lj_expand_kokkos.cpp +++ b/src/KOKKOS/pair_lj_expand_kokkos.cpp @@ -101,10 +101,10 @@ void PairLJExpandKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms @@ -112,14 +112,14 @@ void PairLJExpandKokkos::compute(int eflag_in, int vflag_in) EV_FLOAT ev = pair_compute,void >(this,(NeighListKokkos*)list); - if (eflag) eng_vdwl += ev.evdwl; + if (eflag) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -145,10 +145,10 @@ KK_FLOAT PairLJExpandKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rshift = r - (STACKPARAMS?m_params[itype][jtype].shift:params(itype,jtype).shift); const KK_FLOAT rshiftsq = rshift*rshift; - const KK_FLOAT r2inv = 1.0/rshiftsq; + const KK_FLOAT r2inv = static_cast(1.0)/rshiftsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; const KK_FLOAT forcelj = r6inv * @@ -167,10 +167,10 @@ KK_FLOAT PairLJExpandKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT rshift = r - (STACKPARAMS?m_params[itype][jtype].shift:params(itype,jtype).shift); const KK_FLOAT rshiftsq = rshift*rshift; - const KK_FLOAT r2inv = 1.0/rshiftsq; + const KK_FLOAT r2inv = static_cast(1.0)/rshiftsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; return r6inv*((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - @@ -233,17 +233,17 @@ double PairLJExpandKokkos::init_one(int i, int j) { double cutone = PairLJExpand::init_one(i,j); - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).shift = shift[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).shift = static_cast(shift[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp index f0466287dc8..f4945d16d77 100644 --- a/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp +++ b/src/KOKKOS/pair_lj_gromacs_coul_gromacs_kokkos.cpp @@ -101,15 +101,15 @@ void PairLJGromacsCoulGromacsKokkos::compute(int eflag_in, int vflag type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -126,16 +126,16 @@ void PairLJGromacsCoulGromacsKokkos::compute(int eflag_in, int vflag if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -164,15 +164,17 @@ KK_FLOAT PairLJGromacsCoulGromacsKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT cut_lj_innersq_kk = static_cast(cut_lj_innersq); + const KK_FLOAT cut_lj_inner_kk = static_cast(cut_lj_inner); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcelj = r6inv * ((STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj2:params(itype,jtype).lj2)); - if (rsq > cut_lj_innersq) { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT tlj = r - cut_lj_inner; + if (rsq > cut_lj_innersq_kk) { + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT tlj = r - cut_lj_inner_kk; const KK_FLOAT fswitch = r*tlj*tlj* ((STACKPARAMS?m_params[itype][jtype].ljsw1:params(itype,jtype).ljsw1) + (STACKPARAMS?m_params[itype][jtype].ljsw2:params(itype,jtype).ljsw2)*tlj); @@ -192,16 +194,18 @@ KK_FLOAT PairLJGromacsCoulGromacsKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT cut_lj_innersq_kk = static_cast(cut_lj_innersq); + const KK_FLOAT cut_lj_inner_kk = static_cast(cut_lj_inner); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT englj = r6inv * ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)); englj += (STACKPARAMS?m_params[itype][jtype].ljsw5:params(itype,jtype).ljsw5); - if (rsq > cut_lj_innersq) { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT tlj = r - cut_lj_inner; + if (rsq > cut_lj_innersq_kk) { + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT tlj = r - cut_lj_inner_kk; const KK_FLOAT eswitch = tlj*tlj*tlj * ((STACKPARAMS?m_params[itype][jtype].ljsw3:params(itype,jtype).ljsw3) + (STACKPARAMS?m_params[itype][jtype].ljsw4:params(itype,jtype).ljsw4)*tlj); @@ -222,14 +226,18 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); + const KK_FLOAT cut_coul_innersq_kk = static_cast(cut_coul_innersq); + const KK_FLOAT cut_coul_inner_kk = static_cast(cut_coul_inner); + const KK_FLOAT coulsw1_kk = static_cast(coulsw1); + const KK_FLOAT coulsw2_kk = static_cast(coulsw2); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); KK_FLOAT forcecoul = qqrd2e*qtmp*q(j) *rinv; - if (rsq > cut_coul_innersq) { - const KK_FLOAT r = 1.0/rinv; - const KK_FLOAT tc = r - cut_coul_inner; - const KK_FLOAT fcoulswitch = qqrd2e * qtmp*q(j)*r*tc*tc*(coulsw1 + coulsw2*tc); + if (rsq > cut_coul_innersq_kk) { + const KK_FLOAT r = static_cast(1.0)/rinv; + const KK_FLOAT tc = r - cut_coul_inner_kk; + const KK_FLOAT fcoulswitch = qqrd2e * qtmp*q(j)*r*tc*tc*(coulsw1_kk + coulsw2_kk*tc); forcecoul += fcoulswitch; } return forcecoul * r2inv * factor_coul; @@ -247,14 +255,19 @@ compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; - const KK_FLOAT rinv = sqrt(r2inv); - KK_FLOAT ecoul = qqrd2e * qtmp * q(j) * (rinv-coulsw5); - - if (rsq > cut_coul_innersq) { - const KK_FLOAT r = 1.0/rinv; - const KK_FLOAT tc = r - cut_coul_inner; - const KK_FLOAT ecoulswitch = tc*tc*tc * (coulsw3 + coulsw4*tc); + const KK_FLOAT cut_coul_innersq_kk = static_cast(cut_coul_innersq); + const KK_FLOAT cut_coul_inner_kk = static_cast(cut_coul_inner); + const KK_FLOAT coulsw3_kk = static_cast(coulsw3); + const KK_FLOAT coulsw4_kk = static_cast(coulsw4); + const KK_FLOAT coulsw5_kk = static_cast(coulsw5); + const KK_FLOAT r2inv = static_cast(1.0)/rsq; + const KK_FLOAT rinv = Kokkos::sqrt(r2inv); + KK_FLOAT ecoul = qqrd2e * qtmp * q(j) * (rinv-coulsw5_kk); + + if (rsq > cut_coul_innersq_kk) { + const KK_FLOAT r = static_cast(1.0)/rinv; + const KK_FLOAT tc = r - cut_coul_inner_kk; + const KK_FLOAT ecoulswitch = tc*tc*tc * (coulsw3_kk + coulsw4_kk*tc); ecoul += qqrd2e*qtmp*q(j)*ecoulswitch; } return ecoul * factor_coul; @@ -300,7 +313,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = rtable[i]; + h_table(i) = static_cast(rtable[i]); } Kokkos::deep_copy(d_table,h_table); d_rtable = d_table; @@ -310,7 +323,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = drtable[i]; + h_table(i) = static_cast(drtable[i]); } Kokkos::deep_copy(d_table,h_table); d_drtable = d_table; @@ -322,7 +335,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do // Copy ftable and dftable for (int i = 0; i < ntable; i++) { - h_table(i) = ftable[i]; + h_table(i) = static_cast(ftable[i]); } Kokkos::deep_copy(d_table,h_table); d_ftable = d_table; @@ -333,7 +346,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dftable[i]; + h_table(i) = static_cast(dftable[i]); } Kokkos::deep_copy(d_table,h_table); d_dftable = d_table; @@ -345,7 +358,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do // Copy ctable and dctable for (int i = 0; i < ntable; i++) { - h_table(i) = ctable[i]; + h_table(i) = static_cast(ctable[i]); } Kokkos::deep_copy(d_table,h_table); d_ctable = d_table; @@ -356,7 +369,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dctable[i]; + h_table(i) = static_cast(dctable[i]); } Kokkos::deep_copy(d_table,h_table); d_dctable = d_table; @@ -368,7 +381,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do // Copy etable and detable for (int i = 0; i < ntable; i++) { - h_table(i) = etable[i]; + h_table(i) = static_cast(etable[i]); } Kokkos::deep_copy(d_table,h_table); d_etable = d_table; @@ -379,7 +392,7 @@ void PairLJGromacsCoulGromacsKokkos::init_tables(double cut_coul, do table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = detable[i]; + h_table(i) = static_cast(detable[i]); } Kokkos::deep_copy(d_table,h_table); d_detable = d_table; @@ -395,8 +408,8 @@ void PairLJGromacsCoulGromacsKokkos::init_style() { PairLJGromacsCoulGromacs::init_style(); - Kokkos::deep_copy(d_cut_ljsq,cut_ljsq); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_ljsq,static_cast(cut_ljsq)); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); // error if rRESPA with inner levels @@ -429,24 +442,24 @@ double PairLJGromacsCoulGromacsKokkos::init_one(int i, int j) double cut_ljsqm = cut_ljsq; double cut_coulsqm = cut_coulsq; - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).ljsw1 = ljsw1[i][j]; - k_params.view_host()(i,j).ljsw2 = ljsw2[i][j]; - k_params.view_host()(i,j).ljsw3 = ljsw3[i][j]; - k_params.view_host()(i,j).ljsw4 = ljsw4[i][j]; - k_params.view_host()(i,j).ljsw5 = ljsw5[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsqm; - k_params.view_host()(i,j).cut_coulsq = cut_coulsqm; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).ljsw1 = static_cast(ljsw1[i][j]); + k_params.view_host()(i,j).ljsw2 = static_cast(ljsw2[i][j]); + k_params.view_host()(i,j).ljsw3 = static_cast(ljsw3[i][j]); + k_params.view_host()(i,j).ljsw4 = static_cast(ljsw4[i][j]); + k_params.view_host()(i,j).ljsw5 = static_cast(ljsw5[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsqm); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsqm); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsqm); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_gromacs_kokkos.cpp b/src/KOKKOS/pair_lj_gromacs_kokkos.cpp index b6a19e61166..2f1a583c38d 100644 --- a/src/KOKKOS/pair_lj_gromacs_kokkos.cpp +++ b/src/KOKKOS/pair_lj_gromacs_kokkos.cpp @@ -105,10 +105,10 @@ void PairLJGromacsKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); qqrd2e = force->qqrd2e; newton_pair = force->newton_pair; @@ -120,16 +120,16 @@ void PairLJGromacsKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; + eng_vdwl += static_cast(ev.evdwl); eng_coul += 0.0; } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -158,14 +158,14 @@ KK_FLOAT PairLJGromacsKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT forcelj = r6inv * ((STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1)*r6inv - (STACKPARAMS?m_params[itype][jtype].lj2:params(itype,jtype).lj2)); if (rsq > (STACKPARAMS?m_params[itype][jtype].cut_inner_sq:params(itype,jtype).cut_inner_sq)) { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT tlj = r - (STACKPARAMS?m_params[itype][jtype].cut_inner:params(itype,jtype).cut_inner); const KK_FLOAT fswitch = r*tlj*tlj* ((STACKPARAMS?m_params[itype][jtype].ljsw1:params(itype,jtype).ljsw1) + @@ -186,7 +186,7 @@ KK_FLOAT PairLJGromacsKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, const int& itype, const int& jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT r6inv = r2inv*r2inv*r2inv; KK_FLOAT englj = r6inv * ((STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - @@ -194,7 +194,7 @@ compute_evdwl(const KK_FLOAT& rsq, const int& /*i*/, const int& /*j*/, englj += (STACKPARAMS?m_params[itype][jtype].ljsw5:params(itype,jtype).ljsw5); if (rsq > (STACKPARAMS?m_params[itype][jtype].cut_inner_sq:params(itype,jtype).cut_inner_sq)) { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT tlj = r - (STACKPARAMS?m_params[itype][jtype].cut_inner:params(itype,jtype).cut_inner); const KK_FLOAT eswitch = tlj*tlj*tlj * ((STACKPARAMS?m_params[itype][jtype].ljsw3:params(itype,jtype).ljsw3) + @@ -270,22 +270,22 @@ double PairLJGromacsKokkos::init_one(int i, int j) double cutone = PairLJGromacs::init_one(i,j); double cut_inner_sqm = cut_inner_sq[i][j]; - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).ljsw1 = ljsw1[i][j]; - k_params.view_host()(i,j).ljsw2 = ljsw2[i][j]; - k_params.view_host()(i,j).ljsw3 = ljsw3[i][j]; - k_params.view_host()(i,j).ljsw4 = ljsw4[i][j]; - k_params.view_host()(i,j).ljsw5 = ljsw5[i][j]; - k_params.view_host()(i,j).cut_inner_sq = cut_inner_sqm; - k_params.view_host()(i,j).cut_inner = cut_inner[i][j]; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).ljsw1 = static_cast(ljsw1[i][j]); + k_params.view_host()(i,j).ljsw2 = static_cast(ljsw2[i][j]); + k_params.view_host()(i,j).ljsw3 = static_cast(ljsw3[i][j]); + k_params.view_host()(i,j).ljsw4 = static_cast(ljsw4[i][j]); + k_params.view_host()(i,j).ljsw5 = static_cast(ljsw5[i][j]); + k_params.view_host()(i,j).cut_inner_sq = static_cast(cut_inner_sqm); + k_params.view_host()(i,j).cut_inner = static_cast(cut_inner[i][j]); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); m_cut_inner_sq[j][i] = m_cut_inner_sq[i][j] = cut_inner_sqm; } diff --git a/src/KOKKOS/pair_lj_smooth_kokkos.cpp b/src/KOKKOS/pair_lj_smooth_kokkos.cpp index 363a0f62775..47c974ee378 100644 --- a/src/KOKKOS/pair_lj_smooth_kokkos.cpp +++ b/src/KOKKOS/pair_lj_smooth_kokkos.cpp @@ -97,22 +97,22 @@ void PairLJSmoothKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); copymode = 1; EV_FLOAT ev = pair_compute,void>(this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -150,7 +150,7 @@ compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c const KK_FLOAT ljsw2 = STACKPARAMS ? m_params[itype][jtype].ljsw2 : params(itype,jtype).ljsw2; const KK_FLOAT ljsw3 = STACKPARAMS ? m_params[itype][jtype].ljsw3 : params(itype,jtype).ljsw3; const KK_FLOAT ljsw4 = STACKPARAMS ? m_params[itype][jtype].ljsw4 : params(itype,jtype).ljsw4; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT t = r - cut_inner; const KK_FLOAT tsq = t*t; const KK_FLOAT fskin = ljsw1 + ljsw2*t + ljsw3*tsq + ljsw4*tsq*t; @@ -180,7 +180,7 @@ compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c const KK_FLOAT ljsw2 = STACKPARAMS ? m_params[itype][jtype].ljsw2 : params(itype,jtype).ljsw2; const KK_FLOAT ljsw3 = STACKPARAMS ? m_params[itype][jtype].ljsw3 : params(itype,jtype).ljsw3; const KK_FLOAT ljsw4 = STACKPARAMS ? m_params[itype][jtype].ljsw4 : params(itype,jtype).ljsw4; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT t = r - cut_inner; const KK_FLOAT tsq = t*t; return ljsw0 - ljsw1*t - ljsw2*tsq/static_cast(2.0) diff --git a/src/KOKKOS/pair_lj_spica_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_spica_coul_long_kokkos.cpp index 10d7396fb46..051d335a6ef 100644 --- a/src/KOKKOS/pair_lj_spica_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_spica_coul_long_kokkos.cpp @@ -108,15 +108,15 @@ void PairLJSPICACoulLongKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; // loop over neighbors of my atoms @@ -132,17 +132,17 @@ void PairLJSPICACoulLongKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -172,7 +172,7 @@ KK_FLOAT PairLJSPICACoulLongKokkos:: compute_fpair(const KK_FLOAT& rsq, const int& i, const int&j, const int& itype, const int& jtype) const { (void) i; (void) j; - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const int ljt = (STACKPARAMS?m_params[itype][jtype].lj_type:params(itype,jtype).lj_type); const KK_FLOAT lj_1 = (STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1); @@ -180,8 +180,8 @@ compute_fpair(const KK_FLOAT& rsq, const int& i, const int&j, const int& itype, const KK_FLOAT r4inv=r2inv*r2inv; const KK_FLOAT r6inv=r2inv*r4inv; - const KK_FLOAT a = ljt==LJ12_4?r4inv:(ljt==LJ12_5?r4inv*sqrt(r2inv):r6inv); - const KK_FLOAT b = ljt==LJ12_4?r4inv:(ljt==LJ9_6?1.0/sqrt(r2inv):(ljt==LJ12_5?r2inv*sqrt(r2inv):r2inv)); + const KK_FLOAT a = ljt==LJ12_4?r4inv:(ljt==LJ12_5?r4inv*Kokkos::sqrt(r2inv):r6inv); + const KK_FLOAT b = ljt==LJ12_4?r4inv:(ljt==LJ9_6?static_cast(1.0)/Kokkos::sqrt(r2inv):(ljt==LJ12_5?r2inv*Kokkos::sqrt(r2inv):r2inv)); return a* ( lj_1*r6inv*b - lj_2 * r2inv); } @@ -197,7 +197,7 @@ KK_FLOAT PairLJSPICACoulLongKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int& i, const int&j, const int& itype, const int& jtype) const { (void) i; (void) j; - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const int ljt = (STACKPARAMS?m_params[itype][jtype].lj_type:params(itype,jtype).lj_type); const KK_FLOAT lj_3 = (STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3); @@ -208,14 +208,14 @@ compute_evdwl(const KK_FLOAT& rsq, const int& i, const int&j, const int& itype, const KK_FLOAT r4inv=r2inv*r2inv; return r4inv*(lj_3*r4inv*r4inv - lj_4) - offset; } else if (ljt == LJ9_6) { - const KK_FLOAT r3inv = r2inv*sqrt(r2inv); + const KK_FLOAT r3inv = r2inv*Kokkos::sqrt(r2inv); const KK_FLOAT r6inv = r3inv*r3inv; return r6inv*(lj_3*r3inv - lj_4) - offset; } else if (ljt == LJ12_6) { const KK_FLOAT r6inv = r2inv*r2inv*r2inv; return r6inv*(lj_3*r6inv - lj_4) - offset; } else if (ljt == LJ12_5) { - const KK_FLOAT r5inv = r2inv*r2inv*sqrt(r2inv); + const KK_FLOAT r5inv = r2inv*r2inv*Kokkos::sqrt(r2inv); const KK_FLOAT r7inv = r5inv*r2inv; return r5inv*(lj_3*r7inv - lj_4) - offset; } else @@ -235,29 +235,31 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_ftable[itable] + fraction*d_dftable[itable]; KK_FLOAT forcecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - forcecoul -= (1.0-factor_coul)*prefactor; + forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return forcecoul/rsq; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT rinv = 1.0/r; - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT rinv = static_cast(1.0)/r; + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]*rinv; - KK_FLOAT forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); - if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + KK_FLOAT forcecoul = prefactor * (erfc + static_cast(EWALD_F)*grij*expm2); + if (factor_coul < static_cast(1.0)) forcecoul -= (static_cast(1.0)-factor_coul)*prefactor; return forcecoul*rinv*rinv; } @@ -274,28 +276,30 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJSPICACoulLongKokkos:: compute_ecoul(const KK_FLOAT& rsq, const int& /*i*/, const int&j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - if (Specialisation::DoTable && rsq > tabinnersq) { + const KK_FLOAT tabinnersq_kk = static_cast(tabinnersq); + if (Specialisation::DoTable && rsq > tabinnersq_kk) { union_int_float_t rsq_lookup; rsq_lookup.f = rsq; const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; const KK_FLOAT fraction = ((KK_FLOAT)rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; const KK_FLOAT table = d_etable[itable] + fraction*d_detable[itable]; KK_FLOAT ecoul = qtmp*q[j] * table; - if (factor_coul < 1.0) { + if (factor_coul < static_cast(1.0)) { const KK_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; const KK_FLOAT prefactor = qtmp*q[j] * table; - ecoul -= (1.0-factor_coul)*prefactor; + ecoul -= (static_cast(1.0)-factor_coul)*prefactor; } return ecoul; } else { - const KK_FLOAT r = sqrt(rsq); - const KK_FLOAT grij = g_ewald * r; - const KK_FLOAT expm2 = exp(-grij*grij); - const KK_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); - const KK_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const KK_FLOAT g_ewald_kk = static_cast(g_ewald); + const KK_FLOAT r = Kokkos::sqrt(rsq); + const KK_FLOAT grij = g_ewald_kk * r; + const KK_FLOAT expm2 = Kokkos::exp(-grij*grij); + const KK_FLOAT t = static_cast(1.0) / (static_cast(1.0) + static_cast(EWALD_P)*grij); + const KK_FLOAT erfc = t * (static_cast(A1)+t*(static_cast(A2)+t*(static_cast(A3)+t*(static_cast(A4)+t*static_cast(A5))))) * expm2; const KK_FLOAT prefactor = qqrd2e * qtmp*q[j]/r; KK_FLOAT ecoul = prefactor * erfc; - if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + if (factor_coul < static_cast(1.0)) ecoul -= (static_cast(1.0)-factor_coul)*prefactor; return ecoul; } } @@ -345,7 +349,7 @@ void PairLJSPICACoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = rtable[i]; + h_table(i) = static_cast(rtable[i]); } Kokkos::deep_copy(d_table,h_table); d_rtable = d_table; @@ -355,7 +359,7 @@ void PairLJSPICACoulLongKokkos::init_tables(double cut_coul, double host_table_type h_table("HostTable",ntable); table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = drtable[i]; + h_table(i) = static_cast(drtable[i]); } Kokkos::deep_copy(d_table,h_table); d_drtable = d_table; @@ -367,7 +371,7 @@ void PairLJSPICACoulLongKokkos::init_tables(double cut_coul, double // Copy ftable and dftable for (int i = 0; i < ntable; i++) { - h_table(i) = ftable[i]; + h_table(i) = static_cast(ftable[i]); } Kokkos::deep_copy(d_table,h_table); d_ftable = d_table; @@ -378,7 +382,7 @@ void PairLJSPICACoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dftable[i]; + h_table(i) = static_cast(dftable[i]); } Kokkos::deep_copy(d_table,h_table); d_dftable = d_table; @@ -390,7 +394,7 @@ void PairLJSPICACoulLongKokkos::init_tables(double cut_coul, double // Copy ctable and dctable for (int i = 0; i < ntable; i++) { - h_table(i) = ctable[i]; + h_table(i) = static_cast(ctable[i]); } Kokkos::deep_copy(d_table,h_table); d_ctable = d_table; @@ -401,7 +405,7 @@ void PairLJSPICACoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = dctable[i]; + h_table(i) = static_cast(dctable[i]); } Kokkos::deep_copy(d_table,h_table); d_dctable = d_table; @@ -413,7 +417,7 @@ void PairLJSPICACoulLongKokkos::init_tables(double cut_coul, double // Copy etable and detable for (int i = 0; i < ntable; i++) { - h_table(i) = etable[i]; + h_table(i) = static_cast(etable[i]); } Kokkos::deep_copy(d_table,h_table); d_etable = d_table; @@ -424,7 +428,7 @@ void PairLJSPICACoulLongKokkos::init_tables(double cut_coul, double table_type d_table("DeviceTable",ntable); for (int i = 0; i < ntable; i++) { - h_table(i) = detable[i]; + h_table(i) = static_cast(detable[i]); } Kokkos::deep_copy(d_table,h_table); d_detable = d_table; @@ -440,7 +444,7 @@ void PairLJSPICACoulLongKokkos::init_style() { PairLJSPICACoulLong::init_style(); - Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + Kokkos::deep_copy(d_cut_coulsq,static_cast(cut_coulsq)); // error if rRESPA with inner levels @@ -471,21 +475,21 @@ double PairLJSPICACoulLongKokkos::init_one(int i, int j) { double cutone = PairLJSPICACoulLong::init_one(i,j); - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cut_ljsq = cut_ljsq[i][j]; - k_params.view_host()(i,j).cut_coulsq = cut_coulsq; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cut_ljsq = static_cast(cut_ljsq[i][j]); + k_params.view_host()(i,j).cut_coulsq = static_cast(cut_coulsq); k_params.view_host()(i,j).lj_type = lj_type[i][j]; k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsq[i][j]); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_spica_kokkos.cpp b/src/KOKKOS/pair_lj_spica_kokkos.cpp index fe46bd61642..cb249cf83a0 100644 --- a/src/KOKKOS/pair_lj_spica_kokkos.cpp +++ b/src/KOKKOS/pair_lj_spica_kokkos.cpp @@ -100,10 +100,10 @@ void PairLJSPICAKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms @@ -111,14 +111,14 @@ void PairLJSPICAKokkos::compute(int eflag_in, int vflag_in) EV_FLOAT ev = pair_compute,void >(this,(NeighListKokkos*)list); - if (eflag) eng_vdwl += ev.evdwl; + if (eflag) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -146,7 +146,7 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJSPICAKokkos:: compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const int ljt = (STACKPARAMS?m_params[itype][jtype].lj_type:params(itype,jtype).lj_type); const KK_FLOAT lj_1 = (STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1); @@ -154,8 +154,8 @@ compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c const KK_FLOAT r4inv=r2inv*r2inv; const KK_FLOAT r6inv=r2inv*r4inv; - const KK_FLOAT a = ljt==LJ12_4?r4inv:(ljt==LJ12_5?r4inv*sqrt(r2inv):r6inv); - const KK_FLOAT b = ljt==LJ12_4?r4inv:(ljt==LJ9_6?1.0/sqrt(r2inv):(ljt==LJ12_5?r2inv*sqrt(r2inv):r2inv)); + const KK_FLOAT a = ljt==LJ12_4?r4inv:(ljt==LJ12_5?r4inv*Kokkos::sqrt(r2inv):r6inv); + const KK_FLOAT b = ljt==LJ12_4?r4inv:(ljt==LJ9_6?static_cast(1.0)/Kokkos::sqrt(r2inv):(ljt==LJ12_5?r2inv*Kokkos::sqrt(r2inv):r2inv)); return a* ( lj_1*r6inv*b - lj_2 * r2inv); } @@ -169,7 +169,7 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairLJSPICAKokkos:: compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const int ljt = (STACKPARAMS?m_params[itype][jtype].lj_type:params(itype,jtype).lj_type); const KK_FLOAT lj_3 = (STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3); @@ -180,14 +180,14 @@ compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c const KK_FLOAT r4inv=r2inv*r2inv; return r4inv*(lj_3*r4inv*r4inv - lj_4) - offset; } else if (ljt == LJ9_6) { - const KK_FLOAT r3inv = r2inv*sqrt(r2inv); + const KK_FLOAT r3inv = r2inv*Kokkos::sqrt(r2inv); const KK_FLOAT r6inv = r3inv*r3inv; return r6inv*(lj_3*r3inv - lj_4) - offset; } else if (ljt == LJ12_6) { const KK_FLOAT r6inv = r2inv*r2inv*r2inv; return r6inv*(lj_3*r6inv - lj_4) - offset; } else if (ljt == LJ12_5) { - const KK_FLOAT r5inv = r2inv*r2inv*sqrt(r2inv); + const KK_FLOAT r5inv = r2inv*r2inv*Kokkos::sqrt(r2inv); const KK_FLOAT r7inv = r5inv*r2inv; return r5inv*(lj_3*r7inv - lj_4) - offset; } else @@ -249,17 +249,17 @@ double PairLJSPICAKokkos::init_one(int i, int j) { double cutone = PairLJSPICA::init_one(i,j); - k_params.view_host()(i,j).lj1 = lj1[i][j]; - k_params.view_host()(i,j).lj2 = lj2[i][j]; - k_params.view_host()(i,j).lj3 = lj3[i][j]; - k_params.view_host()(i,j).lj4 = lj4[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).lj1 = static_cast(lj1[i][j]); + k_params.view_host()(i,j).lj2 = static_cast(lj2[i][j]); + k_params.view_host()(i,j).lj3 = static_cast(lj3[i][j]); + k_params.view_host()(i,j).lj4 = static_cast(lj4[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(i,j).lj_type = lj_type[i][j]; k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_lj_switch3_coulgauss_long_kokkos.cpp b/src/KOKKOS/pair_lj_switch3_coulgauss_long_kokkos.cpp index 2f711c65e71..975eecbfe81 100644 --- a/src/KOKKOS/pair_lj_switch3_coulgauss_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_switch3_coulgauss_long_kokkos.cpp @@ -127,16 +127,16 @@ void PairLJSwitch3CoulGaussLongKokkos::compute(int eflag_in, int vfl (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -382,9 +382,9 @@ double PairLJSwitch3CoulGaussLongKokkos::init_one(int i, int j) k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_meam_kokkos.cpp b/src/KOKKOS/pair_meam_kokkos.cpp index 94c2dc0ba69..6f68769c34d 100644 --- a/src/KOKKOS/pair_meam_kokkos.cpp +++ b/src/KOKKOS/pair_meam_kokkos.cpp @@ -256,14 +256,14 @@ void PairMEAMKokkos::compute(int eflag_in, int vflag_in) d_ilist_half, d_offset, d_neighbors_half, d_neighbors_full, neighflag, need_dup, ev); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -355,50 +355,50 @@ KOKKOS_INLINE_FUNCTION void PairMEAMKokkos::operator()(TagPairMEAMPackForwardComm, const int &i) const { int j = d_sendlist(i); int m = i*comm_forward; - v_buf[m++] = d_rho0[j]; - v_buf[m++] = d_rho1[j]; - v_buf[m++] = d_rho2[j]; - v_buf[m++] = d_rho3[j]; - v_buf[m++] = d_frhop[j]; - v_buf[m++] = d_gamma[j]; - v_buf[m++] = d_dgamma1[j]; - v_buf[m++] = d_dgamma2[j]; - v_buf[m++] = d_dgamma3[j]; - v_buf[m++] = d_arho2b[j]; - v_buf[m++] = d_arho1(j,0); - v_buf[m++] = d_arho1(j,1); - v_buf[m++] = d_arho1(j,2); - v_buf[m++] = d_arho2(j,0); - v_buf[m++] = d_arho2(j,1); - v_buf[m++] = d_arho2(j,2); - v_buf[m++] = d_arho2(j,3); - v_buf[m++] = d_arho2(j,4); - v_buf[m++] = d_arho2(j,5); - for (int k = 0; k < 10; k++) v_buf[m++] = d_arho3(j,k); - v_buf[m++] = d_arho3b(j,0); - v_buf[m++] = d_arho3b(j,1); - v_buf[m++] = d_arho3b(j,2); - v_buf[m++] = d_t_ave(j,0); - v_buf[m++] = d_t_ave(j,1); - v_buf[m++] = d_t_ave(j,2); - v_buf[m++] = d_tsq_ave(j,0); - v_buf[m++] = d_tsq_ave(j,1); - v_buf[m++] = d_tsq_ave(j,2); + v_buf[m++] = static_cast(d_rho0[j]); + v_buf[m++] = static_cast(d_rho1[j]); + v_buf[m++] = static_cast(d_rho2[j]); + v_buf[m++] = static_cast(d_rho3[j]); + v_buf[m++] = static_cast(d_frhop[j]); + v_buf[m++] = static_cast(d_gamma[j]); + v_buf[m++] = static_cast(d_dgamma1[j]); + v_buf[m++] = static_cast(d_dgamma2[j]); + v_buf[m++] = static_cast(d_dgamma3[j]); + v_buf[m++] = static_cast(d_arho2b[j]); + v_buf[m++] = static_cast(d_arho1(j,0)); + v_buf[m++] = static_cast(d_arho1(j,1)); + v_buf[m++] = static_cast(d_arho1(j,2)); + v_buf[m++] = static_cast(d_arho2(j,0)); + v_buf[m++] = static_cast(d_arho2(j,1)); + v_buf[m++] = static_cast(d_arho2(j,2)); + v_buf[m++] = static_cast(d_arho2(j,3)); + v_buf[m++] = static_cast(d_arho2(j,4)); + v_buf[m++] = static_cast(d_arho2(j,5)); + for (int k = 0; k < 10; k++) v_buf[m++] = static_cast(d_arho3(j,k)); + v_buf[m++] = static_cast(d_arho3b(j,0)); + v_buf[m++] = static_cast(d_arho3b(j,1)); + v_buf[m++] = static_cast(d_arho3b(j,2)); + v_buf[m++] = static_cast(d_t_ave(j,0)); + v_buf[m++] = static_cast(d_t_ave(j,1)); + v_buf[m++] = static_cast(d_t_ave(j,2)); + v_buf[m++] = static_cast(d_tsq_ave(j,0)); + v_buf[m++] = static_cast(d_tsq_ave(j,1)); + v_buf[m++] = static_cast(d_tsq_ave(j,2)); if (msmeamflag) { - v_buf[m++] = d_arho2mb[j]; - v_buf[m++] = d_arho1m(j,0); - v_buf[m++] = d_arho1m(j,1); - v_buf[m++] = d_arho1m(j,2); - v_buf[m++] = d_arho2m(j,0); - v_buf[m++] = d_arho2m(j,1); - v_buf[m++] = d_arho2m(j,2); - v_buf[m++] = d_arho2m(j,3); - v_buf[m++] = d_arho2m(j,4); - v_buf[m++] = d_arho2m(j,5); - for (int k = 0; k < 10; k++) v_buf[m++] = d_arho3m(j,k); - v_buf[m++] = d_arho3mb(j,0); - v_buf[m++] = d_arho3mb(j,1); - v_buf[m++] = d_arho3mb(j,2); + v_buf[m++] = static_cast(d_arho2mb[j]); + v_buf[m++] = static_cast(d_arho1m(j,0)); + v_buf[m++] = static_cast(d_arho1m(j,1)); + v_buf[m++] = static_cast(d_arho1m(j,2)); + v_buf[m++] = static_cast(d_arho2m(j,0)); + v_buf[m++] = static_cast(d_arho2m(j,1)); + v_buf[m++] = static_cast(d_arho2m(j,2)); + v_buf[m++] = static_cast(d_arho2m(j,3)); + v_buf[m++] = static_cast(d_arho2m(j,4)); + v_buf[m++] = static_cast(d_arho2m(j,5)); + for (int k = 0; k < 10; k++) v_buf[m++] = static_cast(d_arho3m(j,k)); + v_buf[m++] = static_cast(d_arho3mb(j,0)); + v_buf[m++] = static_cast(d_arho3mb(j,1)); + v_buf[m++] = static_cast(d_arho3mb(j,2)); } } @@ -421,50 +421,50 @@ void PairMEAMKokkos::operator()(TagPairMEAMUnpackForwardComm, const //int m = i*38; int m = i*comm_forward; - d_rho0[i+first] = v_buf[m++]; - d_rho1[i+first] = v_buf[m++]; - d_rho2[i+first] = v_buf[m++]; - d_rho3[i+first] = v_buf[m++]; - d_frhop[i+first] = v_buf[m++]; - d_gamma[i+first] = v_buf[m++]; - d_dgamma1[i+first] = v_buf[m++]; - d_dgamma2[i+first] = v_buf[m++]; - d_dgamma3[i+first] = v_buf[m++]; - d_arho2b[i+first] = v_buf[m++]; - d_arho1(i+first,0) = v_buf[m++]; - d_arho1(i+first,1) = v_buf[m++]; - d_arho1(i+first,2) = v_buf[m++]; - d_arho2(i+first,0) = v_buf[m++]; - d_arho2(i+first,1) = v_buf[m++]; - d_arho2(i+first,2) = v_buf[m++]; - d_arho2(i+first,3) = v_buf[m++]; - d_arho2(i+first,4) = v_buf[m++]; - d_arho2(i+first,5) = v_buf[m++]; - for (int k = 0; k < 10; k++) d_arho3(i+first,k) = v_buf[m++]; - d_arho3b(i+first,0) = v_buf[m++]; - d_arho3b(i+first,1) = v_buf[m++]; - d_arho3b(i+first,2) = v_buf[m++]; - d_t_ave(i+first,0) = v_buf[m++]; - d_t_ave(i+first,1) = v_buf[m++]; - d_t_ave(i+first,2) = v_buf[m++]; - d_tsq_ave(i+first,0) = v_buf[m++]; - d_tsq_ave(i+first,1) = v_buf[m++]; - d_tsq_ave(i+first,2) = v_buf[m++]; + d_rho0[i+first] = static_cast(v_buf[m++]); + d_rho1[i+first] = static_cast(v_buf[m++]); + d_rho2[i+first] = static_cast(v_buf[m++]); + d_rho3[i+first] = static_cast(v_buf[m++]); + d_frhop[i+first] = static_cast(v_buf[m++]); + d_gamma[i+first] = static_cast(v_buf[m++]); + d_dgamma1[i+first] = static_cast(v_buf[m++]); + d_dgamma2[i+first] = static_cast(v_buf[m++]); + d_dgamma3[i+first] = static_cast(v_buf[m++]); + d_arho2b[i+first] = static_cast(v_buf[m++]); + d_arho1(i+first,0) = static_cast(v_buf[m++]); + d_arho1(i+first,1) = static_cast(v_buf[m++]); + d_arho1(i+first,2) = static_cast(v_buf[m++]); + d_arho2(i+first,0) = static_cast(v_buf[m++]); + d_arho2(i+first,1) = static_cast(v_buf[m++]); + d_arho2(i+first,2) = static_cast(v_buf[m++]); + d_arho2(i+first,3) = static_cast(v_buf[m++]); + d_arho2(i+first,4) = static_cast(v_buf[m++]); + d_arho2(i+first,5) = static_cast(v_buf[m++]); + for (int k = 0; k < 10; k++) d_arho3(i+first,k) = static_cast(v_buf[m++]); + d_arho3b(i+first,0) = static_cast(v_buf[m++]); + d_arho3b(i+first,1) = static_cast(v_buf[m++]); + d_arho3b(i+first,2) = static_cast(v_buf[m++]); + d_t_ave(i+first,0) = static_cast(v_buf[m++]); + d_t_ave(i+first,1) = static_cast(v_buf[m++]); + d_t_ave(i+first,2) = static_cast(v_buf[m++]); + d_tsq_ave(i+first,0) = static_cast(v_buf[m++]); + d_tsq_ave(i+first,1) = static_cast(v_buf[m++]); + d_tsq_ave(i+first,2) = static_cast(v_buf[m++]); if (msmeamflag) { - d_arho2mb[i+first] = v_buf[m++]; - d_arho1m(i+first,0) = v_buf[m++]; - d_arho1m(i+first,1) = v_buf[m++]; - d_arho1m(i+first,2) = v_buf[m++]; - d_arho2m(i+first,0) = v_buf[m++]; - d_arho2m(i+first,1) = v_buf[m++]; - d_arho2m(i+first,2) = v_buf[m++]; - d_arho2m(i+first,3) = v_buf[m++]; - d_arho2m(i+first,4) = v_buf[m++]; - d_arho2m(i+first,5) = v_buf[m++]; - for (int k = 0; k < 10; k++) d_arho3m(i+first,k) = v_buf[m++]; - d_arho3mb(i+first,0) = v_buf[m++]; - d_arho3mb(i+first,1) = v_buf[m++]; - d_arho3mb(i+first,2) = v_buf[m++]; + d_arho2mb[i+first] = static_cast(v_buf[m++]); + d_arho1m(i+first,0) = static_cast(v_buf[m++]); + d_arho1m(i+first,1) = static_cast(v_buf[m++]); + d_arho1m(i+first,2) = static_cast(v_buf[m++]); + d_arho2m(i+first,0) = static_cast(v_buf[m++]); + d_arho2m(i+first,1) = static_cast(v_buf[m++]); + d_arho2m(i+first,2) = static_cast(v_buf[m++]); + d_arho2m(i+first,3) = static_cast(v_buf[m++]); + d_arho2m(i+first,4) = static_cast(v_buf[m++]); + d_arho2m(i+first,5) = static_cast(v_buf[m++]); + for (int k = 0; k < 10; k++) d_arho3m(i+first,k) = static_cast(v_buf[m++]); + d_arho3mb(i+first,0) = static_cast(v_buf[m++]); + d_arho3mb(i+first,1) = static_cast(v_buf[m++]); + d_arho3mb(i+first,2) = static_cast(v_buf[m++]); } } @@ -501,50 +501,50 @@ int PairMEAMKokkos::pack_forward_comm(int n, int *list, double *buf, int m = 0; for (int i = 0; i < n; i++) { const int j = list[i]; - buf[m++] = meam_inst_kk->h_rho0[j]; - buf[m++] = meam_inst_kk->h_rho1[j]; - buf[m++] = meam_inst_kk->h_rho2[j]; - buf[m++] = meam_inst_kk->h_rho3[j]; - buf[m++] = meam_inst_kk->h_frhop[j]; - buf[m++] = meam_inst_kk->h_gamma[j]; - buf[m++] = meam_inst_kk->h_dgamma1[j]; - buf[m++] = meam_inst_kk->h_dgamma2[j]; - buf[m++] = meam_inst_kk->h_dgamma3[j]; - buf[m++] = meam_inst_kk->h_arho2b[j]; - buf[m++] = meam_inst_kk->h_arho1(j,0); - buf[m++] = meam_inst_kk->h_arho1(j,1); - buf[m++] = meam_inst_kk->h_arho1(j,2); - buf[m++] = meam_inst_kk->h_arho2(j,0); - buf[m++] = meam_inst_kk->h_arho2(j,1); - buf[m++] = meam_inst_kk->h_arho2(j,2); - buf[m++] = meam_inst_kk->h_arho2(j,3); - buf[m++] = meam_inst_kk->h_arho2(j,4); - buf[m++] = meam_inst_kk->h_arho2(j,5); - for (int k = 0; k < 10; k++) buf[m++] = meam_inst_kk->h_arho3(j,k); - buf[m++] = meam_inst_kk->h_arho3b(j,0); - buf[m++] = meam_inst_kk->h_arho3b(j,1); - buf[m++] = meam_inst_kk->h_arho3b(j,2); - buf[m++] = meam_inst_kk->h_t_ave(j,0); - buf[m++] = meam_inst_kk->h_t_ave(j,1); - buf[m++] = meam_inst_kk->h_t_ave(j,2); - buf[m++] = meam_inst_kk->h_tsq_ave(j,0); - buf[m++] = meam_inst_kk->h_tsq_ave(j,1); - buf[m++] = meam_inst_kk->h_tsq_ave(j,2); + buf[m++] = static_cast(meam_inst_kk->h_rho0[j]); + buf[m++] = static_cast(meam_inst_kk->h_rho1[j]); + buf[m++] = static_cast(meam_inst_kk->h_rho2[j]); + buf[m++] = static_cast(meam_inst_kk->h_rho3[j]); + buf[m++] = static_cast(meam_inst_kk->h_frhop[j]); + buf[m++] = static_cast(meam_inst_kk->h_gamma[j]); + buf[m++] = static_cast(meam_inst_kk->h_dgamma1[j]); + buf[m++] = static_cast(meam_inst_kk->h_dgamma2[j]); + buf[m++] = static_cast(meam_inst_kk->h_dgamma3[j]); + buf[m++] = static_cast(meam_inst_kk->h_arho2b[j]); + buf[m++] = static_cast(meam_inst_kk->h_arho1(j,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho1(j,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho1(j,2)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(j,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(j,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(j,2)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(j,3)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(j,4)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(j,5)); + for (int k = 0; k < 10; k++) buf[m++] = static_cast(meam_inst_kk->h_arho3(j,k)); + buf[m++] = static_cast(meam_inst_kk->h_arho3b(j,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho3b(j,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho3b(j,2)); + buf[m++] = static_cast(meam_inst_kk->h_t_ave(j,0)); + buf[m++] = static_cast(meam_inst_kk->h_t_ave(j,1)); + buf[m++] = static_cast(meam_inst_kk->h_t_ave(j,2)); + buf[m++] = static_cast(meam_inst_kk->h_tsq_ave(j,0)); + buf[m++] = static_cast(meam_inst_kk->h_tsq_ave(j,1)); + buf[m++] = static_cast(meam_inst_kk->h_tsq_ave(j,2)); if (msmeamflag) { - buf[m++] = meam_inst_kk->h_arho2mb[j]; - buf[m++] = meam_inst_kk->h_arho1m(j,0); - buf[m++] = meam_inst_kk->h_arho1m(j,1); - buf[m++] = meam_inst_kk->h_arho1m(j,2); - buf[m++] = meam_inst_kk->h_arho2m(j,0); - buf[m++] = meam_inst_kk->h_arho2m(j,1); - buf[m++] = meam_inst_kk->h_arho2m(j,2); - buf[m++] = meam_inst_kk->h_arho2m(j,3); - buf[m++] = meam_inst_kk->h_arho2m(j,4); - buf[m++] = meam_inst_kk->h_arho2m(j,5); - for (int k = 0; k < 10; k++) buf[m++] = meam_inst_kk->h_arho3m(j,k); - buf[m++] = meam_inst_kk->h_arho3mb(j,0); - buf[m++] = meam_inst_kk->h_arho3mb(j,1); - buf[m++] = meam_inst_kk->h_arho3mb(j,2); + buf[m++] = static_cast(meam_inst_kk->h_arho2mb[j]); + buf[m++] = static_cast(meam_inst_kk->h_arho1m(j,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho1m(j,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho1m(j,2)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(j,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(j,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(j,2)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(j,3)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(j,4)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(j,5)); + for (int k = 0; k < 10; k++) buf[m++] = static_cast(meam_inst_kk->h_arho3m(j,k)); + buf[m++] = static_cast(meam_inst_kk->h_arho3mb(j,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho3mb(j,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho3mb(j,2)); } } @@ -583,50 +583,50 @@ void PairMEAMKokkos::unpack_forward_comm(int n, int first, double *b int m = 0; const int last = first + n; for (int i = first; i < last; i++) { - meam_inst_kk->h_rho0[i] = buf[m++]; - meam_inst_kk->h_rho1[i] = buf[m++]; - meam_inst_kk->h_rho2[i] = buf[m++]; - meam_inst_kk->h_rho3[i] = buf[m++]; - meam_inst_kk->h_frhop[i] = buf[m++]; - meam_inst_kk->h_gamma[i] = buf[m++]; - meam_inst_kk->h_dgamma1[i] = buf[m++]; - meam_inst_kk->h_dgamma2[i] = buf[m++]; - meam_inst_kk->h_dgamma3[i] = buf[m++]; - meam_inst_kk->h_arho2b[i] = buf[m++]; - meam_inst_kk->h_arho1(i,0) = buf[m++]; - meam_inst_kk->h_arho1(i,1) = buf[m++]; - meam_inst_kk->h_arho1(i,2) = buf[m++]; - meam_inst_kk->h_arho2(i,0) = buf[m++]; - meam_inst_kk->h_arho2(i,1) = buf[m++]; - meam_inst_kk->h_arho2(i,2) = buf[m++]; - meam_inst_kk->h_arho2(i,3) = buf[m++]; - meam_inst_kk->h_arho2(i,4) = buf[m++]; - meam_inst_kk->h_arho2(i,5) = buf[m++]; - for (int k = 0; k < 10; k++) meam_inst_kk->h_arho3(i,k) = buf[m++]; - meam_inst_kk->h_arho3b(i,0) = buf[m++]; - meam_inst_kk->h_arho3b(i,1) = buf[m++]; - meam_inst_kk->h_arho3b(i,2) = buf[m++]; - meam_inst_kk->h_t_ave(i,0) = buf[m++]; - meam_inst_kk->h_t_ave(i,1) = buf[m++]; - meam_inst_kk->h_t_ave(i,2) = buf[m++]; - meam_inst_kk->h_tsq_ave(i,0) = buf[m++]; - meam_inst_kk->h_tsq_ave(i,1) = buf[m++]; - meam_inst_kk->h_tsq_ave(i,2) = buf[m++]; + meam_inst_kk->h_rho0[i] = static_cast(buf[m++]); + meam_inst_kk->h_rho1[i] = static_cast(buf[m++]); + meam_inst_kk->h_rho2[i] = static_cast(buf[m++]); + meam_inst_kk->h_rho3[i] = static_cast(buf[m++]); + meam_inst_kk->h_frhop[i] = static_cast(buf[m++]); + meam_inst_kk->h_gamma[i] = static_cast(buf[m++]); + meam_inst_kk->h_dgamma1[i] = static_cast(buf[m++]); + meam_inst_kk->h_dgamma2[i] = static_cast(buf[m++]); + meam_inst_kk->h_dgamma3[i] = static_cast(buf[m++]); + meam_inst_kk->h_arho2b[i] = static_cast(buf[m++]); + meam_inst_kk->h_arho1(i,0) = static_cast(buf[m++]); + meam_inst_kk->h_arho1(i,1) = static_cast(buf[m++]); + meam_inst_kk->h_arho1(i,2) = static_cast(buf[m++]); + meam_inst_kk->h_arho2(i,0) = static_cast(buf[m++]); + meam_inst_kk->h_arho2(i,1) = static_cast(buf[m++]); + meam_inst_kk->h_arho2(i,2) = static_cast(buf[m++]); + meam_inst_kk->h_arho2(i,3) = static_cast(buf[m++]); + meam_inst_kk->h_arho2(i,4) = static_cast(buf[m++]); + meam_inst_kk->h_arho2(i,5) = static_cast(buf[m++]); + for (int k = 0; k < 10; k++) meam_inst_kk->h_arho3(i,k) = static_cast(buf[m++]); + meam_inst_kk->h_arho3b(i,0) = static_cast(buf[m++]); + meam_inst_kk->h_arho3b(i,1) = static_cast(buf[m++]); + meam_inst_kk->h_arho3b(i,2) = static_cast(buf[m++]); + meam_inst_kk->h_t_ave(i,0) = static_cast(buf[m++]); + meam_inst_kk->h_t_ave(i,1) = static_cast(buf[m++]); + meam_inst_kk->h_t_ave(i,2) = static_cast(buf[m++]); + meam_inst_kk->h_tsq_ave(i,0) = static_cast(buf[m++]); + meam_inst_kk->h_tsq_ave(i,1) = static_cast(buf[m++]); + meam_inst_kk->h_tsq_ave(i,2) = static_cast(buf[m++]); if (msmeamflag) { - meam_inst_kk->h_arho2mb[i] = buf[m++]; - meam_inst_kk->h_arho1m(i,0) = buf[m++]; - meam_inst_kk->h_arho1m(i,1) = buf[m++]; - meam_inst_kk->h_arho1m(i,2) = buf[m++]; - meam_inst_kk->h_arho2m(i,0) = buf[m++]; - meam_inst_kk->h_arho2m(i,1) = buf[m++]; - meam_inst_kk->h_arho2m(i,2) = buf[m++]; - meam_inst_kk->h_arho2m(i,3) = buf[m++]; - meam_inst_kk->h_arho2m(i,4) = buf[m++]; - meam_inst_kk->h_arho2m(i,5) = buf[m++]; - for (int k = 0; k < 10; k++) meam_inst_kk->h_arho3m(i,k) = buf[m++]; - meam_inst_kk->h_arho3mb(i,0) = buf[m++]; - meam_inst_kk->h_arho3mb(i,1) = buf[m++]; - meam_inst_kk->h_arho3mb(i,2) = buf[m++]; + meam_inst_kk->h_arho2mb[i] = static_cast(buf[m++]); + meam_inst_kk->h_arho1m(i,0) = static_cast(buf[m++]); + meam_inst_kk->h_arho1m(i,1) = static_cast(buf[m++]); + meam_inst_kk->h_arho1m(i,2) = static_cast(buf[m++]); + meam_inst_kk->h_arho2m(i,0) = static_cast(buf[m++]); + meam_inst_kk->h_arho2m(i,1) = static_cast(buf[m++]); + meam_inst_kk->h_arho2m(i,2) = static_cast(buf[m++]); + meam_inst_kk->h_arho2m(i,3) = static_cast(buf[m++]); + meam_inst_kk->h_arho2m(i,4) = static_cast(buf[m++]); + meam_inst_kk->h_arho2m(i,5) = static_cast(buf[m++]); + for (int k = 0; k < 10; k++) meam_inst_kk->h_arho3m(i,k) = static_cast(buf[m++]); + meam_inst_kk->h_arho3mb(i,0) = static_cast(buf[m++]); + meam_inst_kk->h_arho3mb(i,1) = static_cast(buf[m++]); + meam_inst_kk->h_arho3mb(i,2) = static_cast(buf[m++]); } } @@ -676,42 +676,42 @@ void PairMEAMKokkos::operator()(TagPairMEAMPackReverseComm, const in //int m = i*30; int m = i*comm_reverse; - v_buf[m++] = d_rho0[i+first]; - v_buf[m++] = d_arho2b[i+first]; - v_buf[m++] = d_arho1(i+first,0); - v_buf[m++] = d_arho1(i+first,1); - v_buf[m++] = d_arho1(i+first,2); - v_buf[m++] = d_arho2(i+first,0); - v_buf[m++] = d_arho2(i+first,1); - v_buf[m++] = d_arho2(i+first,2); - v_buf[m++] = d_arho2(i+first,3); - v_buf[m++] = d_arho2(i+first,4); - v_buf[m++] = d_arho2(i+first,5); - for (int k = 0; k < 10; k++) v_buf[m++] = d_arho3(i+first,k); - v_buf[m++] = d_arho3b(i+first,0); - v_buf[m++] = d_arho3b(i+first,1); - v_buf[m++] = d_arho3b(i+first,2); - v_buf[m++] = d_t_ave(i+first,0); - v_buf[m++] = d_t_ave(i+first,1); - v_buf[m++] = d_t_ave(i+first,2); - v_buf[m++] = d_tsq_ave(i+first,0); - v_buf[m++] = d_tsq_ave(i+first,1); - v_buf[m++] = d_tsq_ave(i+first,2); + v_buf[m++] = static_cast(d_rho0[i+first]); + v_buf[m++] = static_cast(d_arho2b[i+first]); + v_buf[m++] = static_cast(d_arho1(i+first,0)); + v_buf[m++] = static_cast(d_arho1(i+first,1)); + v_buf[m++] = static_cast(d_arho1(i+first,2)); + v_buf[m++] = static_cast(d_arho2(i+first,0)); + v_buf[m++] = static_cast(d_arho2(i+first,1)); + v_buf[m++] = static_cast(d_arho2(i+first,2)); + v_buf[m++] = static_cast(d_arho2(i+first,3)); + v_buf[m++] = static_cast(d_arho2(i+first,4)); + v_buf[m++] = static_cast(d_arho2(i+first,5)); + for (int k = 0; k < 10; k++) v_buf[m++] = static_cast(d_arho3(i+first,k)); + v_buf[m++] = static_cast(d_arho3b(i+first,0)); + v_buf[m++] = static_cast(d_arho3b(i+first,1)); + v_buf[m++] = static_cast(d_arho3b(i+first,2)); + v_buf[m++] = static_cast(d_t_ave(i+first,0)); + v_buf[m++] = static_cast(d_t_ave(i+first,1)); + v_buf[m++] = static_cast(d_t_ave(i+first,2)); + v_buf[m++] = static_cast(d_tsq_ave(i+first,0)); + v_buf[m++] = static_cast(d_tsq_ave(i+first,1)); + v_buf[m++] = static_cast(d_tsq_ave(i+first,2)); if (msmeamflag) { - v_buf[m++] = d_arho2mb[i+first]; - v_buf[m++] = d_arho1m(i+first,0); - v_buf[m++] = d_arho1m(i+first,1); - v_buf[m++] = d_arho1m(i+first,2); - v_buf[m++] = d_arho2m(i+first,0); - v_buf[m++] = d_arho2m(i+first,1); - v_buf[m++] = d_arho2m(i+first,2); - v_buf[m++] = d_arho2m(i+first,3); - v_buf[m++] = d_arho2m(i+first,4); - v_buf[m++] = d_arho2m(i+first,5); - for (int k = 0; k < 10; k++) v_buf[m++] = d_arho3m(i+first,k); - v_buf[m++] = d_arho3mb(i+first,0); - v_buf[m++] = d_arho3mb(i+first,1); - v_buf[m++] = d_arho3mb(i+first,2); + v_buf[m++] = static_cast(d_arho2mb[i+first]); + v_buf[m++] = static_cast(d_arho1m(i+first,0)); + v_buf[m++] = static_cast(d_arho1m(i+first,1)); + v_buf[m++] = static_cast(d_arho1m(i+first,2)); + v_buf[m++] = static_cast(d_arho2m(i+first,0)); + v_buf[m++] = static_cast(d_arho2m(i+first,1)); + v_buf[m++] = static_cast(d_arho2m(i+first,2)); + v_buf[m++] = static_cast(d_arho2m(i+first,3)); + v_buf[m++] = static_cast(d_arho2m(i+first,4)); + v_buf[m++] = static_cast(d_arho2m(i+first,5)); + for (int k = 0; k < 10; k++) v_buf[m++] = static_cast(d_arho3m(i+first,k)); + v_buf[m++] = static_cast(d_arho3mb(i+first,0)); + v_buf[m++] = static_cast(d_arho3mb(i+first,1)); + v_buf[m++] = static_cast(d_arho3mb(i+first,2)); } } @@ -739,42 +739,42 @@ int PairMEAMKokkos::pack_reverse_comm(int n, int first, double *buf) int m = 0; const int last = first + n; for (int i = first; i < last; i++) { - buf[m++] = meam_inst_kk->h_rho0[i]; - buf[m++] = meam_inst_kk->h_arho2b[i]; - buf[m++] = meam_inst_kk->h_arho1(i,0); - buf[m++] = meam_inst_kk->h_arho1(i,1); - buf[m++] = meam_inst_kk->h_arho1(i,2); - buf[m++] = meam_inst_kk->h_arho2(i,0); - buf[m++] = meam_inst_kk->h_arho2(i,1); - buf[m++] = meam_inst_kk->h_arho2(i,2); - buf[m++] = meam_inst_kk->h_arho2(i,3); - buf[m++] = meam_inst_kk->h_arho2(i,4); - buf[m++] = meam_inst_kk->h_arho2(i,5); - for (int k = 0; k < 10; k++) buf[m++] = meam_inst_kk->h_arho3(i,k); - buf[m++] = meam_inst_kk->h_arho3b(i,0); - buf[m++] = meam_inst_kk->h_arho3b(i,1); - buf[m++] = meam_inst_kk->h_arho3b(i,2); - buf[m++] = meam_inst_kk->h_t_ave(i,0); - buf[m++] = meam_inst_kk->h_t_ave(i,1); - buf[m++] = meam_inst_kk->h_t_ave(i,2); - buf[m++] = meam_inst_kk->h_tsq_ave(i,0); - buf[m++] = meam_inst_kk->h_tsq_ave(i,1); - buf[m++] = meam_inst_kk->h_tsq_ave(i,2); + buf[m++] = static_cast(meam_inst_kk->h_rho0[i]); + buf[m++] = static_cast(meam_inst_kk->h_arho2b[i]); + buf[m++] = static_cast(meam_inst_kk->h_arho1(i,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho1(i,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho1(i,2)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(i,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(i,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(i,2)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(i,3)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(i,4)); + buf[m++] = static_cast(meam_inst_kk->h_arho2(i,5)); + for (int k = 0; k < 10; k++) buf[m++] = static_cast(meam_inst_kk->h_arho3(i,k)); + buf[m++] = static_cast(meam_inst_kk->h_arho3b(i,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho3b(i,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho3b(i,2)); + buf[m++] = static_cast(meam_inst_kk->h_t_ave(i,0)); + buf[m++] = static_cast(meam_inst_kk->h_t_ave(i,1)); + buf[m++] = static_cast(meam_inst_kk->h_t_ave(i,2)); + buf[m++] = static_cast(meam_inst_kk->h_tsq_ave(i,0)); + buf[m++] = static_cast(meam_inst_kk->h_tsq_ave(i,1)); + buf[m++] = static_cast(meam_inst_kk->h_tsq_ave(i,2)); if (msmeamflag) { - buf[m++] = meam_inst_kk->h_arho2mb[i]; - buf[m++] = meam_inst_kk->h_arho1m(i,0); - buf[m++] = meam_inst_kk->h_arho1m(i,1); - buf[m++] = meam_inst_kk->h_arho1m(i,2); - buf[m++] = meam_inst_kk->h_arho2m(i,0); - buf[m++] = meam_inst_kk->h_arho2m(i,1); - buf[m++] = meam_inst_kk->h_arho2m(i,2); - buf[m++] = meam_inst_kk->h_arho2m(i,3); - buf[m++] = meam_inst_kk->h_arho2m(i,4); - buf[m++] = meam_inst_kk->h_arho2m(i,5); - for (int k = 0; k < 10; k++) buf[m++] = meam_inst_kk->h_arho3m(i,k); - buf[m++] = meam_inst_kk->h_arho3mb(i,0); - buf[m++] = meam_inst_kk->h_arho3mb(i,1); - buf[m++] = meam_inst_kk->h_arho3mb(i,2); + buf[m++] = static_cast(meam_inst_kk->h_arho2mb[i]); + buf[m++] = static_cast(meam_inst_kk->h_arho1m(i,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho1m(i,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho1m(i,2)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(i,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(i,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(i,2)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(i,3)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(i,4)); + buf[m++] = static_cast(meam_inst_kk->h_arho2m(i,5)); + for (int k = 0; k < 10; k++) buf[m++] = static_cast(meam_inst_kk->h_arho3m(i,k)); + buf[m++] = static_cast(meam_inst_kk->h_arho3mb(i,0)); + buf[m++] = static_cast(meam_inst_kk->h_arho3mb(i,1)); + buf[m++] = static_cast(meam_inst_kk->h_arho3mb(i,2)); } } @@ -801,42 +801,42 @@ void PairMEAMKokkos::operator()(TagPairMEAMUnpackReverseComm, const //int m = i*30; int m = i*comm_reverse; - d_rho0[j] += v_buf[m++]; - d_arho2b[j] += v_buf[m++]; - d_arho1(j,0) += v_buf[m++]; - d_arho1(j,1) += v_buf[m++]; - d_arho1(j,2) += v_buf[m++]; - d_arho2(j,0) += v_buf[m++]; - d_arho2(j,1) += v_buf[m++]; - d_arho2(j,2) += v_buf[m++]; - d_arho2(j,3) += v_buf[m++]; - d_arho2(j,4) += v_buf[m++]; - d_arho2(j,5) += v_buf[m++]; - for (int k = 0; k < 10; k++) d_arho3(j,k) += v_buf[m++]; - d_arho3b(j,0) += v_buf[m++]; - d_arho3b(j,1) += v_buf[m++]; - d_arho3b(j,2) += v_buf[m++]; - d_t_ave(j,0) += v_buf[m++]; - d_t_ave(j,1) += v_buf[m++]; - d_t_ave(j,2) += v_buf[m++]; - d_tsq_ave(j,0) += v_buf[m++]; - d_tsq_ave(j,1) += v_buf[m++]; - d_tsq_ave(j,2) += v_buf[m++]; + d_rho0[j] += static_cast(v_buf[m++]); + d_arho2b[j] += static_cast(v_buf[m++]); + d_arho1(j,0) += static_cast(v_buf[m++]); + d_arho1(j,1) += static_cast(v_buf[m++]); + d_arho1(j,2) += static_cast(v_buf[m++]); + d_arho2(j,0) += static_cast(v_buf[m++]); + d_arho2(j,1) += static_cast(v_buf[m++]); + d_arho2(j,2) += static_cast(v_buf[m++]); + d_arho2(j,3) += static_cast(v_buf[m++]); + d_arho2(j,4) += static_cast(v_buf[m++]); + d_arho2(j,5) += static_cast(v_buf[m++]); + for (int k = 0; k < 10; k++) d_arho3(j,k) += static_cast(v_buf[m++]); + d_arho3b(j,0) += static_cast(v_buf[m++]); + d_arho3b(j,1) += static_cast(v_buf[m++]); + d_arho3b(j,2) += static_cast(v_buf[m++]); + d_t_ave(j,0) += static_cast(v_buf[m++]); + d_t_ave(j,1) += static_cast(v_buf[m++]); + d_t_ave(j,2) += static_cast(v_buf[m++]); + d_tsq_ave(j,0) += static_cast(v_buf[m++]); + d_tsq_ave(j,1) += static_cast(v_buf[m++]); + d_tsq_ave(j,2) += static_cast(v_buf[m++]); if (msmeamflag) { - d_arho2mb[j] += v_buf[m++]; - d_arho1m(j,0) += v_buf[m++]; - d_arho1m(j,1) += v_buf[m++]; - d_arho1m(j,2) += v_buf[m++]; - d_arho2m(j,0) += v_buf[m++]; - d_arho2m(j,1) += v_buf[m++]; - d_arho2m(j,2) += v_buf[m++]; - d_arho2m(j,3) += v_buf[m++]; - d_arho2m(j,4) += v_buf[m++]; - d_arho2m(j,5) += v_buf[m++]; - for (int k = 0; k < 10; k++) d_arho3m(j,k) += v_buf[m++]; - d_arho3mb(j,0) += v_buf[m++]; - d_arho3mb(j,1) += v_buf[m++]; - d_arho3mb(j,2) += v_buf[m++]; + d_arho2mb[j] += static_cast(v_buf[m++]); + d_arho1m(j,0) += static_cast(v_buf[m++]); + d_arho1m(j,1) += static_cast(v_buf[m++]); + d_arho1m(j,2) += static_cast(v_buf[m++]); + d_arho2m(j,0) += static_cast(v_buf[m++]); + d_arho2m(j,1) += static_cast(v_buf[m++]); + d_arho2m(j,2) += static_cast(v_buf[m++]); + d_arho2m(j,3) += static_cast(v_buf[m++]); + d_arho2m(j,4) += static_cast(v_buf[m++]); + d_arho2m(j,5) += static_cast(v_buf[m++]); + for (int k = 0; k < 10; k++) d_arho3m(j,k) += static_cast(v_buf[m++]); + d_arho3mb(j,0) += static_cast(v_buf[m++]); + d_arho3mb(j,1) += static_cast(v_buf[m++]); + d_arho3mb(j,2) += static_cast(v_buf[m++]); } } @@ -864,42 +864,42 @@ void PairMEAMKokkos::unpack_reverse_comm(int n, int *list, double *b int m = 0; for (int i = 0; i < n; i++) { const int j = list[i]; - meam_inst_kk->h_rho0[j] += buf[m++]; - meam_inst_kk->h_arho2b[j] += buf[m++]; - meam_inst_kk->h_arho1(j,0) += buf[m++]; - meam_inst_kk->h_arho1(j,1) += buf[m++]; - meam_inst_kk->h_arho1(j,2) += buf[m++]; - meam_inst_kk->h_arho2(j,0) += buf[m++]; - meam_inst_kk->h_arho2(j,1) += buf[m++]; - meam_inst_kk->h_arho2(j,2) += buf[m++]; - meam_inst_kk->h_arho2(j,3) += buf[m++]; - meam_inst_kk->h_arho2(j,4) += buf[m++]; - meam_inst_kk->h_arho2(j,5) += buf[m++]; - for (int k = 0; k < 10; k++) meam_inst_kk->h_arho3(j,k) += buf[m++]; - meam_inst_kk->h_arho3b(j,0) += buf[m++]; - meam_inst_kk->h_arho3b(j,1) += buf[m++]; - meam_inst_kk->h_arho3b(j,2) += buf[m++]; - meam_inst_kk->h_t_ave(j,0) += buf[m++]; - meam_inst_kk->h_t_ave(j,1) += buf[m++]; - meam_inst_kk->h_t_ave(j,2) += buf[m++]; - meam_inst_kk->h_tsq_ave(j,0) += buf[m++]; - meam_inst_kk->h_tsq_ave(j,1) += buf[m++]; - meam_inst_kk->h_tsq_ave(j,2) += buf[m++]; + meam_inst_kk->h_rho0[j] += static_cast(buf[m++]); + meam_inst_kk->h_arho2b[j] += static_cast(buf[m++]); + meam_inst_kk->h_arho1(j,0) += static_cast(buf[m++]); + meam_inst_kk->h_arho1(j,1) += static_cast(buf[m++]); + meam_inst_kk->h_arho1(j,2) += static_cast(buf[m++]); + meam_inst_kk->h_arho2(j,0) += static_cast(buf[m++]); + meam_inst_kk->h_arho2(j,1) += static_cast(buf[m++]); + meam_inst_kk->h_arho2(j,2) += static_cast(buf[m++]); + meam_inst_kk->h_arho2(j,3) += static_cast(buf[m++]); + meam_inst_kk->h_arho2(j,4) += static_cast(buf[m++]); + meam_inst_kk->h_arho2(j,5) += static_cast(buf[m++]); + for (int k = 0; k < 10; k++) meam_inst_kk->h_arho3(j,k) += static_cast(buf[m++]); + meam_inst_kk->h_arho3b(j,0) += static_cast(buf[m++]); + meam_inst_kk->h_arho3b(j,1) += static_cast(buf[m++]); + meam_inst_kk->h_arho3b(j,2) += static_cast(buf[m++]); + meam_inst_kk->h_t_ave(j,0) += static_cast(buf[m++]); + meam_inst_kk->h_t_ave(j,1) += static_cast(buf[m++]); + meam_inst_kk->h_t_ave(j,2) += static_cast(buf[m++]); + meam_inst_kk->h_tsq_ave(j,0) += static_cast(buf[m++]); + meam_inst_kk->h_tsq_ave(j,1) += static_cast(buf[m++]); + meam_inst_kk->h_tsq_ave(j,2) += static_cast(buf[m++]); if (msmeamflag) { - meam_inst_kk->h_arho2mb[j] += buf[m++]; - meam_inst_kk->h_arho1m(j,0) += buf[m++]; - meam_inst_kk->h_arho1m(j,1) += buf[m++]; - meam_inst_kk->h_arho1m(j,2) += buf[m++]; - meam_inst_kk->h_arho2m(j,0) += buf[m++]; - meam_inst_kk->h_arho2m(j,1) += buf[m++]; - meam_inst_kk->h_arho2m(j,2) += buf[m++]; - meam_inst_kk->h_arho2m(j,3) += buf[m++]; - meam_inst_kk->h_arho2m(j,4) += buf[m++]; - meam_inst_kk->h_arho2m(j,5) += buf[m++]; - for (int k = 0; k < 10; k++) meam_inst_kk->h_arho3m(j,k) += buf[m++]; - meam_inst_kk->h_arho3mb(j,0) += buf[m++]; - meam_inst_kk->h_arho3mb(j,1) += buf[m++]; - meam_inst_kk->h_arho3mb(j,2) += buf[m++]; + meam_inst_kk->h_arho2mb[j] += static_cast(buf[m++]); + meam_inst_kk->h_arho1m(j,0) += static_cast(buf[m++]); + meam_inst_kk->h_arho1m(j,1) += static_cast(buf[m++]); + meam_inst_kk->h_arho1m(j,2) += static_cast(buf[m++]); + meam_inst_kk->h_arho2m(j,0) += static_cast(buf[m++]); + meam_inst_kk->h_arho2m(j,1) += static_cast(buf[m++]); + meam_inst_kk->h_arho2m(j,2) += static_cast(buf[m++]); + meam_inst_kk->h_arho2m(j,3) += static_cast(buf[m++]); + meam_inst_kk->h_arho2m(j,4) += static_cast(buf[m++]); + meam_inst_kk->h_arho2m(j,5) += static_cast(buf[m++]); + for (int k = 0; k < 10; k++) meam_inst_kk->h_arho3m(j,k) += static_cast(buf[m++]); + meam_inst_kk->h_arho3mb(j,0) += static_cast(buf[m++]); + meam_inst_kk->h_arho3mb(j,1) += static_cast(buf[m++]); + meam_inst_kk->h_arho3mb(j,2) += static_cast(buf[m++]); } } diff --git a/src/KOKKOS/pair_mm3_switch3_coulgauss_long_kokkos.cpp b/src/KOKKOS/pair_mm3_switch3_coulgauss_long_kokkos.cpp index 2cc52627b40..fc12e1fecc0 100644 --- a/src/KOKKOS/pair_mm3_switch3_coulgauss_long_kokkos.cpp +++ b/src/KOKKOS/pair_mm3_switch3_coulgauss_long_kokkos.cpp @@ -127,16 +127,16 @@ void PairMM3Switch3CoulGaussLongKokkos::compute(int eflag_in, int vf (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -387,9 +387,9 @@ double PairMM3Switch3CoulGaussLongKokkos::init_one(int i, int j) k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_morse_kokkos.cpp b/src/KOKKOS/pair_morse_kokkos.cpp index 666c3cbea6f..498b941e0da 100644 --- a/src/KOKKOS/pair_morse_kokkos.cpp +++ b/src/KOKKOS/pair_morse_kokkos.cpp @@ -104,23 +104,23 @@ void PairMorseKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms EV_FLOAT ev = pair_compute,void >(this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -142,7 +142,7 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairMorseKokkos:: compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT rr = sqrt(rsq); + const KK_FLOAT rr = Kokkos::sqrt(rsq); const KK_FLOAT r0 = STACKPARAMS ? m_params[itype][jtype].r0 : params(itype,jtype).r0; const KK_FLOAT d0 = STACKPARAMS ? m_params[itype][jtype].d0 : params(itype,jtype).d0; const KK_FLOAT aa = STACKPARAMS ? m_params[itype][jtype].alpha : params(itype,jtype).alpha; @@ -151,8 +151,8 @@ compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c // U = d0 * [ exp( -2*a*(x-r0)) - 2*exp(-a*(x-r0)) ] // f = -2*a*d0*[ -exp( -2*a*(x-r0) ) + exp( -a*(x-r0) ) ] * grad(r) // = +2*a*d0*[ exp( -2*a*(x-r0) ) - exp( -a*(x-r0) ) ] * grad(r) - const KK_FLOAT dexp = exp( -aa*dr ); - const KK_FLOAT forcelj = 2*aa*d0*dexp*(dexp-1.0); + const KK_FLOAT dexp = Kokkos::exp( -aa*dr ); + const KK_FLOAT forcelj = 2*aa*d0*dexp*(dexp-static_cast(1.0)); return forcelj / rr; } @@ -163,7 +163,7 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairMorseKokkos:: compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT rr = sqrt(rsq); + const KK_FLOAT rr = Kokkos::sqrt(rsq); const KK_FLOAT r0 = STACKPARAMS ? m_params[itype][jtype].r0 : params(itype,jtype).r0; const KK_FLOAT d0 = STACKPARAMS ? m_params[itype][jtype].d0 : params(itype,jtype).d0; const KK_FLOAT aa = STACKPARAMS ? m_params[itype][jtype].alpha : params(itype,jtype).alpha; @@ -172,9 +172,9 @@ compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c // U = d0 * [ exp( -2*a*(x-r0)) - 2*exp(-a*(x-r0)) ] // f = -2*a*d0*[ -exp( -2*a*(x-r0) ) + exp( -a*(x-r0) ) ] * grad(r) // = +2*a*d0*[ exp( -2*a*(x-r0) ) - exp( -a*(x-r0) ) ] * grad(r) - const KK_FLOAT dexp = exp( -aa*dr ); + const KK_FLOAT dexp = Kokkos::exp( -aa*dr ); - return d0 * dexp * ( dexp - 2.0 ); + return d0 * dexp * ( dexp - static_cast(2.0) ); } /* ---------------------------------------------------------------------- @@ -232,16 +232,16 @@ double PairMorseKokkos::init_one(int i, int j) { double cutone = PairMorse::init_one(i,j); - k_params.view_host()(i,j).d0 = d0[i][j]; - k_params.view_host()(i,j).alpha = alpha[i][j]; - k_params.view_host()(i,j).r0 = r0[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).d0 = static_cast(d0[i][j]); + k_params.view_host()(i,j).alpha = static_cast(alpha[i][j]); + k_params.view_host()(i,j).r0 = static_cast(r0[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index 600158abfb6..8d38bcee7b1 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -247,14 +247,14 @@ void PairMultiLucyRXKokkos::compute_style(int eflag_in, int vflag_in else if (k_error_flag.view_host()() == 3) error->one(FLERR,"Only LOOKUP and LINEAR table styles have been implemented for pair multi/lucy/rx"); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -335,33 +335,33 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXComputeinnersq || rho[j]*rho[j] < tb->innersq) { - if (rho[i]*rho[i] < d_table_const.innersq(tidx) || rho[j]*rho[j] < d_table_const.innersq(tidx)) { + if (rho[i]*rho[i] < static_cast(d_table_const.innersq(tidx)) || rho[j]*rho[j] < static_cast(d_table_const.innersq(tidx))) { k_error_flag.template view()() = 1; } if (TABSTYLE == LOOKUP) { //itable = static_cast (((rho[i]*rho[i]) - tb->innersq) * tb->invdelta); - itable = static_cast (((rho[i]*rho[i]) - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + itable = static_cast (((rho[i]*rho[i]) - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); //jtable = static_cast (((rho[j]*rho[j]) - tb->innersq) * tb->invdelta); - jtable = static_cast (((rho[j]*rho[j]) - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + jtable = static_cast (((rho[j]*rho[j]) - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); if (itable >= tlm1 || jtable >= tlm1) { k_error_flag.template view()() = 2; } //A_i = tb->f[itable]; - A_i = d_table_const.f(tidx,itable); + A_i = static_cast(d_table_const.f(tidx,itable)); //A_j = tb->f[jtable]; - A_j = d_table_const.f(tidx,jtable); + A_j = static_cast(d_table_const.f(tidx,jtable)); - const KK_FLOAT rfactor = 1.0-sqrt(rsq/d_cutsq(itype,jtype)); - fpair = 0.5*(A_i + A_j)*(4.0-3.0*rfactor)*rfactor*rfactor*rfactor; - fpair /= sqrt(rsq); + const KK_FLOAT rfactor = static_cast(1.0)-Kokkos::sqrt(rsq/d_cutsq(itype,jtype)); + fpair = static_cast(0.5)*(A_i + A_j)*(static_cast(4.0)-static_cast(3.0)*rfactor)*rfactor*rfactor*rfactor; + fpair /= Kokkos::sqrt(rsq); } else if (TABSTYLE == LINEAR) { //itable = static_cast ((rho[i]*rho[i] - tb->innersq) * tb->invdelta); - itable = static_cast ((rho[i]*rho[i] - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + itable = static_cast ((rho[i]*rho[i] - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); //jtable = static_cast (((rho[j]*rho[j]) - tb->innersq) * tb->invdelta); - jtable = static_cast ((rho[j]*rho[j] - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + jtable = static_cast ((rho[j]*rho[j] - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); if (itable >= tlm1 || jtable >= tlm1) { k_error_flag.template view()() = 2; } @@ -371,64 +371,64 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXCompute=tlm1)jtable=tlm1; //fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); - fraction_i = (((rho[i]*rho[i]) - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx)); + fraction_i = (((rho[i]*rho[i]) - static_cast(d_table_const.rsq(tidx,itable))) * static_cast(d_table_const.invdelta(tidx))); //fraction_j = (((rho[j]*rho[j]) - tb->rsq[jtable]) * tb->invdelta); - fraction_j = (((rho[j]*rho[j]) - d_table_const.rsq(tidx,jtable)) * d_table_const.invdelta(tidx)); + fraction_j = (((rho[j]*rho[j]) - static_cast(d_table_const.rsq(tidx,jtable))) * static_cast(d_table_const.invdelta(tidx))); if (itable==0) fraction_i=0.0; if (itable==tlm1) fraction_i=0.0; if (jtable==0) fraction_j=0.0; if (jtable==tlm1) fraction_j=0.0; //A_i = tb->f[itable] + fraction_i*tb->df[itable]; - A_i = d_table_const.f(tidx,itable) + fraction_i*d_table_const.df(tidx,itable); + A_i = static_cast(d_table_const.f(tidx,itable)) + fraction_i*static_cast(d_table_const.df(tidx,itable)); //A_j = tb->f[jtable] + fraction_j*tb->df[jtable]; - A_j = d_table_const.f(tidx,jtable) + fraction_j*d_table_const.df(tidx,jtable); + A_j = static_cast(d_table_const.f(tidx,jtable)) + fraction_j*static_cast(d_table_const.df(tidx,jtable)); - const KK_FLOAT rfactor = 1.0-sqrt(rsq/d_cutsq(itype,jtype)); - fpair = 0.5*(A_i + A_j)*(4.0-3.0*rfactor)*rfactor*rfactor*rfactor; - fpair /= sqrt(rsq); + const KK_FLOAT rfactor = static_cast(1.0)-Kokkos::sqrt(rsq/d_cutsq(itype,jtype)); + fpair = static_cast(0.5)*(A_i + A_j)*(static_cast(4.0)-static_cast(3.0)*rfactor)*rfactor*rfactor*rfactor; + fpair /= Kokkos::sqrt(rsq); } else k_error_flag.template view()() = 3; - if (isite1 == isite2) fpair = sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpair; - else fpair = (sqrt(mixWtSite1old_i*mixWtSite2old_j) + sqrt(mixWtSite2old_i*mixWtSite1old_j))*fpair; + if (isite1 == isite2) fpair = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*fpair; + else fpair = (Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j) + Kokkos::sqrt(mixWtSite2old_i*mixWtSite1old_j))*fpair; fx_i += delx*fpair; fy_i += dely*fpair; fz_i += delz*fpair; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - a_f(j,0) -= delx*fpair; - a_f(j,1) -= dely*fpair; - a_f(j,2) -= delz*fpair; + a_f(j,0) -= static_cast(delx*fpair); + a_f(j,1) -= static_cast(dely*fpair); + a_f(j,2) -= static_cast(delz*fpair); } //if (evflag) ev_tally(i,j,nlocal,newton_pair,0.0,0.0,fpair,delx,dely,delz); if (EVFLAG) this->template ev_tally(ev,i,j,0.0,fpair,delx,dely,delz); } } - a_f(i,0) += fx_i; - a_f(i,1) += fy_i; - a_f(i,2) += fz_i; + a_f(i,0) += static_cast(fx_i); + a_f(i,1) += static_cast(fy_i); + a_f(i,2) += static_cast(fz_i); //tb = &tables[tabindex[itype][itype]]; const int tidx = d_table_const.tabindex(itype,itype); //itable = static_cast (((rho[i]*rho[i]) - tb->innersq) * tb->invdelta); - itable = static_cast (((rho[i]*rho[i]) - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + itable = static_cast (((rho[i]*rho[i]) - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); //if (TABSTYLE == LOOKUP) evdwl = tb->e[itable]; if (TABSTYLE == LOOKUP) { - evdwl = d_table_const.e(tidx,itable); + evdwl = static_cast(d_table_const.e(tidx,itable)); } else if (TABSTYLE == LINEAR) { if (itable >= tlm1) { k_error_flag.template view()() = 2; } if (itable==0) fraction_i=0.0; //else fraction_i = (((rho[i]*rho[i]) - tb->rsq[itable]) * tb->invdelta); - else fraction_i = (((rho[i]*rho[i]) - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx)); + else fraction_i = (((rho[i]*rho[i]) - static_cast(d_table_const.rsq(tidx,itable))) * static_cast(d_table_const.invdelta(tidx))); //evdwl = tb->e[itable] + fraction_i*tb->de[itable]; - evdwl = d_table_const.e(tidx,itable) + fraction_i*d_table_const.de(tidx,itable); + evdwl = static_cast(d_table_const.e(tidx,itable)) + fraction_i*static_cast(d_table_const.de(tidx,itable)); } else k_error_flag.template view()() = 3; - evdwl *=(MY_PI*d_cutsq(itype,itype)*d_cutsq(itype,itype))/84.0; + evdwl *=(static_cast(MY_PI)*d_cutsq(itype,itype)*d_cutsq(itype,itype))/static_cast(84.0); evdwlOld = mixWtSite1old_i*evdwl; evdwl = mixWtSite1_i*evdwl; @@ -439,7 +439,7 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXCompute(1.0):static_cast(0.5))*static_cast(evdwl); } template @@ -570,21 +570,24 @@ void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXComputeLoca const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; if (ONE_TYPE) { - if (rsq < cutsq_type11) { - const KK_FLOAT rcut = rcut_type11; - const KK_FLOAT r_over_rcut = sqrt(rsq) / rcut; - const KK_FLOAT tmpFactor = 1.0 - r_over_rcut; + const KK_FLOAT cutsq_type11_kk = static_cast(cutsq_type11); + const KK_FLOAT rcut_type11_kk = static_cast(rcut_type11); + const KK_FLOAT factor_type11_kk = static_cast(factor_type11); + if (rsq < cutsq_type11_kk) { + const KK_FLOAT rcut = rcut_type11_kk; + const KK_FLOAT r_over_rcut = Kokkos::sqrt(rsq) / rcut; + const KK_FLOAT tmpFactor = static_cast(1.0) - r_over_rcut; const KK_FLOAT tmpFactor4 = tmpFactor*tmpFactor*tmpFactor*tmpFactor; - const KK_FLOAT factor = factor_type11*(1.0 + 1.5*r_over_rcut)*tmpFactor4; + const KK_FLOAT factor = factor_type11_kk*(static_cast(1.0) + static_cast(1.5)*r_over_rcut)*tmpFactor4; rho_i_contrib += factor; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) a_rho[j] += factor; } } else if (rsq < d_cutsq(itype,jtype)) { - const KK_FLOAT rcut = sqrt(d_cutsq(itype,jtype)); - const KK_FLOAT tmpFactor = 1.0-sqrt(rsq)/rcut; + const KK_FLOAT rcut = Kokkos::sqrt(d_cutsq(itype,jtype)); + const KK_FLOAT tmpFactor = static_cast(1.0)-Kokkos::sqrt(rsq)/rcut; const KK_FLOAT tmpFactor4 = tmpFactor*tmpFactor*tmpFactor*tmpFactor; - const KK_FLOAT factor = (84.0/(5.0*MY_PI*rcut*rcut*rcut))*(1.0+3.0*sqrt(rsq)/(2.0*rcut))*tmpFactor4; + const KK_FLOAT factor = (static_cast(84.0)/(static_cast(5.0)*static_cast(MY_PI)*rcut*rcut*rcut))*(static_cast(1.0)+static_cast(3.0)*Kokkos::sqrt(rsq)/(static_cast(2.0)*rcut))*tmpFactor4; rho_i_contrib += factor; if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) a_rho[j] += factor; @@ -619,7 +622,7 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, KK_FLOAT &mixWt nTotal += dvector(atom_ind,id); nTotalOld += dvector(atom_ind_old,id); } - if (nTotal < MY_EPSILON || nTotalOld < MY_EPSILON) + if (nTotal < static_cast(MY_EPSILON) || nTotalOld < static_cast(MY_EPSILON)) Kokkos::abort("The number of molecules in CG particle is less than 10*DBL_EPSILON."); if (isOneFluid(isite1) == false) { @@ -659,14 +662,14 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, KK_FLOAT &mixWt fractionOFA += dvector(atom_ind,id) / nTotal; } if (isOneFluid(isite1)) { - nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); - nMolecules1 = 1.0-(nTotal-nMoleculesOFA); + nMoleculesOld1 = static_cast(1.0)-(nTotalOld-nMoleculesOFAold); + nMolecules1 = static_cast(1.0)-(nTotal-nMoleculesOFA); fractionOld1 = fractionOFAold; fraction1 = fractionOFA; } if (isOneFluid(isite2)) { - nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); - nMolecules2 = 1.0-(nTotal-nMoleculesOFA); + nMoleculesOld2 = static_cast(1.0)-(nTotalOld-nMoleculesOFAold); + nMolecules2 = static_cast(1.0)-(nTotal-nMoleculesOFA); fractionOld2 = fractionOFAold; fraction2 = fractionOFA; } @@ -703,7 +706,7 @@ template KOKKOS_INLINE_FUNCTION void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXPackForwardComm, const int &i) const { int j = d_sendlist(i); - v_buf[i] = rho[j]; + v_buf[i] = static_cast(rho[j]); } /* ---------------------------------------------------------------------- */ @@ -722,7 +725,7 @@ template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXUnpackForwardComm, const int &i) const { - rho[i + first] = v_buf[i]; + rho[i + first] = static_cast(v_buf[i]); } /* ---------------------------------------------------------------------- */ @@ -811,12 +814,12 @@ void PairMultiLucyRXKokkos::ev_tally(EV_FLOAT &ev, const int &i, con if (EFLAG) { if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; if (NEIGHFLAG!=FULL) { - if (NEWTON_PAIR || i < nlocal) v_eatom[i] += epairhalf; - if (NEWTON_PAIR || j < nlocal) v_eatom[j] += epairhalf; + if (NEWTON_PAIR || i < nlocal) v_eatom[i] += static_cast(epairhalf); + if (NEWTON_PAIR || j < nlocal) v_eatom[j] += static_cast(epairhalf); } else { - v_eatom[i] += epairhalf; + v_eatom[i] += static_cast(epairhalf); } } } @@ -832,56 +835,56 @@ void PairMultiLucyRXKokkos::ev_tally(EV_FLOAT &ev, const int &i, con if (vflag_global) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } if (NEWTON_PAIR || j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } if (vflag_atom) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*static_cast(v0); + v_vatom(i,1) += static_cast(0.5)*static_cast(v1); + v_vatom(i,2) += static_cast(0.5)*static_cast(v2); + v_vatom(i,3) += static_cast(0.5)*static_cast(v3); + v_vatom(i,4) += static_cast(0.5)*static_cast(v4); + v_vatom(i,5) += static_cast(0.5)*static_cast(v5); } if (NEWTON_PAIR || j < nlocal) { - v_vatom(j,0) += 0.5*v0; - v_vatom(j,1) += 0.5*v1; - v_vatom(j,2) += 0.5*v2; - v_vatom(j,3) += 0.5*v3; - v_vatom(j,4) += 0.5*v4; - v_vatom(j,5) += 0.5*v5; + v_vatom(j,0) += static_cast(0.5)*static_cast(v0); + v_vatom(j,1) += static_cast(0.5)*static_cast(v1); + v_vatom(j,2) += static_cast(0.5)*static_cast(v2); + v_vatom(j,3) += static_cast(0.5)*static_cast(v3); + v_vatom(j,4) += static_cast(0.5)*static_cast(v4); + v_vatom(j,5) += static_cast(0.5)*static_cast(v5); } } else { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*static_cast(v0); + v_vatom(i,1) += static_cast(0.5)*static_cast(v1); + v_vatom(i,2) += static_cast(0.5)*static_cast(v2); + v_vatom(i,3) += static_cast(0.5)*static_cast(v3); + v_vatom(i,4) += static_cast(0.5)*static_cast(v4); + v_vatom(i,5) += static_cast(0.5)*static_cast(v5); } } } diff --git a/src/KOKKOS/pair_nm_cut_coul_cut_kokkos.cpp b/src/KOKKOS/pair_nm_cut_coul_cut_kokkos.cpp index 9e7d0e998d8..88b62226f4e 100644 --- a/src/KOKKOS/pair_nm_cut_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_nm_cut_coul_cut_kokkos.cpp @@ -97,15 +97,15 @@ void PairNMCutCoulCutKokkos::compute(int eflag_in, int vflag_in) type = atomKK->k_type.view(); nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; - special_coul[0] = force->special_coul[0]; - special_coul[1] = force->special_coul[1]; - special_coul[2] = force->special_coul[2]; - special_coul[3] = force->special_coul[3]; - qqrd2e = force->qqrd2e; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); + special_coul[0] = static_cast(force->special_coul[0]); + special_coul[1] = static_cast(force->special_coul[1]); + special_coul[2] = static_cast(force->special_coul[2]); + special_coul[3] = static_cast(force->special_coul[3]); + qqrd2e = static_cast(force->qqrd2e); newton_pair = force->newton_pair; EV_FLOAT ev; @@ -116,16 +116,16 @@ void PairNMCutCoulCutKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -182,7 +182,7 @@ compute_fcoul(const KK_FLOAT& rsq, const int& /*i*/, const int& j, const int& /*itype*/, const int& /*jtype*/, const KK_FLOAT& factor_coul, const KK_FLOAT& qtmp) const { - const KK_FLOAT r2inv = 1.0/rsq; + const KK_FLOAT r2inv = static_cast(1.0)/rsq; const KK_FLOAT rinv = Kokkos::sqrt(r2inv); return factor_coul * qqrd2e * qtmp * q(j) * rinv * r2inv; } @@ -305,9 +305,9 @@ double PairNMCutCoulCutKokkos::init_one(int i, int j) k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsqm); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_nm_cut_coul_long_kokkos.cpp b/src/KOKKOS/pair_nm_cut_coul_long_kokkos.cpp index d5c9d52706b..b9c8ab50a1e 100644 --- a/src/KOKKOS/pair_nm_cut_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_nm_cut_coul_long_kokkos.cpp @@ -125,16 +125,16 @@ void PairNMCutCoulLongKokkos::compute(int eflag_in, int vflag_in) (this,(NeighListKokkos*)list); if (eflag) { - eng_vdwl += ev.evdwl; - eng_coul += ev.ecoul; + eng_vdwl += static_cast(ev.evdwl); + eng_coul += static_cast(ev.ecoul); } if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -335,9 +335,9 @@ double PairNMCutCoulLongKokkos::init_one(int i, int j) k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); + m_cut_ljsq[j][i] = m_cut_ljsq[i][j] = static_cast(cut_ljsqm); + m_cut_coulsq[j][i] = m_cut_coulsq[i][j] = static_cast(cut_coulsq); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_pod_kokkos.cpp b/src/KOKKOS/pair_pod_kokkos.cpp index 86ac1c0bb44..ec207c18416 100644 --- a/src/KOKKOS/pair_pod_kokkos.cpp +++ b/src/KOKKOS/pair_pod_kokkos.cpp @@ -117,7 +117,7 @@ double PairPODKokkos::init_one(int i, int j) { double cutone = PairPOD::init_one(i,j); - k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; + k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = static_cast(cutone*cutone); k_cutsq.modify_host(); return cutone; @@ -363,9 +363,9 @@ void PairPODKokkos::copy_from_pod_class(EAPOD *podptr) MemKK::realloc_kokkos(besselparams, "pair_pod:besselparams", 3); auto h_besselparams = Kokkos::create_mirror_view(besselparams); - h_besselparams[0] = podptr->besselparams[0]; - h_besselparams[1] = podptr->besselparams[1]; - h_besselparams[2] = podptr->besselparams[2]; + h_besselparams[0] = static_cast(podptr->besselparams[0]); + h_besselparams[1] = static_cast(podptr->besselparams[1]); + h_besselparams[2] = static_cast(podptr->besselparams[2]); Kokkos::deep_copy(besselparams, h_besselparams); MemKK::realloc_kokkos(elemindex, "pair_pod:elemindex", nelements*nelements); @@ -375,23 +375,23 @@ void PairPODKokkos::copy_from_pod_class(EAPOD *podptr) MemKK::realloc_kokkos(Phi, "pair_pod:Phi", ns*ns); auto h_Phi = Kokkos::create_mirror_view(Phi); - for (int i=0; iPhi[i]; + for (int i=0; i(podptr->Phi[i]); Kokkos::deep_copy(Phi, h_Phi); MemKK::realloc_kokkos(coefficients, "pair_pod:coefficients", nCoeffPerElement * nelements); auto h_coefficients = Kokkos::create_mirror_view(coefficients); - for (int i=0; icoeff[i]; + for (int i=0; i(podptr->coeff[i]); Kokkos::deep_copy(coefficients, h_coefficients); if (nClusters > 1) { MemKK::realloc_kokkos(Proj, "pair_pod:Proj", Mdesc * nComponents * nelements); auto h_Proj = Kokkos::create_mirror_view(Proj); - for (int i=0; iProj[i]; + for (int i=0; i(podptr->Proj[i]); Kokkos::deep_copy(Proj, h_Proj); MemKK::realloc_kokkos(Centroids, "pair_pod:Centroids", nClusters * nComponents * nelements); auto h_Centroids = Kokkos::create_mirror_view(Centroids); - for (int i=0; iCentroids[i]; + for (int i=0; i(podptr->Centroids[i]); Kokkos::deep_copy(Centroids, h_Centroids); } @@ -538,18 +538,18 @@ int PairPODKokkos::NeighborCount(t_pod_1i l_numij, double l_rcutsq, Kokkos::parallel_for("NeighborCount", typename Kokkos::TeamPolicy(Ni, Kokkos::AUTO), KOKKOS_LAMBDA(const typename Kokkos::TeamPolicy::member_type& team) { int i = team.league_rank(); int gi = l_ilist(gi1 + i); - double xi0 = l_x(gi, 0); - double xi1 = l_x(gi, 1); - double xi2 = l_x(gi, 2); + double xi0 = static_cast(l_x(gi, 0)); + double xi1 = static_cast(l_x(gi, 1)); + double xi2 = static_cast(l_x(gi, 2)); int jnum = l_numneigh(gi); int ncount = 0; Kokkos::parallel_reduce(Kokkos::TeamThreadRange(team,jnum), [&] (const int jj, int& count) { int j = l_neighbors(gi,jj); j &= NEIGHMASK; - double delx = xi0 - l_x(j,0); - double dely = xi1 - l_x(j,1); - double delz = xi2 - l_x(j,2); + double delx = xi0 - static_cast(l_x(j,0)); + double dely = xi1 - static_cast(l_x(j,1)); + double delz = xi2 - static_cast(l_x(j,2)); double rsq = delx*delx + dely*dely + delz*delz; if (rsq < l_rcutsq) count++; },ncount); @@ -588,9 +588,9 @@ void PairPODKokkos::NeighborList(t_pod_1d l_rij, t_pod_1i l_numij, Kokkos::parallel_for("NeighborList", typename Kokkos::TeamPolicy(Ni, Kokkos::AUTO), KOKKOS_LAMBDA(const typename Kokkos::TeamPolicy::member_type& team) { int i = team.league_rank(); int gi = l_ilist(gi1 + i); - double xi0 = l_x(gi, 0); - double xi1 = l_x(gi, 1); - double xi2 = l_x(gi, 2); + double xi0 = static_cast(l_x(gi, 0)); + double xi1 = static_cast(l_x(gi, 1)); + double xi2 = static_cast(l_x(gi, 2)); int itype = l_map(l_type(gi)) + 1; //map[atomtypes[gi]] + 1; l_typeai(i) = itype; int jnum = l_numneigh(gi); @@ -599,16 +599,16 @@ void PairPODKokkos::NeighborList(t_pod_1d l_rij, t_pod_1i l_numij, [&] (const int jj, int& offset, bool final) { int gj = l_neighbors(gi,jj); gj &= NEIGHMASK; - double delx = l_x(gj,0) - xi0; - double dely = l_x(gj,1) - xi1; - double delz = l_x(gj,2) - xi2; + double delx = static_cast(l_x(gj,0)) - xi0; + double dely = static_cast(l_x(gj,1)) - xi1; + double delz = static_cast(l_x(gj,2)) - xi2; double rsq = delx*delx + dely*dely + delz*delz; if (rsq >= l_rcutsq) return; if (final) { int nij1 = nij0 + offset; - l_rij(nij1 * 3 + 0) = delx; - l_rij(nij1 * 3 + 1) = dely; - l_rij(nij1 * 3 + 2) = delz; + l_rij(nij1 * 3 + 0) = static_cast(delx); + l_rij(nij1 * 3 + 1) = static_cast(dely); + l_rij(nij1 * 3 + 2) = static_cast(delz); l_idxi(nij1) = i; l_ai(nij1) = gi; l_aj(nij1) = gj; @@ -626,9 +626,9 @@ void PairPODKokkos::radialbasis(t_pod_1d rbft, t_pod_1d rbftx, t_pod int l_inversedegree, int l_nbesselpars, int Nij) { Kokkos::parallel_for("ComputeRadialBasis", Kokkos::RangePolicy(0,Nij), KOKKOS_LAMBDA(int n) { - double xij1 = l_rij(0+3*n); - double xij2 = l_rij(1+3*n); - double xij3 = l_rij(2+3*n); + double xij1 = static_cast(l_rij(0+3*n)); + double xij2 = static_cast(l_rij(1+3*n)); + double xij3 = static_cast(l_rij(2+3*n)); double dij = sqrt(xij1*xij1 + xij2*xij2 + xij3*xij3); double dr1 = xij1/dij; @@ -656,19 +656,19 @@ void PairPODKokkos::radialbasis(t_pod_1d rbft, t_pod_1d rbftx, t_pod double f2 = f1/r; double df1 = dfcut/r; - double alpha = l_besselparams(0); + double alpha = static_cast(l_besselparams(0)); double t1 = (1.0-exp(-alpha)); double t2 = exp(-alpha*r/l_rmax); double x0 = (1.0 - t2)/t1; double dx0 = (alpha/l_rmax)*t2/t1; - alpha = l_besselparams(1); + alpha = static_cast(l_besselparams(1)); t1 = (1.0-exp(-alpha)); t2 = exp(-alpha*r/l_rmax); double x1 = (1.0 - t2)/t1; double dx1 = (alpha/l_rmax)*t2/t1; - alpha = l_besselparams(2); + alpha = static_cast(l_besselparams(2)); t1 = (1.0-exp(-alpha)); t2 = exp(-alpha*r/l_rmax); double x2 = (1.0 - t2)/t1; @@ -681,27 +681,27 @@ void PairPODKokkos::radialbasis(t_pod_1d rbft, t_pod_1d rbftx, t_pod double sinax = sin(a*x0); int idxni = n + Nij*i; - rbft(idxni) = b*f1*sinax; + rbft(idxni) = static_cast(b*f1*sinax); double drbftdr = b*(df1*sinax - f2*sinax + af1*cos(a*x0)*dx0); - rbftx(idxni) = drbftdr*dr1; - rbfty(idxni) = drbftdr*dr2; - rbftz(idxni) = drbftdr*dr3; + rbftx(idxni) = static_cast(drbftdr*dr1); + rbfty(idxni) = static_cast(drbftdr*dr2); + rbftz(idxni) = static_cast(drbftdr*dr3); sinax = sin(a*x1); idxni = n + Nij*i + Nij*l_besseldegree*1; - rbft(idxni) = b*f1*sinax; + rbft(idxni) = static_cast(b*f1*sinax); drbftdr = b*(df1*sinax - f2*sinax + af1*cos(a*x1)*dx1); - rbftx(idxni) = drbftdr*dr1; - rbfty(idxni) = drbftdr*dr2; - rbftz(idxni) = drbftdr*dr3; + rbftx(idxni) = static_cast(drbftdr*dr1); + rbfty(idxni) = static_cast(drbftdr*dr2); + rbftz(idxni) = static_cast(drbftdr*dr3); sinax = sin(a*x2); idxni = n + Nij*i + Nij*l_besseldegree*2; - rbft(idxni) = b*f1*sinax; + rbft(idxni) = static_cast(b*f1*sinax); drbftdr = b*(df1*sinax - f2*sinax + af1*cos(a*x2)*dx2); - rbftx(idxni) = drbftdr*dr1; - rbfty(idxni) = drbftdr*dr2; - rbftz(idxni) = drbftdr*dr3; + rbftx(idxni) = static_cast(drbftdr*dr1); + rbfty(idxni) = static_cast(drbftdr*dr2); + rbftz(idxni) = static_cast(drbftdr*dr3); } // Calculate fcut/dij and dfcut/dij @@ -712,12 +712,12 @@ void PairPODKokkos::radialbasis(t_pod_1d rbft, t_pod_1d rbftx, t_pod int idxni = n + Nij*p; a = a*dij; - rbft(idxni) = fcut/a; + rbft(idxni) = static_cast(fcut/a); double drbftdr = (dfcut - (i+1.0)*f1)/a; - rbftx(idxni) = drbftdr*dr1; - rbfty(idxni) = drbftdr*dr2; - rbftz(idxni) = drbftdr*dr3; + rbftx(idxni) = static_cast(drbftdr*dr1); + rbfty(idxni) = static_cast(drbftdr*dr2); + rbftz(idxni) = static_cast(drbftdr*dr3); } }); } @@ -730,9 +730,9 @@ void PairPODKokkos::matrixMultiply(t_pod_1d a, t_pod_1d b, t_pod_1d int i = idx % r1; // Calculate row index double sum = 0.0; for (int k = 0; k < c1; ++k) { - sum += a(i + r1*k) * b(k + c1*j); // Manually calculate the 1D index + sum += static_cast(a(i + r1*k) * b(k + c1*j)); // Manually calculate the 1D index } - c(i + r1*j) = sum; // Manually calculate the 1D index for c + c(i + r1*j) = static_cast(sum); // Manually calculate the 1D index for c }); } @@ -741,9 +741,9 @@ void PairPODKokkos::angularbasis(t_pod_1d l_abf, t_pod_1d l_abfx, t_ t_pod_1d l_rij, t_pod_1i l_pq3, int l_K3, int N) { Kokkos::parallel_for("AngularBasis", Kokkos::RangePolicy(0,N), KOKKOS_LAMBDA(int j) { - double x = l_rij(j*3 + 0); - double y = l_rij(j*3 + 1); - double z = l_rij(j*3 + 2); + double x = static_cast(l_rij(j*3 + 0)); + double y = static_cast(l_rij(j*3 + 1)); + double z = static_cast(l_rij(j*3 + 2)); double xx = x*x; double yy = y*y; @@ -784,32 +784,32 @@ void PairPODKokkos::angularbasis(t_pod_1d l_abf, t_pod_1d l_abfx, t_ idxa = j + N*n; // Calculate angular basis function and its derivatives using recursion relation if (d==1) { - l_abf(idxa) = l_abf(mj)*u; - l_abfx(idxa) = l_abfx(mj)*u + l_abf(mj); - l_abfy(idxa) = l_abfy(mj)*u; - l_abfz(idxa) = l_abfz(mj)*u; + l_abf(idxa) = static_cast(static_cast(l_abf(mj))*u); + l_abfx(idxa) = static_cast(static_cast(l_abfx(mj))*u + static_cast(l_abf(mj))); + l_abfy(idxa) = static_cast(static_cast(l_abfy(mj))*u); + l_abfz(idxa) = static_cast(static_cast(l_abfz(mj))*u); } else if (d==2) { - l_abf(idxa) = l_abf(mj)*v; - l_abfx(idxa) = l_abfx(mj)*v; - l_abfy(idxa) = l_abfy(mj)*v + l_abf(mj); - l_abfz(idxa) = l_abfz(mj)*v; + l_abf(idxa) = static_cast(static_cast(l_abf(mj))*v); + l_abfx(idxa) = static_cast(static_cast(l_abfx(mj))*v); + l_abfy(idxa) = static_cast(static_cast(l_abfy(mj))*v + static_cast(l_abf(mj))); + l_abfz(idxa) = static_cast(static_cast(l_abfz(mj))*v); } else if (d==3) { - l_abf(idxa) = l_abf(mj)*w; - l_abfx(idxa) = l_abfx(mj)*w; - l_abfy(idxa) = l_abfy(mj)*w; - l_abfz(idxa) = l_abfz(mj)*w + l_abf(mj); + l_abf(idxa) = static_cast(static_cast(l_abf(mj))*w); + l_abfx(idxa) = static_cast(static_cast(l_abfx(mj))*w); + l_abfy(idxa) = static_cast(static_cast(l_abfy(mj))*w); + l_abfz(idxa) = static_cast(static_cast(l_abfz(mj))*w + static_cast(l_abf(mj))); } } for (int n=1; n(l_abfx(idxa)); + y = static_cast(l_abfy(idxa)); + z = static_cast(l_abfz(idxa)); + l_abfx(idxa) = static_cast(x*dudx + y*dvdx + z*dwdx); + l_abfy(idxa) = static_cast(x*dudy + y*dvdy + z*dwdy); + l_abfz(idxa) = static_cast(x*dudz + y*dvdz + z*dwdz); } }); } @@ -832,9 +832,9 @@ void PairPODKokkos::radialangularsum(t_pod_1d l_sumU, t_pod_1d l_rbf double sum=0.0; for (int j=0; j(l_rbf(n + Nij * m) * l_abf(n + Nij * k)); } - l_sumU(kmi) = sum; + l_sumU(kmi) = static_cast(sum); }); } else { @@ -854,9 +854,9 @@ void PairPODKokkos::radialangularsum(t_pod_1d l_sumU, t_pod_1d l_rbf int ia = n + Nij * k; int ib = n + Nij * m; int tn = l_tj(n) - 1; // offset the atom type by 1, since atomtype is 1-based - tm[tn] += l_rbf(ib) * l_abf(ia); + tm[tn] += static_cast(l_rbf(ib) * l_abf(ia)); } - for (int j=0; j(tm[j]); }); } } @@ -884,10 +884,10 @@ void PairPODKokkos::twobody_forces(t_pod_1d fij, t_pod_1d cb2, t_pod int m = idx % l_nrbf2; // rbd index int i2 = n + Nij * m; // Index of the radial basis function for atom n and RBF m int i1 = 3*n; - double c = cb2(l_idxi(n) + Ni*m + Ni*l_nrbf2*(l_tj(n) - 1)); - Kokkos::atomic_add(&fij(0 + i1), c*l_rbfx(i2)); // Add the derivative with respect to x to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(1 + i1), c*l_rbfy(i2)); // Add the derivative with respect to y to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(2 + i1), c*l_rbfz(i2)); // Add the derivative with respect to z to the corresponding descriptor derivative + double c = static_cast(cb2(l_idxi(n) + Ni*m + Ni*l_nrbf2*(l_tj(n) - 1))); + Kokkos::atomic_add(&fij(0 + i1), static_cast(c*static_cast(l_rbfx(i2)))); // Add the derivative with respect to x to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(1 + i1), static_cast(c*static_cast(l_rbfy(i2)))); // Add the derivative with respect to y to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(2 + i1), static_cast(c*static_cast(l_rbfz(i2)))); // Add the derivative with respect to z to the corresponding descriptor derivative }); } @@ -910,9 +910,9 @@ void PairPODKokkos::threebodydesc(t_pod_1d d3, t_pod_1d l_sumU, t_po for (int i2 = i1; i2 < l_nelements; i2++) { double tmp=0; for (int q = 0; q < nn; q++) { - tmp += l_pc3(n1 + q) * l_sumU(i1 + l_nelements * (n1 + q) + nmi) * l_sumU(i2 + l_nelements * (n1 + q) + nmi); + tmp += static_cast(l_pc3(n1 + q) * l_sumU(i1 + l_nelements * (n1 + q) + nmi) * l_sumU(i2 + l_nelements * (n1 + q) + nmi)); } - d3(ipm + totalIterations * l_nabf3 * k) = tmp; + d3(ipm + totalIterations * l_nabf3 * k) = static_cast(tmp); k += 1; } } @@ -932,34 +932,34 @@ void PairPODKokkos::threebody_forces(t_pod_1d fij, t_pod_1d cb3, t_p int j = idx / l_nrbf3; // Calculate j using integer division int m = idx % l_nrbf3; // Calculate m using modulo operation int idxR = j + Nij * m; // Pre-compute the index for rbf - double rbfBase = l_rbf(idxR); - double rbfxBase = l_rbfx(idxR); - double rbfyBase = l_rbfy(idxR); - double rbfzBase = l_rbfz(idxR); + double rbfBase = static_cast(l_rbf(idxR)); + double rbfxBase = static_cast(l_rbfx(idxR)); + double rbfyBase = static_cast(l_rbfy(idxR)); + double rbfzBase = static_cast(l_rbfz(idxR)); double fx = 0; double fy = 0; double fz = 0; for (int p = 0; p < l_nabf3; p++) { - double c3 = 2.0 * cb3(l_idxi(j) + Ni*p + Ni*l_nabf3*m); + double c3 = 2.0 * static_cast(cb3(l_idxi(j) + Ni*p + Ni*l_nabf3*m)); int n1 = l_pn3(p); int nn = l_pn3(p + 1) - n1; int idxU = l_K3 * m + l_K3*l_nrbf3*l_idxi(j); for (int q = 0; q < nn; q++) { int idxNQ = n1 + q; // Combine n1 and q into a single index for pc3 and sumU - double f = c3 * l_pc3(idxNQ) * l_sumU(idxNQ + idxU); + double f = c3 * l_pc3(idxNQ) * static_cast(l_sumU(idxNQ + idxU)); int idxA = j + Nij*idxNQ; // Pre-compute the index for abf - double abfA = l_abf(idxA); + double abfA = static_cast(l_abf(idxA)); // Use the pre-computed indices to update dd3 - fx += f * (l_abfx(idxA) * rbfBase + rbfxBase * abfA); - fy += f * (l_abfy(idxA) * rbfBase + rbfyBase * abfA); - fz += f * (l_abfz(idxA) * rbfBase + rbfzBase * abfA); + fx += f * (static_cast(l_abfx(idxA)) * rbfBase + rbfxBase * abfA); + fy += f * (static_cast(l_abfy(idxA)) * rbfBase + rbfyBase * abfA); + fz += f * (static_cast(l_abfz(idxA)) * rbfBase + rbfzBase * abfA); } } int ii = 3 * j; // Pre-compute the base index for dd3 - Kokkos::atomic_add(&fij(0 + ii), fx); // Add the derivative with respect to x to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(1 + ii), fy); // Add the derivative with respect to y to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(2 + ii), fz); // Add the derivative with respect to z to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(0 + ii), static_cast(fx)); // Add the derivative with respect to x to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(1 + ii), static_cast(fy)); // Add the derivative with respect to y to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(2 + ii), static_cast(fz)); // Add the derivative with respect to z to the corresponding descriptor derivative }); } else { @@ -970,10 +970,10 @@ void PairPODKokkos::threebody_forces(t_pod_1d fij, t_pod_1d cb3, t_p int i2 = l_tj(j) - 1; int idxK = l_nelements * l_K3 * m + l_nelements*l_K3*l_nrbf3*l_idxi(j); int idxR = j + Nij * m; // Pre-compute the index for rbf - double rbfBase = l_rbf(idxR); - double rbfxBase = l_rbfx(idxR); - double rbfyBase = l_rbfy(idxR); - double rbfzBase = l_rbfz(idxR); + double rbfBase = static_cast(l_rbf(idxR)); + double rbfxBase = static_cast(l_rbfx(idxR)); + double rbfyBase = static_cast(l_rbfy(idxR)); + double rbfzBase = static_cast(l_rbfz(idxR)); double fx = 0; double fy = 0; double fz = 0; @@ -983,22 +983,22 @@ void PairPODKokkos::threebody_forces(t_pod_1d fij, t_pod_1d cb3, t_p int jmp = l_idxi(j) + Ni*(p + l_nabf3*m); for (int i1 = 0; i1 < l_nelements; i1++) { double c3 = (i1 == i2) ? 2.0 : 1.0; - c3 = c3 * cb3(jmp + N3*l_elemindex(i2 + l_nelements * i1)); + c3 = c3 * static_cast(cb3(jmp + N3*l_elemindex(i2 + l_nelements * i1))); for (int q = 0; q < nn; q++) { int idxNQ = n1 + q; // Combine n1 and q into a single index int idxA = j + Nij*idxNQ; // Pre-compute the index for abf - double abfA = l_abf(idxA); - double f = c3 * l_pc3(idxNQ) * l_sumU(i1 + l_nelements * idxNQ + idxK); - fx += f * (l_abfx(idxA) * rbfBase + rbfxBase * abfA); - fy += f * (l_abfy(idxA) * rbfBase + rbfyBase * abfA); - fz += f * (l_abfz(idxA) * rbfBase + rbfzBase * abfA); + double abfA = static_cast(l_abf(idxA)); + double f = c3 * l_pc3(idxNQ) * static_cast(l_sumU(i1 + l_nelements * idxNQ + idxK)); + fx += f * (static_cast(l_abfx(idxA)) * rbfBase + rbfxBase * abfA); + fy += f * (static_cast(l_abfy(idxA)) * rbfBase + rbfyBase * abfA); + fz += f * (static_cast(l_abfz(idxA)) * rbfBase + rbfzBase * abfA); } } } int ii = 3 * j; // Pre-compute the base index for dd3 - Kokkos::atomic_add(&fij(0 + ii), fx); // Add the derivative with respect to x to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(1 + ii), fy); // Add the derivative with respect to y to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(2 + ii), fz); // Add the derivative with respect to z to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(0 + ii), static_cast(fx)); // Add the derivative with respect to x to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(1 + ii), static_cast(fy)); // Add the derivative with respect to y to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(2 + ii), static_cast(fz)); // Add the derivative with respect to z to the corresponding descriptor derivative }); } } @@ -1014,13 +1014,13 @@ void PairPODKokkos::threebody_forcecoeff(t_pod_1d fb3, t_pod_1d cb3, int i = idx / l_nrbf3; // Calculate j using integer division int m = idx % l_nrbf3; // Calculate m using modulo operation for (int p = 0; p < l_nabf3; p++) { - double c3 = 2.0 * cb3(i + Ni*p + Ni*l_nabf3*m); + double c3 = 2.0 * static_cast(cb3(i + Ni*p + Ni*l_nabf3*m)); int n1 = l_pn3(p); int nn = l_pn3(p + 1) - n1; int idxU = l_K3 * m + l_K3*l_nrbf3*i; for (int q = 0; q < nn; q++) { int idxNQ = n1 + q; // Combine n1 and q into a single index for pc3 and sumU - fb3(idxNQ + idxU) += c3 * l_pc3(idxNQ) * l_sumU(idxNQ + idxU); + fb3(idxNQ + idxU) += static_cast(c3 * l_pc3(idxNQ) * static_cast(l_sumU(idxNQ + idxU))); } } }); @@ -1038,11 +1038,11 @@ void PairPODKokkos::threebody_forcecoeff(t_pod_1d fb3, t_pod_1d cb3, int k = n1 + q; // Combine n1 and q into a single index int idxU = l_nelements * k + l_nelements * l_K3 * m + l_nelements*l_K3*l_nrbf3*i; for (int i1 = 0; i1 < l_nelements; i1++) { - double tm = l_pc3[k] * l_sumU[i1 + idxU]; + double tm = l_pc3[k] * static_cast(l_sumU[i1 + idxU]); for (int i2 = i1; i2 < l_nelements; i2++) { int em = l_elemindex[i2 + l_nelements * i1]; - double t1 = tm * cb3[jmp + N3*em]; // Ni * nabf3 * nrbf3 * nelements*(nelements+1)/2 - fb3[i2 + idxU] += t1; // K3*nrbf3*Ni + double t1 = tm * static_cast(cb3[jmp + N3*em]); // Ni * nabf3 * nrbf3 * nelements*(nelements+1)/2 + fb3[i2 + idxU] += static_cast(t1); // K3*nrbf3*Ni fb3[i1 + idxU] += l_pc3[k] * cb3[jmp + N3*em] * l_sumU[i2 + idxU]; } } @@ -1075,10 +1075,10 @@ void PairPODKokkos::fourbodydesc(t_pod_1d d4, t_pod_1d l_sumU, t_po int j1 = l_pb4(n1 + q); int j2 = l_pb4(n1 + q + l_Q4); int j3 = l_pb4(n1 + q + 2 * l_Q4); - tmp += c * l_sumU(idxU + i1 + l_nelements * j1) * l_sumU(idxU + i2 + l_nelements * j2) * l_sumU(idxU + i3 + l_nelements * j3); + tmp += static_cast(c * l_sumU(idxU + i1 + l_nelements * j1) * l_sumU(idxU + i2 + l_nelements * j2) * l_sumU(idxU + i3 + l_nelements * j3)); } int kk = p + l_nabf4 * m + l_nabf4 * l_nrbf4 * k; - d4(i + Ni * kk) = tmp; + d4(i + Ni * kk) = static_cast(tmp); k += 1; } } @@ -1100,10 +1100,10 @@ void PairPODKokkos::fourbody_forces(t_pod_1d fij, t_pod_1d cb4, t_po int m = idx % l_nrbf4; // Derive the original m value int idxU = l_K3 * m + l_K3*l_nrbf3*l_idxi(j); int baseIdxJ = j + Nij * m; // Pre-compute the index for rbf - double rbfBase = l_rbf(baseIdxJ); - double rbfxBase = l_rbfx(baseIdxJ); - double rbfyBase = l_rbfy(baseIdxJ); - double rbfzBase = l_rbfz(baseIdxJ); + double rbfBase = static_cast(l_rbf(baseIdxJ)); + double rbfxBase = static_cast(l_rbfx(baseIdxJ)); + double rbfyBase = static_cast(l_rbfy(baseIdxJ)); + double rbfzBase = static_cast(l_rbfz(baseIdxJ)); double fx = 0; double fy = 0; double fz = 0; @@ -1111,16 +1111,16 @@ void PairPODKokkos::fourbody_forces(t_pod_1d fij, t_pod_1d cb4, t_po int n1 = l_pa4(p); int n2 = l_pa4(p + 1); int nn = n2 - n1; - double c4 = cb4(l_idxi(j) + Ni*p + Ni*l_nabf4*m); + double c4 = static_cast(cb4(l_idxi(j) + Ni*p + Ni*l_nabf4*m)); for (int q = 0; q < nn; q++) { int idxNQ = n1 + q; // Combine n1 and q into a single index double c = c4 * l_pc4[idxNQ]; int j1 = l_pb4(idxNQ); int j2 = l_pb4(idxNQ + l_Q4); int j3 = l_pb4(idxNQ + 2 * l_Q4); - double c1 = l_sumU(idxU + j1); - double c2 = l_sumU(idxU + j2); - double c3 = l_sumU(idxU + j3); + double c1 = static_cast(l_sumU(idxU + j1)); + double c2 = static_cast(l_sumU(idxU + j2)); + double c3 = static_cast(l_sumU(idxU + j3)); double t12 = c * c1 * c2; double t13 = c * c1 * c3; double t23 = c * c2 * c3; @@ -1131,25 +1131,25 @@ void PairPODKokkos::fourbody_forces(t_pod_1d fij, t_pod_1d cb4, t_po int baseIdxJ1 = j + Nij * j1; // Common index for j1 terms // Temporary variables to store repeated calculations - double abfBaseJ1 = l_abf(baseIdxJ1); - double abfBaseJ2 = l_abf(baseIdxJ2); - double abfBaseJ3 = l_abf(baseIdxJ3); + double abfBaseJ1 = static_cast(l_abf(baseIdxJ1)); + double abfBaseJ2 = static_cast(l_abf(baseIdxJ2)); + double abfBaseJ3 = static_cast(l_abf(baseIdxJ3)); // Update dd4 using pre-computed indices - fx += t12 * (l_abfx(baseIdxJ3) * rbfBase + rbfxBase * abfBaseJ3) - + t13 * (l_abfx(baseIdxJ2) * rbfBase + rbfxBase * abfBaseJ2) - + t23 * (l_abfx(baseIdxJ1) * rbfBase + rbfxBase * abfBaseJ1); - fy += t12 * (l_abfy(baseIdxJ3) * rbfBase + rbfyBase * abfBaseJ3) - + t13 * (l_abfy(baseIdxJ2) * rbfBase + rbfyBase * abfBaseJ2) - + t23 * (l_abfy(baseIdxJ1) * rbfBase + rbfyBase * abfBaseJ1); - fz += t12 * (l_abfz(baseIdxJ3) * rbfBase + rbfzBase * abfBaseJ3) - + t13 * (l_abfz(baseIdxJ2) * rbfBase + rbfzBase * abfBaseJ2) - + t23 * (l_abfz(baseIdxJ1) * rbfBase + rbfzBase * abfBaseJ1); + fx += t12 * (static_cast(l_abfx(baseIdxJ3)) * rbfBase + rbfxBase * abfBaseJ3) + + t13 * (static_cast(l_abfx(baseIdxJ2)) * rbfBase + rbfxBase * abfBaseJ2) + + t23 * (static_cast(l_abfx(baseIdxJ1)) * rbfBase + rbfxBase * abfBaseJ1); + fy += t12 * (static_cast(l_abfy(baseIdxJ3)) * rbfBase + rbfyBase * abfBaseJ3) + + t13 * (static_cast(l_abfy(baseIdxJ2)) * rbfBase + rbfyBase * abfBaseJ2) + + t23 * (static_cast(l_abfy(baseIdxJ1)) * rbfBase + rbfyBase * abfBaseJ1); + fz += t12 * (static_cast(l_abfz(baseIdxJ3)) * rbfBase + rbfzBase * abfBaseJ3) + + t13 * (static_cast(l_abfz(baseIdxJ2)) * rbfBase + rbfzBase * abfBaseJ2) + + t23 * (static_cast(l_abfz(baseIdxJ1)) * rbfBase + rbfzBase * abfBaseJ1); } } int ii = 3 * j; // Pre-compute the base index for dd3 - Kokkos::atomic_add(&fij(0 + ii), fx); // Add the derivative with respect to x to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(1 + ii), fy); // Add the derivative with respect to y to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(2 + ii), fz); // Add the derivative with respect to z to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(0 + ii), static_cast(fx)); // Add the derivative with respect to x to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(1 + ii), static_cast(fy)); // Add the derivative with respect to y to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(2 + ii), static_cast(fz)); // Add the derivative with respect to z to the corresponding descriptor derivative }); } else { @@ -1158,10 +1158,10 @@ void PairPODKokkos::fourbody_forces(t_pod_1d fij, t_pod_1d cb4, t_po int j = idx / l_nrbf4; // Derive the original j value int m = idx % l_nrbf4; // Derive the original m value int idxM = j + Nij * m; - double rbfM = l_rbf(idxM); - double rbfxM = l_rbfx(idxM); - double rbfyM = l_rbfy(idxM); - double rbfzM = l_rbfz(idxM); + double rbfM = static_cast(l_rbf(idxM)); + double rbfxM = static_cast(l_rbfx(idxM)); + double rbfyM = static_cast(l_rbfy(idxM)); + double rbfzM = static_cast(l_rbfz(idxM)); int typej = l_tj(j) - 1; double fx = 0; double fy = 0; @@ -1176,7 +1176,7 @@ void PairPODKokkos::fourbody_forces(t_pod_1d fij, t_pod_1d cb4, t_po for (int i2 = i1; i2 < l_nelements; i2++) { for (int i3 = i2; i3 < l_nelements; i3++) { for (int q = 0; q < nn; q++) { - double c = l_pc4(n1 + q) * cb4(jpm + N3*k); + double c = l_pc4(n1 + q) * static_cast(cb4(jpm + N3*k)); int j1 = l_pb4(n1 + q); int j2 = l_pb4(n1 + q + l_Q4); int j3 = l_pb4(n1 + q + 2 * l_Q4); @@ -1184,9 +1184,9 @@ void PairPODKokkos::fourbody_forces(t_pod_1d fij, t_pod_1d cb4, t_po int idx1 = i1 + l_nelements * j1 + l_nelements * l_K3 * m + l_nelements * l_K3 * l_nrbf3 * l_idxi(j); int idx2 = i2 + l_nelements * j2 + l_nelements * l_K3 * m + l_nelements * l_K3 * l_nrbf3 * l_idxi(j); int idx3 = i3 + l_nelements * j3 + l_nelements * l_K3 * m + l_nelements * l_K3 * l_nrbf3 * l_idxi(j); - double c1 = l_sumU(idx1); - double c2 = l_sumU(idx2 ); - double c3 = l_sumU(idx3); + double c1 = static_cast(l_sumU(idx1)); + double c2 = static_cast(l_sumU(idx2 )); + double c3 = static_cast(l_sumU(idx3)); double t12 = c*(c1 * c2); double t13 = c*(c1 * c3); double t23 = c*(c2 * c3); @@ -1194,18 +1194,18 @@ void PairPODKokkos::fourbody_forces(t_pod_1d fij, t_pod_1d cb4, t_po int idxJ3 = j + Nij * j3; int idxJ2 = j + Nij * j2; int idxJ1 = j + Nij * j1; - double abfJ1 = l_abf(idxJ1); - double abfJ2 = l_abf(idxJ2); - double abfJ3 = l_abf(idxJ3); - double abfxJ1 = l_abfx(idxJ1); - double abfxJ2 = l_abfx(idxJ2); - double abfxJ3 = l_abfx(idxJ3); - double abfyJ1 = l_abfy(idxJ1); - double abfyJ2 = l_abfy(idxJ2); - double abfyJ3 = l_abfy(idxJ3); - double abfzJ1 = l_abfz(idxJ1); - double abfzJ2 = l_abfz(idxJ2); - double abfzJ3 = l_abfz(idxJ3); + double abfJ1 = static_cast(l_abf(idxJ1)); + double abfJ2 = static_cast(l_abf(idxJ2)); + double abfJ3 = static_cast(l_abf(idxJ3)); + double abfxJ1 = static_cast(l_abfx(idxJ1)); + double abfxJ2 = static_cast(l_abfx(idxJ2)); + double abfxJ3 = static_cast(l_abfx(idxJ3)); + double abfyJ1 = static_cast(l_abfy(idxJ1)); + double abfyJ2 = static_cast(l_abfy(idxJ2)); + double abfyJ3 = static_cast(l_abfy(idxJ3)); + double abfzJ1 = static_cast(l_abfz(idxJ1)); + double abfzJ2 = static_cast(l_abfz(idxJ2)); + double abfzJ3 = static_cast(l_abfz(idxJ3)); // Compute contributions for each condition if (typej == i3) { @@ -1230,9 +1230,9 @@ void PairPODKokkos::fourbody_forces(t_pod_1d fij, t_pod_1d cb4, t_po } } int ii = 3 * j; // Pre-compute the base index for dd3 - Kokkos::atomic_add(&fij(0 + ii), fx); // Add the derivative with respect to x to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(1 + ii), fy); // Add the derivative with respect to y to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(2 + ii), fz); // Add the derivative with respect to z to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(0 + ii), static_cast(fx)); // Add the derivative with respect to x to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(1 + ii), static_cast(fy)); // Add the derivative with respect to y to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(2 + ii), static_cast(fz)); // Add the derivative with respect to z to the corresponding descriptor derivative }); } } @@ -1252,19 +1252,19 @@ void PairPODKokkos::fourbody_forcecoeff(t_pod_1d fb4, t_pod_1d cb4, int n1 = l_pa4(p); int n2 = l_pa4(p + 1); int nn = n2 - n1; - double c4 = cb4(i + Ni*p + Ni*l_nabf4*m); + double c4 = static_cast(cb4(i + Ni*p + Ni*l_nabf4*m)); for (int q = 0; q < nn; q++) { int idxNQ = n1 + q; // Combine n1 and q into a single index double c = c4 * l_pc4[idxNQ]; int j1 = idxU + l_pb4(idxNQ); int j2 = idxU + l_pb4(idxNQ + l_Q4); int j3 = idxU + l_pb4(idxNQ + 2 * l_Q4); - double c1 = l_sumU(j1); - double c2 = l_sumU(j2); - double c3 = l_sumU(j3); - fb4[j3] += c * c1 * c2; - fb4[j2] += c * c1 * c3; - fb4[j1] += c * c2 * c3; + double c1 = static_cast(l_sumU(j1)); + double c2 = static_cast(l_sumU(j2)); + double c3 = static_cast(l_sumU(j3)); + fb4[j3] += static_cast(c * c1 * c2); + fb4[j2] += static_cast(c * c1 * c3); + fb4[j1] += static_cast(c * c2 * c3); } } }); @@ -1289,15 +1289,15 @@ void PairPODKokkos::fourbody_forcecoeff(t_pod_1d fb4, t_pod_1d cb4, int idx3 = l_nelements * j3 + l_nelements * l_K3 * m + l_nelements * l_K3 * l_nrbf3 * i; int k = 0; for (int i1 = 0; i1 < l_nelements; i1++) { - double c1 = l_sumU[idx1 + i1]; + double c1 = static_cast(l_sumU[idx1 + i1]); for (int i2 = i1; i2 < l_nelements; i2++) { - double c2 = l_sumU[idx2 + i2]; + double c2 = static_cast(l_sumU[idx2 + i2]); for (int i3 = i2; i3 < l_nelements; i3++) { - double c3 = l_sumU[idx3 + i3]; - double c4 = c * cb4[jpm + N3*k]; - fb4[idx3 + i3] += c4*(c1 * c2); - fb4[idx2 + i2] += c4*(c1 * c3); - fb4[idx1 + i1] += c4*(c2 * c3); + double c3 = static_cast(l_sumU[idx3 + i3]); + double c4 = c * static_cast(cb4[jpm + N3*k]); + fb4[idx3 + i3] += static_cast(c4*(c1 * c2)); + fb4[idx2 + i2] += static_cast(c4*(c1 * c3)); + fb4[idx1 + i1] += static_cast(c4*(c2 * c3)); k += 1; } } @@ -1319,29 +1319,29 @@ void PairPODKokkos::allbody_forces(t_pod_1d fij, t_pod_1d l_forcecoe int m = idx % l_nrbf3; // Calculate m using modulo operation int i2 = l_tj(j) - 1; int idxR = j + Nij * m; // Pre-compute the index for rbf - double rbfBase = l_rbf(idxR); - double rbfxBase = l_rbfx(idxR); - double rbfyBase = l_rbfy(idxR); - double rbfzBase = l_rbfz(idxR); + double rbfBase = static_cast(l_rbf(idxR)); + double rbfxBase = static_cast(l_rbfx(idxR)); + double rbfyBase = static_cast(l_rbfy(idxR)); + double rbfzBase = static_cast(l_rbfz(idxR)); double fx = 0; double fy = 0; double fz = 0; for (int k = 0; k < l_K3; k++) { int idxU = l_nelements * k + l_nelements * l_K3 * m + l_nelements*l_K3*l_nrbf3*l_idxi[j]; - double fc = l_forcecoeff[i2 + idxU]; + double fc = static_cast(l_forcecoeff[i2 + idxU]); int idxA = j + Nij*k; // Pre-compute the index for abf - double abfA = l_abf[idxA]; - double abfxA = l_abfx[idxA]; - double abfyA = l_abfy[idxA]; - double abfzA = l_abfz[idxA]; + double abfA = static_cast(l_abf[idxA]); + double abfxA = static_cast(l_abfx[idxA]); + double abfyA = static_cast(l_abfy[idxA]); + double abfzA = static_cast(l_abfz[idxA]); fx += fc * (abfxA * rbfBase + rbfxBase * abfA); // K3*nrbf3*Nij fy += fc * (abfyA * rbfBase + rbfyBase * abfA); fz += fc * (abfzA * rbfBase + rbfzBase * abfA); } int ii = 3 * j; // Pre-compute the base index for dd3 - Kokkos::atomic_add(&fij(0 + ii), fx); // Add the derivative with respect to x to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(1 + ii), fy); // Add the derivative with respect to y to the corresponding descriptor derivative - Kokkos::atomic_add(&fij(2 + ii), fz); // Add the derivative with respect to z to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(0 + ii), static_cast(fx)); // Add the derivative with respect to x to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(1 + ii), static_cast(fy)); // Add the derivative with respect to y to the corresponding descriptor derivative + Kokkos::atomic_add(&fij(2 + ii), static_cast(fz)); // Add the derivative with respect to z to the corresponding descriptor derivative }); } @@ -1369,9 +1369,9 @@ void PairPODKokkos::crossdesc_reduction(t_pod_1d cb1, t_pod_1d cb2, int k2 = ind2(m); // dd2 int m1 = n + Ni * k1; // d1 int m2 = n + Ni * k2; // d2 - double c = c12(n + Ni * m); - Kokkos::atomic_add(&cb1(m1), c * d2(m2)); - Kokkos::atomic_add(&cb2(m2), c * d1(m1)); + double c = static_cast(c12(n + Ni * m)); + Kokkos::atomic_add(&cb1(m1), static_cast(c * static_cast(d2(m2)))); + Kokkos::atomic_add(&cb2(m2), static_cast(c * static_cast(d1(m1)))); }); } @@ -1525,9 +1525,9 @@ void PairPODKokkos::blockatom_environment_descriptors(t_pod_1d ei, t double sum = 0.0; int typei = tyai[i]-1; for (int m = 0; m < nDes; m++) { - sum += proj[k + nCom*m + nCom*nDes*typei] * B[i + Ni*m]; + sum += static_cast(proj[k + nCom*m + nCom*nDes*typei] * B[i + Ni*m]); } - pca[i + Ni*k] = sum; + pca[i + Ni*k] = static_cast(sum); }); totalIterations = Ni*nCls; @@ -1537,18 +1537,18 @@ void PairPODKokkos::blockatom_environment_descriptors(t_pod_1d ei, t int typei = tyai[i]-1; double sum = 1e-20; for (int k = 0; k < nCom; k++) { - double c = cent[k + j * nCom + nCls*nCom*typei]; - double p = pca[i + Ni*k]; + double c = static_cast(cent[k + j * nCom + nCls*nCom*typei]); + double p = static_cast(pca[i + Ni*k]); sum += (p - c) * (p - c); } - D[i + Ni*j] = 1.0 / sum; + D[i + Ni*j] = static_cast(1.0 / sum); }); Kokkos::parallel_for("Probabilities", Kokkos::RangePolicy(0,Ni), KOKKOS_LAMBDA(int i) { double sum = 0; - for (int j = 0; j < nCls; j++) sum += D[i + Ni*j]; - sumD[i] = sum; - for (int j = 0; j < nCls; j++) P[i + Ni*j] = D[i + Ni*j]/sum; + for (int j = 0; j < nCls; j++) sum += static_cast(D[i + Ni*j]); + sumD[i] = static_cast(sum); + for (int j = 0; j < nCls; j++) P[i + Ni*j] = static_cast(static_cast(D[i + Ni*j])/sum); }); Kokkos::parallel_for("atomic_energies", Kokkos::RangePolicy(0,Ni), KOKKOS_LAMBDA(int n) { @@ -1565,8 +1565,8 @@ void PairPODKokkos::blockatom_environment_descriptors(t_pod_1d ei, t int nc = nCoeff*(tyai[n]-1); double sum = 0; for (int m = 0; m(cefs[1 + m + k*nDes + nc]*B[n + Ni*m]); + cp[n + Ni*k] = static_cast(sum); }); totalIterations = Ni*nDes; @@ -1576,33 +1576,33 @@ void PairPODKokkos::blockatom_environment_descriptors(t_pod_1d ei, t int nc = nCoeff*(tyai[n]-1); double sum = 0.0; for (int k = 0; k(cefs[1 + m + k*nDes + nc]*P[n + Ni*k]); + cb[n + Ni*m] = static_cast(sum); }); Kokkos::parallel_for("base_env_coefficients", Kokkos::RangePolicy(0,totalIterations), KOKKOS_LAMBDA(int idx) { int i = idx % Ni; int m = idx / Ni; int typei = tyai[i]-1; - double S1 = 1/sumD[i]; - double S2 = sumD[i]*sumD[i]; + double S1 = static_cast(1/sumD[i]); + double S2 = static_cast(sumD[i]*sumD[i]); double sum = 0.0; for (int j=0; j(D[i + Ni*j]) / S2; if (k==j) dP_dD += S1; double dD_dB = 0.0; - double D2 = 2 * D[i + Ni*k] * D[i + Ni*k]; + double D2 = static_cast(2 * D[i + Ni*k] * D[i + Ni*k]); for (int n = 0; n < nCom; n++) { - double dD_dpca = D2 * (cent[n + k * nCom + nCls*nCom*typei] - pca[i + Ni*n]); - dD_dB += dD_dpca * proj[n + m * nCom + nCom*nDes*typei]; + double dD_dpca = D2 * static_cast(cent[n + k * nCom + nCls*nCom*typei] - pca[i + Ni*n]); + dD_dB += dD_dpca * static_cast(proj[n + m * nCom + nCom*nDes*typei]); } dP_dB += dP_dD * dD_dB; } - sum += cp[i + Ni*j]*dP_dB; + sum += static_cast(cp[i + Ni*j])*dP_dB; } - cb[i + Ni*m] += sum; + cb[i + Ni*m] += static_cast(sum); }); } @@ -1677,15 +1677,15 @@ void PairPODKokkos::tallyforce(t_pod_1d l_fij, t_pod_1i l_ai, t_pod_ int im = l_ai(n); int jm = l_aj(n); int n3 = 3*n; - double fx = l_fij(n3 + 0); - double fy = l_fij(n3 + 1); - double fz = l_fij(n3 + 2); - Kokkos::atomic_add(&l_f(im, 0), fx); - Kokkos::atomic_add(&l_f(im, 1), fy); - Kokkos::atomic_add(&l_f(im, 2), fz); - Kokkos::atomic_sub(&l_f(jm, 0), fx); - Kokkos::atomic_sub(&l_f(jm, 1), fy); - Kokkos::atomic_sub(&l_f(jm, 2), fz); + double fx = static_cast(l_fij(n3 + 0)); + double fy = static_cast(l_fij(n3 + 1)); + double fz = static_cast(l_fij(n3 + 2)); + Kokkos::atomic_add(&l_f(im, 0), static_cast(fx)); + Kokkos::atomic_add(&l_f(im, 1), static_cast(fy)); + Kokkos::atomic_add(&l_f(im, 2), static_cast(fz)); + Kokkos::atomic_sub(&l_f(jm, 0), static_cast(fx)); + Kokkos::atomic_sub(&l_f(jm, 1), static_cast(fy)); + Kokkos::atomic_sub(&l_f(jm, 2), static_cast(fz)); }); } @@ -1698,7 +1698,7 @@ void PairPODKokkos::tallyenergy(t_pod_1d l_ei, int istart, int Ni) if (eflag_global) { double local_eng_vdwl = 0.0; Kokkos::parallel_reduce("GlobalEnergyTally", Kokkos::RangePolicy(0,Ni), KOKKOS_LAMBDA(int k, double& update) { - update += l_ei(k); + update += static_cast(l_ei(k)); }, local_eng_vdwl); // Update global energy on the host after the parallel region @@ -1708,7 +1708,7 @@ void PairPODKokkos::tallyenergy(t_pod_1d l_ei, int istart, int Ni) // For per-atom energy tally if (eflag_atom) { Kokkos::parallel_for("PerAtomEnergyTally", Kokkos::RangePolicy(0,Ni), KOKKOS_LAMBDA(int k) { - l_eatom(istart + k) += l_ei(k); + l_eatom(istart + k) += static_cast(l_ei(k)); }); } } @@ -1723,7 +1723,7 @@ void PairPODKokkos::tallystress(t_pod_1d l_fij, t_pod_1d l_rij, t_po double sum = 0.0; Kokkos::parallel_reduce("GlobalStressTally", Kokkos::RangePolicy(0,Nij), KOKKOS_LAMBDA(int k, double& update) { int k3 = 3*k; - update += l_rij(j + k3) * l_fij(j + k3); + update += static_cast(l_rij(j + k3) * l_fij(j + k3)); }, sum); virial[j] -= sum; } @@ -1731,21 +1731,21 @@ void PairPODKokkos::tallystress(t_pod_1d l_fij, t_pod_1d l_rij, t_po double sum = 0.0; Kokkos::parallel_reduce("GlobalStressTally", Kokkos::RangePolicy(0,Nij), KOKKOS_LAMBDA(int k, double& update) { int k3 = 3*k; - update += l_rij(k3) * l_fij(1 + k3); + update += static_cast(l_rij(k3) * l_fij(1 + k3)); }, sum); virial[3] -= sum; sum = 0.0; Kokkos::parallel_reduce("GlobalStressTally", Kokkos::RangePolicy(0,Nij), KOKKOS_LAMBDA(int k, double& update) { int k3 = 3*k; - update += l_rij(k3) * l_fij(2 + k3); + update += static_cast(l_rij(k3) * l_fij(2 + k3)); }, sum); virial[4] -= sum; sum = 0.0; Kokkos::parallel_reduce("GlobalStressTally", Kokkos::RangePolicy(0,Nij), KOKKOS_LAMBDA(int k, double& update) { int k3 = 3*k; - update += l_rij(1+k3) * l_fij(2+k3); + update += static_cast(l_rij(1+k3) * l_fij(2+k3)); }, sum); virial[5] -= sum; } @@ -1756,19 +1756,19 @@ void PairPODKokkos::tallystress(t_pod_1d l_fij, t_pod_1d l_rij, t_po int j = l_aj(k); int k3 = 3*k; double v_local[6]; - v_local[0] = -l_rij(k3) * l_fij(k3 + 0); - v_local[1] = -l_rij(k3 + 1) * l_fij(k3 + 1); - v_local[2] = -l_rij(k3 + 2) * l_fij(k3 + 2); - v_local[3] = -l_rij(k3 + 0) * l_fij(k3 + 1); - v_local[4] = -l_rij(k3 + 0) * l_fij(k3 + 2); - v_local[5] = -l_rij(k3 + 1) * l_fij(k3 + 2); + v_local[0] = static_cast(-l_rij(k3) * l_fij(k3 + 0)); + v_local[1] = static_cast(-l_rij(k3 + 1) * l_fij(k3 + 1)); + v_local[2] = static_cast(-l_rij(k3 + 2) * l_fij(k3 + 2)); + v_local[3] = static_cast(-l_rij(k3 + 0) * l_fij(k3 + 1)); + v_local[4] = static_cast(-l_rij(k3 + 0) * l_fij(k3 + 2)); + v_local[5] = static_cast(-l_rij(k3 + 1) * l_fij(k3 + 2)); for (int d = 0; d < 6; ++d) { - Kokkos::atomic_add(&l_vatom(i, d), 0.5 * v_local[d]); + Kokkos::atomic_add(&l_vatom(i, d), static_cast(0.5 * v_local[d])); } for (int d = 0; d < 6; ++d) { - Kokkos::atomic_add(&l_vatom(j, d), 0.5 * v_local[d]); + Kokkos::atomic_add(&l_vatom(j, d), static_cast(0.5 * v_local[d])); } }); diff --git a/src/KOKKOS/pair_soft_kokkos.cpp b/src/KOKKOS/pair_soft_kokkos.cpp index 1fb00518043..945fc754165 100644 --- a/src/KOKKOS/pair_soft_kokkos.cpp +++ b/src/KOKKOS/pair_soft_kokkos.cpp @@ -95,10 +95,10 @@ void PairSoftKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms @@ -106,14 +106,14 @@ void PairSoftKokkos::compute(int eflag_in, int vflag_in) EV_FLOAT ev = pair_compute,void >(this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -137,13 +137,13 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairSoftKokkos:: compute_fpair(const KK_FLOAT& rsq, const int &, const int &, const int& itype, const int& jtype) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT cut_ij = STACKPARAMS?m_params[itype][jtype].cut:params(itype,jtype).cut; const KK_FLOAT prefactor_ij = STACKPARAMS?m_params[itype][jtype].prefactor:params(itype,jtype).prefactor; - const KK_FLOAT arg = MY_PI*r/cut_ij; + const KK_FLOAT arg = static_cast(MY_PI)*r/cut_ij; KK_FLOAT fpair = 0.0; - if (r > 0.0) fpair = prefactor_ij * sin(arg) * MY_PI/cut_ij/r; + if (r > static_cast(0.0)) fpair = prefactor_ij * Kokkos::sin(arg) * static_cast(MY_PI)/cut_ij/r; return fpair; } @@ -154,12 +154,12 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairSoftKokkos:: compute_evdwl(const KK_FLOAT& rsq, const int &, const int &, const int& itype, const int& jtype) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT cut_ij = STACKPARAMS?m_params[itype][jtype].cut:params(itype,jtype).cut; const KK_FLOAT prefactor_ij = STACKPARAMS?m_params[itype][jtype].prefactor:params(itype,jtype).prefactor; - const KK_FLOAT arg = MY_PI*r/cut_ij; + const KK_FLOAT arg = static_cast(MY_PI)*r/cut_ij; - return prefactor_ij*(1.0+cos(arg)); + return prefactor_ij*(static_cast(1.0)+Kokkos::cos(arg)); } /* ---------------------------------------------------------------------- @@ -217,13 +217,13 @@ double PairSoftKokkos::init_one(int i, int j) { double cutone = PairSoft::init_one(i,j); - k_params.view_host()(i,j).prefactor = prefactor[i][j]; - k_params.view_host()(i,j).cut = cutone; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).prefactor = static_cast(prefactor[i][j]); + k_params.view_host()(i,j).cut = static_cast(cutone); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; diff --git a/src/KOKKOS/pair_sw_kokkos.cpp b/src/KOKKOS/pair_sw_kokkos.cpp index 72e67f93065..fade6d40320 100644 --- a/src/KOKKOS/pair_sw_kokkos.cpp +++ b/src/KOKKOS/pair_sw_kokkos.cpp @@ -178,14 +178,14 @@ void PairSWKokkos::compute(int eflag_in, int vflag_in) if (need_dup) Kokkos::Experimental::contribute(f, dup_f); - if (eflag_global) eng_vdwl += ev_all.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev_all.evdwl); if (vflag_global) { - virial[0] += ev_all.v[0]; - virial[1] += ev_all.v[1]; - virial[2] += ev_all.v[2]; - virial[3] += ev_all.v[3]; - virial[4] += ev_all.v[4]; - virial[5] += ev_all.v[5]; + virial[0] += static_cast(ev_all.v[0]); + virial[1] += static_cast(ev_all.v[1]); + virial[2] += static_cast(ev_all.v[2]); + virial[3] += static_cast(ev_all.v[3]); + virial[4] += static_cast(ev_all.v[4]); + virial[5] += static_cast(ev_all.v[5]); } if (eflag_atom) { @@ -240,7 +240,7 @@ void PairSWKokkos::operator()(TagPairSWComputeShortNeigh, const int& const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; const int ijparam = d_elem3param(itype,jtype,jtype); - if (rsq < d_params[ijparam].cutsq) { + if (rsq < static_cast(d_params[ijparam].cutsq)) { d_neighbors_short(ii,inside) = j; inside++; } @@ -306,15 +306,15 @@ void PairSWKokkos::operator()(TagPairSWCompute, co twobody(d_params[ijparam],rsq,fpair,eflag,evdwl); - fxtmpi += delx*fpair; - fytmpi += dely*fpair; - fztmpi += delz*fpair; - a_f(j,0) -= delx*fpair; - a_f(j,1) -= dely*fpair; - a_f(j,2) -= delz*fpair; + fxtmpi += static_cast(delx*fpair); + fytmpi += static_cast(dely*fpair); + fztmpi += static_cast(delz*fpair); + a_f(j,0) -= static_cast(delx*fpair); + a_f(j,1) -= static_cast(dely*fpair); + a_f(j,2) -= static_cast(delz*fpair); if (EVFLAG) { - if (eflag) ev.evdwl += evdwl; + if (eflag) ev.evdwl += static_cast(evdwl); if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,evdwl,fpair,delx,dely,delz); } } @@ -359,7 +359,7 @@ void PairSWKokkos::operator()(TagPairSWCompute, co a_f(k,2) += fk[2]; if (EVFLAG) { - if (eflag) ev.evdwl += evdwl; + if (eflag) ev.evdwl += static_cast(evdwl); if (vflag_either || eflag_atom) this->template ev_tally3(ev,i,j,k,evdwl,0.0,fj,fk,delr1,delr2); } } @@ -479,16 +479,16 @@ void PairSWKokkos::twobody(const Param& param, const KK_FLOAT& rsq, { KK_FLOAT r,rinvsq,rp,rq,rainv,rainvsq,expsrainv; - r = sqrt(rsq); - rinvsq = 1.0/rsq; - rp = pow(r,-param.powerp); - rq = pow(r,-param.powerq); - rainv = 1.0 / (r - param.cut); + r = Kokkos::sqrt(rsq); + rinvsq = static_cast(1.0)/rsq; + rp = Kokkos::pow(r,static_cast(-param.powerp)); + rq = Kokkos::pow(r,static_cast(-param.powerq)); + rainv = static_cast(1.0) / (r - static_cast(param.cut)); rainvsq = rainv*rainv*r; - expsrainv = exp(param.sigma * rainv); - fforce = (param.c1*rp - param.c2*rq + - (param.c3*rp -param.c4*rq) * rainvsq) * expsrainv * rinvsq; - if (eflag) eng = (param.c5*rp - param.c6*rq) * expsrainv; + expsrainv = Kokkos::exp(static_cast(param.sigma) * rainv); + fforce = (static_cast(param.c1)*rp - static_cast(param.c2)*rq + + (static_cast(param.c3)*rp -static_cast(param.c4)*rq) * rainvsq) * expsrainv * rinvsq; + if (eflag) eng = (static_cast(param.c5)*rp - static_cast(param.c6)*rq) * expsrainv; } /* ---------------------------------------------------------------------- */ @@ -506,23 +506,23 @@ void PairSWKokkos::threebody_kk(const Param& paramij, const Param& p KK_FLOAT rinv12,cs,delcs,delcssq,facexp,facrad,frad1,frad2; KK_FLOAT facang,facang12,csfacang,csfac1,csfac2; - r1 = sqrt(rsq1); - rinvsq1 = 1.0/rsq1; - rainv1 = 1.0/(r1 - paramij.cut); - gsrainv1 = paramij.sigma_gamma * rainv1; + r1 = Kokkos::sqrt(rsq1); + rinvsq1 = static_cast(1.0)/rsq1; + rainv1 = static_cast(1.0)/(r1 - static_cast(paramij.cut)); + gsrainv1 = static_cast(paramij.sigma_gamma) * rainv1; gsrainvsq1 = gsrainv1*rainv1/r1; - expgsrainv1 = exp(gsrainv1); + expgsrainv1 = Kokkos::exp(gsrainv1); - r2 = sqrt(rsq2); - rinvsq2 = 1.0/rsq2; - rainv2 = 1.0/(r2 - paramik.cut); - gsrainv2 = paramik.sigma_gamma * rainv2; + r2 = Kokkos::sqrt(rsq2); + rinvsq2 = static_cast(1.0)/rsq2; + rainv2 = static_cast(1.0)/(r2 - static_cast(paramik.cut)); + gsrainv2 = static_cast(paramik.sigma_gamma) * rainv2; gsrainvsq2 = gsrainv2*rainv2/r2; - expgsrainv2 = exp(gsrainv2); + expgsrainv2 = Kokkos::exp(gsrainv2); - rinv12 = 1.0/(r1*r2); + rinv12 = static_cast(1.0)/(r1*r2); cs = (delr1[0]*delr2[0] + delr1[1]*delr2[1] + delr1[2]*delr2[2]) * rinv12; - delcs = cs - paramijk.costheta; + delcs = cs - static_cast(paramijk.costheta); delcssq = delcs*delcs; facexp = expgsrainv1*expgsrainv2; @@ -530,23 +530,23 @@ void PairSWKokkos::threebody_kk(const Param& paramij, const Param& p // facrad = sqrt(paramij.lambda_epsilon*paramik.lambda_epsilon) * // facexp*delcssq; - facrad = paramijk.lambda_epsilon * facexp*delcssq; + facrad = static_cast(paramijk.lambda_epsilon) * facexp*delcssq; frad1 = facrad*gsrainvsq1; frad2 = facrad*gsrainvsq2; - facang = paramijk.lambda_epsilon2 * facexp*delcs; + facang = static_cast(paramijk.lambda_epsilon2) * facexp*delcs; facang12 = rinv12*facang; csfacang = cs*facang; csfac1 = rinvsq1*csfacang; - fj[0] = delr1[0]*(frad1+csfac1)-delr2[0]*facang12; - fj[1] = delr1[1]*(frad1+csfac1)-delr2[1]*facang12; - fj[2] = delr1[2]*(frad1+csfac1)-delr2[2]*facang12; + fj[0] = static_cast(delr1[0]*(frad1+csfac1)-delr2[0]*facang12); + fj[1] = static_cast(delr1[1]*(frad1+csfac1)-delr2[1]*facang12); + fj[2] = static_cast(delr1[2]*(frad1+csfac1)-delr2[2]*facang12); csfac2 = rinvsq2*csfacang; - fk[0] = delr2[0]*(frad2+csfac2)-delr1[0]*facang12; - fk[1] = delr2[1]*(frad2+csfac2)-delr1[1]*facang12; - fk[2] = delr2[2]*(frad2+csfac2)-delr1[2]*facang12; + fk[0] = static_cast(delr2[0]*(frad2+csfac2)-delr1[0]*facang12); + fk[1] = static_cast(delr2[1]*(frad2+csfac2)-delr1[1]*facang12); + fk[2] = static_cast(delr2[2]*(frad2+csfac2)-delr1[2]*facang12); if (eflag) eng = facrad; } @@ -571,9 +571,9 @@ void PairSWKokkos::ev_tally(EV_FLOAT &ev, const int &i, const int &j auto a_vatom = v_vatom.template access>(); if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; - a_eatom[i] += epairhalf; - a_eatom[j] += epairhalf; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; + a_eatom[i] += static_cast(epairhalf); + a_eatom[j] += static_cast(epairhalf); } if (vflag_either) { @@ -585,28 +585,28 @@ void PairSWKokkos::ev_tally(EV_FLOAT &ev, const int &i, const int &j const KK_FLOAT v5 = dely*delz*fpair; if (vflag_global) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } if (vflag_atom) { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; - - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; + a_vatom(i,0) += static_cast(static_cast(0.5)*v0); + a_vatom(i,1) += static_cast(static_cast(0.5)*v1); + a_vatom(i,2) += static_cast(static_cast(0.5)*v2); + a_vatom(i,3) += static_cast(static_cast(0.5)*v3); + a_vatom(i,4) += static_cast(static_cast(0.5)*v4); + a_vatom(i,5) += static_cast(static_cast(0.5)*v5); + + a_vatom(j,0) += static_cast(static_cast(0.5)*v0); + a_vatom(j,1) += static_cast(static_cast(0.5)*v1); + a_vatom(j,2) += static_cast(static_cast(0.5)*v2); + a_vatom(j,3) += static_cast(static_cast(0.5)*v3); + a_vatom(j,4) += static_cast(static_cast(0.5)*v4); + a_vatom(j,5) += static_cast(static_cast(0.5)*v5); } } } @@ -636,41 +636,41 @@ void PairSWKokkos::ev_tally3(EV_FLOAT &ev, const int &i, const int & auto a_vatom = v_vatom.template access>(); if (eflag_atom) { - epairthird = THIRD * (evdwl + ecoul); - a_eatom[i] += epairthird; - a_eatom[j] += epairthird; - a_eatom[k] += epairthird; + epairthird = static_cast(THIRD) * (evdwl + ecoul); + a_eatom[i] += static_cast(epairthird); + a_eatom[j] += static_cast(epairthird); + a_eatom[k] += static_cast(epairthird); } if (vflag_either) { - v[0] = drji[0]*fj[0] + drki[0]*fk[0]; - v[1] = drji[1]*fj[1] + drki[1]*fk[1]; - v[2] = drji[2]*fj[2] + drki[2]*fk[2]; - v[3] = drji[0]*fj[1] + drki[0]*fk[1]; - v[4] = drji[0]*fj[2] + drki[0]*fk[2]; - v[5] = drji[1]*fj[2] + drki[1]*fk[2]; + v[0] = drji[0]*static_cast(fj[0]) + drki[0]*static_cast(fk[0]); + v[1] = drji[1]*static_cast(fj[1]) + drki[1]*static_cast(fk[1]); + v[2] = drji[2]*static_cast(fj[2]) + drki[2]*static_cast(fk[2]); + v[3] = drji[0]*static_cast(fj[1]) + drki[0]*static_cast(fk[1]); + v[4] = drji[0]*static_cast(fj[2]) + drki[0]*static_cast(fk[2]); + v[5] = drji[1]*static_cast(fj[2]) + drki[1]*static_cast(fk[2]); if (vflag_global) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } if (vflag_atom) { - a_vatom(i,0) += THIRD*v[0]; a_vatom(i,1) += THIRD*v[1]; - a_vatom(i,2) += THIRD*v[2]; a_vatom(i,3) += THIRD*v[3]; - a_vatom(i,4) += THIRD*v[4]; a_vatom(i,5) += THIRD*v[5]; + a_vatom(i,0) += static_cast(static_cast(THIRD)*v[0]); a_vatom(i,1) += static_cast(static_cast(THIRD)*v[1]); + a_vatom(i,2) += static_cast(static_cast(THIRD)*v[2]); a_vatom(i,3) += static_cast(static_cast(THIRD)*v[3]); + a_vatom(i,4) += static_cast(static_cast(THIRD)*v[4]); a_vatom(i,5) += static_cast(static_cast(THIRD)*v[5]); - a_vatom(j,0) += THIRD*v[0]; a_vatom(j,1) += THIRD*v[1]; - a_vatom(j,2) += THIRD*v[2]; a_vatom(j,3) += THIRD*v[3]; - a_vatom(j,4) += THIRD*v[4]; a_vatom(j,5) += THIRD*v[5]; + a_vatom(j,0) += static_cast(static_cast(THIRD)*v[0]); a_vatom(j,1) += static_cast(static_cast(THIRD)*v[1]); + a_vatom(j,2) += static_cast(static_cast(THIRD)*v[2]); a_vatom(j,3) += static_cast(static_cast(THIRD)*v[3]); + a_vatom(j,4) += static_cast(static_cast(THIRD)*v[4]); a_vatom(j,5) += static_cast(static_cast(THIRD)*v[5]); - a_vatom(k,0) += THIRD*v[0]; a_vatom(k,1) += THIRD*v[1]; - a_vatom(k,2) += THIRD*v[2]; a_vatom(k,3) += THIRD*v[3]; - a_vatom(k,4) += THIRD*v[4]; a_vatom(k,5) += THIRD*v[5]; + a_vatom(k,0) += static_cast(static_cast(THIRD)*v[0]); a_vatom(k,1) += static_cast(static_cast(THIRD)*v[1]); + a_vatom(k,2) += static_cast(static_cast(THIRD)*v[2]); a_vatom(k,3) += static_cast(static_cast(THIRD)*v[3]); + a_vatom(k,4) += static_cast(static_cast(THIRD)*v[4]); a_vatom(k,5) += static_cast(static_cast(THIRD)*v[5]); } } } @@ -691,22 +691,22 @@ void PairSWKokkos::ev_tally3_atom(EV_FLOAT & /*ev*/, const int &i, KK_FLOAT epairthird,v[6]; if (eflag_atom) { - epairthird = THIRD * (evdwl + ecoul); - d_eatom[i] += epairthird; + epairthird = static_cast(THIRD) * (evdwl + ecoul); + d_eatom[i] += static_cast(epairthird); } if (vflag_either) { - v[0] = drji[0]*fj[0] + drki[0]*fk[0]; - v[1] = drji[1]*fj[1] + drki[1]*fk[1]; - v[2] = drji[2]*fj[2] + drki[2]*fk[2]; - v[3] = drji[0]*fj[1] + drki[0]*fk[1]; - v[4] = drji[0]*fj[2] + drki[0]*fk[2]; - v[5] = drji[1]*fj[2] + drki[1]*fk[2]; + v[0] = drji[0]*static_cast(fj[0]) + drki[0]*static_cast(fk[0]); + v[1] = drji[1]*static_cast(fj[1]) + drki[1]*static_cast(fk[1]); + v[2] = drji[2]*static_cast(fj[2]) + drki[2]*static_cast(fk[2]); + v[3] = drji[0]*static_cast(fj[1]) + drki[0]*static_cast(fk[1]); + v[4] = drji[0]*static_cast(fj[2]) + drki[0]*static_cast(fk[2]); + v[5] = drji[1]*static_cast(fj[2]) + drki[1]*static_cast(fk[2]); if (vflag_atom) { - d_vatom(i,0) += THIRD*v[0]; d_vatom(i,1) += THIRD*v[1]; - d_vatom(i,2) += THIRD*v[2]; d_vatom(i,3) += THIRD*v[3]; - d_vatom(i,4) += THIRD*v[4]; d_vatom(i,5) += THIRD*v[5]; + d_vatom(i,0) += static_cast(static_cast(THIRD)*v[0]); d_vatom(i,1) += static_cast(static_cast(THIRD)*v[1]); + d_vatom(i,2) += static_cast(static_cast(THIRD)*v[2]); d_vatom(i,3) += static_cast(static_cast(THIRD)*v[3]); + d_vatom(i,4) += static_cast(static_cast(THIRD)*v[4]); d_vatom(i,5) += static_cast(static_cast(THIRD)*v[5]); } } } diff --git a/src/KOKKOS/pair_table_kokkos.cpp b/src/KOKKOS/pair_table_kokkos.cpp index 2bf1893a01f..59e0f0b782c 100644 --- a/src/KOKKOS/pair_table_kokkos.cpp +++ b/src/KOKKOS/pair_table_kokkos.cpp @@ -174,14 +174,14 @@ void PairTableKokkos::compute_style(int eflag_in, int vflag_in) } } - if (eflag) eng_vdwl += ev.evdwl; + if (eflag) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (eflag_atom) { @@ -203,66 +203,68 @@ template template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION -double PairTableKokkos:: -compute_fpair(const double &rsq, const int &, const int &, const int &itype, const int &jtype) const { +KK_FLOAT PairTableKokkos:: +compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { union_int_float_t rsq_lookup; double fpair; + const double rsq_d = static_cast(rsq); const int tidx = d_table_const.tabindex(itype,jtype); if (Specialisation::TabStyle == LOOKUP) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + const int itable = static_cast ((rsq_d - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); fpair = d_table_const.f(tidx,itable); } else if (Specialisation::TabStyle == LINEAR) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - const double fraction = (rsq - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); + const int itable = static_cast ((rsq_d - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + const double fraction = (rsq_d - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); fpair = d_table_const.f(tidx,itable) + fraction*d_table_const.df(tidx,itable); } else if (Specialisation::TabStyle == SPLINE) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - const double b = (rsq - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); + const int itable = static_cast ((rsq_d - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + const double b = (rsq_d - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); const double a = 1.0 - b; fpair = a * d_table_const.f(tidx,itable) + b * d_table_const.f(tidx,itable+1) + ((a*a*a-a)*d_table_const.f2(tidx,itable) + (b*b*b-b)*d_table_const.f2(tidx,itable+1)) * d_table_const.deltasq6(tidx); } else { - rsq_lookup.f = rsq; + rsq_lookup.f = static_cast(rsq_d); int itable = rsq_lookup.i & d_table_const.nmask(tidx); itable >>= d_table_const.nshiftbits(tidx); - const double fraction = (rsq_lookup.f - d_table_const.rsq(tidx,itable)) * d_table_const.drsq(tidx,itable); + const double fraction = (static_cast(rsq_lookup.f) - d_table_const.rsq(tidx,itable)) * d_table_const.drsq(tidx,itable); fpair = d_table_const.f(tidx,itable) + fraction*d_table_const.df(tidx,itable); } - return fpair; + return static_cast(fpair); } template template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION -double PairTableKokkos:: -compute_evdwl(const double &rsq, const int &, const int &, const int &itype, const int &jtype) const { +KK_FLOAT PairTableKokkos:: +compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { double evdwl; union_int_float_t rsq_lookup; + const double rsq_d = static_cast(rsq); const int tidx = d_table_const.tabindex(itype,jtype); if (Specialisation::TabStyle == LOOKUP) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + const int itable = static_cast ((rsq_d - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); evdwl = d_table_const.e(tidx,itable); } else if (Specialisation::TabStyle == LINEAR) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - const double fraction = (rsq - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); + const int itable = static_cast ((rsq_d - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + const double fraction = (rsq_d - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); evdwl = d_table_const.e(tidx,itable) + fraction*d_table_const.de(tidx,itable); } else if (Specialisation::TabStyle == SPLINE) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - const double b = (rsq - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); + const int itable = static_cast ((rsq_d - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); + const double b = (rsq_d - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); const double a = 1.0 - b; evdwl = a * d_table_const.e(tidx,itable) + b * d_table_const.e(tidx,itable+1) + ((a*a*a-a)*d_table_const.e2(tidx,itable) + (b*b*b-b)*d_table_const.e2(tidx,itable+1)) * d_table_const.deltasq6(tidx); } else { - rsq_lookup.f = rsq; + rsq_lookup.f = static_cast(rsq_d); int itable = rsq_lookup.i & d_table_const.nmask(tidx); itable >>= d_table_const.nshiftbits(tidx); - const double fraction = (rsq_lookup.f - d_table_const.rsq(tidx,itable)) * d_table_const.drsq(tidx,itable); + const double fraction = (static_cast(rsq_lookup.f) - d_table_const.rsq(tidx,itable)) * d_table_const.drsq(tidx,itable); evdwl = d_table_const.e(tidx,itable) + fraction*d_table_const.de(tidx,itable); } - return evdwl; + return static_cast(evdwl); } template diff --git a/src/KOKKOS/pair_table_kokkos.h b/src/KOKKOS/pair_table_kokkos.h index 7322fbdc3c9..07a3c43c663 100644 --- a/src/KOKKOS/pair_table_kokkos.h +++ b/src/KOKKOS/pair_table_kokkos.h @@ -122,17 +122,17 @@ class PairTableKokkos : public PairTable { template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION - double compute_fpair(const double& rsq, const int& i, const int&j, const int& itype, const int& jtype) const; + KK_FLOAT compute_fpair(const KK_FLOAT& rsq, const int& i, const int&j, const int& itype, const int& jtype) const; template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION - double compute_evdwl(const double& rsq, const int& i, const int&j, const int& itype, const int& jtype) const; + KK_FLOAT compute_evdwl(const KK_FLOAT& rsq, const int& i, const int&j, const int& itype, const int& jtype) const; template // NOLINTNEXTLINE KOKKOS_INLINE_FUNCTION - double compute_ecoul(const double& /*rsq*/, const int& /*i*/, const int& /*j*/, + KK_FLOAT compute_ecoul(const KK_FLOAT& /*rsq*/, const int& /*i*/, const int& /*j*/, const int& /*itype*/, const int& /*jtype*/) const { return 0; } friend struct PairComputeFunctor >; diff --git a/src/KOKKOS/pair_table_rx_kokkos.cpp b/src/KOKKOS/pair_table_rx_kokkos.cpp index b62900a289f..cc907539066 100644 --- a/src/KOKKOS/pair_table_rx_kokkos.cpp +++ b/src/KOKKOS/pair_table_rx_kokkos.cpp @@ -84,7 +84,7 @@ void getMixingWeights( nTotal += dvector(atom_ind,id); nTotalOld += dvector(atom_ind_old,id); } - if (nTotal < MY_EPSILON || nTotalOld < MY_EPSILON) + if (nTotal < static_cast(MY_EPSILON) || nTotalOld < static_cast(MY_EPSILON)) Kokkos::abort("The number of molecules in CG particle is less than 10*DBL_EPSILON."); assert(isite1 >= 0); @@ -128,14 +128,14 @@ void getMixingWeights( fractionOFA += dvector(atom_ind,id)/nTotal; } if (isOneFluid(isite1)) { - nMoleculesOld1 = 1.0-(nTotalOld-nMoleculesOFAold); - nMolecules1 = 1.0-(nTotal-nMoleculesOFA); + nMoleculesOld1 = static_cast(1.0)-(nTotalOld-nMoleculesOFAold); + nMolecules1 = static_cast(1.0)-(nTotal-nMoleculesOFA); fractionOld1 = fractionOFAold; fraction1 = fractionOFA; } if (isOneFluid(isite2)) { - nMoleculesOld2 = 1.0-(nTotalOld-nMoleculesOFAold); - nMolecules2 = 1.0-(nTotal-nMoleculesOFA); + nMoleculesOld2 = static_cast(1.0)-(nTotalOld-nMoleculesOFAold); + nMolecules2 = static_cast(1.0)-(nTotal-nMoleculesOFA); fractionOld2 = fractionOFAold; fraction2 = fractionOFA; } @@ -235,25 +235,25 @@ compute_fpair(KK_FLOAT rsq, KK_FLOAT fpair; const int tidx = d_table_const.tabindex(itype,jtype); if (TABSTYLE == PairTable::LOOKUP) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - fpair = d_table_const.f(tidx,itable); + const int itable = static_cast ((rsq - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); + fpair = static_cast(d_table_const.f(tidx,itable)); } else if (TABSTYLE == PairTable::LINEAR) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - const KK_FLOAT fraction = (rsq - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); - fpair = d_table_const.f(tidx,itable) + fraction*d_table_const.df(tidx,itable); + const int itable = static_cast ((rsq - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); + const KK_FLOAT fraction = (rsq - static_cast(d_table_const.rsq(tidx,itable))) * static_cast(d_table_const.invdelta(tidx)); + fpair = static_cast(d_table_const.f(tidx,itable)) + fraction*static_cast(d_table_const.df(tidx,itable)); } else if (TABSTYLE == PairTable::SPLINE) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - const KK_FLOAT b = (rsq - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); - const KK_FLOAT a = 1.0 - b; - fpair = a * d_table_const.f(tidx,itable) + b * d_table_const.f(tidx,itable+1) + - ((a*a*a-a)*d_table_const.f2(tidx,itable) + (b*b*b-b)*d_table_const.f2(tidx,itable+1)) * - d_table_const.deltasq6(tidx); + const int itable = static_cast ((rsq - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); + const KK_FLOAT b = (rsq - static_cast(d_table_const.rsq(tidx,itable))) * static_cast(d_table_const.invdelta(tidx)); + const KK_FLOAT a = static_cast(1.0) - b; + fpair = a * static_cast(d_table_const.f(tidx,itable)) + b * static_cast(d_table_const.f(tidx,itable+1)) + + ((a*a*a-a)*static_cast(d_table_const.f2(tidx,itable)) + (b*b*b-b)*static_cast(d_table_const.f2(tidx,itable+1))) * + static_cast(d_table_const.deltasq6(tidx)); } else { rsq_lookup.f = rsq; int itable = rsq_lookup.i & d_table_const.nmask(tidx); itable >>= d_table_const.nshiftbits(tidx); - const KK_FLOAT fraction = (rsq_lookup.f - d_table_const.rsq(tidx,itable)) * d_table_const.drsq(tidx,itable); - fpair = d_table_const.f(tidx,itable) + fraction*d_table_const.df(tidx,itable); + const KK_FLOAT fraction = (rsq_lookup.f - static_cast(d_table_const.rsq(tidx,itable))) * static_cast(d_table_const.drsq(tidx,itable)); + fpair = static_cast(d_table_const.f(tidx,itable)) + fraction*static_cast(d_table_const.df(tidx,itable)); } return fpair; } @@ -271,25 +271,25 @@ compute_evdwl( Pair::union_int_float_t rsq_lookup; const int tidx = d_table_const.tabindex(itype,jtype); if (TABSTYLE == PairTable::LOOKUP) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - evdwl = d_table_const.e(tidx,itable); + const int itable = static_cast ((rsq - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); + evdwl = static_cast(d_table_const.e(tidx,itable)); } else if (TABSTYLE == PairTable::LINEAR) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - const KK_FLOAT fraction = (rsq - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); - evdwl = d_table_const.e(tidx,itable) + fraction*d_table_const.de(tidx,itable); + const int itable = static_cast ((rsq - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); + const KK_FLOAT fraction = (rsq - static_cast(d_table_const.rsq(tidx,itable))) * static_cast(d_table_const.invdelta(tidx)); + evdwl = static_cast(d_table_const.e(tidx,itable)) + fraction*static_cast(d_table_const.de(tidx,itable)); } else if (TABSTYLE == PairTable::SPLINE) { - const int itable = static_cast ((rsq - d_table_const.innersq(tidx)) * d_table_const.invdelta(tidx)); - const KK_FLOAT b = (rsq - d_table_const.rsq(tidx,itable)) * d_table_const.invdelta(tidx); - const KK_FLOAT a = 1.0 - b; - evdwl = a * d_table_const.e(tidx,itable) + b * d_table_const.e(tidx,itable+1) + - ((a*a*a-a)*d_table_const.e2(tidx,itable) + (b*b*b-b)*d_table_const.e2(tidx,itable+1)) * - d_table_const.deltasq6(tidx); + const int itable = static_cast ((rsq - static_cast(d_table_const.innersq(tidx))) * static_cast(d_table_const.invdelta(tidx))); + const KK_FLOAT b = (rsq - static_cast(d_table_const.rsq(tidx,itable))) * static_cast(d_table_const.invdelta(tidx)); + const KK_FLOAT a = static_cast(1.0) - b; + evdwl = a * static_cast(d_table_const.e(tidx,itable)) + b * static_cast(d_table_const.e(tidx,itable+1)) + + ((a*a*a-a)*static_cast(d_table_const.e2(tidx,itable)) + (b*b*b-b)*static_cast(d_table_const.e2(tidx,itable+1))) * + static_cast(d_table_const.deltasq6(tidx)); } else { rsq_lookup.f = rsq; int itable = rsq_lookup.i & d_table_const.nmask(tidx); itable >>= d_table_const.nshiftbits(tidx); - const KK_FLOAT fraction = (rsq_lookup.f - d_table_const.rsq(tidx,itable)) * d_table_const.drsq(tidx,itable); - evdwl = d_table_const.e(tidx,itable) + fraction*d_table_const.de(tidx,itable); + const KK_FLOAT fraction = (rsq_lookup.f - static_cast(d_table_const.rsq(tidx,itable))) * static_cast(d_table_const.drsq(tidx,itable)); + evdwl = static_cast(d_table_const.e(tidx,itable)) + fraction*static_cast(d_table_const.de(tidx,itable)); } return evdwl; } @@ -320,7 +320,7 @@ ev_tally( { if (eflag) { if (eflag_atom) { - auto epairhalf = 0.5 * epair; + auto epairhalf = static_cast(0.5) * static_cast(epair); if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) v_eatom[i] += epairhalf; if (NEWTON_PAIR || j < nlocal) v_eatom[j] += epairhalf; @@ -341,65 +341,65 @@ ev_tally( if (vflag_global) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } else { if (i < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } if (j < nlocal) { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } if (vflag_atom) { if (NEIGHFLAG!=FULL) { if (NEWTON_PAIR || i < nlocal) { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*static_cast(v0); + v_vatom(i,1) += static_cast(0.5)*static_cast(v1); + v_vatom(i,2) += static_cast(0.5)*static_cast(v2); + v_vatom(i,3) += static_cast(0.5)*static_cast(v3); + v_vatom(i,4) += static_cast(0.5)*static_cast(v4); + v_vatom(i,5) += static_cast(0.5)*static_cast(v5); } if (NEWTON_PAIR || j < nlocal) { - v_vatom(j,0) += 0.5*v0; - v_vatom(j,1) += 0.5*v1; - v_vatom(j,2) += 0.5*v2; - v_vatom(j,3) += 0.5*v3; - v_vatom(j,4) += 0.5*v4; - v_vatom(j,5) += 0.5*v5; + v_vatom(j,0) += static_cast(0.5)*static_cast(v0); + v_vatom(j,1) += static_cast(0.5)*static_cast(v1); + v_vatom(j,2) += static_cast(0.5)*static_cast(v2); + v_vatom(j,3) += static_cast(0.5)*static_cast(v3); + v_vatom(j,4) += static_cast(0.5)*static_cast(v4); + v_vatom(j,5) += static_cast(0.5)*static_cast(v5); } } else { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*static_cast(v0); + v_vatom(i,1) += static_cast(0.5)*static_cast(v1); + v_vatom(i,2) += static_cast(0.5)*static_cast(v2); + v_vatom(i,3) += static_cast(0.5)*static_cast(v3); + v_vatom(i,4) += static_cast(0.5)*static_cast(v4); + v_vatom(i,5) += static_cast(0.5)*static_cast(v5); } } } @@ -483,7 +483,7 @@ compute_item( auto rsq = delx*delx + dely*dely + delz*delz; auto jtype = type(j); - if (rsq < (STACKPARAMS ? m_cutsq[itype][jtype] : d_cutsq(itype,jtype))) { + if (static_cast(rsq) < (STACKPARAMS ? m_cutsq[itype][jtype] : d_cutsq(itype,jtype))) { auto mixWtSite1old_j = mixWtSite1old(j); auto mixWtSite2old_j = mixWtSite2old(j); auto mixWtSite1_j = mixWtSite1(j); @@ -492,9 +492,9 @@ compute_item( auto fpair = factor_lj * compute_fpair( rsq,itype,jtype,d_table_const); - if (isite1 == isite2) fpair *= sqrt(mixWtSite1old_i * mixWtSite2old_j); - else fpair *= (sqrt(mixWtSite1old_i * mixWtSite2old_j) + - sqrt(mixWtSite2old_i * mixWtSite1old_j)); + if (isite1 == isite2) fpair *= Kokkos::sqrt(mixWtSite1old_i * mixWtSite2old_j); + else fpair *= (Kokkos::sqrt(mixWtSite1old_i * mixWtSite2old_j) + + Kokkos::sqrt(mixWtSite2old_i * mixWtSite1old_j)); fx_i += delx*fpair; fy_i += dely*fpair; @@ -503,9 +503,9 @@ compute_item( auto do_half = (NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal); if (do_half) { - f(j,0) -= delx*fpair; - f(j,1) -= dely*fpair; - f(j,2) -= delz*fpair; + f(j,0) -= static_cast(delx*fpair); + f(j,1) -= static_cast(dely*fpair); + f(j,2) -= static_cast(delz*fpair); } auto evdwl = compute_evdwl( @@ -513,25 +513,25 @@ compute_item( KK_FLOAT evdwlOld; if (isite1 == isite2) { - evdwlOld = sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwl; - evdwl = sqrt(mixWtSite1_i*mixWtSite2_j)*evdwl; + evdwlOld = Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j)*evdwl; + evdwl = Kokkos::sqrt(mixWtSite1_i*mixWtSite2_j)*evdwl; } else { - evdwlOld = (sqrt(mixWtSite1old_i*mixWtSite2old_j) + - sqrt(mixWtSite2old_i*mixWtSite1old_j))*evdwl; - evdwl = (sqrt(mixWtSite1_i*mixWtSite2_j) + - sqrt(mixWtSite2_i*mixWtSite1_j))*evdwl; + evdwlOld = (Kokkos::sqrt(mixWtSite1old_i*mixWtSite2old_j) + + Kokkos::sqrt(mixWtSite2old_i*mixWtSite1old_j))*evdwl; + evdwl = (Kokkos::sqrt(mixWtSite1_i*mixWtSite2_j) + + Kokkos::sqrt(mixWtSite2_i*mixWtSite1_j))*evdwl; } evdwlOld *= factor_lj; evdwl *= factor_lj; - uCG_i += 0.5*evdwlOld; - if (do_half) uCG(j) += 0.5*evdwlOld; + uCG_i += static_cast(0.5)*evdwlOld; + if (do_half) uCG(j) += static_cast(0.5)*evdwlOld; - uCGnew_i += 0.5*evdwl; - if (do_half) uCGnew(j) += 0.5*evdwl; + uCGnew_i += static_cast(0.5)*evdwl; + if (do_half) uCGnew(j) += static_cast(0.5)*evdwl; evdwl = evdwlOld; - ev.evdwl += (do_half ? 1.0 : 0.5)*evdwl; + ev.evdwl += (do_half ? static_cast(1.0) : static_cast(0.5))*static_cast(evdwl); if (EVFLAG) { ev_tally( @@ -546,9 +546,9 @@ compute_item( uCG(i) += uCG_i; uCGnew(i) += uCGnew_i; - f(i,0) += fx_i; - f(i,1) += fy_i; - f(i,2) += fz_i; + f(i,0) += static_cast(fx_i); + f(i,1) += static_cast(fy_i); + f(i,2) += static_cast(fz_i); return ev; } @@ -807,14 +807,14 @@ void PairTableRXKokkos::compute_style(int eflag_in, int vflag_in) } } - if (eflag) eng_vdwl += ev.evdwl; + if (eflag) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -1247,43 +1247,43 @@ double PairTableRXKokkos::single(int i, int j, int itype, int jtype, } else if (tabstyle == LINEAR) { itable = static_cast ((rsq-tb->innersq) * tb->invdelta); if (itable >= tlm1) error->one(FLERR,"Pair distance > table outer cutoff"); - fraction = (rsq - tb->rsq[itable]) * tb->invdelta; - value = tb->f[itable] + fraction*tb->df[itable]; - fforce = factor_lj * value; + fraction = static_cast((rsq - tb->rsq[itable]) * tb->invdelta); + value = static_cast(tb->f[itable]) + fraction*static_cast(tb->df[itable]); + fforce = factor_lj * static_cast(value); } else if (tabstyle == SPLINE) { itable = static_cast ((rsq-tb->innersq) * tb->invdelta); if (itable >= tlm1) error->one(FLERR,"Pair distance > table outer cutoff"); - b = (rsq - tb->rsq[itable]) * tb->invdelta; - a = 1.0 - b; - value = a * tb->f[itable] + b * tb->f[itable+1] + - ((a*a*a-a)*tb->f2[itable] + (b*b*b-b)*tb->f2[itable+1]) * - tb->deltasq6; - fforce = factor_lj * value; + b = static_cast((rsq - tb->rsq[itable]) * tb->invdelta); + a = static_cast(1.0) - b; + value = a * static_cast(tb->f[itable]) + b * static_cast(tb->f[itable+1]) + + ((a*a*a-a)*static_cast(tb->f2[itable]) + (b*b*b-b)*static_cast(tb->f2[itable+1])) * + static_cast(tb->deltasq6); + fforce = factor_lj * static_cast(value); } else { Pair::union_int_float_t rsq_lookup; - rsq_lookup.f = rsq; + rsq_lookup.f = static_cast(rsq); itable = rsq_lookup.i & tb->nmask; itable >>= tb->nshiftbits; - fraction = (rsq_lookup.f - tb->rsq[itable]) * tb->drsq[itable]; - value = tb->f[itable] + fraction*tb->df[itable]; - fforce = factor_lj * value; + fraction = (rsq_lookup.f - static_cast(tb->rsq[itable])) * static_cast(tb->drsq[itable]); + value = static_cast(tb->f[itable]) + fraction*static_cast(tb->df[itable]); + fforce = factor_lj * static_cast(value); } - if (isite1 == isite2) fforce = sqrt(mixWtSite1_i*mixWtSite2_j)*fforce; - else fforce = (sqrt(mixWtSite1_i*mixWtSite2_j) + sqrt(mixWtSite2_i*mixWtSite1_j))*fforce; + if (isite1 == isite2) fforce = sqrt(static_cast(mixWtSite1_i*mixWtSite2_j))*fforce; + else fforce = (sqrt(static_cast(mixWtSite1_i*mixWtSite2_j)) + sqrt(static_cast(mixWtSite2_i*mixWtSite1_j)))*fforce; if (tabstyle == LOOKUP) - phi = tb->e[itable]; + phi = static_cast(tb->e[itable]); else if (tabstyle == LINEAR || tabstyle == BITMAP) - phi = tb->e[itable] + fraction*tb->de[itable]; + phi = static_cast(tb->e[itable]) + fraction*static_cast(tb->de[itable]); else - phi = a * tb->e[itable] + b * tb->e[itable+1] + - ((a*a*a-a)*tb->e2[itable] + (b*b*b-b)*tb->e2[itable+1]) * tb->deltasq6; + phi = a * static_cast(tb->e[itable]) + b * static_cast(tb->e[itable+1]) + + ((a*a*a-a)*static_cast(tb->e2[itable]) + (b*b*b-b)*static_cast(tb->e2[itable+1])) * static_cast(tb->deltasq6); - if (isite1 == isite2) phi = sqrt(mixWtSite1_i*mixWtSite2_j)*phi; - else phi = (sqrt(mixWtSite1_i*mixWtSite2_j) + sqrt(mixWtSite2_i*mixWtSite1_j))*phi; + if (isite1 == isite2) phi = Kokkos::sqrt(mixWtSite1_i*mixWtSite2_j)*phi; + else phi = (Kokkos::sqrt(mixWtSite1_i*mixWtSite2_j) + Kokkos::sqrt(mixWtSite2_i*mixWtSite1_j))*phi; - return factor_lj*phi; + return factor_lj*static_cast(phi); } /* ---------------------------------------------------------------------- diff --git a/src/KOKKOS/pair_tersoff_kokkos.cpp b/src/KOKKOS/pair_tersoff_kokkos.cpp index 5befeb85b9a..2c1f4098193 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_kokkos.cpp @@ -410,7 +410,7 @@ void PairTersoffKokkos::tersoff_compute(const int &ii, EV_FLOAT& ev) KK_FLOAT bo_ij = 0; if (rsq1 > cutsq1) continue; - const KK_FLOAT rij = sqrt(rsq1); + const KK_FLOAT rij = Kokkos::sqrt(rsq1); for (int kk = 0; kk < jnum; kk++) { if (jj == kk) continue; @@ -425,7 +425,7 @@ void PairTersoffKokkos::tersoff_compute(const int &ii, EV_FLOAT& ev) const KK_FLOAT cutsq2 = d_params(iparam_ijk).cutsq; if (rsq2 > cutsq2) continue; - const KK_FLOAT rik = sqrt(rsq2); + const KK_FLOAT rik = Kokkos::sqrt(rsq2); bo_ij += bondorder(d_params(iparam_ijk),rij,delx1,dely1,delz1,rik,delx2,dely2,delz2); } @@ -466,7 +466,7 @@ void PairTersoffKokkos::tersoff_compute(const int &ii, EV_FLOAT& ev) const KK_FLOAT cutsq2 = d_params(iparam_ijk).cutsq; if (rsq2 > cutsq2) continue; - const KK_FLOAT rik = sqrt(rsq2); + const KK_FLOAT rik = Kokkos::sqrt(rsq2); ters_dthb(d_params(iparam_ijk),prefactor,rij,delx1,dely1,delz1, rik,delx2,dely2,delz2,fi,fj,fk); @@ -506,7 +506,7 @@ void PairTersoffKokkos::tersoff_compute(const int &ii, EV_FLOAT& ev) KK_FLOAT tmp_fce, tmp_fcd; ters_fc_k_and_ters_dfc(d_params[iparam_ij],rij,tmp_fce,tmp_fcd); - const KK_FLOAT tmp_exp = exp(-d_params[iparam_ij].lam1 * rij); + const KK_FLOAT tmp_exp = Kokkos::exp(-d_params[iparam_ij].lam1 * rij); const KK_FLOAT frep = -d_params[iparam_ij].biga * tmp_exp * (tmp_fcd - tmp_fce*d_params[iparam_ij].lam1) / rij; const KK_FLOAT eng = tmp_fce * d_params[iparam_ij].biga * tmp_exp; @@ -608,7 +608,7 @@ KK_FLOAT PairTersoffKokkos::ters_fc_k(const ParamKokkos& param, cons if (r < ters_R-ters_D) return static_cast(1.0); if (r > ters_R+ters_D) return static_cast(0.0); - return static_cast(0.5)*(static_cast(1.0) - sin(static_cast(MY_PI2)*(r - ters_R)/ters_D)); + return static_cast(0.5)*(static_cast(1.0) - Kokkos::sin(static_cast(MY_PI2)*(r - ters_R)/ters_D)); } /* ---------------------------------------------------------------------- */ @@ -623,7 +623,7 @@ KK_FLOAT PairTersoffKokkos::ters_dfc(const ParamKokkos& param, const if (r < ters_R-ters_D) return static_cast(0.0); if (r > ters_R+ters_D) return static_cast(0.0); - return -(static_cast(MY_PI4)/ters_D) * cos(static_cast(MY_PI2)*(r - ters_R)/ters_D); + return -(static_cast(MY_PI4)/ters_D) * Kokkos::cos(static_cast(MY_PI2)*(r - ters_R)/ters_D); } /* ---------------------------------------------------------------------- */ @@ -651,8 +651,8 @@ void PairTersoffKokkos::ters_fc_k_and_ters_dfc(const ParamKokkos& pa //KK_FLOAT sn, cn; //sincos(arg, &sn, &cn); - fc = static_cast(0.5)*(static_cast(1.0) - sin(arg)); - dfc = -(static_cast(MY_PI4)/ters_D) * cos(arg); + fc = static_cast(0.5)*(static_cast(1.0) - Kokkos::sin(arg)); + dfc = -(static_cast(MY_PI4)/ters_D) * Kokkos::cos(arg); } /* ---------------------------------------------------------------------- */ @@ -674,7 +674,7 @@ KK_FLOAT PairTersoffKokkos::bondorder(const ParamKokkos& param, if (arg > static_cast(69.0776)) ex_delr = static_cast(1.e30); else if (arg < static_cast(-69.0776)) ex_delr = static_cast(0.0); - else ex_delr = exp(arg); + else ex_delr = Kokkos::exp(arg); return ters_fc_k(param,rik) * ters_gijk(param,costheta) * ex_delr; } @@ -737,7 +737,7 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffKokkos::ters_fa_k(const ParamKokkos& param, const KK_FLOAT &r) const { if (r > param.bigr + param.bigd) return static_cast(0.0); - return -param.bigb * exp(-param.lam2 * r) + return -param.bigb * Kokkos::exp(-param.lam2 * r) * ters_fc_k(param,r); } @@ -749,7 +749,7 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffKokkos::ters_dfa(const ParamKokkos& param, const KK_FLOAT &r) const { if (r > param.bigr + param.bigd) return static_cast(0.0); - return param.bigb * exp(-param.lam2 * r) * + return param.bigb * Kokkos::exp(-param.lam2 * r) * (param.lam2 * ters_fc_k(param,r) - ters_dfc(param,r)); } @@ -764,7 +764,7 @@ void PairTersoffKokkos::ters_fa_k_and_ters_dfa(const ParamKokkos& pa fa = static_cast(0.0); dfa = static_cast(0.0); } else { - KK_FLOAT tmp1 = param.bigb * exp(-param.lam2 * r); + KK_FLOAT tmp1 = param.bigb * Kokkos::exp(-param.lam2 * r); KK_FLOAT fc_k, dfc; ters_fc_k_and_ters_dfc(param,r,fc_k,dfc); fa = -tmp1 * fc_k; @@ -780,13 +780,13 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffKokkos::ters_bij_k(const ParamKokkos& param, const KK_FLOAT &bo) const { const KK_FLOAT tmp = param.beta * bo; - if (tmp > param.c1) return static_cast(1.0)/sqrt(tmp); + if (tmp > param.c1) return static_cast(1.0)/Kokkos::sqrt(tmp); if (tmp > param.c2) - return (static_cast(1.0) - pow(tmp,-param.powern) / (static_cast(2.0)*param.powern))/sqrt(tmp); + return (static_cast(1.0) - Kokkos::pow(tmp,-param.powern) / (static_cast(2.0)*param.powern))/Kokkos::sqrt(tmp); if (tmp < param.c4) return static_cast(1.0); if (tmp < param.c3) - return static_cast(1.0) - pow(tmp,param.powern)/(static_cast(2.0)*param.powern); - return pow(static_cast(1.0) + pow(tmp,param.powern), static_cast(-1.0)/(static_cast(2.0)*param.powern)); + return static_cast(1.0) - Kokkos::pow(tmp,param.powern)/(static_cast(2.0)*param.powern); + return Kokkos::pow(static_cast(1.0) + Kokkos::pow(tmp,param.powern), static_cast(-1.0)/(static_cast(2.0)*param.powern)); } /* ---------------------------------------------------------------------- */ @@ -797,20 +797,20 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffKokkos::ters_dbij(const ParamKokkos& param, const KK_FLOAT &bo) const { const KK_FLOAT tmp = param.beta * bo; - const KK_FLOAT factor = static_cast(-0.5)/sqrt(tmp*tmp*tmp); //pow(tmp,-1.5) + const KK_FLOAT factor = static_cast(-0.5)/Kokkos::sqrt(tmp*tmp*tmp); //pow(tmp,-1.5) if (tmp > param.c1) return param.beta * factor; if (tmp > param.c2) return param.beta * (factor * // error in negligible 2nd term fixed 2/21/2022 // (1.0 - 0.5*(1.0 + 1.0/(2.0*param.powern)) * (static_cast(1.0) - (static_cast(1.0) + static_cast(0.5)/(param.powern)) * - pow(tmp,-param.powern))); + Kokkos::pow(tmp,-param.powern))); if (tmp < param.c4) return static_cast(0.0); if (tmp < param.c3) - return -static_cast(0.5)*param.beta * pow(tmp,param.powern-static_cast(1.0)); + return -static_cast(0.5)*param.beta * Kokkos::pow(tmp,param.powern-static_cast(1.0)); - const KK_FLOAT tmp_n = pow(tmp,param.powern); - return static_cast(-0.5) * pow(static_cast(1.0)+tmp_n, static_cast(-1.0)-(static_cast(0.5)/(param.powern)))*tmp_n / bo; + const KK_FLOAT tmp_n = Kokkos::pow(tmp,param.powern); + return static_cast(-0.5) * Kokkos::pow(static_cast(1.0)+tmp_n, static_cast(-1.0)-(static_cast(0.5)/(param.powern)))*tmp_n / bo; } /* ---------------------------------------------------------------------- */ @@ -821,9 +821,9 @@ KOKKOS_INLINE_FUNCTION void PairTersoffKokkos::ters_bij_k_and_ters_dbij(const ParamKokkos& param, const KK_FLOAT &bo, KK_FLOAT& bij, KK_FLOAT& prefactor) const { const KK_FLOAT tmp = param.beta * bo; - const KK_FLOAT factor = static_cast(-0.5)/sqrt(tmp*tmp*tmp); //pow(tmp,-1.5) + const KK_FLOAT factor = static_cast(-0.5)/Kokkos::sqrt(tmp*tmp*tmp); //pow(tmp,-1.5) if (tmp > param.c1) { - bij = static_cast(1.0)/sqrt(tmp); + bij = static_cast(1.0)/Kokkos::sqrt(tmp); prefactor = param.beta * factor; return; } @@ -831,8 +831,8 @@ void PairTersoffKokkos::ters_bij_k_and_ters_dbij(const ParamKokkos& auto prm_ijk_pn = param.powern; if (tmp > param.c2) { - auto tmp_pow_neg_prm_ijk_pn = pow(tmp,-prm_ijk_pn); - bij = (static_cast(1.0) - tmp_pow_neg_prm_ijk_pn / (static_cast(2.0)*prm_ijk_pn))/sqrt(tmp); + auto tmp_pow_neg_prm_ijk_pn = Kokkos::pow(tmp,-prm_ijk_pn); + bij = (static_cast(1.0) - tmp_pow_neg_prm_ijk_pn / (static_cast(2.0)*prm_ijk_pn))/Kokkos::sqrt(tmp); prefactor = param.beta * (factor * (static_cast(1.0) - static_cast(0.5)*(static_cast(1.0) + static_cast(0.5)/(prm_ijk_pn)) * tmp_pow_neg_prm_ijk_pn)); @@ -845,15 +845,15 @@ void PairTersoffKokkos::ters_bij_k_and_ters_dbij(const ParamKokkos& return; } if (tmp < param.c3) { - auto tmp_pow_prm_ijk_pn_less_one = pow(tmp,prm_ijk_pn-static_cast(1.0)); + auto tmp_pow_prm_ijk_pn_less_one = Kokkos::pow(tmp,prm_ijk_pn-static_cast(1.0)); bij = static_cast(1.0) - tmp_pow_prm_ijk_pn_less_one*tmp/(static_cast(2.0)*prm_ijk_pn); prefactor = static_cast(-0.5)*param.beta * tmp_pow_prm_ijk_pn_less_one; return; } - const KK_FLOAT tmp_n = pow(tmp,param.powern); - bij = pow(static_cast(1.0) + tmp_n, static_cast(-0.5)/(prm_ijk_pn)); - prefactor = static_cast(-0.5) * pow(static_cast(1.0)+tmp_n, static_cast(-1.0)-(static_cast(0.5)/(prm_ijk_pn)))*tmp_n / bo; + const KK_FLOAT tmp_n = Kokkos::pow(tmp,param.powern); + bij = Kokkos::pow(static_cast(1.0) + tmp_n, static_cast(-0.5)/(prm_ijk_pn)); + prefactor = static_cast(-0.5) * Kokkos::pow(static_cast(1.0)+tmp_n, static_cast(-1.0)-(static_cast(0.5)/(prm_ijk_pn)))*tmp_n / bo; } /* ---------------------------------------------------------------------- */ @@ -895,7 +895,7 @@ void PairTersoffKokkos::ters_dthb( if (tmp > static_cast(69.0776)) ex_delr = static_cast(1.e30); else if (tmp < static_cast(-69.0776)) ex_delr = static_cast(0.0); - else ex_delr = exp(tmp); + else ex_delr = Kokkos::exp(tmp); if (int(param.powerm) == 3) dex_delr = static_cast(3.0)*paramtmp*paramtmp*param.lam3*ex_delr;//pow(rij-rik,2.0)*ex_delr; @@ -965,7 +965,7 @@ void PairTersoffKokkos::ters_dthbj( if (tmp > static_cast(69.0776)) ex_delr = static_cast(1.e30); else if (tmp < static_cast(-69.0776)) ex_delr = static_cast(0.0); - else ex_delr = exp(tmp); + else ex_delr = Kokkos::exp(tmp); if (int(param.powerm) == 3) dex_delr = static_cast(3.0)*paramtmp*paramtmp*param.lam3*ex_delr;//pow(param.lam3,3.0) * pow(rij-rik,2.0)*ex_delr; @@ -1028,7 +1028,7 @@ void PairTersoffKokkos::ters_dthbk( if (tmp > static_cast(69.0776)) ex_delr = static_cast(1.e30); else if (tmp < static_cast(-69.0776)) ex_delr = static_cast(0.0); - else ex_delr = exp(tmp); + else ex_delr = Kokkos::exp(tmp); if (int(param.powerm) == 3) dex_delr = static_cast(3.0)*paramtmp*paramtmp*param.lam3*ex_delr;//pow(param.lam3,3.0) * pow(rij-rik,2.0)*ex_delr; diff --git a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp index aebf87904c1..820958e9133 100644 --- a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp @@ -253,14 +253,14 @@ void PairTersoffMODKokkos::compute(int eflag_in, int vflag_in) if (need_dup) Kokkos::Experimental::contribute(f, dup_f); - if (eflag_global) eng_vdwl += ev_all.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev_all.evdwl); if (vflag_global) { - virial[0] += ev_all.v[0]; - virial[1] += ev_all.v[1]; - virial[2] += ev_all.v[2]; - virial[3] += ev_all.v[3]; - virial[4] += ev_all.v[4]; - virial[5] += ev_all.v[5]; + virial[0] += static_cast(ev_all.v[0]); + virial[1] += static_cast(ev_all.v[1]); + virial[2] += static_cast(ev_all.v[2]); + virial[3] += static_cast(ev_all.v[3]); + virial[4] += static_cast(ev_all.v[4]); + virial[5] += static_cast(ev_all.v[5]); } if (eflag_atom) { @@ -299,7 +299,8 @@ void PairTersoffMODKokkos::operator()(TagPairTersoffMODComputeShortN const KK_FLOAT xtmp = x(i,0); const KK_FLOAT ytmp = x(i,1); const KK_FLOAT ztmp = x(i,2); - const KK_FLOAT cutmax_sq = cutmax*cutmax; + const KK_FLOAT cutmax_kk = static_cast(cutmax); + const KK_FLOAT cutmax_sq = cutmax_kk*cutmax_kk; const int jnum = d_numneigh[i]; int inside = 0; @@ -372,27 +373,27 @@ void PairTersoffMODKokkos::tersoff_mod_compute(const int &ii, EV_FLO const KK_FLOAT delz = ztmp - x(j,2); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; const int iparam_ij = d_elem3param(itype,jtype,jtype); - const KK_FLOAT cutsq = d_params(iparam_ij).cutsq; + const KK_FLOAT cutsq = static_cast(d_params(iparam_ij).cutsq); if (rsq >= cutsq) continue; - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT tmp_fce = ters_fc_k(d_params(iparam_ij),r); const KK_FLOAT tmp_fcd = ters_dfc(d_params(iparam_ij),r); - const KK_FLOAT tmp_exp = exp(-d_params(iparam_ij).lam1 * r); - const KK_FLOAT frep = -d_params(iparam_ij).biga * tmp_exp * - (tmp_fcd - tmp_fce*d_params(iparam_ij).lam1) / r; - const KK_FLOAT eng = tmp_fce * d_params(iparam_ij).biga * tmp_exp; - - f_x += delx*frep; - f_y += dely*frep; - f_z += delz*frep; - a_f(j,0) -= delx*frep; - a_f(j,1) -= dely*frep; - a_f(j,2) -= delz*frep; + const KK_FLOAT tmp_exp = Kokkos::exp(-static_cast(d_params(iparam_ij).lam1) * r); + const KK_FLOAT frep = -static_cast(d_params(iparam_ij).biga) * tmp_exp * + (tmp_fcd - tmp_fce*static_cast(d_params(iparam_ij).lam1)) / r; + const KK_FLOAT eng = tmp_fce * static_cast(d_params(iparam_ij).biga) * tmp_exp; + + f_x += static_cast(delx*frep); + f_y += static_cast(dely*frep); + f_z += static_cast(delz*frep); + a_f(j,0) -= static_cast(delx*frep); + a_f(j,1) -= static_cast(dely*frep); + a_f(j,2) -= static_cast(delz*frep); if (EVFLAG) { - if (eflag) ev.evdwl += eng; + if (eflag) ev.evdwl += static_cast(eng); if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,eng,frep,delx,dely,delz); } } @@ -408,11 +409,11 @@ void PairTersoffMODKokkos::tersoff_mod_compute(const int &ii, EV_FLO const KK_FLOAT delz1 = ztmp - x(j,2); const KK_FLOAT rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; const int iparam_ij = d_elem3param(itype,jtype,jtype); - const KK_FLOAT cutsq1 = d_params(iparam_ij).cutsq; + const KK_FLOAT cutsq1 = static_cast(d_params(iparam_ij).cutsq); KK_FLOAT bo_ij = 0.0; if (rsq1 > cutsq1) continue; - const KK_FLOAT rij = sqrt(rsq1); + const KK_FLOAT rij = Kokkos::sqrt(rsq1); for (int kk = 0; kk < jnum; kk++) { if (jj == kk) continue; @@ -424,10 +425,10 @@ void PairTersoffMODKokkos::tersoff_mod_compute(const int &ii, EV_FLO const KK_FLOAT delz2 = ztmp - x(k,2); const KK_FLOAT rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; const int iparam_ijk = d_elem3param(itype,jtype,ktype); - const KK_FLOAT cutsq2 = d_params(iparam_ijk).cutsq; + const KK_FLOAT cutsq2 = static_cast(d_params(iparam_ijk).cutsq); if (rsq2 > cutsq2) continue; - const KK_FLOAT rik = sqrt(rsq2); + const KK_FLOAT rik = Kokkos::sqrt(rsq2); bo_ij += bondorder(d_params(iparam_ijk),rij,delx1,dely1,delz1,rik,delx2,dely2,delz2); } @@ -436,19 +437,19 @@ void PairTersoffMODKokkos::tersoff_mod_compute(const int &ii, EV_FLO const KK_FLOAT fa = ters_fa_k(d_params(iparam_ij),rij); const KK_FLOAT dfa = ters_dfa(d_params(iparam_ij),rij); const KK_FLOAT bij = ters_bij_k(d_params(iparam_ij),bo_ij); - const KK_FLOAT fatt = -0.5*bij * dfa / rij; - const KK_FLOAT prefactor = 0.5*fa * ters_dbij(d_params(iparam_ij),bo_ij); + const KK_FLOAT fatt = -static_cast(0.5)*bij * dfa / rij; + const KK_FLOAT prefactor = static_cast(0.5)*fa * ters_dbij(d_params(iparam_ij),bo_ij); - f_x += delx1*fatt; - f_y += dely1*fatt; - f_z += delz1*fatt; - KK_ACC_FLOAT fj_x = -delx1*fatt; - KK_ACC_FLOAT fj_y = -dely1*fatt; - KK_ACC_FLOAT fj_z = -delz1*fatt; + f_x += static_cast(delx1*fatt); + f_y += static_cast(dely1*fatt); + f_z += static_cast(delz1*fatt); + KK_ACC_FLOAT fj_x = static_cast(-delx1*fatt); + KK_ACC_FLOAT fj_y = static_cast(-dely1*fatt); + KK_ACC_FLOAT fj_z = static_cast(-delz1*fatt); if (EVFLAG) { - const KK_FLOAT eng = 0.5*bij * fa; - if (eflag) ev.evdwl += eng; + const KK_FLOAT eng = static_cast(0.5)*bij * fa; + if (eflag) ev.evdwl += static_cast(eng); if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,eng,fatt,delx1,dely1,delz1); } @@ -465,10 +466,10 @@ void PairTersoffMODKokkos::tersoff_mod_compute(const int &ii, EV_FLO const KK_FLOAT delz2 = ztmp - x(k,2); const KK_FLOAT rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; const int iparam_ijk = d_elem3param(itype,jtype,ktype); - const KK_FLOAT cutsq2 = d_params(iparam_ijk).cutsq; + const KK_FLOAT cutsq2 = static_cast(d_params(iparam_ijk).cutsq); if (rsq2 > cutsq2) continue; - const KK_FLOAT rik = sqrt(rsq2); + const KK_FLOAT rik = Kokkos::sqrt(rsq2); ters_dthb(d_params(iparam_ijk),prefactor,rij,delx1,dely1,delz1, rik,delx2,dely2,delz2,fi,fj,fk); @@ -567,13 +568,13 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffMODKokkos::ters_fc_k(const Param& param, const KK_FLOAT &r) const { - const KK_FLOAT ters_R = param.bigr; - const KK_FLOAT ters_D = param.bigd; + const KK_FLOAT ters_R = static_cast(param.bigr); + const KK_FLOAT ters_D = static_cast(param.bigd); if (r < ters_R-ters_D) return 1.0; if (r > ters_R+ters_D) return 0.0; - return 0.5*(1.0 - 1.125*sin(MY_PI2*(r - ters_R)/ters_D) - - 0.125*sin(3.0*MY_PI2*(r - ters_R)/ters_D)); + return static_cast(0.5)*(static_cast(1.0) - static_cast(1.125)*Kokkos::sin(static_cast(MY_PI2)*(r - ters_R)/ters_D) - + static_cast(0.125)*Kokkos::sin(static_cast(3.0)*static_cast(MY_PI2)*(r - ters_R)/ters_D)); } /* ---------------------------------------------------------------------- */ @@ -583,13 +584,13 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffMODKokkos::ters_dfc(const Param& param, const KK_FLOAT &r) const { - const KK_FLOAT ters_R = param.bigr; - const KK_FLOAT ters_D = param.bigd; + const KK_FLOAT ters_R = static_cast(param.bigr); + const KK_FLOAT ters_D = static_cast(param.bigd); if (r < ters_R-ters_D) return 0.0; if (r > ters_R+ters_D) return 0.0; - return -(0.375*MY_PI4/ters_D) * (3.0*cos(MY_PI2*(r - ters_R)/ters_D) + - cos(3.0*MY_PI2*(r - ters_R)/ters_D)); + return -(static_cast(0.375)*static_cast(MY_PI4)/ters_D) * (static_cast(3.0)*Kokkos::cos(static_cast(MY_PI2)*(r - ters_R)/ters_D) + + Kokkos::cos(static_cast(3.0)*static_cast(MY_PI2)*(r - ters_R)/ters_D)); } /* ---------------------------------------------------------------------- */ @@ -605,13 +606,13 @@ KK_FLOAT PairTersoffMODKokkos::bondorder(const Param& param, const KK_FLOAT costheta = (dx1*dx2 + dy1*dy2 + dz1*dz2)/(rij*rik); - const KK_FLOAT paramtmp = param.lam3 * (rij-rik); + const KK_FLOAT paramtmp = static_cast(param.lam3) * (rij-rik); if (int(param.powerm) == 3) arg = paramtmp*paramtmp*paramtmp;//pow(param.lam3 * (rij-rik),3.0); else arg = paramtmp; - if (arg > 69.0776) ex_delr = 1.e30; - else if (arg < -69.0776) ex_delr = 0.0; - else ex_delr = exp(arg); + if (arg > static_cast(69.0776)) ex_delr = static_cast(1.e30); + else if (arg < static_cast(-69.0776)) ex_delr = 0.0; + else ex_delr = Kokkos::exp(arg); return ters_fc_k(param,rik) * ters_gijk(param,costheta) * ex_delr; } @@ -624,15 +625,15 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffMODKokkos:: ters_gijk(const Param& param, const KK_FLOAT &cos) const { - const KK_FLOAT ters_c1 = param.c1; - const KK_FLOAT ters_c2 = param.c2; - const KK_FLOAT ters_c3 = param.c3; - const KK_FLOAT ters_c4 = param.c4; - const KK_FLOAT ters_c5 = param.c5; - const KK_FLOAT tmp_h = (param.h - cos)*(param.h - cos); + const KK_FLOAT ters_c1 = static_cast(param.c1); + const KK_FLOAT ters_c2 = static_cast(param.c2); + const KK_FLOAT ters_c3 = static_cast(param.c3); + const KK_FLOAT ters_c4 = static_cast(param.c4); + const KK_FLOAT ters_c5 = static_cast(param.c5); + const KK_FLOAT tmp_h = (static_cast(param.h) - cos)*(static_cast(param.h) - cos); return ters_c1 + (ters_c2*tmp_h/(ters_c3 + tmp_h)) * - (1.0 + ters_c4*exp(-ters_c5*tmp_h)); + (static_cast(1.0) + ters_c4*Kokkos::exp(-ters_c5*tmp_h)); } @@ -644,15 +645,15 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffMODKokkos:: ters_dgijk(const Param& param, const KK_FLOAT &cos) const { - const KK_FLOAT ters_c2 = param.c2; - const KK_FLOAT ters_c3 = param.c3; - const KK_FLOAT ters_c4 = param.c4; - const KK_FLOAT ters_c5 = param.c5; - const KK_FLOAT tmp_h = (param.h - cos)*(param.h - cos); - const KK_FLOAT g1 = (param.h - cos)/(ters_c3 + tmp_h); - const KK_FLOAT g2 = exp(-ters_c5*tmp_h); - - return -2.0*ters_c2*g1*((1 + ters_c4*g2)*(1 + g1*(cos - param.h)) - + const KK_FLOAT ters_c2 = static_cast(param.c2); + const KK_FLOAT ters_c3 = static_cast(param.c3); + const KK_FLOAT ters_c4 = static_cast(param.c4); + const KK_FLOAT ters_c5 = static_cast(param.c5); + const KK_FLOAT tmp_h = (static_cast(param.h) - cos)*(static_cast(param.h) - cos); + const KK_FLOAT g1 = (static_cast(param.h) - cos)/(ters_c3 + tmp_h); + const KK_FLOAT g2 = Kokkos::exp(-ters_c5*tmp_h); + + return -static_cast(2.0)*ters_c2*g1*((1 + ters_c4*g2)*(1 + g1*(cos - static_cast(param.h))) - tmp_h*ters_c4*ters_c5*g2); } @@ -663,8 +664,8 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffMODKokkos::ters_fa_k(const Param& param, const KK_FLOAT &r) const { - if (r > param.bigr + param.bigd) return 0.0; - return -param.bigb * exp(-param.lam2 * r) + if (r > static_cast(param.bigr) + static_cast(param.bigd)) return 0.0; + return -static_cast(param.bigb) * Kokkos::exp(-static_cast(param.lam2) * r) * ters_fc_k(param,r); } @@ -675,9 +676,9 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffMODKokkos::ters_dfa(const Param& param, const KK_FLOAT &r) const { - if (r > param.bigr + param.bigd) return 0.0; - return param.bigb * exp(-param.lam2 * r) * - (param.lam2 * ters_fc_k(param,r) - ters_dfc(param,r)); + if (r > static_cast(param.bigr) + static_cast(param.bigd)) return 0.0; + return static_cast(param.bigb) * Kokkos::exp(-static_cast(param.lam2) * r) * + (static_cast(param.lam2) * ters_fc_k(param,r) - ters_dfc(param,r)); } /* ---------------------------------------------------------------------- */ @@ -687,12 +688,14 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffMODKokkos::ters_bij_k(const Param& param, const KK_FLOAT &bo) const { - const KK_FLOAT tmp = param.beta * bo; - if (tmp > param.ca1) - return pow(tmp, -param.powern/(2.0*param.powern_del)); - if (tmp < param.ca4) + const KK_FLOAT tmp = static_cast(param.beta) * bo; + const KK_FLOAT powern_kk = static_cast(param.powern); + const KK_FLOAT powern_del_kk = static_cast(param.powern_del); + if (tmp > static_cast(param.ca1)) + return Kokkos::pow(tmp, -powern_kk/(static_cast(2.0)*powern_del_kk)); + if (tmp < static_cast(param.ca4)) return 1.0; - return pow(1.0 + pow(tmp,param.powern), -1.0/(2.0*param.powern_del)); + return Kokkos::pow(static_cast(1.0) + Kokkos::pow(tmp,powern_kk), -static_cast(1.0)/(static_cast(2.0)*powern_del_kk)); } /* ---------------------------------------------------------------------- */ @@ -702,16 +705,18 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffMODKokkos::ters_dbij(const Param& param, const KK_FLOAT &bo) const { - const KK_FLOAT tmp = param.beta * bo; - if (tmp > param.ca1) - return -0.5*(param.powern/param.powern_del)* - pow(tmp,-0.5*(param.powern/param.powern_del)) / bo; - if (tmp < param.ca4) + const KK_FLOAT tmp = static_cast(param.beta) * bo; + const KK_FLOAT powern_kk = static_cast(param.powern); + const KK_FLOAT powern_del_kk = static_cast(param.powern_del); + if (tmp > static_cast(param.ca1)) + return -static_cast(0.5)*(powern_kk/powern_del_kk)* + Kokkos::pow(tmp,-static_cast(0.5)*(powern_kk/powern_del_kk)) / bo; + if (tmp < static_cast(param.ca4)) return 0.0; - const KK_FLOAT tmp_n = pow(tmp,param.powern); - return -0.5 *(param.powern/param.powern_del)* - pow(1.0+tmp_n, -1.0-(1.0/(2.0*param.powern_del)))*tmp_n / bo; + const KK_FLOAT tmp_n = Kokkos::pow(tmp,powern_kk); + return -static_cast(0.5) *(powern_kk/powern_del_kk)* + Kokkos::pow(static_cast(1.0)+tmp_n, -static_cast(1.0)-(static_cast(1.0)/(static_cast(2.0)*powern_del_kk)))*tmp_n / bo; } /* ---------------------------------------------------------------------- */ @@ -734,11 +739,11 @@ void PairTersoffMODKokkos::ters_dthb( delrik[0] = dx2; delrik[1] = dy2; delrik[2] = dz2; //rij = sqrt(rsq1); - rijinv = 1.0/rij; + rijinv = static_cast(1.0)/rij; vec3_scale(rijinv,delrij,rij_hat); //rik = sqrt(rsq2); - rikinv = 1.0/rik; + rikinv = static_cast(1.0)/rik; vec3_scale(rikinv,delrik,rik_hat); // from PairTersoffMOD::ters_zetaterm_d @@ -748,17 +753,17 @@ void PairTersoffMODKokkos::ters_dthb( fc = ters_fc_k(param,rik); dfc = ters_dfc(param,rik); - const KK_FLOAT paramtmp = param.lam3 * (rij-rik); + const KK_FLOAT paramtmp = static_cast(param.lam3) * (rij-rik); if (int(param.powerm) == 3) tmp = paramtmp*paramtmp*paramtmp;//pow(param.lam3 * (rij-rik),3.0); else tmp = paramtmp; - if (tmp > 69.0776) ex_delr = 1.e30; - else if (tmp < -69.0776) ex_delr = 0.0; - else ex_delr = exp(tmp); + if (tmp > static_cast(69.0776)) ex_delr = static_cast(1.e30); + else if (tmp < static_cast(-69.0776)) ex_delr = 0.0; + else ex_delr = Kokkos::exp(tmp); if (int(param.powerm) == 3) - dex_delr = 3.0*paramtmp*paramtmp*param.lam3*ex_delr;//pow(rij-rik,2.0)*ex_delr; - else dex_delr = param.lam3 * ex_delr; + dex_delr = static_cast(3.0)*paramtmp*paramtmp*static_cast(param.lam3)*ex_delr;//pow(rij-rik,2.0)*ex_delr; + else dex_delr = static_cast(param.lam3) * ex_delr; cos = vec3_dot(rij_hat,rik_hat); gijk = ters_gijk(param,cos); @@ -807,10 +812,10 @@ void PairTersoffMODKokkos::ters_dthbj( delrij[0] = dx1; delrij[1] = dy1; delrij[2] = dz1; delrik[0] = dx2; delrik[1] = dy2; delrik[2] = dz2; - rijinv = 1.0/rij; + rijinv = static_cast(1.0)/rij; vec3_scale(rijinv,delrij,rij_hat); - rikinv = 1.0/rik; + rikinv = static_cast(1.0)/rik; vec3_scale(rikinv,delrik,rik_hat); KK_FLOAT gijk,dgijk,ex_delr,dex_delr,fc,dfc,cos,tmp; @@ -818,17 +823,17 @@ void PairTersoffMODKokkos::ters_dthbj( fc = ters_fc_k(param,rik); dfc = ters_dfc(param,rik); - const KK_FLOAT paramtmp = param.lam3 * (rij-rik); + const KK_FLOAT paramtmp = static_cast(param.lam3) * (rij-rik); if (int(param.powerm) == 3) tmp = paramtmp*paramtmp*paramtmp;//pow(param.lam3 * (rij-rik),3.0); else tmp = paramtmp; - if (tmp > 69.0776) ex_delr = 1.e30; - else if (tmp < -69.0776) ex_delr = 0.0; - else ex_delr = exp(tmp); + if (tmp > static_cast(69.0776)) ex_delr = static_cast(1.e30); + else if (tmp < static_cast(-69.0776)) ex_delr = 0.0; + else ex_delr = Kokkos::exp(tmp); if (int(param.powerm) == 3) - dex_delr = 3.0*paramtmp*paramtmp*param.lam3*ex_delr;//pow(param.lam3,3.0) * pow(rij-rik,2.0)*ex_delr; - else dex_delr = param.lam3 * ex_delr; + dex_delr = static_cast(3.0)*paramtmp*paramtmp*static_cast(param.lam3)*ex_delr;//pow(param.lam3,3.0) * pow(rij-rik,2.0)*ex_delr; + else dex_delr = static_cast(param.lam3) * ex_delr; cos = vec3_dot(rij_hat,rik_hat); gijk = ters_gijk(param,cos); @@ -870,10 +875,10 @@ void PairTersoffMODKokkos::ters_dthbk( delrij[0] = dx1; delrij[1] = dy1; delrij[2] = dz1; delrik[0] = dx2; delrik[1] = dy2; delrik[2] = dz2; - rijinv = 1.0/rij; + rijinv = static_cast(1.0)/rij; vec3_scale(rijinv,delrij,rij_hat); - rikinv = 1.0/rik; + rikinv = static_cast(1.0)/rik; vec3_scale(rikinv,delrik,rik_hat); KK_FLOAT gijk,dgijk,ex_delr,dex_delr,fc,dfc,cos,tmp; @@ -881,17 +886,17 @@ void PairTersoffMODKokkos::ters_dthbk( fc = ters_fc_k(param,rik); dfc = ters_dfc(param,rik); - const KK_FLOAT paramtmp = param.lam3 * (rij-rik); + const KK_FLOAT paramtmp = static_cast(param.lam3) * (rij-rik); if (int(param.powerm) == 3) tmp = paramtmp*paramtmp*paramtmp;//pow(param.lam3 * (rij-rik),3.0); else tmp = paramtmp; - if (tmp > 69.0776) ex_delr = 1.e30; - else if (tmp < -69.0776) ex_delr = 0.0; - else ex_delr = exp(tmp); + if (tmp > static_cast(69.0776)) ex_delr = static_cast(1.e30); + else if (tmp < static_cast(-69.0776)) ex_delr = 0.0; + else ex_delr = Kokkos::exp(tmp); if (int(param.powerm) == 3) - dex_delr = 3.0*paramtmp*paramtmp*param.lam3*ex_delr;//pow(param.lam3,3.0) * pow(rij-rik,2.0)*ex_delr; - else dex_delr = param.lam3 * ex_delr; + dex_delr = static_cast(3.0)*paramtmp*paramtmp*static_cast(param.lam3)*ex_delr;//pow(param.lam3,3.0) * pow(rij-rik,2.0)*ex_delr; + else dex_delr = static_cast(param.lam3) * ex_delr; cos = vec3_dot(rij_hat,rik_hat); gijk = ters_gijk(param,cos); @@ -929,9 +934,9 @@ void PairTersoffMODKokkos::ev_tally(EV_FLOAT &ev, const int &i, cons auto a_vatom = v_vatom.template access>(); if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; - a_eatom[i] += epairhalf; - a_eatom[j] += epairhalf; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; + a_eatom[i] += static_cast(epairhalf); + a_eatom[j] += static_cast(epairhalf); } if (vflag_either) { @@ -943,28 +948,28 @@ void PairTersoffMODKokkos::ev_tally(EV_FLOAT &ev, const int &i, cons const KK_FLOAT v5 = dely*delz*fpair; if (vflag_global) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } if (vflag_atom) { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; - - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; + a_vatom(i,0) += static_cast(static_cast(0.5)*v0); + a_vatom(i,1) += static_cast(static_cast(0.5)*v1); + a_vatom(i,2) += static_cast(static_cast(0.5)*v2); + a_vatom(i,3) += static_cast(static_cast(0.5)*v3); + a_vatom(i,4) += static_cast(static_cast(0.5)*v4); + a_vatom(i,5) += static_cast(static_cast(0.5)*v5); + + a_vatom(j,0) += static_cast(static_cast(0.5)*v0); + a_vatom(j,1) += static_cast(static_cast(0.5)*v1); + a_vatom(j,2) += static_cast(static_cast(0.5)*v2); + a_vatom(j,3) += static_cast(static_cast(0.5)*v3); + a_vatom(j,4) += static_cast(static_cast(0.5)*v4); + a_vatom(j,5) += static_cast(static_cast(0.5)*v5); } } } @@ -985,38 +990,38 @@ void PairTersoffMODKokkos::v_tally3(EV_FLOAT &ev, const int &i, cons KK_FLOAT v[6]; - v[0] = (drij[0]*fj[0] + drik[0]*fk[0]); - v[1] = (drij[1]*fj[1] + drik[1]*fk[1]); - v[2] = (drij[2]*fj[2] + drik[2]*fk[2]); - v[3] = (drij[0]*fj[1] + drik[0]*fk[1]); - v[4] = (drij[0]*fj[2] + drik[0]*fk[2]); - v[5] = (drij[1]*fj[2] + drik[1]*fk[2]); + v[0] = (drij[0]*static_cast(fj[0]) + drik[0]*static_cast(fk[0])); + v[1] = (drij[1]*static_cast(fj[1]) + drik[1]*static_cast(fk[1])); + v[2] = (drij[2]*static_cast(fj[2]) + drik[2]*static_cast(fk[2])); + v[3] = (drij[0]*static_cast(fj[1]) + drik[0]*static_cast(fk[1])); + v[4] = (drij[0]*static_cast(fj[2]) + drik[0]*static_cast(fk[2])); + v[5] = (drij[1]*static_cast(fj[2]) + drik[1]*static_cast(fk[2])); if (vflag_global) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } if (vflag_atom) { - v[0] *= THIRD; - v[1] *= THIRD; - v[2] *= THIRD; - v[3] *= THIRD; - v[4] *= THIRD; - v[5] *= THIRD; + v[0] *= static_cast(THIRD); + v[1] *= static_cast(THIRD); + v[2] *= static_cast(THIRD); + v[3] *= static_cast(THIRD); + v[4] *= static_cast(THIRD); + v[5] *= static_cast(THIRD); - a_vatom(i,0) += v[0]; a_vatom(i,1) += v[1]; a_vatom(i,2) += v[2]; - a_vatom(i,3) += v[3]; a_vatom(i,4) += v[4]; a_vatom(i,5) += v[5]; + a_vatom(i,0) += static_cast(v[0]); a_vatom(i,1) += static_cast(v[1]); a_vatom(i,2) += static_cast(v[2]); + a_vatom(i,3) += static_cast(v[3]); a_vatom(i,4) += static_cast(v[4]); a_vatom(i,5) += static_cast(v[5]); - a_vatom(j,0) += v[0]; a_vatom(j,1) += v[1]; a_vatom(j,2) += v[2]; - a_vatom(j,3) += v[3]; a_vatom(j,4) += v[4]; a_vatom(j,5) += v[5]; + a_vatom(j,0) += static_cast(v[0]); a_vatom(j,1) += static_cast(v[1]); a_vatom(j,2) += static_cast(v[2]); + a_vatom(j,3) += static_cast(v[3]); a_vatom(j,4) += static_cast(v[4]); a_vatom(j,5) += static_cast(v[5]); - a_vatom(k,0) += v[0]; a_vatom(k,1) += v[1]; a_vatom(k,2) += v[2]; - a_vatom(k,3) += v[3]; a_vatom(k,4) += v[4]; a_vatom(k,5) += v[5]; + a_vatom(k,0) += static_cast(v[0]); a_vatom(k,1) += static_cast(v[1]); a_vatom(k,2) += static_cast(v[2]); + a_vatom(k,3) += static_cast(v[3]); a_vatom(k,4) += static_cast(v[4]); a_vatom(k,5) += static_cast(v[5]); } } @@ -1032,25 +1037,25 @@ void PairTersoffMODKokkos::v_tally3_atom(EV_FLOAT &ev, const int &i, { KK_FLOAT v[6]; - v[0] = THIRD * (drji[0]*fj[0] + drjk[0]*fk[0]); - v[1] = THIRD * (drji[1]*fj[1] + drjk[1]*fk[1]); - v[2] = THIRD * (drji[2]*fj[2] + drjk[2]*fk[2]); - v[3] = THIRD * (drji[0]*fj[1] + drjk[0]*fk[1]); - v[4] = THIRD * (drji[0]*fj[2] + drjk[0]*fk[2]); - v[5] = THIRD * (drji[1]*fj[2] + drjk[1]*fk[2]); + v[0] = static_cast(THIRD) * (drji[0]*static_cast(fj[0]) + drjk[0]*static_cast(fk[0])); + v[1] = static_cast(THIRD) * (drji[1]*static_cast(fj[1]) + drjk[1]*static_cast(fk[1])); + v[2] = static_cast(THIRD) * (drji[2]*static_cast(fj[2]) + drjk[2]*static_cast(fk[2])); + v[3] = static_cast(THIRD) * (drji[0]*static_cast(fj[1]) + drjk[0]*static_cast(fk[1])); + v[4] = static_cast(THIRD) * (drji[0]*static_cast(fj[2]) + drjk[0]*static_cast(fk[2])); + v[5] = static_cast(THIRD) * (drji[1]*static_cast(fj[2]) + drjk[1]*static_cast(fk[2])); if (vflag_global) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } if (vflag_atom) { - d_vatom(i,0) += v[0]; d_vatom(i,1) += v[1]; d_vatom(i,2) += v[2]; - d_vatom(i,3) += v[3]; d_vatom(i,4) += v[4]; d_vatom(i,5) += v[5]; + d_vatom(i,0) += static_cast(v[0]); d_vatom(i,1) += static_cast(v[1]); d_vatom(i,2) += static_cast(v[2]); + d_vatom(i,3) += static_cast(v[3]); d_vatom(i,4) += static_cast(v[4]); d_vatom(i,5) += static_cast(v[5]); } } diff --git a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp index c3c85d7b4e6..f5eba7086dc 100644 --- a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp @@ -66,12 +66,12 @@ PairTersoffZBLKokkos::PairTersoffZBLKokkos(LAMMPS *lmp) : PairTersof datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK; if (strcmp(update->unit_style,"metal") == 0) { - global_a_0 = 0.529; - global_epsilon_0 = 0.00552635; + global_a_0 = static_cast(0.529); + global_epsilon_0 = static_cast(0.00552635); global_e = 1.0; } else if (strcmp(update->unit_style,"real") == 0) { - global_a_0 = 0.529; - global_epsilon_0 = 0.00552635 * 0.043365121; + global_a_0 = static_cast(0.529); + global_epsilon_0 = static_cast(0.00552635 * 0.043365121); global_e = 1.0; } else error->all(FLERR,"Pair tersoff/zbl/kk requires metal or real units"); @@ -266,14 +266,14 @@ void PairTersoffZBLKokkos::compute(int eflag_in, int vflag_in) if (need_dup) Kokkos::Experimental::contribute(f, dup_f); - if (eflag_global) eng_vdwl += ev_all.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev_all.evdwl); if (vflag_global) { - virial[0] += ev_all.v[0]; - virial[1] += ev_all.v[1]; - virial[2] += ev_all.v[2]; - virial[3] += ev_all.v[3]; - virial[4] += ev_all.v[4]; - virial[5] += ev_all.v[5]; + virial[0] += static_cast(ev_all.v[0]); + virial[1] += static_cast(ev_all.v[1]); + virial[2] += static_cast(ev_all.v[2]); + virial[3] += static_cast(ev_all.v[3]); + virial[4] += static_cast(ev_all.v[4]); + virial[5] += static_cast(ev_all.v[5]); } if (eflag_atom) { @@ -312,7 +312,8 @@ void PairTersoffZBLKokkos::operator()(TagPairTersoffZBLComputeShortN const KK_FLOAT xtmp = x(i,0); const KK_FLOAT ytmp = x(i,1); const KK_FLOAT ztmp = x(i,2); - const KK_FLOAT cutmax_sq = cutmax*cutmax; + const KK_FLOAT cutmax_kk = static_cast(cutmax); + const KK_FLOAT cutmax_sq = cutmax_kk*cutmax_kk; const int jnum = d_numneigh[i]; int inside = 0; @@ -385,57 +386,57 @@ void PairTersoffZBLKokkos::tersoff_zbl_compute(const int &ii, EV_FLO const KK_FLOAT delz = ztmp - x(j,2); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; const int iparam_ij = d_elem3param(itype,jtype,jtype); - const KK_FLOAT cutsq = d_params(iparam_ij).cutsq; + const KK_FLOAT cutsq = static_cast(d_params(iparam_ij).cutsq); if (rsq > cutsq) continue; // Tersoff repulsive portion - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); const KK_FLOAT tmp_fce = ters_fc_k(d_params(iparam_ij),r); const KK_FLOAT tmp_fcd = ters_dfc(d_params(iparam_ij),r); - const KK_FLOAT tmp_exp = exp(-d_params(iparam_ij).lam1 * r); - const KK_FLOAT frep_t = d_params(iparam_ij).biga * tmp_exp * - (tmp_fcd - tmp_fce*d_params(iparam_ij).lam1); - const KK_FLOAT eng_t = tmp_fce * d_params(iparam_ij).biga * tmp_exp; + const KK_FLOAT tmp_exp = Kokkos::exp(-static_cast(d_params(iparam_ij).lam1) * r); + const KK_FLOAT frep_t = static_cast(d_params(iparam_ij).biga) * tmp_exp * + (tmp_fcd - tmp_fce*static_cast(d_params(iparam_ij).lam1)); + const KK_FLOAT eng_t = tmp_fce * static_cast(d_params(iparam_ij).biga) * tmp_exp; // ZBL repulsive portion - const KK_FLOAT esq = pow(global_e,2.0); - const KK_FLOAT a_ij = (0.8854*global_a_0) / - (pow(d_params(iparam_ij).Z_i,0.23) + pow(d_params(iparam_ij).Z_j,0.23)); - const KK_FLOAT premult = (d_params(iparam_ij).Z_i * d_params(iparam_ij).Z_j * esq)/ - (4.0*MY_PI*global_epsilon_0); + const KK_FLOAT esq = Kokkos::pow(global_e,static_cast(2.0)); + const KK_FLOAT a_ij = (static_cast(0.8854)*global_a_0) / + static_cast(pow(d_params(iparam_ij).Z_i,0.23) + pow(d_params(iparam_ij).Z_j,0.23)); + const KK_FLOAT premult = (static_cast(d_params(iparam_ij).Z_i) * static_cast(d_params(iparam_ij).Z_j) * esq)/ + (static_cast(4.0)*static_cast(MY_PI)*global_epsilon_0); const KK_FLOAT r_ov_a = r/a_ij; - const KK_FLOAT phi = 0.1818*exp(-3.2*r_ov_a) + 0.5099*exp(-0.9423*r_ov_a) + - 0.2802*exp(-0.4029*r_ov_a) + 0.02817*exp(-0.2016*r_ov_a); - const KK_FLOAT dphi = (1.0/a_ij) * (-3.2*0.1818*exp(-3.2*r_ov_a) - - 0.9423*0.5099*exp(-0.9423*r_ov_a) - - 0.4029*0.2802*exp(-0.4029*r_ov_a) - - 0.2016*0.02817*exp(-0.2016*r_ov_a)); + const KK_FLOAT phi = static_cast(0.1818)*Kokkos::exp(static_cast(-3.2)*r_ov_a) + static_cast(0.5099)*Kokkos::exp(static_cast(-0.9423)*r_ov_a) + + static_cast(0.2802)*Kokkos::exp(static_cast(-0.4029)*r_ov_a) + static_cast(0.02817)*Kokkos::exp(static_cast(-0.2016)*r_ov_a); + const KK_FLOAT dphi = (static_cast(1.0)/a_ij) * (static_cast(-3.2*0.1818)*Kokkos::exp(static_cast(-3.2)*r_ov_a) - + static_cast(0.9423*0.5099)*Kokkos::exp(static_cast(-0.9423)*r_ov_a) - + static_cast(0.4029*0.2802)*Kokkos::exp(static_cast(-0.4029)*r_ov_a) - + static_cast(0.2016*0.02817)*Kokkos::exp(static_cast(-0.2016)*r_ov_a)); const KK_FLOAT frep_z = premult*-phi/rsq + premult*dphi/r; - const KK_FLOAT eng_z = premult*(1.0/r)*phi; + const KK_FLOAT eng_z = premult*(static_cast(1.0)/r)*phi; // combine two parts with smoothing by Fermi-like function KK_FLOAT frep, eng; frep = -(-fermi_d_k(d_params(iparam_ij),r) * eng_z + - (1.0 - fermi_k(d_params(iparam_ij),r))*frep_z + + (static_cast(1.0) - fermi_k(d_params(iparam_ij),r))*frep_z + fermi_d_k(d_params(iparam_ij),r)*eng_t + fermi_k(d_params(iparam_ij),r)*frep_t) / r; if (eflag) - eng = (1.0 - fermi_k(d_params(iparam_ij),r)) * eng_z + + eng = (static_cast(1.0) - fermi_k(d_params(iparam_ij),r)) * eng_z + fermi_k(d_params(iparam_ij),r) * eng_t; - f_x += delx*frep; - f_y += dely*frep; - f_z += delz*frep; - a_f(j,0) -= delx*frep; - a_f(j,1) -= dely*frep; - a_f(j,2) -= delz*frep; + f_x += static_cast(delx*frep); + f_y += static_cast(dely*frep); + f_z += static_cast(delz*frep); + a_f(j,0) -= static_cast(delx*frep); + a_f(j,1) -= static_cast(dely*frep); + a_f(j,2) -= static_cast(delz*frep); if (EVFLAG) { - if (eflag) ev.evdwl += eng; + if (eflag) ev.evdwl += static_cast(eng); if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,eng,frep,delx,dely,delz); } } @@ -451,11 +452,11 @@ void PairTersoffZBLKokkos::tersoff_zbl_compute(const int &ii, EV_FLO const KK_FLOAT delz1 = ztmp - x(j,2); const KK_FLOAT rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; const int iparam_ij = d_elem3param(itype,jtype,jtype); - const KK_FLOAT cutsq1 = d_params(iparam_ij).cutsq; + const KK_FLOAT cutsq1 = static_cast(d_params(iparam_ij).cutsq); KK_FLOAT bo_ij = 0.0; if (rsq1 > cutsq1) continue; - const KK_FLOAT rij = sqrt(rsq1); + const KK_FLOAT rij = Kokkos::sqrt(rsq1); for (int kk = 0; kk < jnum; kk++) { if (jj == kk) continue; @@ -467,10 +468,10 @@ void PairTersoffZBLKokkos::tersoff_zbl_compute(const int &ii, EV_FLO const KK_FLOAT delz2 = ztmp - x(k,2); const KK_FLOAT rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; const int iparam_ijk = d_elem3param(itype,jtype,ktype); - const KK_FLOAT cutsq2 = d_params(iparam_ijk).cutsq; + const KK_FLOAT cutsq2 = static_cast(d_params(iparam_ijk).cutsq); if (rsq2 > cutsq2) continue; - const KK_FLOAT rik = sqrt(rsq2); + const KK_FLOAT rik = Kokkos::sqrt(rsq2); bo_ij += bondorder(d_params(iparam_ijk),rij,delx1,dely1,delz1,rik,delx2,dely2,delz2); } @@ -479,19 +480,19 @@ void PairTersoffZBLKokkos::tersoff_zbl_compute(const int &ii, EV_FLO const KK_FLOAT fa = ters_fa_k(d_params(iparam_ij),rij); const KK_FLOAT dfa = ters_dfa(d_params(iparam_ij),rij); const KK_FLOAT bij = ters_bij_k(d_params(iparam_ij),bo_ij); - const KK_FLOAT fatt = -0.5*bij * dfa / rij; - const KK_FLOAT prefactor = 0.5*fa * ters_dbij(d_params(iparam_ij),bo_ij); + const KK_FLOAT fatt = -static_cast(0.5)*bij * dfa / rij; + const KK_FLOAT prefactor = static_cast(0.5)*fa * ters_dbij(d_params(iparam_ij),bo_ij); - f_x += delx1*fatt; - f_y += dely1*fatt; - f_z += delz1*fatt; - KK_ACC_FLOAT fj_x = -delx1*fatt; - KK_ACC_FLOAT fj_y = -dely1*fatt; - KK_ACC_FLOAT fj_z = -delz1*fatt; + f_x += static_cast(delx1*fatt); + f_y += static_cast(dely1*fatt); + f_z += static_cast(delz1*fatt); + KK_ACC_FLOAT fj_x = static_cast(-delx1*fatt); + KK_ACC_FLOAT fj_y = static_cast(-dely1*fatt); + KK_ACC_FLOAT fj_z = static_cast(-delz1*fatt); if (EVFLAG) { - const KK_FLOAT eng = 0.5*bij * fa; - if (eflag) ev.evdwl += eng; + const KK_FLOAT eng = static_cast(0.5)*bij * fa; + if (eflag) ev.evdwl += static_cast(eng); if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,eng,fatt,delx1,dely1,delz1); } @@ -508,10 +509,10 @@ void PairTersoffZBLKokkos::tersoff_zbl_compute(const int &ii, EV_FLO const KK_FLOAT delz2 = ztmp - x(k,2); const KK_FLOAT rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; const int iparam_ijk = d_elem3param(itype,jtype,ktype); - const KK_FLOAT cutsq2 = d_params(iparam_ijk).cutsq; + const KK_FLOAT cutsq2 = static_cast(d_params(iparam_ijk).cutsq); if (rsq2 > cutsq2) continue; - const KK_FLOAT rik = sqrt(rsq2); + const KK_FLOAT rik = Kokkos::sqrt(rsq2); ters_dthb(d_params(iparam_ijk),prefactor,rij,delx1,dely1,delz1, rik,delx2,dely2,delz2,fi,fj,fk); @@ -610,12 +611,12 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffZBLKokkos::ters_fc_k(const Param& param, const KK_FLOAT &r) const { - const KK_FLOAT ters_R = param.bigr; - const KK_FLOAT ters_D = param.bigd; + const KK_FLOAT ters_R = static_cast(param.bigr); + const KK_FLOAT ters_D = static_cast(param.bigd); if (r < ters_R-ters_D) return 1.0; if (r > ters_R+ters_D) return 0.0; - return 0.5*(1.0 - sin(MY_PI2*(r - ters_R)/ters_D)); + return static_cast(0.5)*(static_cast(1.0) - Kokkos::sin(static_cast(MY_PI2)*(r - ters_R)/ters_D)); } /* ---------------------------------------------------------------------- */ @@ -625,12 +626,12 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffZBLKokkos::ters_dfc(const Param& param, const KK_FLOAT &r) const { - const KK_FLOAT ters_R = param.bigr; - const KK_FLOAT ters_D = param.bigd; + const KK_FLOAT ters_R = static_cast(param.bigr); + const KK_FLOAT ters_D = static_cast(param.bigd); if (r < ters_R-ters_D) return 0.0; if (r > ters_R+ters_D) return 0.0; - return -(MY_PI4/ters_D) * cos(MY_PI2*(r - ters_R)/ters_D); + return -(static_cast(MY_PI4)/ters_D) * Kokkos::cos(static_cast(MY_PI2)*(r - ters_R)/ters_D); } /* ---------------------------------------------------------------------- */ @@ -646,13 +647,13 @@ KK_FLOAT PairTersoffZBLKokkos::bondorder(const Param& param, const KK_FLOAT costheta = (dx1*dx2 + dy1*dy2 + dz1*dz2)/(rij*rik); - const KK_FLOAT paramtmp = param.lam3 * (rij-rik); + const KK_FLOAT paramtmp = static_cast(param.lam3) * (rij-rik); if (int(param.powerm) == 3) arg = paramtmp*paramtmp*paramtmp;//pow(param.lam3 * (rij-rik),3.0); else arg = paramtmp; - if (arg > 69.0776) ex_delr = 1.e30; - else if (arg < -69.0776) ex_delr = 0.0; - else ex_delr = exp(arg); + if (arg > static_cast(69.0776)) ex_delr = static_cast(1.e30); + else if (arg < static_cast(-69.0776)) ex_delr = 0.0; + else ex_delr = Kokkos::exp(arg); return ters_fc_k(param,rik) * ters_gijk(param,costheta) * ex_delr; } @@ -665,11 +666,11 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffZBLKokkos:: ters_gijk(const Param& param, const KK_FLOAT &cos) const { - const KK_FLOAT ters_c = param.c * param.c; - const KK_FLOAT ters_d = param.d * param.d; - const KK_FLOAT hcth = param.h - cos; + const KK_FLOAT ters_c = static_cast(param.c) * static_cast(param.c); + const KK_FLOAT ters_d = static_cast(param.d) * static_cast(param.d); + const KK_FLOAT hcth = static_cast(param.h) - cos; - return param.gamma*(1.0 + ters_c/ters_d - ters_c/(ters_d+hcth*hcth)); + return static_cast(param.gamma)*(static_cast(1.0) + ters_c/ters_d - ters_c/(ters_d+hcth*hcth)); } /* ---------------------------------------------------------------------- */ @@ -680,12 +681,12 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffZBLKokkos:: ters_dgijk(const Param& param, const KK_FLOAT &cos) const { - const KK_FLOAT ters_c = param.c * param.c; - const KK_FLOAT ters_d = param.d * param.d; - const KK_FLOAT hcth = param.h - cos; - const KK_FLOAT numerator = -2.0 * ters_c * hcth; - const KK_FLOAT denominator = 1.0/(ters_d + hcth*hcth); - return param.gamma * numerator * denominator * denominator; + const KK_FLOAT ters_c = static_cast(param.c) * static_cast(param.c); + const KK_FLOAT ters_d = static_cast(param.d) * static_cast(param.d); + const KK_FLOAT hcth = static_cast(param.h) - cos; + const KK_FLOAT numerator = static_cast(-2.0) * ters_c * hcth; + const KK_FLOAT denominator = static_cast(1.0)/(ters_d + hcth*hcth); + return static_cast(param.gamma) * numerator * denominator * denominator; } /* ---------------------------------------------------------------------- */ @@ -695,8 +696,8 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffZBLKokkos::ters_fa_k(const Param& param, const KK_FLOAT &r) const { - if (r > param.bigr + param.bigd) return 0.0; - return -param.bigb * exp(-param.lam2 * r) + if (r > static_cast(param.bigr) + static_cast(param.bigd)) return 0.0; + return -static_cast(param.bigb) * Kokkos::exp(-static_cast(param.lam2) * r) * ters_fc_k(param,r) * fermi_k(param,r); } @@ -707,9 +708,9 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffZBLKokkos::ters_dfa(const Param& param, const KK_FLOAT &r) const { - if (r > param.bigr + param.bigd) return 0.0; - return param.bigb * exp(-param.lam2 * r) * - (param.lam2 * ters_fc_k(param,r) * fermi_k(param,r) - + if (r > static_cast(param.bigr) + static_cast(param.bigd)) return 0.0; + return static_cast(param.bigb) * Kokkos::exp(-static_cast(param.lam2) * r) * + (static_cast(param.lam2) * ters_fc_k(param,r) * fermi_k(param,r) - ters_dfc(param,r) * fermi_k(param,r) - ters_fc_k(param,r) * fermi_d_k(param,r)); } @@ -721,14 +722,15 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffZBLKokkos::ters_bij_k(const Param& param, const KK_FLOAT &bo) const { - const KK_FLOAT tmp = param.beta * bo; - if (tmp > param.c1) return 1.0/sqrt(tmp); - if (tmp > param.c2) - return (1.0 - pow(tmp,-param.powern) / (2.0*param.powern))/sqrt(tmp); - if (tmp < param.c4) return 1.0; - if (tmp < param.c3) - return 1.0 - pow(tmp,param.powern)/(2.0*param.powern); - return pow(1.0 + pow(tmp,param.powern), -1.0/(2.0*param.powern)); + const KK_FLOAT tmp = static_cast(param.beta) * bo; + const KK_FLOAT powern_kk = static_cast(param.powern); + if (tmp > static_cast(param.c1)) return static_cast(1.0)/Kokkos::sqrt(tmp); + if (tmp > static_cast(param.c2)) + return (static_cast(1.0) - Kokkos::pow(tmp,-powern_kk) / (static_cast(2.0)*powern_kk))/Kokkos::sqrt(tmp); + if (tmp < static_cast(param.c4)) return 1.0; + if (tmp < static_cast(param.c3)) + return static_cast(1.0) - Kokkos::pow(tmp,powern_kk)/(static_cast(2.0)*powern_kk); + return Kokkos::pow(static_cast(1.0) + Kokkos::pow(tmp,powern_kk), static_cast(-1.0)/(static_cast(2.0)*powern_kk)); } /* ---------------------------------------------------------------------- */ @@ -738,21 +740,22 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffZBLKokkos::ters_dbij(const Param& param, const KK_FLOAT &bo) const { - const KK_FLOAT tmp = param.beta * bo; - const KK_FLOAT factor = -0.5/sqrt(tmp*tmp*tmp); //pow(tmp,-1.5) - if (tmp > param.c1) return param.beta * factor; - if (tmp > param.c2) - return param.beta * (factor * + const KK_FLOAT tmp = static_cast(param.beta) * bo; + const KK_FLOAT powern_kk = static_cast(param.powern); + const KK_FLOAT factor = -static_cast(0.5)/Kokkos::sqrt(tmp*tmp*tmp); //pow(tmp,-1.5) + if (tmp > static_cast(param.c1)) return static_cast(param.beta) * factor; + if (tmp > static_cast(param.c2)) + return static_cast(param.beta) * (factor * // error in negligible 2nd term fixed 2/21/2022 // (1.0 - 0.5*(1.0 + 1.0/(2.0*param.powern)) * - (1.0 - (1.0 + 1.0/(2.0*param.powern)) * - pow(tmp,-param.powern))); - if (tmp < param.c4) return 0.0; - if (tmp < param.c3) - return -0.5*param.beta * pow(tmp,param.powern-1.0); - - const KK_FLOAT tmp_n = pow(tmp,param.powern); - return -0.5 * pow(1.0+tmp_n, -1.0-(1.0/(2.0*param.powern)))*tmp_n / bo; + (static_cast(1.0) - (static_cast(1.0) + static_cast(1.0)/(static_cast(2.0)*powern_kk)) * + Kokkos::pow(tmp,-powern_kk))); + if (tmp < static_cast(param.c4)) return 0.0; + if (tmp < static_cast(param.c3)) + return -static_cast(0.5)*static_cast(param.beta) * Kokkos::pow(tmp,powern_kk-static_cast(1.0)); + + const KK_FLOAT tmp_n = Kokkos::pow(tmp,powern_kk); + return -static_cast(0.5) * Kokkos::pow(static_cast(1.0)+tmp_n, -static_cast(1.0)-(static_cast(1.0)/(static_cast(2.0)*powern_kk)))*tmp_n / bo; } /* ---------------------------------------------------------------------- */ @@ -775,11 +778,11 @@ void PairTersoffZBLKokkos::ters_dthb( delrik[0] = dx2; delrik[1] = dy2; delrik[2] = dz2; //rij = sqrt(rsq1); - rijinv = 1.0/rij; + rijinv = static_cast(1.0)/rij; vec3_scale(rijinv,delrij,rij_hat); //rik = sqrt(rsq2); - rikinv = 1.0/rik; + rikinv = static_cast(1.0)/rik; vec3_scale(rikinv,delrik,rik_hat); // from PairTersoffZBL::ters_zetaterm_d @@ -789,17 +792,17 @@ void PairTersoffZBLKokkos::ters_dthb( fc = ters_fc_k(param,rik); dfc = ters_dfc(param,rik); - const KK_FLOAT paramtmp = param.lam3 * (rij-rik); + const KK_FLOAT paramtmp = static_cast(param.lam3) * (rij-rik); if (int(param.powerm) == 3) tmp = paramtmp*paramtmp*paramtmp;//pow(param.lam3 * (rij-rik),3.0); else tmp = paramtmp; - if (tmp > 69.0776) ex_delr = 1.e30; - else if (tmp < -69.0776) ex_delr = 0.0; - else ex_delr = exp(tmp); + if (tmp > static_cast(69.0776)) ex_delr = static_cast(1.e30); + else if (tmp < static_cast(-69.0776)) ex_delr = 0.0; + else ex_delr = Kokkos::exp(tmp); if (int(param.powerm) == 3) - dex_delr = 3.0*paramtmp*paramtmp*param.lam3*ex_delr;//pow(rij-rik,2.0)*ex_delr; - else dex_delr = param.lam3 * ex_delr; + dex_delr = static_cast(3.0)*paramtmp*paramtmp*static_cast(param.lam3)*ex_delr;//pow(rij-rik,2.0)*ex_delr; + else dex_delr = static_cast(param.lam3) * ex_delr; cos = vec3_dot(rij_hat,rik_hat); gijk = ters_gijk(param,cos); @@ -848,10 +851,10 @@ void PairTersoffZBLKokkos::ters_dthbj( delrij[0] = dx1; delrij[1] = dy1; delrij[2] = dz1; delrik[0] = dx2; delrik[1] = dy2; delrik[2] = dz2; - rijinv = 1.0/rij; + rijinv = static_cast(1.0)/rij; vec3_scale(rijinv,delrij,rij_hat); - rikinv = 1.0/rik; + rikinv = static_cast(1.0)/rik; vec3_scale(rikinv,delrik,rik_hat); KK_FLOAT gijk,dgijk,ex_delr,dex_delr,fc,dfc,cos,tmp; @@ -859,17 +862,17 @@ void PairTersoffZBLKokkos::ters_dthbj( fc = ters_fc_k(param,rik); dfc = ters_dfc(param,rik); - const KK_FLOAT paramtmp = param.lam3 * (rij-rik); + const KK_FLOAT paramtmp = static_cast(param.lam3) * (rij-rik); if (int(param.powerm) == 3) tmp = paramtmp*paramtmp*paramtmp;//pow(param.lam3 * (rij-rik),3.0); else tmp = paramtmp; - if (tmp > 69.0776) ex_delr = 1.e30; - else if (tmp < -69.0776) ex_delr = 0.0; - else ex_delr = exp(tmp); + if (tmp > static_cast(69.0776)) ex_delr = static_cast(1.e30); + else if (tmp < static_cast(-69.0776)) ex_delr = 0.0; + else ex_delr = Kokkos::exp(tmp); if (int(param.powerm) == 3) - dex_delr = 3.0*paramtmp*paramtmp*param.lam3*ex_delr;//pow(param.lam3,3.0) * pow(rij-rik,2.0)*ex_delr; - else dex_delr = param.lam3 * ex_delr; + dex_delr = static_cast(3.0)*paramtmp*paramtmp*static_cast(param.lam3)*ex_delr;//pow(param.lam3,3.0) * pow(rij-rik,2.0)*ex_delr; + else dex_delr = static_cast(param.lam3) * ex_delr; cos = vec3_dot(rij_hat,rik_hat); gijk = ters_gijk(param,cos); @@ -911,10 +914,10 @@ void PairTersoffZBLKokkos::ters_dthbk( delrij[0] = dx1; delrij[1] = dy1; delrij[2] = dz1; delrik[0] = dx2; delrik[1] = dy2; delrik[2] = dz2; - rijinv = 1.0/rij; + rijinv = static_cast(1.0)/rij; vec3_scale(rijinv,delrij,rij_hat); - rikinv = 1.0/rik; + rikinv = static_cast(1.0)/rik; vec3_scale(rikinv,delrik,rik_hat); KK_FLOAT gijk,dgijk,ex_delr,dex_delr,fc,dfc,cos,tmp; @@ -922,17 +925,17 @@ void PairTersoffZBLKokkos::ters_dthbk( fc = ters_fc_k(param,rik); dfc = ters_dfc(param,rik); - const KK_FLOAT paramtmp = param.lam3 * (rij-rik); + const KK_FLOAT paramtmp = static_cast(param.lam3) * (rij-rik); if (int(param.powerm) == 3) tmp = paramtmp*paramtmp*paramtmp;//pow(param.lam3 * (rij-rik),3.0); else tmp = paramtmp; - if (tmp > 69.0776) ex_delr = 1.e30; - else if (tmp < -69.0776) ex_delr = 0.0; - else ex_delr = exp(tmp); + if (tmp > static_cast(69.0776)) ex_delr = static_cast(1.e30); + else if (tmp < static_cast(-69.0776)) ex_delr = 0.0; + else ex_delr = Kokkos::exp(tmp); if (int(param.powerm) == 3) - dex_delr = 3.0*paramtmp*paramtmp*param.lam3*ex_delr;//pow(param.lam3,3.0) * pow(rij-rik,2.0)*ex_delr; - else dex_delr = param.lam3 * ex_delr; + dex_delr = static_cast(3.0)*paramtmp*paramtmp*static_cast(param.lam3)*ex_delr;//pow(param.lam3,3.0) * pow(rij-rik,2.0)*ex_delr; + else dex_delr = static_cast(param.lam3) * ex_delr; cos = vec3_dot(rij_hat,rik_hat); gijk = ters_gijk(param,cos); @@ -959,8 +962,8 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffZBLKokkos::fermi_k(const Param& param, const KK_FLOAT &r) const { - return 1.0 / (1.0 + exp(-param.ZBLexpscale * - (r - param.ZBLcut))); + return static_cast(1.0) / (static_cast(1.0) + Kokkos::exp(-static_cast(param.ZBLexpscale) * + (r - static_cast(param.ZBLcut)))); } /* ---------------------------------------------------------------------- */ @@ -970,10 +973,12 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairTersoffZBLKokkos::fermi_d_k(const Param& param, const KK_FLOAT &r) const { - return param.ZBLexpscale * exp(-param.ZBLexpscale * - (r - param.ZBLcut)) / - pow(1.0 + exp(-param.ZBLexpscale * - (r - param.ZBLcut)),2.0); + const KK_FLOAT ZBLexpscale_kk = static_cast(param.ZBLexpscale); + const KK_FLOAT ZBLcut_kk = static_cast(param.ZBLcut); + return ZBLexpscale_kk * Kokkos::exp(-ZBLexpscale_kk * + (r - ZBLcut_kk)) / + Kokkos::pow(static_cast(1.0) + Kokkos::exp(-ZBLexpscale_kk * + (r - ZBLcut_kk)),static_cast(2.0)); } /* ---------------------------------------------------------------------- */ @@ -995,9 +1000,9 @@ void PairTersoffZBLKokkos::ev_tally(EV_FLOAT &ev, const int &i, cons auto a_vatom = v_vatom.template access>(); if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; - a_eatom[i] += epairhalf; - a_eatom[j] += epairhalf; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; + a_eatom[i] += static_cast(epairhalf); + a_eatom[j] += static_cast(epairhalf); } if (vflag_either) { @@ -1009,28 +1014,28 @@ void PairTersoffZBLKokkos::ev_tally(EV_FLOAT &ev, const int &i, cons const KK_FLOAT v5 = dely*delz*fpair; if (vflag_global) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } if (vflag_atom) { - a_vatom(i,0) += 0.5*v0; - a_vatom(i,1) += 0.5*v1; - a_vatom(i,2) += 0.5*v2; - a_vatom(i,3) += 0.5*v3; - a_vatom(i,4) += 0.5*v4; - a_vatom(i,5) += 0.5*v5; - - a_vatom(j,0) += 0.5*v0; - a_vatom(j,1) += 0.5*v1; - a_vatom(j,2) += 0.5*v2; - a_vatom(j,3) += 0.5*v3; - a_vatom(j,4) += 0.5*v4; - a_vatom(j,5) += 0.5*v5; + a_vatom(i,0) += static_cast(static_cast(0.5)*v0); + a_vatom(i,1) += static_cast(static_cast(0.5)*v1); + a_vatom(i,2) += static_cast(static_cast(0.5)*v2); + a_vatom(i,3) += static_cast(static_cast(0.5)*v3); + a_vatom(i,4) += static_cast(static_cast(0.5)*v4); + a_vatom(i,5) += static_cast(static_cast(0.5)*v5); + + a_vatom(j,0) += static_cast(static_cast(0.5)*v0); + a_vatom(j,1) += static_cast(static_cast(0.5)*v1); + a_vatom(j,2) += static_cast(static_cast(0.5)*v2); + a_vatom(j,3) += static_cast(static_cast(0.5)*v3); + a_vatom(j,4) += static_cast(static_cast(0.5)*v4); + a_vatom(j,5) += static_cast(static_cast(0.5)*v5); } } } @@ -1052,38 +1057,38 @@ void PairTersoffZBLKokkos::v_tally3(EV_FLOAT &ev, KK_FLOAT v[6]; - v[0] = (drij[0]*fj[0] + drik[0]*fk[0]); - v[1] = (drij[1]*fj[1] + drik[1]*fk[1]); - v[2] = (drij[2]*fj[2] + drik[2]*fk[2]); - v[3] = (drij[0]*fj[1] + drik[0]*fk[1]); - v[4] = (drij[0]*fj[2] + drik[0]*fk[2]); - v[5] = (drij[1]*fj[2] + drik[1]*fk[2]); + v[0] = (drij[0]*static_cast(fj[0]) + drik[0]*static_cast(fk[0])); + v[1] = (drij[1]*static_cast(fj[1]) + drik[1]*static_cast(fk[1])); + v[2] = (drij[2]*static_cast(fj[2]) + drik[2]*static_cast(fk[2])); + v[3] = (drij[0]*static_cast(fj[1]) + drik[0]*static_cast(fk[1])); + v[4] = (drij[0]*static_cast(fj[2]) + drik[0]*static_cast(fk[2])); + v[5] = (drij[1]*static_cast(fj[2]) + drik[1]*static_cast(fk[2])); if (vflag_global) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } if (vflag_atom) { - v[0] *= THIRD; - v[1] *= THIRD; - v[2] *= THIRD; - v[3] *= THIRD; - v[4] *= THIRD; - v[5] *= THIRD; + v[0] *= static_cast(THIRD); + v[1] *= static_cast(THIRD); + v[2] *= static_cast(THIRD); + v[3] *= static_cast(THIRD); + v[4] *= static_cast(THIRD); + v[5] *= static_cast(THIRD); - a_vatom(i,0) += v[0]; a_vatom(i,1) += v[1]; a_vatom(i,2) += v[2]; - a_vatom(i,3) += v[3]; a_vatom(i,4) += v[4]; a_vatom(i,5) += v[5]; + a_vatom(i,0) += static_cast(v[0]); a_vatom(i,1) += static_cast(v[1]); a_vatom(i,2) += static_cast(v[2]); + a_vatom(i,3) += static_cast(v[3]); a_vatom(i,4) += static_cast(v[4]); a_vatom(i,5) += static_cast(v[5]); - a_vatom(j,0) += v[0]; a_vatom(j,1) += v[1]; a_vatom(j,2) += v[2]; - a_vatom(j,3) += v[3]; a_vatom(j,4) += v[4]; a_vatom(j,5) += v[5]; + a_vatom(j,0) += static_cast(v[0]); a_vatom(j,1) += static_cast(v[1]); a_vatom(j,2) += static_cast(v[2]); + a_vatom(j,3) += static_cast(v[3]); a_vatom(j,4) += static_cast(v[4]); a_vatom(j,5) += static_cast(v[5]); - a_vatom(k,0) += v[0]; a_vatom(k,1) += v[1]; a_vatom(k,2) += v[2]; - a_vatom(k,3) += v[3]; a_vatom(k,4) += v[4]; a_vatom(k,5) += v[5]; + a_vatom(k,0) += static_cast(v[0]); a_vatom(k,1) += static_cast(v[1]); a_vatom(k,2) += static_cast(v[2]); + a_vatom(k,3) += static_cast(v[3]); a_vatom(k,4) += static_cast(v[4]); a_vatom(k,5) += static_cast(v[5]); } } @@ -1098,25 +1103,25 @@ void PairTersoffZBLKokkos::v_tally3_atom(EV_FLOAT &ev, const int &i, { KK_FLOAT v[6]; - v[0] = THIRD * (drji[0]*fj[0] + drjk[0]*fk[0]); - v[1] = THIRD * (drji[1]*fj[1] + drjk[1]*fk[1]); - v[2] = THIRD * (drji[2]*fj[2] + drjk[2]*fk[2]); - v[3] = THIRD * (drji[0]*fj[1] + drjk[0]*fk[1]); - v[4] = THIRD * (drji[0]*fj[2] + drjk[0]*fk[2]); - v[5] = THIRD * (drji[1]*fj[2] + drjk[1]*fk[2]); + v[0] = static_cast(THIRD) * (drji[0]*static_cast(fj[0]) + drjk[0]*static_cast(fk[0])); + v[1] = static_cast(THIRD) * (drji[1]*static_cast(fj[1]) + drjk[1]*static_cast(fk[1])); + v[2] = static_cast(THIRD) * (drji[2]*static_cast(fj[2]) + drjk[2]*static_cast(fk[2])); + v[3] = static_cast(THIRD) * (drji[0]*static_cast(fj[1]) + drjk[0]*static_cast(fk[1])); + v[4] = static_cast(THIRD) * (drji[0]*static_cast(fj[2]) + drjk[0]*static_cast(fk[2])); + v[5] = static_cast(THIRD) * (drji[1]*static_cast(fj[2]) + drjk[1]*static_cast(fk[2])); if (vflag_global) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } if (vflag_atom) { - d_vatom(i,0) += v[0]; d_vatom(i,1) += v[1]; d_vatom(i,2) += v[2]; - d_vatom(i,3) += v[3]; d_vatom(i,4) += v[4]; d_vatom(i,5) += v[5]; + d_vatom(i,0) += static_cast(v[0]); d_vatom(i,1) += static_cast(v[1]); d_vatom(i,2) += static_cast(v[2]); + d_vatom(i,3) += static_cast(v[3]); d_vatom(i,4) += static_cast(v[4]); d_vatom(i,5) += static_cast(v[5]); } } diff --git a/src/KOKKOS/pair_tip4p_kokkos.h b/src/KOKKOS/pair_tip4p_kokkos.h index 27c1b7ddf90..dac73aa7f68 100644 --- a/src/KOKKOS/pair_tip4p_kokkos.h +++ b/src/KOKKOS/pair_tip4p_kokkos.h @@ -147,15 +147,19 @@ class PairTIP4PKokkos : public PairCPUBase { Kokkos::atomic_add(&f(idx,1), (KK_ACC_FLOAT)(dely*cforce)); Kokkos::atomic_add(&f(idx,2), (KK_ACC_FLOAT)(delz*cforce)); if (do_virial) { - v[0] += x(idx,0)*delx*cforce; v[1] += x(idx,1)*dely*cforce; v[2] += x(idx,2)*delz*cforce; - v[3] += x(idx,0)*dely*cforce; v[4] += x(idx,0)*delz*cforce; v[5] += x(idx,1)*delz*cforce; + v[0] += static_cast(x(idx,0)*delx*cforce); + v[1] += static_cast(x(idx,1)*dely*cforce); + v[2] += static_cast(x(idx,2)*delz*cforce); + v[3] += static_cast(x(idx,0)*dely*cforce); + v[4] += static_cast(x(idx,0)*delz*cforce); + v[5] += static_cast(x(idx,1)*delz*cforce); } vlist[n++] = idx; } else { key += keyinc; const KK_FLOAT fdx = delx*cforce, fdy = dely*cforce, fdz = delz*cforce; - const KK_ACC_FLOAT fOx = fdx*m_alphaO, fOy = fdy*m_alphaO, fOz = fdz*m_alphaO; - const KK_ACC_FLOAT fHx = fdx*m_alphaH, fHy = fdy*m_alphaH, fHz = fdz*m_alphaH; + const KK_FLOAT fOx = fdx*m_alphaO, fOy = fdy*m_alphaO, fOz = fdz*m_alphaO; + const KK_FLOAT fHx = fdx*m_alphaH, fHy = fdy*m_alphaH, fHz = fdz*m_alphaH; Kokkos::atomic_add(&f(idx,0), (KK_ACC_FLOAT)fOx); Kokkos::atomic_add(&f(idx,1), (KK_ACC_FLOAT)fOy); Kokkos::atomic_add(&f(idx,2), (KK_ACC_FLOAT)fOz); @@ -166,12 +170,12 @@ class PairTIP4PKokkos : public PairCPUBase { Kokkos::atomic_add(&f(iH2,1), (KK_ACC_FLOAT)fHy); Kokkos::atomic_add(&f(iH2,2), (KK_ACC_FLOAT)fHz); if (do_virial) { - v[0] += x(idx,0)*fOx + x(iH1,0)*fHx + x(iH2,0)*fHx; - v[1] += x(idx,1)*fOy + x(iH1,1)*fHy + x(iH2,1)*fHy; - v[2] += x(idx,2)*fOz + x(iH1,2)*fHz + x(iH2,2)*fHz; - v[3] += x(idx,0)*fOy + x(iH1,0)*fHy + x(iH2,0)*fHy; - v[4] += x(idx,0)*fOz + x(iH1,0)*fHz + x(iH2,0)*fHz; - v[5] += x(idx,1)*fOz + x(iH1,1)*fHz + x(iH2,1)*fHz; + v[0] += static_cast(x(idx,0)*fOx + x(iH1,0)*fHx + x(iH2,0)*fHx); + v[1] += static_cast(x(idx,1)*fOy + x(iH1,1)*fHy + x(iH2,1)*fHy); + v[2] += static_cast(x(idx,2)*fOz + x(iH1,2)*fHz + x(iH2,2)*fHz); + v[3] += static_cast(x(idx,0)*fOy + x(iH1,0)*fHy + x(iH2,0)*fHy); + v[4] += static_cast(x(idx,0)*fOz + x(iH1,0)*fHz + x(iH2,0)*fHz); + v[5] += static_cast(x(idx,1)*fOz + x(iH1,1)*fHz + x(iH2,1)*fHz); } vlist[n++] = idx; vlist[n++] = iH1; vlist[n++] = iH2; } @@ -184,7 +188,7 @@ class PairTIP4PKokkos : public PairCPUBase { void ev_tally_tip4p(EV_FLOAT &ev, const int &key, const int (&vlist)[6], const KK_ACC_FLOAT (&v)[6], const KK_FLOAT &ecoul) const { - if (this->eflag_global) ev.ecoul += ecoul; + if (this->eflag_global) ev.ecoul += static_cast(ecoul); if (this->vflag_global) for (int k = 0; k < 6; k++) ev.v[k] += v[k]; @@ -217,9 +221,9 @@ class PairTIP4PKokkos : public PairCPUBase { if (this->vflag_atom) { for (int k = 0; k < 6; k++) { - const KK_ACC_FLOAT vO = (KK_FLOAT)0.5*v[k]*m_alphaO; - const KK_ACC_FLOAT vH = (KK_FLOAT)0.5*v[k]*m_alphaH; - const KK_ACC_FLOAT vA = (KK_FLOAT)0.5*v[k]; + const KK_ACC_FLOAT vO = (KK_ACC_FLOAT)0.5*v[k]*(KK_ACC_FLOAT)m_alphaO; + const KK_ACC_FLOAT vH = (KK_ACC_FLOAT)0.5*v[k]*(KK_ACC_FLOAT)m_alphaH; + const KK_ACC_FLOAT vA = (KK_ACC_FLOAT)0.5*v[k]; if (key == 0) { Kokkos::atomic_add(&d_vatom(vlist[0],k), vA); Kokkos::atomic_add(&d_vatom(vlist[1],k), vA); @@ -253,7 +257,7 @@ class PairTIP4PKokkos : public PairCPUBase { const KK_FLOAT &fpair, const KK_FLOAT &delx, const KK_FLOAT &dely, const KK_FLOAT &delz) const { - if (this->eflag_global) ev.evdwl += evdwl; + if (this->eflag_global) ev.evdwl += static_cast(evdwl); if (this->eflag_atom) { Kokkos::atomic_add(&d_eatom[i], (KK_ACC_FLOAT)((KK_FLOAT)0.5*evdwl)); Kokkos::atomic_add(&d_eatom[j], (KK_ACC_FLOAT)((KK_FLOAT)0.5*evdwl)); @@ -266,8 +270,12 @@ class PairTIP4PKokkos : public PairCPUBase { const KK_FLOAT v4 = delx*delz*fpair; const KK_FLOAT v5 = dely*delz*fpair; if (this->vflag_global) { - ev.v[0] += v0; ev.v[1] += v1; ev.v[2] += v2; - ev.v[3] += v3; ev.v[4] += v4; ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } if (this->vflag_atom) { Kokkos::atomic_add(&d_vatom(i,0), (KK_ACC_FLOAT)((KK_FLOAT)0.5*v0)); @@ -395,20 +403,21 @@ class PairTIP4PKokkos : public PairCPUBase { nlocal = this->atom->nlocal; nall = this->atom->nlocal + this->atom->nghost; - qqrd2e = this->force->qqrd2e; + qqrd2e = static_cast(this->force->qqrd2e); for (int i = 0; i < 4; i++) { - special_coul[i] = this->force->special_coul[i]; - special_lj[i] = this->force->special_lj[i]; + special_coul[i] = static_cast(this->force->special_coul[i]); + special_lj[i] = static_cast(this->force->special_lj[i]); } - m_alpha = this->alpha; + m_alpha = static_cast(this->alpha); // shares of the M-site force redistributed onto O and each H - m_alphaO = 1.0 - this->alpha; - m_alphaH = 0.5 * this->alpha; + m_alphaO = static_cast(1.0 - this->alpha); + m_alphaH = static_cast(0.5 * this->alpha); m_typeO = this->typeO; m_typeH = this->typeH; - m_cut_coulsq = this->cut_coulsq; - m_cut_coulsqplus = (this->cut_coul + 2.0*this->qdist) * (this->cut_coul + 2.0*this->qdist); + m_cut_coulsq = static_cast(this->cut_coulsq); + m_cut_coulsqplus = static_cast((this->cut_coul + 2.0*this->qdist) * + (this->cut_coul + 2.0*this->qdist)); map_style = this->atom->map_style; if (map_style == Atom::MAP_ARRAY) { @@ -458,11 +467,9 @@ class PairTIP4PKokkos : public PairCPUBase { if (k_h_missing.view_host()()) this->error->one(FLERR,"TIP4P hydrogen is missing"); - if (this->eflag_global) this->eng_coul += ev.ecoul; - if (this->vflag_global) { - this->virial[0] += ev.v[0]; this->virial[1] += ev.v[1]; this->virial[2] += ev.v[2]; - this->virial[3] += ev.v[3]; this->virial[4] += ev.v[4]; this->virial[5] += ev.v[5]; - } + if (this->eflag_global) this->eng_coul += static_cast(ev.ecoul); + if (this->vflag_global) + for (int k = 0; k < 6; k++) this->virial[k] += static_cast(ev.v[k]); if (this->eflag_atom) { k_eatom.template modify(); k_eatom.sync_host(); } if (this->vflag_atom) { k_vatom.template modify(); k_vatom.sync_host(); } this->atomKK->modified(this->execution_space,this->datamask_modify); diff --git a/src/KOKKOS/pair_uf3_kokkos.cpp b/src/KOKKOS/pair_uf3_kokkos.cpp index b217f8348ee..bc7b2112274 100644 --- a/src/KOKKOS/pair_uf3_kokkos.cpp +++ b/src/KOKKOS/pair_uf3_kokkos.cpp @@ -254,7 +254,7 @@ template void PairUF3Kokkos::create_2b_coefficien for (int i = 1; i < num_of_elements + 1; i++) { for (int j = i; j < num_of_elements + 1; j++) { for (int k = 0; k < max_num_coeff_2b; k++) { - d_coefficients_2b_view(map2b_view(i, j), k) = n2b_coeff_array[i][j][k]; + d_coefficients_2b_view(map2b_view(i, j), k) = static_cast(n2b_coeff_array[i][j][k]); } } } @@ -270,9 +270,9 @@ template void PairUF3Kokkos::create_2b_coefficien for (int i = 1; i < num_of_elements + 1; i++) { for (int j = i; j < num_of_elements + 1; j++) { for (int k = 0; k < max_num_knots_2b; k++) { - d_n2b_knot_view(map2b_view(i, j), k) = n2b_knots_array[i][j][k]; + d_n2b_knot_view(map2b_view(i, j), k) = static_cast(n2b_knots_array[i][j][k]); } - d_n2b_knot_spacings_view(map2b_view(i, j)) = n2b_knots_array[i][j][4] - n2b_knots_array[i][j][3]; + d_n2b_knot_spacings_view(map2b_view(i, j)) = static_cast(n2b_knots_array[i][j][4] - n2b_knots_array[i][j][3]); } } @@ -289,8 +289,8 @@ template void PairUF3Kokkos::create_2b_coefficien //n2b_knot[i][j].size() - 4; l++) { auto c = get_constants(&n2b_knots_array[i][j][l], n2b_coeff_array[i][j][l]); for (int k = 0; k < 16; k++) - constants_2b_view(map2b_view(i, j), l, k) = (std::isinf(c[k]) || std::isnan(c[k])) ? 0 - : c[k]; + constants_2b_view(map2b_view(i, j), l, k) = static_cast((std::isinf(c[k]) || std::isnan(c[k])) ? 0 + : c[k]); } } } @@ -307,7 +307,7 @@ template void PairUF3Kokkos::create_2b_coefficien auto c = get_dnconstants(&n2b_knots_array[i][j][l + 1], coeff); for (int k = 0; k < 9; k++) dnconstants_2b_view(map2b_view(i, j), l, k) = - (std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]; + static_cast((std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]); } } } @@ -355,22 +355,22 @@ template void PairUF3Kokkos::create_3b_coefficien for (int k = 1; k < num_of_elements + 1; k++) { for (int m = 0; m < n3b_knots_array_size[map_3b[i][j][k]][0]; m++) d_n3b_knot_matrix_view(map3b_view(i, j, k), 0, m) = - n3b_knots_array[map_3b[i][j][k]][0][m]; + static_cast(n3b_knots_array[map_3b[i][j][k]][0][m]); for (int m = 0; m < n3b_knots_array_size[map_3b[i][j][k]][1]; m++) d_n3b_knot_matrix_view(map3b_view(i, j, k), 1, m) = - n3b_knots_array[map_3b[i][j][k]][1][m]; + static_cast(n3b_knots_array[map_3b[i][j][k]][1][m]); for (int m = 0; m < n3b_knots_array_size[map_3b[i][j][k]][2]; m++) d_n3b_knot_matrix_view(map3b_view(i, j, k), 2, m) = - n3b_knots_array[map_3b[i][j][k]][2][m]; + static_cast(n3b_knots_array[map_3b[i][j][k]][2][m]); d_n3b_knot_matrix_spacings_view(map3b_view(i, j, k),2) = - n3b_knots_array[map_3b[i][j][k]][2][4] - n3b_knots_array[map_3b[i][j][k]][2][3]; + static_cast(n3b_knots_array[map_3b[i][j][k]][2][4] - n3b_knots_array[map_3b[i][j][k]][2][3]); d_n3b_knot_matrix_spacings_view(map3b_view(i, j, k),1) = - n3b_knots_array[map_3b[i][j][k]][1][4] - n3b_knots_array[map_3b[i][j][k]][1][3]; + static_cast(n3b_knots_array[map_3b[i][j][k]][1][4] - n3b_knots_array[map_3b[i][j][k]][1][3]); d_n3b_knot_matrix_spacings_view(map3b_view(i, j, k),0) = - n3b_knots_array[map_3b[i][j][k]][0][4] - n3b_knots_array[map_3b[i][j][k]][0][3]; + static_cast(n3b_knots_array[map_3b[i][j][k]][0][4] - n3b_knots_array[map_3b[i][j][k]][0][3]); } Kokkos::deep_copy(d_n3b_knot_matrix, d_n3b_knot_matrix_view); Kokkos::deep_copy(d_n3b_knot_matrix_spacings, d_n3b_knot_matrix_spacings_view); @@ -384,13 +384,13 @@ template void PairUF3Kokkos::create_3b_coefficien for (int j = 1; j < num_of_elements + 1; j++) { for (int k = 1; k < num_of_elements + 1; k++) { d_n3b_knot_spacings_view(map3b_view(i, j, k), 0) = - 1 / (n3b_knots_array[map_3b[i][j][k]][0][5] - n3b_knots_array[map_3b[i][j][k]][0][4]); + static_cast(1 / (n3b_knots_array[map_3b[i][j][k]][0][5] - n3b_knots_array[map_3b[i][j][k]][0][4])); d_n3b_knot_spacings_view(map3b_view(i, j, k), 1) = - 1 / (n3b_knots_array[map_3b[i][j][k]][1][5] - n3b_knots_array[map_3b[i][j][k]][1][4]); + static_cast(1 / (n3b_knots_array[map_3b[i][j][k]][1][5] - n3b_knots_array[map_3b[i][j][k]][1][4])); d_n3b_knot_spacings_view(map3b_view(i, j, k), 2) = - 1 / (n3b_knots_array[map_3b[i][j][k]][2][5] - n3b_knots_array[map_3b[i][j][k]][2][4]); + static_cast(1 / (n3b_knots_array[map_3b[i][j][k]][2][5] - n3b_knots_array[map_3b[i][j][k]][2][4])); } } } @@ -409,7 +409,7 @@ template void PairUF3Kokkos::create_3b_coefficien for (int j = 0; j < n3b_coeff_array_size[map_3b[n][m][o]][1]; j++) { for (int k = 0; k < n3b_coeff_array_size[map_3b[n][m][o]][2]; k++) { d_coefficients_3b_view(map3b_view(n, m, o), i, j, k) = - n3b_coeff_array[map_3b[n][m][o]][i][j][k]; + static_cast(n3b_coeff_array[map_3b[n][m][o]][i][j][k]); } } } @@ -450,7 +450,7 @@ template void PairUF3Kokkos::create_3b_coefficien 3 / (n3b_knots_array[map_3b[n][m][o]][0][k + 4] - n3b_knots_array[map_3b[n][m][o]][0][k + 1]); d_dncoefficients_3b_view(map3b_view(n, m, o), 2, i, j, k) = - (n3b_coeff_array[map_3b[n][m][o]][i][j][k + 1] - n3b_coeff_array[map_3b[n][m][o]][i][j][k]) * dntemp4; + static_cast((n3b_coeff_array[map_3b[n][m][o]][i][j][k + 1] - n3b_coeff_array[map_3b[n][m][o]][i][j][k]) * dntemp4); } } } @@ -464,7 +464,7 @@ template void PairUF3Kokkos::create_3b_coefficien std::vector dncoeff_vect; for (int k = 0; k < coeff_dim3; k++) { d_dncoefficients_3b_view(map3b_view(n, m, o), 1, i, j, k) = - (n3b_coeff_array[map_3b[n][m][o]][i][j + 1][k] - n3b_coeff_array[map_3b[n][m][o]][i][j][k]) * dntemp4; + static_cast((n3b_coeff_array[map_3b[n][m][o]][i][j + 1][k] - n3b_coeff_array[map_3b[n][m][o]][i][j][k]) * dntemp4); } } } @@ -475,7 +475,7 @@ template void PairUF3Kokkos::create_3b_coefficien for (int j = 0; j < coeff_dim2; j++) { for (int k = 0; k < coeff_dim3; k++) { d_dncoefficients_3b_view(map3b_view(n, m, o), 0, i, j, k) = - (n3b_coeff_array[map_3b[n][m][o]][i + 1][j][k] - n3b_coeff_array[map_3b[n][m][o]][i][j][k]) * dntemp4; + static_cast((n3b_coeff_array[map_3b[n][m][o]][i + 1][j][k] - n3b_coeff_array[map_3b[n][m][o]][i][j][k]) * dntemp4); } } } @@ -501,19 +501,19 @@ template void PairUF3Kokkos::create_3b_coefficien auto c = get_constants(&n3b_knots_array[map_3b[n][m][o]][2][l], 1); for (int k = 0; k < 16; k++) constants_3b_view(map3b_view(n, m, o), 0, l, k) = - (std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]; + static_cast((std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]); } for (int l = 0; l < n3b_knots_array_size[map_3b[n][m][o]][1] - 4; l++) { auto c = get_constants(&n3b_knots_array[map_3b[n][m][o]][1][l], 1); for (int k = 0; k < 16; k++) constants_3b_view(map3b_view(n, m, o), 1, l, k) = - (std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]; + static_cast((std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]); } for (int l = 0; l < n3b_knots_array_size[map_3b[n][m][o]][0] -4; l++) { auto c = get_constants(&n3b_knots_array[map_3b[n][m][o]][0][l], 1); for (int k = 0; k < 16; k++) constants_3b_view(map3b_view(n, m, o), 2, l, k) = - (std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]; + static_cast((std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]); } } } @@ -530,19 +530,19 @@ template void PairUF3Kokkos::create_3b_coefficien auto c = get_dnconstants(&n3b_knots_array[map_3b[n][m][o]][2][l], 1); for (int k = 0; k < 9; k++) dnconstants_3b_view(map3b_view(n, m, o), 0, l - 1, k) = - (std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]; + static_cast((std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]); } for (int l = 1; l < n3b_knots_array_size[map_3b[n][m][o]][1] - 5; l++) { auto c = get_dnconstants(&n3b_knots_array[map_3b[n][m][o]][1][l], 1); for (int k = 0; k < 9; k++) dnconstants_3b_view(map3b_view(n, m, o), 1, l - 1, k) = - (std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]; + static_cast((std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]); } for (int l = 1; l < n3b_knots_array_size[map_3b[n][m][o]][0] - 5; l++) { auto c = get_dnconstants(&n3b_knots_array[map_3b[n][m][o]][0][l], 1); for (int k = 0; k < 9; k++) dnconstants_3b_view(map3b_view(n, m, o), 2, l - 1, k) = - (std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]; + static_cast((std::isinf(c[k]) || std::isnan(c[k])) ? 0 : c[k]); } } } @@ -808,14 +808,14 @@ template void PairUF3Kokkos::compute(int eflag_in Kokkos::Experimental::contribute(d_cvatom, cvscatter); Kokkos::Experimental::contribute(f, fscatter); - if (eflag_global) eng_vdwl += ev_all.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev_all.evdwl); if (vflag_global) { - virial[0] += ev_all.v[0]; - virial[1] += ev_all.v[1]; - virial[2] += ev_all.v[2]; - virial[3] += ev_all.v[3]; - virial[4] += ev_all.v[4]; - virial[5] += ev_all.v[5]; + virial[0] += static_cast(ev_all.v[0]); + virial[1] += static_cast(ev_all.v[1]); + virial[2] += static_cast(ev_all.v[2]); + virial[3] += static_cast(ev_all.v[3]); + virial[4] += static_cast(ev_all.v[4]); + virial[5] += static_cast(ev_all.v[5]); } if (eflag_atom) { @@ -920,20 +920,20 @@ PairUF3Kokkos::operator()(TagPairUF3ComputeFullA, if (rsq >= d_cutsq(itype, jtype)) continue; - const KK_FLOAT rij = sqrt(rsq); + const KK_FLOAT rij = Kokkos::sqrt(rsq); this->template twobody(itype, jtype, rij, evdwl, fpair); fpair = -fpair / rij; - fxtmpi += delx * fpair; - fytmpi += dely * fpair; - fztmpi += delz * fpair; - a_f(j, 0) -= delx * fpair; - a_f(j, 1) -= dely * fpair; - a_f(j, 2) -= delz * fpair; + fxtmpi += static_cast(delx * fpair); + fytmpi += static_cast(dely * fpair); + fztmpi += static_cast(delz * fpair); + a_f(j, 0) -= static_cast(delx * fpair); + a_f(j, 1) -= static_cast(dely * fpair); + a_f(j, 2) -= static_cast(delz * fpair); if (EVFLAG) { - if (eflag) ev.evdwl += evdwl; + if (eflag) ev.evdwl += static_cast(evdwl); if (vflag_either || eflag_atom) this->template ev_tally(ev, i, j, evdwl, fpair, delx, dely, delz); } @@ -949,7 +949,7 @@ PairUF3Kokkos::operator()(TagPairUF3ComputeFullA, del_rji[0] = x(j, 0) - xtmp; del_rji[1] = x(j, 1) - ytmp; del_rji[2] = x(j, 2) - ztmp; - KK_FLOAT rij = sqrt(del_rji[0] * del_rji[0] + del_rji[1] * del_rji[1] + del_rji[2] * del_rji[2]); + KK_FLOAT rij = Kokkos::sqrt(del_rji[0] * del_rji[0] + del_rji[1] * del_rji[1] + del_rji[2] * del_rji[2]); KK_ACC_FLOAT fxtmpj = 0.0; KK_ACC_FLOAT fytmpj = 0.0; @@ -973,7 +973,7 @@ PairUF3Kokkos::operator()(TagPairUF3ComputeFullA, del_rki[1] = x(k, 1) - ytmp; del_rki[2] = x(k, 2) - ztmp; KK_FLOAT rik = - sqrt(del_rki[0] * del_rki[0] + del_rki[1] * del_rki[1] + del_rki[2] * del_rki[2]); + Kokkos::sqrt(del_rki[0] * del_rki[0] + del_rki[1] * del_rki[1] + del_rki[2] * del_rki[2]); if (rik < d_min_cut_3b(itype, jtype, ktype, 1)) continue; if (rik > d_cut_3b(itype, ktype, jtype)) continue; @@ -982,7 +982,7 @@ PairUF3Kokkos::operator()(TagPairUF3ComputeFullA, del_rkj[1] = x(k, 1) - x(j, 1); del_rkj[2] = x(k, 2) - x(j, 2); KK_FLOAT rjk = - sqrt(del_rkj[0] * del_rkj[0] + del_rkj[1] * del_rkj[1] + del_rkj[2] * del_rkj[2]); + Kokkos::sqrt(del_rkj[0] * del_rkj[0] + del_rkj[1] * del_rkj[1] + del_rkj[2] * del_rkj[2]); if (rjk < d_min_cut_3b(itype, jtype, ktype, 0)) continue; this->template threebody(itype, jtype, ktype, rij, rik, rjk, evdwl3, triangle_eval); @@ -1007,17 +1007,17 @@ PairUF3Kokkos::operator()(TagPairUF3ComputeFullA, fjk[2] = *(triangle_eval + 2) * (del_rkj[2] / rjk); fkj[2] = -fjk[2]; - Fj[0] = fji[0] + fjk[0]; - Fj[1] = fji[1] + fjk[1]; - Fj[2] = fji[2] + fjk[2]; + Fj[0] = static_cast(fji[0] + fjk[0]); + Fj[1] = static_cast(fji[1] + fjk[1]); + Fj[2] = static_cast(fji[2] + fjk[2]); - Fk[0] = fki[0] + fkj[0]; - Fk[1] = fki[1] + fkj[1]; - Fk[2] = fki[2] + fkj[2]; + Fk[0] = static_cast(fki[0] + fkj[0]); + Fk[1] = static_cast(fki[1] + fkj[1]); + Fk[2] = static_cast(fki[2] + fkj[2]); - fxtmpi += (fij[0] + fik[0]); - fytmpi += (fij[1] + fik[1]); - fztmpi += (fij[2] + fik[2]); + fxtmpi += static_cast(fij[0] + fik[0]); + fytmpi += static_cast(fij[1] + fik[1]); + fztmpi += static_cast(fij[2] + fik[2]); fxtmpj += Fj[0]; fytmpj += Fj[1]; fztmpj += Fj[2]; @@ -1026,54 +1026,54 @@ PairUF3Kokkos::operator()(TagPairUF3ComputeFullA, a_f(k, 2) += Fk[2]; if (EVFLAG) { - if (eflag) { ev.evdwl += evdwl3; } + if (eflag) { ev.evdwl += static_cast(evdwl3); } if (vflag_either || eflag_atom) { this->template ev_tally3(ev, i, j, k, evdwl3, 0.0, Fj, Fk, del_rji, del_rki); if (cvflag_atom) { KK_FLOAT ric[3]; - ric[0] = THIRD * (-del_rji[0] - del_rki[0]); - ric[1] = THIRD * (-del_rji[1] - del_rki[1]); - ric[2] = THIRD * (-del_rji[2] - del_rki[2]); - a_cvatom(i, 0) += ric[0] * (-Fj[0] - Fk[0]); - a_cvatom(i, 1) += ric[1] * (-Fj[1] - Fk[1]); - a_cvatom(i, 2) += ric[2] * (-Fj[2] - Fk[2]); - a_cvatom(i, 3) += ric[0] * (-Fj[1] - Fk[1]); - a_cvatom(i, 4) += ric[0] * (-Fj[2] - Fk[2]); - a_cvatom(i, 5) += ric[1] * (-Fj[2] - Fk[2]); - a_cvatom(i, 6) += ric[1] * (-Fj[0] - Fk[0]); - a_cvatom(i, 7) += ric[2] * (-Fj[0] - Fk[0]); - a_cvatom(i, 8) += ric[2] * (-Fj[1] - Fk[1]); + ric[0] = static_cast(THIRD) * (-del_rji[0] - del_rki[0]); + ric[1] = static_cast(THIRD) * (-del_rji[1] - del_rki[1]); + ric[2] = static_cast(THIRD) * (-del_rji[2] - del_rki[2]); + a_cvatom(i, 0) += static_cast(ric[0]) * (-Fj[0] - Fk[0]); + a_cvatom(i, 1) += static_cast(ric[1]) * (-Fj[1] - Fk[1]); + a_cvatom(i, 2) += static_cast(ric[2]) * (-Fj[2] - Fk[2]); + a_cvatom(i, 3) += static_cast(ric[0]) * (-Fj[1] - Fk[1]); + a_cvatom(i, 4) += static_cast(ric[0]) * (-Fj[2] - Fk[2]); + a_cvatom(i, 5) += static_cast(ric[1]) * (-Fj[2] - Fk[2]); + a_cvatom(i, 6) += static_cast(ric[1]) * (-Fj[0] - Fk[0]); + a_cvatom(i, 7) += static_cast(ric[2]) * (-Fj[0] - Fk[0]); + a_cvatom(i, 8) += static_cast(ric[2]) * (-Fj[1] - Fk[1]); KK_FLOAT rjc[3]; - rjc[0] = THIRD * (del_rji[0] - del_rkj[0]); - rjc[1] = THIRD * (del_rji[1] - del_rkj[1]); - rjc[2] = THIRD * (del_rji[2] - del_rkj[2]); - - a_cvatom(j, 0) += rjc[0] * Fj[0]; - a_cvatom(j, 1) += rjc[1] * Fj[1]; - a_cvatom(j, 2) += rjc[2] * Fj[2]; - a_cvatom(j, 3) += rjc[0] * Fj[1]; - a_cvatom(j, 4) += rjc[0] * Fj[2]; - a_cvatom(j, 5) += rjc[1] * Fj[2]; - a_cvatom(j, 6) += rjc[1] * Fj[0]; - a_cvatom(j, 7) += rjc[2] * Fj[0]; - a_cvatom(j, 8) += rjc[2] * Fj[1]; + rjc[0] = static_cast(THIRD) * (del_rji[0] - del_rkj[0]); + rjc[1] = static_cast(THIRD) * (del_rji[1] - del_rkj[1]); + rjc[2] = static_cast(THIRD) * (del_rji[2] - del_rkj[2]); + + a_cvatom(j, 0) += static_cast(rjc[0]) * Fj[0]; + a_cvatom(j, 1) += static_cast(rjc[1]) * Fj[1]; + a_cvatom(j, 2) += static_cast(rjc[2]) * Fj[2]; + a_cvatom(j, 3) += static_cast(rjc[0]) * Fj[1]; + a_cvatom(j, 4) += static_cast(rjc[0]) * Fj[2]; + a_cvatom(j, 5) += static_cast(rjc[1]) * Fj[2]; + a_cvatom(j, 6) += static_cast(rjc[1]) * Fj[0]; + a_cvatom(j, 7) += static_cast(rjc[2]) * Fj[0]; + a_cvatom(j, 8) += static_cast(rjc[2]) * Fj[1]; KK_FLOAT rkc[3]; - rkc[0] = THIRD * (del_rki[0] + del_rkj[0]); - rkc[1] = THIRD * (del_rki[1] + del_rkj[1]); - rkc[2] = THIRD * (del_rki[2] + del_rkj[2]); - - a_cvatom(k, 0) += rkc[0] * Fk[0]; - a_cvatom(k, 1) += rkc[1] * Fk[1]; - a_cvatom(k, 2) += rkc[2] * Fk[2]; - a_cvatom(k, 3) += rkc[0] * Fk[1]; - a_cvatom(k, 4) += rkc[0] * Fk[2]; - a_cvatom(k, 5) += rkc[1] * Fk[2]; - a_cvatom(k, 6) += rkc[1] * Fk[0]; - a_cvatom(k, 7) += rkc[2] * Fk[0]; - a_cvatom(k, 8) += rkc[2] * Fk[1]; + rkc[0] = static_cast(THIRD) * (del_rki[0] + del_rkj[0]); + rkc[1] = static_cast(THIRD) * (del_rki[1] + del_rkj[1]); + rkc[2] = static_cast(THIRD) * (del_rki[2] + del_rkj[2]); + + a_cvatom(k, 0) += static_cast(rkc[0]) * Fk[0]; + a_cvatom(k, 1) += static_cast(rkc[1]) * Fk[1]; + a_cvatom(k, 2) += static_cast(rkc[2]) * Fk[2]; + a_cvatom(k, 3) += static_cast(rkc[0]) * Fk[1]; + a_cvatom(k, 4) += static_cast(rkc[0]) * Fk[2]; + a_cvatom(k, 5) += static_cast(rkc[1]) * Fk[2]; + a_cvatom(k, 6) += static_cast(rkc[1]) * Fk[0]; + a_cvatom(k, 7) += static_cast(rkc[2]) * Fk[0]; + a_cvatom(k, 8) += static_cast(rkc[2]) * Fk[1]; } } } @@ -1118,9 +1118,9 @@ PairUF3Kokkos::ev_tally(EV_FLOAT &ev, const int &i, const int &j, co auto a_cvatom = cvscatter.access(); if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; - a_eatom[i] += epairhalf; - a_eatom[j] += epairhalf; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; + a_eatom[i] += static_cast(epairhalf); + a_eatom[j] += static_cast(epairhalf); } if (vflag_either) { @@ -1132,49 +1132,49 @@ PairUF3Kokkos::ev_tally(EV_FLOAT &ev, const int &i, const int &j, co const KK_FLOAT v5 = dely * delz * fpair; if (vflag_global) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } if (vflag_atom) { - a_vatom(i, 0) += 0.5 * v0; - a_vatom(i, 1) += 0.5 * v1; - a_vatom(i, 2) += 0.5 * v2; - a_vatom(i, 3) += 0.5 * v3; - a_vatom(i, 4) += 0.5 * v4; - a_vatom(i, 5) += 0.5 * v5; - - a_vatom(j, 0) += 0.5 * v0; - a_vatom(j, 1) += 0.5 * v1; - a_vatom(j, 2) += 0.5 * v2; - a_vatom(j, 3) += 0.5 * v3; - a_vatom(j, 4) += 0.5 * v4; - a_vatom(j, 5) += 0.5 * v5; + a_vatom(i, 0) += static_cast(0.5) * static_cast(v0); + a_vatom(i, 1) += static_cast(0.5) * static_cast(v1); + a_vatom(i, 2) += static_cast(0.5) * static_cast(v2); + a_vatom(i, 3) += static_cast(0.5) * static_cast(v3); + a_vatom(i, 4) += static_cast(0.5) * static_cast(v4); + a_vatom(i, 5) += static_cast(0.5) * static_cast(v5); + + a_vatom(j, 0) += static_cast(0.5) * static_cast(v0); + a_vatom(j, 1) += static_cast(0.5) * static_cast(v1); + a_vatom(j, 2) += static_cast(0.5) * static_cast(v2); + a_vatom(j, 3) += static_cast(0.5) * static_cast(v3); + a_vatom(j, 4) += static_cast(0.5) * static_cast(v4); + a_vatom(j, 5) += static_cast(0.5) * static_cast(v5); } if (cvflag_atom) { - a_cvatom(i, 0) += 0.5 * v0; - a_cvatom(i, 1) += 0.5 * v1; - a_cvatom(i, 2) += 0.5 * v2; - a_cvatom(i, 3) += 0.5 * v3; - a_cvatom(i, 4) += 0.5 * v4; - a_cvatom(i, 5) += 0.5 * v5; - a_cvatom(i, 6) += 0.5 * v3; - a_cvatom(i, 7) += 0.5 * v4; - a_cvatom(i, 8) += 0.5 * v5; - a_cvatom(j, 0) += 0.5 * v0; - a_cvatom(j, 1) += 0.5 * v1; - a_cvatom(j, 2) += 0.5 * v2; - a_cvatom(j, 3) += 0.5 * v3; - a_cvatom(j, 4) += 0.5 * v4; - a_cvatom(j, 5) += 0.5 * v5; - a_cvatom(j, 6) += 0.5 * v3; - a_cvatom(j, 7) += 0.5 * v4; - a_cvatom(j, 8) += 0.5 * v5; + a_cvatom(i, 0) += static_cast(0.5) * static_cast(v0); + a_cvatom(i, 1) += static_cast(0.5) * static_cast(v1); + a_cvatom(i, 2) += static_cast(0.5) * static_cast(v2); + a_cvatom(i, 3) += static_cast(0.5) * static_cast(v3); + a_cvatom(i, 4) += static_cast(0.5) * static_cast(v4); + a_cvatom(i, 5) += static_cast(0.5) * static_cast(v5); + a_cvatom(i, 6) += static_cast(0.5) * static_cast(v3); + a_cvatom(i, 7) += static_cast(0.5) * static_cast(v4); + a_cvatom(i, 8) += static_cast(0.5) * static_cast(v5); + a_cvatom(j, 0) += static_cast(0.5) * static_cast(v0); + a_cvatom(j, 1) += static_cast(0.5) * static_cast(v1); + a_cvatom(j, 2) += static_cast(0.5) * static_cast(v2); + a_cvatom(j, 3) += static_cast(0.5) * static_cast(v3); + a_cvatom(j, 4) += static_cast(0.5) * static_cast(v4); + a_cvatom(j, 5) += static_cast(0.5) * static_cast(v5); + a_cvatom(j, 6) += static_cast(0.5) * static_cast(v3); + a_cvatom(j, 7) += static_cast(0.5) * static_cast(v4); + a_cvatom(j, 8) += static_cast(0.5) * static_cast(v5); } } } @@ -1202,50 +1202,50 @@ PairUF3Kokkos::ev_tally3(EV_FLOAT &ev, const int &i, const int &j, i auto a_vatom = vscatter.access(); if (eflag_atom) { - epairthird = THIRD * (evdwl + ecoul); - a_eatom[i] += epairthird; - a_eatom[j] += epairthird; - a_eatom[k] += epairthird; + epairthird = static_cast(THIRD) * (evdwl + ecoul); + a_eatom[i] += static_cast(epairthird); + a_eatom[j] += static_cast(epairthird); + a_eatom[k] += static_cast(epairthird); } if (vflag_either) { - v[0] = drji[0] * fj[0] + drki[0] * fk[0]; - v[1] = drji[1] * fj[1] + drki[1] * fk[1]; - v[2] = drji[2] * fj[2] + drki[2] * fk[2]; - v[3] = drji[0] * fj[1] + drki[0] * fk[1]; - v[4] = drji[0] * fj[2] + drki[0] * fk[2]; - v[5] = drji[1] * fj[2] + drki[1] * fk[2]; + v[0] = drji[0] * static_cast(fj[0]) + drki[0] * static_cast(fk[0]); + v[1] = drji[1] * static_cast(fj[1]) + drki[1] * static_cast(fk[1]); + v[2] = drji[2] * static_cast(fj[2]) + drki[2] * static_cast(fk[2]); + v[3] = drji[0] * static_cast(fj[1]) + drki[0] * static_cast(fk[1]); + v[4] = drji[0] * static_cast(fj[2]) + drki[0] * static_cast(fk[2]); + v[5] = drji[1] * static_cast(fj[2]) + drki[1] * static_cast(fk[2]); if (vflag_global) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } if (vflag_atom) { - a_vatom(i, 0) += THIRD * v[0]; - a_vatom(i, 1) += THIRD * v[1]; - a_vatom(i, 2) += THIRD * v[2]; - a_vatom(i, 3) += THIRD * v[3]; - a_vatom(i, 4) += THIRD * v[4]; - a_vatom(i, 5) += THIRD * v[5]; - - a_vatom(j, 0) += THIRD * v[0]; - a_vatom(j, 1) += THIRD * v[1]; - a_vatom(j, 2) += THIRD * v[2]; - a_vatom(j, 3) += THIRD * v[3]; - a_vatom(j, 4) += THIRD * v[4]; - a_vatom(j, 5) += THIRD * v[5]; - - a_vatom(k, 0) += THIRD * v[0]; - a_vatom(k, 1) += THIRD * v[1]; - a_vatom(k, 2) += THIRD * v[2]; - a_vatom(k, 3) += THIRD * v[3]; - a_vatom(k, 4) += THIRD * v[4]; - a_vatom(k, 5) += THIRD * v[5]; + a_vatom(i, 0) += static_cast(THIRD) * static_cast(v[0]); + a_vatom(i, 1) += static_cast(THIRD) * static_cast(v[1]); + a_vatom(i, 2) += static_cast(THIRD) * static_cast(v[2]); + a_vatom(i, 3) += static_cast(THIRD) * static_cast(v[3]); + a_vatom(i, 4) += static_cast(THIRD) * static_cast(v[4]); + a_vatom(i, 5) += static_cast(THIRD) * static_cast(v[5]); + + a_vatom(j, 0) += static_cast(THIRD) * static_cast(v[0]); + a_vatom(j, 1) += static_cast(THIRD) * static_cast(v[1]); + a_vatom(j, 2) += static_cast(THIRD) * static_cast(v[2]); + a_vatom(j, 3) += static_cast(THIRD) * static_cast(v[3]); + a_vatom(j, 4) += static_cast(THIRD) * static_cast(v[4]); + a_vatom(j, 5) += static_cast(THIRD) * static_cast(v[5]); + + a_vatom(k, 0) += static_cast(THIRD) * static_cast(v[0]); + a_vatom(k, 1) += static_cast(THIRD) * static_cast(v[1]); + a_vatom(k, 2) += static_cast(THIRD) * static_cast(v[2]); + a_vatom(k, 3) += static_cast(THIRD) * static_cast(v[3]); + a_vatom(k, 4) += static_cast(THIRD) * static_cast(v[4]); + a_vatom(k, 5) += static_cast(THIRD) * static_cast(v[5]); } } } @@ -1619,9 +1619,9 @@ double PairUF3Kokkos::single(int /*i*/, int /*j*/, int itype, int jt double r = sqrt(rsq); int interaction_id = map2b(itype, jtype); int start_index = 3; - while (r > d_n2b_knot(interaction_id, start_index + 1)) start_index++; + while (r > static_cast(d_n2b_knot(interaction_id, start_index + 1))) start_index++; - if (r < d_cutsq(itype, jtype)) { + if (r < static_cast(d_cutsq(itype, jtype))) { double r_values[4]; r_values[0] = 1; r_values[1] = r; @@ -1629,33 +1629,33 @@ double PairUF3Kokkos::single(int /*i*/, int /*j*/, int itype, int jt r_values[3] = r_values[2] * r_values[1]; // Calculate energy - value = constants_2b(interaction_id, start_index, 0); - value += r_values[1] * constants_2b(interaction_id, start_index, 1); - value += r_values[2] * constants_2b(interaction_id, start_index, 2); - value += r_values[3] * constants_2b(interaction_id, start_index, 3); - value += constants_2b(interaction_id, start_index - 1, 4); - value += r_values[1] * constants_2b(interaction_id, start_index - 1, 5); - value += r_values[2] * constants_2b(interaction_id, start_index - 1, 6); - value += r_values[3] * constants_2b(interaction_id, start_index - 1, 7); - value += constants_2b(interaction_id, start_index - 2, 8); - value += r_values[1] * constants_2b(interaction_id, start_index - 2, 9); - value += r_values[2] * constants_2b(interaction_id, start_index - 2, 10); - value += r_values[3] * constants_2b(interaction_id, start_index - 2, 11); - value += constants_2b(interaction_id, start_index - 3, 12); - value += r_values[1] * constants_2b(interaction_id, start_index - 3, 13); - value += r_values[2] * constants_2b(interaction_id, start_index - 3, 14); - value += r_values[3] * constants_2b(interaction_id, start_index - 3, 15); + value = static_cast(constants_2b(interaction_id, start_index, 0)); + value += r_values[1] * static_cast(constants_2b(interaction_id, start_index, 1)); + value += r_values[2] * static_cast(constants_2b(interaction_id, start_index, 2)); + value += r_values[3] * static_cast(constants_2b(interaction_id, start_index, 3)); + value += static_cast(constants_2b(interaction_id, start_index - 1, 4)); + value += r_values[1] * static_cast(constants_2b(interaction_id, start_index - 1, 5)); + value += r_values[2] * static_cast(constants_2b(interaction_id, start_index - 1, 6)); + value += r_values[3] * static_cast(constants_2b(interaction_id, start_index - 1, 7)); + value += static_cast(constants_2b(interaction_id, start_index - 2, 8)); + value += r_values[1] * static_cast(constants_2b(interaction_id, start_index - 2, 9)); + value += r_values[2] * static_cast(constants_2b(interaction_id, start_index - 2, 10)); + value += r_values[3] * static_cast(constants_2b(interaction_id, start_index - 2, 11)); + value += static_cast(constants_2b(interaction_id, start_index - 3, 12)); + value += r_values[1] * static_cast(constants_2b(interaction_id, start_index - 3, 13)); + value += r_values[2] * static_cast(constants_2b(interaction_id, start_index - 3, 14)); + value += r_values[3] * static_cast(constants_2b(interaction_id, start_index - 3, 15)); // Calculate force - fforce = dnconstants_2b(interaction_id, start_index - 1, 0); - fforce += r_values[1] * dnconstants_2b(interaction_id, start_index - 1, 1); - fforce += r_values[2] * dnconstants_2b(interaction_id, start_index - 1, 2); - fforce += dnconstants_2b(interaction_id, start_index - 2, 3); - fforce += r_values[1] * dnconstants_2b(interaction_id, start_index - 2, 4); - fforce += r_values[2] * dnconstants_2b(interaction_id, start_index - 2, 5); - fforce += dnconstants_2b(interaction_id, start_index - 3, 6); - fforce += r_values[1] * dnconstants_2b(interaction_id, start_index - 3, 7); - fforce += r_values[2] * dnconstants_2b(interaction_id, start_index - 3, 8); + fforce = static_cast(dnconstants_2b(interaction_id, start_index - 1, 0)); + fforce += r_values[1] * static_cast(dnconstants_2b(interaction_id, start_index - 1, 1)); + fforce += r_values[2] * static_cast(dnconstants_2b(interaction_id, start_index - 1, 2)); + fforce += static_cast(dnconstants_2b(interaction_id, start_index - 2, 3)); + fforce += r_values[1] * static_cast(dnconstants_2b(interaction_id, start_index - 2, 4)); + fforce += r_values[2] * static_cast(dnconstants_2b(interaction_id, start_index - 2, 5)); + fforce += static_cast(dnconstants_2b(interaction_id, start_index - 3, 6)); + fforce += r_values[1] * static_cast(dnconstants_2b(interaction_id, start_index - 3, 7)); + fforce += r_values[2] * static_cast(dnconstants_2b(interaction_id, start_index - 3, 8)); } return factor_lj * value; diff --git a/src/KOKKOS/pair_ufm_kokkos.cpp b/src/KOKKOS/pair_ufm_kokkos.cpp index 3f76147b6eb..eed63880842 100644 --- a/src/KOKKOS/pair_ufm_kokkos.cpp +++ b/src/KOKKOS/pair_ufm_kokkos.cpp @@ -97,22 +97,22 @@ void PairUFMKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); copymode = 1; EV_FLOAT ev = pair_compute,void>(this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -139,7 +139,7 @@ compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c const KK_FLOAT uf1 = STACKPARAMS ? m_params[itype][jtype].uf1 : params(itype,jtype).uf1; const KK_FLOAT uf2 = STACKPARAMS ? m_params[itype][jtype].uf2 : params(itype,jtype).uf2; const KK_FLOAT scale = STACKPARAMS ? m_params[itype][jtype].scale : params(itype,jtype).scale; - const KK_FLOAT expuf = exp(-rsq * uf2); + const KK_FLOAT expuf = Kokkos::exp(-rsq * uf2); return scale * uf1 * expuf / (static_cast(1.0) - expuf); } @@ -152,8 +152,8 @@ compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, c const KK_FLOAT uf2 = STACKPARAMS ? m_params[itype][jtype].uf2 : params(itype,jtype).uf2; const KK_FLOAT uf3 = STACKPARAMS ? m_params[itype][jtype].uf3 : params(itype,jtype).uf3; const KK_FLOAT offset = STACKPARAMS ? m_params[itype][jtype].offset : params(itype,jtype).offset; - const KK_FLOAT expuf = exp(-rsq * uf2); - return -uf3 * log(static_cast(1.0) - expuf) - offset; + const KK_FLOAT expuf = Kokkos::exp(-rsq * uf2); + return -uf3 * Kokkos::log(static_cast(1.0) - expuf) - offset; } /* ---------------------------------------------------------------------- diff --git a/src/KOKKOS/pair_vashishta_kokkos.cpp b/src/KOKKOS/pair_vashishta_kokkos.cpp index 47d63868418..baaaefa3bfa 100644 --- a/src/KOKKOS/pair_vashishta_kokkos.cpp +++ b/src/KOKKOS/pair_vashishta_kokkos.cpp @@ -164,14 +164,14 @@ void PairVashishtaKokkos::compute(int eflag_in, int vflag_in) ev_all += ev; } - if (eflag_global) eng_vdwl += ev_all.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev_all.evdwl); if (vflag_global) { - virial[0] += ev_all.v[0]; - virial[1] += ev_all.v[1]; - virial[2] += ev_all.v[2]; - virial[3] += ev_all.v[3]; - virial[4] += ev_all.v[4]; - virial[5] += ev_all.v[5]; + virial[0] += static_cast(ev_all.v[0]); + virial[1] += static_cast(ev_all.v[1]); + virial[2] += static_cast(ev_all.v[2]); + virial[3] += static_cast(ev_all.v[3]); + virial[4] += static_cast(ev_all.v[4]); + virial[5] += static_cast(ev_all.v[5]); } if (eflag_atom) { @@ -213,12 +213,12 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeShortNei const KK_FLOAT delz = ztmp - x(j,2); const KK_FLOAT rsq = delx*delx + dely*dely + delz*delz; - if (rsq < d_params[ijparam].cutsq) { + if (rsq < static_cast(d_params[ijparam].cutsq)) { d_neighbors_short_2body(ii,inside_2body) = j; inside_2body++; } - if (rsq < d_params[ijparam].cutsq2) { + if (rsq < static_cast(d_params[ijparam].cutsq2)) { d_neighbors_short_3body(ii,inside_3body) = j; inside_3body++; } @@ -283,15 +283,15 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeHalf(delx*fpair); + fytmpi += static_cast(dely*fpair); + fztmpi += static_cast(delz*fpair); + a_f(j,0) -= static_cast(delx*fpair); + a_f(j,1) -= static_cast(dely*fpair); + a_f(j,2) -= static_cast(delz*fpair); if (EVFLAG) { - if (eflag) ev.evdwl += evdwl; + if (eflag) ev.evdwl += static_cast(evdwl); if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,evdwl,fpair,delx,dely,delz); } } @@ -338,7 +338,7 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeHalf(evdwl); if (vflag_either || eflag_atom) this->template ev_tally3(ev,i,j,k,evdwl,0.0,fj,fk,delr1,delr2); } } @@ -405,12 +405,12 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeFullA(delx*fpair); + fytmpi += static_cast(dely*fpair); + fztmpi += static_cast(delz*fpair); if (EVFLAG) { - if (eflag) ev.evdwl += 0.5*evdwl; + if (eflag) ev.evdwl += static_cast(0.5)*static_cast(evdwl); if (vflag_either || eflag_atom) this->template ev_tally(ev,i,j,evdwl,fpair,delx,dely,delz); } } @@ -447,7 +447,7 @@ void PairVashishtaKokkos::operator()(TagPairVashishtaComputeFullA(evdwl); if (vflag_either || eflag_atom) this->template ev_tally3(ev,i,j,k,evdwl,0.0,fj,fk,delr1,delr2); } } @@ -638,22 +638,33 @@ void PairVashishtaKokkos::twobody(const Param& param, const KK_FLOAT const int& eflag, KK_FLOAT& eng) const { KK_FLOAT r,rinvsq,r4inv,r6inv,reta,lam1r,lam4r,vc2,vc3; - r = sqrt(rsq); - rinvsq = 1.0/rsq; + const KK_FLOAT eta_kk = static_cast(param.eta); + const KK_FLOAT lam1inv_kk = static_cast(param.lam1inv); + const KK_FLOAT lam4inv_kk = static_cast(param.lam4inv); + const KK_FLOAT zizj_kk = static_cast(param.zizj); + const KK_FLOAT mbigd_kk = static_cast(param.mbigd); + const KK_FLOAT dvrc_kk = static_cast(param.dvrc); + const KK_FLOAT big6w_kk = static_cast(param.big6w); + const KK_FLOAT heta_kk = static_cast(param.heta); + const KK_FLOAT bigh_kk = static_cast(param.bigh); + const KK_FLOAT bigw_kk = static_cast(param.bigw); + const KK_FLOAT c0_kk = static_cast(param.c0); + r = Kokkos::sqrt(rsq); + rinvsq = static_cast(1.0)/rsq; r4inv = rinvsq*rinvsq; r6inv = rinvsq*r4inv; - reta = pow(r,-param.eta); - lam1r = r*param.lam1inv; - lam4r = r*param.lam4inv; - vc2 = param.zizj * exp(-lam1r)/r; - vc3 = param.mbigd * r4inv*exp(-lam4r); - - fforce = (param.dvrc*r - - (4.0*vc3 + lam4r*vc3+param.big6w*r6inv - - param.heta*reta - vc2 - lam1r*vc2) + reta = Kokkos::pow(r,-eta_kk); + lam1r = r*lam1inv_kk; + lam4r = r*lam4inv_kk; + vc2 = zizj_kk * Kokkos::exp(-lam1r)/r; + vc3 = mbigd_kk * r4inv*Kokkos::exp(-lam4r); + + fforce = (dvrc_kk*r + - (static_cast(4.0)*vc3 + lam4r*vc3+big6w_kk*r6inv + - heta_kk*reta - vc2 - lam1r*vc2) ) * rinvsq; - if (eflag) eng = param.bigh*reta + vc2 - vc3 - param.bigw*r6inv - r*param.dvrc + param.c0; + if (eflag) eng = bigh_kk*reta + vc2 - vc3 - bigw_kk*r6inv - r*dvrc_kk + c0_kk; } /* ---------------------------------------------------------------------- */ @@ -671,47 +682,56 @@ void PairVashishtaKokkos::threebody(const Param& paramij, const Para KK_FLOAT rinv12,cs,delcs,delcssq,facexp,facrad,frad1,frad2,pcsinv,pcsinvsq,pcs; KK_FLOAT facang,facang12,csfacang,csfac1,csfac2; - r1 = sqrt(rsq1); - rinvsq1 = 1.0/rsq1; - rainv1 = 1.0/(r1 - paramij.r0); - gsrainv1 = paramij.gamma * rainv1; + const KK_FLOAT r0ij_kk = static_cast(paramij.r0); + const KK_FLOAT gammaij_kk = static_cast(paramij.gamma); + const KK_FLOAT r0ik_kk = static_cast(paramik.r0); + const KK_FLOAT gammaik_kk = static_cast(paramik.gamma); + const KK_FLOAT costheta_kk = static_cast(paramijk.costheta); + const KK_FLOAT bigc_kk = static_cast(paramijk.bigc); + const KK_FLOAT bigb_kk = static_cast(paramijk.bigb); + const KK_FLOAT big2b_kk = static_cast(paramijk.big2b); + + r1 = Kokkos::sqrt(rsq1); + rinvsq1 = static_cast(1.0)/rsq1; + rainv1 = static_cast(1.0)/(r1 - r0ij_kk); + gsrainv1 = gammaij_kk * rainv1; gsrainvsq1 = gsrainv1*rainv1/r1; - expgsrainv1 = exp(gsrainv1); + expgsrainv1 = Kokkos::exp(gsrainv1); - r2 = sqrt(rsq2); - rinvsq2 = 1.0/rsq2; - rainv2 = 1.0/(r2 - paramik.r0); - gsrainv2 = paramik.gamma * rainv2; + r2 = Kokkos::sqrt(rsq2); + rinvsq2 = static_cast(1.0)/rsq2; + rainv2 = static_cast(1.0)/(r2 - r0ik_kk); + gsrainv2 = gammaik_kk * rainv2; gsrainvsq2 = gsrainv2*rainv2/r2; - expgsrainv2 = exp(gsrainv2); + expgsrainv2 = Kokkos::exp(gsrainv2); - rinv12 = 1.0/(r1*r2); + rinv12 = static_cast(1.0)/(r1*r2); cs = (delr1[0]*delr2[0] + delr1[1]*delr2[1] + delr1[2]*delr2[2]) * rinv12; - delcs = cs - paramijk.costheta; + delcs = cs - costheta_kk; delcssq = delcs*delcs; - pcsinv = paramijk.bigc*delcssq + 1.0; + pcsinv = bigc_kk*delcssq + static_cast(1.0); pcsinvsq = pcsinv*pcsinv; pcs = delcssq/pcsinv; facexp = expgsrainv1*expgsrainv2; - facrad = paramijk.bigb * facexp * pcs; + facrad = bigb_kk * facexp * pcs; frad1 = facrad*gsrainvsq1; frad2 = facrad*gsrainvsq2; - facang = paramijk.big2b * facexp * delcs/pcsinvsq; + facang = big2b_kk * facexp * delcs/pcsinvsq; facang12 = rinv12*facang; csfacang = cs*facang; csfac1 = rinvsq1*csfacang; - fj[0] = delr1[0]*(frad1+csfac1)-delr2[0]*facang12; - fj[1] = delr1[1]*(frad1+csfac1)-delr2[1]*facang12; - fj[2] = delr1[2]*(frad1+csfac1)-delr2[2]*facang12; + fj[0] = static_cast(delr1[0]*(frad1+csfac1)-delr2[0]*facang12); + fj[1] = static_cast(delr1[1]*(frad1+csfac1)-delr2[1]*facang12); + fj[2] = static_cast(delr1[2]*(frad1+csfac1)-delr2[2]*facang12); csfac2 = rinvsq2*csfacang; - fk[0] = delr2[0]*(frad2+csfac2)-delr1[0]*facang12; - fk[1] = delr2[1]*(frad2+csfac2)-delr1[1]*facang12; - fk[2] = delr2[2]*(frad2+csfac2)-delr1[2]*facang12; + fk[0] = static_cast(delr2[0]*(frad2+csfac2)-delr1[0]*facang12); + fk[1] = static_cast(delr2[1]*(frad2+csfac2)-delr1[1]*facang12); + fk[2] = static_cast(delr2[2]*(frad2+csfac2)-delr1[2]*facang12); if (eflag) eng = facrad; } @@ -729,38 +749,47 @@ void PairVashishtaKokkos::threebodyj(const Param& paramij, const Par KK_FLOAT rinv12,cs,delcs,delcssq,facexp,facrad,frad1,pcsinv,pcsinvsq,pcs; KK_FLOAT facang,facang12,csfacang,csfac1; - r1 = sqrt(rsq1); - rinvsq1 = 1.0/rsq1; - rainv1 = 1.0/(r1 - paramij.r0); - gsrainv1 = paramij.gamma * rainv1; + const KK_FLOAT r0ij_kk = static_cast(paramij.r0); + const KK_FLOAT gammaij_kk = static_cast(paramij.gamma); + const KK_FLOAT r0ik_kk = static_cast(paramik.r0); + const KK_FLOAT gammaik_kk = static_cast(paramik.gamma); + const KK_FLOAT costheta_kk = static_cast(paramijk.costheta); + const KK_FLOAT bigc_kk = static_cast(paramijk.bigc); + const KK_FLOAT bigb_kk = static_cast(paramijk.bigb); + const KK_FLOAT big2b_kk = static_cast(paramijk.big2b); + + r1 = Kokkos::sqrt(rsq1); + rinvsq1 = static_cast(1.0)/rsq1; + rainv1 = static_cast(1.0)/(r1 - r0ij_kk); + gsrainv1 = gammaij_kk * rainv1; gsrainvsq1 = gsrainv1*rainv1/r1; - expgsrainv1 = exp(gsrainv1); + expgsrainv1 = Kokkos::exp(gsrainv1); - r2 = sqrt(rsq2); - rainv2 = 1.0/(r2 - paramik.r0); - gsrainv2 = paramik.gamma * rainv2; - expgsrainv2 = exp(gsrainv2); + r2 = Kokkos::sqrt(rsq2); + rainv2 = static_cast(1.0)/(r2 - r0ik_kk); + gsrainv2 = gammaik_kk * rainv2; + expgsrainv2 = Kokkos::exp(gsrainv2); - rinv12 = 1.0/(r1*r2); + rinv12 = static_cast(1.0)/(r1*r2); cs = (delr1[0]*delr2[0] + delr1[1]*delr2[1] + delr1[2]*delr2[2]) * rinv12; - delcs = cs - paramijk.costheta; + delcs = cs - costheta_kk; delcssq = delcs*delcs; - pcsinv = paramijk.bigc*delcssq + 1.0; + pcsinv = bigc_kk*delcssq + static_cast(1.0); pcsinvsq = pcsinv*pcsinv; pcs = delcssq/pcsinv; facexp = expgsrainv1*expgsrainv2; - facrad = paramijk.bigb * facexp * pcs; + facrad = bigb_kk * facexp * pcs; frad1 = facrad*gsrainvsq1; - facang = paramijk.big2b * facexp * delcs/pcsinvsq; + facang = big2b_kk * facexp * delcs/pcsinvsq; facang12 = rinv12*facang; csfacang = cs*facang; csfac1 = rinvsq1*csfacang; - fj[0] = delr1[0]*(frad1+csfac1)-delr2[0]*facang12; - fj[1] = delr1[1]*(frad1+csfac1)-delr2[1]*facang12; - fj[2] = delr1[2]*(frad1+csfac1)-delr2[2]*facang12; + fj[0] = static_cast(delr1[0]*(frad1+csfac1)-delr2[0]*facang12); + fj[1] = static_cast(delr1[1]*(frad1+csfac1)-delr2[1]*facang12); + fj[2] = static_cast(delr1[2]*(frad1+csfac1)-delr2[2]*facang12); } /* ---------------------------------------------------------------------- */ @@ -782,10 +811,10 @@ void PairVashishtaKokkos::ev_tally(EV_FLOAT &ev, const int &i, const if (eflag_atom) { - const KK_FLOAT epairhalf = 0.5 * epair; - v_eatom[i] += epairhalf; + const KK_FLOAT epairhalf = static_cast(0.5) * epair; + v_eatom[i] += static_cast(epairhalf); if (NEIGHFLAG != FULL) - v_eatom[j] += epairhalf; + v_eatom[j] += static_cast(epairhalf); } if (VFLAG) { @@ -798,37 +827,37 @@ void PairVashishtaKokkos::ev_tally(EV_FLOAT &ev, const int &i, const if (vflag_global) { if (NEIGHFLAG != FULL) { - ev.v[0] += v0; - ev.v[1] += v1; - ev.v[2] += v2; - ev.v[3] += v3; - ev.v[4] += v4; - ev.v[5] += v5; + ev.v[0] += static_cast(v0); + ev.v[1] += static_cast(v1); + ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); + ev.v[4] += static_cast(v4); + ev.v[5] += static_cast(v5); } else { - ev.v[0] += 0.5*v0; - ev.v[1] += 0.5*v1; - ev.v[2] += 0.5*v2; - ev.v[3] += 0.5*v3; - ev.v[4] += 0.5*v4; - ev.v[5] += 0.5*v5; + ev.v[0] += static_cast(0.5)*static_cast(v0); + ev.v[1] += static_cast(0.5)*static_cast(v1); + ev.v[2] += static_cast(0.5)*static_cast(v2); + ev.v[3] += static_cast(0.5)*static_cast(v3); + ev.v[4] += static_cast(0.5)*static_cast(v4); + ev.v[5] += static_cast(0.5)*static_cast(v5); } } if (vflag_atom) { - v_vatom(i,0) += 0.5*v0; - v_vatom(i,1) += 0.5*v1; - v_vatom(i,2) += 0.5*v2; - v_vatom(i,3) += 0.5*v3; - v_vatom(i,4) += 0.5*v4; - v_vatom(i,5) += 0.5*v5; + v_vatom(i,0) += static_cast(0.5)*static_cast(v0); + v_vatom(i,1) += static_cast(0.5)*static_cast(v1); + v_vatom(i,2) += static_cast(0.5)*static_cast(v2); + v_vatom(i,3) += static_cast(0.5)*static_cast(v3); + v_vatom(i,4) += static_cast(0.5)*static_cast(v4); + v_vatom(i,5) += static_cast(0.5)*static_cast(v5); if (NEIGHFLAG != FULL) { - v_vatom(j,0) += 0.5*v0; - v_vatom(j,1) += 0.5*v1; - v_vatom(j,2) += 0.5*v2; - v_vatom(j,3) += 0.5*v3; - v_vatom(j,4) += 0.5*v4; - v_vatom(j,5) += 0.5*v5; + v_vatom(j,0) += static_cast(0.5)*static_cast(v0); + v_vatom(j,1) += static_cast(0.5)*static_cast(v1); + v_vatom(j,2) += static_cast(0.5)*static_cast(v2); + v_vatom(j,3) += static_cast(0.5)*static_cast(v3); + v_vatom(j,4) += static_cast(0.5)*static_cast(v4); + v_vatom(j,5) += static_cast(0.5)*static_cast(v5); } } } @@ -858,44 +887,44 @@ void PairVashishtaKokkos::ev_tally3(EV_FLOAT &ev, const int &i, cons Kokkos::View::value,Kokkos::MemoryTraits::value> > v_vatom = d_vatom; if (eflag_atom) { - epairthird = THIRD * (evdwl + ecoul); - v_eatom[i] += epairthird; + epairthird = static_cast(THIRD) * (evdwl + ecoul); + v_eatom[i] += static_cast(epairthird); if (NEIGHFLAG != FULL) { - v_eatom[j] += epairthird; - v_eatom[k] += epairthird; + v_eatom[j] += static_cast(epairthird); + v_eatom[k] += static_cast(epairthird); } } if (VFLAG) { - v[0] = drji[0]*fj[0] + drki[0]*fk[0]; - v[1] = drji[1]*fj[1] + drki[1]*fk[1]; - v[2] = drji[2]*fj[2] + drki[2]*fk[2]; - v[3] = drji[0]*fj[1] + drki[0]*fk[1]; - v[4] = drji[0]*fj[2] + drki[0]*fk[2]; - v[5] = drji[1]*fj[2] + drki[1]*fk[2]; + v[0] = drji[0]*static_cast(fj[0]) + drki[0]*static_cast(fk[0]); + v[1] = drji[1]*static_cast(fj[1]) + drki[1]*static_cast(fk[1]); + v[2] = drji[2]*static_cast(fj[2]) + drki[2]*static_cast(fk[2]); + v[3] = drji[0]*static_cast(fj[1]) + drki[0]*static_cast(fk[1]); + v[4] = drji[0]*static_cast(fj[2]) + drki[0]*static_cast(fk[2]); + v[5] = drji[1]*static_cast(fj[2]) + drki[1]*static_cast(fk[2]); if (vflag_global) { - ev.v[0] += v[0]; - ev.v[1] += v[1]; - ev.v[2] += v[2]; - ev.v[3] += v[3]; - ev.v[4] += v[4]; - ev.v[5] += v[5]; + ev.v[0] += static_cast(v[0]); + ev.v[1] += static_cast(v[1]); + ev.v[2] += static_cast(v[2]); + ev.v[3] += static_cast(v[3]); + ev.v[4] += static_cast(v[4]); + ev.v[5] += static_cast(v[5]); } if (vflag_atom) { - v_vatom(i,0) += THIRD*v[0]; v_vatom(i,1) += THIRD*v[1]; - v_vatom(i,2) += THIRD*v[2]; v_vatom(i,3) += THIRD*v[3]; - v_vatom(i,4) += THIRD*v[4]; v_vatom(i,5) += THIRD*v[5]; + v_vatom(i,0) += static_cast(THIRD)*static_cast(v[0]); v_vatom(i,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(i,2) += static_cast(THIRD)*static_cast(v[2]); v_vatom(i,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(i,4) += static_cast(THIRD)*static_cast(v[4]); v_vatom(i,5) += static_cast(THIRD)*static_cast(v[5]); if (NEIGHFLAG != FULL) { - v_vatom(j,0) += THIRD*v[0]; v_vatom(j,1) += THIRD*v[1]; - v_vatom(j,2) += THIRD*v[2]; v_vatom(j,3) += THIRD*v[3]; - v_vatom(j,4) += THIRD*v[4]; v_vatom(j,5) += THIRD*v[5]; + v_vatom(j,0) += static_cast(THIRD)*static_cast(v[0]); v_vatom(j,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(j,2) += static_cast(THIRD)*static_cast(v[2]); v_vatom(j,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(j,4) += static_cast(THIRD)*static_cast(v[4]); v_vatom(j,5) += static_cast(THIRD)*static_cast(v[5]); - v_vatom(k,0) += THIRD*v[0]; v_vatom(k,1) += THIRD*v[1]; - v_vatom(k,2) += THIRD*v[2]; v_vatom(k,3) += THIRD*v[3]; - v_vatom(k,4) += THIRD*v[4]; v_vatom(k,5) += THIRD*v[5]; + v_vatom(k,0) += static_cast(THIRD)*static_cast(v[0]); v_vatom(k,1) += static_cast(THIRD)*static_cast(v[1]); + v_vatom(k,2) += static_cast(THIRD)*static_cast(v[2]); v_vatom(k,3) += static_cast(THIRD)*static_cast(v[3]); + v_vatom(k,4) += static_cast(THIRD)*static_cast(v[4]); v_vatom(k,5) += static_cast(THIRD)*static_cast(v[5]); } } } @@ -922,22 +951,22 @@ void PairVashishtaKokkos::ev_tally3_atom(EV_FLOAT & /*ev*/, const in const int VFLAG = vflag_atom; if (eflag_atom) { - epairthird = THIRD * (evdwl + ecoul); - d_eatom[i] += epairthird; + epairthird = static_cast(THIRD) * (evdwl + ecoul); + d_eatom[i] += static_cast(epairthird); } if (VFLAG) { - v[0] = drji[0]*fj[0] + drki[0]*fk[0]; - v[1] = drji[1]*fj[1] + drki[1]*fk[1]; - v[2] = drji[2]*fj[2] + drki[2]*fk[2]; - v[3] = drji[0]*fj[1] + drki[0]*fk[1]; - v[4] = drji[0]*fj[2] + drki[0]*fk[2]; - v[5] = drji[1]*fj[2] + drki[1]*fk[2]; + v[0] = drji[0]*static_cast(fj[0]) + drki[0]*static_cast(fk[0]); + v[1] = drji[1]*static_cast(fj[1]) + drki[1]*static_cast(fk[1]); + v[2] = drji[2]*static_cast(fj[2]) + drki[2]*static_cast(fk[2]); + v[3] = drji[0]*static_cast(fj[1]) + drki[0]*static_cast(fk[1]); + v[4] = drji[0]*static_cast(fj[2]) + drki[0]*static_cast(fk[2]); + v[5] = drji[1]*static_cast(fj[2]) + drki[1]*static_cast(fk[2]); if (vflag_atom) { - d_vatom(i,0) += THIRD*v[0]; d_vatom(i,1) += THIRD*v[1]; - d_vatom(i,2) += THIRD*v[2]; d_vatom(i,3) += THIRD*v[3]; - d_vatom(i,4) += THIRD*v[4]; d_vatom(i,5) += THIRD*v[5]; + d_vatom(i,0) += static_cast(THIRD)*static_cast(v[0]); d_vatom(i,1) += static_cast(THIRD)*static_cast(v[1]); + d_vatom(i,2) += static_cast(THIRD)*static_cast(v[2]); d_vatom(i,3) += static_cast(THIRD)*static_cast(v[3]); + d_vatom(i,4) += static_cast(THIRD)*static_cast(v[4]); d_vatom(i,5) += static_cast(THIRD)*static_cast(v[5]); } } } diff --git a/src/KOKKOS/pair_ylz_kokkos.cpp b/src/KOKKOS/pair_ylz_kokkos.cpp index a5c0c9cdd74..fecf3f2f384 100644 --- a/src/KOKKOS/pair_ylz_kokkos.cpp +++ b/src/KOKKOS/pair_ylz_kokkos.cpp @@ -262,7 +262,7 @@ void PairYLZKokkos::operator()(TagPairYLZKernel(MY_TWOBYSIXTH) * sig; const KK_FLOAT rcut = Kokkos::sqrt(cutsq_ij); // rotation matrix for atom j @@ -321,14 +321,14 @@ void PairYLZKokkos::operator()(TagPairYLZKernel(4.0)*(t2 - t4)/r*energy_well; dUdphi = -energy_well; } else { - const KK_FLOAT t = MY_PI2*(r - rmin)/(rcut - rmin); + const KK_FLOAT t = static_cast(MY_PI2)*(r - rmin)/(rcut - rmin); const KK_FLOAT cos_t = Kokkos::cos(t); // t1 = cos_t^(2*zt-1) KK_FLOAT t1 = cos_t; for (int k = 1; k <= static_cast(static_cast(2.0)*zt) - 2; k++) t1 *= cos_t; const KK_FLOAT uA = -energy_well*t1*cos_t; U = uA*phi; - dUdr = MY_PI*zt/(rcut - rmin)*t1*Kokkos::sin(t)*phi*energy_well; + dUdr = static_cast(MY_PI)*zt/(rcut - rmin)*t1*Kokkos::sin(t)*phi*energy_well; dUdphi = uA; } @@ -352,12 +352,12 @@ void PairYLZKokkos::operator()(TagPairYLZKernel(ff_x); + fy_i += static_cast(ff_y); + fz_i += static_cast(ff_z); + torx_i += static_cast(ttor_x); + tory_i += static_cast(ttor_y); + torz_i += static_cast(ttor_z); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { // torque on j: cross(dU/dnj1, nj1) @@ -368,12 +368,12 @@ void PairYLZKokkos::operator()(TagPairYLZKernel(ff_x); + a_f(j,1) -= static_cast(ff_y); + a_f(j,2) -= static_cast(ff_z); + a_torque(j,0) += static_cast(rtor_x); + a_torque(j,1) += static_cast(rtor_y); + a_torque(j,2) += static_cast(rtor_z); } if (EVFLAG) { @@ -418,9 +418,9 @@ void PairYLZKokkos::ev_tally_xyz(EV_FLOAT &ev, int i, int j, const K if (eflag_atom) { const KK_FLOAT epairhalf = half*epair; - Kokkos::atomic_add(&d_eatom[i], epairhalf); + Kokkos::atomic_add(&d_eatom[i], static_cast(epairhalf)); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) - Kokkos::atomic_add(&d_eatom[j], epairhalf); + Kokkos::atomic_add(&d_eatom[j], static_cast(epairhalf)); } if (vflag_either) { @@ -433,34 +433,34 @@ void PairYLZKokkos::ev_tally_xyz(EV_FLOAT &ev, int i, int j, const K if (vflag_global) { if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - ev.v[0] += v0; ev.v[1] += v1; ev.v[2] += v2; - ev.v[3] += v3; ev.v[4] += v4; ev.v[5] += v5; + ev.v[0] += static_cast(v0); ev.v[1] += static_cast(v1); ev.v[2] += static_cast(v2); + ev.v[3] += static_cast(v3); ev.v[4] += static_cast(v4); ev.v[5] += static_cast(v5); } else { - ev.v[0] += half*v0; ev.v[1] += half*v1; ev.v[2] += half*v2; - ev.v[3] += half*v3; ev.v[4] += half*v4; ev.v[5] += half*v5; + ev.v[0] += static_cast(half*v0); ev.v[1] += static_cast(half*v1); ev.v[2] += static_cast(half*v2); + ev.v[3] += static_cast(half*v3); ev.v[4] += static_cast(half*v4); ev.v[5] += static_cast(half*v5); } } if (vflag_atom) { - Kokkos::atomic_add(&d_vatom(i,0), half*v0); - Kokkos::atomic_add(&d_vatom(i,1), half*v1); - Kokkos::atomic_add(&d_vatom(i,2), half*v2); - Kokkos::atomic_add(&d_vatom(i,3), half*v3); - Kokkos::atomic_add(&d_vatom(i,4), half*v4); - Kokkos::atomic_add(&d_vatom(i,5), half*v5); + Kokkos::atomic_add(&d_vatom(i,0), static_cast(half*v0)); + Kokkos::atomic_add(&d_vatom(i,1), static_cast(half*v1)); + Kokkos::atomic_add(&d_vatom(i,2), static_cast(half*v2)); + Kokkos::atomic_add(&d_vatom(i,3), static_cast(half*v3)); + Kokkos::atomic_add(&d_vatom(i,4), static_cast(half*v4)); + Kokkos::atomic_add(&d_vatom(i,5), static_cast(half*v5)); if ((NEIGHFLAG==HALF || NEIGHFLAG==HALFTHREAD) && (NEWTON_PAIR || j < nlocal)) { - Kokkos::atomic_add(&d_vatom(j,0), half*v0); - Kokkos::atomic_add(&d_vatom(j,1), half*v1); - Kokkos::atomic_add(&d_vatom(j,2), half*v2); - Kokkos::atomic_add(&d_vatom(j,3), half*v3); - Kokkos::atomic_add(&d_vatom(j,4), half*v4); - Kokkos::atomic_add(&d_vatom(j,5), half*v5); + Kokkos::atomic_add(&d_vatom(j,0), static_cast(half*v0)); + Kokkos::atomic_add(&d_vatom(j,1), static_cast(half*v1)); + Kokkos::atomic_add(&d_vatom(j,2), static_cast(half*v2)); + Kokkos::atomic_add(&d_vatom(j,3), static_cast(half*v3)); + Kokkos::atomic_add(&d_vatom(j,4), static_cast(half*v4)); + Kokkos::atomic_add(&d_vatom(j,5), static_cast(half*v5)); } } } if (eflag_global) - ev.evdwl += efactor*epair; + ev.evdwl += static_cast(efactor*epair); } /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_yukawa_colloid_kokkos.cpp b/src/KOKKOS/pair_yukawa_colloid_kokkos.cpp index 4bd84eb6ca3..b885e627e1c 100644 --- a/src/KOKKOS/pair_yukawa_colloid_kokkos.cpp +++ b/src/KOKKOS/pair_yukawa_colloid_kokkos.cpp @@ -120,14 +120,14 @@ double PairYukawaColloidKokkos::init_one(int i, int j) { double cutone = PairYukawaColloid::init_one(i,j); - k_params.view_host()(i,j).a = a[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).a = static_cast(a[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; @@ -177,24 +177,24 @@ void PairYukawaColloidKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms EV_FLOAT ev = pair_compute,void >( this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -221,7 +221,8 @@ compute_fpair(const KK_FLOAT &rsq, const int &i, const int &j, const int &itype, const int &jtype) const { const KK_FLOAT radi = radius[i]; const KK_FLOAT radj = radius[j]; - const KK_FLOAT rr = sqrt(rsq); + const KK_FLOAT rr = Kokkos::sqrt(rsq); + const KK_FLOAT kappa_kk = static_cast(kappa); // Fetch the params either off the stack or from some mapped memory? const KK_FLOAT aa = STACKPARAMS ? m_params[itype][jtype].a : params(itype,jtype).a; @@ -229,8 +230,8 @@ compute_fpair(const KK_FLOAT &rsq, const int &i, const int &j, // U = a * exp(-kappa*(r-(radi+radj))) / kappa // f = -dU/dr = a * exp(-kappa*r) // f/r = a * exp(-kappa*r) / r - const KK_FLOAT rinv = 1.0 / rr; - const KK_FLOAT screening = exp(-kappa*(rr-(radi+radj))); + const KK_FLOAT rinv = static_cast(1.0) / rr; + const KK_FLOAT screening = Kokkos::exp(-kappa_kk*(rr-(radi+radj))); const KK_FLOAT forceyukawa = aa * screening; const KK_FLOAT fpair = forceyukawa * rinv; @@ -246,16 +247,17 @@ compute_evdwl(const KK_FLOAT &rsq, const int &i, const int &j, const int &itype, const int &jtype) const { const KK_FLOAT radi = radius[i]; const KK_FLOAT radj = radius[j]; - const KK_FLOAT rr = sqrt(rsq); + const KK_FLOAT rr = Kokkos::sqrt(rsq); + const KK_FLOAT kappa_kk = static_cast(kappa); const KK_FLOAT aa = STACKPARAMS ? m_params[itype][jtype].a : params(itype,jtype).a; const KK_FLOAT offset = STACKPARAMS ? m_params[itype][jtype].offset : params(itype,jtype).offset; // U = a * exp(-kappa*(r-(radi+radj))) / kappa - const KK_FLOAT screening = exp(-kappa*(rr-(radi+radj))); + const KK_FLOAT screening = Kokkos::exp(-kappa_kk*(rr-(radi+radj))); - return aa / kappa * screening - offset; + return aa / kappa_kk * screening - offset; } diff --git a/src/KOKKOS/pair_yukawa_kokkos.cpp b/src/KOKKOS/pair_yukawa_kokkos.cpp index fbfb6553eae..f4f47cc7890 100644 --- a/src/KOKKOS/pair_yukawa_kokkos.cpp +++ b/src/KOKKOS/pair_yukawa_kokkos.cpp @@ -120,14 +120,14 @@ double PairYukawaKokkos::init_one(int i, int j) { double cutone = PairYukawa::init_one(i,j); - k_params.view_host()(i,j).a = a[i][j]; - k_params.view_host()(i,j).offset = offset[i][j]; - k_params.view_host()(i,j).cutsq = cutone*cutone; + k_params.view_host()(i,j).a = static_cast(a[i][j]); + k_params.view_host()(i,j).offset = static_cast(offset[i][j]); + k_params.view_host()(i,j).cutsq = static_cast(cutone*cutone); k_params.view_host()(j,i) = k_params.view_host()(i,j); if (i(cutone*cutone); } k_cutsq.view_host()(i,j) = k_cutsq.view_host()(j,i) = cutone*cutone; @@ -176,24 +176,24 @@ void PairYukawaKokkos::compute(int eflag_in, int vflag_in) nlocal = atom->nlocal; nall = atom->nlocal + atom->nghost; newton_pair = force->newton_pair; - special_lj[0] = force->special_lj[0]; - special_lj[1] = force->special_lj[1]; - special_lj[2] = force->special_lj[2]; - special_lj[3] = force->special_lj[3]; + special_lj[0] = static_cast(force->special_lj[0]); + special_lj[1] = static_cast(force->special_lj[1]); + special_lj[2] = static_cast(force->special_lj[2]); + special_lj[3] = static_cast(force->special_lj[3]); // loop over neighbors of my atoms EV_FLOAT ev = pair_compute,void >( this,(NeighListKokkos*)list); - if (eflag_global) eng_vdwl += ev.evdwl; + if (eflag_global) eng_vdwl += static_cast(ev.evdwl); if (vflag_global) { - virial[0] += ev.v[0]; - virial[1] += ev.v[1]; - virial[2] += ev.v[2]; - virial[3] += ev.v[3]; - virial[4] += ev.v[4]; - virial[5] += ev.v[5]; + virial[0] += static_cast(ev.v[0]); + virial[1] += static_cast(ev.v[1]); + virial[2] += static_cast(ev.v[2]); + virial[3] += static_cast(ev.v[3]); + virial[4] += static_cast(ev.v[4]); + virial[5] += static_cast(ev.v[5]); } if (vflag_fdotr) pair_virial_fdotr_compute(this); @@ -218,7 +218,8 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairYukawaKokkos:: compute_fpair(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT rr = sqrt(rsq); + const KK_FLOAT rr = Kokkos::sqrt(rsq); + const KK_FLOAT kappa_kk = static_cast(kappa); // Fetch the params either off the stack or from some mapped memory? const KK_FLOAT aa = STACKPARAMS ? m_params[itype][jtype].a : params(itype,jtype).a; @@ -227,10 +228,10 @@ compute_fpair(const KK_FLOAT &rsq, const int &, const int &, // f = (kappa * a * exp(-kappa*r) / r + a*exp(-kappa*r)/r^2)*grad(r) // = (kappa + 1/r) * (a * exp(-kappa*r) / r) // f/r = (kappa + 1/r) * (a * exp(-kappa*r) / r^2) - const KK_FLOAT rinv = 1.0 / rr; + const KK_FLOAT rinv = static_cast(1.0) / rr; const KK_FLOAT rinv2 = rinv*rinv; - const KK_FLOAT screening = exp(-kappa*rr); - const KK_FLOAT forceyukawa = aa * screening * (kappa + rinv); + const KK_FLOAT screening = Kokkos::exp(-kappa_kk*rr); + const KK_FLOAT forceyukawa = aa * screening * (kappa_kk + rinv); const KK_FLOAT fpair = forceyukawa * rinv2; return fpair; @@ -243,7 +244,8 @@ KOKKOS_INLINE_FUNCTION KK_FLOAT PairYukawaKokkos:: compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT rr = sqrt(rsq); + const KK_FLOAT rr = Kokkos::sqrt(rsq); + const KK_FLOAT kappa_kk = static_cast(kappa); const KK_FLOAT aa = STACKPARAMS ? m_params[itype][jtype].a : params(itype,jtype).a; const KK_FLOAT offset = STACKPARAMS ? m_params[itype][jtype].offset @@ -253,8 +255,8 @@ compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, // f = (kappa * a * exp(-kappa*r) / r + a*exp(-kappa*r)/r^2)*grad(r) // = (kappa + 1/r) * (a * exp(-kappa*r) / r) // f/r = (kappa + 1/r) * (a * exp(-kappa*r) / r^2) - const KK_FLOAT rinv = 1.0 / rr; - const KK_FLOAT screening = exp(-kappa*rr); + const KK_FLOAT rinv = static_cast(1.0) / rr; + const KK_FLOAT screening = Kokkos::exp(-kappa_kk*rr); return aa * screening * rinv - offset; } diff --git a/src/KOKKOS/pair_zbl_kokkos.cpp b/src/KOKKOS/pair_zbl_kokkos.cpp index 694e619ebc4..10faf0452c2 100644 --- a/src/KOKKOS/pair_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_zbl_kokkos.cpp @@ -212,7 +212,7 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairZBLKokkos:: compute_fpair(const KK_FLOAT& rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); KK_FLOAT fpair = dzbldr(r, itype, jtype); if (rsq > cut_innersq_kk) { @@ -232,7 +232,7 @@ template KOKKOS_INLINE_FUNCTION KK_FLOAT PairZBLKokkos:: compute_evdwl(const KK_FLOAT &rsq, const int &, const int &, const int &itype, const int &jtype) const { - const KK_FLOAT r = sqrt(rsq); + const KK_FLOAT r = Kokkos::sqrt(rsq); KK_FLOAT evdwl = e_zbl(r, itype, jtype); evdwl += d_sw5(itype,jtype); if (rsq > cut_innersq_kk) { @@ -339,10 +339,10 @@ KK_FLOAT PairZBLKokkos::e_zbl(KK_FLOAT r, int i, int j) const { const KK_FLOAT zzeij = d_zze(i,j); const KK_FLOAT rinv = static_cast(1.0) / r; - KK_FLOAT sum = c1_kk*exp(-d1aij*r); - sum += c2_kk*exp(-d2aij*r); - sum += c3_kk*exp(-d3aij*r); - sum += c4_kk*exp(-d4aij*r); + KK_FLOAT sum = c1_kk*Kokkos::exp(-d1aij*r); + sum += c2_kk*Kokkos::exp(-d2aij*r); + sum += c3_kk*Kokkos::exp(-d3aij*r); + sum += c4_kk*Kokkos::exp(-d4aij*r); KK_FLOAT result = zzeij*sum*rinv; @@ -365,10 +365,10 @@ KK_FLOAT PairZBLKokkos::dzbldr(KK_FLOAT r, int i, int j) const { const KK_FLOAT zzeij = d_zze(i,j); const KK_FLOAT rinv = static_cast(1.0) / r; - const KK_FLOAT e1 = exp(-d1aij*r); - const KK_FLOAT e2 = exp(-d2aij*r); - const KK_FLOAT e3 = exp(-d3aij*r); - const KK_FLOAT e4 = exp(-d4aij*r); + const KK_FLOAT e1 = Kokkos::exp(-d1aij*r); + const KK_FLOAT e2 = Kokkos::exp(-d2aij*r); + const KK_FLOAT e3 = Kokkos::exp(-d3aij*r); + const KK_FLOAT e4 = Kokkos::exp(-d4aij*r); KK_FLOAT sum = c1_kk*e1; sum += c2_kk*e2; @@ -401,10 +401,10 @@ KK_FLOAT PairZBLKokkos::d2zbldr2(KK_FLOAT r, int i, int j) const { const KK_FLOAT zzeij = d_zze(i,j); const KK_FLOAT rinv = static_cast(1.0) / r; - const KK_FLOAT e1 = exp(-d1aij*r); - const KK_FLOAT e2 = exp(-d2aij*r); - const KK_FLOAT e3 = exp(-d3aij*r); - const KK_FLOAT e4 = exp(-d4aij*r); + const KK_FLOAT e1 = Kokkos::exp(-d1aij*r); + const KK_FLOAT e2 = Kokkos::exp(-d2aij*r); + const KK_FLOAT e3 = Kokkos::exp(-d3aij*r); + const KK_FLOAT e4 = Kokkos::exp(-d4aij*r); KK_FLOAT sum = c1_kk*e1; sum += c2_kk*e2; diff --git a/src/KOKKOS/region_block_kokkos.cpp b/src/KOKKOS/region_block_kokkos.cpp index 9350e572504..3802c22f968 100644 --- a/src/KOKKOS/region_block_kokkos.cpp +++ b/src/KOKKOS/region_block_kokkos.cpp @@ -66,9 +66,9 @@ template KOKKOS_INLINE_FUNCTION void RegBlockKokkos::operator()(TagRegBlockMatchAll, const int &i) const { if (d_mask[i] & groupbit) { - double x_tmp = d_x(i,0); - double y_tmp = d_x(i,1); - double z_tmp = d_x(i,2); + double x_tmp = static_cast(d_x(i,0)); + double y_tmp = static_cast(d_x(i,1)); + double z_tmp = static_cast(d_x(i,2)); d_match[i] = match_kokkos(x_tmp,y_tmp,z_tmp); } } diff --git a/src/KOKKOS/region_sphere_kokkos.cpp b/src/KOKKOS/region_sphere_kokkos.cpp index a9e50f69a87..b279891e1ba 100644 --- a/src/KOKKOS/region_sphere_kokkos.cpp +++ b/src/KOKKOS/region_sphere_kokkos.cpp @@ -72,7 +72,7 @@ void RegSphereKokkos::operator()(TagRegSphereMatchAll, const int &i) KK_FLOAT x_tmp = d_x(i,0); KK_FLOAT y_tmp = d_x(i,1); KK_FLOAT z_tmp = d_x(i,2); - d_match[i] = match_kokkos(x_tmp,y_tmp,z_tmp); + d_match[i] = match_kokkos(static_cast(x_tmp),static_cast(y_tmp),static_cast(z_tmp)); } } diff --git a/src/KOKKOS/sna_kokkos_impl.h b/src/KOKKOS/sna_kokkos_impl.h index 2e64992abc8..912be807281 100644 --- a/src/KOKKOS/sna_kokkos_impl.h +++ b/src/KOKKOS/sna_kokkos_impl.h @@ -358,14 +358,14 @@ void SNAKokkos::compute_cayley const real_type y = rij(iatom,jnbor,1); const real_type z = rij(iatom,jnbor,2); const real_type rsq = x * x + y * y + z * z; - const real_type r = sqrt(rsq); + const real_type r = Kokkos::sqrt(rsq); const real_type rcut = rcutij(iatom, jnbor); const real_type sinner = sinnerij(iatom, jnbor); const real_type dinner = dinnerij(iatom, jnbor); const real_type rscale0 = rfac0 * static_cast(MY_PI) / (rcut - rmin0); const real_type theta0 = (r - rmin0) * rscale0; - const real_type sn = sin(theta0); - const real_type cs = cos(theta0); + const real_type sn = Kokkos::sin(theta0); + const real_type cs = Kokkos::cos(theta0); const real_type z0 = r * cs / sn; const real_type dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; @@ -380,7 +380,7 @@ void SNAKokkos::compute_cayley const real_type uy = y * rinv; const real_type uz = z * rinv; - const real_type r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); + const real_type r0inv = static_cast(1.0) / Kokkos::sqrt(r * r + z0 * z0); const complex a = { z0 * r0inv, -z * r0inv }; const complex b = { r0inv * y, -r0inv * x }; @@ -761,16 +761,16 @@ void SNAKokkos::compute_ui_cpu const real_type y = rij(iatom,jnbor,1); const real_type z = rij(iatom,jnbor,2); const real_type rsq = x * x + y * y + z * z; - const real_type r = sqrt(rsq); + const real_type r = Kokkos::sqrt(rsq); const real_type theta0 = (r - rmin0) * rfac0 * static_cast(MY_PI) / (rcutij(iatom,jnbor) - rmin0); // theta0 = (r - rmin0) * rscale0; - const real_type z0 = r / tan(theta0); + const real_type z0 = r / Kokkos::tan(theta0); // begin what was "compute_uarray_cpu" // compute Cayley-Klein parameters for unit quaternion - real_type r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); + real_type r0inv = static_cast(1.0) / Kokkos::sqrt(r * r + z0 * z0); complex a = { r0inv * z0, -r0inv * z }; complex b = { r0inv * y, -r0inv * x }; @@ -1688,11 +1688,11 @@ void SNAKokkos::compute_duidrj const real_type y = rij(iatom,jnbor,1); const real_type z = rij(iatom,jnbor,2); const real_type rsq = x * x + y * y + z * z; - const real_type r = sqrt(rsq); + const real_type r = Kokkos::sqrt(rsq); const real_type rscale0 = rfac0 * static_cast(MY_PI) / (rcutij(iatom,jnbor) - rmin0); const real_type theta0 = (r - rmin0) * rscale0; - const real_type sn = sin(theta0); - const real_type cs = cos(theta0); + const real_type sn = Kokkos::sin(theta0); + const real_type cs = Kokkos::cos(theta0); const real_type z0 = r * cs / sn; const real_type dz0dr = z0 / r - (r*rscale0) * (rsq + z0 * z0) / rsq; @@ -1703,7 +1703,7 @@ void SNAKokkos::compute_duidrj u[1] = y * rinv; u[2] = z * rinv; - real_type r0inv = static_cast(1.0) / sqrt(r * r + z0 * z0); + real_type r0inv = static_cast(1.0) / Kokkos::sqrt(r * r + z0 * z0); complex a = { z0 * r0inv, -z * r0inv }; complex b = { y * r0inv, -x * r0inv }; @@ -2228,7 +2228,7 @@ real_type SNAKokkos::compute_s else if (r > rcut) return zero; else { real_type rcutfac = static_cast(MY_PI) / (rcut - rmin0); - sfac_outer = onehalf * (cos((r - rmin0) * rcutfac) + one); + sfac_outer = onehalf * (Kokkos::cos((r - rmin0) * rcutfac) + one); } } else sfac_outer = zero; // switch_flag is always 0 or 1 @@ -2239,7 +2239,7 @@ real_type SNAKokkos::compute_s else if (r > sinner - dinner) { real_type rcutfac = static_cast(MY_PI2) / dinner; return sfac_outer * - onehalf * (one - cos(static_cast(MY_PI2) + (r - sinner) * rcutfac)); + onehalf * (one - Kokkos::cos(static_cast(MY_PI2) + (r - sinner) * rcutfac)); } else return zero; } return zero; // dummy return @@ -2313,8 +2313,8 @@ void SNAKokkos::compute_s_dsfa else { const real_type rcutfac = static_cast(MY_PI) / (rcut - rmin0); const real_type theta0 = (r - rmin0) * rcutfac; - const real_type sn = sin(theta0); - const real_type cs = cos(theta0); + const real_type sn = Kokkos::sin(theta0); + const real_type cs = Kokkos::cos(theta0); sfac_outer = onehalf * (cs + one); dsfac_outer = -onehalf * sn * rcutfac; } @@ -2325,8 +2325,8 @@ void SNAKokkos::compute_s_dsfa if (r >= sinner + dinner) { sfac = sfac_outer; dsfac = dsfac_outer; return; } else if (r > sinner - dinner) { real_type rcutfac = static_cast(MY_PI2) / dinner; - sfac_inner = onehalf * (one - cos(static_cast(MY_PI2) + (r - sinner) * rcutfac)); - dsfac_inner = onehalf * rcutfac * sin(static_cast(MY_PI2) + (r - sinner) * rcutfac); + sfac_inner = onehalf * (one - Kokkos::cos(static_cast(MY_PI2) + (r - sinner) * rcutfac)); + dsfac_inner = onehalf * rcutfac * Kokkos::sin(static_cast(MY_PI2) + (r - sinner) * rcutfac); sfac = sfac_outer * sfac_inner; dsfac = dsfac_outer * sfac_inner + sfac_outer * dsfac_inner; return;