From 4df60e350384f4feb348a419e066dac6777e269f Mon Sep 17 00:00:00 2001 From: wrtobin Date: Tue, 1 Oct 2024 10:31:29 -0700 Subject: [PATCH 1/4] std::, if constexper, macro whitespace --- src/Macros.hpp | 2 +- src/arrayManipulation.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Macros.hpp b/src/Macros.hpp index e5ec9ff0..a52ac85a 100644 --- a/src/Macros.hpp +++ b/src/Macros.hpp @@ -145,7 +145,7 @@ "***** Block: [%u, %u, %u]\n" \ "***** Thread: [%u, %u, %u]\n" \ "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n" \ - "***** MSG: " STRINGIZE( MSG ) "\n\n"; \ + "***** MSG: " STRINGIZE( MSG ) "\n\n"; \ printf( formatString, blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, threadIdx.y, threadIdx.z ); \ asm ( "trap;" ); \ } \ diff --git a/src/arrayManipulation.hpp b/src/arrayManipulation.hpp index 43371770..f79fed07 100644 --- a/src/arrayManipulation.hpp +++ b/src/arrayManipulation.hpp @@ -293,7 +293,7 @@ void resize( T * const LVARRAY_RESTRICT ptr, destroy( ptr + newSize, size - newSize ); // Initialize things between size and newSize. - if( sizeof ... ( ARGS ) == 0 && std::is_trivially_default_constructible< T >::value ) + if constexpr ( sizeof ... ( ARGS ) == 0 && std::is_trivially_default_constructible< T >::value ) { if( newSize - size > 0 ) { @@ -303,7 +303,7 @@ void resize( T * const LVARRAY_RESTRICT ptr, #pragma GCC diagnostic ignored "-Warray-bounds" #pragma GCC diagnostic ignored "-Wstringop-overflow=" #endif - memset( reinterpret_cast< void * >( ptr + size ), 0, ( sizeDiff ) * sizeof( T ) ); + std::memset( reinterpret_cast< void * >( ptr + size ), 0, ( sizeDiff ) * sizeof( T ) ); #if !defined(__clang__) #pragma GCC diagnostic pop #endif From 72cf6f6a68602571f9bccdc5a6c9e714fdc96bda Mon Sep 17 00:00:00 2001 From: wrtobin Date: Tue, 1 Oct 2024 10:53:46 -0700 Subject: [PATCH 2/4] guard other memset --- src/umpireInterface.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/umpireInterface.cpp b/src/umpireInterface.cpp index 9219564d..12e5de0f 100644 --- a/src/umpireInterface.cpp +++ b/src/umpireInterface.cpp @@ -71,8 +71,15 @@ void memset( void * const dstPointer, int const val, std::size_t const size ) return rm.memset( dstPointer, val, size ); } #endif - +#if !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow=" +#endif std::memset( dstPointer, val, size ); +#if !defined(__clang__) +#pragma GCC diagnostic pop +#endif } } // namespace umpireInterface From 99c123e1a04d37d2be163d85269bc6761099849a Mon Sep 17 00:00:00 2001 From: wrtobin Date: Tue, 1 Oct 2024 11:31:06 -0700 Subject: [PATCH 3/4] taking another shot at it --- src/umpireInterface.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/umpireInterface.cpp b/src/umpireInterface.cpp index 12e5de0f..0c875d55 100644 --- a/src/umpireInterface.cpp +++ b/src/umpireInterface.cpp @@ -64,17 +64,17 @@ camp::resources::Event copy( void * const dstPointer, void * const srcPointer, void memset( void * const dstPointer, int const val, std::size_t const size ) { +#if !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow=" +#endif #if defined( LVARRAY_USE_UMPIRE ) umpire::ResourceManager & rm = umpire::ResourceManager::getInstance(); if( rm.hasAllocator( dstPointer ) ) { return rm.memset( dstPointer, val, size ); } -#endif -#if !defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Warray-bounds" -#pragma GCC diagnostic ignored "-Wstringop-overflow=" #endif std::memset( dstPointer, val, size ); #if !defined(__clang__) From ff1cd56de95379a1844a52d18532de95d170e970 Mon Sep 17 00:00:00 2001 From: wrtobin Date: Tue, 1 Oct 2024 14:20:05 -0700 Subject: [PATCH 4/4] seems like this works? --- src/ArrayOfArraysView.hpp | 4 +++- src/arrayManipulation.hpp | 25 ++++++++----------------- src/umpireInterface.cpp | 8 -------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/ArrayOfArraysView.hpp b/src/ArrayOfArraysView.hpp index 3ce26cd1..ebcaa630 100644 --- a/src/ArrayOfArraysView.hpp +++ b/src/ArrayOfArraysView.hpp @@ -639,7 +639,9 @@ class ArrayOfArraysView * @param defaultArrayCapacity the default capacity for each new array. */ void resize( INDEX_TYPE const newSize, INDEX_TYPE const defaultArrayCapacity=0 ) - { return resizeImpl( newSize, defaultArrayCapacity ); } + { + return resizeImpl( newSize, defaultArrayCapacity ); + } /** * @brief Reserve space for the given number of arrays. diff --git a/src/arrayManipulation.hpp b/src/arrayManipulation.hpp index f79fed07..bd505d58 100644 --- a/src/arrayManipulation.hpp +++ b/src/arrayManipulation.hpp @@ -292,29 +292,20 @@ void resize( T * const LVARRAY_RESTRICT ptr, // Delete things between newSize and size. destroy( ptr + newSize, size - newSize ); - // Initialize things between size and newSize. - if constexpr ( sizeof ... ( ARGS ) == 0 && std::is_trivially_default_constructible< T >::value ) + if( newSize - size > 0 ) { - if( newSize - size > 0 ) + // Initialize things between size and newSize. + if constexpr ( sizeof ... ( ARGS ) == 0 && std::is_trivially_default_constructible< T >::value ) { std::size_t const sizeDiff = integerConversion< std::size_t >( newSize - size ); -#if !defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Warray-bounds" -#pragma GCC diagnostic ignored "-Wstringop-overflow=" -#endif std::memset( reinterpret_cast< void * >( ptr + size ), 0, ( sizeDiff ) * sizeof( T ) ); -#if !defined(__clang__) -#pragma GCC diagnostic pop -#endif } - } - else - { - // Use std::size_t so that when GCC optimizes this it doesn't produce sign warnings. - for( std::size_t i = size; i < std::size_t( newSize ); ++i ) + else { - new ( ptr + i ) T( std::forward< ARGS >( args )... ); + for( T * iptr = ptr + size; iptr < ptr + newSize; ++iptr ) + { + new ( iptr ) T( std::forward< ARGS >( args )... ); + } } } } diff --git a/src/umpireInterface.cpp b/src/umpireInterface.cpp index 0c875d55..23f29b3e 100644 --- a/src/umpireInterface.cpp +++ b/src/umpireInterface.cpp @@ -64,11 +64,6 @@ camp::resources::Event copy( void * const dstPointer, void * const srcPointer, void memset( void * const dstPointer, int const val, std::size_t const size ) { -#if !defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Warray-bounds" -#pragma GCC diagnostic ignored "-Wstringop-overflow=" -#endif #if defined( LVARRAY_USE_UMPIRE ) umpire::ResourceManager & rm = umpire::ResourceManager::getInstance(); if( rm.hasAllocator( dstPointer ) ) @@ -77,9 +72,6 @@ void memset( void * const dstPointer, int const val, std::size_t const size ) } #endif std::memset( dstPointer, val, size ); -#if !defined(__clang__) -#pragma GCC diagnostic pop -#endif } } // namespace umpireInterface