Skip to content

Commit

Permalink
Bins: Index Type int
Browse files Browse the repository at this point in the history
For performance reasons, `int` are better index types since
they do not have over/underflow checks and thus vectorize better.

Also, I see narrowing warnings casting from `int` to AMReX'
`unsigned int` in WarpX.
  • Loading branch information
ax3l committed Dec 23, 2023
1 parent 75571e2 commit 78c9cda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Src/Particle/AMReX_BinIterator.H
Expand Up @@ -22,7 +22,7 @@ constexpr bool IsParticleTileData (Args...) {
template <typename T>
struct BinIterator
{
using index_type = unsigned int;
using index_type = int;

using const_pointer_type = typename std::conditional<IsParticleTileData<T>(),
T,
Expand Down
4 changes: 2 additions & 2 deletions Src/Particle/AMReX_DenseBins.H
Expand Up @@ -29,7 +29,7 @@ namespace BinPolicy
template <typename T>
struct DenseBinIteratorFactory
{
using index_type = unsigned int;
using index_type = int;

using const_pointer_type = typename std::conditional<IsParticleTileData<T>(),
T,
Expand Down Expand Up @@ -77,7 +77,7 @@ class DenseBins
public:

using BinIteratorFactory = DenseBinIteratorFactory<T>;
using index_type = unsigned int;
using index_type = int;

using const_pointer_type = typename std::conditional<IsParticleTileData<T>(),
T,
Expand Down
6 changes: 3 additions & 3 deletions Src/Particle/AMReX_SparseBins.H
Expand Up @@ -14,7 +14,7 @@ template <typename T>
struct SparseBinIteratorFactory
{

using index_type = unsigned int;
using index_type = int;

using const_pointer_type = typename std::conditional<IsParticleTileData<T>(),
T,
Expand All @@ -33,7 +33,7 @@ struct SparseBinIteratorFactory
: m_bins_ptr(bins.dataPtr()),
m_offsets_ptr(offsets.dataPtr()),
m_permutation_ptr(permutation.dataPtr()),
m_items(items), m_num_bins(bins.size())
m_items(items), m_num_bins(int(bins.size()))
{}

[[nodiscard]] AMREX_GPU_HOST_DEVICE
Expand Down Expand Up @@ -97,7 +97,7 @@ public:

using BinIteratorFactory = SparseBinIteratorFactory<T>;
using bin_type = IntVect;
using index_type = unsigned int;
using index_type = int;

using const_pointer_type = typename std::conditional<IsParticleTileData<T>(),
T,
Expand Down

0 comments on commit 78c9cda

Please sign in to comment.