Skip to content

Commit

Permalink
Fix warnings related to host functions called from device
Browse files Browse the repository at this point in the history
Closes #354

See merge request gysela-developpers/gyselalibxx!705

--------------------------------------------
  • Loading branch information
tpadioleau committed Oct 4, 2024
1 parent 7227d3b commit 6f688d6
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ DFieldSpMomX DiffusiveNeutralSolver::operator()(

DConstFieldVx quadrature_coeffs = m_quadrature_coeffs;

IdxRangeVx const idx_range_vx(get_idx_range<GridVx>(allfdistribu));

// fluid moments computation
ddc::parallel_fill(density, 0.);
ddc::parallel_for_each(
Expand All @@ -209,7 +211,7 @@ DFieldSpMomX DiffusiveNeutralSolver::operator()(
KOKKOS_LAMBDA(IdxSpX const ispx) {
double particle_flux(0);
double momentum_flux(0);
for (IdxVx const ivx : get_idx_range<GridVx>(allfdistribu)) {
for (IdxVx const ivx : idx_range_vx) {
CoordVx const coordv = ddc::coordinate(ivx);
double const val(quadrature_coeffs(ivx) * allfdistribu(ispx, ivx));
density(ispx) += val;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,16 @@ void KineticFluidCouplingSource::operator()(

DConstFieldVx quadrature_coeffs = get_const_field(m_quadrature_coeffs);

IdxRangeVx const idx_range_vx(get_idx_range<GridVx>(allfdistribu));

ddc::parallel_fill(Kokkos::DefaultExecutionSpace(), kinsp_density, 0.);
ddc::parallel_for_each(
Kokkos::DefaultExecutionSpace(),
dom_kspx,
KOKKOS_LAMBDA(IdxSpX const ispx) {
double particle_flux(0);
double momentum_flux(0);
for (IdxVx const ivx : get_idx_range<GridVx>(allfdistribu)) {
for (IdxVx const ivx : idx_range_vx) {
CoordVx const coordv = ddc::coordinate(ivx);
double const val(quadrature_coeffs(ivx) * allfdistribu(ispx, ivx));
kinsp_density(ispx) += val;
Expand Down
2 changes: 1 addition & 1 deletion src/geometryXVx/poisson/chargedensitycalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ DFieldX ChargeDensityCalculator::operator()(DFieldX const rho, DConstFieldSpXVx
rho,
KOKKOS_LAMBDA(IdxXVx ixvx) {
double sum = 0.0;
for (auto isp : get_idx_range(kinetic_charges)) {
for (auto isp : kin_species_idx_range) {
sum += kinetic_charges(isp) * allfdistribu(isp, ixvx);
}
return sum;
Expand Down
7 changes: 4 additions & 3 deletions src/geometryXVx/rhs/collisions_inter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ void CollisionsInter::get_derivative(DFieldSpXVx const df, DConstFieldSpXVx cons
auto fluid_velocity = get_field(fluid_velocity_f);
auto temperature = get_field(temperature_f);

IdxRangeVx const idx_range_vx(get_idx_range<GridVx>(allfdistribu));

DFieldMemVx quadrature_coeffs_alloc(
trapezoid_quadrature_coefficients<Kokkos::DefaultExecutionSpace>(
get_idx_range<GridVx>(allfdistribu)));
trapezoid_quadrature_coefficients<Kokkos::DefaultExecutionSpace>(idx_range_vx));
DFieldVx quadrature_coeffs = get_field(quadrature_coeffs_alloc);

//Moments computation
Expand All @@ -51,7 +52,7 @@ void CollisionsInter::get_derivative(DFieldSpXVx const df, DConstFieldSpXVx cons
IdxX ix(ddc::select<GridX>(ispx));
double particle_flux(0);
double momentum_flux(0);
for (IdxVx ivx : get_idx_range<GridVx>(allfdistribu)) {
for (IdxVx ivx : idx_range_vx) {
CoordVx const coordv = ddc::coordinate(ivx);
double const val(quadrature_coeffs(ivx) * allfdistribu(isp, ix, ivx));
density(isp, ix) += val;
Expand Down
10 changes: 7 additions & 3 deletions src/geometryXVx/rhs/collisions_intra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ void CollisionsIntra::compute_rhs_vector(
DConstFieldSpXVx allfdistribu,
double fthresh) const
{
IdxRangeVx const idx_range_vx(get_idx_range<GridVx>(AA));

ddc::parallel_for_each(
Kokkos::DefaultExecutionSpace(),
get_idx_range(RR),
Expand All @@ -236,12 +238,12 @@ void CollisionsIntra::compute_rhs_vector(
IdxVx const ivx_next = ivx + 1;
IdxVx const ivx_prev = ivx - 1;

if (ivx == get_idx_range<GridVx>(AA).front()) {
if (ivx == idx_range_vx.front()) {
RR(isp, ix, ivx) = (2. - BB(isp, ix, ivx)) * allfdistribu(isp, ix, ivx)
+ (-CC(isp, ix, ivx)) * allfdistribu(isp, ix, ivx_next)
- 2. * AA(isp, ix, ivx) * fthresh;

} else if (ivx == get_idx_range<GridVx>(AA).back()) {
} else if (ivx == idx_range_vx.back()) {
RR(isp, ix, ivx) = (2. - BB(isp, ix, ivx)) * allfdistribu(isp, ix, ivx)
+ (-AA(isp, ix, ivx)) * allfdistribu(isp, ix, ivx_prev)
- 2. * CC(isp, ix, ivx) * fthresh;
Expand Down Expand Up @@ -276,6 +278,8 @@ DFieldSpXVx CollisionsIntra::operator()(DFieldSpXVx allfdistribu, double dt) con
get_idx_range<GridVx>(allfdistribu)));
DConstFieldVx quadrature_coeffs = get_const_field(quadrature_coeffs_alloc);

IdxRangeVx const idx_range_vx(get_idx_range<GridVx>(allfdistribu));

//Moments computation
ddc::parallel_fill(density, 0.);
ddc::parallel_for_each(
Expand All @@ -284,7 +288,7 @@ DFieldSpXVx CollisionsIntra::operator()(DFieldSpXVx allfdistribu, double dt) con
KOKKOS_LAMBDA(IdxSpX const ispx) {
double particle_flux(0);
double momentum_flux(0);
for (IdxVx const ivx : get_idx_range<GridVx>(allfdistribu)) {
for (IdxVx const ivx : idx_range_vx) {
CoordVx const coordv = ddc::coordinate(ivx);
double const val(quadrature_coeffs(ivx) * allfdistribu(ispx, ivx));
density(ispx) += val;
Expand Down
4 changes: 3 additions & 1 deletion src/geometryXVx/rhs/collisions_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,13 @@ void compute_Vcoll_Tcoll(
ddc::parallel_fill(I3mean, 0.);
ddc::parallel_fill(I4mean, 0.);

IdxRangeVx const idx_range_vx(get_idx_range<GridVx>(allfdistribu));

ddc::parallel_for_each(
Kokkos::DefaultExecutionSpace(),
grid_sp_x,
KOKKOS_LAMBDA(IdxSpX const ispx) {
for (IdxVx const ivx : get_idx_range<GridVx>(allfdistribu)) {
for (IdxVx const ivx : idx_range_vx) {
I0mean(ispx) += quadrature_coeffs(ivx) * I0mean_integrand(ispx, ivx);
I1mean(ispx) += quadrature_coeffs(ivx) * I1mean_integrand(ispx, ivx);
I2mean(ispx) += quadrature_coeffs(ivx) * I2mean_integrand(ispx, ivx);
Expand Down
2 changes: 1 addition & 1 deletion src/geometryXVx/rhs/krook_source_adaptive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void KrookSourceAdaptive::get_amplitudes(DFieldSpX amplitudes, DConstFieldSpXVx
double density_ion = 0.;
double density_electron = 0.;

for (IdxVx ivx : get_idx_range<GridVx>(allfdistribu)) {
for (IdxVx ivx : gridvx) {
density_ion += quadrature_coeffs(ivx) * allfdistribu(iion, ix, ivx);
density_electron += quadrature_coeffs(ivx) * allfdistribu(ielec(), ix, ivx);
}
Expand Down
2 changes: 1 addition & 1 deletion src/geometryXYVxVy/poisson/chargedensitycalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void ChargeDensityCalculator::operator()(DFieldXY rho, DConstFieldSpXYVxVy allfd
rho,
KOKKOS_LAMBDA(IdxXYVxVy idx) {
double sum = 0.0;
for (auto isp : get_idx_range(kinetic_charges)) {
for (auto isp : kin_species_idx_range) {
sum += kinetic_charges(isp) * allfdistribu(isp, idx);
}
return sum;
Expand Down
10 changes: 4 additions & 6 deletions src/interpolation/Lagrange_interpolator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,14 @@ class LagrangeInterpolator : public IInterpolator<GridInterp, Grid1D...>
= ddc::create_mirror_and_copy(Kokkos::DefaultExecutionSpace(), inout_data);
auto inout_data_tmp = get_field(inout_data_tmp_alloc);
auto batch_idx_range = ddc::remove_dims_of<GridInterp>(get_idx_range(inout_data));
auto const interp_range = get_idx_range<GridInterp>(inout_data);
ddc::parallel_for_each(
Kokkos::DefaultExecutionSpace(),
batch_idx_range,
KOKKOS_LAMBDA(typename decltype(batch_idx_range)::discrete_element_type const i) {
Lagrange<Kokkos::DefaultExecutionSpace, GridInterp, BcMin, BcMax> evaluator(
deg,
inout_data_tmp[i],
get_idx_range<GridInterp>(inout_data),
ghost);
for (Idx<GridInterp> j : get_idx_range<GridInterp>(inout_data)) {
Lagrange<Kokkos::DefaultExecutionSpace, GridInterp, BcMin, BcMax>
evaluator(deg, inout_data_tmp[i], interp_range, ghost);
for (Idx<GridInterp> j : interp_range) {
inout_data(i, j) = evaluator.evaluate(coordinates(i, j));
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ddc_alias_inline_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static constexpr bool is_gslx_field_v = detail::IsGslxField<Type>::value;
* @returns The index range.
*/
template <class... QueryGrids, class FieldType>
KOKKOS_INLINE_FUNCTION auto get_idx_range(FieldType const& field) noexcept
auto get_idx_range(FieldType const& field) noexcept
{
static_assert(
ddc::is_chunk_v<FieldType> || has_idx_range_v<FieldType>,
Expand Down
2 changes: 1 addition & 1 deletion toolchains/v100.persee/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_BUILD_TYPE Release)

# Compiler options
set(CMAKE_CXX_COMPILER ${PROJECT_SOURCE_DIR}/vendor/kokkos/bin/nvcc_wrapper)
set(CMAKE_CXX_FLAGS "-Wall -Wno-sign-compare -Xcudafe --diag_suppress=unsigned_compare_with_zero -Xcudafe --diag_suppress=integer_sign_change")
set(CMAKE_CXX_FLAGS "-Wall -Wno-sign-compare --Werror cross-execution-space-call -Xcudafe --diag_suppress=unsigned_compare_with_zero -Xcudafe --diag_suppress=integer_sign_change")

# Kokkos options
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "Allow serial code to run" FORCE)
Expand Down

0 comments on commit 6f688d6

Please sign in to comment.