Skip to content

Commit

Permalink
Merge pull request ecmwf#52 in ATLAS/atlas from feature/atlas-bits-lo…
Browse files Browse the repository at this point in the history
…cal-64 to develop

* commit 'b26965ddfd3c31feecb07578de61ae20a2742d2d':
  ATLAS-317 Prevent integer overflows if ATLAS_BITS_LOCAL=64
  ATLAS-317 Support ATLAS_BITS_LOCAL=64 in tests
  • Loading branch information
wdeconinck committed Nov 10, 2020
2 parents d300465 + b26965d commit ae1da55
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
20 changes: 10 additions & 10 deletions src/atlas/array/helpers/ArraySlicer.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,37 +149,37 @@ class ArraySlicer {
};

template <typename Int>
static int offset_part( View& view, int& i_view, Int idx ) {
static idx_t offset_part( View& view, int& i_view, Int idx ) {
return idx * view.stride( i_view++ );
}

static int offset_part( View& view, int& i_view, Range range ) { return range.start() * view.stride( i_view++ ); }
static idx_t offset_part( View& view, int& i_view, Range range ) { return range.start() * view.stride( i_view++ ); }

static int offset_part( View& view, int& i_view, RangeAll range ) {
static idx_t offset_part( View& view, int& i_view, RangeAll range ) {
return range.start() * view.stride( i_view++ );
}

static int offset_part( View& view, int& i_view, RangeTo range ) { return range.start() * view.stride( i_view++ ); }
static idx_t offset_part( View& view, int& i_view, RangeTo range ) { return range.start() * view.stride( i_view++ ); }

static int offset_part( View& view, int& i_view, RangeFrom range ) {
static idx_t offset_part( View& view, int& i_view, RangeFrom range ) {
return range.start() * view.stride( i_view++ );
}

static int offset_part( View&, int& /*i_view*/, RangeDummy ) { return 0; }
static idx_t offset_part( View&, int& /*i_view*/, RangeDummy ) { return 0; }

template <int Dim, typename Int, typename... Ints>
static int offset_remaining( View& view, int& i_view, const Int idx, const Ints... next_idx ) {
const int p = offset_part( view, i_view, idx );
static idx_t offset_remaining( View& view, int& i_view, const Int idx, const Ints... next_idx ) {
const idx_t p = offset_part( view, i_view, idx );
return p + offset_remaining<Dim + 1>( view, i_view, next_idx... );
}

template <int Dim, typename Int>
static int offset_remaining( View& view, int& i_view, const Int last_idx ) {
static idx_t offset_remaining( View& view, int& i_view, const Int last_idx ) {
return offset_part( view, i_view, last_idx );
}

template <typename... Args>
static int offset( View& view, const Args... args ) {
static idx_t offset( View& view, const Args... args ) {
int i_view( 0 );
return offset_remaining<0>( view, i_view, args... );
}
Expand Down
4 changes: 2 additions & 2 deletions src/tests/functionspace/test_structuredcolumns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ CASE( "test_functionspace_StructuredColumns halo exchange adjoint test 1" ) {

// Field setup values 1 in interior and zeros in halos.
auto view1 = atlas::array::make_view<long, 2>( fieldInit );
auto i_index = atlas::array::make_view<int, 1>( fs.index_i() );
auto j_index = atlas::array::make_view<int, 1>( fs.index_j() );
auto i_index = atlas::array::make_view<atlas::idx_t, 1>( fs.index_i() );
auto j_index = atlas::array::make_view<atlas::idx_t, 1>( fs.index_j() );
for ( atlas::idx_t jn = 0; jn < fs.sizeOwned(); ++jn ) {
for ( atlas::idx_t jl = 0; jl < fieldInit.levels(); ++jl ) {
view1( jn, jl ) = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ CASE( "biperiodic_latlon" ) {
};

auto gv = atlas::array::make_view<atlas::gidx_t, 1>( fs.global_index() );
auto pv = atlas::array::make_view<atlas::idx_t, 1>( fs.partition() );
auto pv = atlas::array::make_view<int, 1>( fs.partition() );

for ( int j = fs.j_begin_halo(); j < fs.j_end_halo(); j++ ) {
for ( int i = fs.i_begin_halo( j ); i < fs.i_end_halo( j ); i++ ) {
Expand Down
12 changes: 6 additions & 6 deletions src/tests/functionspace/test_structuredcolumns_haloexchange.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ namespace test {
atlas::FieldSet getIJ( const atlas::functionspace::StructuredColumns& fs ) {
atlas::FieldSet ij;

auto vi0 = atlas::array::make_view<int, 1>( fs.index_i() );
auto vj0 = atlas::array::make_view<int, 1>( fs.index_j() );
auto vi0 = atlas::array::make_view<atlas::idx_t, 1>( fs.index_i() );
auto vj0 = atlas::array::make_view<atlas::idx_t, 1>( fs.index_j() );

auto fi = fs.createField<int>();
auto fj = fs.createField<int>();
auto fi = fs.createField<atlas::idx_t>();
auto fj = fs.createField<atlas::idx_t>();

auto vi1 = atlas::array::make_view<int, 1>( fi );
auto vj1 = atlas::array::make_view<int, 1>( fj );
auto vi1 = atlas::array::make_view<atlas::idx_t, 1>( fi );
auto vj1 = atlas::array::make_view<atlas::idx_t, 1>( fj );

for ( int i = 0; i < fs.size(); i++ ) {
vi1( i ) = vi0( i );
Expand Down
8 changes: 4 additions & 4 deletions src/tests/grid/test_distribution_regular_bands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ CASE( "test_regular_bands" ) {
EXPECT_EQ( fs_regularbands.size(), fs_checkerboard.size() );
EXPECT_EQ( fs_regularbands.sizeOwned(), fs_checkerboard.sizeOwned() );

auto i1 = array::make_view<int, 1>( ij1[0] );
auto j1 = array::make_view<int, 1>( ij1[1] );
auto i2 = array::make_view<int, 1>( ij2[0] );
auto j2 = array::make_view<int, 1>( ij2[1] );
auto i1 = array::make_view<idx_t, 1>( ij1[0] );
auto j1 = array::make_view<idx_t, 1>( ij1[1] );
auto i2 = array::make_view<idx_t, 1>( ij2[0] );
auto j2 = array::make_view<idx_t, 1>( ij2[1] );

for ( int k = 0; k < fs_checkerboard.sizeOwned(); k++ ) {
EXPECT_EQ( i1[k], i2[k] );
Expand Down

0 comments on commit ae1da55

Please sign in to comment.