Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber committed Nov 23, 2023
1 parent 5a7e6e6 commit aa30cc6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/alpaka/nbody/nbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ constexpr auto runUpate = true; // run update step. Useful to disable for benchm
constexpr auto elementsPerThread = xsimd::batch<float>::size;
constexpr auto threadsPerBlock = 1;
constexpr auto sharedElementsPerBlock = 1;
constexpr auto aosoaLanes = xsimd::batch<float>::size; // vectors
constexpr auto aosoaLanes = elementsPerThread;
#elif ANY_GPU_ENABLED
constexpr auto threadsPerBlock = 256;
constexpr auto sharedElementsPerBlock = 512;
Expand Down Expand Up @@ -144,7 +144,7 @@ LLAMA_FN_HOST_ACC_INLINE void pPInteraction(const Acc& acc, ParticleRefI& pis, P
const auto distSqr = +eps2 + dist(tag::X{}) + dist(tag::Y{}) + dist(tag::Z{});
const auto distSixth = distSqr * distSqr * distSqr;
const auto invDistCube
= allowRsqrt ? alpaka::math::rsqrt(acc, distSixth) : (1.0f / alpaka::math::sqrt(acc, distSixth));
= allowRsqrt ? alpaka::math::rsqrt(acc, distSixth) : (FP{1} / alpaka::math::sqrt(acc, distSixth));
const auto sts = (pj(tag::Mass{}) * timestep) * invDistCube;
pis(tag::Vel{}) += dist * sts;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cuda/nbody/nbody.cu
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ __device__ void pPInteraction(ParticleRefI& pi, ParticleRefJ pj)
dist *= dist;
const FP distSqr = eps2 + dist(tag::X{}) + dist(tag::Y{}) + dist(tag::Z{});
const FP distSixth = distSqr * distSqr * distSqr;
const FP invDistCube = allowRsqrt ? rsqrt(distSixth) : (1.0f / sqrt(distSixth));
const FP invDistCube = allowRsqrt ? rsqrt(distSixth) : (FP{1} / sqrt(distSixth));
const FP sts = pj(tag::Mass{}) * invDistCube * +timestep;
pi(tag::Vel{}) += dist * sts;
}
Expand Down

0 comments on commit aa30cc6

Please sign in to comment.