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 09e7ec5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 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
4 changes: 2 additions & 2 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 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 09e7ec5

Please sign in to comment.