From e6db46430dcef8ea1f22d6b84c54d66a5602bf31 Mon Sep 17 00:00:00 2001 From: Olivier Iffrig Date: Mon, 9 Nov 2020 11:29:20 +0000 Subject: [PATCH 1/2] ATLAS-317 Support ATLAS_BITS_LOCAL=64 in tests --- src/tests/functionspace/test_structuredcolumns.cc | 4 ++-- .../test_structuredcolumns_biperiodic.cc | 2 +- .../test_structuredcolumns_haloexchange.cc | 12 ++++++------ src/tests/grid/test_distribution_regular_bands.cc | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/tests/functionspace/test_structuredcolumns.cc b/src/tests/functionspace/test_structuredcolumns.cc index 165153d96..4a2d066dc 100644 --- a/src/tests/functionspace/test_structuredcolumns.cc +++ b/src/tests/functionspace/test_structuredcolumns.cc @@ -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( fieldInit ); - auto i_index = atlas::array::make_view( fs.index_i() ); - auto j_index = atlas::array::make_view( fs.index_j() ); + auto i_index = atlas::array::make_view( fs.index_i() ); + auto j_index = atlas::array::make_view( 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; diff --git a/src/tests/functionspace/test_structuredcolumns_biperiodic.cc b/src/tests/functionspace/test_structuredcolumns_biperiodic.cc index 3831eba99..dc7c23051 100644 --- a/src/tests/functionspace/test_structuredcolumns_biperiodic.cc +++ b/src/tests/functionspace/test_structuredcolumns_biperiodic.cc @@ -90,7 +90,7 @@ CASE( "biperiodic_latlon" ) { }; auto gv = atlas::array::make_view( fs.global_index() ); - auto pv = atlas::array::make_view( fs.partition() ); + auto pv = atlas::array::make_view( 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++ ) { diff --git a/src/tests/functionspace/test_structuredcolumns_haloexchange.cc b/src/tests/functionspace/test_structuredcolumns_haloexchange.cc index 8a2862d45..6c31217a1 100644 --- a/src/tests/functionspace/test_structuredcolumns_haloexchange.cc +++ b/src/tests/functionspace/test_structuredcolumns_haloexchange.cc @@ -38,14 +38,14 @@ namespace test { atlas::FieldSet getIJ( const atlas::functionspace::StructuredColumns& fs ) { atlas::FieldSet ij; - auto vi0 = atlas::array::make_view( fs.index_i() ); - auto vj0 = atlas::array::make_view( fs.index_j() ); + auto vi0 = atlas::array::make_view( fs.index_i() ); + auto vj0 = atlas::array::make_view( fs.index_j() ); - auto fi = fs.createField(); - auto fj = fs.createField(); + auto fi = fs.createField(); + auto fj = fs.createField(); - auto vi1 = atlas::array::make_view( fi ); - auto vj1 = atlas::array::make_view( fj ); + auto vi1 = atlas::array::make_view( fi ); + auto vj1 = atlas::array::make_view( fj ); for ( int i = 0; i < fs.size(); i++ ) { vi1( i ) = vi0( i ); diff --git a/src/tests/grid/test_distribution_regular_bands.cc b/src/tests/grid/test_distribution_regular_bands.cc index 23c0a5f61..d69c35d58 100644 --- a/src/tests/grid/test_distribution_regular_bands.cc +++ b/src/tests/grid/test_distribution_regular_bands.cc @@ -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( ij1[0] ); - auto j1 = array::make_view( ij1[1] ); - auto i2 = array::make_view( ij2[0] ); - auto j2 = array::make_view( ij2[1] ); + auto i1 = array::make_view( ij1[0] ); + auto j1 = array::make_view( ij1[1] ); + auto i2 = array::make_view( ij2[0] ); + auto j2 = array::make_view( ij2[1] ); for ( int k = 0; k < fs_checkerboard.sizeOwned(); k++ ) { EXPECT_EQ( i1[k], i2[k] ); From b26965ddfd3c31feecb07578de61ae20a2742d2d Mon Sep 17 00:00:00 2001 From: Olivier Iffrig Date: Mon, 9 Nov 2020 11:30:12 +0000 Subject: [PATCH 2/2] ATLAS-317 Prevent integer overflows if ATLAS_BITS_LOCAL=64 --- src/atlas/array/helpers/ArraySlicer.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/atlas/array/helpers/ArraySlicer.h b/src/atlas/array/helpers/ArraySlicer.h index ad3bfd730..2e37ebd4e 100644 --- a/src/atlas/array/helpers/ArraySlicer.h +++ b/src/atlas/array/helpers/ArraySlicer.h @@ -149,37 +149,37 @@ class ArraySlicer { }; template - 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 - 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( view, i_view, next_idx... ); } template - 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 - 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... ); }