From 769252d77bcc017e6ffb3eafdcb90759ec258bac Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Thu, 18 Mar 2021 11:02:19 -0700 Subject: [PATCH 01/16] Added Spack config for Summit. --- .../spack_configs/summit/compilers.yaml | 46 +++++++++++++++++++ .../spack_configs/summit/packages.yaml | 28 +++++++++++ 2 files changed, 74 insertions(+) create mode 100644 scripts/uberenv/spack_configs/summit/compilers.yaml create mode 100644 scripts/uberenv/spack_configs/summit/packages.yaml diff --git a/scripts/uberenv/spack_configs/summit/compilers.yaml b/scripts/uberenv/spack_configs/summit/compilers.yaml new file mode 100644 index 00000000..3e310223 --- /dev/null +++ b/scripts/uberenv/spack_configs/summit/compilers.yaml @@ -0,0 +1,46 @@ +compilers: +- compiler: + spec: gcc@10.2.0 + paths: + cc: /sw/summit/gcc/10.2.0/bin/gcc + cxx: /sw/summit/gcc/10.2.0/bin/g++ + f77: + fc: + flags: + cflags: -mcpu=native -mtune=native + cxxflags: -mcpu=native -mtune=native + operating_system: rhel7 + target: ppc64le + modules: [gcc/10.2.0] + environment: {} + extra_rpaths: [] +- compiler: + spec: gcc@8.1.1 + paths: + cc: /sw/summit/gcc/8.1.1/bin/gcc + cxx: /sw/summit/gcc/8.1.1/bin/g++ + f77: + fc: + flags: + cflags: -mcpu=native -mtune=native + cxxflags: -mcpu=native -mtune=native + operating_system: rhel7 + target: ppc64le + modules: [gcc/8.1.1] + environment: {} + extra_rpaths: [] +- compiler: + spec: gcc@7.4.0 + paths: + cc: /sw/summit/gcc/7.4.0/bin/gcc + cxx: /sw/summit/gcc/7.4.0/bin/g++ + f77: + fc: + flags: + cflags: -mcpu=native -mtune=native + cxxflags: -mcpu=native -mtune=native + operating_system: rhel7 + target: ppc64le + modules: [gcc/7.4.0] + environment: {} + extra_rpaths: [] \ No newline at end of file diff --git a/scripts/uberenv/spack_configs/summit/packages.yaml b/scripts/uberenv/spack_configs/summit/packages.yaml new file mode 100644 index 00000000..c1986859 --- /dev/null +++ b/scripts/uberenv/spack_configs/summit/packages.yaml @@ -0,0 +1,28 @@ +packages: + all: + target: [default] + compiler: [gcc] + + cuda: + buildable: False + externals: + - spec: cuda@10.1.243 + modules: + - cuda/10.1.243 + - spec: cuda@11.2.0 + modules: + - cuda/11.2.0 + + cmake: + buildable: False + externals: + - spec: cmake@3.14.5 + modules: + - cmake/3.14.2 + + python: + buildable: False + externals: + - spec: python@3.7.0 + modules: + - python/3.7.0 From b5be34f4e4bde0d17c95175c276aebddd624f425 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Fri, 23 Apr 2021 13:54:30 -0700 Subject: [PATCH 02/16] Added allocator construction to ChaiBuffer and buffer construction to Array. --- examples/exampleBuffers.cpp | 12 +- src/Array.hpp | 83 +++++----- src/ArrayOfArraysView.hpp | 16 +- src/ArraySlice.hpp | 2 +- src/ArrayView.hpp | 21 ++- src/CRSMatrix.hpp | 2 +- src/ChaiBuffer.hpp | 67 ++++++-- src/MallocBuffer.hpp | 5 +- src/SortedArray.hpp | 2 +- src/StackBuffer.hpp | 4 +- src/bufferManipulation.hpp | 23 ++- src/indexing.hpp | 33 ++++ src/typeManipulation.hpp | 13 +- unitTests/CMakeLists.txt | 134 ++++++++-------- unitTests/testArray_ChaiBuffer.cpp | 120 +++++++++++++++ unitTests/testBuffers.cpp | 24 ++- unitTests/testChaiBuffer.cpp | 235 +++++++++++++++++++++++++++++ 17 files changed, 638 insertions(+), 158 deletions(-) create mode 100644 unitTests/testArray_ChaiBuffer.cpp create mode 100644 unitTests/testChaiBuffer.cpp diff --git a/examples/exampleBuffers.cpp b/examples/exampleBuffers.cpp index 202a5c66..914b75bc 100644 --- a/examples/exampleBuffers.cpp +++ b/examples/exampleBuffers.cpp @@ -30,7 +30,7 @@ TEST( MallocBuffer, copy ) { constexpr std::ptrdiff_t size = 55; LvArray::MallocBuffer< int > buffer( true ); - buffer.reallocate( 0, size ); + buffer.reallocate( 0, LvArray::MemorySpace::CPU, size ); for( int i = 0; i < size; ++i ) { @@ -54,7 +54,7 @@ TEST( MallocBuffer, nonPOD ) { constexpr std::ptrdiff_t size = 4; LvArray::MallocBuffer< std::string > buffer( true ); - buffer.reallocate( 0, size ); + buffer.reallocate( 0, LvArray::MemorySpace::CPU, size ); // Buffers don't initialize data so placement new must be used. for( int i = 0; i < size; ++i ) @@ -85,7 +85,7 @@ CUDA_TEST( ChaiBuffer, captureOnDevice ) { constexpr std::ptrdiff_t size = 55; LvArray::ChaiBuffer< int > buffer( true ); - buffer.reallocate( 0, size ); + buffer.reallocate( 0, LvArray::MemorySpace::CPU, size ); for( int i = 0; i < size; ++i ) { @@ -118,7 +118,7 @@ CUDA_TEST( ChaiBuffer, captureOnDeviceConst ) { constexpr std::ptrdiff_t size = 55; LvArray::ChaiBuffer< int > buffer( true ); - buffer.reallocate( 0, size ); + buffer.reallocate( 0, LvArray::MemorySpace::CPU, size ); for( int i = 0; i < size; ++i ) { @@ -153,7 +153,7 @@ CUDA_TEST( ChaiBuffer, captureOnDeviceConst ) TEST( ChaiBuffer, setName ) { LvArray::ChaiBuffer< int > buffer( true ); - buffer.reallocate( 0, 1024 ); + buffer.reallocate( 0, LvArray::MemorySpace::CPU, 1024 ); // Move to the device. buffer.move( LvArray::MemorySpace::GPU, true ); @@ -188,7 +188,7 @@ TEST( StackBuffer, example ) EXPECT_EQ( buffer[ i ], i ); } - EXPECT_DEATH_IF_SUPPORTED( buffer.reallocate( size, 2 * size ), "" ); + EXPECT_DEATH_IF_SUPPORTED( buffer.reallocate( size, LvArray::MemorySpace::CPU, 2 * size ), "" ); // Not necessary with the StackBuffer but it's good practice. buffer.free(); diff --git a/src/Array.hpp b/src/Array.hpp index 66806d0e..bd3cb692 100644 --- a/src/Array.hpp +++ b/src/Array.hpp @@ -89,7 +89,8 @@ class Array : public ArrayView< T, inline Array(): ParentClass( true ) { - CalculateStrides(); + this->m_strides = indexing::calculateStrides< PERMUTATION >( this->m_dims ); + #if !defined(__CUDA_ARCH__) setName( "" ); #endif @@ -110,6 +111,24 @@ class Array : public ArrayView< T, Array() { resize( dims ... ); } + /** + * @brief Construct an Array from @p buffer, taking ownership of its contents. + * @param buffer The buffer to construct the Array from. + * @note The Array is empty and @p buffer is expected to be empty as well. + */ + Array( BUFFER_TYPE< T > && buffer ): + ParentClass( std::move( buffer ) ) + { + this->m_strides = indexing::calculateStrides< PERMUTATION >( this->m_dims ); + +#if !defined(__CUDA_ARCH__) + setName( "" ); +#endif +#if defined(LVARRAY_USE_TOTALVIEW_OUTPUT) && !defined(__CUDA_ARCH__) + Array::TV_ttf_display_type( nullptr ); +#endif + } + /** * @brief Copy constructor. * @param source object to copy. @@ -285,7 +304,7 @@ class Array : public ArrayView< T, LVARRAY_ERROR_IF_LT( this->m_dims[ i ], 0 ); } - CalculateStrides(); + this->m_strides = indexing::calculateStrides< PERMUTATION >( this->m_dims ); bufferManipulation::resize( this->m_dataBuffer, oldSize, this->size() ); } @@ -313,7 +332,7 @@ class Array : public ArrayView< T, ++curDim; }, newDims ... ); - CalculateStrides(); + this->m_strides = indexing::calculateStrides< PERMUTATION >( this->m_dims ); bufferManipulation::resize( this->m_dataBuffer, oldSize, this->size() ); } @@ -328,6 +347,21 @@ class Array : public ArrayView< T, template< typename ... DIMS > LVARRAY_HOST_DEVICE void resizeWithoutInitializationOrDestruction( DIMS const ... newDims ) + { + return resizeWithoutInitializationOrDestruction( MemorySpace::CPU, newDims ... ); + } + + /** + * @brief Resize the array without initializing any new values or destroying any old values. + * Only safe on POD data, however it is much faster for large allocations. + * @tparam DIMS Variadic list of integral types. + * @param space The space to perform the resize in. + * @param newDims The new dimensions, must be of length NDIM. + * @note This does not preserve the values in the Array unless NDIM == 1. + */ + template< typename ... DIMS > + LVARRAY_HOST_DEVICE + void resizeWithoutInitializationOrDestruction( MemorySpace const space, DIMS const ... newDims ) { static_assert( sizeof ... ( DIMS ) == NDIM, "The number of arguments provided does not equal NDIM!" ); static_assert( std::is_trivially_destructible< T >::value, @@ -343,9 +377,9 @@ class Array : public ArrayView< T, ++i; }, newDims ... ); - CalculateStrides(); + this->m_strides = indexing::calculateStrides< PERMUTATION >( this->m_dims ); - bufferManipulation::reserve( this->m_dataBuffer, oldSize, this->size() ); + bufferManipulation::reserve( this->m_dataBuffer, oldSize, space, this->size() ); } /** @@ -374,7 +408,7 @@ class Array : public ArrayView< T, LVARRAY_ERROR_IF_LT( this->m_dims[ camp::get< 0 >( pair ) ], 0 ); }, camp::make_tuple( INDICES, newDims )... ); - CalculateStrides(); + this->m_strides = indexing::calculateStrides< PERMUTATION >( this->m_dims ); bufferManipulation::resize( this->m_dataBuffer, oldSize, this->size() ); } @@ -411,7 +445,7 @@ class Array : public ArrayView< T, this->m_dims[ this->getSingleParameterResizeIndex() ] = 0; - CalculateStrides(); + this->m_strides = indexing::calculateStrides< PERMUTATION >( this->m_dims ); } /** @@ -439,7 +473,7 @@ class Array : public ArrayView< T, * capacity() >= newCapacity. */ void reserve( INDEX_TYPE const newCapacity ) - { bufferManipulation::reserve( this->m_dataBuffer, this->size(), newCapacity ); } + { bufferManipulation::reserve( this->m_dataBuffer, this->size(), MemorySpace::CPU, newCapacity ); } ///@} @@ -544,31 +578,6 @@ class Array : public ArrayView< T, private: - /** - * @brief Calculate the strides given the dimensions and permutation. - * @note Adapted from RAJA::make_permuted_layout. - */ - LVARRAY_HOST_DEVICE - void CalculateStrides() - { - constexpr typeManipulation::CArray< camp::idx_t, NDIM > perm = typeManipulation::asArray( PERMUTATION {} ); - INDEX_TYPE foldedStrides[ NDIM ]; - - for( int i = 0; i < NDIM; ++i ) - { - foldedStrides[ i ] = 1; - for( int j = i + 1; j < NDIM; ++j ) - { - foldedStrides[ i ] *= this->m_dims[ perm[ j ] ]; - } - } - - for( int i = 0; i < NDIM; ++i ) - { - this->m_strides[ perm[ i ] ] = foldedStrides[ i ]; - } - } - /** * @brief Resize the default dimension of the Array. * @tparam ARGS variadic pack containing the types to initialize the new values with. @@ -590,7 +599,8 @@ class Array : public ArrayView< T, { INDEX_TYPE const oldSize = this->size(); this->m_dims[ this->m_singleParameterResizeIndex ] = newDimLength; - CalculateStrides(); + this->m_strides = indexing::calculateStrides< PERMUTATION >( this->m_dims ); + bufferManipulation::resize( this->m_dataBuffer, oldSize, this->size(), std::forward< ARGS >( args )... ); return; } @@ -602,7 +612,8 @@ class Array : public ArrayView< T, // Set the size of the dimension, recalculate the strides and get the new total size. this->m_dims[ this->m_singleParameterResizeIndex ] = newDimLength; - CalculateStrides(); + this->m_strides = indexing::calculateStrides< PERMUTATION >( this->m_dims ); + INDEX_TYPE const newSize = this->size(); // If we aren't changing the total size then we can return early. @@ -612,7 +623,7 @@ class Array : public ArrayView< T, if( newDimLength > curDimLength ) { // Reserve space in the buffer but don't initialize the values. - bufferManipulation::reserve( this->m_dataBuffer, curSize, newSize ); + bufferManipulation::reserve( this->m_dataBuffer, curSize, MemorySpace::CPU, newSize ); T * const ptr = this->data(); // The resizing consists of iterations where each iteration consists of the addition of a diff --git a/src/ArrayOfArraysView.hpp b/src/ArrayOfArraysView.hpp index 0dd1729d..eb3dd782 100644 --- a/src/ArrayOfArraysView.hpp +++ b/src/ArrayOfArraysView.hpp @@ -631,8 +631,8 @@ class ArrayOfArraysView */ void reserve( INDEX_TYPE const newCapacity ) { - bufferManipulation::reserve( m_offsets, m_numArrays + 1, newCapacity + 1 ); - bufferManipulation::reserve( m_sizes, m_numArrays, newCapacity ); + bufferManipulation::reserve( m_offsets, m_numArrays + 1, MemorySpace::CPU, newCapacity + 1 ); + bufferManipulation::reserve( m_sizes, m_numArrays, MemorySpace::CPU, newCapacity ); } /** @@ -648,7 +648,7 @@ class ArrayOfArraysView INDEX_TYPE const maxOffset = m_offsets[ m_numArrays ]; typeManipulation::forEachArg( [newValueCapacity, maxOffset] ( auto & buffer ) { - bufferManipulation::reserve( buffer, maxOffset, newValueCapacity ); + bufferManipulation::reserve( buffer, maxOffset, MemorySpace::CPU, newValueCapacity ); }, m_values, buffers ... ); } @@ -710,11 +710,11 @@ class ArrayOfArraysView destroyValues( 0, m_numArrays, buffers ... ); - bufferManipulation::reserve( m_sizes, m_numArrays, numSubArrays ); + bufferManipulation::reserve( m_sizes, m_numArrays, MemorySpace::CPU, numSubArrays ); std::fill_n( m_sizes.data(), numSubArrays, 0 ); INDEX_TYPE const offsetsSize = ( m_numArrays == 0 ) ? 0 : m_numArrays + 1; - bufferManipulation::reserve( m_offsets, offsetsSize, numSubArrays + 1 ); + bufferManipulation::reserve( m_offsets, offsetsSize, MemorySpace::CPU, numSubArrays + 1 ); m_offsets[ 0 ] = 0; // RAJA::inclusive_scan fails on empty input range @@ -730,7 +730,7 @@ class ArrayOfArraysView INDEX_TYPE const maxOffset = m_offsets[ m_numArrays ]; typeManipulation::forEachArg( [ maxOffset] ( auto & buffer ) { - bufferManipulation::reserve( buffer, 0, maxOffset ); + bufferManipulation::reserve( buffer, 0, MemorySpace::CPU, maxOffset ); }, m_values, buffers ... ); } @@ -787,7 +787,7 @@ class ArrayOfArraysView INDEX_TYPE const maxOffset = m_offsets[ m_numArrays ]; typeManipulation::forEachArg( [totalSize, maxOffset]( auto & buffer ) { - bufferManipulation::reserve( buffer, maxOffset, totalSize ); + bufferManipulation::reserve( buffer, maxOffset, MemorySpace::CPU, totalSize ); }, m_values, buffers ... ); } } @@ -843,7 +843,7 @@ class ArrayOfArraysView INDEX_TYPE const maxOffset = m_offsets[ m_numArrays ]; typeManipulation::forEachArg( [maxOffset, srcMaxOffset]( auto & dstBuffer ) { - bufferManipulation::reserve( dstBuffer, maxOffset, srcMaxOffset ); + bufferManipulation::reserve( dstBuffer, maxOffset, MemorySpace::CPU, srcMaxOffset ); }, m_values, pairs.first ... ); m_numArrays = srcNumArrays; diff --git a/src/ArraySlice.hpp b/src/ArraySlice.hpp index 8d197504..2156437b 100644 --- a/src/ArraySlice.hpp +++ b/src/ArraySlice.hpp @@ -259,7 +259,7 @@ class ArraySlice /** * @return A raw pointer. - * @note This method is only active when NDIM == 0 and USD == 0. + * @note This method is only active when NDIM == 1 and USD == 0. */ template< int _NDIM=NDIM, int _USD=USD > LVARRAY_HOST_DEVICE constexpr inline diff --git a/src/ArrayView.hpp b/src/ArrayView.hpp index 45b94ce8..77d1b54e 100644 --- a/src/ArrayView.hpp +++ b/src/ArrayView.hpp @@ -586,6 +586,12 @@ class ArrayView */ ///@{ + /** + * @return The last space the Array was moved to. + */ + MemorySpace getPreviousSpace() const + { return m_dataBuffer.getPreviousSpace(); } + /** * @brief Touch the memory in @p space. * @param space The memory space in which a touch will be recorded. @@ -595,7 +601,6 @@ class ArrayView m_dataBuffer.registerTouch( space ); } - /** * @brief Move the Array to the given execution space, optionally touching it. * @param space the space to move the Array to. @@ -649,6 +654,20 @@ class ArrayView #endif } + /** + * @brief Protected constructor to be used by the Array class. + * @details Construct an empty ArrayView from @p buffer. + * @param buffer The buffer use. + */ + DISABLE_HD_WARNING + inline LVARRAY_HOST_DEVICE constexpr + ArrayView( BUFFER_TYPE< T > && buffer ) noexcept: + m_dims{ 0 }, + m_strides{ 0 }, + m_dataBuffer{ std::move( buffer ) }, + m_singleParameterResizeIndex{ 0 } + {} + /// the dimensions of the array. typeManipulation::CArray< INDEX_TYPE, NDIM > m_dims = { 0 }; diff --git a/src/CRSMatrix.hpp b/src/CRSMatrix.hpp index 83fefca4..1ce9eb07 100644 --- a/src/CRSMatrix.hpp +++ b/src/CRSMatrix.hpp @@ -146,7 +146,7 @@ class CRSMatrix : protected CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE } // Reallocate to the appropriate length - bufferManipulation::reserve( this->m_entries, 0, src.nonZeroCapacity() ); + bufferManipulation::reserve( this->m_entries, 0, MemorySpace::CPU, src.nonZeroCapacity() ); ParentClass::assimilate( reinterpret_cast< SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE > && >( src ) ); diff --git a/src/ChaiBuffer.hpp b/src/ChaiBuffer.hpp index 24f0d8e9..665fc5c2 100644 --- a/src/ChaiBuffer.hpp +++ b/src/ChaiBuffer.hpp @@ -145,6 +145,34 @@ class ChaiBuffer } } + /** + * @brief Construct a ChaiBuffer which uses the specific allocator for each space. + * @param spaces The list of spaces. + * @param allocators The allocators, must be the same length as @p spaces. + * @details @code allocator[ i ] @endcode is used for the memory space @code spaces[ i ] @endcode. + */ + ChaiBuffer( std::initializer_list< MemorySpace > const & spaces, + std::initializer_list< umpire::Allocator > const & allocators ): + m_pointer( nullptr ), + m_capacity( 0 ), + m_pointerRecord( new chai::PointerRecord{} ) + { + m_pointerRecord->m_size = 0; + setName( "" ); + + LVARRAY_ERROR_IF_NE( spaces.size(), allocators.size() ); + + for( int space = chai::CPU; space < chai::NUM_EXECUTION_SPACES; ++space ) + { + m_pointerRecord->m_allocators[ space ] = internal::getArrayManager().getAllocatorId( chai::ExecutionSpace( space ) ); + } + + for( std::size_t i = 0; i < spaces.size(); ++i ) + { + m_pointerRecord->m_allocators[ internal::toChaiExecutionSpace( spaces.begin()[ i ] ) ] = allocators.begin()[ i ].getId(); + } + } + /** * @brief Copy constructor. * @param src The buffer to copy. @@ -245,38 +273,43 @@ class ChaiBuffer /** * @brief Reallocate the buffer to the new capacity. - * @param size the number of values that are initialized in the buffer. - * Values between [0, size) are destroyed. + * @param size the number of values that are initialized in the buffer. Values between [0, size) are destroyed. + * @param space The space to perform the reallocation in. If space is the CPU then the buffer is reallocated + * only on the CPU and it is free'd in the other spaces. If the space is the GPU the the current size must be zero. * @param newCapacity the new capacity of the buffer. - * @note This currently only reallocates the buffer on the CPU and it frees - * the buffer in every other memory space. */ - void reallocate( std::ptrdiff_t const size, std::ptrdiff_t const newCapacity ) + void reallocate( std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity ) { chai::PointerRecord * const newRecord = new chai::PointerRecord{}; newRecord->m_size = newCapacity * sizeof( T ); newRecord->m_user_callback = m_pointerRecord->m_user_callback; - for( int space = chai::CPU; space < chai::NUM_EXECUTION_SPACES; ++space ) + for( int s = chai::CPU; s < chai::NUM_EXECUTION_SPACES; ++s ) { - newRecord->m_allocators[ space ] = m_pointerRecord->m_allocators[ space ]; + newRecord->m_allocators[ s ] = m_pointerRecord->m_allocators[ s ]; } + chai::ExecutionSpace const chaiSpace = internal::toChaiExecutionSpace( space ); + internal::chaiLock.lock(); - internal::getArrayManager().allocate( newRecord, chai::CPU ); + internal::getArrayManager().allocate( newRecord, chaiSpace ); internal::chaiLock.unlock(); - T * const newPointer = static_cast< T * >( newRecord->m_pointers[ chai::CPU ] ); + T * const newPointer = static_cast< T * >( newRecord->m_pointers[ chaiSpace ] ); - std::ptrdiff_t const overlapAmount = std::min( newCapacity, size ); - arrayManipulation::uninitializedMove( newPointer, overlapAmount, m_pointer ); - arrayManipulation::destroy( m_pointer, size ); + if( size > 0 ) + { + LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::CPU, "Calling reallocate with a non-zero current size is not yet supporeted for the GPU." ); + std::ptrdiff_t const overlapAmount = std::min( newCapacity, size ); + arrayManipulation::uninitializedMove( newPointer, overlapAmount, m_pointer ); + arrayManipulation::destroy( m_pointer, size ); + } free(); m_capacity = newCapacity; m_pointer = newPointer; m_pointerRecord = newRecord; - registerTouch( MemorySpace::CPU ); + registerTouch( space ); } /** @@ -383,6 +416,12 @@ class ChaiBuffer #endif } + /** + * @return The last space the ChaiBuffer was moved to. + */ + MemorySpace getPreviousSpace() const + { return internal::toMemorySpace( m_pointerRecord->m_last_space ); } + /** * @brief Touch the buffer in the given space. * @param space the space to touch. @@ -403,7 +442,7 @@ class ChaiBuffer template< typename U=ChaiBuffer< T > > void setName( std::string const & name ) { - std::string const typeString = LvArray::system::demangleType< U >(); + std::string const typeString = system::demangleType< U >(); m_pointerRecord->m_user_callback = [name, typeString]( chai::PointerRecord const * const record, chai::Action const act, chai::ExecutionSpace const s ) { diff --git a/src/MallocBuffer.hpp b/src/MallocBuffer.hpp index 04640c01..240938c5 100644 --- a/src/MallocBuffer.hpp +++ b/src/MallocBuffer.hpp @@ -122,10 +122,13 @@ class MallocBuffer : public bufferManipulation::VoidBuffer /** * @brief Reallocate the buffer to the new capacity. * @param size The number of values that are initialized in the buffer. + * @param space The space to perform the reallocation in, not used. * @param newCapacity The new capacity of the buffer. */ - void reallocate( std::ptrdiff_t const size, std::ptrdiff_t const newCapacity ) + void reallocate( std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity ) { + LVARRAY_ERROR_IF_NE( space, MemorySpace::CPU ); + // TODO: If std::is_trivially_copyable_v< T > then we could use std::realloc. T * const newPtr = reinterpret_cast< T * >( std::malloc( newCapacity * sizeof( T ) ) ); diff --git a/src/SortedArray.hpp b/src/SortedArray.hpp index da2299d1..cd4473d3 100644 --- a/src/SortedArray.hpp +++ b/src/SortedArray.hpp @@ -309,7 +309,7 @@ class SortedArray : protected SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE > */ inline void reserve( INDEX_TYPE const nVals ) - { bufferManipulation::reserve( this->m_values, size(), nVals ); } + { bufferManipulation::reserve( this->m_values, size(), MemorySpace::CPU, nVals ); } ///@} diff --git a/src/StackBuffer.hpp b/src/StackBuffer.hpp index 3ea0e6f5..831a3643 100644 --- a/src/StackBuffer.hpp +++ b/src/StackBuffer.hpp @@ -80,12 +80,14 @@ class StackBuffer : public bufferManipulation::VoidBuffer * @brief Notionally this method reallocates the buffer, but since the StackBuffer is sized at * compile time all this does is check that newCapacity doesn't exceed LENGTH. * @param size The current size of the buffer, not used. + * @param space The space to perform the reallocation in, not used. * @param newCapacity the new capacity of the buffer. */ LVARRAY_HOST_DEVICE inline - void reallocate( std::ptrdiff_t const size, std::ptrdiff_t const newCapacity ) + void reallocate( std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity ) { LVARRAY_UNUSED_VARIABLE( size ); + LVARRAY_UNUSED_VARIABLE( space ); LVARRAY_ERROR_IF_GT( newCapacity, LENGTH ); } /** diff --git a/src/bufferManipulation.hpp b/src/bufferManipulation.hpp index 86265966..5bcf381e 100644 --- a/src/bufferManipulation.hpp +++ b/src/bufferManipulation.hpp @@ -106,6 +106,13 @@ struct VoidBuffer LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::CPU, "This Buffer type can only be used on the CPU." ); } + /** + * @return The last space the buffer was moved to. + * @note The default behavior is that the Buffer can only exist on the CPU. + */ + MemorySpace getPreviousSpace() const + { return MemorySpace::CPU; } + /** * @brief Touch the buffer in the given space. * @param space the space to touch. @@ -199,15 +206,16 @@ void free( BUFFER & buf, std::ptrdiff_t const size ) * @tparam BUFFER the buffer type. * @param buf The buffer to set the capacity of. * @param size The size of the buffer. + * @param space The space to set the capacity in. * @param newCapacity The new capacity of the buffer. */ DISABLE_HD_WARNING template< typename BUFFER > LVARRAY_HOST_DEVICE -void setCapacity( BUFFER & buf, std::ptrdiff_t const size, std::ptrdiff_t const newCapacity ) +void setCapacity( BUFFER & buf, std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity ) { check( buf, size ); - buf.reallocate( size, newCapacity ); + buf.reallocate( size, space, newCapacity ); } /** @@ -215,17 +223,18 @@ void setCapacity( BUFFER & buf, std::ptrdiff_t const size, std::ptrdiff_t const * @tparam BUFFER the buffer type. * @param buf The buffer to reserve space in. * @param size The size of the buffer. + * @param space The space to perform the reserve in. * @param newCapacity The new minimum capacity of the buffer. */ template< typename BUFFER > LVARRAY_HOST_DEVICE -void reserve( BUFFER & buf, std::ptrdiff_t const size, std::ptrdiff_t const newCapacity ) +void reserve( BUFFER & buf, std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity ) { check( buf, size ); if( newCapacity > buf.capacity() ) { - setCapacity( buf, size, newCapacity ); + setCapacity( buf, size, space, newCapacity ); } } @@ -246,7 +255,7 @@ void dynamicReserve( BUFFER & buf, std::ptrdiff_t const size, std::ptrdiff_t con if( newCapacity > buf.capacity() ) { - setCapacity( buf, size, 2 * newCapacity ); + setCapacity( buf, size, MemorySpace::CPU, 2 * newCapacity ); } } @@ -258,8 +267,6 @@ void dynamicReserve( BUFFER & buf, std::ptrdiff_t const size, std::ptrdiff_t con * @param size The current size of the buffer. * @param newSize The new size of the buffer. * @param args The arguments to initialize the new values with. - * @note Use this in methods which increase the size of the buffer to efficiently grow - * the capacity. */ template< typename BUFFER, typename ... ARGS > LVARRAY_HOST_DEVICE @@ -267,7 +274,7 @@ void resize( BUFFER & buf, std::ptrdiff_t const size, std::ptrdiff_t const newSi { check( buf, size ); - reserve( buf, size, newSize ); + reserve( buf, size, MemorySpace::CPU, newSize ); arrayManipulation::resize( buf.data(), size, newSize, std::forward< ARGS >( args )... ); diff --git a/src/indexing.hpp b/src/indexing.hpp index 05be8254..a2ce89ff 100644 --- a/src/indexing.hpp +++ b/src/indexing.hpp @@ -208,6 +208,39 @@ LVARRAY_HOST_DEVICE inline void checkIndices( INDEX_TYPE const * const LVARRAY_RESTRICT dims, INDICES const ... indices ) { LVARRAY_ERROR_IF( invalidIndices( dims, indices ... ), "Invalid indices. " << printDimsAndIndices( dims, indices ... ) ); } +/** + * @brief Calculate the strides given the dimensions and permutation. + * @tparam PERMUTATION The permutation to apply to the dimensions to calculate the strides. + * @tparam INDEX_TYPE The integral type used for the dimensions of the space. + * @tparam NDIM The number of dimensions. + * @param dims The size of each dimension. + * @return The strides of each dimension. + * @note Adapted from RAJA::make_permuted_layout. + */ +template< typename PERMUTATION, typename INDEX_TYPE, camp::idx_t NDIM > +LVARRAY_HOST_DEVICE inline +typeManipulation::CArray< INDEX_TYPE, NDIM > calculateStrides( typeManipulation::CArray< INDEX_TYPE, NDIM > const & dims ) +{ + constexpr typeManipulation::CArray< camp::idx_t, NDIM > perm = typeManipulation::asArray( PERMUTATION {} ); + INDEX_TYPE foldedStrides[ NDIM ]; + + for( int i = 0; i < NDIM; ++i ) + { + foldedStrides[ i ] = 1; + for( int j = i + 1; j < NDIM; ++j ) + { + foldedStrides[ i ] *= dims[ perm[ j ] ]; + } + } + + typeManipulation::CArray< INDEX_TYPE, NDIM > strides; + for( int i = 0; i < NDIM; ++i ) + { + strides[ perm[ i ] ] = foldedStrides[ i ]; + } + + return strides; +} } // namespace indexing } // namespace LvArray diff --git a/src/typeManipulation.hpp b/src/typeManipulation.hpp index 29d455c5..204f8aca 100644 --- a/src/typeManipulation.hpp +++ b/src/typeManipulation.hpp @@ -423,7 +423,7 @@ constexpr camp::idx_t getDimension( camp::idx_seq< INDICES... > ) * @return The unit stride dimension, the last index in the sequence. */ template< camp::idx_t... INDICES > -constexpr camp::idx_t getStrideOneDimension( camp::idx_seq< INDICES... > ) +LVARRAY_HOST_DEVICE constexpr camp::idx_t getStrideOneDimension( camp::idx_seq< INDICES... > ) { constexpr camp::idx_t dimension = camp::seq_at< sizeof...( INDICES ) - 1, camp::idx_seq< INDICES... > >::value; static_assert( dimension >= 0, "The dimension must be greater than zero." ); @@ -448,7 +448,7 @@ constexpr bool isValidPermutation( PERMUTATION ) * @struct CArray * @brief A wrapper around a compile time c array. */ -template< typename T, std::ptrdiff_t N > +template< typename T, camp::idx_t N > struct CArray { /** @@ -456,7 +456,7 @@ struct CArray * @param i The position to access. */ LVARRAY_INTEL_CONSTEXPR inline LVARRAY_HOST_DEVICE - T & operator[]( std::ptrdiff_t const i ) + T & operator[]( camp::idx_t const i ) { return data[ i ]; } /** @@ -464,19 +464,18 @@ struct CArray * @param i The position to access. */ constexpr inline LVARRAY_HOST_DEVICE - T const & operator[]( std::ptrdiff_t const i ) const + T const & operator[]( camp::idx_t const i ) const { return data[ i ]; } /** * @return Return the size of the array. */ constexpr inline LVARRAY_HOST_DEVICE - std::ptrdiff_t size() + camp::idx_t size() { return N; } /// The backing c array, public so that aggregate initialization works. - /// The funny name is to dissuade the user from accessing it directly. - T data[ N ]; + T data[ N ] = {}; }; /** diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index d374f5eb..dc9ed49d 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -1,73 +1,77 @@ # # Specify list of tests # -set(testSources - testArray1D.cpp - testArray1DOfArray1D.cpp - testArray1DOfArray1DOfArray1D.cpp - testArrayOfArrays.cpp - testArrayOfSets.cpp - testArraySlice.cpp - testArrayView_copyAssignmentOperator.cpp - testArrayView_copyConstructor.cpp - testArrayView_defaultConstructor.cpp - testArrayView_emptyMove.cpp - testArrayView_modifyInKernel.cpp - testArrayView_modifyInMultipleKernels.cpp - testArrayView_move.cpp - testArrayView_moveMultipleTimes.cpp - testArrayView_moveNoTouch.cpp - testArrayView_readInKernel.cpp - testArrayView_setValues.cpp - testArrayView_setValuesFromView.cpp - testArrayView_toSlice.cpp - testArrayView_toSliceConst.cpp - testArrayView_toView.cpp - testArrayView_toViewConst.cpp - testArrayView_udcToSlice.cpp - testArrayView_udcToSliceConst.cpp - testArrayView_udcToViewConst.cpp - testArray_clear.cpp - testArray_copyAssignmentOperator.cpp - testArray_copyConstructor.cpp - testArray_defaultConstructor.cpp - testArray_getSetSingleParameterResizeIndex.cpp - testArray_indexing.cpp - testArray_moveAssignmentOperator.cpp - testArray_moveConstructor.cpp - testArray_reserveAndCapacity.cpp - testArray_resize.cpp - testArray_resizeDefault.cpp - testArray_resizeDimension.cpp - testArray_resizeFromArgs.cpp - testArray_resizeFromPointer.cpp - testArray_resizeWithoutInitializationOrDestruction.cpp - testArray_sizedConstructor.cpp - testArray_toView.cpp - testArray_toViewConst.cpp - testBuffers.cpp - testCRSMatrix.cpp - testIndexing.cpp - testInput.cpp - testIntegerConversion.cpp - testMath.cpp - testSliceHelpers.cpp - testSortedArray.cpp - testSortedArrayManipulation.cpp - testSparsityPattern.cpp - testStackArray.cpp - testTensorOpsDeterminant.cpp - testTensorOpsEigen.cpp - testTensorOpsInverseOneArg.cpp - testTensorOpsInverseTwoArgs.cpp - testTensorOpsSymDeterminant.cpp - testTensorOpsSymInverseOneArg.cpp - testTensorOpsSymInverseTwoArgs.cpp - testTypeManipulation.cpp - testStackTrace.cpp - testInvalidOperations.cpp +set( testSources + testArray1D.cpp + testArray1DOfArray1D.cpp + testArray1DOfArray1DOfArray1D.cpp + testArrayOfArrays.cpp + testArrayOfSets.cpp + testArraySlice.cpp + testArrayView_copyAssignmentOperator.cpp + testArrayView_copyConstructor.cpp + testArrayView_defaultConstructor.cpp + testArrayView_emptyMove.cpp + testArrayView_modifyInKernel.cpp + testArrayView_modifyInMultipleKernels.cpp + testArrayView_move.cpp + testArrayView_moveMultipleTimes.cpp + testArrayView_moveNoTouch.cpp + testArrayView_readInKernel.cpp + testArrayView_setValues.cpp + testArrayView_setValuesFromView.cpp + testArrayView_toSlice.cpp + testArrayView_toSliceConst.cpp + testArrayView_toView.cpp + testArrayView_toViewConst.cpp + testArrayView_udcToSlice.cpp + testArrayView_udcToSliceConst.cpp + testArrayView_udcToViewConst.cpp + testArray_clear.cpp + testArray_copyAssignmentOperator.cpp + testArray_copyConstructor.cpp + testArray_defaultConstructor.cpp + testArray_getSetSingleParameterResizeIndex.cpp + testArray_indexing.cpp + testArray_moveAssignmentOperator.cpp + testArray_moveConstructor.cpp + testArray_reserveAndCapacity.cpp + testArray_resize.cpp + testArray_resizeDefault.cpp + testArray_resizeDimension.cpp + testArray_resizeFromArgs.cpp + testArray_resizeFromPointer.cpp + testArray_resizeWithoutInitializationOrDestruction.cpp + testArray_sizedConstructor.cpp + testArray_toView.cpp + testArray_toViewConst.cpp + testBuffers.cpp + testCRSMatrix.cpp + testIndexing.cpp + testInput.cpp + testIntegerConversion.cpp + testMath.cpp + testSliceHelpers.cpp + testSortedArray.cpp + testSortedArrayManipulation.cpp + testSparsityPattern.cpp + testStackArray.cpp + testTensorOpsDeterminant.cpp + testTensorOpsEigen.cpp + testTensorOpsInverseOneArg.cpp + testTensorOpsInverseTwoArgs.cpp + testTensorOpsSymDeterminant.cpp + testTensorOpsSymInverseOneArg.cpp + testTensorOpsSymInverseTwoArgs.cpp + testTypeManipulation.cpp + testStackTrace.cpp + testInvalidOperations.cpp ) +if( ENABLE_CHAI ) + set( testSources ${testSources} testChaiBuffer.cpp testArray_ChaiBuffer.cpp ) +endif() + # # Add gtest C++ based tests # diff --git a/unitTests/testArray_ChaiBuffer.cpp b/unitTests/testArray_ChaiBuffer.cpp new file mode 100644 index 00000000..7b302305 --- /dev/null +++ b/unitTests/testArray_ChaiBuffer.cpp @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * All rights reserved. + * See the LICENSE file for details. + * SPDX-License-Identifier: (BSD-3-Clause) + */ + +/** + * @file testBuffers.cpp + */ + +// Source includes +#include "testUtils.hpp" +#include "ChaiBuffer.hpp" +#include "Array.hpp" + +// TPL includes +#include + +// System includes +#include +#include + + +namespace LvArray +{ +namespace testing +{ + +template< typename T > +class ArrayTest : public ::testing::Test +{ +public: + + void testAllocatorConstruction() + { + umpire::ResourceManager & rm = umpire::ResourceManager::getInstance(); + auto hostPool = rm.makeAllocator< umpire::strategy::DynamicPool >( "HOST_pool", rm.getAllocator( "HOST" ) ); + + #if defined( LVARRAY_USE_CUDA ) + auto devicePool = rm.makeAllocator< umpire::strategy::DynamicPool >( "DEVICE_pool", rm.getAllocator( "DEVICE" ) ); + std::initializer_list< MemorySpace > const spaces = { MemorySpace::CPU, MemorySpace::GPU }; + std::initializer_list< umpire::Allocator > const allocators = { hostPool, devicePool }; + #else + std::initializer_list< MemorySpace > const spaces = { MemorySpace::CPU }; + std::initializer_list< umpire::Allocator > const allocators = { hostPool }; + #endif + + Array< int, 1, RAJA::PERM_I, int, ChaiBuffer > array( ChaiBuffer< T >( spaces, allocators ) ); + array.resize( 100 ); + + for( int i = 0; i < array.size(); ++i ) + { + array[ i ] = T( i ); + } + + EXPECT_EQ( rm.getAllocator( array.data() ).getName(), "HOST_pool" ); + + #if defined( LVARRAY_USE_CUDA ) + array.move( MemorySpace::GPU, true ); + EXPECT_EQ( rm.getAllocator( array.data() ).getName(), "DEVICE_pool" ); + + array.move( MemorySpace::CPU, true ); + EXPECT_EQ( rm.getAllocator( array.data() ).getName(), "HOST_pool" ); + #endif + } + +#if defined( LVARRAY_USE_CUDA ) + void testDeviceAlloc() + { + Array< int, 1, RAJA::PERM_I, int, ChaiBuffer > array; + + array.resizeWithoutInitializationOrDestruction( MemorySpace::GPU, 100 ); + + T * const devPtr = array.data(); + forall< parallelDevicePolicy< 32 > >( array.size(), [devPtr] LVARRAY_DEVICE ( int const i ) + { + new ( &devPtr[ i ] ) T( i ); + } ); + + array.move( MemorySpace::CPU, true ); + for( int i = 0; i < array.size(); ++i ) + { + EXPECT_EQ( array[ i ], T( i ) ); + } + } +#endif +}; + +/// The list of types to instantiate ArrayTest with. +using ArrayTestTypes = ::testing::Types< + int + >; + +TYPED_TEST_SUITE( ArrayTest, ArrayTestTypes, ); + +TYPED_TEST( ArrayTest, AllocatorConstruction ) +{ + this->testAllocatorConstruction(); +} + +#if defined( LVARRAY_USE_CUDA ) + +TYPED_TEST( ArrayTest, DeviceAlloc ) +{ + this->testDeviceAlloc(); +} + +#endif + +} // namespace testing +} // namespace LvArray + +// This is the default gtest main method. It is included for ease of debugging. +int main( int argc, char * * argv ) +{ + ::testing::InitGoogleTest( &argc, argv ); + int const result = RUN_ALL_TESTS(); + return result; +} diff --git a/unitTests/testBuffers.cpp b/unitTests/testBuffers.cpp index 1e9837b0..496c868f 100644 --- a/unitTests/testBuffers.cpp +++ b/unitTests/testBuffers.cpp @@ -147,6 +147,16 @@ TYPED_TEST( BufferAPITest, setName ) bufferManipulation::free( buffer, 0 ); } +TYPED_TEST( BufferAPITest, getPreviousSpace ) +{ + TypeParam buffer( true ); + + MemorySpace const previousSpace = buffer.getPreviousSpace(); + LVARRAY_UNUSED_VARIABLE( previousSpace ); + + bufferManipulation::free( buffer, 0 ); +} + template< typename > struct ToBufferConst {}; @@ -187,7 +197,7 @@ class BufferTestNoRealloc : public ::testing::Test */ void SetUp() override { - m_buffer.reallocate( 0, NO_REALLOC_CAPACITY ); + m_buffer.reallocate( 0, MemorySpace::CPU, NO_REALLOC_CAPACITY ); } /** @@ -606,7 +616,7 @@ class BufferTestWithRealloc : public BufferTestNoRealloc< BUFFER_TYPE > { COMPARE_TO_REFERENCE( m_buffer, m_ref ); - bufferManipulation::setCapacity( m_buffer, size(), size() + 100 ); + bufferManipulation::setCapacity( m_buffer, size(), MemorySpace::CPU, size() + 100 ); T const * const ptr = m_buffer.data(); T const val( randInt() ); @@ -617,7 +627,7 @@ class BufferTestWithRealloc : public BufferTestNoRealloc< BUFFER_TYPE > COMPARE_TO_REFERENCE( m_buffer, m_ref ); - bufferManipulation::setCapacity( m_buffer, size(), size() - 50 ); + bufferManipulation::setCapacity( m_buffer, size(), MemorySpace::CPU, size() - 50 ); m_ref.resize( size() - 50 ); COMPARE_TO_REFERENCE( m_buffer, m_ref ); @@ -630,20 +640,20 @@ class BufferTestWithRealloc : public BufferTestNoRealloc< BUFFER_TYPE > { COMPARE_TO_REFERENCE( m_buffer, m_ref ); - bufferManipulation::setCapacity( m_buffer, size(), size() + 100 ); + bufferManipulation::setCapacity( m_buffer, size(), MemorySpace::CPU, size() + 100 ); T const * const ptr = m_buffer.data(); T const val( randInt() ); bufferManipulation::resize( m_buffer, size(), size() + 100, val ); m_ref.resize( size() + 100, val ); - bufferManipulation::reserve( m_buffer, size(), size() - 50 ); + bufferManipulation::reserve( m_buffer, size(), MemorySpace::CPU, size() - 50 ); EXPECT_EQ( ptr, m_buffer.data() ); COMPARE_TO_REFERENCE( m_buffer, m_ref ); - bufferManipulation::reserve( m_buffer, size(), size() + 50 ); + bufferManipulation::reserve( m_buffer, size(), MemorySpace::CPU, size() + 50 ); T const * const newPtr = m_buffer.data(); T const newVal( randInt() ); @@ -735,8 +745,6 @@ TYPED_TEST( BufferTestWithRealloc, combination ) // TODO: // BufferTestNoRealloc on device with StackBuffer + MallocBuffer -// Move tests with ChaiBuffer -// Copy-capture tests with ChaiBuffer } // namespace testing } // namespace LvArray diff --git a/unitTests/testChaiBuffer.cpp b/unitTests/testChaiBuffer.cpp new file mode 100644 index 00000000..2a79c868 --- /dev/null +++ b/unitTests/testChaiBuffer.cpp @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * All rights reserved. + * See the LICENSE file for details. + * SPDX-License-Identifier: (BSD-3-Clause) + */ + +/** + * @file testBuffers.cpp + */ + +// Source includes +#include "testUtils.hpp" +#include "ChaiBuffer.hpp" + +// TPL includes +#include + +// System includes +#include +#include + + +namespace LvArray +{ +namespace testing +{ + +template< typename T > +class ChaiBufferTest : public ::testing::Test +{ +public: + + void testAllocatorConstruction() + { + umpire::ResourceManager & rm = umpire::ResourceManager::getInstance(); + auto hostPool = rm.makeAllocator< umpire::strategy::DynamicPool >( "HOST_pool", rm.getAllocator( "HOST" ) ); + + #if defined( LVARRAY_USE_CUDA ) + auto devicePool = rm.makeAllocator< umpire::strategy::DynamicPool >( "DEVICE_pool", rm.getAllocator( "DEVICE" ) ); + std::initializer_list< MemorySpace > const spaces = { MemorySpace::CPU, MemorySpace::GPU }; + std::initializer_list< umpire::Allocator > const allocators = { hostPool, devicePool }; + #else + std::initializer_list< MemorySpace > const spaces = { MemorySpace::CPU }; + std::initializer_list< umpire::Allocator > const allocators = { hostPool }; + #endif + + ChaiBuffer< T > buffer( spaces, allocators ); + + int const size = 100; + buffer.reallocate( 0, MemorySpace::CPU, size ); + + for( int i = 0; i < size; ++i ) + { + new ( &buffer[ i ] ) T( i ); + } + + EXPECT_EQ( rm.getAllocator( buffer.data() ).getName(), "HOST_pool" ); + + #if defined( LVARRAY_USE_CUDA ) + buffer.move( MemorySpace::GPU, true ); + EXPECT_EQ( rm.getAllocator( buffer.data() ).getName(), "DEVICE_pool" ); + + buffer.move( MemorySpace::CPU, true ); + EXPECT_EQ( rm.getAllocator( buffer.data() ).getName(), "HOST_pool" ); + #endif + + bufferManipulation::free( buffer, size ); + } + + +#if defined( LVARRAY_USE_CUDA ) + void testMove() + { + ChaiBuffer< T > buffer( true ); + + int const size = 100; + buffer.reallocate( 0, MemorySpace::CPU, size ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); + + for( int i = 0; i < size; ++i ) + { + new ( &buffer[ i ] ) T( i ); + } + + buffer.move( MemorySpace::GPU, true ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::GPU ); + T * const devPtr = buffer.data(); + + forall< parallelDevicePolicy< 32 > >( size, [devPtr] LVARRAY_DEVICE ( int const i ) + { + devPtr[ i ] += devPtr[ i ]; + } ); + + // Check that the device changes are seen on the host. Then modify the values without touching. + buffer.move( MemorySpace::CPU, false ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); + for( int i = 0; i < size; ++i ) + { + EXPECT_EQ( buffer[ i ], T( i ) + T( i ) ); + buffer[ i ] = T( 0 ); + } + + buffer.move( MemorySpace::GPU, true ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::GPU ); + forall< parallelDevicePolicy< 32 > >( size, [devPtr] LVARRAY_DEVICE ( int const i ) + { + devPtr[ i ] += devPtr[ i ]; + } ); + + buffer.move( MemorySpace::CPU, false ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); + for( int i = 0; i < size; ++i ) + { + EXPECT_EQ( buffer[ i ], T( i ) + T( i ) + T( i ) + T( i ) ); + } + + bufferManipulation::free( buffer, size ); + } + + void testCapture() + { + ChaiBuffer< T > buffer( true ); + + int const size = 100; + buffer.reallocate( 0, MemorySpace::CPU, size ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); + + for( int i = 0; i < size; ++i ) + { + new ( &buffer[ i ] ) T( i ); + } + + forall< parallelDevicePolicy< 32 > >( size, [buffer] LVARRAY_DEVICE ( int const i ) + { + buffer[ i ] += buffer[ i ]; + } ); + + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::GPU ); + + + // Check that the device changes are seen on the host. Then modify the values without touching. + ChaiBuffer< T const > constBuffer( buffer ); + forall< serialPolicy >( size, [constBuffer] ( int const i ) + { + EXPECT_EQ( constBuffer[ i ], T( i ) + T( i ) ); + const_cast< T & >( constBuffer[ i ] ) = T( 0 ); + } ); + + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); + EXPECT_EQ( constBuffer.getPreviousSpace(), MemorySpace::CPU ); + + forall< parallelDevicePolicy< 32 > >( size, [buffer] LVARRAY_DEVICE ( int const i ) + { + buffer[ i ] += buffer[ i ]; + } ); + + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::GPU ); + + forall< serialPolicy >( size, [constBuffer] ( int const i ) + { + EXPECT_EQ( constBuffer[ i ], T( i ) + T( i ) + T( i ) + T( i ) ); + } ); + + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); + EXPECT_EQ( constBuffer.getPreviousSpace(), MemorySpace::CPU ); + + bufferManipulation::free( buffer, size ); + } + + void testDeviceRealloc() + { + ChaiBuffer< T > buffer( true ); + + int const size = 100; + buffer.reallocate( 0, MemorySpace::GPU, size ); + + T * const devPtr = buffer.data(); + forall< parallelDevicePolicy< 32 > >( size, [devPtr] LVARRAY_DEVICE ( int const i ) + { + new ( &devPtr[ i ] ) T( i ); + } ); + + buffer.move( MemorySpace::CPU, true ); + for( int i = 0; i < size; ++i ) + { + EXPECT_EQ( buffer[ i ], T( i ) ); + } + + bufferManipulation::free( buffer, size ); + } +#endif +}; + +/// The list of types to instantiate ChaiBufferTest with. +using ChaiBufferTestTypes = ::testing::Types< + int + >; + +TYPED_TEST_SUITE( ChaiBufferTest, ChaiBufferTestTypes, ); + +TYPED_TEST( ChaiBufferTest, AllocatorConstruction ) +{ + this->testAllocatorConstruction(); +} + +#if defined( LVARRAY_USE_CUDA ) + +TYPED_TEST( ChaiBufferTest, Move ) +{ + this->testMove(); +} + +TYPED_TEST( ChaiBufferTest, Capture ) +{ + this->testCapture(); +} + +TYPED_TEST( ChaiBufferTest, DeviceRealloc ) +{ + this->testDeviceRealloc(); +} + +#endif + +} // namespace testing +} // namespace LvArray + +// This is the default gtest main method. It is included for ease of debugging. +int main( int argc, char * * argv ) +{ + ::testing::InitGoogleTest( &argc, argv ); + int const result = RUN_ALL_TESTS(); + return result; +} From db00ce62f7223d7ecbdf17977cc29bd1def4462e Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Fri, 23 Apr 2021 13:53:58 -0700 Subject: [PATCH 03/16] Added half precision math functions. --- src/fixedSizeSquareMatrixOpsImpl.hpp | 4 +- src/limits.hpp | 50 +- src/math.hpp | 937 ++++++++++++++++++++++++--- src/output.hpp | 29 + unitTests/testMath.cpp | 629 +++++++++++++++--- unitTests/testUtils.hpp | 4 +- 6 files changed, 1462 insertions(+), 191 deletions(-) diff --git a/src/fixedSizeSquareMatrixOpsImpl.hpp b/src/fixedSizeSquareMatrixOpsImpl.hpp index d29857a7..cfceb6d7 100644 --- a/src/fixedSizeSquareMatrixOpsImpl.hpp +++ b/src/fixedSizeSquareMatrixOpsImpl.hpp @@ -1211,8 +1211,8 @@ struct SquareMatrixOps< 3 > // roots are already sorted, since cos is monotonically decreasing on [0, pi] constexpr FloatingPoint squareRootThree = 1.73205080756887729352744; - eigenvalues[ 0 ] = -p * ( cosTheta + squareRootThree * sinTheta ); // == 2 * p * cos( theta + 2pi/3 ) - eigenvalues[ 1 ] = -p * ( cosTheta - squareRootThree * sinTheta ); // == 2 * p * cos( theta + pi/3 ) + eigenvalues[ 0 ] = -p * ( cosTheta + squareRootThree * sinTheta ); // == 2 * p * cos( theta + 2pi/3 ) + eigenvalues[ 1 ] = -p * ( cosTheta - squareRootThree * sinTheta ); // == 2 * p * cos( theta + pi/3 ) eigenvalues[ 2 ] = 2 * p * cosTheta; } diff --git a/src/limits.hpp b/src/limits.hpp index 19ba40a0..670dcb29 100644 --- a/src/limits.hpp +++ b/src/limits.hpp @@ -19,6 +19,10 @@ // System includes #include +#if defined( LVARRAY_USE_CUDA ) + #include +#endif + namespace LvArray { @@ -51,6 +55,32 @@ struct NumericLimits : public std::numeric_limits< T > static constexpr T denorm_min = std::numeric_limits< T >::denorm_min(); }; +#if defined( LVARRAY_USE_CUDA ) +/** + * @brief An overload for half precision. + * @note The values here are stored as float so that they can be constexpr. + */ +template<> +struct NumericLimits< __half > +{ + /// The smallest finite value T can hold. + static constexpr float min = 1.0 / 16384; + /// The lowest finite value T can hold. + static constexpr float lowest = -65504; + /// The largest finite value T can hold. + static constexpr float max = 65504; + /// The difference between 1.0 and the next representable value (if T is floating point). + static constexpr float epsilon = 1.0 / 1024; + /// The smallest positive subnormal value (if T is a floating point). + static constexpr float denorm_min = 1.0 / 16777216; +}; + +template<> +struct NumericLimits< __half2 > : public NumericLimits< __half > +{}; + +#endif + /** * @struct NumericLimitsNC * @brief The same as @c NumericLimits except the entries are not static or constexpr. @@ -58,26 +88,18 @@ struct NumericLimits : public std::numeric_limits< T > * @tparam T the numeric type to query. */ template< typename T > -struct NumericLimitsNC : public std::numeric_limits< T > +struct NumericLimitsNC { /// The smallest finite value T can hold. - T const min = std::numeric_limits< T >::min(); + T const min = NumericLimits< T >::min; /// The lowest finite value T can hold. - T const lowest = std::numeric_limits< T >::lowest(); + T const lowest = NumericLimits< T >::lowest; /// The largest finite value T can hold. - T const max = std::numeric_limits< T >::max(); + T const max = NumericLimits< T >::max; /// The difference between 1.0 and the next representable value (if T is floating point). - T const epsilon = std::numeric_limits< T >::epsilon(); - /// The maximum rounding error (if T is a floating point). - T const round_error = std::numeric_limits< T >::round_error(); - /// A positive infinity value (if T is a floating point). - T const infinity = std::numeric_limits< T >::infinity(); - /// A quiet NaN (if T is a floating point). - T const quiet_NaN = std::numeric_limits< T >::quiet_NaN(); - /// A signaling NaN (if T is a floating point). - T const signaling_NaN = std::numeric_limits< T >::signaling_NaN(); + T const epsilon = NumericLimits< T >::epsilon; /// The smallest positive subnormal value (if T is a floating point). - T const denorm_min = std::numeric_limits< T >::denorm_min(); + T const denorm_min = NumericLimits< T >::denorm_min; }; namespace internal diff --git a/src/math.hpp b/src/math.hpp index f89c6096..54b4062e 100644 --- a/src/math.hpp +++ b/src/math.hpp @@ -20,6 +20,10 @@ #include #include +#if defined( LVARRAY_USE_CUDA ) + #include +#endif + namespace LvArray { @@ -29,11 +33,272 @@ namespace LvArray namespace math { +namespace internal +{ + +/** + * @brief Convert @p u to type @tparam T. + * @tparam T The type to convert to. + * @tparam U The type to convert from. + * @param u The value to convert. + * @note No checking is done to ensure the conversion is safe. Ie you could convert -1 to uint. + * @return @p u converted to @tparam T. + */ +template< typename T, typename U > +LVARRAY_HOST_DEVICE inline constexpr +T convert( T const, U const u ) +{ return u; } + +/** + * @brief Return the number of values stored in @tparam T, by default this is 1. + * @tparam T The type to query. + * @return The number of values stored in @tparam T, by default this is 1. + */ +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +int numValues( T const ) +{ return 1; } + +/** + * @brief The type of a single value of type @c T. + * @tparam T The type to query. + */ +template< typename T > +struct SingleType +{ + /// An alias for T. + using type = T; +}; + +/** + * @return @p x. + * @tparam T The type of @p x. + * @param x The value to return. + */ +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +SingleType< T > getFirst( T const x ) +{ return x; } + +/** + * @return @p x. + * @tparam T The type of @p x. + * @param x The value to return. + */ +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +SingleType< T > getSecond( T const x ) +{ return x; } + +/** + * @return 1 if @p x is less than @p y, else 0. + * @tparam T The type of @p x and @p y. + * @param x The first value. + * @param y The second value. + */ +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +T lessThan( T const x, T const y ) +{ return __hlt( x, y ); } + +#if defined( LVARRAY_USE_CUDA ) +/** + * @brief Convert @p u to @c __half. + * @tparam U The type to convert from. + * @param u The value to convert. + * @note No checking is done to ensure the conversion is safe. + * @return @p u converted to @c __half. + */ +template< typename U > +LVARRAY_HOST_DEVICE inline constexpr +__half convert( __half const, U const u ) +{ return __float2half_rn( u ); } + +/** + * @brief Convert @p u to @c __half2, filling both halves of the returned value with @p u converted to @c __half. + * @tparam U The type to convert from. + * @param u The value to convert. + * @note No checking is done to ensure the conversion is safe. + * @return A @c __half2 with both halves having value @p u converted to @c __half. + */ +template< typename U > +LVARRAY_HOST_DEVICE inline constexpr +__half2 convert( __half2 const, U const u ) +{ return __float2half2_rn( u ); } + +/** + * @brief Convert @p u to @c __half2, filling both halves of the returned value with @p u. + * @param u The value to convert. + * @return A @c __half2 with both halves having value @p u. + */ +LVARRAY_HOST_DEVICE inline +__half2 convert( __half2 const, __half const u ) +{ +#if defined( __CUDA_ARCH__ ) + return __half2half2( u ); +#else + return __float2half2_rn( u ); +#endif +} + +/** + * @brief Convert @p u, @p v to @c __half2. + * @tparam U The first type to convert from. + * @tparam V The second type to convert from. + * @param u The first value to convert. + * @param v The second value to convert. + * @note No checking is done to ensure the conversion is safe. + * @return A @c __half2 containing @p u as the first value and @p v as the second. + */ +template< typename U, typename V > +LVARRAY_HOST_DEVICE inline constexpr +__half2 convert( __half2 const, U const u, V const v ) +{ return __floats2half2_rn( u, v ); } + +/** + * @brief Convert @p u, @p v to @c __half2. + * @param u The first value to convert. + * @param v The second value to convert. + * @return A @c __half2 containing @p u as the first value and @p v as the second. + */ +LVARRAY_HOST_DEVICE inline +__half2 convert( __half2 const, __half const u, __half const v ) +{ +#if defined( __CUDA_ARCH__ ) + return __halves2half2( u, v ); +#else + return __floats2half2_rn( u, v ); +#endif +} + +/** + * @brief Return the number of values stored in a @c __half2, which is 2. + * @return The number of values stored in a @c __half2, which is 2. + */ +LVARRAY_HOST_DEVICE inline constexpr +int numValues( __half2 const & ) +{ return 2; } + +/** + * @brief The type of a single value of type @c __half2. + */ +template<> +struct SingleType< __half2 > +{ + /// An alias for __half. + using type = __half; +}; + +/** + * @return The fist @c __half in @p x. + * @param x The value to query. + */ +LVARRAY_DEVICE inline +__half getFirst( __half2 const x ) +{ return __low2half( x ); } + +/** + * @return The second @c __half in @p x. + * @param x The value to query. + */ +LVARRAY_DEVICE inline +__half getSecond( __half2 const x ) +{ return __high2half( x ); } + +/** + * @return 1 if @p x is less than @p y, else 0. + * @param x The first value. + * @param y The second value. + */ +LVARRAY_DEVICE inline +__half lessThan( __half const x, __half const y ) +{ return __hlt( x, y ); } + +/** + * @return 1 if @p x is less than @p y, else 0, performed elementwise accross the two values. + * @param x The first value. + * @param y The second value. + */ +LVARRAY_DEVICE inline +__half2 lessThan( __half2 const x, __half2 const y ) +{ return __hlt2( x, y ); } + +#endif + +} // namespace internal + /** * @name General purpose functions */ ///@{ +/** + * @brief Return the number of values stored in type @tparam T. + * @param T The type to query. + * @return The number of values stored in type @tparam T. + */ +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +int numValues() +{ return internal::numValues( T() ); } + +/** + * @brief The type of a single value of type @c T. + * @tparam T The type to query. + */ +template< typename T > +using SingleType = typename internal::SingleType< T >::type; + +/** + * @brief Convert @p u to type @tparam T. + * @tparam T The type to convert to. + * @tparam U The type to convert from. + * @param u The value to convert. + * @note No checking is done to ensure the conversion is safe. Ie you could convert -1 to uint. + * @return @p u converted to @tparam T. + */ +template< typename T, typename U > +LVARRAY_HOST_DEVICE inline constexpr +T convert( U const u ) +{ return internal::convert( T(), u ); } + +/** + * @brief Convert @p u and @p v to a dual type @tparam T. + * @tparam T The type to convert to, must hold two values such as __half2. + * @tparam U The first type to convert from. + * @tparam U The second type to convert from. + * @param u The first value to convert. + * @param v The second value to convert. + * @note No checking is done to ensure the conversion is safe. Ie you could convert -1 to uint. + * @return @p u, @p v converted to @tparam T. + */ +template< typename T, typename U, typename V > +LVARRAY_HOST_DEVICE inline constexpr +T convert( U const u, V const v ) +{ return internal::convert( T(), u, v ); } + +/** + * @return The fist value in @p x. + * @tparam T The type of @p x. + * @param x The value to query. + * @note If @code numValues< T >() == 1 @endcode then @p x is returned. + */ +template< typename T > +LVARRAY_DEVICE inline +SingleType< T > getFirst( T const x ) +{ return internal::getFirst( x ); } + +/** + * @return The second value in @p x. + * @tparam T The type of @p x. + * @param x The value to query. + * @note If @code numValues< T >() == 1 @endcode then @p x is returned. + */ +template< typename T > +LVARRAY_DEVICE inline +SingleType< T > getSecond( T const x ) +{ return internal::getSecond( x ); } + /** * @return Return the maximum of the numbers @p a and @p b. * @tparam T A numeric type. @@ -46,13 +311,41 @@ std::enable_if_t< std::is_arithmetic< T >::value, T > max( T const a, T const b ) { #if defined(__CUDA_ARCH__) - static_assert( std::is_same< decltype( ::max( a, b ) ), T >::value, "Should return a T." ); return ::max( a, b ); #else return std::max( a, b ); #endif } +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc max( T, T ) +LVARRAY_DEVICE inline +__half max( __half const a, __half const b ) +{ +#if CUDART_VERSION > 11000 + return __hmax( a, b ); +#else + return a > b ? a : b; +#endif +} + +/// @copydoc max( T, T ) +LVARRAY_DEVICE inline +__half2 max( __half2 const a, __half2 const b ) +{ +#if CUDART_VERSION > 11000 + return __hmax2( a, b ); +#else + __half2 const aFactor = __hge2( a, b ); + __half2 const bFactor = convert< __half2 >( 1 ) - aFactor; + return a * aFactor + bFactor * b; +#endif +} + +#endif + + /** * @return Return the minimum of the numbers @p a and @p b. * @tparam T A numeric type. @@ -65,45 +358,92 @@ std::enable_if_t< std::is_arithmetic< T >::value, T > min( T const a, T const b ) { #if defined(__CUDA_ARCH__) - static_assert( std::is_same< decltype( ::min( a, b ) ), T >::value, "Should return a T." ); return ::min( a, b ); #else return std::min( a, b ); #endif } +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc min( T, T ) +LVARRAY_DEVICE inline +__half min( __half const a, __half const b ) +{ +#if CUDART_VERSION > 11000 + return __hmin( a, b ); +#else + return a < b ? a : b; +#endif +} + +/// @copydoc min( T, T ) +LVARRAY_DEVICE inline +__half2 min( __half2 const a, __half2 const b ) +{ +#if CUDART_VERSION > 11000 + return __hmin2( a, b ); +#else + __half2 const aFactor = __hle2( a, b ); + __half2 const bFactor = convert< __half2 >( 1 ) - aFactor; + return a * aFactor + bFactor * b; +#endif +} + +#endif + /** * @return The absolute value of @p x. * @param x The number to get the absolute value of. * @note This set of overloads is valid for any numeric type. */ -LVARRAY_HOST_DEVICE inline -float abs( float const x ) -{ return ::fabsf( x ); } - -/// @copydoc abs( float ) -LVARRAY_HOST_DEVICE inline -double abs( double const x ) -{ return ::fabs( x ); } - -/** - * @copydoc abs( float ) - * @tparam T An integral type. - */ template< typename T > -LVARRAY_HOST_DEVICE inline -std::enable_if_t< std::is_integral< T >::value, T > -abs( T const x ) +LVARRAY_HOST_DEVICE inline constexpr +T abs( T const x ) { #if defined(__CUDA_ARCH__) - static_assert( std::is_same< decltype( ::abs( x ) ), T >::value, "Should return a T." ); return ::abs( x ); #else - static_assert( std::is_same< decltype( std::abs( x ) ), T >::value, "Should return a T." ); return std::abs( x ); #endif } +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc abs( T ) +LVARRAY_DEVICE inline +__half abs( __half const x ) +{ +#if CUDART_VERSION > 11000 + return __habs( x ); +#else + return x > __half( 0 ) ? x : -x; +#endif +} + +/// @copydoc abs( T ) +LVARRAY_DEVICE inline +__half2 abs( __half2 const x ) +{ +#if CUDART_VERSION > 11000 + return __habs2( x ); +#else + return x - __hle2( x, convert< __half2 >( 0 ) ) * ( x + x ); +#endif +} + +#endif + +/** + * @return @code x * x @endcode. + * @tparam T The typeof @p x. + * @param x The value to square. + */ +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +T square( T const x ) +{ return x * x; } + ///@} /** @@ -114,21 +454,23 @@ abs( T const x ) /** * @return The square root of @p x. * @param x The number to get the square root of. - * @note This set of overloads is valid for any numeric type. If @p x is not a float - * it is converted to a double and the return type is double. + * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double + * and the return type is @c double. */ -LVARRAY_HOST_DEVICE inline +LVARRAY_HOST_DEVICE inline constexpr float sqrt( float const x ) -{ return ::sqrtf( x ); } +{ +#if defined(__CUDA_ARCH__) + return ::sqrtf( x ); +#else + return std::sqrt( x ); +#endif +} -/** - * @copydoc sqrt( float ) - * @tparam T An integral type. - */ +/// @copydoc sqrt( float ) template< typename T > -LVARRAY_HOST_DEVICE inline -std::enable_if_t< std::is_arithmetic< T >::value, double > -sqrt( T const x ) +LVARRAY_HOST_DEVICE inline constexpr +double sqrt( T const x ) { #if defined(__CUDA_ARCH__) return ::sqrt( double( x ) ); @@ -137,13 +479,27 @@ sqrt( T const x ) #endif } +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc sqrt( float ) +LVARRAY_DEVICE inline +__half sqrt( __half const x ) +{ return ::hsqrt( x ); } + +/// @copydoc sqrt( float ) +LVARRAY_DEVICE inline +__half2 sqrt( __half2 const x ) +{ return ::h2sqrt( x ); } + +#endif + /** * @return One over the square root of @p x. * @param x The number to get the inverse square root of. - * @note This set of overloads is valid for any numeric type. If @p x is not a float - * it is converted to a double and the return type is double. + * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double + * and the return type is double. */ -LVARRAY_HOST_DEVICE inline +LVARRAY_HOST_DEVICE inline constexpr float invSqrt( float const x ) { #if defined(__CUDA_ARCH__) @@ -153,22 +509,32 @@ float invSqrt( float const x ) #endif } -/** - * @copydoc invSqrt( float ) - * @tparam T An integral type. - */ +/// @copydoc invSqrt( float ) template< typename T > -LVARRAY_HOST_DEVICE inline -std::enable_if_t< std::is_arithmetic< T >::value, double > -invSqrt( T const x ) +LVARRAY_HOST_DEVICE inline constexpr +double invSqrt( T const x ) { -#if defined(__CUDACC__) +#if defined( __CUDA_ARCH__ ) return ::rsqrt( double( x ) ); #else return 1 / std::sqrt( x ); #endif } +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc invSqrt( float ) +LVARRAY_DEVICE inline +__half invSqrt( __half const x ) +{ return ::hrsqrt( x ); } + +/// @copydoc invSqrt( float ) +LVARRAY_DEVICE inline +__half2 invSqrt( __half2 const x ) +{ return ::h2rsqrt( x ); } + +#endif + ///@} /** @@ -179,41 +545,86 @@ invSqrt( T const x ) /** * @return The sine of @p theta. * @param theta The angle in radians. + * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double + * and the return type is double. */ -LVARRAY_HOST_DEVICE inline +LVARRAY_HOST_DEVICE inline constexpr float sin( float const theta ) -{ return ::sinf( theta ); } +{ +#if defined(__CUDA_ARCH__) + return ::sinf( theta ); +#else + return std::sin( theta ); +#endif +} /// @copydoc sin( float ) -LVARRAY_HOST_DEVICE inline -double sin( double const theta ) -{ return ::sin( theta ); } +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +double sin( T const theta ) +{ +#if defined(__CUDA_ARCH__) + return ::sin( double( theta ) ); +#else + return std::sin( theta ); +#endif +} + +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc sin( float ) +LVARRAY_DEVICE inline +__half sin( __half const theta ) +{ return ::hsin( theta ); } + +/// @copydoc sin( float ) +LVARRAY_DEVICE inline +__half2 sin( __half2 const theta ) +{ return ::h2sin( theta ); } + +#endif /** * @return The cosine of @p theta. * @param theta The angle in radians. + * @note This set of overloads is valid for any numeric type. If @p theta is not a float + * it is converted to a double and the return type is double. */ -LVARRAY_HOST_DEVICE inline +LVARRAY_HOST_DEVICE inline constexpr float cos( float const theta ) -{ return ::cosf( theta ); } +{ +#if defined(__CUDA_ARCH__) + return ::cosf( theta ); +#else + return std::cos( theta ); +#endif +} /// @copydoc cos( float ) -LVARRAY_HOST_DEVICE inline -double cos( double const theta ) -{ return ::cos( theta ); } +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +double cos( T const theta ) +{ +#if defined(__CUDA_ARCH__) + return ::cos( double( theta ) ); +#else + return std::cos( theta ); +#endif +} -/** - * @return The tangent of @p theta. - * @param theta The angle in radians. - */ -LVARRAY_HOST_DEVICE inline -float tan( float const theta ) -{ return ::tanf( theta ); } +#if defined( LVARRAY_USE_CUDA ) -/// @copydoc tan( float ) -LVARRAY_HOST_DEVICE inline -double tan( double const theta ) -{ return ::tan( theta ); } +/// @copydoc cos( float ) +LVARRAY_DEVICE inline +__half cos( __half const theta ) +{ return ::hcos( theta ); } + +/// @copydoc cos( float ) +LVARRAY_DEVICE inline +__half2 cos( __half2 const theta ) +{ return ::h2cos( theta ); } + +#endif /** * @brief Compute the sine and cosine of @p theta. @@ -221,29 +632,116 @@ double tan( double const theta ) * @param sinTheta The sine of @p theta. * @param cosTheta The cosine of @p theta. */ -LVARRAY_HOST_DEVICE inline +LVARRAY_HOST_DEVICE inline constexpr void sincos( float const theta, float & sinTheta, float & cosTheta ) { -#if defined(__CUDACC__) - ::sincosf( theta, &sinTheta, &cosTheta ); +#if defined(__CUDA_ARCH__) + ::sincos( theta, &sinTheta, &cosTheta ); #else - sinTheta = ::sin( theta ); - cosTheta = ::cos( theta ); + sinTheta = std::sin( theta ); + cosTheta = std::cos( theta ); #endif } /// @copydoc sincos( float, float &, float & ) -LVARRAY_HOST_DEVICE inline +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr void sincos( double const theta, double & sinTheta, double & cosTheta ) { -#if defined(__CUDACC__) +#if defined(__CUDA_ARCH__) ::sincos( theta, &sinTheta, &cosTheta ); #else - sinTheta = ::sin( theta ); - cosTheta = ::cos( theta ); + sinTheta = std::sin( theta ); + cosTheta = std::cos( theta ); #endif } +/// @copydoc sincos( float, float &, float & ) +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +void sincos( T const theta, double & sinTheta, double & cosTheta ) +{ +#if defined(__CUDA_ARCH__) + double s, c; + ::sincos( theta, &s, &c ); + sinTheta = s; + cosTheta = c; +#else + sinTheta = std::sin( theta ); + cosTheta = std::cos( theta ); +#endif +} + +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc sincos( float, float &, float & ) +LVARRAY_DEVICE inline +void sincos( __half const theta, __half & sinTheta, __half & cosTheta ) +{ + sinTheta = ::hsin( theta ); + cosTheta = ::hcos( theta ); +} + +/// @copydoc sincos( float, float &, float & ) +LVARRAY_DEVICE inline +void sincos( __half2 const theta, __half2 & sinTheta, __half2 & cosTheta ) +{ + sinTheta = ::h2sin( theta ); + cosTheta = ::h2cos( theta ); +} + +#endif + +/** + * @return The tangent of @p theta. + * @param theta The angle in radians. + * @note This set of overloads is valid for any numeric type. If @p theta is not a float + * it is converted to a double and the return type is double. + */ +LVARRAY_HOST_DEVICE inline constexpr +float tan( float const theta ) +{ +#if defined(__CUDA_ARCH__) + return ::tanf( theta ); +#else + return std::tan( theta ); +#endif +} + +/// @copydoc tan( float ) +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +double tan( T const theta ) +{ +#if defined(__CUDA_ARCH__) + return ::tan( double( theta ) ); +#else + return std::tan( theta ); +#endif +} + +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc tan( float ) +LVARRAY_DEVICE inline +__half tan( __half const theta ) +{ + __half s, c; + sincos( theta, s, c ); + return s / c; +} + +/// @copydoc tan( float ) +LVARRAY_DEVICE inline +__half2 tan( __half2 const theta ) +{ + __half2 s, c; + sincos( theta, s, c ); + return s / c; +} + +#endif + ///@} /** @@ -251,45 +749,310 @@ void sincos( double const theta, double & sinTheta, double & cosTheta ) */ ///@{ +namespace internal +{ + +/** + * @return The arcsine of @p x. + * @param x The value to get the arcsine of, must be in [-1, 1]. + * @details Has a max error of 1.36e-3 and max relative error of 6.95e-3 for half precision. + * The largeish relative error occurs where the algorithm transitions away from the small value approximation. + * The original algorithm didn't the small value approximation and it had huge (~3.0x) relative error, + * I believe due to the poor cancellation when subtracting from pi/2. @c acos doesn't have this problem + * and calculating @c asin as @code pi/2 - acos @endcode led to the the same error. To improve precision + * you could always add in another term in the taylor series (x^3 / 6) but I don't think it's worth it. + * @note Modified from https://developer.download.nvidia.com/cg/asin.html + */ +template< typename T > +LVARRAY_DEVICE inline constexpr +T asinImpl( T const x ) +{ + T const negate = lessThan( x, math::convert< T >( 0 ) ); + T const absX = abs( x ); + + T ret = math::convert< T >( -0.0187293 ) * absX + math::convert< T >( 0.0742610 ); + ret = ret * absX - math::convert< T >( 0.2121144 ); + ret = ret * absX + math::convert< T >( 1.5707288 ); + ret = math::convert< T >( 3.14159265358979 * 0.5 ) - ret * sqrt( math::convert< T >( 1 ) - absX ); + ret = ret - negate * ( ret + ret ); + T const smallAngle = lessThan( absX, math::convert< T >( 1.7e-1 ) ); + return smallAngle * x + ( math::convert< T >( 1 ) - smallAngle ) * ret; +} + +/** + * @return The arcsine of @p x. + * @param x The value to get the arcsine of, must be in [-1, 1]. + * @details Has a max error of 2.64e-3 and max relative error of 1.37e-3 for half precision. + * @note Modified from https://developer.download.nvidia.com/cg/acos.html + */ +template< typename T > +LVARRAY_DEVICE inline constexpr +T acosImpl( T const x ) +{ + T const negate = lessThan( x, math::convert< T >( 0 ) ); + T const absX = abs( x ); + + T ret = math::convert< T >( -0.0187293 ) * absX + math::convert< T >( 0.0742610 ); + ret = ret * absX - math::convert< T >( 0.2121144 ); + ret = ret * absX + math::convert< T >( 1.5707288 ); + ret = ret * sqrt( math::convert< T >( 1 ) - absX ); + ret = ret - negate * ( ret + ret ); + return negate * math::convert< T >( 3.14159265358979 ) + ret; +} + +/** + * @return The arctangent of the point @p x, @p y. + * @param y The y coordinate. + * @param x The x coordinate. + * @details Has a max error of 2.29e-3 and max relative error of 1.51e-3 for half precision. + * @note Modified from https://developer.download.nvidia.com/cg/atan2.html + */ +template< typename T > +LVARRAY_DEVICE inline constexpr +T atan2Impl( T const y, T const x ) +{ + T const absX = abs( x ); + T const absY = abs( y ); + T const ratio = min( absX, absY ) / max( absX, absY ); + T const ratio2 = ratio * ratio; + + T ret = math::convert< T >( -0.013480470 ) * ratio2 + math::convert< T >( 0.057477314 ); + ret = ret * ratio2 - math::convert< T >( 0.121239071 ); + ret = ret * ratio2 + math::convert< T >( 0.195635925 ); + ret = ret * ratio2 - math::convert< T >( 0.332994597 ); + ret = ret * ratio2 + math::convert< T >( 0.999995630 ); + ret = ret * ratio; + + // For single values the following works out to: + // ret = absX < absY ? 1.570796327 - ret : ret; + // ret = x < 0 ? 3.141592654 - ret : ret; + // ret = y < 0 ? -ret : ret; + ret = internal::lessThan( absX, absY ) * ( math::convert< T >( 1.570796327 ) - ret - ret ) + ret; + ret = internal::lessThan( x, math::convert< T >( 0 ) ) * ( math::convert< T >( 3.141592654 ) - ret - ret ) + ret; + ret = ret - internal::lessThan( y, math::convert< T >( 0 ) ) * ( ret + ret ); + + return ret; +} + +} // namespace internal + /** * @return The arcsine of the value @p x. * @param x The value to get the arcsine of, must be in [-1, 1]. + * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double + * and the return type is double. */ -LVARRAY_HOST_DEVICE inline +LVARRAY_HOST_DEVICE inline constexpr float asin( float const x ) -{ return ::asinf( x ); } +{ +#if defined(__CUDA_ARCH__) + return ::asinf( x ); +#else + return std::asin( x ); +#endif +} /// @copydoc asin( float ) -LVARRAY_HOST_DEVICE inline -double asin( double const x ) -{ return ::asin( x ); } +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +double asin( T const x ) +{ +#if defined(__CUDA_ARCH__) + return ::asin( double( x ) ); +#else + return std::asin( x ); +#endif +} + +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc asin( float ) +LVARRAY_DEVICE inline +__half asin( __half const x ) +{ return internal::asinImpl( x ); } + +/// @copydoc asin( float ) +LVARRAY_DEVICE inline +__half2 asin( __half2 const x ) +{ return internal::asinImpl( x ); } + +#endif /** * @return The arccosine of the value @p x. * @param x The value to get the arccosine of, must be in [-1, 1]. + * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double + * and the return type is double. */ -LVARRAY_HOST_DEVICE inline +LVARRAY_HOST_DEVICE inline constexpr float acos( float const x ) -{ return ::acosf( x ); } +{ +#if defined(__CUDA_ARCH__) + return ::acosf( x ); +#else + return std::acos( x ); +#endif +} /// @copydoc acos( float ) -LVARRAY_HOST_DEVICE inline -double acos( double const x ) -{ return ::acos( x ); } +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +double acos( T const x ) +{ +#if defined(__CUDA_ARCH__) + return ::acos( double( x ) ); +#else + return std::acos( x ); +#endif +} + +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc acos( float ) +LVARRAY_DEVICE inline +__half acos( __half const x ) +{ return internal::acosImpl( x ); } + +/// @copydoc acos( float ) +LVARRAY_DEVICE inline +__half2 acos( __half2 const x ) +{ return internal::acosImpl( x ); } + +#endif /** * @return The angle corresponding to the point (x, y). * @param y The y coordinate. * @param x The x coordinate. + * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double + * and the return type is double. */ -LVARRAY_HOST_DEVICE inline +LVARRAY_HOST_DEVICE inline constexpr float atan2( float const y, float const x ) -{ return ::atan2f( y, x ); } +{ +#if defined(__CUDA_ARCH__) + return ::atan2f( y, x ); +#else + return std::atan2( y, x ); +#endif +} /// @copydoc atan2( float, float ) -LVARRAY_HOST_DEVICE inline -double atan2( double const y, double const x ) -{ return ::atan2( y, x ); } +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +double atan2( T const y, T const x ) +{ +#if defined(__CUDA_ARCH__) + return ::atan2( double( y ), double( x ) ); +#else + return std::atan2( y, x ); +#endif +} + +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc atan2( float, float ) +LVARRAY_DEVICE inline +__half atan2( __half const y, __half const x ) +{ return internal::atan2Impl( y, x ); } + +/// @copydoc atan2( float, float ) +LVARRAY_DEVICE inline +__half2 atan2( __half2 const y, __half2 const x ) +{ return internal::atan2Impl( y, x ); } + +#endif + +///@} + +/** + * @name Exponential functions + */ +///@{ + +/** + * @return e raised to the @p x. + * @param x The power to raise e to. + * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double + * and the return type is double. + */ +LVARRAY_HOST_DEVICE inline constexpr +float exp( float const x ) +{ +#if defined(__CUDA_ARCH__) + return ::expf( x ); +#else + return std::exp( x ); +#endif +} + +/// @copydoc exp( float ) +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +double exp( T const x ) +{ +#if defined(__CUDA_ARCH__) + return ::exp( double( x ) ); +#else + return std::exp( x ); +#endif +} + +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc exp( float ) +LVARRAY_DEVICE inline +__half exp( __half const x ) +{ return ::hexp( x ); } + +/// @copydoc exp( float ) +LVARRAY_DEVICE inline +__half2 exp( __half2 const x ) +{ return ::h2exp( x ); } + +#endif + +/** + * @return The natural logarithm of @p x. + * @param x The number to get the natural logarithm of. + * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double + * and the return type is double. + */ +LVARRAY_HOST_DEVICE inline constexpr +float log( float const x ) +{ +#if defined(__CUDA_ARCH__) + return ::logf( x ); +#else + return std::log( x ); +#endif +} + +/// @copydoc log( float ) +template< typename T > +LVARRAY_HOST_DEVICE inline constexpr +double log( T const x ) +{ +#if defined(__CUDA_ARCH__) + return ::log( double( x ) ); +#else + return std::log( x ); +#endif +} + +#if defined( LVARRAY_USE_CUDA ) + +/// @copydoc log( float ) +LVARRAY_DEVICE inline +__half log( __half const x ) +{ return ::hlog( x ); } + +/// @copydoc log( float ) +LVARRAY_DEVICE inline +__half2 log( __half2 const x ) +{ return ::h2log( x ); } + +#endif ///@} diff --git a/src/output.hpp b/src/output.hpp index 10bfea78..1941ffcd 100644 --- a/src/output.hpp +++ b/src/output.hpp @@ -27,6 +27,10 @@ #include #include +#if defined( LVARRAY_USE_CUDA ) + #include +#endif + namespace LvArray { @@ -307,3 +311,28 @@ std::ostream & operator<< ( std::ostream & stream, T const ( &array )[ M ][ N ] } } // namespace LvArray + +#if defined( LVARRAY_USE_CUDA ) + +/** + * @brief Output a @c __half to a stream. + * @param stream The output stream to write to. + * @param x The value to ouput. + * @return @p stream. + */ +inline std::ostream & operator<<( std::ostream & stream, __half const x ) +{ return stream << float( x ); } + +/** + * @brief Output a @c __half2 to a stream. + * @param stream The output stream to write to. + * @param x The value to ouput. + * @return @p stream. + */ +inline std::ostream & operator<<( std::ostream & stream, __half2 const x ) +{ + float2 const c = __half22float2( x ); + return stream << c.x << ", " << c.y; +} + +#endif diff --git a/unitTests/testMath.cpp b/unitTests/testMath.cpp index 18435d6d..5405d90c 100644 --- a/unitTests/testMath.cpp +++ b/unitTests/testMath.cpp @@ -9,6 +9,7 @@ #include "math.hpp" #include "testUtils.hpp" #include "limits.hpp" +#include "output.hpp" // TPL includes #include @@ -24,49 +25,107 @@ struct TestMath : public ::testing::Test using T = typename T_POLICY_PAIR::first_type; using POLICY = typename T_POLICY_PAIR::second_type; - void maxAndMin() + void numValues() + { + constexpr int N = math::numValues< T >(); + static_assert( N == 1, "Should be one." ); + } + + void convert() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T a = 7; - T b = -55; - PORTABLE_EXPECT_EQ( math::max( a, b ), a ); - PORTABLE_EXPECT_EQ( math::min( a, b ), b ); + { + T const x = math::convert< T >( 5 ); + PORTABLE_EXPECT_EQ( x, T( 5 ) ); + } ); + } - a = 120; - b = 240; - PORTABLE_EXPECT_EQ( math::max( a, b ), b ); - PORTABLE_EXPECT_EQ( math::min( a, b ), a ); - } ); + void maxAndMin() + { + forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) + { + T a = 7; + T b = -55; + PORTABLE_EXPECT_EQ( math::max( a, b ), a ); + PORTABLE_EXPECT_EQ( math::min( a, b ), b ); + + a = 120; + b = 240; + PORTABLE_EXPECT_EQ( math::max( a, b ), b ); + PORTABLE_EXPECT_EQ( math::min( a, b ), a ); + } ); } void abs() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T a = 7; - PORTABLE_EXPECT_EQ( math::abs( a ), a ); + { + T a = 7; + PORTABLE_EXPECT_EQ( math::abs( a ), a ); + + a = -55; + PORTABLE_EXPECT_EQ( math::abs( a ), -a ); + } ); + } - a = -55; - PORTABLE_EXPECT_EQ( math::abs( a ), -a ); - } ); + void square() + { + forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) + { + PORTABLE_EXPECT_EQ( math::square( T( 3 ) ), T( 9 ) ); + } ); } void sqrtAndInvSqrt() { using FloatingPoint = decltype( math::sqrt( T() ) ); forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; + { + FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; + + T a = 5 * 5; + PORTABLE_EXPECT_EQ( math::sqrt( a ), FloatingPoint( 5.0 ) ); + PORTABLE_EXPECT_NEAR( math::invSqrt( a ), FloatingPoint( 1.0 / 5.0 ), epsilon ); + + a = 12 * 12; + PORTABLE_EXPECT_EQ( math::sqrt( a ), FloatingPoint( 12.0 ) ); + PORTABLE_EXPECT_NEAR( math::invSqrt( a ), FloatingPoint( 1.0 / 12.0 ), epsilon ); + } ); + } + + void trig() + { + using FloatingPoint = decltype( math::sin( T() ) ); + forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) + { + FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; + + PORTABLE_EXPECT_NEAR( math::sin( T( 10 ) ), FloatingPoint( ::sin( 10.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::cos( T( 10 ) ), FloatingPoint( ::cos( 10.0 ) ), epsilon ); - T a = 5 * 5; - PORTABLE_EXPECT_EQ( math::sqrt( a ), 5.0 ); - PORTABLE_EXPECT_NEAR( math::invSqrt( a ), 1.0 / 5.0, epsilon ); + FloatingPoint s, c; + math::sincos( T( 10 ), s, c ); + PORTABLE_EXPECT_NEAR( s, FloatingPoint( ::sin( 10.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( c, FloatingPoint( ::cos( 10.0 ) ), epsilon ); - a = 12 * 12; - PORTABLE_EXPECT_EQ( math::sqrt( a ), 12.0 ); - PORTABLE_EXPECT_NEAR( math::invSqrt( a ), 1.0 / 12.0, epsilon ); - } ); + PORTABLE_EXPECT_NEAR( math::tan( T( 10 ) ), FloatingPoint( ::tan( 10.0 ) ), epsilon ); + + PORTABLE_EXPECT_NEAR( math::asin( T( 1 ) ), FloatingPoint( ::asin( 1.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::acos( T( 0 ) ), FloatingPoint( ::acos( 0.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::atan2( T( 1 ), T( 2 ) ), FloatingPoint( ::atan2( 1.0, 2.0 ) ), epsilon ); + } ); + } + + void exponential() + { + using FloatingPoint = decltype( math::exp( T() ) ); + forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) + { + FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; + + PORTABLE_EXPECT_NEAR( math::exp( T( 2 ) ), FloatingPoint( ::exp( 2.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::log( T( 2 ) ), FloatingPoint( ::log( 2.0 ) ), epsilon ); + } ); } }; @@ -77,97 +136,495 @@ using TestMathTypes = ::testing::Types< , std::pair< long long int, serialPolicy > , std::pair< float, serialPolicy > , std::pair< double, serialPolicy > -#if defined(LVARRAY_USE_CUDA) +#if defined( LVARRAY_USE_CUDA ) , std::pair< int, parallelDevicePolicy< 32 > > , std::pair< long int, parallelDevicePolicy< 32 > > , std::pair< long long int, parallelDevicePolicy< 32 > > , std::pair< float, parallelDevicePolicy< 32 > > , std::pair< double, parallelDevicePolicy< 32 > > + , std::pair< __half, parallelDevicePolicy< 32 > > #endif >; TYPED_TEST_SUITE( TestMath, TestMathTypes, ); +TYPED_TEST( TestMath, numValues ) +{ this->numValues(); } + +TYPED_TEST( TestMath, convert ) +{ this->convert(); } + TYPED_TEST( TestMath, maxAndMin ) -{ - this->maxAndMin(); -} +{ this->maxAndMin(); } TYPED_TEST( TestMath, abs ) -{ - this->abs(); -} +{ this->abs(); } + +TYPED_TEST( TestMath, square ) +{ this->square(); } TYPED_TEST( TestMath, sqrtAndInvSqrt ) -{ - this->sqrtAndInvSqrt(); -} +{ this->sqrtAndInvSqrt(); } +TYPED_TEST( TestMath, trig ) +{ this->trig(); } -template< typename FLOATING_POINT_POLICY_PAIR > -struct TestMathFloatingPointOnly : public ::testing::Test +TYPED_TEST( TestMath, exponential ) +{ this->exponential(); } + + +template< typename T_POLICY_PAIR > +struct TestMath2 : public ::testing::Test { - using FloatingPoint = typename FLOATING_POINT_POLICY_PAIR::first_type; - using POLICY = typename FLOATING_POINT_POLICY_PAIR::second_type; + using T = typename T_POLICY_PAIR::first_type; + using POLICY = typename T_POLICY_PAIR::second_type; + using SingleT = math::SingleType< T >; + + void numValues() + { + constexpr int N = math::numValues< T >(); + static_assert( N == 2, "Should be two." ); + } + + void convert() + { + forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) + { + T x = math::convert< T >( 5 ); + PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 5 ) ); + PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 5 ) ); + + x = math::convert< T >( SingleT( 3 ) ); + PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 3 ) ); + PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 3 ) ); + + x = math::convert< T >( SingleT( 1 ), SingleT( 2 ) ); + PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 1 ) ); + PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 2 ) ); + + x = math::convert< T >( 5, 6 ); + PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 5 ) ); + PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 6 ) ); + + SingleT const * const xPtr = reinterpret_cast< SingleT const * >( &x ); + PORTABLE_EXPECT_EQ( xPtr[ 0 ], SingleT( 5 ) ); + PORTABLE_EXPECT_EQ( xPtr[ 1 ], SingleT( 6 ) ); + } ); + } + + void maxAndMin() + { + forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) + { + T a = math::convert< T >( -60, 10 ); + T b = math::convert< T >( 64, 13 ); + PORTABLE_EXPECT_EQ( math::max( a, b ), b ); + PORTABLE_EXPECT_EQ( math::min( a, b ), a ); + + a = math::convert< T >( 7, 100 ); + b = math::convert< T >( -55, 110 ); + PORTABLE_EXPECT_EQ( math::max( a, b ), math::convert< T >( 7, 110 ) ); + PORTABLE_EXPECT_EQ( math::min( a, b ), math::convert< T >( -55, 100 ) ); + } ); + } + + void abs() + { + forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) + { + T a = math::convert< T >( 7, 8 ); + PORTABLE_EXPECT_EQ( math::abs( a ), a ); + + a = math::convert< T >( -101, -4 ); + PORTABLE_EXPECT_EQ( math::abs( a ), -a ); + + a = math::convert< T >( 4, -8 ); + PORTABLE_EXPECT_EQ( math::abs( a ), math::convert< T >( 4, 8 ) ); + } ); + } + + void square() + { + forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) + { + T const a = math::convert< T >( 7, 8 ); + PORTABLE_EXPECT_EQ( math::square( a ), math::convert< T >( 49, 64 ) ); + } ); + } + + void sqrtAndInvSqrt() + { + forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) + { + T const epsilon = math::convert< T >( NumericLimitsNC< SingleT >{}.epsilon ); + + T a = math::convert< T >( 5 * 5, 12 * 12 ); + PORTABLE_EXPECT_EQ( math::sqrt( a ), math::convert< T >( 5.0, 12 ) ); + PORTABLE_EXPECT_NEAR( math::invSqrt( a ), math::convert< T >( 1.0 / 5.0, 1.0 / 12.0 ), epsilon ); + } ); + } void trig() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; - - FloatingPoint const coords[ 2 ][ 3 ] = { { 1, 2, 1.10714871779409050301 }, - { 4, -1, -0.24497866312686415417 } }; - - for( int i = 0; i < 2; ++i ) - { - FloatingPoint const x = coords[ i ][ 0 ]; - FloatingPoint const y = coords[ i ][ 1 ]; - FloatingPoint const theta = coords[ i ][ 2 ]; - - FloatingPoint const sinExpected = y / math::sqrt( x * x + y * y ); - FloatingPoint const cosExpected = x / math::sqrt( x * x + y * y ); - FloatingPoint const tanExpected = y / x; - - PORTABLE_EXPECT_NEAR( math::sin( theta ), sinExpected, epsilon ); - PORTABLE_EXPECT_NEAR( math::cos( theta ), cosExpected, epsilon ); - PORTABLE_EXPECT_NEAR( math::tan( theta ), tanExpected, 2.1 * epsilon ); - - FloatingPoint sinTheta; - FloatingPoint cosTheta; - math::sincos( theta, sinTheta, cosTheta ); - PORTABLE_EXPECT_NEAR( math::cos( theta ), cosTheta, epsilon ); - PORTABLE_EXPECT_NEAR( math::sin( theta ), sinTheta, epsilon ); - - PORTABLE_EXPECT_NEAR( math::abs( math::asin( sinTheta ) ), math::abs( theta ), 1.1 * epsilon ); - PORTABLE_EXPECT_NEAR( math::abs( math::acos( cosTheta ) ), math::abs( theta ), 1.1 * epsilon ); - - #if defined( __ibmxl__ ) && !defined( __CUDA_ARCH__ ) - PORTABLE_EXPECT_NEAR( math::atan2( y, x ), theta, 1.1 * epsilon ); - #else - PORTABLE_EXPECT_NEAR( math::atan2( y, x ), theta, epsilon ); - #endif - } - } ); + { + T const epsilon = math::convert< T >( NumericLimitsNC< SingleT >{}.epsilon ); + + PORTABLE_EXPECT_NEAR( math::sin( math::convert< T >( 1, 2 ) ), + math::convert< T >( ::sin( 1.0 ), ::sin( 2.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::cos( math::convert< T >( 1, 2 ) ), + math::convert< T >( ::cos( 1.0 ), ::cos( 2.0 ) ), epsilon ); + + T s, c; + math::sincos( math::convert< T >( 1, 2 ), s, c ); + PORTABLE_EXPECT_NEAR( s, math::convert< T >( ::sin( 1.0 ), ::sin( 2.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( c, math::convert< T >( ::cos( 1.0 ), ::cos( 2.0 ) ), epsilon ); + + T expected = math::convert< T >( ::tan( 1.0 ), ::tan( 2.0 ) ); + PORTABLE_EXPECT_NEAR( math::tan( math::convert< T >( 1, 2 ) ), expected, expected * epsilon ); + + PORTABLE_EXPECT_NEAR( math::asin( math::convert< T >( 0.25, 0.75) ), + math::convert< T >( ::asin( 0.25 ), ::asin( 0.75 ) ), epsilon ); + + PORTABLE_EXPECT_NEAR( math::acos( math::convert< T >( 0.25, 0.75) ), + math::convert< T >( ::acos( 0.25 ), ::acos( 0.75 ) ), epsilon ); + + PORTABLE_EXPECT_NEAR( math::atan2( math::convert< T >( 1 ), math::convert< T >( 2, -3 ) ), + math::convert< T >( ::atan2( 1.0, 2.0 ), ::atan2( 1.0, -3.0 ) ), epsilon ); + } ); + } + + void exponential() + { + forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) + { + T const epsilon = math::convert< T >( NumericLimitsNC< SingleT >{}.epsilon ); + + PORTABLE_EXPECT_NEAR( math::exp( math::convert< T >( 2, 3 ) ), math::convert< T >( 7.38905609893, 20.0855369232 ), epsilon ); + PORTABLE_EXPECT_NEAR( math::log( math::convert< T >( 2, 3 ) ), math::convert< T >( 0.69314718056, 1.09861228867 ), epsilon ); + } ); } }; -using TestMathFloatingPointOnlyTypes = ::testing::Types< - std::pair< float, serialPolicy > - , std::pair< double, serialPolicy > -#if defined(LVARRAY_USE_CUDA) - , std::pair< float, parallelDevicePolicy< 32 > > - , std::pair< double, parallelDevicePolicy< 32 > > -#endif +#if defined( LVARRAY_USE_CUDA ) + +using TestMath2Types = ::testing::Types< + std::pair< __half2, parallelDevicePolicy< 32 > > >; -TYPED_TEST_SUITE( TestMathFloatingPointOnly, TestMathFloatingPointOnlyTypes, ); +TYPED_TEST_SUITE( TestMath2, TestMath2Types, ); + +TYPED_TEST( TestMath2, numValues ) +{ this->numValues(); } + +TYPED_TEST( TestMath2, convert ) +{ this->convert(); } + +TYPED_TEST( TestMath2, maxAndMin ) +{ this->maxAndMin(); } + +TYPED_TEST( TestMath2, abs ) +{ this->abs(); } + +TYPED_TEST( TestMath2, square ) +{ this->square(); } + +TYPED_TEST( TestMath2, sqrtAndInvSqrt ) +{ this->sqrtAndInvSqrt(); } + +TYPED_TEST( TestMath2, trig ) +{ this->trig(); } + +TYPED_TEST( TestMath2, exponential ) +{ this->exponential(); } + +template< typename LAMBDA > +void forAllHalvesinMinus1to1( bool const include1, LAMBDA && lambda ) +{ + forall< parallelDevicePolicy< 32 > >( 1, [include1, lambda] LVARRAY_DEVICE ( int ) + { + __half limit( 1.0 / ( 1 << 13 ) ); + __half increment( 1.0 / ( 1 << 24 ) ); + + for( __half x( 0 ); x < __half( 1 ); limit *= 2, increment *= 2 ) + { + for( ; x < limit; x += increment ) + { + lambda( -x ); + lambda( +x ); + } + } + + if( include1 ) + { + lambda( __half( -1 ) ); + lambda( __half( +1 ) ); + } + } ); +} + +void asinHalfAccuracy() +{ + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxDiff( 0 ); + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); + + forAllHalvesinMinus1to1( true, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) + { + double const result = math::asin( x ); + double const expected = math::asin( double( x ) ); + + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = math::abs( diff / expected ); + + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } ); + + EXPECT_LT( maxDiff.get(), 1.5 * float( NumericLimitsNC< __half >{}.epsilon ) ); + EXPECT_LT( maxRDiff.get(), 8 * float( NumericLimitsNC< __half >{}.epsilon ) ); + + printf( "Max difference is %.8e\n", maxDiff.get() ); + printf( "Max relative difference is %.8e\n", maxRDiff.get() ); +} + +void asinHalf2Accuracy() +{ + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxDiff( 0 ); + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); + + forAllHalvesinMinus1to1( true, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) + { + __half2 const result = math::asin( math::convert< __half2 >( x, -x ) ); + double const expected0 = math::asin( double( x ) ); + double const expected1 = math::asin( double( -x ) ); + + { + double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); + double const rdiff0 = math::abs( diff0 / expected0 ); + maxDiff.max( diff0 ); + maxRDiff.max( rdiff0 ); + } + + { + double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); + double const rdiff1 = math::abs( diff1 / expected1 ); + maxDiff.max( diff1 ); + maxRDiff.max( rdiff1 ); + } + } ); + + EXPECT_LT( maxDiff.get(), 1.5 * float( NumericLimitsNC< __half >{}.epsilon ) ); + EXPECT_LT( maxRDiff.get(), 8 * float( NumericLimitsNC< __half >{}.epsilon ) ); + + printf( "Max difference is %.8e\n", maxDiff.get() ); + printf( "Max relative difference is %.8e\n", maxRDiff.get() ); +} + +void acosHalfAccuracy() +{ + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxDiff( 0 ); + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); + + // CUDA acos( +/-1 ) produces a NaN :( + forAllHalvesinMinus1to1( false, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) + { + double const result = math::acos( x ); + double const expected = math::acos( double( x ) ); + + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = abs( diff / expected ); + + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } ); + + EXPECT_LT( maxDiff.get(), 3 * float( NumericLimitsNC< __half >{}.epsilon ) ); + EXPECT_LT( maxRDiff.get(), 1.5 * float( NumericLimitsNC< __half >{}.epsilon ) ); -TYPED_TEST( TestMathFloatingPointOnly, trig ) + printf( "Max difference is %.8e\n", maxDiff.get() ); + printf( "Max relative difference is %.8e\n", maxRDiff.get() ); +} + +void acosHalf2Accuracy() { - this->trig(); + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxDiff( 0 ); + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); + + forAllHalvesinMinus1to1( false, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) + { + __half2 const result = math::acos( math::convert< __half2 >( x, -x ) ); + double const expected0 = math::acos( double( x ) ); + double const expected1 = math::acos( double( -x ) ); + + { + double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); + double const rdiff0 = math::abs( diff0 / expected0 ); + maxDiff.max( diff0 ); + maxRDiff.max( rdiff0 ); + } + + { + double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); + double const rdiff1 = math::abs( diff1 / expected1 ); + maxDiff.max( diff1 ); + maxRDiff.max( rdiff1 ); + } + } ); + + EXPECT_LT( maxDiff.get(), 3 * float( NumericLimitsNC< __half >{}.epsilon ) ); + EXPECT_LT( maxRDiff.get(), 1.5 * float( NumericLimitsNC< __half >{}.epsilon ) ); + + printf( "Max difference is %.8e\n", maxDiff.get() ); + printf( "Max relative difference is %.8e\n", maxRDiff.get() ); } +void atan2HalfAccuracy() +{ + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxDiff( 0 ); + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); + + forAllHalvesinMinus1to1( true, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) + { + // atan2( x, 1 ) + { + double const result = math::atan2( x, __half( 1.0 ) ); + double const expected = math::atan2( double( x ), 1.0 ); + + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = abs( diff / expected ); + + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } + + // atan2( x, -1 ) + { + double const result = math::atan2( x, __half( -1.0 ) ); + double const expected = math::atan2( double( x ), -1.0 ); + + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = abs( diff / expected ); + + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } + + // atan2( 1, x ) + { + double const result = math::atan2( __half( 1.0 ), x ); + double const expected = math::atan2( 1.0, double( x ) ); + + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = abs( diff / expected ); + + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } + + // atan2( -1, x ) + { + double const result = math::atan2( __half( -1.0 ), x ); + double const expected = math::atan2( -1.0, double( x ) ); + + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = abs( diff / expected ); + + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } + } ); + + EXPECT_LT( maxDiff.get(), 3 * float( NumericLimitsNC< __half >{}.epsilon ) ); + EXPECT_LT( maxRDiff.get(), 2 * float( NumericLimitsNC< __half >{}.epsilon ) ); + + printf( "Max difference is %.8e\n", maxDiff.get() ); + printf( "Max relative difference is %.8e\n", maxRDiff.get() ); +} + +void atan2Half2Accuracy() +{ + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxDiff( 0 ); + RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); + + forAllHalvesinMinus1to1( true, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) + { + // atan2( x, -1 ), atan2( 1, x ); + { + __half2 const result = math::atan2( math::convert< __half2 >( x, 1 ), math::convert< __half2 >( -1, x ) ); + double const expected0 = math::atan2( double( x ), -1 ); + double const expected1 = math::atan2( 1, double( x ) ); + + { + double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); + double const rdiff0 = math::abs( diff0 / expected0 ); + maxDiff.max( diff0 ); + maxRDiff.max( rdiff0 ); + } + + { + double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); + double const rdiff1 = math::abs( diff1 / expected1 ); + maxDiff.max( diff1 ); + maxRDiff.max( rdiff1 ); + } + } + + // atan2( x, 1 ), atan2( -1, x ); + { + __half2 const result = math::atan2( math::convert< __half2 >( x, -1 ), math::convert< __half2 >( 1, x ) ); + double const expected0 = math::atan2( double( x ), 1 ); + double const expected1 = math::atan2( -1, double( x ) ); + + { + double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); + double const rdiff0 = math::abs( diff0 / expected0 ); + maxDiff.max( diff0 ); + maxRDiff.max( rdiff0 ); + } + + { + double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); + double const rdiff1 = math::abs( diff1 / expected1 ); + maxDiff.max( diff1 ); + maxRDiff.max( rdiff1 ); + } + } + + } ); + + EXPECT_LT( maxDiff.get(), 3 * float( NumericLimitsNC< __half >{}.epsilon ) ); + EXPECT_LT( maxRDiff.get(), 2 * float( NumericLimitsNC< __half >{}.epsilon ) ); + + printf( "Max difference is %.8e\n", maxDiff.get() ); + printf( "Max relative difference is %.8e\n", maxRDiff.get() ); +} + +// These tests take 100x longer in debug mode. +#if defined( NDEBUG ) + +TEST( TestHalfMath, asinHalfAccuracy ) +{ asinHalfAccuracy(); } + +TEST( TestHalfMath, asinHalf2Accuracy ) +{ asinHalf2Accuracy(); } + +TEST( TestHalfMath, acosHalfAccuracy ) +{ acosHalfAccuracy(); } + +TEST( TestHalfMath, acosHalf2Accuracy ) +{ acosHalf2Accuracy(); } + +TEST( TestHalfMath, atan2HalfAccuracy ) +{ atan2HalfAccuracy(); } + +TEST( TestHalfMath, atan2Half2Accuracy ) +{ atan2Half2Accuracy(); } + +#endif + +#endif + + } // namespace testing } // namespace LvArray diff --git a/unitTests/testUtils.hpp b/unitTests/testUtils.hpp index 3885eccf..68279300 100644 --- a/unitTests/testUtils.hpp +++ b/unitTests/testUtils.hpp @@ -82,11 +82,11 @@ inline void forall( INDEX_TYPE const max, LAMBDA && body ) #ifndef __CUDA_ARCH__ #define PORTABLE_EXPECT_EQ( L, R ) EXPECT_EQ( L, R ) -#define PORTABLE_EXPECT_NEAR( L, R, EPSILON ) EXPECT_LE( math::abs( ( L ) -( R ) ), EPSILON ) << \ +#define PORTABLE_EXPECT_NEAR( L, R, EPSILON ) EXPECT_LE( math::abs( ( L ) - ( R ) ), EPSILON ) << \ STRINGIZE( L ) " = " << ( L ) << "\n" << STRINGIZE( R ) " = " << ( R ); #else #define PORTABLE_EXPECT_EQ( L, R ) LVARRAY_ERROR_IF_NE( L, R ) -#define PORTABLE_EXPECT_NEAR( L, R, EPSILON ) LVARRAY_ERROR_IF_GE_MSG( math::abs( ( L ) -( R ) ), EPSILON, \ +#define PORTABLE_EXPECT_NEAR( L, R, EPSILON ) LVARRAY_ERROR_IF_GE_MSG( math::abs( ( L ) - ( R ) ), EPSILON, \ STRINGIZE( L ) " = " << ( L ) << "\n" << STRINGIZE( R ) " = " << ( R ) ); #endif From dd8c77990847dbc48d9255e85d6e3a3c79ccf3c4 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Fri, 23 Apr 2021 11:08:30 -0700 Subject: [PATCH 04/16] Updated RAJA to 0.13.0 --- ...rkArray1DR2TensorMultiplicationKernels.cpp | 4 ++-- benchmarks/benchmarkInnerProductKernels.cpp | 4 ++-- benchmarks/benchmarkMatrixMatrixKernels.cpp | 4 ++-- benchmarks/benchmarkMatrixVectorKernels.cpp | 4 ++-- benchmarks/benchmarkOuterProductKernels.cpp | 4 ++-- benchmarks/benchmarkReduceKernels.cpp | 4 ++-- cmake/SetupTPL.cmake | 15 ++++++++++++ host-configs/LLNL/lassen-base.cmake | 1 + host-configs/LLNL/quartz-base.cmake | 1 + scripts/uberenv/packages/lvarray/package.py | 24 ++++++++++++------- scripts/uberenv/project.json | 2 +- .../blueos_3_ppc64le_ib_p9/compilers.yaml | 19 +++++++++++++-- .../toss_3_x86_64_ib/packages.yaml | 6 +++++ unitTests/testArray.hpp | 8 ++++--- unitTests/testUtils.hpp | 23 ++++++++++++++++++ 15 files changed, 96 insertions(+), 27 deletions(-) diff --git a/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.cpp b/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.cpp index 0ed82e0c..667f8f92 100644 --- a/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.cpp +++ b/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.cpp @@ -156,7 +156,7 @@ void ArrayOfR2TensorsNative< PERMUTATION >:: RAJAViewKernel( RajaView< VALUE_TYPE const, PERMUTATION > const & a, RajaView< VALUE_TYPE const, PERMUTATION > const & b, RajaView< VALUE_TYPE, PERMUTATION > const & c ) -{ KERNEL( a.layout.sizes[ 0 ], a( i, j, l ), b( i, l, k ), c( i, j, k ) ); } +{ KERNEL( getRAJAViewLayout( a ).sizes[ 0 ], a( i, j, l ), b( i, l, k ), c( i, j, k ) ); } template<> void ArrayOfR2TensorsNative< RAJA::PERM_IJK >:: @@ -245,7 +245,7 @@ void ArrayOfR2TensorsRAJA< PERMUTATION, POLICY >:: RAJAViewKernel( RajaView< VALUE_TYPE const, PERMUTATION > const & a, RajaView< VALUE_TYPE const, PERMUTATION > const & b, RajaView< VALUE_TYPE, PERMUTATION > const & c ) -{ RAJA_KERNEL( a.layout.sizes[ 0 ], a( i, j, l ), b( i, l, k ), c( i, j, k ) ); } +{ RAJA_KERNEL( getRAJAViewLayout( a ).sizes[ 0 ], a( i, j, l ), b( i, l, k ), c( i, j, k ) ); } template< typename POLICY > void pointerRajaHelper( RAJA::PERM_IJK, diff --git a/benchmarks/benchmarkInnerProductKernels.cpp b/benchmarks/benchmarkInnerProductKernels.cpp index 7a0bcf87..c7f03ce3 100644 --- a/benchmarks/benchmarkInnerProductKernels.cpp +++ b/benchmarks/benchmarkInnerProductKernels.cpp @@ -62,7 +62,7 @@ VALUE_TYPE InnerProductNative:: VALUE_TYPE InnerProductNative:: RAJAViewKernel( RajaView< VALUE_TYPE const, RAJA::PERM_I > const & a, RajaView< VALUE_TYPE const, RAJA::PERM_I > const & b ) -{ INNER_PRODUCT_KERNEL( a.layout.sizes[ 0 ], a( i ), b( i ) ); } +{ INNER_PRODUCT_KERNEL( getRAJAViewLayout( a ).sizes[ 0 ], a( i ), b( i ) ); } VALUE_TYPE InnerProductNative:: pointerKernel( INDEX_TYPE const N, @@ -98,7 +98,7 @@ template< typename POLICY > VALUE_TYPE InnerProductRAJA< POLICY >:: RAJAViewKernel( RajaView< VALUE_TYPE const, RAJA::PERM_I > const & a, RajaView< VALUE_TYPE const, RAJA::PERM_I > const & b ) -{ INNER_PRODUCT_KERNEL_RAJA( a.layout.sizes[ 0 ], a( i ), b( i ) ); } +{ INNER_PRODUCT_KERNEL_RAJA( getRAJAViewLayout( a ).sizes[ 0 ], a( i ), b( i ) ); } template< typename POLICY > VALUE_TYPE InnerProductRAJA< POLICY >:: diff --git a/benchmarks/benchmarkMatrixMatrixKernels.cpp b/benchmarks/benchmarkMatrixMatrixKernels.cpp index 505011fd..c7ec661c 100644 --- a/benchmarks/benchmarkMatrixMatrixKernels.cpp +++ b/benchmarks/benchmarkMatrixMatrixKernels.cpp @@ -90,7 +90,7 @@ void MatrixMatrixNative< PERMUTATION >:: RAJAViewKernel( RajaView< VALUE_TYPE const, PERMUTATION > const & a, RajaView< VALUE_TYPE const, PERMUTATION > const & b, RajaView< VALUE_TYPE, PERMUTATION > const & c ) -{ MATRIX_MATRIX_KERNEL( a.layout.sizes[ 0 ], a.layout.sizes[ 1 ], b.layout.sizes[ 1 ], a( i, k ), b( k, j ), c( i, j ) ); } +{ MATRIX_MATRIX_KERNEL( getRAJAViewLayout( a ).sizes[ 0 ], getRAJAViewLayout( a ).sizes[ 1 ], getRAJAViewLayout( b ).sizes[ 1 ], a( i, k ), b( k, j ), c( i, j ) ); } template<> void MatrixMatrixNative< RAJA::PERM_IJ >:: @@ -155,7 +155,7 @@ void MatrixMatrixRAJA< PERMUTATION, POLICY >:: RAJAViewKernel( RajaView< VALUE_TYPE const, PERMUTATION > const & a, RajaView< VALUE_TYPE const, PERMUTATION > const & b, RajaView< VALUE_TYPE, PERMUTATION > const & c ) -{ MATRIX_MATRIX_KERNEL_RAJA( a.layout.sizes[ 0 ], a.layout.sizes[ 1 ], b.layout.sizes[ 1 ], a( i, k ), b( k, j ), c( i, j ) ); } +{ MATRIX_MATRIX_KERNEL_RAJA( getRAJAViewLayout( a ).sizes[ 0 ], getRAJAViewLayout( a ).sizes[ 1 ], getRAJAViewLayout( b ).sizes[ 1 ], a( i, k ), b( k, j ), c( i, j ) ); } template< typename POLICY > void RAJAPointerKernelHelper( RAJA::PERM_IJ, diff --git a/benchmarks/benchmarkMatrixVectorKernels.cpp b/benchmarks/benchmarkMatrixVectorKernels.cpp index 15114dad..de118a3e 100644 --- a/benchmarks/benchmarkMatrixVectorKernels.cpp +++ b/benchmarks/benchmarkMatrixVectorKernels.cpp @@ -80,7 +80,7 @@ void MatrixVectorNative< PERMUTATION >:: RAJAViewKernel( RajaView< VALUE_TYPE const, PERMUTATION > const & a, RajaView< VALUE_TYPE const, RAJA::PERM_I > const & b, RajaView< VALUE_TYPE, RAJA::PERM_I > const & c ) -{ MATRIX_VECTOR_KERNEL( a.layout.sizes[ 0 ], a.layout.sizes[ 1 ], a( i, j ), b( j ), c( i ) ); } +{ MATRIX_VECTOR_KERNEL( getRAJAViewLayout( a ).sizes[ 0 ], getRAJAViewLayout( a ).sizes[ 1 ], a( i, j ), b( j ), c( i ) ); } template<> void MatrixVectorNative< RAJA::PERM_IJ >:: @@ -134,7 +134,7 @@ void MatrixVectorRAJA< PERMUTATION, POLICY >:: RAJAViewKernel( RajaView< VALUE_TYPE const, PERMUTATION > const & a, RajaView< VALUE_TYPE const, RAJA::PERM_I > const & b, RajaView< VALUE_TYPE, RAJA::PERM_I > const & c ) -{ MATRIX_VECTOR_KERNEL_RAJA( a.layout.sizes[ 0 ], a.layout.sizes[ 1 ], a( i, j ), b( j ), c( i ) ); } +{ MATRIX_VECTOR_KERNEL_RAJA( getRAJAViewLayout( a ).sizes[ 0 ], getRAJAViewLayout( a ).sizes[ 1 ], a( i, j ), b( j ), c( i ) ); } template< typename POLICY > diff --git a/benchmarks/benchmarkOuterProductKernels.cpp b/benchmarks/benchmarkOuterProductKernels.cpp index 7779b11d..91eab27b 100644 --- a/benchmarks/benchmarkOuterProductKernels.cpp +++ b/benchmarks/benchmarkOuterProductKernels.cpp @@ -80,7 +80,7 @@ void OuterProductNative< PERMUTATION >:: RAJAViewKernel( RajaView< VALUE_TYPE const, RAJA::PERM_I > const & a, RajaView< VALUE_TYPE const, RAJA::PERM_I > const & b, RajaView< VALUE_TYPE, PERMUTATION > const & c ) -{ OUTER_PRODUCT_KERNEL( c.layout.sizes[ 0 ], c.layout.sizes[ 1 ], a( i ), b( j ), c( i, j ) ); } +{ OUTER_PRODUCT_KERNEL( getRAJAViewLayout( c ).sizes[ 0 ], getRAJAViewLayout( c ).sizes[ 1 ], a( i ), b( j ), c( i, j ) ); } template<> void OuterProductNative< RAJA::PERM_IJ >:: @@ -133,7 +133,7 @@ void OuterProductRAJA< PERMUTATION, POLICY >:: RAJAViewKernel( RajaView< VALUE_TYPE const, RAJA::PERM_I > const & a, RajaView< VALUE_TYPE const, RAJA::PERM_I > const & b, RajaView< VALUE_TYPE, PERMUTATION > const & c ) -{ OUTER_PRODUCT_KERNEL_RAJA( c.layout.sizes[ 0 ], c.layout.sizes[ 1 ], a( i ), b( j ), c( i, j ) ); } +{ OUTER_PRODUCT_KERNEL_RAJA( getRAJAViewLayout( c ).sizes[ 0 ], getRAJAViewLayout( c ).sizes[ 1 ], a( i ), b( j ), c( i, j ) ); } template< typename POLICY > diff --git a/benchmarks/benchmarkReduceKernels.cpp b/benchmarks/benchmarkReduceKernels.cpp index 2cb18f33..a0b29b1a 100644 --- a/benchmarks/benchmarkReduceKernels.cpp +++ b/benchmarks/benchmarkReduceKernels.cpp @@ -48,7 +48,7 @@ VALUE_TYPE ReduceNative::subscriptSliceKernel( ArraySliceT< VALUE_TYPE const, RA { REDUCE_KERNEL( a.size(), a[ i ] ); } VALUE_TYPE ReduceNative::RAJAViewKernel( RajaView< VALUE_TYPE const, RAJA::PERM_I > const & a ) -{ REDUCE_KERNEL( a.layout.sizes[ 0 ], a( i ) ); } +{ REDUCE_KERNEL( getRAJAViewLayout( a ).sizes[ 0 ], a( i ) ); } VALUE_TYPE ReduceNative::pointerKernel( VALUE_TYPE const * const LVARRAY_RESTRICT a, INDEX_TYPE const N ) @@ -72,7 +72,7 @@ VALUE_TYPE ReduceRAJA< POLICY >::subscriptSliceKernel( ArraySliceT< VALUE_TYPE c template< class POLICY > VALUE_TYPE ReduceRAJA< POLICY >::RAJAViewKernel( RajaView< VALUE_TYPE const, RAJA::PERM_I > const & a ) -{ REDUCE_KERNEL_RAJA( a.layout.sizes[ 0 ], a( i ) ); } +{ REDUCE_KERNEL_RAJA( getRAJAViewLayout( a ).sizes[ 0 ], a( i ) ); } template< class POLICY > VALUE_TYPE ReduceRAJA< POLICY >::pointerKernel( VALUE_TYPE const * const LVARRAY_RESTRICT a, diff --git a/cmake/SetupTPL.cmake b/cmake/SetupTPL.cmake index 953ad344..bff94834 100644 --- a/cmake/SetupTPL.cmake +++ b/cmake/SetupTPL.cmake @@ -1,5 +1,20 @@ set(thirdPartyLibs "") +################################ +# CAMP +################################ +if(NOT EXISTS ${CAMP_DIR}) + message(FATAL_ERROR "CAMP_DIR must be defined and point to a valid directory when using CAMP.") +endif() + +message(STATUS "Using CAMP from ${CAMP_DIR}") + +find_package(camp REQUIRED PATHS ${CAMP_DIR}) + +set(ENABLE_CAMP ON CACHE BOOL "") + +set(thirdPartyLibs ${thirdPartyLibs} camp) + ################################ # RAJA ################################ diff --git a/host-configs/LLNL/lassen-base.cmake b/host-configs/LLNL/lassen-base.cmake index 19cf24c6..9948f9ae 100644 --- a/host-configs/LLNL/lassen-base.cmake +++ b/host-configs/LLNL/lassen-base.cmake @@ -2,6 +2,7 @@ set(GEOSX_TPL_ROOT_DIR /usr/gapps/GEOSX/thirdPartyLibs CACHE PATH "") set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2021-03-01/install-${CONFIG_NAME}-release CACHE PATH "") +set(CAMP_DIR ${GEOSX_TPL_DIR}/raja CACHE PATH "") set(RAJA_DIR ${GEOSX_TPL_DIR}/raja CACHE PATH "") set(ENABLE_UMPIRE ON CACHE BOOL "") diff --git a/host-configs/LLNL/quartz-base.cmake b/host-configs/LLNL/quartz-base.cmake index 600b3ebb..d17e2323 100644 --- a/host-configs/LLNL/quartz-base.cmake +++ b/host-configs/LLNL/quartz-base.cmake @@ -3,6 +3,7 @@ set(ENABLE_FORTRAN OFF CACHE BOOL "") set(GEOSX_TPL_ROOT_DIR /usr/gapps/GEOSX/thirdPartyLibs CACHE PATH "") set(GEOSX_TPL_DIR ${GEOSX_TPL_ROOT_DIR}/2021-03-01/install-${CONFIG_NAME}-release CACHE PATH "") +set(CAMP_DIR ${GEOSX_TPL_DIR}/raja CACHE PATH "") set(RAJA_DIR ${GEOSX_TPL_DIR}/raja CACHE PATH "") set(ENABLE_UMPIRE ON CACHE BOOL "") diff --git a/scripts/uberenv/packages/lvarray/package.py b/scripts/uberenv/packages/lvarray/package.py index 1c94b4d0..b8e2ff74 100644 --- a/scripts/uberenv/packages/lvarray/package.py +++ b/scripts/uberenv/packages/lvarray/package.py @@ -57,11 +57,15 @@ class Lvarray(CMakePackage, CudaPackage): depends_on('cmake@3.8:', type='build') depends_on('cmake@3.9:', when='+cuda', type='build') + depends_on('camp') + depends_on('camp+cuda', when='+cuda') + depends_on('raja') depends_on('raja+cuda', when='+cuda') + # At the moment Umpire doesn't support shared when building with CUDA. depends_on('umpire', when='+umpire') - depends_on('umpire+cuda', when='+umpire+cuda') + depends_on('umpire+cuda~shared', when='+umpire+cuda') depends_on('chai+raja', when='+chai') depends_on('chai+raja+cuda', when='+chai+cuda') @@ -231,12 +235,17 @@ def hostconfig(self, spec, prefix, py_site_pkgs_dir=None): else: cfg.write(cmake_cache_option("ENABLE_CUDA", False)) + cfg.write("#{0}\n".format("-" * 80)) + cfg.write("# CAMP\n") + cfg.write("#{0}\n\n".format("-" * 80)) + + cfg.write(cmake_cache_entry("CAMP_DIR", spec['camp'].prefix)) + cfg.write("#{0}\n".format("-" * 80)) cfg.write("# RAJA\n") cfg.write("#{0}\n\n".format("-" * 80)) - raja_dir = spec['raja'].prefix - cfg.write(cmake_cache_entry("RAJA_DIR", raja_dir)) + cfg.write(cmake_cache_entry("RAJA_DIR", spec['raja'].prefix)) cfg.write("#{0}\n".format("-" * 80)) cfg.write("# Umpire\n") @@ -244,8 +253,7 @@ def hostconfig(self, spec, prefix, py_site_pkgs_dir=None): if "+umpire" in spec: cfg.write(cmake_cache_option("ENABLE_UMPIRE", True)) - umpire_dir = spec['umpire'].prefix - cfg.write(cmake_cache_entry("UMPIRE_DIR", umpire_dir)) + cfg.write(cmake_cache_entry("UMPIRE_DIR", spec['umpire'].prefix)) else: cfg.write(cmake_cache_option("ENABLE_UMPIRE", False)) @@ -255,8 +263,7 @@ def hostconfig(self, spec, prefix, py_site_pkgs_dir=None): if "+chai" in spec: cfg.write(cmake_cache_option("ENABLE_CHAI", True)) - chai_dir = spec['chai'].prefix - cfg.write(cmake_cache_entry("CHAI_DIR", chai_dir)) + cfg.write(cmake_cache_entry("CHAI_DIR", spec['chai'].prefix)) else: cfg.write(cmake_cache_option("ENABLE_CHAI", False)) @@ -270,8 +277,7 @@ def hostconfig(self, spec, prefix, py_site_pkgs_dir=None): cfg.write("#{0}\n\n".format("-" * 80)) cfg.write(cmake_cache_option("ENABLE_CALIPER", True)) - caliper_dir = spec['caliper'].prefix - cfg.write(cmake_cache_entry("CALIPER_DIR", caliper_dir)) + cfg.write(cmake_cache_entry("CALIPER_DIR", spec['caliper'].prefix)) else: cfg.write(cmake_cache_option("ENABLE_CALIPER", False)) diff --git a/scripts/uberenv/project.json b/scripts/uberenv/project.json index 1125a54f..9822f975 100644 --- a/scripts/uberenv/project.json +++ b/scripts/uberenv/project.json @@ -4,7 +4,7 @@ "package_final_phase" : "hostconfig", "package_source_dir" : "../..", "spack_url": "https://github.com/corbett5/spack", - "spack_branch": "package/corbett/geosx", + "spack_branch": "package/corbett/lvarray-update", "spack_activate" : {}, "spack_clean_packages": ["lvarray"], "build_jobs": 100 diff --git a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/compilers.yaml b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/compilers.yaml index f1eb2562..defa2b1c 100644 --- a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/compilers.yaml +++ b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/compilers.yaml @@ -17,8 +17,23 @@ compilers: - compiler: spec: clang@10.0.1 paths: - cc: /usr/tce/packages/clang/clang-ibm-10.0.1-gcc-8.3.1/bin/clang - cxx: /usr/tce/packages/clang/clang-ibm-10.0.1-gcc-8.3.1/bin/clang++ + cc: /usr/tce/packages/clang/clang-ibm-10.0.1/bin/clang + cxx: /usr/tce/packages/clang/clang-ibm-10.0.1/bin/clang++ + f77: + fc: + flags: + cflags: -mcpu=native -mtune=native + cxxflags: -mcpu=native -mtune=native + operating_system: rhel7 + target: ppc64le + modules: [] + environment: {} + extra_rpaths: [] +- compiler: + spec: clang@11.0.0 + paths: + cc: /usr/tce/packages/clang/clang-ibm-11.0.0/bin/clang + cxx: /usr/tce/packages/clang/clang-ibm-11.0.0/bin/clang++ f77: fc: flags: diff --git a/scripts/uberenv/spack_configs/toss_3_x86_64_ib/packages.yaml b/scripts/uberenv/spack_configs/toss_3_x86_64_ib/packages.yaml index 58f69ffb..a9bc5cdc 100644 --- a/scripts/uberenv/spack_configs/toss_3_x86_64_ib/packages.yaml +++ b/scripts/uberenv/spack_configs/toss_3_x86_64_ib/packages.yaml @@ -32,3 +32,9 @@ packages: externals: - spec: flex@2.5.37 prefix: /usr/bin/ + + papi: + buildable: False + externals: + - spec: papi@5.4.3 + prefix: /usr/tce/packages/papi/papi-5.4.3 diff --git a/unitTests/testArray.hpp b/unitTests/testArray.hpp index c60bcd52..4ee9dcb8 100644 --- a/unitTests/testArray.hpp +++ b/unitTests/testArray.hpp @@ -433,11 +433,13 @@ class ArrayTest : public ::testing::Test RAJA::make_permuted_layout( dimensions, RAJA::as_array< PERMUTATION >::get() ) ); - EXPECT_EQ( array.data(), view.data ); + EXPECT_EQ( array.data(), getRAJAViewData( view ) ); + + RAJA::Layout< NDIM > const & layout = getRAJAViewLayout( view ); for( int dim = 0; dim < NDIM; ++dim ) { - EXPECT_EQ( array.size( dim ), view.layout.sizes[ dim ] ); - EXPECT_EQ( array.strides()[ dim ], view.layout.strides[ dim ] ); + EXPECT_EQ( array.size( dim ), layout.sizes[ dim ] ); + EXPECT_EQ( array.strides()[ dim ], layout.strides[ dim ] ); } compareToRAJAView( array, view ); diff --git a/unitTests/testUtils.hpp b/unitTests/testUtils.hpp index 68279300..74c24619 100644 --- a/unitTests/testUtils.hpp +++ b/unitTests/testUtils.hpp @@ -80,6 +80,29 @@ inline void forall( INDEX_TYPE const max, LAMBDA && body ) RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, max ), std::forward< LAMBDA >( body ) ); } +template< typename T, typename LAYOUT > +LVARRAY_HOST_DEVICE inline constexpr +T * getRAJAViewData( RAJA::View< T, LAYOUT > const & view ) +{ +#if RAJA_VERSION_MAJOR <= 0 && RAJA_VERSION_MINOR <= 13 + return view.data; +#else + return view.get_data(); +#endif +} + +template< typename T, typename LAYOUT > +LVARRAY_HOST_DEVICE inline constexpr +LAYOUT const & getRAJAViewLayout( RAJA::View< T, LAYOUT > const & view ) +{ +#if RAJA_VERSION_MAJOR <= 0 && RAJA_VERSION_MINOR <= 13 + return view.layout; +#else + return view.get_layout(); +#endif +} + + #ifndef __CUDA_ARCH__ #define PORTABLE_EXPECT_EQ( L, R ) EXPECT_EQ( L, R ) #define PORTABLE_EXPECT_NEAR( L, R, EPSILON ) EXPECT_LE( math::abs( ( L ) - ( R ) ), EPSILON ) << \ From d026c0f755808f4fdb1aa69486a0e34788f4b4b5 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Fri, 23 Apr 2021 11:06:43 -0700 Subject: [PATCH 05/16] Added type conversion to ArrayView. --- src/ArrayView.hpp | 64 +++++++++- src/ChaiBuffer.hpp | 12 +- src/MallocBuffer.hpp | 12 +- src/typeManipulation.hpp | 42 +++++++ unitTests/CMakeLists.txt | 1 + unitTests/testArrayView_typeConversion.cpp | 137 +++++++++++++++++++++ unitTests/testBuffers.cpp | 66 ++++++++-- unitTests/testTypeManipulation.cpp | 19 +++ 8 files changed, 328 insertions(+), 25 deletions(-) create mode 100644 unitTests/testArrayView_typeConversion.cpp diff --git a/src/ArrayView.hpp b/src/ArrayView.hpp index 77d1b54e..988ca9eb 100644 --- a/src/ArrayView.hpp +++ b/src/ArrayView.hpp @@ -130,6 +130,40 @@ class ArrayView m_singleParameterResizeIndex( source.m_singleParameterResizeIndex ) {} + /** + * @brief Construct a new ArrayView from an ArrayView with a different type. + * @tparam U The type to convert from. + * @param source The ArrayView to convert. + * @details If the size of @c T and @c U are different then either the size of @c T must be a + * multiple of the size of @c U or vice versa. If the types have different size then size of the unit stride + * dimension is changed accordingly. + * @note This is useful for converting between single values and SIMD types such as CUDA's @c __half and @c __half2. + * @code + * Array< int, 2, RAJA::PERM_IJ, std::ptrdiff_t, MallocBuffer > x( 5, 10 ); + * ArrayView< int[ 2 ], 2, 1, std::ptrdiff_t, MallocBuffer > y( x.toView() ); + * assert( y.size( 1 ) == x.size( 1 ) / 2 ); + * assert( y( 3, 4 )[ 0 ] == x( 3, 8 ) ); + * @endcode + */ + template< typename U, typename=std::enable_if_t< !std::is_same< T, U >::value > > + inline LVARRAY_HOST_DEVICE constexpr + explicit ArrayView( ArrayView< U, NDIM, USD, INDEX_TYPE, BUFFER_TYPE > const & source ): + m_dims{ source.dimsArray() }, + m_strides{ source.stridesArray() }, + m_dataBuffer{ source.dataBuffer() }, + m_singleParameterResizeIndex( source.getSingleParameterResizeIndex() ) + { + m_dims[ USD ] = typeManipulation::convertSize< T, U >( m_dims[ USD ] ); + + for( int i = 0; i < NDIM; ++i ) + { + if( i != USD ) + { + m_strides[ i ] = typeManipulation::convertSize< T, U >( m_strides[ i ] ); + } + } + } + /** * @brief Move constructor, creates a shallow copy and invalidates the source. * @param source object to move. @@ -155,7 +189,7 @@ class ArrayView * @param singleParameterResizeIndex The single parameter resize index. * @param buffer The buffer to copy construct. */ - inline LVARRAY_HOST_DEVICE constexpr + inline LVARRAY_HOST_DEVICE constexpr explicit ArrayView( typeManipulation::CArray< INDEX_TYPE, NDIM > const & dims, typeManipulation::CArray< INDEX_TYPE, NDIM > const & strides, int const singleParameterResizeIndex, @@ -357,7 +391,7 @@ class ArrayView /** * @return Return the allocated size. */ - LVARRAY_HOST_DEVICE inline + LVARRAY_HOST_DEVICE inline constexpr INDEX_TYPE size() const noexcept { #if defined( __ibmxl__ ) @@ -377,14 +411,14 @@ class ArrayView * @return Return the length of the given dimension. * @param dim The dimension to get the length of. */ - LVARRAY_HOST_DEVICE inline + LVARRAY_HOST_DEVICE inline CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE size( int const dim ) const noexcept { #ifdef LVARRAY_BOUNDS_CHECK LVARRAY_ASSERT_GE( dim, 0 ); LVARRAY_ASSERT_GT( NDIM, dim ); #endif - return m_dims[dim]; + return m_dims[ dim ]; } /** @@ -431,6 +465,13 @@ class ArrayView INDEX_TYPE const * dims() const noexcept { return m_dims.data; } + /** + * @return The CArray containing the size of each dimension. + */ + LVARRAY_HOST_DEVICE inline constexpr + typeManipulation::CArray< INDEX_TYPE, NDIM > const & dimsArray() const + { return m_dims; } + /** * @return A pointer to the array containing the stride of each dimension. */ @@ -438,6 +479,21 @@ class ArrayView INDEX_TYPE const * strides() const noexcept { return m_strides.data; } + /** + * @return The CArray containing the stride of each dimension. + */ + LVARRAY_HOST_DEVICE inline constexpr + typeManipulation::CArray< INDEX_TYPE, NDIM > const & stridesArray() const + { return m_strides; } + + /** + * @return A reference to the underlying buffer. + * @note Use with caution. + */ + LVARRAY_HOST_DEVICE inline constexpr + BUFFER_TYPE< T > const & dataBuffer() const + { return m_dataBuffer; } + ///@} /** diff --git a/src/ChaiBuffer.hpp b/src/ChaiBuffer.hpp index 665fc5c2..df826a56 100644 --- a/src/ChaiBuffer.hpp +++ b/src/ChaiBuffer.hpp @@ -226,15 +226,15 @@ class ChaiBuffer } /** - * @brief Create a copy of @p src with const T. - * @tparam _T A dummy parameter to allow enable_if, do not specify. + * @brief Create a shallow copy of @p src but with a different type. + * @tparam U The type to convert from. * @param src The buffer to copy. */ - template< typename _T=T, typename=std::enable_if_t< std::is_const< _T >::value > > + template< typename U > LVARRAY_HOST_DEVICE inline constexpr - ChaiBuffer( ChaiBuffer< std::remove_const_t< T > > const & src ): - m_pointer( src.data() ), - m_capacity( src.capacity() ), + ChaiBuffer( ChaiBuffer< U > const & src ): + m_pointer( reinterpret_cast< T * >( src.data() ) ), + m_capacity( typeManipulation::convertSize< T, U >( src.capacity() ) ), m_pointerRecord( &src.pointerRecord() ) {} diff --git a/src/MallocBuffer.hpp b/src/MallocBuffer.hpp index 240938c5..c1ec08ef 100644 --- a/src/MallocBuffer.hpp +++ b/src/MallocBuffer.hpp @@ -80,15 +80,15 @@ class MallocBuffer : public bufferManipulation::VoidBuffer } /** - * @brief Create a copy of @p src with const T. - * @tparam _T A dummy parameter to allow enable_if, do not specify. + * @brief Create a shallow copy of @p src but with a different type. + * @tparam U The type to convert from. * @param src The buffer to copy. */ - template< typename _T=T, typename=std::enable_if_t< std::is_const< _T >::value > > + template< typename U > LVARRAY_HOST_DEVICE inline constexpr - MallocBuffer( MallocBuffer< std::remove_const_t< T > > const & src ): - m_data( src.data() ), - m_capacity( src.capacity() ) + MallocBuffer( MallocBuffer< U > const & src ): + m_data( reinterpret_cast< T * >( src.data() ) ), + m_capacity( typeManipulation::convertSize< T, U >( src.capacity() ) ) {} /** diff --git a/src/typeManipulation.hpp b/src/typeManipulation.hpp index 204f8aca..b40b5ecc 100644 --- a/src/typeManipulation.hpp +++ b/src/typeManipulation.hpp @@ -442,6 +442,47 @@ constexpr bool isValidPermutation( PERMUTATION ) return internal::isValidPermutation( PERMUTATION {}, camp::make_idx_seq_t< NDIM > {} ); } +/** + * @brief Convert a number of values of type @c U to a number of values of type @c T. + * @tparam T The type to convert to. + * @tparam U The type to convert from. + * @tparam INDEX_TYPE The type of @p numU. + * @param numU The number of @c U to convert to number of @c T. + * @return @p numU converted to a number of types @p T. + * @details This is a specialization for when @code sizeof( T ) <= sizeof( U ) @endcode. + */ +template< typename T, typename U, typename INDEX_TYPE > +constexpr inline LVARRAY_HOST_DEVICE +std::enable_if_t< ( sizeof( T ) <= sizeof( U ) ), INDEX_TYPE > +convertSize( INDEX_TYPE const numU ) +{ + static_assert( sizeof( U ) % sizeof( T ) == 0, "T and U need to have compatable sizes." ); + + return numU * sizeof( U ) / sizeof( T ); +} + +/** + * @brief Convert a number of values of type @c U to a number of values of type @c T. + * @tparam T The type to convert to. + * @tparam U The type to convert from. + * @tparam INDEX_TYPE The type of @p numU. + * @param numU The number of @c U to convert to number of @c T. + * @return @p numU converted to a number of types @p T. + * @details This is a specialization for when @code sizeof( T ) > sizeof( U ) @endcode. + */ +template< typename T, typename U, typename INDEX_TYPE > +inline LVARRAY_HOST_DEVICE +std::enable_if_t< ( sizeof( T ) > sizeof( U ) ), INDEX_TYPE > +convertSize( INDEX_TYPE const numU ) +{ + static_assert( sizeof( T ) % sizeof( U ) == 0, "T and U need to have compatable sizes." ); + + INDEX_TYPE const numUPerT = sizeof( T ) / sizeof( U ); + LVARRAY_ERROR_IF_NE( numU % numUPerT, 0 ); + + return numU / numUPerT; +} + /** * @tparam T The type of values stored in the array. * @tparam N The number of values in the array. @@ -475,6 +516,7 @@ struct CArray { return N; } /// The backing c array, public so that aggregate initialization works. + // TODO(corbett5) remove {} T data[ N ] = {}; }; diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index dc9ed49d..015ee911 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -24,6 +24,7 @@ set( testSources testArrayView_toSliceConst.cpp testArrayView_toView.cpp testArrayView_toViewConst.cpp + testArrayView_typeConversion.cpp testArrayView_udcToSlice.cpp testArrayView_udcToSliceConst.cpp testArrayView_udcToViewConst.cpp diff --git a/unitTests/testArrayView_typeConversion.cpp b/unitTests/testArrayView_typeConversion.cpp new file mode 100644 index 00000000..5a9363d6 --- /dev/null +++ b/unitTests/testArrayView_typeConversion.cpp @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * All rights reserved. + * See the LICENSE file for details. + * SPDX-License-Identifier: (BSD-3-Clause) + */ + +// Source includes +#include "Array.hpp" +#include "testUtils.hpp" + +// TPL includes +#include + +namespace LvArray +{ +namespace testing +{ + +template< template< typename > class BUFFER_TYPE > +void testTypeConversion() +{ + { + Array< int, 1, RAJA::PERM_I, int, BUFFER_TYPE > array( 20 ); + ArrayView< int[ 4 ], 1, 0, int, BUFFER_TYPE > const view4( array ); + + EXPECT_EQ( view4.size(), array.size() / 4 ); + EXPECT_EQ( reinterpret_cast< int * >( view4.data() ), array.data() ); + + ArrayView< int[ 2 ], 1, 0, int, BUFFER_TYPE > const view2( view4 ); + EXPECT_EQ( view2.size(), array.size() / 2 ); + EXPECT_EQ( reinterpret_cast< int * >( view2.data() ), array.data() ); + } + + { + Array< int, 2, RAJA::PERM_IJ, int, BUFFER_TYPE > array( 10, 20 ); + ArrayView< int[ 4 ], 2, 1, int, BUFFER_TYPE > const view4( array ); + EXPECT_EQ( view4.size(), array.size() / 4 ); + EXPECT_EQ( view4.size( 0 ), array.size( 0 ) ); + EXPECT_EQ( view4.size( 1 ), array.size( 1 ) / 4 ); + + for( int i = 0; i < view4.size( 0 ); ++i ) + { + for( int j = 0; j < view4.size( 1 ); ++j ) + { + for( int k = 0; k < 4; ++k ) + { + EXPECT_EQ( &view4( i, j )[ k ], &array( i, 4 * j + k ) ); + } + } + } + + ArrayView< int[ 2 ], 2, 1, int, BUFFER_TYPE > view2( view4 ); + EXPECT_EQ( view2.size(), array.size() / 2 ); + EXPECT_EQ( view2.size( 0 ), array.size( 0 ) ); + EXPECT_EQ( view2.size( 1 ), array.size( 1 ) / 2 ); + + for( int i = 0; i < view2.size( 0 ); ++i ) + { + for( int j = 0; j < view2.size( 1 ); ++j ) + { + for( int k = 0; k < 2; ++k ) + { + EXPECT_EQ( &view2( i, j )[ k ], &array( i, 2 * j + k ) ); + } + } + } + } + + { + Array< int, 3, RAJA::PERM_KJI, int, BUFFER_TYPE > array( 8, 10, 11 ); + ArrayView< int[ 4 ], 3, 0, int, BUFFER_TYPE > const view4( array ); + EXPECT_EQ( view4.size(), array.size() / 4 ); + EXPECT_EQ( view4.size( 0 ), array.size( 0 ) / 4 ); + EXPECT_EQ( view4.size( 1 ), array.size( 1 ) ); + EXPECT_EQ( view4.size( 2 ), array.size( 2 ) ); + + for( int i = 0; i < view4.size( 0 ); ++i ) + { + for( int j = 0; j < view4.size( 1 ); ++j ) + { + for( int k = 0; k < view4.size( 2 ); ++k ) + { + for( int l = 0; l < 4; ++l ) + { + EXPECT_EQ( &view4( i, j, k )[ l ], &array( 4 * i + l, j, k ) ); + } + } + } + } + + ArrayView< int[ 2 ], 3, 0, int, BUFFER_TYPE > const view2( view4 ); + EXPECT_EQ( view2.size(), array.size() / 2 ); + EXPECT_EQ( view2.size( 0 ), array.size( 0 ) / 2 ); + EXPECT_EQ( view2.size( 1 ), array.size( 1 ) ); + EXPECT_EQ( view2.size( 2 ), array.size( 2 ) ); + + for( int i = 0; i < view2.size( 0 ); ++i ) + { + for( int j = 0; j < view2.size( 1 ); ++j ) + { + for( int k = 0; k < view2.size( 2 ); ++k ) + { + for( int l = 0; l < 2; ++l ) + { + EXPECT_EQ( &view2( i, j, k )[ l ], &array( 2 * i + l, j, k ) ); + } + } + } + } + } +} + +TEST( ArrayView, MallocBuffer_TypeConversion ) +{ + testTypeConversion< MallocBuffer >(); +} + +#if defined(LVARRAY_USE_CHAI) + +TEST( ArrayView, ChaiBuffer_TypeConversion ) +{ + testTypeConversion< ChaiBuffer >(); +} + +#endif + +} // namespace testing +} // namespace LvArray + +// This is the default gtest main method. It is included for ease of debugging. +int main( int argc, char * * argv ) +{ + ::testing::InitGoogleTest( &argc, argv ); + int const result = RUN_ALL_TESTS(); + return result; +} diff --git a/unitTests/testBuffers.cpp b/unitTests/testBuffers.cpp index 496c868f..8df5c976 100644 --- a/unitTests/testBuffers.cpp +++ b/unitTests/testBuffers.cpp @@ -157,22 +157,25 @@ TYPED_TEST( BufferAPITest, getPreviousSpace ) bufferManipulation::free( buffer, 0 ); } -template< typename > -struct ToBufferConst +template< typename, typename > +struct ToBufferT {}; -template< template< typename > class BUFFER, typename T > -struct ToBufferConst< BUFFER< T > > +template< typename T, template< typename > class BUFFER, typename U > +struct ToBufferT< T, BUFFER< U > > { - using type = BUFFER< T const >; + using type = BUFFER< T >; }; -template< typename T, int N > -struct ToBufferConst< StackBuffer< T, N > > +template< typename T, typename U, int N > +struct ToBufferT< T, StackBuffer< U, N > > { - using type = StackBuffer< T const, N >; + using type = StackBuffer< T, N >; }; +template< typename BUFFER > +using ToBufferConst = typename ToBufferT< typename BUFFER::value_type const, BUFFER >::type; + /** * @tparam BUFFER_TYPE the type of the Buffer to test. * @brief Testing class that holds a buffer, size and a std::vector to compare against. @@ -511,7 +514,7 @@ TYPED_TEST( BufferTestNoRealloc, moveAssignmentOperator ) TYPED_TEST( BufferTestNoRealloc, ConstConstructor ) { this->emplaceBack( 100 ); - typename ToBufferConst< TypeParam >::type copy( this->m_buffer ); + ToBufferConst< TypeParam > copy( this->m_buffer ); EXPECT_EQ( this->m_buffer.capacity(), copy.capacity() ); @@ -525,6 +528,7 @@ TYPED_TEST( BufferTestNoRealloc, ConstConstructor ) } COMPARE_TO_REFERENCE( copy, this->m_ref ); + COMPARE_TO_REFERENCE( this->m_buffer, this->m_ref ); } /** @@ -664,6 +668,43 @@ class BufferTestWithRealloc : public BufferTestNoRealloc< BUFFER_TYPE > COMPARE_TO_REFERENCE( m_buffer, m_ref ); } + + void typeConversion() + { + this->resize( 60 ); + + typename ToBufferT< T[ 4 ], BUFFER_TYPE >::type buffer4( m_buffer ); + EXPECT_EQ( buffer4.capacity(), m_buffer.capacity() / 4 ); + + if( BUFFER_TYPE::hasShallowCopy ) + { + EXPECT_EQ( static_cast< void * >( buffer4.data() ), static_cast< void * >( m_buffer.data() ) ); + } + + for( std::ptrdiff_t i = 0; i < size() / 4; ++i ) + { + for( std::ptrdiff_t j = 0; j < 4; ++j ) + { + EXPECT_EQ( buffer4[ i ][ j ], m_buffer[ 4 * i + j ] ); + } + } + + typename ToBufferT< T[ 2 ], BUFFER_TYPE >::type buffer2( buffer4 ); + EXPECT_EQ( buffer2.capacity(), m_buffer.capacity() / 2 ); + + if( BUFFER_TYPE::hasShallowCopy ) + { + EXPECT_EQ( static_cast< void * >( buffer2.data() ), static_cast< void * >( m_buffer.data() ) ); + } + + for( std::ptrdiff_t i = 0; i < size() / 2; ++i ) + { + for( std::ptrdiff_t j = 0; j < 2; ++j ) + { + EXPECT_EQ( buffer2[ i ][ j ], m_buffer[ 2 * i + j ] ); + } + } + } }; /// The list of types to instantiate BufferTestWithRealloc with, @@ -742,6 +783,13 @@ TYPED_TEST( BufferTestWithRealloc, combination ) this->popBack( 100 ); } +/** + * @brief Test buffer type conversion. + */ +TYPED_TEST( BufferTestWithRealloc, typeConversion ) +{ + this->typeConversion(); +} // TODO: // BufferTestNoRealloc on device with StackBuffer + MallocBuffer diff --git a/unitTests/testTypeManipulation.cpp b/unitTests/testTypeManipulation.cpp index 96d5a0bf..700dad59 100644 --- a/unitTests/testTypeManipulation.cpp +++ b/unitTests/testTypeManipulation.cpp @@ -683,5 +683,24 @@ TEST( Permutation, AsArray ) } } +TEST( typeManipulation, convertSize ) +{ + EXPECT_EQ( ( typeManipulation::convertSize< char, int >( 40 ) ), 40 * sizeof( int ) / sizeof( char ) ); + + EXPECT_DEATH_IF_SUPPORTED( ( typeManipulation::convertSize< double, int >( 41 ) ), "" ); + + EXPECT_EQ( ( typeManipulation::convertSize< float[ 2 ], float >( 10 ) ), 10 * sizeof( float ) / sizeof( float[ 2 ] ) ); + + EXPECT_EQ( ( typeManipulation::convertSize< float, float[ 2 ] >( 13 ) ), 13 * sizeof( float[ 2 ] ) / sizeof( float ) ); +} + } // namespace testing } // namespace LvArray + +// This is the default gtest main method. It is included for ease of debugging. +int main( int argc, char * * argv ) +{ + ::testing::InitGoogleTest( &argc, argv ); + int const result = RUN_ALL_TESTS(); + return result; +} From a009d3e256fa6cdbc4e608aa0271188bae6314c5 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Sun, 4 Apr 2021 14:07:53 -0700 Subject: [PATCH 06/16] Improved CUDA error macro messages. --- src/Macros.hpp | 53 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/src/Macros.hpp b/src/Macros.hpp index fa6e949c..9ae73669 100644 --- a/src/Macros.hpp +++ b/src/Macros.hpp @@ -93,26 +93,47 @@ */ #if defined(__CUDA_ARCH__) #if !defined(NDEBUG) -#define LVARRAY_ERROR_IF( EXP, MSG ) assert( !(EXP) ) + #define LVARRAY_ERROR_IF( EXP, MSG ) \ + do \ + { \ + if( EXP ) \ + { \ + assert( false && "EXP = " STRINGIZE( EXP ) "MSG = " STRINGIZE( MSG ) ); \ + } \ + } while( false ) #else -#define LVARRAY_ERROR_IF( EXP, MSG ) if( EXP ) asm ( "trap;" ) + #define LVARRAY_ERROR_IF( EXP, MSG ) \ + do \ + { \ + if( EXP ) \ + { \ + constexpr char const * formatString = "***** ERROR\n" \ + "***** LOCATION: " LOCATION "\n" \ + "***** Block: [%u, %u, %u]\n" \ + "***** Thread: [%u, %u, %u]\n" \ + "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n" \ + "***** MSG: " STRINGIZE( MSG ) "\n\n"; \ + printf( formatString, blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, threadIdx.y, threadIdx.z ); \ + asm ( "trap;" ); \ + } \ + } while( false ) #endif #else -#define LVARRAY_ERROR_IF( EXP, MSG ) \ - do \ - { \ - if( EXP ) \ + #define LVARRAY_ERROR_IF( EXP, MSG ) \ + do \ { \ - std::ostringstream __oss; \ - __oss << "***** ERROR\n"; \ - __oss << "***** LOCATION: " LOCATION "\n"; \ - __oss << "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n"; \ - __oss << MSG << "\n"; \ - __oss << LvArray::system::stackTrace( true ); \ - std::cout << __oss.str() << std::endl; \ - LvArray::system::callErrorHandler(); \ - } \ - } while( false ) + if( EXP ) \ + { \ + std::ostringstream __oss; \ + __oss << "***** ERROR\n"; \ + __oss << "***** LOCATION: " LOCATION "\n"; \ + __oss << "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n"; \ + __oss << MSG << "\n"; \ + __oss << LvArray::system::stackTrace( true ); \ + std::cout << __oss.str() << std::endl; \ + LvArray::system::callErrorHandler(); \ + } \ + } while( false ) #endif /** From c4a869900528dde85748cc1b065695f71c5bd15a Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Wed, 28 Apr 2021 01:17:39 -0700 Subject: [PATCH 07/16] Added memcpy and memset functions. --- cmake/Config.cmake | 3 +- src/ArraySlice.hpp | 17 +- src/ArrayView.hpp | 25 +- src/CMakeLists.txt | 10 +- src/CRSMatrix.hpp | 4 +- src/CRSMatrixView.hpp | 29 +- src/LvArrayConfig.hpp.in | 2 + src/arrayManipulation.hpp | 26 +- src/memcpy.hpp | 220 +++++++++++++++ src/typeManipulation.hpp | 12 + src/umpireInterface.cpp | 79 ++++++ src/umpireInterface.hpp | 61 ++++ unitTests/CMakeLists.txt | 6 +- unitTests/testArrayView.hpp | 28 ++ unitTests/testArrayView_typeConversion.cpp | 2 +- unitTests/testArrayView_zero.cpp | 30 ++ unitTests/testCRSMatrix.cpp | 28 ++ unitTests/testMemcpy.cpp | 310 +++++++++++++++++++++ unitTests/testUtils.hpp | 4 +- 19 files changed, 871 insertions(+), 25 deletions(-) create mode 100644 src/memcpy.hpp create mode 100644 src/umpireInterface.cpp create mode 100644 src/umpireInterface.hpp create mode 100644 unitTests/testArrayView_zero.cpp create mode 100644 unitTests/testMemcpy.cpp diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 36dfd081..0a44fd1b 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -1,5 +1,6 @@ # -set( PREPROCESSOR_DEFINES CHAI +set( PREPROCESSOR_DEFINES UMPIRE + CHAI CUDA TOTALVIEW_OUTPUT CALIPER ) diff --git a/src/ArraySlice.hpp b/src/ArraySlice.hpp index 2156437b..18591ad5 100644 --- a/src/ArraySlice.hpp +++ b/src/ArraySlice.hpp @@ -188,12 +188,25 @@ class ArraySlice * @param dim the dimension to get the length of. */ LVARRAY_HOST_DEVICE inline CONSTEXPR_WITHOUT_BOUNDS_CHECK - INDEX_TYPE size( int dim ) const noexcept + INDEX_TYPE size( int const dim ) const noexcept { #ifdef LVARRAY_BOUNDS_CHECK LVARRAY_ERROR_IF_GE( dim, NDIM ); #endif - return m_dims[dim]; + return m_dims[ dim ]; + } + + /** + * @return Return the stride of the given dimension. + * @param dim the dimension to get the stride of. + */ + LVARRAY_HOST_DEVICE inline CONSTEXPR_WITHOUT_BOUNDS_CHECK + INDEX_TYPE stride( int const dim ) const noexcept + { +#ifdef LVARRAY_BOUNDS_CHECK + LVARRAY_ERROR_IF_GE( dim, NDIM ); +#endif + return m_strides[ dim ]; } /** diff --git a/src/ArrayView.hpp b/src/ArrayView.hpp index 988ca9eb..a7239bd2 100644 --- a/src/ArrayView.hpp +++ b/src/ArrayView.hpp @@ -19,6 +19,7 @@ #include "limits.hpp" #include "sliceHelpers.hpp" #include "bufferManipulation.hpp" +#include "umpireInterface.hpp" // System includes #if defined(LVARRAY_USE_TOTALVIEW_OUTPUT) && !defined(__CUDA_ARCH__) @@ -601,18 +602,36 @@ class ArrayView * @brief Set all entries in the array to @p value. * @tparam POLICY The RAJA policy to use. * @param value The value to set entries to. + * @note The view is moved to and touched in the appropriate space. */ DISABLE_HD_WARNING template< typename POLICY > void setValues( T const & value ) const { auto const view = toView(); - RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, size() ), [value, view] LVARRAY_HOST_DEVICE ( INDEX_TYPE const i ) + RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, size() ), + [value, view] LVARRAY_HOST_DEVICE ( INDEX_TYPE const i ) { view.data()[ i ] = value; } ); } + /** + * @brief Use memset to set all the values in the array to 0. + * @details This is preferred over setValues< POLICY >( 0 ) for numeric types since it is much faster in most cases. + * If the buffer is allocated using Umpire then the Umpire ResouceManager is used, otherwise std::memset is used. + * @note The memset occurs in the last space the array was used in and the view is moved and touched in that space. + */ + inline void zero() const + { + #if !defined( LVARRAY_USE_UMPIRE ) + LVARRAY_ERROR_IF_NE_MSG( getPreviousSpace(), MemorySpace::CPU, "Without Umpire only host memory is supported." ); + #endif + + move( getPreviousSpace(), true ); + umpireInterface::memset( data(), 0, size() * sizeof( T ) ); + } + /** * @brief Set entries to values from another compatible ArrayView. * @tparam POLICY The RAJA policy to use. @@ -653,9 +672,7 @@ class ArrayView * @param space The memory space in which a touch will be recorded. */ void registerTouch( MemorySpace const space ) const - { - m_dataBuffer.registerTouch( space ); - } + { m_dataBuffer.registerTouch( space ); } /** * @brief Move the Array to the given execution space, optionally touching it. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 18ac086c..ad629fc0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,6 @@ set( lvarray_headers ArrayView.hpp CRSMatrix.hpp CRSMatrixView.hpp - ChaiBuffer.hpp Macros.hpp MallocBuffer.hpp SortedArray.hpp @@ -25,6 +24,7 @@ set( lvarray_headers input.hpp limits.hpp math.hpp + memcpy.hpp output.hpp sliceHelpers.hpp sortedArrayManipulation.hpp @@ -32,11 +32,15 @@ set( lvarray_headers system.hpp tensorOps.hpp totalview/tv_data_display.h - typeManipulation.hpp ) + typeManipulation.hpp + umpireInterface.hpp ) + +blt_list_append( TO lvarray_headers ELEMENTS ChaiBuffer.hpp IF ENABLE_CHAI ) set( lvarray_sources system.cpp - totalview/tv_data_display.c ) + totalview/tv_data_display.c + umpireInterface.cpp ) blt_add_library( NAME lvarray SOURCES ${lvarray_sources} diff --git a/src/CRSMatrix.hpp b/src/CRSMatrix.hpp index 1ce9eb07..7f4ae865 100644 --- a/src/CRSMatrix.hpp +++ b/src/CRSMatrix.hpp @@ -401,7 +401,7 @@ class CRSMatrix : protected CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE ///@} /** - * @name Methods that modify the entires of the matrix + * @name Methods that modify the entries of the matrix */ ///@{ @@ -414,6 +414,8 @@ class CRSMatrix : protected CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE void setValues( T const & value ) const { ParentClass::template setValues< POLICY >( value ); } + using ParentClass::zero; + /** * @copydoc ParentClass::addToRow * @note This is not brought in with a @c using statement because it breaks doxygen. diff --git a/src/CRSMatrixView.hpp b/src/CRSMatrixView.hpp index 7b8e4630..1c1a67e3 100644 --- a/src/CRSMatrixView.hpp +++ b/src/CRSMatrixView.hpp @@ -15,6 +15,7 @@ #include "SparsityPatternView.hpp" #include "arrayManipulation.hpp" #include "ArraySlice.hpp" +#include "umpireInterface.hpp" namespace LvArray { @@ -341,8 +342,7 @@ class CRSMatrixView : protected SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFE * @param value The value to set entries in the matrix to. */ template< typename POLICY > - inline - void setValues( T const & value ) const + inline void setValues( T const & value ) const { CRSMatrixView< T, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > const view = toViewConstSizes(); RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, numRows() ), @@ -356,6 +356,29 @@ class CRSMatrixView : protected SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFE } ); } + /** + * @brief Use memset to set all the values in the matrix to 0. + * @details This is preferred over setValues< POLICY >( 0 ) for numeric types since it is much faster in most cases. + * If the buffer is allocated using Umpire then the Umpire ResouceManager is used, otherwise + * std::memset is used. This zeroes out all of the memory spanned by m_entries including values that are + * part of overallocated capacity so if you have a small matrix with a huge capacity it won't be as quick as + * you might like. + * @note The memset occurs in the last space the matrix was used in and the matrix is moved and the entries are + * touched in that space. + */ + inline void zero() const + { + #if !defined( LVARRAY_USE_UMPIRE ) + LVARRAY_ERROR_IF_NE_MSG( getPreviousSpace(), MemorySpace::CPU, "Without Umpire only host memory is supported." ); + #endif + + ParentClass::move( m_entries.getPreviousSpace(), false ); + m_entries.move( m_entries.getPreviousSpace(), true ); + + INDEX_TYPE const numBytes = m_entries.capacity() * sizeof( T ); + umpireInterface::memset( m_entries.data(), 0, numBytes ); + } + /** * @brief Add to the given entries, the entries must already exist in the matrix. * The columns must be sorted. @@ -505,7 +528,7 @@ class CRSMatrixView : protected SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFE ///@{ /** - * @brief Move this SparsityPattern to the given memory space and touch the values, sizes and offsets. + * @brief Move this matrix to the given memory space and touch the values, sizes and offsets. * @param space the memory space to move to. * @param touch If true touch the values, sizes and offsets in the new space. * @note When moving to the GPU since the offsets can't be modified on device they are not touched. diff --git a/src/LvArrayConfig.hpp.in b/src/LvArrayConfig.hpp.in index b029f6f4..16e44b04 100644 --- a/src/LvArrayConfig.hpp.in +++ b/src/LvArrayConfig.hpp.in @@ -20,6 +20,8 @@ #cmakedefine LVARRAY_BOUNDS_CHECK +#cmakedefine LVARRAY_USE_UMPIRE + #cmakedefine LVARRAY_USE_CHAI #cmakedefine LVARRAY_USE_CUDA diff --git a/src/arrayManipulation.hpp b/src/arrayManipulation.hpp index b467162a..94718233 100644 --- a/src/arrayManipulation.hpp +++ b/src/arrayManipulation.hpp @@ -12,7 +12,12 @@ #pragma once +// Source includes #include "Macros.hpp" +#include "typeManipulation.hpp" + +// System includes +#include #ifdef LVARRAY_BOUNDS_CHECK @@ -148,9 +153,12 @@ void destroy( T * const LVARRAY_RESTRICT ptr, { LVARRAY_ASSERT( ptr != nullptr || size == 0 ); - for( std::ptrdiff_t i = 0; i < size; ++i ) + if( !std::is_trivially_destructible< T >::value ) { - ptr[ i ].~T(); + for( std::ptrdiff_t i = 0; i < size; ++i ) + { + ptr[ i ].~T(); + } } } @@ -284,9 +292,19 @@ void resize( T * const LVARRAY_RESTRICT ptr, destroy( ptr + newSize, size - newSize ); // Initialize things between size and newSize. - for( std::ptrdiff_t i = size; i < newSize; ++i ) + if( sizeof ... ( ARGS ) == 0 && std::is_trivially_default_constructible< T >::value ) + { + if( newSize - size > 0 ) + { + memset( reinterpret_cast< void * >( ptr + size ), 0, ( newSize - size ) * sizeof( T ) ); + } + } + else { - new ( ptr + i ) T( std::forward< ARGS >( args )... ); + for( std::ptrdiff_t i = size; i < newSize; ++i ) + { + new ( ptr + i ) T( std::forward< ARGS >( args )... ); + } } } diff --git a/src/memcpy.hpp b/src/memcpy.hpp new file mode 100644 index 00000000..fda9ea3c --- /dev/null +++ b/src/memcpy.hpp @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * All rights reserved. + * See the LICENSE file for details. + * SPDX-License-Identifier: (BSD-3-Clause) + */ + +/** + * @file memcpy.hpp + * @brief Contains the implementation of LvArray::memcpy. + */ + +#pragma once + +// Source includes +#include "ArrayView.hpp" +#include "umpireInterface.hpp" + +// System includes +#include + +namespace LvArray +{ + +namespace internal +{ + +/** + * @brief Specialization for when all the indices have been consumed. + * @return @p curSlice. + * @tparam N_LEFT The number of indices left to consume, this is a specialization for @c N_LEFT == 0. + * @tparam T The type of values in the slice. + * @tparam NDIM The number of dimensions in the slice. + * @tparam USD The unit stride dimension of the slice. + * @tparam INDEX_TYPE The index type of the slice. + * @param curSlice The slice to return. + */ +template< int N_LEFT, typename T, int NDIM, int USD, typename INDEX_TYPE > +std::enable_if_t< N_LEFT == 0, ArraySlice< T, NDIM, USD, INDEX_TYPE > > +slice( ArraySlice< T, NDIM, USD, INDEX_TYPE > const curSlice, INDEX_TYPE const *) +{ return curSlice; } + +/** + * @brief Slice @p curSlice until all of @p remainingIndices have been consumed. + * @tparam N_LEFT The number of indices left to consume. + * @tparam T The type of values in the slice. + * @tparam NDIM The number of dimensions in the slice. + * @tparam USD The unit stride dimension of the slice. + * @tparam INDEX_TYPE The index type of the slice. + * @param curSlice The ArraySlice to further slice. + * @param remainingIndices The indices used to slice @p curSlice. + * @return @code curSlice[ remainingIndices[ 0 ] ][ remainingIndices[ 1 ] ][ ... ] @endcode. + */ +template< int N_LEFT, typename T, int NDIM, int USD, typename INDEX_TYPE > +std::enable_if_t< N_LEFT != 0, ArraySlice< T, NDIM - N_LEFT, USD - N_LEFT, INDEX_TYPE > > +slice( ArraySlice< T, NDIM, USD, INDEX_TYPE > const curSlice, INDEX_TYPE const * const remainingIndices ) +{ return slice< N_LEFT - 1 >( curSlice[ remainingIndices[ 0 ] ], remainingIndices + 1 ); } + +} // namespace internal + +/** + * @brief Use memcpy to copy @p src in to @p dst. + * @tparam T The type contined by @p dst and @p src. + * @tparam NDIM The number of dimensions in @p dst and @p src. + * @tparam DST_USD The unit stride dimension of @p dst and @p src. + * @tparam DST_INDEX_TYPE The index type of @p dst. + * @tparam SRC_INDEX_TYPE The index type of @p src. + * @param dst The destination slice. + * @param src The source slice. + * @details If both @p src and @p dst were allocated with Umpire then the Umpire ResouceManager is used to perform + * the copy, otherwise std::memcpy is used. + */ +template< typename T, int NDIM, int USD, typename DST_INDEX_TYPE, typename SRC_INDEX_TYPE > +void memcpy( ArraySlice< T, NDIM, USD, DST_INDEX_TYPE > const dst, + ArraySlice< T const, NDIM, USD, SRC_INDEX_TYPE > const src ) +{ + LVARRAY_ERROR_IF_NE( dst.size(), src.size() ); + + for( int i = 0; i < NDIM; ++i ) + { + LVARRAY_ERROR_IF_NE( dst.stride( i ), src.stride( i ) ); + } + + T * const dstPointer = dst.dataIfContiguous(); + T * const srcPointer = const_cast< T * >( src.dataIfContiguous() ); + std::size_t numBytes = dst.size() * sizeof( T ); + + umpireInterface::copy( dstPointer, srcPointer, numBytes ); +} + +/** + * @brief Use memcpy to (maybe asynchronously) copy @p src in to @p dst. + * @tparam T The type contined by @p dst and @p src. + * @tparam NDIM The number of dimensions in @p dst and @p src. + * @tparam DST_USD The unit stride dimension of @p dst and @p src. + * @tparam DST_INDEX_TYPE The index type of @p dst. + * @tparam SRC_INDEX_TYPE The index type of @p src. + * @param resource The resource to use. + * @param dst The destination slice. + * @param src The source slice. + * @return An event corresponding to the copy. + * @details If both @p src and @p dst were allocated with Umpire then the Umpire ResouceManager is used to perform + * the copy, otherwise std::memcpy is used. Umpire does not currently support asynchronous copying with host + * resources, in fact it does not even support synchronous copying with host resources. As such if a @p resource + * wraps a resource of type @c camp::resouces::Host the method that doesn't take a resource is used. + */ +template< typename T, int NDIM, int USD, typename DST_INDEX_TYPE, typename SRC_INDEX_TYPE > +camp::resources::Event memcpy( camp::resources::Resource & resource, + ArraySlice< T, NDIM, USD, DST_INDEX_TYPE > const dst, + ArraySlice< T const, NDIM, USD, SRC_INDEX_TYPE > const src ) +{ + LVARRAY_ERROR_IF_NE( dst.size(), src.size() ); + + for( int i = 0; i < NDIM; ++i ) + { + LVARRAY_ERROR_IF_NE( dst.stride( i ), src.stride( i ) ); + } + + T * const dstPointer = dst.dataIfContiguous(); + T * const srcPointer = const_cast< T * >( src.dataIfContiguous() ); + std::size_t numBytes = dst.size() * sizeof( T ); + + return umpireInterface::copy( dstPointer, srcPointer, resource, numBytes ); +} + +/** + * @brief Copy the values from a slice of @p src into a slice of @p dst. + * @tparam N_DST_INDICES The number of indices used to slice @p dst. + * @tparam N_DST_INDICES The number of indices used to slice @p src. + * @tparam T The type of the values contained by @p dst and @p src. + * @tparam DST_NDIM The number of dimensions in @p dst. + * @tparam DST_USD The unit stride dimension of @p dst. + * @tparam DST_INDEX_TYPE The index type of @p dst. + * @tparam DST_BUFFER The buffer type of @p dst. + * @tparam SRC_NDIM The number of dimensions in @p src. + * @tparam SRC_USD The unit stride dimension of @p src. + * @tparam SRC_INDEX_TYPE The index type of @p src. + * @tparam SRC_BUFFER The buffer type of @p src. + * @param dst The destination array. + * @param dstIndices The indices used to slice @p dst. + * @param src The source array. + * @param srcIndices The indices used to slice @p src. + * @details The copy occurs from the current space of @p src to the current space of @p dst. + * Each array is moved to their current space. + * @code + * Array2d< T > x( 10, 10 ); + * Array1d< T > y( 10 ); + * // Set x[ 5 ][ : ] = y[ : ] + * memcpy< 1, 0 >( x, { 5 }, y, {} ); + * @endcode + */ +template< std::size_t N_DST_INDICES, std::size_t N_SRC_INDICES, typename T, int DST_NDIM, int DST_USD, + typename DST_INDEX_TYPE, template< typename > class DST_BUFFER, int SRC_NDIM, int SRC_USD, + typename SRC_INDEX_TYPE, template< typename > class SRC_BUFFER > +void memcpy( ArrayView< T, DST_NDIM, DST_USD, DST_INDEX_TYPE, DST_BUFFER > const & dst, + std::array< DST_INDEX_TYPE, N_DST_INDICES > const & dstIndices, + ArrayView< T const, SRC_NDIM, SRC_USD, SRC_INDEX_TYPE, SRC_BUFFER > const & src, + std::array< SRC_INDEX_TYPE, N_SRC_INDICES > const & srcIndices ) +{ +#if !defined( LVARRAY_USE_UMPIRE ) + LVARRAY_ERROR_IF_NE_MSG( dst.getPreviousSpace(), MemorySpace::CPU, "Without Umpire only host memory is supported." ); + LVARRAY_ERROR_IF_NE_MSG( src.getPreviousSpace(), MemorySpace::CPU, "Without Umpire only host memory is supported." ); +#endif + + dst.move( dst.getPreviousSpace(), true ); + src.move( src.getPreviousSpace(), false ); + + ArraySlice< T, DST_NDIM - N_DST_INDICES, DST_USD - N_DST_INDICES, DST_INDEX_TYPE > const dstSlice = + internal::slice< N_DST_INDICES >( dst.toSlice(), dstIndices.data() ); + + ArraySlice< T const, SRC_NDIM - N_SRC_INDICES, SRC_USD - N_SRC_INDICES, SRC_INDEX_TYPE > const srcSlice = + internal::slice< N_SRC_INDICES >( src.toSlice(), srcIndices.data() ); + + memcpy( dstSlice, srcSlice ); +} + +/** + * @brief Copy the values from a slice of @p src into a slice of @p dst using @p resource (may be asynchronous). + * @tparam N_DST_INDICES The number of indices used to slice @p dst. + * @tparam N_DST_INDICES The number of indices used to slice @p src. + * @tparam T The type of the values contained by @p dst and @p src. + * @tparam DST_NDIM The number of dimensions in @p dst. + * @tparam DST_USD The unit stride dimension of @p dst. + * @tparam DST_INDEX_TYPE The index type of @p dst. + * @tparam DST_BUFFER The buffer type of @p dst. + * @tparam SRC_NDIM The number of dimensions in @p src. + * @tparam SRC_USD The unit stride dimension of @p src. + * @tparam SRC_INDEX_TYPE The index type of @p src. + * @tparam SRC_BUFFER The buffer type of @p src. + * @param resource The resource to use. + * @param dst The destination array. + * @param dstIndices The indices used to slice @p dst. + * @param src The source array. + * @param srcIndices The indices used to slice @p src. + * @return An event corresponding to the copy. + * @details The copy occurs from the current space of @p src to the current space of @p dst. + * Each array is moved to their current space. + */ +template< std::size_t N_DST_INDICES, std::size_t N_SRC_INDICES, typename T, int DST_NDIM, int DST_USD, + typename DST_INDEX_TYPE, template< typename > class DST_BUFFER, int SRC_NDIM, int SRC_USD, + typename SRC_INDEX_TYPE, template< typename > class SRC_BUFFER > +camp::resources::Event memcpy( camp::resources::Resource & resource, + ArrayView< T, DST_NDIM, DST_USD, DST_INDEX_TYPE, DST_BUFFER > const & dst, + std::array< DST_INDEX_TYPE, N_DST_INDICES > const & dstIndices, + ArrayView< T const, SRC_NDIM, SRC_USD, SRC_INDEX_TYPE, SRC_BUFFER > const & src, + std::array< SRC_INDEX_TYPE, N_SRC_INDICES > const & srcIndices ) +{ + dst.move( dst.getPreviousSpace(), true ); + src.move( src.getPreviousSpace(), false ); + + ArraySlice< T, DST_NDIM - N_DST_INDICES, DST_USD - N_DST_INDICES, DST_INDEX_TYPE > const dstSlice = + internal::slice< N_DST_INDICES >( dst.toSlice(), dstIndices.data() ); + + ArraySlice< T const, SRC_NDIM - N_SRC_INDICES, SRC_USD - N_SRC_INDICES, SRC_INDEX_TYPE > const srcSlice = + internal::slice< N_SRC_INDICES >( src.toSlice(), srcIndices.data() ); + + return memcpy( resource, dstSlice, srcSlice ); +} + +} // namespace LvArray diff --git a/src/typeManipulation.hpp b/src/typeManipulation.hpp index b40b5ecc..c7c79957 100644 --- a/src/typeManipulation.hpp +++ b/src/typeManipulation.hpp @@ -22,6 +22,18 @@ // System includes #include #include +#include + +#if defined(__GLIBCXX__) && __GLIBCXX__ <= 20150626 +namespace std +{ + /** + * @brief This is a fix for LC's old standard library that doesn't conform to C++14. + */ + template< typename T > + using is_trivially_default_constructible = has_trivial_default_constructor< T >; +} +#endif /** * @brief Macro that expands to a static constexpr bool with one template argument diff --git a/src/umpireInterface.cpp b/src/umpireInterface.cpp new file mode 100644 index 00000000..458b4fee --- /dev/null +++ b/src/umpireInterface.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * All rights reserved. + * See the LICENSE file for details. + * SPDX-License-Identifier: (BSD-3-Clause) + */ + +// Source includes +#include "LvArrayConfig.hpp" +#include "umpireInterface.hpp" + +// TPL includes +#if defined( LVARRAY_USE_UMPIRE ) +#include +#endif + +// System includes +#include + +namespace LvArray +{ + +namespace umpireInterface +{ + +void copy( void * const dstPointer, void * const srcPointer, std::size_t const size ) +{ +#if defined( LVARRAY_USE_UMPIRE ) + umpire::ResourceManager & rm = umpire::ResourceManager::getInstance(); + if( rm.hasAllocator( dstPointer ) && rm.hasAllocator( srcPointer ) ) + { + rm.copy( dstPointer, srcPointer, size ); + return; + } +#endif + + std::memcpy( dstPointer, srcPointer, size ); +} + +camp::resources::Event copy( void * const dstPointer, void * const srcPointer, + camp::resources::Resource & resource, std::size_t const size ) +{ +#if defined( LVARRAY_USE_UMPIRE ) + umpire::ResourceManager & rm = umpire::ResourceManager::getInstance(); + + bool const allocatedByUmpire = rm.hasAllocator( dstPointer ) && rm.hasAllocator( srcPointer ); + + // Umpire breaks if you supply a host resource. + if( allocatedByUmpire && resource.try_get< camp::resources::Host >() ) + { + rm.copy( dstPointer, srcPointer, size ); + return resource.get_event(); + } + + if( allocatedByUmpire ) + { + return rm.copy( dstPointer, srcPointer, resource, size ); + } +#endif + + std::memcpy( dstPointer, srcPointer, size ); + return resource.get_event(); +} + +void memset( void * const dstPointer, int const val, std::size_t const size ) +{ +#if defined( LVARRAY_USE_UMPIRE ) + umpire::ResourceManager & rm = umpire::ResourceManager::getInstance(); + if( rm.hasAllocator( dstPointer ) ) + { + return rm.memset( dstPointer, val, size ); + } +#endif + + std::memset( dstPointer, val, size ); +} + +} // namespace umpireInterface +} // namespace LvArray diff --git a/src/umpireInterface.hpp b/src/umpireInterface.hpp new file mode 100644 index 00000000..88769308 --- /dev/null +++ b/src/umpireInterface.hpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * All rights reserved. + * See the LICENSE file for details. + * SPDX-License-Identifier: (BSD-3-Clause) + */ + +/** + * @file umpireInterface.hpp + * @brief Contains the LvArray umpire interface. This is only used to keep umpire/ResourceManager.hpp + * out of the includes for most headers. + */ + +#pragma once + +// TPL includes +#include + +namespace LvArray +{ + +namespace umpireInterface +{ + +/** + * @brief Use memcpy to copy @p srcPointer in to @p dstPointer. + * @param dstPointer The destination pointer. + * @param srcPointer The source pointer. + * @param size The number of bytes to copy. + * @details If both @p src and @p dst were allocated with Umpire then the Umpire ResouceManager is used to perform + * the copy, otherwise std::memcpy is used. + */ +void copy( void * const dstPointer, void * const srcPointer, std::size_t const size ); + +/** + * @brief Use memcpy to (maybe asynchronously) copy @p src in to @p dst. + * @param dstPointer The destination slice. + * @param srcPointer The source slice. + * @param resource The resource to use. + * @param size The number of bytes to copy. + * @return The event corresponding to the copy. + * @details If both @p src and @p dst were allocated with Umpire then the Umpire ResouceManager is used to perform + * the copy, otherwise std::memcpy is used. Umpire does not currently support asynchronous copying with host + * resources, in fact it does not even support synchronous copying with host resources. As such if a @p resource + * wraps a resource of type @c camp::resouces::Host the method that doesn't take a resource is used. + */ +camp::resources::Event copy( void * const dstPointer, void * const srcPointer, + camp::resources::Resource & resource, std::size_t const size ); + +/** + * @brief Use memset to set the bytes of @p dstPointer. + * @param dstPointer The destination pointer. + * @param val The value (converted to a char) to set. + * @param size The number of bytes to set. + * @details If both @p src and @p dst were allocated with Umpire then the Umpire ResouceManager is used to perform + * the memset, otherwise std::memcpy is used. + */ +void memset( void * const dstPointer, int const val, std::size_t const size ); + +} // namespace umpireInterface +} // namespace LvArray diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 015ee911..91971b13 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -28,6 +28,7 @@ set( testSources testArrayView_udcToSlice.cpp testArrayView_udcToSliceConst.cpp testArrayView_udcToViewConst.cpp + testArrayView_zero.cpp testArray_clear.cpp testArray_copyAssignmentOperator.cpp testArray_copyConstructor.cpp @@ -52,6 +53,7 @@ set( testSources testInput.cpp testIntegerConversion.cpp testMath.cpp + testMemcpy.cpp testSliceHelpers.cpp testSortedArray.cpp testSortedArrayManipulation.cpp @@ -69,9 +71,7 @@ set( testSources testInvalidOperations.cpp ) -if( ENABLE_CHAI ) - set( testSources ${testSources} testChaiBuffer.cpp testArray_ChaiBuffer.cpp ) -endif() +blt_list_append( TO testSources ELEMENTS testChaiBuffer.cpp testArray_ChaiBuffer.cpp IF ENABLE_CHAI ) # # Add gtest C++ based tests diff --git a/unitTests/testArrayView.hpp b/unitTests/testArrayView.hpp index bb340ffd..bd770f65 100644 --- a/unitTests/testArrayView.hpp +++ b/unitTests/testArrayView.hpp @@ -448,6 +448,34 @@ class ArrayViewPolicyTest : public ArrayViewTest< typename ARRAY_POLICY_PAIR::fi { EXPECT_EQ( array->size( dim ), sizes[ dim ] ); } } + static void zero() + { + std::unique_ptr< ARRAY > array = ParentClass::sizedConstructor(); + + INDEX_TYPE totalSize = 1; + std::array< INDEX_TYPE, NDIM > sizes; + for( int dim = 0; dim < NDIM; ++dim ) + { + sizes[ dim ] = array->size( dim ); + totalSize *= array->size( dim ); + } + + array->move( RAJAHelper< POLICY >::space ); + array->zero(); + + ViewTypeConst const view = array->toViewConst(); + forall< POLICY >( array->size(), [view] LVARRAY_HOST_DEVICE ( INDEX_TYPE const i ) + { + PORTABLE_EXPECT_EQ( view.data()[ i ], T{} ); + } ); + + EXPECT_EQ( array->size(), totalSize ); + EXPECT_EQ( array->capacity(), totalSize ); + + for( int dim = 0; dim < NDIM; ++dim ) + { EXPECT_EQ( array->size( dim ), sizes[ dim ] ); } + } + static void setValuesFromView() { ARRAY array; diff --git a/unitTests/testArrayView_typeConversion.cpp b/unitTests/testArrayView_typeConversion.cpp index 5a9363d6..4afc89dd 100644 --- a/unitTests/testArrayView_typeConversion.cpp +++ b/unitTests/testArrayView_typeConversion.cpp @@ -109,7 +109,7 @@ void testTypeConversion() } } } -} +}; TEST( ArrayView, MallocBuffer_TypeConversion ) { diff --git a/unitTests/testArrayView_zero.cpp b/unitTests/testArrayView_zero.cpp new file mode 100644 index 00000000..2a283671 --- /dev/null +++ b/unitTests/testArrayView_zero.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * All rights reserved. + * See the LICENSE file for details. + * SPDX-License-Identifier: (BSD-3-Clause) + */ + +// Source includes +#include "testArrayView.hpp" + +namespace LvArray +{ +namespace testing +{ + +TYPED_TEST( ArrayViewPolicyTest, zero ) +{ + this->zero(); +} + +} // namespace testing +} // namespace LvArray + +// This is the default gtest main method. It is included for ease of debugging. +int main( int argc, char * * argv ) +{ + ::testing::InitGoogleTest( &argc, argv ); + int const result = RUN_ALL_TESTS(); + return result; +} diff --git a/unitTests/testCRSMatrix.cpp b/unitTests/testCRSMatrix.cpp index 1365ac32..3792352e 100644 --- a/unitTests/testCRSMatrix.cpp +++ b/unitTests/testCRSMatrix.cpp @@ -771,6 +771,27 @@ class CRSMatrixViewTest : public CRSMatrixTest< typename CRS_MATRIX_POLICY_PAIR: COMPARE_TO_REFERENCE } + void zero() + { + // Kind of a hack, this shouldn't be tested with TestString. + if( std::is_same< T, TestString >::value ) + { return; } + + m_matrix.move( RAJAHelper< POLICY >::space ); + this->m_matrix.zero(); + + for( auto & row : this->m_ref ) + { + for( auto & kvPair : row ) + { + kvPair.second = T{}; + } + } + + this->m_matrix.move( MemorySpace::CPU ); + COMPARE_TO_REFERENCE + } + /** * @brief Test the CRSMatrixView insert methods. * @param [in] maxInserts the maximum number of inserts. @@ -1058,6 +1079,13 @@ TYPED_TEST( CRSMatrixViewTest, setValues ) this->setValues(); } +TYPED_TEST( CRSMatrixViewTest, zero ) +{ + this->resize( DEFAULT_NROWS, DEFAULT_NCOLS ); + this->insert( DEFAULT_MAX_INSERTS ); + this->zero(); +} + TYPED_TEST( CRSMatrixViewTest, insert ) { this->resize( DEFAULT_NROWS, DEFAULT_NCOLS ); diff --git a/unitTests/testMemcpy.cpp b/unitTests/testMemcpy.cpp new file mode 100644 index 00000000..9e83ff2c --- /dev/null +++ b/unitTests/testMemcpy.cpp @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * All rights reserved. + * See the LICENSE file for details. + * SPDX-License-Identifier: (BSD-3-Clause) + */ + +// Source includes +#include "Array.hpp" +#include "memcpy.hpp" +#include "testUtils.hpp" + +// TPL includes +#include + +namespace LvArray +{ +namespace testing +{ + +template< template< typename > class BUFFER_TYPE > +void testMemcpy1D() +{ + Array< int, 1, RAJA::PERM_I, std::ptrdiff_t, BUFFER_TYPE > x( 100 ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + x[ i ] = i; + } + + Array< int, 1, RAJA::PERM_I, std::ptrdiff_t, BUFFER_TYPE > y( x.size() ); + + memcpy( y.toSlice(), x.toSliceConst() ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + EXPECT_EQ( x[ i ], y[ i ] ); + } + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + x[ i ] = 2 * i; + } + + memcpy< 0, 0 >( y, {}, x.toViewConst(), {} ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + EXPECT_EQ( x[ i ], y[ i ] ); + } +} + +template< template< typename > class BUFFER_TYPE > +void testAsyncMemcpy1D() +{ + camp::resources::Resource host{ camp::resources::Host{} }; + + Array< int, 1, RAJA::PERM_I, std::ptrdiff_t, BUFFER_TYPE > x( 100 ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + x[ i ] = i; + } + + Array< int, 1, RAJA::PERM_I, std::ptrdiff_t, BUFFER_TYPE > y( x.size() ); + + camp::resources::Event e = memcpy( host, y.toSlice(), x.toSliceConst() ); + host.wait_for( &e ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + EXPECT_EQ( x[ i ], y[ i ] ); + } + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + x[ i ] = 2 * i; + } + + e = memcpy< 0, 0 >( host, y, {}, x.toViewConst(), {} ); + host.wait_for( &e ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + EXPECT_EQ( x[ i ], y[ i ] ); + } +} + +template< template< typename > class BUFFER_TYPE > +void testMemcpy2D() +{ + Array< int, 2, RAJA::PERM_IJ, std::ptrdiff_t, BUFFER_TYPE > x( 2, 10 ); + + for( std::ptrdiff_t i = 0; i < x.size( 0 ); ++i ) + { + for( std::ptrdiff_t j = 0; j < x.size( 1 ); ++j ) + { + x( i, j ) = 4 * i + j; + } + } + + Array< int, 2, RAJA::PERM_IJ, std::ptrdiff_t, BUFFER_TYPE > y( x.size( 0 ), x.size( 1 ) ); + + memcpy( y[ 0 ], x[ 1 ].toSliceConst() ); + memcpy( y[ 1 ], x[ 0 ].toSliceConst() ); + + for( std::ptrdiff_t i = 0; i < x.size( 0 ); ++i ) + { + for( std::ptrdiff_t j = 0; j < x.size( 1 ); ++j ) + { + EXPECT_EQ( x( i, j ), y( 1 - i, j ) ); + } + } + + memcpy< 1, 1 >( y, { 1 }, x.toViewConst(), { 1 } ); + + for( std::ptrdiff_t i = 0; i < x.size( 0 ); ++i ) + { + for( std::ptrdiff_t j = 0; j < x.size( 1 ); ++j ) + { + EXPECT_EQ( x( 1, j ), y( i, j ) ); + } + } + + memcpy< 0, 0 >( y, {}, x.toViewConst(), {} ); + + for( std::ptrdiff_t i = 0; i < x.size( 0 ); ++i ) + { + for( std::ptrdiff_t j = 0; j < x.size( 1 ); ++j ) + { + EXPECT_EQ( x( i, j ), y( i, j ) ); + } + } +} + +template< template< typename > class BUFFER_TYPE > +void testInvalidMemcpy() +{ + Array< int, 2, RAJA::PERM_IJ, std::ptrdiff_t, BUFFER_TYPE > x( 6, 7 ); + Array< int, 2, RAJA::PERM_IJ, std::ptrdiff_t, BUFFER_TYPE > y( 4, 3 ); + + EXPECT_DEATH_IF_SUPPORTED( memcpy( x.toSlice(), y.toSliceConst() ), "" ); +} + +#if defined( LVARRAY_USE_CUDA ) + +template< template< typename > class BUFFER_TYPE > +void testMemcpyDevice() +{ + Array< int, 1, RAJA::PERM_I, std::ptrdiff_t, BUFFER_TYPE > x( 100 ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + x[ i ] = i; + } + + Array< int, 1, RAJA::PERM_I, std::ptrdiff_t, BUFFER_TYPE > y( x.size() ); + y.move( MemorySpace::GPU ); + int * yPtr = y.data(); + + memcpy< 0, 0 >( y, {}, x.toViewConst(), {} ); + + forall< RAJA::cuda_exec< 32 > >( y.size(), [yPtr] LVARRAY_DEVICE ( std::ptrdiff_t const i ) + { + PORTABLE_EXPECT_EQ( yPtr[ i ], i ); + yPtr[ i ] *= 2; + } ); + + memcpy< 0, 0 >( x, {}, y.toViewConst(), {} ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + EXPECT_EQ( x[ i ], 2 * i ); + } + + // Move y to the CPU but then capture and modify a view on device. This way y's data pointer is still pointing + // to host memory but the subsequent memcpy should pick up that it's previous space is on device. + y.move( MemorySpace::CPU ); + + ArrayView< int, 1, 0, std::ptrdiff_t, BUFFER_TYPE > const yView = y.toView(); + forall< RAJA::cuda_exec< 32 > >( y.size(), [yView] LVARRAY_DEVICE ( std::ptrdiff_t const i ) + { + yView[ i ] = -i; + } ); + + memcpy< 0, 0 >( x, {}, y.toViewConst(), {} ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + EXPECT_EQ( x[ i ], -i ); + } +} + +template< template< typename > class BUFFER_TYPE > +void testAsyncMemcpyDevice() +{ + camp::resources::Resource stream{ camp::resources::Cuda{} }; + + Array< int, 1, RAJA::PERM_I, std::ptrdiff_t, BUFFER_TYPE > x( 100 ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + x[ i ] = i; + } + + Array< int, 1, RAJA::PERM_I, std::ptrdiff_t, BUFFER_TYPE > y( x.size() ); + y.move( MemorySpace::GPU ); + int * yPtr = y.data(); + + camp::resources::Event e = memcpy< 0, 0 >( stream, y.toView(), {}, x.toViewConst(), {} ); + stream.wait_for( &e ); + + forall< RAJA::cuda_exec< 32 > >( y.size(), [yPtr] LVARRAY_DEVICE ( std::ptrdiff_t const i ) + { + PORTABLE_EXPECT_EQ( yPtr[ i ], i ); + yPtr[ i ] *= 2; + } ); + + e = memcpy< 0, 0 >( stream, x, {}, y.toViewConst(), {} ); + stream.wait_for( &e ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + EXPECT_EQ( x[ i ], 2 * i ); + } + + // Move y to the CPU but then capture and modify a view on device. This way y's data pointer is still pointing + // to host memory but the subsequent memcpy should pick up that it's previous space is on device. + y.move( MemorySpace::CPU ); + + ArrayView< int, 1, 0, std::ptrdiff_t, BUFFER_TYPE > const yView = y.toView(); + forall< RAJA::cuda_exec< 32 > >( y.size(), [yView] LVARRAY_DEVICE ( std::ptrdiff_t const i ) + { + yView[ i ] = -i; + } ); + + e = memcpy< 0, 0 >( stream, x, {}, y.toViewConst(), {} ); + stream.wait_for( &e ); + + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) + { + EXPECT_EQ( x[ i ], -i ); + } +} + +#endif + +TEST( TestMemcpy, MallocBuffer1D ) +{ + testMemcpy1D< MallocBuffer >(); +} + +TEST( TestMemcpy, AsyncMallocBuffer1D ) +{ + testAsyncMemcpy1D< MallocBuffer >(); +} + +TEST( TestMemcpy, MallocBuffer2D ) +{ + testMemcpy2D< MallocBuffer >(); +} + +TEST( TestMemcpy, Invalid ) +{ + testInvalidMemcpy< MallocBuffer >(); +} + +#if defined(LVARRAY_USE_CHAI) + +TEST( TestMemcpy, ChaiBuffer1D ) +{ + testMemcpy1D< ChaiBuffer >(); +} + +TEST( TestMemcpy, AsyncChaiBuffer1D ) +{ + testAsyncMemcpy1D< ChaiBuffer >(); +} + +TEST( TestMemcpy, ChaiBuffer2D ) +{ + testMemcpy2D< ChaiBuffer >(); +} + +#if defined( LVARRAY_USE_CUDA ) + +TEST( TestMemcpy, ChaiBufferDevice ) +{ + testMemcpyDevice< ChaiBuffer >(); +} + +TEST( TestMemcpy, AsyncChaiBufferDevice ) +{ + testAsyncMemcpyDevice< ChaiBuffer >(); +} + +#endif + +#endif + +} // namespace testing +} // namespace LvArray + +// This is the default gtest main method. It is included for ease of debugging. +int main( int argc, char * * argv ) +{ + ::testing::InitGoogleTest( &argc, argv ); + int const result = RUN_ALL_TESTS(); + return result; +} diff --git a/unitTests/testUtils.hpp b/unitTests/testUtils.hpp index 74c24619..79b9aa52 100644 --- a/unitTests/testUtils.hpp +++ b/unitTests/testUtils.hpp @@ -218,9 +218,7 @@ class TestString */ struct Tensor { - LVARRAY_HOST_DEVICE Tensor(): - Tensor( 0 ) - {} + Tensor() = default; template< class T > LVARRAY_HOST_DEVICE explicit Tensor( T val ): From 218b8d11bd02601a72af82f6fdb81a1f3a69a04e Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Wed, 28 Apr 2021 01:39:44 -0700 Subject: [PATCH 08/16] Use camp Platform for MemorySpace. --- ...rkArray1DR2TensorMultiplicationKernels.hpp | 2 +- benchmarks/benchmarkMatrixMatrixKernels.hpp | 2 +- .../benchmarkSparsityGenerationKernels.hpp | 6 +- docs/sphinx/ArrayOfArrays.rst | 2 +- docs/sphinx/ArrayOfSets.rst | 2 +- docs/sphinx/SortedArray.rst | 2 +- docs/sphinx/SparsityPatternAndCRSMatrix.rst | 2 +- docs/sphinx/bufferClasses.rst | 2 +- examples/exampleArray.cpp | 6 +- examples/exampleArrayOfArrays.cpp | 2 +- examples/exampleBuffers.cpp | 18 +++--- examples/exampleSortedArray.cpp | 2 +- src/Array.hpp | 6 +- src/ArrayOfArraysView.hpp | 24 ++++---- src/ArrayView.hpp | 2 +- src/CRSMatrix.hpp | 2 +- src/CRSMatrixView.hpp | 2 +- src/ChaiBuffer.hpp | 22 +++---- src/MallocBuffer.hpp | 2 +- src/SortedArray.hpp | 2 +- src/SortedArrayView.hpp | 2 +- src/bufferManipulation.hpp | 59 +++++++++---------- src/memcpy.hpp | 4 +- src/python/PyArray.cpp | 4 +- src/python/PyCRSMatrix.cpp | 4 +- src/python/PySortedArray.cpp | 7 ++- src/python/python.cpp | 4 +- unitTests/testArray1DOfArray1D.cpp | 6 +- unitTests/testArray1DOfArray1DOfArray1D.cpp | 4 +- unitTests/testArrayOfArrays.cpp | 16 ++--- unitTests/testArrayOfSets.cpp | 10 ++-- unitTests/testArrayView.hpp | 12 ++-- unitTests/testArray_ChaiBuffer.cpp | 12 ++-- unitTests/testBuffers.cpp | 18 +++--- unitTests/testCRSMatrix.cpp | 16 ++--- unitTests/testChaiBuffer.cpp | 50 ++++++++-------- unitTests/testMemcpy.cpp | 8 +-- unitTests/testSortedArray.cpp | 2 +- unitTests/testSortedArrayManipulation.cpp | 10 ++-- unitTests/testSparsityPattern.cpp | 14 ++--- unitTests/testTensorOpsEigen.cpp | 2 +- unitTests/testUtils.hpp | 6 +- 42 files changed, 192 insertions(+), 188 deletions(-) diff --git a/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.hpp b/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.hpp index ee8a920a..d5beaaaa 100644 --- a/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.hpp +++ b/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.hpp @@ -240,7 +240,7 @@ class ArrayOfR2TensorsRAJA : private ArrayOfR2TensorsNative< PERMUTATION > } ~ArrayOfR2TensorsRAJA() - { this->m_c.move( MemorySpace::CPU ); } + { this->m_c.move( MemorySpace::host ); } void fortranView() const { diff --git a/benchmarks/benchmarkMatrixMatrixKernels.hpp b/benchmarks/benchmarkMatrixMatrixKernels.hpp index 136d5de9..14a01f95 100644 --- a/benchmarks/benchmarkMatrixMatrixKernels.hpp +++ b/benchmarks/benchmarkMatrixMatrixKernels.hpp @@ -170,7 +170,7 @@ class MatrixMatrixRAJA : public MatrixMatrixNative< PERMUTATION > } ~MatrixMatrixRAJA() - { this->m_c.move( MemorySpace::CPU, false ); } + { this->m_c.move( MemorySpace::host, false ); } void fortranView() const { diff --git a/benchmarks/benchmarkSparsityGenerationKernels.hpp b/benchmarks/benchmarkSparsityGenerationKernels.hpp index d9935dfb..272dd8a2 100644 --- a/benchmarks/benchmarkSparsityGenerationKernels.hpp +++ b/benchmarks/benchmarkSparsityGenerationKernels.hpp @@ -115,7 +115,7 @@ class SparsityGenerationNative INDEX_TYPE const nodeKp = nodeJp * ( m_numElemsY + 1 ); /// Iterate over all the nodes. - m_sparsity.move( MemorySpace::CPU ); + m_sparsity.move( MemorySpace::host ); #if defined(RAJA_ENABLE_OPENMP) using EXEC_POLICY = parallelHostPolicy; @@ -255,8 +255,8 @@ class CRSMatrixAddToRow : public SparsityGenerationRAJA< POLICY > INDEX_TYPE const nodeJp = this->m_numElemsX + 1; INDEX_TYPE const nodeKp = nodeJp * ( this->m_numElemsY + 1 ); - m_matrix.move( MemorySpace::CPU, false ); - this->m_nodeToElemMap.move( MemorySpace::CPU, false ); + m_matrix.move( MemorySpace::host, false ); + this->m_nodeToElemMap.move( MemorySpace::host, false ); #if defined(RAJA_ENABLE_OPENMP) using EXEC_POLICY = parallelHostPolicy; diff --git a/docs/sphinx/ArrayOfArrays.rst b/docs/sphinx/ArrayOfArrays.rst index 7b4cb7c9..683a66be 100644 --- a/docs/sphinx/ArrayOfArrays.rst +++ b/docs/sphinx/ArrayOfArrays.rst @@ -144,7 +144,7 @@ The three types of ``LvArray::ArrayOfArrayView`` obtainable from an ``LvArray::A - ``LvArray::ArrayOfArraysView< T, INDEX_TYPE const, true, LvArray::ChaiBuffer >``, obtained by calling ``toViewConstSizes()``. When it is moved to a new space the values are touched but the sizes and offsets aren't. - ``LvArray::ArrayOfArraysView< T const, INDEX_TYPE const, true, LvArray::ChaiBuffer >``, obtained by calling ``toViewConst()``. None of the buffers are touched in the new space. -Calling the explicit ``move`` method with the touch parameter set to ``true`` on a view type has the behavior described above. However calling ``move( MemorySpace::CPU )`` on an ``LvArray::ArrayOfArrays`` will also touch the offsets (if moving to the GPU the offsets aren't touched). This is the only way to touch the offsets so if an ``LvArray::ArrayOfArrays`` was previously on the device then it must be explicitly moved and touched on the host before any modification to the offsets can safely take place. +Calling the explicit ``move`` method with the touch parameter set to ``true`` on a view type has the behavior described above. However calling ``move( MemorySpace::host )`` on an ``LvArray::ArrayOfArrays`` will also touch the offsets (if moving to the GPU the offsets aren't touched). This is the only way to touch the offsets so if an ``LvArray::ArrayOfArrays`` was previously on the device then it must be explicitly moved and touched on the host before any modification to the offsets can safely take place. .. literalinclude:: ../../examples/exampleArrayOfArrays.cpp :language: c++ diff --git a/docs/sphinx/ArrayOfSets.rst b/docs/sphinx/ArrayOfSets.rst index 73ce9ae3..38d4762d 100644 --- a/docs/sphinx/ArrayOfSets.rst +++ b/docs/sphinx/ArrayOfSets.rst @@ -54,7 +54,7 @@ The two types of ``LvArray::ArrayOfSetsView`` obtainable from an ``LvArray::Arra - ``LvArray::ArrayOfSetsView< T, INDEX_TYPE const, LvArray::ChaiBuffer >``, obtained by calling ``toView()``. When it is moved to a new space the values are touched as well as the sizes. The offsets are not touched. - ``LvArray::ArrayOfSetsView< T const, INDEX_TYPE const, LvArray::ChaiBuffer >``, obtained by calling ``toViewConst()``. None of the buffers are touched in the new space. -Calling the explicit ``move`` method with the touch parameter set to ``true`` on a view type has the behavior described above. However calling ``move( MemorySpace::CPU )`` on an ``LvArray::ArrayOfSets`` will also touch the offsets (if moving to the GPU the offsets aren't touched). This is the only way to touch the offsets so if an ``LvArray::ArrayOfSets`` was previously on the device then it must be explicitly moved and touched on the host before any modification to the offsets can safely take place. +Calling the explicit ``move`` method with the touch parameter set to ``true`` on a view type has the behavior described above. However calling ``move( MemorySpace::host )`` on an ``LvArray::ArrayOfSets`` will also touch the offsets (if moving to the GPU the offsets aren't touched). This is the only way to touch the offsets so if an ``LvArray::ArrayOfSets`` was previously on the device then it must be explicitly moved and touched on the host before any modification to the offsets can safely take place. Usage with ``LVARRAY_BOUNDS_CHECK`` ------------------------------------- diff --git a/docs/sphinx/SortedArray.rst b/docs/sphinx/SortedArray.rst index abce4a52..d81969ba 100644 --- a/docs/sphinx/SortedArray.rst +++ b/docs/sphinx/SortedArray.rst @@ -37,7 +37,7 @@ Usage with ``LvArray::ChaiBuffer`` ---------------------------------- When using the ``LvArray::ChaiBuffer`` as the buffer type the ``LvArray::SortedArray`` can exist in multiple memory spaces. It can be explicitly moved between spaces with the method ``move``. Because the ``SortedArrayView`` cannot modify the values the data is never touched when moving to device, even if the optional ``touch`` parameter is set to false. -It is worth noting that after a ``LvArray::SortedArray`` is moved to the device it must be explicitly moved back to the host by calling ``move( MemorySpace::CPU )`` before it can be safely modified. This won't actually trigger a memory copy since the values weren't touched on device, its purpose is to let CHAI know that the values were touched on the host so that the next time it is moved to device it will copy the values back over. +It is worth noting that after a ``LvArray::SortedArray`` is moved to the device it must be explicitly moved back to the host by calling ``move( MemorySpace::host )`` before it can be safely modified. This won't actually trigger a memory copy since the values weren't touched on device, its purpose is to let CHAI know that the values were touched on the host so that the next time it is moved to device it will copy the values back over. .. literalinclude:: ../../examples/exampleSortedArray.cpp :language: c++ diff --git a/docs/sphinx/SparsityPatternAndCRSMatrix.rst b/docs/sphinx/SparsityPatternAndCRSMatrix.rst index 21657331..26cd2694 100644 --- a/docs/sphinx/SparsityPatternAndCRSMatrix.rst +++ b/docs/sphinx/SparsityPatternAndCRSMatrix.rst @@ -71,7 +71,7 @@ The three types of ``LvArray::CRSMatrixView`` obtainable from an ``LvArray::CRSM - ``LvArray::CRSMatrixsView< T, COL_TYPE const, INDEX_TYPE const, LvArray::ChaiBuffer >``, obtained by calling ``toViewConstSizes()``. When it is moved to a new space the values are touched but the columns, sizes and offsets aren't. - ``LvArray::CRSMatrixsView< T const, COL_TYPE const, INDEX_TYPE const, LvArray::ChaiBuffer >``, obtained by calling ``toViewConst()``. None of the buffers are touched in the new space. -Calling the explicit ``move`` method with the touch parameter set to ``true`` on a view type has the behavior described above. However calling ``move( MemorySpace::CPU )`` on an ``LvArray::CRSMatrix`` or ``LvArray::SparsityPattern`` will also touch the offsets (if moving to the GPU the offsets aren't touched). This is the only way to touch the offsets so if an ``LvArray::CRSMatrix`` was previously on the device then it must be explicitly moved and touched on the host before any modification to the offsets can safely take place. +Calling the explicit ``move`` method with the touch parameter set to ``true`` on a view type has the behavior described above. However calling ``move( MemorySpace::host )`` on an ``LvArray::CRSMatrix`` or ``LvArray::SparsityPattern`` will also touch the offsets (if moving to the GPU the offsets aren't touched). This is the only way to touch the offsets so if an ``LvArray::CRSMatrix`` was previously on the device then it must be explicitly moved and touched on the host before any modification to the offsets can safely take place. Usage with ``LVARRAY_BOUNDS_CHECK`` ------------------------------------- diff --git a/docs/sphinx/bufferClasses.rst b/docs/sphinx/bufferClasses.rst index 3845fb8d..ffed9818 100644 --- a/docs/sphinx/bufferClasses.rst +++ b/docs/sphinx/bufferClasses.rst @@ -6,7 +6,7 @@ The buffer classes are the backbone of every LvArray class. A buffer class is re ``LvArray::MallocBuffer`` ------------------------- -As you might have guessed ``LvArray::MallocBuffer`` uses ``malloc`` and ``free`` to handle its allocation. Copying a ``LvArray::MallocBuffer`` does not copy the allocation. The allocation of a ``LvArray::MallocBuffer`` lives exclusively on the host and as such it will abort the program if you try to move it to or touch it in any space other than ``MemorySpace::CPU``. +As you might have guessed ``LvArray::MallocBuffer`` uses ``malloc`` and ``free`` to handle its allocation. Copying a ``LvArray::MallocBuffer`` does not copy the allocation. The allocation of a ``LvArray::MallocBuffer`` lives exclusively on the host and as such it will abort the program if you try to move it to or touch it in any space other than ``MemorySpace::host``. .. literalinclude:: ../../examples/exampleBuffers.cpp :language: c++ diff --git a/examples/exampleArray.cpp b/examples/exampleArray.cpp index d44be3d8..510a38b6 100644 --- a/examples/exampleArray.cpp +++ b/examples/exampleArray.cpp @@ -332,7 +332,7 @@ CUDA_TEST( Array, chaiBuffer ) LvArray::ChaiBuffer > array( 5, 6 ); // Move the array to the device. - array.move( LvArray::MemorySpace::GPU ); + array.move( LvArray::MemorySpace::cuda ); int * const devicePointer = array.data(); RAJA::forall< RAJA::cuda_exec< 32 > >( @@ -370,11 +370,11 @@ TEST( Array, setName ) LvArray::ChaiBuffer > array( 1024, 1024 ); // Move the array to the device. - array.move( LvArray::MemorySpace::GPU ); + array.move( LvArray::MemorySpace::cuda ); // Provide a name and move the array to the host. array.setName( "my_array" ); - array.move( LvArray::MemorySpace::CPU ); + array.move( LvArray::MemorySpace::host ); } // Sphinx end before setName diff --git a/examples/exampleArrayOfArrays.cpp b/examples/exampleArrayOfArrays.cpp index f6b172a5..7c8fa6f0 100644 --- a/examples/exampleArrayOfArrays.cpp +++ b/examples/exampleArrayOfArrays.cpp @@ -346,7 +346,7 @@ CUDA_TEST( ArrayOfArrays, ChaiBuffer ) // This won't copy any data since everything is current on host. It will however touch the values, // sizes and offsets. - arrayOfArrays.move( LvArray::MemorySpace::CPU ); + arrayOfArrays.move( LvArray::MemorySpace::host ); // Verify that all the modifications are present in the parent ArrayOfArrays. EXPECT_EQ( arrayOfArrays.size(), 10 ); diff --git a/examples/exampleBuffers.cpp b/examples/exampleBuffers.cpp index 914b75bc..ee3b5876 100644 --- a/examples/exampleBuffers.cpp +++ b/examples/exampleBuffers.cpp @@ -30,7 +30,7 @@ TEST( MallocBuffer, copy ) { constexpr std::ptrdiff_t size = 55; LvArray::MallocBuffer< int > buffer( true ); - buffer.reallocate( 0, LvArray::MemorySpace::CPU, size ); + buffer.reallocate( 0, LvArray::MemorySpace::host, size ); for( int i = 0; i < size; ++i ) { @@ -54,7 +54,7 @@ TEST( MallocBuffer, nonPOD ) { constexpr std::ptrdiff_t size = 4; LvArray::MallocBuffer< std::string > buffer( true ); - buffer.reallocate( 0, LvArray::MemorySpace::CPU, size ); + buffer.reallocate( 0, LvArray::MemorySpace::host, size ); // Buffers don't initialize data so placement new must be used. for( int i = 0; i < size; ++i ) @@ -85,7 +85,7 @@ CUDA_TEST( ChaiBuffer, captureOnDevice ) { constexpr std::ptrdiff_t size = 55; LvArray::ChaiBuffer< int > buffer( true ); - buffer.reallocate( 0, LvArray::MemorySpace::CPU, size ); + buffer.reallocate( 0, LvArray::MemorySpace::host, size ); for( int i = 0; i < size; ++i ) { @@ -118,7 +118,7 @@ CUDA_TEST( ChaiBuffer, captureOnDeviceConst ) { constexpr std::ptrdiff_t size = 55; LvArray::ChaiBuffer< int > buffer( true ); - buffer.reallocate( 0, LvArray::MemorySpace::CPU, size ); + buffer.reallocate( 0, LvArray::MemorySpace::host, size ); for( int i = 0; i < size; ++i ) { @@ -153,18 +153,18 @@ CUDA_TEST( ChaiBuffer, captureOnDeviceConst ) TEST( ChaiBuffer, setName ) { LvArray::ChaiBuffer< int > buffer( true ); - buffer.reallocate( 0, LvArray::MemorySpace::CPU, 1024 ); + buffer.reallocate( 0, LvArray::MemorySpace::host, 1024 ); // Move to the device. - buffer.move( LvArray::MemorySpace::GPU, true ); + buffer.move( LvArray::MemorySpace::cuda, true ); // Give buffer a name and move back to the host. buffer.setName( "my_buffer" ); - buffer.move( LvArray::MemorySpace::CPU, true ); + buffer.move( LvArray::MemorySpace::host, true ); // Rename buffer and override the default type. buffer.setName< double >( "my_buffer_with_a_nonsensical_type" ); - buffer.move( LvArray::MemorySpace::GPU, true ); + buffer.move( LvArray::MemorySpace::cuda, true ); } // Sphinx end before ChaiBuffer setName @@ -188,7 +188,7 @@ TEST( StackBuffer, example ) EXPECT_EQ( buffer[ i ], i ); } - EXPECT_DEATH_IF_SUPPORTED( buffer.reallocate( size, LvArray::MemorySpace::CPU, 2 * size ), "" ); + EXPECT_DEATH_IF_SUPPORTED( buffer.reallocate( size, LvArray::MemorySpace::host, 2 * size ), "" ); // Not necessary with the StackBuffer but it's good practice. buffer.free(); diff --git a/examples/exampleSortedArray.cpp b/examples/exampleSortedArray.cpp index d65a4297..252b10cd 100644 --- a/examples/exampleSortedArray.cpp +++ b/examples/exampleSortedArray.cpp @@ -80,7 +80,7 @@ CUDA_TEST( SortedArray, ChaiBuffer ) ); // Move the set back to the CPU and modify it. - set.move( LvArray::MemorySpace::CPU ); + set.move( LvArray::MemorySpace::host ); set.insert( 6 ); // Verify that the modification is seen on device. diff --git a/src/Array.hpp b/src/Array.hpp index bd3cb692..fc9524f4 100644 --- a/src/Array.hpp +++ b/src/Array.hpp @@ -348,7 +348,7 @@ class Array : public ArrayView< T, LVARRAY_HOST_DEVICE void resizeWithoutInitializationOrDestruction( DIMS const ... newDims ) { - return resizeWithoutInitializationOrDestruction( MemorySpace::CPU, newDims ... ); + return resizeWithoutInitializationOrDestruction( MemorySpace::host, newDims ... ); } /** @@ -473,7 +473,7 @@ class Array : public ArrayView< T, * capacity() >= newCapacity. */ void reserve( INDEX_TYPE const newCapacity ) - { bufferManipulation::reserve( this->m_dataBuffer, this->size(), MemorySpace::CPU, newCapacity ); } + { bufferManipulation::reserve( this->m_dataBuffer, this->size(), MemorySpace::host, newCapacity ); } ///@} @@ -623,7 +623,7 @@ class Array : public ArrayView< T, if( newDimLength > curDimLength ) { // Reserve space in the buffer but don't initialize the values. - bufferManipulation::reserve( this->m_dataBuffer, curSize, MemorySpace::CPU, newSize ); + bufferManipulation::reserve( this->m_dataBuffer, curSize, MemorySpace::host, newSize ); T * const ptr = this->data(); // The resizing consists of iterations where each iteration consists of the addition of a diff --git a/src/ArrayOfArraysView.hpp b/src/ArrayOfArraysView.hpp index eb3dd782..4099a20b 100644 --- a/src/ArrayOfArraysView.hpp +++ b/src/ArrayOfArraysView.hpp @@ -584,7 +584,7 @@ class ArrayOfArraysView m_sizes.move( space, touch ); #if defined(LVARRAY_USE_CUDA) - if( space == MemorySpace::GPU ) touch = false; + if( space == MemorySpace::cuda ) touch = false; #endif m_offsets.move( space, touch ); } @@ -631,8 +631,8 @@ class ArrayOfArraysView */ void reserve( INDEX_TYPE const newCapacity ) { - bufferManipulation::reserve( m_offsets, m_numArrays + 1, MemorySpace::CPU, newCapacity + 1 ); - bufferManipulation::reserve( m_sizes, m_numArrays, MemorySpace::CPU, newCapacity ); + bufferManipulation::reserve( m_offsets, m_numArrays + 1, MemorySpace::host, newCapacity + 1 ); + bufferManipulation::reserve( m_sizes, m_numArrays, MemorySpace::host, newCapacity ); } /** @@ -648,7 +648,7 @@ class ArrayOfArraysView INDEX_TYPE const maxOffset = m_offsets[ m_numArrays ]; typeManipulation::forEachArg( [newValueCapacity, maxOffset] ( auto & buffer ) { - bufferManipulation::reserve( buffer, maxOffset, MemorySpace::CPU, newValueCapacity ); + bufferManipulation::reserve( buffer, maxOffset, MemorySpace::host, newValueCapacity ); }, m_values, buffers ... ); } @@ -710,11 +710,11 @@ class ArrayOfArraysView destroyValues( 0, m_numArrays, buffers ... ); - bufferManipulation::reserve( m_sizes, m_numArrays, MemorySpace::CPU, numSubArrays ); + bufferManipulation::reserve( m_sizes, m_numArrays, MemorySpace::host, numSubArrays ); std::fill_n( m_sizes.data(), numSubArrays, 0 ); INDEX_TYPE const offsetsSize = ( m_numArrays == 0 ) ? 0 : m_numArrays + 1; - bufferManipulation::reserve( m_offsets, offsetsSize, MemorySpace::CPU, numSubArrays + 1 ); + bufferManipulation::reserve( m_offsets, offsetsSize, MemorySpace::host, numSubArrays + 1 ); m_offsets[ 0 ] = 0; // RAJA::inclusive_scan fails on empty input range @@ -730,7 +730,7 @@ class ArrayOfArraysView INDEX_TYPE const maxOffset = m_offsets[ m_numArrays ]; typeManipulation::forEachArg( [ maxOffset] ( auto & buffer ) { - bufferManipulation::reserve( buffer, 0, MemorySpace::CPU, maxOffset ); + bufferManipulation::reserve( buffer, 0, MemorySpace::host, maxOffset ); }, m_values, buffers ... ); } @@ -787,7 +787,7 @@ class ArrayOfArraysView INDEX_TYPE const maxOffset = m_offsets[ m_numArrays ]; typeManipulation::forEachArg( [totalSize, maxOffset]( auto & buffer ) { - bufferManipulation::reserve( buffer, maxOffset, MemorySpace::CPU, totalSize ); + bufferManipulation::reserve( buffer, maxOffset, MemorySpace::host, totalSize ); }, m_values, buffers ... ); } } @@ -843,7 +843,7 @@ class ArrayOfArraysView INDEX_TYPE const maxOffset = m_offsets[ m_numArrays ]; typeManipulation::forEachArg( [maxOffset, srcMaxOffset]( auto & dstBuffer ) { - bufferManipulation::reserve( dstBuffer, maxOffset, MemorySpace::CPU, srcMaxOffset ); + bufferManipulation::reserve( dstBuffer, maxOffset, MemorySpace::host, srcMaxOffset ); }, m_values, pairs.first ... ); m_numArrays = srcNumArrays; @@ -938,7 +938,7 @@ class ArrayOfArraysView // We need to touch the offsets on the CPU because since it contains const data // when the ArrayOfArraysView gets copy constructed it doesn't get touched even though // it can then be modified via this method when called from a parent non-view class. - m_offsets.registerTouch( MemorySpace::CPU ); + m_offsets.registerTouch( MemorySpace::host ); } /** @@ -992,13 +992,13 @@ class ArrayOfArraysView // This moves m_sizes and m_offsets, m_values and buffers are moved inside the loop. if( !typeManipulation::all_of_t< std::is_trivially_destructible< T >, std::is_trivially_destructible< typename BUFFERS::value_type > ... >::value ) - { move( MemorySpace::CPU, true ); } + { move( MemorySpace::host, true ); } typeManipulation::forEachArg( [this, begin, end] ( auto & buffer ) { if( !std::is_trivially_destructible< std::remove_reference_t< decltype( buffer[ 0 ] ) > >::value ) { - buffer.move( MemorySpace::CPU, true ); + buffer.move( MemorySpace::host, true ); for( INDEX_TYPE i = begin; i < end; ++i ) { INDEX_TYPE const offset = m_offsets[ i ]; diff --git a/src/ArrayView.hpp b/src/ArrayView.hpp index a7239bd2..db311391 100644 --- a/src/ArrayView.hpp +++ b/src/ArrayView.hpp @@ -625,7 +625,7 @@ class ArrayView inline void zero() const { #if !defined( LVARRAY_USE_UMPIRE ) - LVARRAY_ERROR_IF_NE_MSG( getPreviousSpace(), MemorySpace::CPU, "Without Umpire only host memory is supported." ); + LVARRAY_ERROR_IF_NE_MSG( getPreviousSpace(), MemorySpace::host, "Without Umpire only host memory is supported." ); #endif move( getPreviousSpace(), true ); diff --git a/src/CRSMatrix.hpp b/src/CRSMatrix.hpp index 7f4ae865..642774aa 100644 --- a/src/CRSMatrix.hpp +++ b/src/CRSMatrix.hpp @@ -146,7 +146,7 @@ class CRSMatrix : protected CRSMatrixView< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE } // Reallocate to the appropriate length - bufferManipulation::reserve( this->m_entries, 0, MemorySpace::CPU, src.nonZeroCapacity() ); + bufferManipulation::reserve( this->m_entries, 0, MemorySpace::host, src.nonZeroCapacity() ); ParentClass::assimilate( reinterpret_cast< SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFER_TYPE > && >( src ) ); diff --git a/src/CRSMatrixView.hpp b/src/CRSMatrixView.hpp index 1c1a67e3..8b9f7a56 100644 --- a/src/CRSMatrixView.hpp +++ b/src/CRSMatrixView.hpp @@ -369,7 +369,7 @@ class CRSMatrixView : protected SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFE inline void zero() const { #if !defined( LVARRAY_USE_UMPIRE ) - LVARRAY_ERROR_IF_NE_MSG( getPreviousSpace(), MemorySpace::CPU, "Without Umpire only host memory is supported." ); + LVARRAY_ERROR_IF_NE_MSG( getPreviousSpace(), MemorySpace::host, "Without Umpire only host memory is supported." ); #endif ParentClass::move( m_entries.getPreviousSpace(), false ); diff --git a/src/ChaiBuffer.hpp b/src/ChaiBuffer.hpp index df826a56..20919bbc 100644 --- a/src/ChaiBuffer.hpp +++ b/src/ChaiBuffer.hpp @@ -51,12 +51,12 @@ static std::mutex chaiLock; */ inline chai::ExecutionSpace toChaiExecutionSpace( MemorySpace const space ) { - if( space == MemorySpace::NONE ) + if( space == MemorySpace::undefined ) return chai::NONE; - if( space == MemorySpace::CPU ) + if( space == MemorySpace::host ) return chai::CPU; #if defined(LVARRAY_USE_CUDA) - if( space == MemorySpace::GPU ) + if( space == MemorySpace::cuda || space == MemorySpace::hip ) return chai::GPU; #endif @@ -72,17 +72,17 @@ inline chai::ExecutionSpace toChaiExecutionSpace( MemorySpace const space ) inline MemorySpace toMemorySpace( chai::ExecutionSpace const space ) { if( space == chai::NONE ) - return MemorySpace::NONE; + return MemorySpace::undefined; if( space == chai::CPU ) - return MemorySpace::CPU; + return MemorySpace::host; #if defined(LVARRAY_USE_CUDA) if( space == chai::GPU ) - return MemorySpace::GPU; + return MemorySpace::cuda; #endif LVARRAY_ERROR( "Unrecognized execution space " << static_cast< int >( space ) ); - return MemorySpace::NONE; + return MemorySpace::undefined; } } // namespace internal @@ -299,7 +299,7 @@ class ChaiBuffer if( size > 0 ) { - LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::CPU, "Calling reallocate with a non-zero current size is not yet supporeted for the GPU." ); + LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::host, "Calling reallocate with a non-zero current size is not yet supporeted for the GPU." ); std::ptrdiff_t const overlapAmount = std::min( newCapacity, size ); arrayManipulation::uninitializedMove( newPointer, overlapAmount, m_pointer ); arrayManipulation::destroy( m_pointer, size ); @@ -383,7 +383,7 @@ class ChaiBuffer if( prevSpace == chai::GPU && prevSpace != chaiSpace ) moveInnerData( space, size, touch ); #else - LVARRAY_ERROR_IF_NE( space, MemorySpace::CPU ); + LVARRAY_ERROR_IF_NE( space, MemorySpace::host ); LVARRAY_UNUSED_VARIABLE( size ); LVARRAY_UNUSED_VARIABLE( touch ); #endif @@ -411,7 +411,7 @@ class ChaiBuffer if( !std::is_const< T >::value && touch ) m_pointerRecord->m_touched[ chaiSpace ] = true; m_pointerRecord->m_last_space = chaiSpace; #else - LVARRAY_ERROR_IF_NE( space, MemorySpace::CPU ); + LVARRAY_ERROR_IF_NE( space, MemorySpace::host ); LVARRAY_UNUSED_VARIABLE( touch ); #endif } @@ -471,7 +471,7 @@ class ChaiBuffer std::enable_if_t< bufferManipulation::HasMemberFunction_move< U > > moveInnerData( MemorySpace const space, std::ptrdiff_t const size, bool const touch ) const { - if( space == MemorySpace::NONE ) return; + if( space == MemorySpace::undefined ) return; for( std::ptrdiff_t i = 0; i < size; ++i ) { diff --git a/src/MallocBuffer.hpp b/src/MallocBuffer.hpp index c1ec08ef..836d3c4c 100644 --- a/src/MallocBuffer.hpp +++ b/src/MallocBuffer.hpp @@ -127,7 +127,7 @@ class MallocBuffer : public bufferManipulation::VoidBuffer */ void reallocate( std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity ) { - LVARRAY_ERROR_IF_NE( space, MemorySpace::CPU ); + LVARRAY_ERROR_IF_NE( space, MemorySpace::host ); // TODO: If std::is_trivially_copyable_v< T > then we could use std::realloc. T * const newPtr = reinterpret_cast< T * >( std::malloc( newCapacity * sizeof( T ) ) ); diff --git a/src/SortedArray.hpp b/src/SortedArray.hpp index cd4473d3..aa5ff056 100644 --- a/src/SortedArray.hpp +++ b/src/SortedArray.hpp @@ -309,7 +309,7 @@ class SortedArray : protected SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE > */ inline void reserve( INDEX_TYPE const nVals ) - { bufferManipulation::reserve( this->m_values, size(), MemorySpace::CPU, nVals ); } + { bufferManipulation::reserve( this->m_values, size(), MemorySpace::host, nVals ); } ///@} diff --git a/src/SortedArrayView.hpp b/src/SortedArrayView.hpp index be82968f..a7a61530 100644 --- a/src/SortedArrayView.hpp +++ b/src/SortedArrayView.hpp @@ -273,7 +273,7 @@ class SortedArrayView void move( MemorySpace const space, bool touch=true ) const { #if defined(LVARRAY_USE_CUDA) - if( space == MemorySpace::GPU ) touch = false; + if( space == MemorySpace::cuda ) touch = false; #endif m_values.move( space, touch ); } diff --git a/src/bufferManipulation.hpp b/src/bufferManipulation.hpp index 5bcf381e..7d921037 100644 --- a/src/bufferManipulation.hpp +++ b/src/bufferManipulation.hpp @@ -18,41 +18,40 @@ #include "typeManipulation.hpp" #include "arrayManipulation.hpp" +// TPL includes +#include + // System includes #include namespace LvArray { -/** - * @enum MemorySpace - * @brief An enum containing the available memory spaces. - */ -enum class MemorySpace -{ - NONE - , CPU -#if defined(LVARRAY_USE_CUDA) - , GPU -#endif -}; +/// @brief an alias for camp::resources::Platform. +using MemorySpace = camp::resources::Platform; /** - * @brief Output a MemorySpace enum to a stream. + * @brief Output a Platform enum to a stream. * @param os The output stream to write to. * @param space The MemorySpace to output. * @return @p os. */ inline std::ostream & operator<<( std::ostream & os, MemorySpace const space ) { - if( space == MemorySpace::NONE ) - os << "NONE"; - if( space == MemorySpace::CPU ) - os << "CPU"; -#if defined(LVARRAY_USE_CUDA) - if( space == MemorySpace::GPU ) - os << "GPU"; -#endif + if( space == MemorySpace::undefined ) + return os << "undefined"; + if( space == MemorySpace::host ) + return os << "host"; + if( space == MemorySpace::cuda ) + return os << "cuda"; + if( space == MemorySpace::omp_target ) + return os << "omp_target"; + if( space == MemorySpace::hip ) + return os << "hip"; + if( space == MemorySpace::sycl ) + return os << "sycl"; + + LVARRAY_ERROR( "Unrecognized memory space " << static_cast< int >( space ) ); return os; } @@ -68,7 +67,7 @@ namespace bufferManipulation * that is true iff the class has a method move(MemorySpace, bool). * @tparam CLASS The type to test. */ -HAS_MEMBER_FUNCTION_NO_RTYPE( move, MemorySpace::CPU, true ); +HAS_MEMBER_FUNCTION_NO_RTYPE( move, MemorySpace::host, true ); /** * @class VoidBuffer @@ -90,7 +89,7 @@ struct VoidBuffer { LVARRAY_UNUSED_VARIABLE( size ); LVARRAY_UNUSED_VARIABLE( touch ); - LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::CPU, "This Buffer type can only be used on the CPU." ); + LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::host, "This Buffer type can only be used on the CPU." ); } /** @@ -103,7 +102,7 @@ struct VoidBuffer void move( MemorySpace const space, bool const touch ) const { LVARRAY_UNUSED_VARIABLE( touch ); - LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::CPU, "This Buffer type can only be used on the CPU." ); + LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::host, "This Buffer type can only be used on the CPU." ); } /** @@ -111,7 +110,7 @@ struct VoidBuffer * @note The default behavior is that the Buffer can only exist on the CPU. */ MemorySpace getPreviousSpace() const - { return MemorySpace::CPU; } + { return MemorySpace::host; } /** * @brief Touch the buffer in the given space. @@ -120,7 +119,7 @@ struct VoidBuffer * occurs if you try to move it to a different space. */ void registerTouch( MemorySpace const space ) const - { LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::CPU, "This Buffer type can only be used on the CPU." ); } + { LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::host, "This Buffer type can only be used on the CPU." ); } /** * @tparam The type of the owning object. @@ -194,7 +193,7 @@ void free( BUFFER & buf, std::ptrdiff_t const size ) if( !std::is_trivially_destructible< T >::value ) { - buf.move( MemorySpace::CPU, true ); + buf.move( MemorySpace::host, true ); arrayManipulation::destroy( buf.data(), size ); } @@ -255,7 +254,7 @@ void dynamicReserve( BUFFER & buf, std::ptrdiff_t const size, std::ptrdiff_t con if( newCapacity > buf.capacity() ) { - setCapacity( buf, size, MemorySpace::CPU, 2 * newCapacity ); + setCapacity( buf, size, MemorySpace::host, 2 * newCapacity ); } } @@ -274,14 +273,14 @@ void resize( BUFFER & buf, std::ptrdiff_t const size, std::ptrdiff_t const newSi { check( buf, size ); - reserve( buf, size, MemorySpace::CPU, newSize ); + reserve( buf, size, MemorySpace::host, newSize ); arrayManipulation::resize( buf.data(), size, newSize, std::forward< ARGS >( args )... ); #if !defined(__CUDA_ARCH__) if( newSize > 0 ) { - buf.registerTouch( MemorySpace::CPU ); + buf.registerTouch( MemorySpace::host ); } #endif } diff --git a/src/memcpy.hpp b/src/memcpy.hpp index fda9ea3c..dafcf78e 100644 --- a/src/memcpy.hpp +++ b/src/memcpy.hpp @@ -158,8 +158,8 @@ void memcpy( ArrayView< T, DST_NDIM, DST_USD, DST_INDEX_TYPE, DST_BUFFER > const std::array< SRC_INDEX_TYPE, N_SRC_INDICES > const & srcIndices ) { #if !defined( LVARRAY_USE_UMPIRE ) - LVARRAY_ERROR_IF_NE_MSG( dst.getPreviousSpace(), MemorySpace::CPU, "Without Umpire only host memory is supported." ); - LVARRAY_ERROR_IF_NE_MSG( src.getPreviousSpace(), MemorySpace::CPU, "Without Umpire only host memory is supported." ); + LVARRAY_ERROR_IF_NE_MSG( dst.getPreviousSpace(), MemorySpace::host, "Without Umpire only host memory is supported." ); + LVARRAY_ERROR_IF_NE_MSG( src.getPreviousSpace(), MemorySpace::host, "Without Umpire only host memory is supported." ); #endif dst.move( dst.getPreviousSpace(), true ); diff --git a/src/python/PyArray.cpp b/src/python/PyArray.cpp index 77b27065..8e36b51e 100644 --- a/src/python/PyArray.cpp +++ b/src/python/PyArray.cpp @@ -224,12 +224,12 @@ static PyObject * PyArray_setAccessLevel( PyArray * const self, PyObject * const VERIFY_INITIALIZED( self ); int newAccessLevel; - int newSpace = static_cast< int >( LvArray::MemorySpace::CPU ); + int newSpace = static_cast< int >( LvArray::MemorySpace::host ); if( !PyArg_ParseTuple( args, "i|i", &newAccessLevel, &newSpace ) ) { return nullptr; } - if( newSpace != static_cast< int >( LvArray::MemorySpace::CPU ) ) + if( newSpace != static_cast< int >( LvArray::MemorySpace::host ) ) { PyErr_SetString( PyExc_ValueError, "Invalid space" ); return nullptr; diff --git a/src/python/PyCRSMatrix.cpp b/src/python/PyCRSMatrix.cpp index faa1b4c3..9b81a4b7 100644 --- a/src/python/PyCRSMatrix.cpp +++ b/src/python/PyCRSMatrix.cpp @@ -370,12 +370,12 @@ static PyObject * PyCRSMatrix_setAccessLevel( PyCRSMatrix * const self, PyObject VERIFY_INITIALIZED( self ); int newAccessLevel; - int newSpace = static_cast< int >( LvArray::MemorySpace::CPU ); + int newSpace = static_cast< int >( LvArray::MemorySpace::host ); if( !PyArg_ParseTuple( args, "i|i", &newAccessLevel, &newSpace ) ) { return nullptr; } - if( newSpace != static_cast< int >( LvArray::MemorySpace::CPU ) ) + if( newSpace != static_cast< int >( LvArray::MemorySpace::host ) ) { PyErr_SetString( PyExc_ValueError, "Invalid space" ); return nullptr; diff --git a/src/python/PySortedArray.cpp b/src/python/PySortedArray.cpp index d20c1d33..669ba1e3 100644 --- a/src/python/PySortedArray.cpp +++ b/src/python/PySortedArray.cpp @@ -181,11 +181,16 @@ static PyObject * PySortedArray_setAccessLevel( PySortedArray * const self, PyOb VERIFY_INITIALIZED( self ); int newAccessLevel; - int newSpace = static_cast< int >( LvArray::MemorySpace::NONE ); + int newSpace = static_cast< int >( LvArray::MemorySpace::host ); if( !PyArg_ParseTuple( args, "i|i", &newAccessLevel, &newSpace ) ) { return nullptr; } + if( newSpace != static_cast< int >( LvArray::MemorySpace::host ) ) + { + PyErr_SetString( PyExc_ValueError, "Invalid space" ); + return nullptr; + } self->sortedArray->setAccessLevel( newAccessLevel, newSpace ); Py_RETURN_NONE; } diff --git a/src/python/python.cpp b/src/python/python.cpp index 97d5b0ec..341bab13 100644 --- a/src/python/python.cpp +++ b/src/python/python.cpp @@ -76,11 +76,11 @@ static bool addConstants( PyObject * module ) "couldn't add constant", false ); } - PYTHON_ERROR_IF( PyModule_AddIntConstant( module, "CPU", static_cast< long >( LvArray::MemorySpace::CPU ) ), PyExc_RuntimeError, + PYTHON_ERROR_IF( PyModule_AddIntConstant( module, "CPU", static_cast< long >( LvArray::MemorySpace::host ) ), PyExc_RuntimeError, "couldn't add constant", false ); #if defined(USE_CUDA) - PYTHON_ERROR_IF( PyModule_AddIntConstant( module, "GPU", static_cast< long >( LvArray::MemorySpace::GPU ) ), PyExc_RuntimeError, + PYTHON_ERROR_IF( PyModule_AddIntConstant( module, "GPU", static_cast< long >( LvArray::MemorySpace::cuda ) ), PyExc_RuntimeError, "couldn't add constant", false ); #endif diff --git a/unitTests/testArray1DOfArray1D.cpp b/unitTests/testArray1DOfArray1D.cpp index e049ddb4..b3710747 100644 --- a/unitTests/testArray1DOfArray1D.cpp +++ b/unitTests/testArray1DOfArray1D.cpp @@ -138,7 +138,7 @@ class Array1DOfArray1DTest : public ::testing::Test } } ); - array.move( MemorySpace::CPU ); + array.move( MemorySpace::host ); dataPointer = array.data(); forall< serialPolicy >( array.size(), [dataPointer] LVARRAY_HOST_DEVICE ( INDEX_TYPE const i ) { @@ -182,7 +182,7 @@ class Array1DOfArray1DTest : public ::testing::Test } // Check that the modifications are present in the original array after launching a host kernel. - array.move( MemorySpace::CPU ); + array.move( MemorySpace::host ); dataPointer = array.data(); forall< serialPolicy >( array.size(), [dataPointer] LVARRAY_HOST_DEVICE ( INDEX_TYPE const i ) { @@ -199,7 +199,7 @@ class Array1DOfArray1DTest : public ::testing::Test { Array1D< Array1D< T > > array( 10 ); array.move( RAJAHelper< POLICY >::space ); - array.move( MemorySpace::CPU ); + array.move( MemorySpace::host ); } private: diff --git a/unitTests/testArray1DOfArray1DOfArray1D.cpp b/unitTests/testArray1DOfArray1DOfArray1D.cpp index edf6b78a..f161c19a 100644 --- a/unitTests/testArray1DOfArray1DOfArray1D.cpp +++ b/unitTests/testArray1DOfArray1DOfArray1D.cpp @@ -162,7 +162,7 @@ class Array1DOfArray1DOfArray1DTest : public ::testing::Test } } ); - array.move( MemorySpace::CPU ); + array.move( MemorySpace::host ); dataPointer = array.data(); forall< serialPolicy >( array.size(), [dataPointer] LVARRAY_HOST_DEVICE ( INDEX_TYPE const i ) { @@ -221,7 +221,7 @@ class Array1DOfArray1DOfArray1DTest : public ::testing::Test } // Check that the modifications are present in the original array after launching a host kernel. - array.move( MemorySpace::CPU, false ); + array.move( MemorySpace::host, false ); dataPointer = array.data(); forall< serialPolicy >( array.size(), [dataPointer] LVARRAY_HOST_DEVICE ( INDEX_TYPE const i ) { diff --git a/unitTests/testArrayOfArrays.cpp b/unitTests/testArrayOfArrays.cpp index 7ccdd69d..c21c1e8b 100644 --- a/unitTests/testArrayOfArrays.cpp +++ b/unitTests/testArrayOfArrays.cpp @@ -977,7 +977,7 @@ class ArrayOfArraysViewTest : public ArrayOfArraysTest< typename ARRAY_OF_ARRAYS } // Move the view back to the host and compare with the reference. - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE; } @@ -1019,7 +1019,7 @@ class ArrayOfArraysViewTest : public ArrayOfArraysTest< typename ARRAY_OF_ARRAYS } ); // Move the view back to the host and compare with the reference. - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE; } @@ -1055,7 +1055,7 @@ class ArrayOfArraysViewTest : public ArrayOfArraysTest< typename ARRAY_OF_ARRAYS } ); // Move the view back to the host and compare with the reference. - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE; } @@ -1103,7 +1103,7 @@ class ArrayOfArraysViewTest : public ArrayOfArraysTest< typename ARRAY_OF_ARRAYS } ); // Move the view back to the host and compare with the reference. - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE; } @@ -1145,7 +1145,7 @@ class ArrayOfArraysViewTest : public ArrayOfArraysTest< typename ARRAY_OF_ARRAYS } ); // Move the view back to the host and compare with the reference. - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE; } @@ -1183,7 +1183,7 @@ class ArrayOfArraysViewTest : public ArrayOfArraysTest< typename ARRAY_OF_ARRAYS } ); // Move the view back to the host and compare with the reference. - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE; } @@ -1218,7 +1218,7 @@ class ArrayOfArraysViewTest : public ArrayOfArraysTest< typename ARRAY_OF_ARRAYS } ); // Move the view back to the host and compare with the reference. - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE; } @@ -1376,7 +1376,7 @@ class ArrayOfArraysViewAtomicTest : public ArrayOfArraysViewTest< ARRAY_OF_ARRAY } ); // Now sort each array and check that the values are as expected. - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); IndexType const appendsPerArray = numThreads * appendsPerArrayPerThread; for( IndexType i = 0; i < nArrays; ++i ) { diff --git a/unitTests/testArrayOfSets.cpp b/unitTests/testArrayOfSets.cpp index e4262229..72c623ed 100644 --- a/unitTests/testArrayOfSets.cpp +++ b/unitTests/testArrayOfSets.cpp @@ -812,7 +812,7 @@ class ArrayOfSetsViewTest : public ArrayOfSetsTest< typename ARRAY_OF_SETS_POLIC } ); // Move the view back to the host and compare with the reference. - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -832,7 +832,7 @@ class ArrayOfSetsViewTest : public ArrayOfSetsTest< typename ARRAY_OF_SETS_POLIC } } ); - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -849,7 +849,7 @@ class ArrayOfSetsViewTest : public ArrayOfSetsTest< typename ARRAY_OF_SETS_POLIC view.insertIntoSet( i, toInsertView[ i ].begin(), toInsertView[ i ].end() ); } ); - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -869,7 +869,7 @@ class ArrayOfSetsViewTest : public ArrayOfSetsTest< typename ARRAY_OF_SETS_POLIC } } ); - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -886,7 +886,7 @@ class ArrayOfSetsViewTest : public ArrayOfSetsTest< typename ARRAY_OF_SETS_POLIC view.removeFromSet( i, toRemoveView[ i ].begin(), toRemoveView[ i ].end() ); } ); - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); COMPARE_TO_REFERENCE } diff --git a/unitTests/testArrayView.hpp b/unitTests/testArrayView.hpp index bd770f65..17016b2a 100644 --- a/unitTests/testArrayView.hpp +++ b/unitTests/testArrayView.hpp @@ -283,7 +283,7 @@ class ArrayViewPolicyTest : public ArrayViewTest< typename ARRAY_POLICY_PAIR::fi dataPointer[ i ] += dataPointer[ i ]; } ); - array->move( MemorySpace::CPU, false ); + array->move( MemorySpace::host, false ); forValuesInSliceWithIndices( array->toSliceConst(), [] ( T const & value, auto const ... indices ) { @@ -318,7 +318,7 @@ class ArrayViewPolicyTest : public ArrayViewTest< typename ARRAY_POLICY_PAIR::fi for( INDEX_TYPE i = 0; i < array->size(); ++i ) { hostPointer[ i ] += hostPointer[ i ]; } - array->move( MemorySpace::CPU, false ); + array->move( MemorySpace::host, false ); EXPECT_EQ( array->data(), hostPointer ); forValuesInSliceWithIndices( array->toSliceConst(), [] ( T const & value, auto const ... indices ) { @@ -383,7 +383,7 @@ class ArrayViewPolicyTest : public ArrayViewTest< typename ARRAY_POLICY_PAIR::fi dataPointer[ i ] += dataPointer[ i ]; } ); - array->move( MemorySpace::CPU ); + array->move( MemorySpace::host ); dataPointer = array->data(); forall< serialPolicy >( array->size(), [dataPointer] LVARRAY_HOST_DEVICE ( INDEX_TYPE const i ) { @@ -397,7 +397,7 @@ class ArrayViewPolicyTest : public ArrayViewTest< typename ARRAY_POLICY_PAIR::fi dataPointer[ i ] += dataPointer[ i ]; } ); - array->move( MemorySpace::CPU, false ); + array->move( MemorySpace::host, false ); forValuesInSliceWithIndices( array->toSliceConst(), [] ( T const & value, auto const ... indices ) { @@ -414,7 +414,7 @@ class ArrayViewPolicyTest : public ArrayViewTest< typename ARRAY_POLICY_PAIR::fi { ARRAY array; array.move( RAJAHelper< POLICY >::space ); - array.move( MemorySpace::CPU ); + array.move( MemorySpace::host ); } static void setValues() @@ -498,7 +498,7 @@ class ArrayViewPolicyTest : public ArrayViewTest< typename ARRAY_POLICY_PAIR::fi EXPECT_EQ( array.capacity(), arrayToCopy->size() ); EXPECT_EQ( array.data(), initialPtr ); - array.move( MemorySpace::CPU ); + array.move( MemorySpace::host ); ParentClass::checkFill( array ); } diff --git a/unitTests/testArray_ChaiBuffer.cpp b/unitTests/testArray_ChaiBuffer.cpp index 7b302305..95c37f8c 100644 --- a/unitTests/testArray_ChaiBuffer.cpp +++ b/unitTests/testArray_ChaiBuffer.cpp @@ -39,10 +39,10 @@ class ArrayTest : public ::testing::Test #if defined( LVARRAY_USE_CUDA ) auto devicePool = rm.makeAllocator< umpire::strategy::DynamicPool >( "DEVICE_pool", rm.getAllocator( "DEVICE" ) ); - std::initializer_list< MemorySpace > const spaces = { MemorySpace::CPU, MemorySpace::GPU }; + std::initializer_list< MemorySpace > const spaces = { MemorySpace::host, MemorySpace::cuda }; std::initializer_list< umpire::Allocator > const allocators = { hostPool, devicePool }; #else - std::initializer_list< MemorySpace > const spaces = { MemorySpace::CPU }; + std::initializer_list< MemorySpace > const spaces = { MemorySpace::host }; std::initializer_list< umpire::Allocator > const allocators = { hostPool }; #endif @@ -57,10 +57,10 @@ class ArrayTest : public ::testing::Test EXPECT_EQ( rm.getAllocator( array.data() ).getName(), "HOST_pool" ); #if defined( LVARRAY_USE_CUDA ) - array.move( MemorySpace::GPU, true ); + array.move( MemorySpace::cuda, true ); EXPECT_EQ( rm.getAllocator( array.data() ).getName(), "DEVICE_pool" ); - array.move( MemorySpace::CPU, true ); + array.move( MemorySpace::host, true ); EXPECT_EQ( rm.getAllocator( array.data() ).getName(), "HOST_pool" ); #endif } @@ -70,7 +70,7 @@ class ArrayTest : public ::testing::Test { Array< int, 1, RAJA::PERM_I, int, ChaiBuffer > array; - array.resizeWithoutInitializationOrDestruction( MemorySpace::GPU, 100 ); + array.resizeWithoutInitializationOrDestruction( MemorySpace::cuda, 100 ); T * const devPtr = array.data(); forall< parallelDevicePolicy< 32 > >( array.size(), [devPtr] LVARRAY_DEVICE ( int const i ) @@ -78,7 +78,7 @@ class ArrayTest : public ::testing::Test new ( &devPtr[ i ] ) T( i ); } ); - array.move( MemorySpace::CPU, true ); + array.move( MemorySpace::host, true ); for( int i = 0; i < array.size(); ++i ) { EXPECT_EQ( array[ i ], T( i ) ); diff --git a/unitTests/testBuffers.cpp b/unitTests/testBuffers.cpp index 8df5c976..94c5f317 100644 --- a/unitTests/testBuffers.cpp +++ b/unitTests/testBuffers.cpp @@ -117,8 +117,8 @@ TYPED_TEST( BufferAPITest, move ) { TypeParam buffer( true ); - buffer.moveNested( MemorySpace::CPU, 0, true ); - buffer.move( MemorySpace::CPU, true ); + buffer.moveNested( MemorySpace::host, 0, true ); + buffer.move( MemorySpace::host, true ); bufferManipulation::free( buffer, 0 ); } @@ -130,7 +130,7 @@ TYPED_TEST( BufferAPITest, registerTouch ) { TypeParam buffer( true ); - buffer.registerTouch( MemorySpace::CPU ); + buffer.registerTouch( MemorySpace::host ); bufferManipulation::free( buffer, 0 ); } @@ -200,7 +200,7 @@ class BufferTestNoRealloc : public ::testing::Test */ void SetUp() override { - m_buffer.reallocate( 0, MemorySpace::CPU, NO_REALLOC_CAPACITY ); + m_buffer.reallocate( 0, MemorySpace::host, NO_REALLOC_CAPACITY ); } /** @@ -620,7 +620,7 @@ class BufferTestWithRealloc : public BufferTestNoRealloc< BUFFER_TYPE > { COMPARE_TO_REFERENCE( m_buffer, m_ref ); - bufferManipulation::setCapacity( m_buffer, size(), MemorySpace::CPU, size() + 100 ); + bufferManipulation::setCapacity( m_buffer, size(), MemorySpace::host, size() + 100 ); T const * const ptr = m_buffer.data(); T const val( randInt() ); @@ -631,7 +631,7 @@ class BufferTestWithRealloc : public BufferTestNoRealloc< BUFFER_TYPE > COMPARE_TO_REFERENCE( m_buffer, m_ref ); - bufferManipulation::setCapacity( m_buffer, size(), MemorySpace::CPU, size() - 50 ); + bufferManipulation::setCapacity( m_buffer, size(), MemorySpace::host, size() - 50 ); m_ref.resize( size() - 50 ); COMPARE_TO_REFERENCE( m_buffer, m_ref ); @@ -644,20 +644,20 @@ class BufferTestWithRealloc : public BufferTestNoRealloc< BUFFER_TYPE > { COMPARE_TO_REFERENCE( m_buffer, m_ref ); - bufferManipulation::setCapacity( m_buffer, size(), MemorySpace::CPU, size() + 100 ); + bufferManipulation::setCapacity( m_buffer, size(), MemorySpace::host, size() + 100 ); T const * const ptr = m_buffer.data(); T const val( randInt() ); bufferManipulation::resize( m_buffer, size(), size() + 100, val ); m_ref.resize( size() + 100, val ); - bufferManipulation::reserve( m_buffer, size(), MemorySpace::CPU, size() - 50 ); + bufferManipulation::reserve( m_buffer, size(), MemorySpace::host, size() - 50 ); EXPECT_EQ( ptr, m_buffer.data() ); COMPARE_TO_REFERENCE( m_buffer, m_ref ); - bufferManipulation::reserve( m_buffer, size(), MemorySpace::CPU, size() + 50 ); + bufferManipulation::reserve( m_buffer, size(), MemorySpace::host, size() + 50 ); T const * const newPtr = m_buffer.data(); T const newVal( randInt() ); diff --git a/unitTests/testCRSMatrix.cpp b/unitTests/testCRSMatrix.cpp index 3792352e..1270df11 100644 --- a/unitTests/testCRSMatrix.cpp +++ b/unitTests/testCRSMatrix.cpp @@ -672,7 +672,7 @@ class CRSMatrixViewTest : public CRSMatrixTest< typename CRS_MATRIX_POLICY_PAIR: { memoryMotionInit(); - this->m_matrix.move( MemorySpace::CPU ); + this->m_matrix.move( MemorySpace::host ); IndexType curIndex = 0; for( IndexType row = 0; row < m_matrix.numRows(); ++row ) { @@ -703,7 +703,7 @@ class CRSMatrixViewTest : public CRSMatrixTest< typename CRS_MATRIX_POLICY_PAIR: } ); // This should copy back the entries but not the columns. - this->m_matrix.move( MemorySpace::CPU ); + this->m_matrix.move( MemorySpace::host ); for( IndexType row = 0; row < numRows; ++row ) { ASSERT_EQ( m_matrix.numNonZeros( row ), this->m_ref[row].size()); @@ -748,7 +748,7 @@ class CRSMatrixViewTest : public CRSMatrixTest< typename CRS_MATRIX_POLICY_PAIR: this->insert( maxInserts ); // Move the matrix back to the host, this should copy nothing. - this->m_matrix.move( MemorySpace::CPU ); + this->m_matrix.move( MemorySpace::host ); // And therefore the matrix should still equal the reference. COMPARE_TO_REFERENCE @@ -767,7 +767,7 @@ class CRSMatrixViewTest : public CRSMatrixTest< typename CRS_MATRIX_POLICY_PAIR: } } - this->m_matrix.move( MemorySpace::CPU ); + this->m_matrix.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -788,7 +788,7 @@ class CRSMatrixViewTest : public CRSMatrixTest< typename CRS_MATRIX_POLICY_PAIR: } } - this->m_matrix.move( MemorySpace::CPU ); + this->m_matrix.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -849,7 +849,7 @@ class CRSMatrixViewTest : public CRSMatrixTest< typename CRS_MATRIX_POLICY_PAIR: ); } - this->m_matrix.move( MemorySpace::CPU ); + this->m_matrix.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -903,7 +903,7 @@ class CRSMatrixViewTest : public CRSMatrixTest< typename CRS_MATRIX_POLICY_PAIR: } ); } - this->m_matrix.move( MemorySpace::CPU ); + this->m_matrix.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -1249,7 +1249,7 @@ class CRSMatrixViewAtomicTest : public CRSMatrixViewTest< CRS_MATRIX_POLICY_PAIR } ); } - this->m_matrix.move( MemorySpace::CPU ); + this->m_matrix.move( MemorySpace::host ); COMPARE_TO_REFERENCE } diff --git a/unitTests/testChaiBuffer.cpp b/unitTests/testChaiBuffer.cpp index 2a79c868..6a047789 100644 --- a/unitTests/testChaiBuffer.cpp +++ b/unitTests/testChaiBuffer.cpp @@ -38,17 +38,17 @@ class ChaiBufferTest : public ::testing::Test #if defined( LVARRAY_USE_CUDA ) auto devicePool = rm.makeAllocator< umpire::strategy::DynamicPool >( "DEVICE_pool", rm.getAllocator( "DEVICE" ) ); - std::initializer_list< MemorySpace > const spaces = { MemorySpace::CPU, MemorySpace::GPU }; + std::initializer_list< MemorySpace > const spaces = { MemorySpace::host, MemorySpace::cuda }; std::initializer_list< umpire::Allocator > const allocators = { hostPool, devicePool }; #else - std::initializer_list< MemorySpace > const spaces = { MemorySpace::CPU }; + std::initializer_list< MemorySpace > const spaces = { MemorySpace::host }; std::initializer_list< umpire::Allocator > const allocators = { hostPool }; #endif ChaiBuffer< T > buffer( spaces, allocators ); int const size = 100; - buffer.reallocate( 0, MemorySpace::CPU, size ); + buffer.reallocate( 0, MemorySpace::host, size ); for( int i = 0; i < size; ++i ) { @@ -58,10 +58,10 @@ class ChaiBufferTest : public ::testing::Test EXPECT_EQ( rm.getAllocator( buffer.data() ).getName(), "HOST_pool" ); #if defined( LVARRAY_USE_CUDA ) - buffer.move( MemorySpace::GPU, true ); + buffer.move( MemorySpace::cuda, true ); EXPECT_EQ( rm.getAllocator( buffer.data() ).getName(), "DEVICE_pool" ); - buffer.move( MemorySpace::CPU, true ); + buffer.move( MemorySpace::host, true ); EXPECT_EQ( rm.getAllocator( buffer.data() ).getName(), "HOST_pool" ); #endif @@ -75,16 +75,16 @@ class ChaiBufferTest : public ::testing::Test ChaiBuffer< T > buffer( true ); int const size = 100; - buffer.reallocate( 0, MemorySpace::CPU, size ); - EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); + buffer.reallocate( 0, MemorySpace::host, size ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::host ); for( int i = 0; i < size; ++i ) { new ( &buffer[ i ] ) T( i ); } - buffer.move( MemorySpace::GPU, true ); - EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::GPU ); + buffer.move( MemorySpace::cuda, true ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::cuda ); T * const devPtr = buffer.data(); forall< parallelDevicePolicy< 32 > >( size, [devPtr] LVARRAY_DEVICE ( int const i ) @@ -93,23 +93,23 @@ class ChaiBufferTest : public ::testing::Test } ); // Check that the device changes are seen on the host. Then modify the values without touching. - buffer.move( MemorySpace::CPU, false ); - EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); + buffer.move( MemorySpace::host, false ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::host ); for( int i = 0; i < size; ++i ) { EXPECT_EQ( buffer[ i ], T( i ) + T( i ) ); buffer[ i ] = T( 0 ); } - buffer.move( MemorySpace::GPU, true ); - EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::GPU ); + buffer.move( MemorySpace::cuda, true ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::cuda ); forall< parallelDevicePolicy< 32 > >( size, [devPtr] LVARRAY_DEVICE ( int const i ) { devPtr[ i ] += devPtr[ i ]; } ); - buffer.move( MemorySpace::CPU, false ); - EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); + buffer.move( MemorySpace::host, false ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::host ); for( int i = 0; i < size; ++i ) { EXPECT_EQ( buffer[ i ], T( i ) + T( i ) + T( i ) + T( i ) ); @@ -123,8 +123,8 @@ class ChaiBufferTest : public ::testing::Test ChaiBuffer< T > buffer( true ); int const size = 100; - buffer.reallocate( 0, MemorySpace::CPU, size ); - EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); + buffer.reallocate( 0, MemorySpace::host, size ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::host ); for( int i = 0; i < size; ++i ) { @@ -136,7 +136,7 @@ class ChaiBufferTest : public ::testing::Test buffer[ i ] += buffer[ i ]; } ); - EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::GPU ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::cuda ); // Check that the device changes are seen on the host. Then modify the values without touching. @@ -147,23 +147,23 @@ class ChaiBufferTest : public ::testing::Test const_cast< T & >( constBuffer[ i ] ) = T( 0 ); } ); - EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); - EXPECT_EQ( constBuffer.getPreviousSpace(), MemorySpace::CPU ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::host ); + EXPECT_EQ( constBuffer.getPreviousSpace(), MemorySpace::host ); forall< parallelDevicePolicy< 32 > >( size, [buffer] LVARRAY_DEVICE ( int const i ) { buffer[ i ] += buffer[ i ]; } ); - EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::GPU ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::cuda ); forall< serialPolicy >( size, [constBuffer] ( int const i ) { EXPECT_EQ( constBuffer[ i ], T( i ) + T( i ) + T( i ) + T( i ) ); } ); - EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::CPU ); - EXPECT_EQ( constBuffer.getPreviousSpace(), MemorySpace::CPU ); + EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::host ); + EXPECT_EQ( constBuffer.getPreviousSpace(), MemorySpace::host ); bufferManipulation::free( buffer, size ); } @@ -173,7 +173,7 @@ class ChaiBufferTest : public ::testing::Test ChaiBuffer< T > buffer( true ); int const size = 100; - buffer.reallocate( 0, MemorySpace::GPU, size ); + buffer.reallocate( 0, MemorySpace::cuda, size ); T * const devPtr = buffer.data(); forall< parallelDevicePolicy< 32 > >( size, [devPtr] LVARRAY_DEVICE ( int const i ) @@ -181,7 +181,7 @@ class ChaiBufferTest : public ::testing::Test new ( &devPtr[ i ] ) T( i ); } ); - buffer.move( MemorySpace::CPU, true ); + buffer.move( MemorySpace::host, true ); for( int i = 0; i < size; ++i ) { EXPECT_EQ( buffer[ i ], T( i ) ); diff --git a/unitTests/testMemcpy.cpp b/unitTests/testMemcpy.cpp index 9e83ff2c..291500f5 100644 --- a/unitTests/testMemcpy.cpp +++ b/unitTests/testMemcpy.cpp @@ -155,7 +155,7 @@ void testMemcpyDevice() } Array< int, 1, RAJA::PERM_I, std::ptrdiff_t, BUFFER_TYPE > y( x.size() ); - y.move( MemorySpace::GPU ); + y.move( MemorySpace::cuda ); int * yPtr = y.data(); memcpy< 0, 0 >( y, {}, x.toViewConst(), {} ); @@ -175,7 +175,7 @@ void testMemcpyDevice() // Move y to the CPU but then capture and modify a view on device. This way y's data pointer is still pointing // to host memory but the subsequent memcpy should pick up that it's previous space is on device. - y.move( MemorySpace::CPU ); + y.move( MemorySpace::host ); ArrayView< int, 1, 0, std::ptrdiff_t, BUFFER_TYPE > const yView = y.toView(); forall< RAJA::cuda_exec< 32 > >( y.size(), [yView] LVARRAY_DEVICE ( std::ptrdiff_t const i ) @@ -204,7 +204,7 @@ void testAsyncMemcpyDevice() } Array< int, 1, RAJA::PERM_I, std::ptrdiff_t, BUFFER_TYPE > y( x.size() ); - y.move( MemorySpace::GPU ); + y.move( MemorySpace::cuda ); int * yPtr = y.data(); camp::resources::Event e = memcpy< 0, 0 >( stream, y.toView(), {}, x.toViewConst(), {} ); @@ -226,7 +226,7 @@ void testAsyncMemcpyDevice() // Move y to the CPU but then capture and modify a view on device. This way y's data pointer is still pointing // to host memory but the subsequent memcpy should pick up that it's previous space is on device. - y.move( MemorySpace::CPU ); + y.move( MemorySpace::host ); ArrayView< int, 1, 0, std::ptrdiff_t, BUFFER_TYPE > const yView = y.toView(); forall< RAJA::cuda_exec< 32 > >( y.size(), [yView] LVARRAY_DEVICE ( std::ptrdiff_t const i ) diff --git a/unitTests/testSortedArray.cpp b/unitTests/testSortedArray.cpp index 0d3c98df..f5ed0089 100644 --- a/unitTests/testSortedArray.cpp +++ b/unitTests/testSortedArray.cpp @@ -411,7 +411,7 @@ class SortedArrayViewTest : public SortedArrayTest< typename SORTED_ARRAY_POLICY ASSERT_EQ( m_set.size(), size ); // Move the array back to the host and check that the values haven't been overwritten. - m_set.move( MemorySpace::CPU ); + m_set.move( MemorySpace::host ); EXPECT_EQ( hostPointer, m_set.data() ); for( INDEX_TYPE i = 0; i < size; ++i ) { diff --git a/unitTests/testSortedArrayManipulation.cpp b/unitTests/testSortedArrayManipulation.cpp index 8079e064..afa51350 100644 --- a/unitTests/testSortedArrayManipulation.cpp +++ b/unitTests/testSortedArrayManipulation.cpp @@ -67,7 +67,7 @@ class SingleArrayTest : public ::testing::Test EXPECT_EQ( resultOfFirstIsSorted.get(), isInitiallySorted ); EXPECT_TRUE( resultOfSecondIsSorted.get() ); - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); checkEquality(); } } @@ -108,7 +108,7 @@ class SingleArrayTest : public ::testing::Test EXPECT_EQ( firstIsSortedUnique.get(), isInitiallySortedUnique ); EXPECT_TRUE( secondIsSortedUnique.get() ); - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); EXPECT_EQ( numUniqueValues.get(), m_ref.size() ); m_array.resize( numUniqueValues.get() ); @@ -139,7 +139,7 @@ class SingleArrayTest : public ::testing::Test numUniqueValues += sortedArrayManipulation::makeSortedUnique( view.begin(), view.end(), comp ); } ); - m_array.move( MemorySpace::CPU ); + m_array.move( MemorySpace::host ); EXPECT_EQ( numUniqueValues.get(), m_ref.size() ); m_array.resize( numUniqueValues.get() ); @@ -234,8 +234,8 @@ class DualArrayTest : public ::testing::Test dualSort( keys.begin(), keys.end(), values.begin(), comp ); } ); - m_keys.move( MemorySpace::CPU ); - m_values.move( MemorySpace::CPU ); + m_keys.move( MemorySpace::host ); + m_values.move( MemorySpace::host ); checkEquality(); } } diff --git a/unitTests/testSparsityPattern.cpp b/unitTests/testSparsityPattern.cpp index b557bb4b..2082bb00 100644 --- a/unitTests/testSparsityPattern.cpp +++ b/unitTests/testSparsityPattern.cpp @@ -809,7 +809,7 @@ class SparsityPatternViewTest : public SparsityPatternTest< typename SPARSITY_PA } } ); - m_sp.move( MemorySpace::CPU ); + m_sp.move( MemorySpace::host ); curIndex = 0; for( IndexType row = 0; row < numRows; ++row ) { @@ -849,7 +849,7 @@ class SparsityPatternViewTest : public SparsityPatternTest< typename SPARSITY_PA } // Move the SparsityPattern back from device, this should be a no-op. - m_sp.move( MemorySpace::CPU ); + m_sp.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -869,7 +869,7 @@ class SparsityPatternViewTest : public SparsityPatternTest< typename SPARSITY_PA } } ); - m_sp.move( MemorySpace::CPU ); + m_sp.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -886,7 +886,7 @@ class SparsityPatternViewTest : public SparsityPatternTest< typename SPARSITY_PA view.insertNonZeros( row, toInsertView[ row ].begin(), toInsertView[ row ].end() ); } ); - m_sp.move( MemorySpace::CPU ); + m_sp.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -906,7 +906,7 @@ class SparsityPatternViewTest : public SparsityPatternTest< typename SPARSITY_PA } } ); - m_sp.move( MemorySpace::CPU ); + m_sp.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -923,7 +923,7 @@ class SparsityPatternViewTest : public SparsityPatternTest< typename SPARSITY_PA view.removeNonZeros( row, toRemoveView[ row ].begin(), toRemoveView[ row ].end() ); } ); - m_sp.move( MemorySpace::CPU ); + m_sp.move( MemorySpace::host ); COMPARE_TO_REFERENCE } @@ -1125,7 +1125,7 @@ class CRSMatrixTest : public SparsityPatternTest< typename CRSMatrixToSparsityPa { CRS_MATRIX matrix; matrix.template assimilate< POLICY >( std::move( this->m_sp ) ); - matrix.move( MemorySpace::CPU ); + matrix.move( MemorySpace::host ); this->compareToReference( matrix.toSparsityPatternView() ); EXPECT_EQ( this->m_sp.numRows(), 0 ); diff --git a/unitTests/testTensorOpsEigen.cpp b/unitTests/testTensorOpsEigen.cpp index 212acd73..8b17d919 100644 --- a/unitTests/testTensorOpsEigen.cpp +++ b/unitTests/testTensorOpsEigen.cpp @@ -52,7 +52,7 @@ class TestEigendecomposition : public ::testing::Test T const maxValue = math::min( scale, end ); // Fill in the matrices - m_matrices.move( MemorySpace::CPU ); + m_matrices.move( MemorySpace::host ); for( T & value : m_matrices ) { value = randomValue( maxValue, m_gen ); } diff --git a/unitTests/testUtils.hpp b/unitTests/testUtils.hpp index 79b9aa52..6366ff30 100644 --- a/unitTests/testUtils.hpp +++ b/unitTests/testUtils.hpp @@ -42,7 +42,7 @@ struct RAJAHelper< serialPolicy > { using ReducePolicy = RAJA::seq_reduce; using AtomicPolicy = RAJA::seq_atomic; - static constexpr MemorySpace space = MemorySpace::CPU; + static constexpr MemorySpace space = MemorySpace::host; }; #if defined(RAJA_ENABLE_OPENMP) @@ -54,7 +54,7 @@ struct RAJAHelper< parallelHostPolicy > { using ReducePolicy = RAJA::omp_reduce; using AtomicPolicy = RAJA::omp_atomic; - static constexpr MemorySpace space = MemorySpace::CPU; + static constexpr MemorySpace space = MemorySpace::host; }; #endif @@ -69,7 +69,7 @@ struct RAJAHelper< RAJA::cuda_exec< N > > { using ReducePolicy = RAJA::cuda_reduce; using AtomicPolicy = RAJA::cuda_atomic; - static constexpr MemorySpace space = MemorySpace::GPU; + static constexpr MemorySpace space = MemorySpace::cuda; }; #endif From bc3013d27563a7bb4c6bbda337ef3664ee7e0004 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Wed, 28 Apr 2021 12:35:36 -0700 Subject: [PATCH 09/16] Copyright update. --- CMakeLists.txt | 7 +++ benchmarks/CMakeLists.txt | 45 +++++++++++-------- ...benchmarkArray1DR2TensorMultiplication.cpp | 2 +- ...rkArray1DR2TensorMultiplicationKernels.cpp | 2 +- ...rkArray1DR2TensorMultiplicationKernels.hpp | 2 +- ...ayOfArraysNodeToElementMapConstruction.cpp | 2 +- ...aysNodeToElementMapConstructionKernels.cpp | 2 +- ...aysNodeToElementMapConstructionKernels.hpp | 2 +- benchmarks/benchmarkArrayOfArraysReduce.cpp | 2 +- .../benchmarkArrayOfArraysReduceKernels.cpp | 2 +- .../benchmarkArrayOfArraysReduceKernels.hpp | 2 +- benchmarks/benchmarkEigendecomposition.cpp | 2 +- .../benchmarkEigendecompositionKernels.cpp | 2 +- .../benchmarkEigendecompositionKernels.hpp | 2 +- benchmarks/benchmarkHelpers.hpp | 2 +- benchmarks/benchmarkInnerProduct.cpp | 2 +- benchmarks/benchmarkInnerProductKernels.cpp | 2 +- benchmarks/benchmarkInnerProductKernels.hpp | 2 +- benchmarks/benchmarkMatrixMatrix.cpp | 2 +- benchmarks/benchmarkMatrixMatrixKernels.cpp | 2 +- benchmarks/benchmarkMatrixMatrixKernels.hpp | 2 +- benchmarks/benchmarkMatrixVector.cpp | 2 +- benchmarks/benchmarkMatrixVectorKernels.cpp | 2 +- benchmarks/benchmarkMatrixVectorKernels.hpp | 2 +- benchmarks/benchmarkOuterProduct.cpp | 2 +- benchmarks/benchmarkOuterProductKernels.cpp | 2 +- benchmarks/benchmarkOuterProductKernels.hpp | 2 +- benchmarks/benchmarkReduce.cpp | 2 +- benchmarks/benchmarkReduceKernels.cpp | 2 +- benchmarks/benchmarkReduceKernels.hpp | 2 +- benchmarks/benchmarkSparsityGeneration.cpp | 2 +- .../benchmarkSparsityGenerationKernels.cpp | 2 +- .../benchmarkSparsityGenerationKernels.hpp | 2 +- cmake/lvarray-config.cmake.in | 2 +- docs/CMakeLists.txt | 7 +++ docs/sphinx/Array.rst | 8 ++++ docs/sphinx/ArrayOfArrays.rst | 8 ++++ docs/sphinx/ArrayOfSets.rst | 8 ++++ docs/sphinx/CMakeLists.txt | 7 +++ docs/sphinx/SortedArray.rst | 8 ++++ docs/sphinx/SparsityPatternAndCRSMatrix.rst | 8 ++++ docs/sphinx/benchmarks.rst | 8 ++++ docs/sphinx/bufferClasses.rst | 8 ++++ docs/sphinx/buildGuide.rst | 8 ++++ docs/sphinx/developmentAids.rst | 8 ++++ docs/sphinx/extraThings.rst | 8 ++++ docs/sphinx/index.rst | 8 ++++ docs/sphinx/tensorOps.rst | 8 ++++ docs/sphinx/testing.rst | 8 ++++ examples/CMakeLists.txt | 7 +++ examples/Foo.hpp | 2 +- examples/exampleArray.cpp | 2 +- examples/exampleArrayOfArrays.cpp | 2 +- examples/exampleArrayOfSets.cpp | 2 +- examples/exampleBuffers.cpp | 2 +- examples/exampleSortedArray.cpp | 2 +- .../exampleSparsityPatternAndCRSMatrix.cpp | 2 +- examples/exampleTensorOps.cpp | 2 +- examples/exampleTestFoo.cpp | 2 +- scripts/gitlab/build_and_test.sh | 4 +- src/Array.hpp | 2 +- src/ArrayOfArrays.hpp | 2 +- src/ArrayOfArraysView.hpp | 2 +- src/ArrayOfSets.hpp | 2 +- src/ArrayOfSetsView.hpp | 2 +- src/ArraySlice.hpp | 2 +- src/ArrayView.hpp | 2 +- src/CMakeLists.txt | 7 +++ src/CRSMatrix.hpp | 2 +- src/CRSMatrixView.hpp | 2 +- src/ChaiBuffer.hpp | 2 +- src/LvArrayConfig.hpp.in | 2 +- src/Macros.hpp | 2 +- src/MallocBuffer.hpp | 2 +- src/SortedArray.hpp | 2 +- src/SortedArrayView.hpp | 2 +- src/SparsityPattern.hpp | 2 +- src/SparsityPatternView.hpp | 2 +- src/StackBuffer.hpp | 2 +- src/arrayManipulation.hpp | 2 +- src/bufferManipulation.hpp | 2 +- src/fixedSizeSquareMatrixOps.hpp | 2 +- src/fixedSizeSquareMatrixOpsImpl.hpp | 2 +- src/genericTensorOps.hpp | 2 +- src/indexing.hpp | 2 +- src/input.hpp | 2 +- src/limits.hpp | 2 +- src/math.hpp | 2 +- src/memcpy.hpp | 2 +- src/output.hpp | 2 +- src/sliceHelpers.hpp | 2 +- src/sortedArrayManipulation.hpp | 2 +- src/sortedArrayManipulationHelpers.hpp | 2 +- src/system.cpp | 2 +- src/system.hpp | 2 +- src/tensorOps.hpp | 2 +- src/totalview/tv_helpers.hpp | 2 +- src/typeManipulation.hpp | 2 +- src/umpireInterface.cpp | 2 +- src/umpireInterface.hpp | 2 +- unitTests/CMakeLists.txt | 7 +++ unitTests/testArray.hpp | 2 +- unitTests/testArray1D.cpp | 2 +- unitTests/testArray1DOfArray1D.cpp | 2 +- unitTests/testArray1DOfArray1DOfArray1D.cpp | 2 +- unitTests/testArrayOfArrays.cpp | 2 +- unitTests/testArrayOfSets.cpp | 2 +- unitTests/testArraySlice.cpp | 2 +- unitTests/testArrayView.hpp | 2 +- .../testArrayView_copyAssignmentOperator.cpp | 2 +- unitTests/testArrayView_copyConstructor.cpp | 2 +- .../testArrayView_defaultConstructor.cpp | 2 +- unitTests/testArrayView_emptyMove.cpp | 2 +- unitTests/testArrayView_modifyInKernel.cpp | 2 +- .../testArrayView_modifyInMultipleKernels.cpp | 2 +- unitTests/testArrayView_move.cpp | 2 +- unitTests/testArrayView_moveMultipleTimes.cpp | 2 +- unitTests/testArrayView_moveNoTouch.cpp | 2 +- unitTests/testArrayView_readInKernel.cpp | 2 +- unitTests/testArrayView_setValues.cpp | 2 +- unitTests/testArrayView_setValuesFromView.cpp | 2 +- unitTests/testArrayView_toSlice.cpp | 2 +- unitTests/testArrayView_toSliceConst.cpp | 2 +- unitTests/testArrayView_toView.cpp | 2 +- unitTests/testArrayView_toViewConst.cpp | 2 +- unitTests/testArrayView_typeConversion.cpp | 2 +- unitTests/testArrayView_udcToSlice.cpp | 2 +- unitTests/testArrayView_udcToSliceConst.cpp | 2 +- unitTests/testArrayView_udcToViewConst.cpp | 2 +- unitTests/testArrayView_zero.cpp | 2 +- unitTests/testArray_ChaiBuffer.cpp | 2 +- unitTests/testArray_clear.cpp | 2 +- .../testArray_copyAssignmentOperator.cpp | 2 +- unitTests/testArray_copyConstructor.cpp | 2 +- unitTests/testArray_defaultConstructor.cpp | 2 +- ...Array_getSetSingleParameterResizeIndex.cpp | 2 +- unitTests/testArray_indexing.cpp | 2 +- .../testArray_moveAssignmentOperator.cpp | 2 +- unitTests/testArray_moveConstructor.cpp | 2 +- unitTests/testArray_reserveAndCapacity.cpp | 2 +- unitTests/testArray_resize.cpp | 2 +- unitTests/testArray_resizeDefault.cpp | 2 +- unitTests/testArray_resizeDimension.cpp | 2 +- unitTests/testArray_resizeFromArgs.cpp | 2 +- unitTests/testArray_resizeFromPointer.cpp | 2 +- ...sizeWithoutInitializationOrDestruction.cpp | 2 +- unitTests/testArray_sizedConstructor.cpp | 2 +- unitTests/testArray_toView.cpp | 2 +- unitTests/testArray_toViewConst.cpp | 2 +- unitTests/testBuffers.cpp | 2 +- unitTests/testCRSMatrix.cpp | 2 +- unitTests/testChaiBuffer.cpp | 2 +- unitTests/testFloatingPointExceptions.cpp | 2 +- .../testFloatingPointExceptionsHelpers.cpp | 2 +- .../testFloatingPointExceptionsHelpers.hpp | 2 +- unitTests/testIndexing.cpp | 2 +- unitTests/testInput.cpp | 2 +- unitTests/testIntegerConversion.cpp | 2 +- unitTests/testInvalidOperations.cpp | 2 +- unitTests/testMath.cpp | 2 +- unitTests/testMemcpy.cpp | 2 +- unitTests/testSliceHelpers.cpp | 2 +- unitTests/testSortedArray.cpp | 2 +- unitTests/testSortedArrayManipulation.cpp | 2 +- unitTests/testSparsityPattern.cpp | 2 +- unitTests/testStackArray.cpp | 2 +- unitTests/testStackTrace.cpp | 2 +- unitTests/testTensorOps.cpp | 2 +- unitTests/testTensorOpsCommon.hpp | 2 +- unitTests/testTensorOpsDeterminant.cpp | 2 +- unitTests/testTensorOpsEigen.cpp | 2 +- unitTests/testTensorOpsFixedSize.cpp | 2 +- unitTests/testTensorOpsInverse.hpp | 2 +- unitTests/testTensorOpsInverseOneArg.cpp | 2 +- unitTests/testTensorOpsInverseTwoArgs.cpp | 2 +- unitTests/testTensorOpsNoSize.cpp | 2 +- unitTests/testTensorOpsOneSize.cpp | 2 +- unitTests/testTensorOpsSymDeterminant.cpp | 2 +- unitTests/testTensorOpsSymInverseOneArg.cpp | 2 +- unitTests/testTensorOpsSymInverseTwoArgs.cpp | 2 +- unitTests/testTensorOpsThreeSizes.hpp | 2 +- unitTests/testTensorOpsThreeSizes1.cpp | 2 +- unitTests/testTensorOpsThreeSizes2.cpp | 2 +- unitTests/testTensorOpsThreeSizes3.cpp | 2 +- unitTests/testTensorOpsThreeSizes4.cpp | 2 +- unitTests/testTensorOpsThreeSizes5.cpp | 2 +- unitTests/testTensorOpsThreeSizes6.cpp | 2 +- unitTests/testTensorOpsTwoSizes.hpp | 2 +- unitTests/testTensorOpsTwoSizes1.cpp | 2 +- unitTests/testTensorOpsTwoSizes2.cpp | 2 +- unitTests/testTensorOpsTwoSizes3.cpp | 2 +- unitTests/testTensorOpsTwoSizes4.cpp | 2 +- unitTests/testTypeManipulation.cpp | 2 +- unitTests/testUtils.hpp | 2 +- 194 files changed, 347 insertions(+), 194 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d211e6a6..3939fd37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,10 @@ +################################################################################################### +# Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. +# All rights reserved. +# See the LICENSE file for details. +# SPDX-License-Identifier: (BSD-3-Clause) +################################################################################################### + cmake_minimum_required( VERSION 3.9 ) # Set version number diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 4c6cd9b9..30df8f2a 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -1,27 +1,34 @@ +################################################################################################### +# Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. +# All rights reserved. +# See the LICENSE file for details. +# SPDX-License-Identifier: (BSD-3-Clause) +################################################################################################### + # -# Specify list of tests +# Specify list of benchmarks # -set(benchmarkSources - benchmarkReduce.cpp - benchmarkInnerProduct.cpp - benchmarkOuterProduct.cpp - benchmarkMatrixVector.cpp - benchmarkMatrixMatrix.cpp - benchmarkArray1DR2TensorMultiplication.cpp - benchmarkSparsityGeneration.cpp - benchmarkArrayOfArraysReduce.cpp - benchmarkArrayOfArraysNodeToElementMapConstruction.cpp - benchmarkEigendecomposition.cpp +set( benchmarkSources + benchmarkReduce.cpp + benchmarkInnerProduct.cpp + benchmarkOuterProduct.cpp + benchmarkMatrixVector.cpp + benchmarkMatrixMatrix.cpp + benchmarkArray1DR2TensorMultiplication.cpp + benchmarkSparsityGeneration.cpp + benchmarkArrayOfArraysReduce.cpp + benchmarkArrayOfArraysNodeToElementMapConstruction.cpp + benchmarkEigendecomposition.cpp ) -if (NOT ${ENABLE_BENCHMARKS}) +if( NOT ${ENABLE_BENCHMARKS} ) message(FATAL_ERROR "Benchmarks not enabled!") endif() # -# Add gtest C++ based tests +# Add benchmarks # -foreach(benchmark ${benchmarkSources}) +foreach( benchmark ${benchmarkSources} ) get_filename_component( benchmark_name ${benchmark} NAME_WE ) blt_add_executable( NAME ${benchmark_name} SOURCES ${benchmark} ${benchmark_name}Kernels.cpp @@ -33,10 +40,10 @@ foreach(benchmark ${benchmarkSources}) # blt_add_target_compile_flags( TO ${benchmark_name} # FLAGS -fsave-optimization-record ) - blt_add_benchmark(NAME ${benchmark_name} - COMMAND ${benchmark_name}) + blt_add_benchmark( NAME ${benchmark_name} + COMMAND ${benchmark_name} ) - install(TARGETS ${benchmark_name} - DESTINATION bin) + install( TARGETS ${benchmark_name} + DESTINATION bin ) endforeach() diff --git a/benchmarks/benchmarkArray1DR2TensorMultiplication.cpp b/benchmarks/benchmarkArray1DR2TensorMultiplication.cpp index e1dbec1d..2efb794d 100644 --- a/benchmarks/benchmarkArray1DR2TensorMultiplication.cpp +++ b/benchmarks/benchmarkArray1DR2TensorMultiplication.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.cpp b/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.cpp index 667f8f92..9b0afe0f 100644 --- a/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.cpp +++ b/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.hpp b/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.hpp index d5beaaaa..848ccb06 100644 --- a/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.hpp +++ b/benchmarks/benchmarkArray1DR2TensorMultiplicationKernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstruction.cpp b/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstruction.cpp index 0449ac06..eabb1cf1 100644 --- a/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstruction.cpp +++ b/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstruction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstructionKernels.cpp b/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstructionKernels.cpp index 678332d3..051cee25 100644 --- a/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstructionKernels.cpp +++ b/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstructionKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstructionKernels.hpp b/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstructionKernels.hpp index 376d777a..b1f02ba4 100644 --- a/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstructionKernels.hpp +++ b/benchmarks/benchmarkArrayOfArraysNodeToElementMapConstructionKernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkArrayOfArraysReduce.cpp b/benchmarks/benchmarkArrayOfArraysReduce.cpp index 97c90a87..f96591c1 100644 --- a/benchmarks/benchmarkArrayOfArraysReduce.cpp +++ b/benchmarks/benchmarkArrayOfArraysReduce.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkArrayOfArraysReduceKernels.cpp b/benchmarks/benchmarkArrayOfArraysReduceKernels.cpp index bb6ef963..e6c1d82f 100644 --- a/benchmarks/benchmarkArrayOfArraysReduceKernels.cpp +++ b/benchmarks/benchmarkArrayOfArraysReduceKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkArrayOfArraysReduceKernels.hpp b/benchmarks/benchmarkArrayOfArraysReduceKernels.hpp index 27d475a9..8672d688 100644 --- a/benchmarks/benchmarkArrayOfArraysReduceKernels.hpp +++ b/benchmarks/benchmarkArrayOfArraysReduceKernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkEigendecomposition.cpp b/benchmarks/benchmarkEigendecomposition.cpp index 0fb610e2..15131ef3 100644 --- a/benchmarks/benchmarkEigendecomposition.cpp +++ b/benchmarks/benchmarkEigendecomposition.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkEigendecompositionKernels.cpp b/benchmarks/benchmarkEigendecompositionKernels.cpp index e2add3d5..3e0be19e 100644 --- a/benchmarks/benchmarkEigendecompositionKernels.cpp +++ b/benchmarks/benchmarkEigendecompositionKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkEigendecompositionKernels.hpp b/benchmarks/benchmarkEigendecompositionKernels.hpp index 9721e81e..b42d8728 100644 --- a/benchmarks/benchmarkEigendecompositionKernels.hpp +++ b/benchmarks/benchmarkEigendecompositionKernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkHelpers.hpp b/benchmarks/benchmarkHelpers.hpp index 564b4592..0e1e8a1c 100644 --- a/benchmarks/benchmarkHelpers.hpp +++ b/benchmarks/benchmarkHelpers.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkInnerProduct.cpp b/benchmarks/benchmarkInnerProduct.cpp index 58f268e7..d027d089 100644 --- a/benchmarks/benchmarkInnerProduct.cpp +++ b/benchmarks/benchmarkInnerProduct.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkInnerProductKernels.cpp b/benchmarks/benchmarkInnerProductKernels.cpp index c7f03ce3..929c0e06 100644 --- a/benchmarks/benchmarkInnerProductKernels.cpp +++ b/benchmarks/benchmarkInnerProductKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkInnerProductKernels.hpp b/benchmarks/benchmarkInnerProductKernels.hpp index 1c5a7e14..5b426f36 100644 --- a/benchmarks/benchmarkInnerProductKernels.hpp +++ b/benchmarks/benchmarkInnerProductKernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkMatrixMatrix.cpp b/benchmarks/benchmarkMatrixMatrix.cpp index 53ba54c7..a47dde9f 100644 --- a/benchmarks/benchmarkMatrixMatrix.cpp +++ b/benchmarks/benchmarkMatrixMatrix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkMatrixMatrixKernels.cpp b/benchmarks/benchmarkMatrixMatrixKernels.cpp index c7ec661c..1b2e5f9a 100644 --- a/benchmarks/benchmarkMatrixMatrixKernels.cpp +++ b/benchmarks/benchmarkMatrixMatrixKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkMatrixMatrixKernels.hpp b/benchmarks/benchmarkMatrixMatrixKernels.hpp index 14a01f95..b7e2860e 100644 --- a/benchmarks/benchmarkMatrixMatrixKernels.hpp +++ b/benchmarks/benchmarkMatrixMatrixKernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkMatrixVector.cpp b/benchmarks/benchmarkMatrixVector.cpp index 1aba47cf..cdcbd7c1 100644 --- a/benchmarks/benchmarkMatrixVector.cpp +++ b/benchmarks/benchmarkMatrixVector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkMatrixVectorKernels.cpp b/benchmarks/benchmarkMatrixVectorKernels.cpp index de118a3e..014dadf0 100644 --- a/benchmarks/benchmarkMatrixVectorKernels.cpp +++ b/benchmarks/benchmarkMatrixVectorKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkMatrixVectorKernels.hpp b/benchmarks/benchmarkMatrixVectorKernels.hpp index efdacd46..06f22e0b 100644 --- a/benchmarks/benchmarkMatrixVectorKernels.hpp +++ b/benchmarks/benchmarkMatrixVectorKernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkOuterProduct.cpp b/benchmarks/benchmarkOuterProduct.cpp index 61bd6e7b..692fefc0 100644 --- a/benchmarks/benchmarkOuterProduct.cpp +++ b/benchmarks/benchmarkOuterProduct.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkOuterProductKernels.cpp b/benchmarks/benchmarkOuterProductKernels.cpp index 91eab27b..59116315 100644 --- a/benchmarks/benchmarkOuterProductKernels.cpp +++ b/benchmarks/benchmarkOuterProductKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkOuterProductKernels.hpp b/benchmarks/benchmarkOuterProductKernels.hpp index 38c7fbc0..f880a681 100644 --- a/benchmarks/benchmarkOuterProductKernels.hpp +++ b/benchmarks/benchmarkOuterProductKernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkReduce.cpp b/benchmarks/benchmarkReduce.cpp index 1e6458e0..81cd4b56 100644 --- a/benchmarks/benchmarkReduce.cpp +++ b/benchmarks/benchmarkReduce.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkReduceKernels.cpp b/benchmarks/benchmarkReduceKernels.cpp index a0b29b1a..82899998 100644 --- a/benchmarks/benchmarkReduceKernels.cpp +++ b/benchmarks/benchmarkReduceKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkReduceKernels.hpp b/benchmarks/benchmarkReduceKernels.hpp index ca53e77b..121d0bb6 100644 --- a/benchmarks/benchmarkReduceKernels.hpp +++ b/benchmarks/benchmarkReduceKernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkSparsityGeneration.cpp b/benchmarks/benchmarkSparsityGeneration.cpp index 44580df8..6909dd50 100644 --- a/benchmarks/benchmarkSparsityGeneration.cpp +++ b/benchmarks/benchmarkSparsityGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkSparsityGenerationKernels.cpp b/benchmarks/benchmarkSparsityGenerationKernels.cpp index d3f8cc2c..9fafbd58 100644 --- a/benchmarks/benchmarkSparsityGenerationKernels.cpp +++ b/benchmarks/benchmarkSparsityGenerationKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/benchmarks/benchmarkSparsityGenerationKernels.hpp b/benchmarks/benchmarkSparsityGenerationKernels.hpp index 272dd8a2..e8448070 100644 --- a/benchmarks/benchmarkSparsityGenerationKernels.hpp +++ b/benchmarks/benchmarkSparsityGenerationKernels.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/cmake/lvarray-config.cmake.in b/cmake/lvarray-config.cmake.in index 88dde0ed..70ae7113 100644 --- a/cmake/lvarray-config.cmake.in +++ b/cmake/lvarray-config.cmake.in @@ -1,5 +1,5 @@ ######################################################################################### -# Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. +# Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. # All rights reserved. # See the LICENSE file for details. # SPDX-License-Identifier: (BSD-3-Clause) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index eb4b2c94..fdf37f50 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,3 +1,10 @@ +################################################################################################### +# Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. +# All rights reserved. +# See the LICENSE file for details. +# SPDX-License-Identifier: (BSD-3-Clause) +################################################################################################### + ################################ # documentation targets ################################ diff --git a/docs/sphinx/Array.rst b/docs/sphinx/Array.rst index 5cc47b89..e2294bf8 100644 --- a/docs/sphinx/Array.rst +++ b/docs/sphinx/Array.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############################################################################### ``LvArray::Array`` ############################################################################### diff --git a/docs/sphinx/ArrayOfArrays.rst b/docs/sphinx/ArrayOfArrays.rst index 683a66be..10c6676e 100644 --- a/docs/sphinx/ArrayOfArrays.rst +++ b/docs/sphinx/ArrayOfArrays.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############################################################################### ``LvArray::ArrayOfArrays`` ############################################################################### diff --git a/docs/sphinx/ArrayOfSets.rst b/docs/sphinx/ArrayOfSets.rst index 38d4762d..5c5a0ff9 100644 --- a/docs/sphinx/ArrayOfSets.rst +++ b/docs/sphinx/ArrayOfSets.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############################################################################### ``LvArray::ArrayOfSets`` ############################################################################### diff --git a/docs/sphinx/CMakeLists.txt b/docs/sphinx/CMakeLists.txt index 845a8bca..b02955d2 100644 --- a/docs/sphinx/CMakeLists.txt +++ b/docs/sphinx/CMakeLists.txt @@ -1 +1,8 @@ +################################################################################################### +# Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. +# All rights reserved. +# See the LICENSE file for details. +# SPDX-License-Identifier: (BSD-3-Clause) +################################################################################################### + blt_add_sphinx_target( LvArray_docs ) diff --git a/docs/sphinx/SortedArray.rst b/docs/sphinx/SortedArray.rst index d81969ba..829b5f76 100644 --- a/docs/sphinx/SortedArray.rst +++ b/docs/sphinx/SortedArray.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ######################## ``LvArray::SortedArray`` ######################## diff --git a/docs/sphinx/SparsityPatternAndCRSMatrix.rst b/docs/sphinx/SparsityPatternAndCRSMatrix.rst index 26cd2694..ebb41830 100644 --- a/docs/sphinx/SparsityPatternAndCRSMatrix.rst +++ b/docs/sphinx/SparsityPatternAndCRSMatrix.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############################################################################### ``LvArray::SparsityPattern`` and ``LvArray::CRSMatrix`` ############################################################################### diff --git a/docs/sphinx/benchmarks.rst b/docs/sphinx/benchmarks.rst index 661f3a64..a5ca9033 100644 --- a/docs/sphinx/benchmarks.rst +++ b/docs/sphinx/benchmarks.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############################################################################### Benchmarking (Coming soon) ############################################################################### diff --git a/docs/sphinx/bufferClasses.rst b/docs/sphinx/bufferClasses.rst index ffed9818..0bde53b4 100644 --- a/docs/sphinx/bufferClasses.rst +++ b/docs/sphinx/bufferClasses.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############## Buffer Classes ############## diff --git a/docs/sphinx/buildGuide.rst b/docs/sphinx/buildGuide.rst index d5542ca5..a260f7bd 100644 --- a/docs/sphinx/buildGuide.rst +++ b/docs/sphinx/buildGuide.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############################################################################### Build Guide ############################################################################### diff --git a/docs/sphinx/developmentAids.rst b/docs/sphinx/developmentAids.rst index 486c9521..01a77b03 100644 --- a/docs/sphinx/developmentAids.rst +++ b/docs/sphinx/developmentAids.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############################################################################### Development Aids (Coming soon) ############################################################################### diff --git a/docs/sphinx/extraThings.rst b/docs/sphinx/extraThings.rst index fda3c33a..aa757c06 100644 --- a/docs/sphinx/extraThings.rst +++ b/docs/sphinx/extraThings.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############################################################################### Extra Goodies (Coming soon) ############################################################################### diff --git a/docs/sphinx/index.rst b/docs/sphinx/index.rst index 8d8d3196..827d9cf6 100644 --- a/docs/sphinx/index.rst +++ b/docs/sphinx/index.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + LvArray ======= diff --git a/docs/sphinx/tensorOps.rst b/docs/sphinx/tensorOps.rst index ca732263..537124de 100644 --- a/docs/sphinx/tensorOps.rst +++ b/docs/sphinx/tensorOps.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############################################################################### ``LvArray::tensorOps`` ############################################################################### diff --git a/docs/sphinx/testing.rst b/docs/sphinx/testing.rst index 5f1e8d4e..760363e3 100644 --- a/docs/sphinx/testing.rst +++ b/docs/sphinx/testing.rst @@ -1,3 +1,11 @@ +.. ## +.. ## Copyright (c) 2021, Lawrence Livermore National Security, LLC +.. ## and LvArray project contributors. See the LICENCE file +.. ## for details. +.. ## +.. ## SPDX-License-Identifier: (BSD-3-Clause) +.. ## + ############################################################################### Testing ############################################################################### diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 2e1f657e..c30209ba 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,10 @@ +################################################################################################### +# Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. +# All rights reserved. +# See the LICENSE file for details. +# SPDX-License-Identifier: (BSD-3-Clause) +################################################################################################### + # # Specify list of tests # diff --git a/examples/Foo.hpp b/examples/Foo.hpp index cab36eb7..602511d5 100644 --- a/examples/Foo.hpp +++ b/examples/Foo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/examples/exampleArray.cpp b/examples/exampleArray.cpp index 510a38b6..2a22aeee 100644 --- a/examples/exampleArray.cpp +++ b/examples/exampleArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/examples/exampleArrayOfArrays.cpp b/examples/exampleArrayOfArrays.cpp index 7c8fa6f0..2eff3155 100644 --- a/examples/exampleArrayOfArrays.cpp +++ b/examples/exampleArrayOfArrays.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/examples/exampleArrayOfSets.cpp b/examples/exampleArrayOfSets.cpp index 72af3bf1..64206df1 100644 --- a/examples/exampleArrayOfSets.cpp +++ b/examples/exampleArrayOfSets.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/examples/exampleBuffers.cpp b/examples/exampleBuffers.cpp index ee3b5876..57555896 100644 --- a/examples/exampleBuffers.cpp +++ b/examples/exampleBuffers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/examples/exampleSortedArray.cpp b/examples/exampleSortedArray.cpp index 252b10cd..7d20a312 100644 --- a/examples/exampleSortedArray.cpp +++ b/examples/exampleSortedArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/examples/exampleSparsityPatternAndCRSMatrix.cpp b/examples/exampleSparsityPatternAndCRSMatrix.cpp index 4f47eb12..473c90ea 100644 --- a/examples/exampleSparsityPatternAndCRSMatrix.cpp +++ b/examples/exampleSparsityPatternAndCRSMatrix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/examples/exampleTensorOps.cpp b/examples/exampleTensorOps.cpp index 7cb21aee..ad3e4dc2 100644 --- a/examples/exampleTensorOps.cpp +++ b/examples/exampleTensorOps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/examples/exampleTestFoo.cpp b/examples/exampleTestFoo.cpp index dd50318a..fbd20b31 100644 --- a/examples/exampleTestFoo.cpp +++ b/examples/exampleTestFoo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/scripts/gitlab/build_and_test.sh b/scripts/gitlab/build_and_test.sh index 347ef892..063a0baf 100755 --- a/scripts/gitlab/build_and_test.sh +++ b/scripts/gitlab/build_and_test.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash ############################################################################### -# Copyright (c) 2016-21, Lawrence Livermore National Security, LLC -# and RAJA project contributors. See the RAJA/COPYRIGHT file for details. +# Copyright (c) 2021, Lawrence Livermore National Security, LLC +# and LvArray project contributors. See the LICENCE file for details. # # SPDX-License-Identifier: (BSD-3-Clause) ############################################################################### diff --git a/src/Array.hpp b/src/Array.hpp index fc9524f4..7c103c85 100644 --- a/src/Array.hpp +++ b/src/Array.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/ArrayOfArrays.hpp b/src/ArrayOfArrays.hpp index d8dc079c..1ce2231e 100644 --- a/src/ArrayOfArrays.hpp +++ b/src/ArrayOfArrays.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/ArrayOfArraysView.hpp b/src/ArrayOfArraysView.hpp index 4099a20b..7aebc595 100644 --- a/src/ArrayOfArraysView.hpp +++ b/src/ArrayOfArraysView.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/ArrayOfSets.hpp b/src/ArrayOfSets.hpp index e585e297..c8b75190 100644 --- a/src/ArrayOfSets.hpp +++ b/src/ArrayOfSets.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/ArrayOfSetsView.hpp b/src/ArrayOfSetsView.hpp index 8b295027..e5d1d2b6 100644 --- a/src/ArrayOfSetsView.hpp +++ b/src/ArrayOfSetsView.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/ArraySlice.hpp b/src/ArraySlice.hpp index 18591ad5..8ce5db24 100644 --- a/src/ArraySlice.hpp +++ b/src/ArraySlice.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/ArrayView.hpp b/src/ArrayView.hpp index db311391..e12668b7 100644 --- a/src/ArrayView.hpp +++ b/src/ArrayView.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad629fc0..a85c36bd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,10 @@ +################################################################################################### +# Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. +# All rights reserved. +# See the LICENSE file for details. +# SPDX-License-Identifier: (BSD-3-Clause) +################################################################################################### + set( lvarray_headers Array.hpp ArrayOfArrays.hpp diff --git a/src/CRSMatrix.hpp b/src/CRSMatrix.hpp index 642774aa..ddd786c5 100644 --- a/src/CRSMatrix.hpp +++ b/src/CRSMatrix.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/CRSMatrixView.hpp b/src/CRSMatrixView.hpp index 8b9f7a56..b0e10f77 100644 --- a/src/CRSMatrixView.hpp +++ b/src/CRSMatrixView.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/ChaiBuffer.hpp b/src/ChaiBuffer.hpp index 20919bbc..7a3bfd5f 100644 --- a/src/ChaiBuffer.hpp +++ b/src/ChaiBuffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/LvArrayConfig.hpp.in b/src/LvArrayConfig.hpp.in index 16e44b04..2c997ab5 100644 --- a/src/LvArrayConfig.hpp.in +++ b/src/LvArrayConfig.hpp.in @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/Macros.hpp b/src/Macros.hpp index 9ae73669..24788617 100644 --- a/src/Macros.hpp +++ b/src/Macros.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/MallocBuffer.hpp b/src/MallocBuffer.hpp index 836d3c4c..f40051ae 100644 --- a/src/MallocBuffer.hpp +++ b/src/MallocBuffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/SortedArray.hpp b/src/SortedArray.hpp index aa5ff056..58ea36f2 100644 --- a/src/SortedArray.hpp +++ b/src/SortedArray.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/SortedArrayView.hpp b/src/SortedArrayView.hpp index a7a61530..ab7ca790 100644 --- a/src/SortedArrayView.hpp +++ b/src/SortedArrayView.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/SparsityPattern.hpp b/src/SparsityPattern.hpp index 00a98241..652d5e56 100644 --- a/src/SparsityPattern.hpp +++ b/src/SparsityPattern.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/SparsityPatternView.hpp b/src/SparsityPatternView.hpp index 8f0a4706..b2fa19a6 100644 --- a/src/SparsityPatternView.hpp +++ b/src/SparsityPatternView.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/StackBuffer.hpp b/src/StackBuffer.hpp index 831a3643..f18795ec 100644 --- a/src/StackBuffer.hpp +++ b/src/StackBuffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/arrayManipulation.hpp b/src/arrayManipulation.hpp index 94718233..9cf25ee9 100644 --- a/src/arrayManipulation.hpp +++ b/src/arrayManipulation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/bufferManipulation.hpp b/src/bufferManipulation.hpp index 7d921037..8a620dd8 100644 --- a/src/bufferManipulation.hpp +++ b/src/bufferManipulation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/fixedSizeSquareMatrixOps.hpp b/src/fixedSizeSquareMatrixOps.hpp index af553fc8..c61e4a9e 100644 --- a/src/fixedSizeSquareMatrixOps.hpp +++ b/src/fixedSizeSquareMatrixOps.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/fixedSizeSquareMatrixOpsImpl.hpp b/src/fixedSizeSquareMatrixOpsImpl.hpp index cfceb6d7..f006d866 100644 --- a/src/fixedSizeSquareMatrixOpsImpl.hpp +++ b/src/fixedSizeSquareMatrixOpsImpl.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/genericTensorOps.hpp b/src/genericTensorOps.hpp index 1fdd67a9..a0ce1269 100644 --- a/src/genericTensorOps.hpp +++ b/src/genericTensorOps.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/indexing.hpp b/src/indexing.hpp index a2ce89ff..2dca4597 100644 --- a/src/indexing.hpp +++ b/src/indexing.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/input.hpp b/src/input.hpp index 3636ec15..fde15d56 100644 --- a/src/input.hpp +++ b/src/input.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/limits.hpp b/src/limits.hpp index 670dcb29..9a551042 100644 --- a/src/limits.hpp +++ b/src/limits.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/math.hpp b/src/math.hpp index 54b4062e..7fed344b 100644 --- a/src/math.hpp +++ b/src/math.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/memcpy.hpp b/src/memcpy.hpp index dafcf78e..bf1e3564 100644 --- a/src/memcpy.hpp +++ b/src/memcpy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/output.hpp b/src/output.hpp index 1941ffcd..93b93bf0 100644 --- a/src/output.hpp +++ b/src/output.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/sliceHelpers.hpp b/src/sliceHelpers.hpp index ea75e413..38dec145 100644 --- a/src/sliceHelpers.hpp +++ b/src/sliceHelpers.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/sortedArrayManipulation.hpp b/src/sortedArrayManipulation.hpp index 609fd809..7e9cae5d 100644 --- a/src/sortedArrayManipulation.hpp +++ b/src/sortedArrayManipulation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/sortedArrayManipulationHelpers.hpp b/src/sortedArrayManipulationHelpers.hpp index 1c3e13be..be6765b3 100644 --- a/src/sortedArrayManipulationHelpers.hpp +++ b/src/sortedArrayManipulationHelpers.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/system.cpp b/src/system.cpp index 7b236015..019fe665 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/system.hpp b/src/system.hpp index 42bf5017..59a77526 100644 --- a/src/system.hpp +++ b/src/system.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/tensorOps.hpp b/src/tensorOps.hpp index faae3492..b48975f1 100644 --- a/src/tensorOps.hpp +++ b/src/tensorOps.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/totalview/tv_helpers.hpp b/src/totalview/tv_helpers.hpp index e3683483..4e9ef376 100644 --- a/src/totalview/tv_helpers.hpp +++ b/src/totalview/tv_helpers.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/typeManipulation.hpp b/src/typeManipulation.hpp index c7c79957..3a2ec2ac 100644 --- a/src/typeManipulation.hpp +++ b/src/typeManipulation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/umpireInterface.cpp b/src/umpireInterface.cpp index 458b4fee..6dd9bfbc 100644 --- a/src/umpireInterface.cpp +++ b/src/umpireInterface.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/src/umpireInterface.hpp b/src/umpireInterface.hpp index 88769308..2ec8c0aa 100644 --- a/src/umpireInterface.hpp +++ b/src/umpireInterface.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 91971b13..208def73 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -1,3 +1,10 @@ +################################################################################################### +# Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. +# All rights reserved. +# See the LICENSE file for details. +# SPDX-License-Identifier: (BSD-3-Clause) +################################################################################################### + # # Specify list of tests # diff --git a/unitTests/testArray.hpp b/unitTests/testArray.hpp index 4ee9dcb8..f6254d10 100644 --- a/unitTests/testArray.hpp +++ b/unitTests/testArray.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray1D.cpp b/unitTests/testArray1D.cpp index 96a8e2e5..cddb18fc 100644 --- a/unitTests/testArray1D.cpp +++ b/unitTests/testArray1D.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray1DOfArray1D.cpp b/unitTests/testArray1DOfArray1D.cpp index b3710747..faa53b52 100644 --- a/unitTests/testArray1DOfArray1D.cpp +++ b/unitTests/testArray1DOfArray1D.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray1DOfArray1DOfArray1D.cpp b/unitTests/testArray1DOfArray1DOfArray1D.cpp index f161c19a..5dc93fe8 100644 --- a/unitTests/testArray1DOfArray1DOfArray1D.cpp +++ b/unitTests/testArray1DOfArray1DOfArray1D.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayOfArrays.cpp b/unitTests/testArrayOfArrays.cpp index c21c1e8b..de2f6bb8 100644 --- a/unitTests/testArrayOfArrays.cpp +++ b/unitTests/testArrayOfArrays.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayOfSets.cpp b/unitTests/testArrayOfSets.cpp index 72c623ed..364a2d0d 100644 --- a/unitTests/testArrayOfSets.cpp +++ b/unitTests/testArrayOfSets.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArraySlice.cpp b/unitTests/testArraySlice.cpp index 832467cc..c2c8a61b 100644 --- a/unitTests/testArraySlice.cpp +++ b/unitTests/testArraySlice.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView.hpp b/unitTests/testArrayView.hpp index 17016b2a..961723b8 100644 --- a/unitTests/testArrayView.hpp +++ b/unitTests/testArrayView.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_copyAssignmentOperator.cpp b/unitTests/testArrayView_copyAssignmentOperator.cpp index 89b372e0..050d2e7e 100644 --- a/unitTests/testArrayView_copyAssignmentOperator.cpp +++ b/unitTests/testArrayView_copyAssignmentOperator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_copyConstructor.cpp b/unitTests/testArrayView_copyConstructor.cpp index 7024a88e..11079d21 100644 --- a/unitTests/testArrayView_copyConstructor.cpp +++ b/unitTests/testArrayView_copyConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_defaultConstructor.cpp b/unitTests/testArrayView_defaultConstructor.cpp index 1581aa5d..43ba5a50 100644 --- a/unitTests/testArrayView_defaultConstructor.cpp +++ b/unitTests/testArrayView_defaultConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_emptyMove.cpp b/unitTests/testArrayView_emptyMove.cpp index ee9e37aa..2a5f1f04 100644 --- a/unitTests/testArrayView_emptyMove.cpp +++ b/unitTests/testArrayView_emptyMove.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_modifyInKernel.cpp b/unitTests/testArrayView_modifyInKernel.cpp index 7e9e2c6e..897b419b 100644 --- a/unitTests/testArrayView_modifyInKernel.cpp +++ b/unitTests/testArrayView_modifyInKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_modifyInMultipleKernels.cpp b/unitTests/testArrayView_modifyInMultipleKernels.cpp index db08239f..8c5938a5 100644 --- a/unitTests/testArrayView_modifyInMultipleKernels.cpp +++ b/unitTests/testArrayView_modifyInMultipleKernels.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_move.cpp b/unitTests/testArrayView_move.cpp index 0b3b907f..84e46b72 100644 --- a/unitTests/testArrayView_move.cpp +++ b/unitTests/testArrayView_move.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_moveMultipleTimes.cpp b/unitTests/testArrayView_moveMultipleTimes.cpp index 778c78df..c41199a5 100644 --- a/unitTests/testArrayView_moveMultipleTimes.cpp +++ b/unitTests/testArrayView_moveMultipleTimes.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_moveNoTouch.cpp b/unitTests/testArrayView_moveNoTouch.cpp index 9625ceec..d45c77e7 100644 --- a/unitTests/testArrayView_moveNoTouch.cpp +++ b/unitTests/testArrayView_moveNoTouch.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_readInKernel.cpp b/unitTests/testArrayView_readInKernel.cpp index a453e629..b2cce782 100644 --- a/unitTests/testArrayView_readInKernel.cpp +++ b/unitTests/testArrayView_readInKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_setValues.cpp b/unitTests/testArrayView_setValues.cpp index 1567982e..d07eb146 100644 --- a/unitTests/testArrayView_setValues.cpp +++ b/unitTests/testArrayView_setValues.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_setValuesFromView.cpp b/unitTests/testArrayView_setValuesFromView.cpp index 1a93c5a0..8cd7975a 100644 --- a/unitTests/testArrayView_setValuesFromView.cpp +++ b/unitTests/testArrayView_setValuesFromView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_toSlice.cpp b/unitTests/testArrayView_toSlice.cpp index 63de6a45..b6dba70e 100644 --- a/unitTests/testArrayView_toSlice.cpp +++ b/unitTests/testArrayView_toSlice.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_toSliceConst.cpp b/unitTests/testArrayView_toSliceConst.cpp index 1e64d563..3e6ce47d 100644 --- a/unitTests/testArrayView_toSliceConst.cpp +++ b/unitTests/testArrayView_toSliceConst.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_toView.cpp b/unitTests/testArrayView_toView.cpp index e79de36b..11994ad8 100644 --- a/unitTests/testArrayView_toView.cpp +++ b/unitTests/testArrayView_toView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_toViewConst.cpp b/unitTests/testArrayView_toViewConst.cpp index a5ef44c9..c2e8b31f 100644 --- a/unitTests/testArrayView_toViewConst.cpp +++ b/unitTests/testArrayView_toViewConst.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_typeConversion.cpp b/unitTests/testArrayView_typeConversion.cpp index 4afc89dd..4c5b64a1 100644 --- a/unitTests/testArrayView_typeConversion.cpp +++ b/unitTests/testArrayView_typeConversion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_udcToSlice.cpp b/unitTests/testArrayView_udcToSlice.cpp index fb2050f9..b2ca05d7 100644 --- a/unitTests/testArrayView_udcToSlice.cpp +++ b/unitTests/testArrayView_udcToSlice.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_udcToSliceConst.cpp b/unitTests/testArrayView_udcToSliceConst.cpp index 8f7fa423..e0f1b8a1 100644 --- a/unitTests/testArrayView_udcToSliceConst.cpp +++ b/unitTests/testArrayView_udcToSliceConst.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_udcToViewConst.cpp b/unitTests/testArrayView_udcToViewConst.cpp index 099ad4ac..15cf9454 100644 --- a/unitTests/testArrayView_udcToViewConst.cpp +++ b/unitTests/testArrayView_udcToViewConst.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArrayView_zero.cpp b/unitTests/testArrayView_zero.cpp index 2a283671..36164e75 100644 --- a/unitTests/testArrayView_zero.cpp +++ b/unitTests/testArrayView_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_ChaiBuffer.cpp b/unitTests/testArray_ChaiBuffer.cpp index 95c37f8c..48641f58 100644 --- a/unitTests/testArray_ChaiBuffer.cpp +++ b/unitTests/testArray_ChaiBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_clear.cpp b/unitTests/testArray_clear.cpp index e6e42c34..d628a97e 100644 --- a/unitTests/testArray_clear.cpp +++ b/unitTests/testArray_clear.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_copyAssignmentOperator.cpp b/unitTests/testArray_copyAssignmentOperator.cpp index e6a62cdc..dc4c654f 100644 --- a/unitTests/testArray_copyAssignmentOperator.cpp +++ b/unitTests/testArray_copyAssignmentOperator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_copyConstructor.cpp b/unitTests/testArray_copyConstructor.cpp index e3d90d51..e7a0efc0 100644 --- a/unitTests/testArray_copyConstructor.cpp +++ b/unitTests/testArray_copyConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_defaultConstructor.cpp b/unitTests/testArray_defaultConstructor.cpp index c89559c6..276cc3fb 100644 --- a/unitTests/testArray_defaultConstructor.cpp +++ b/unitTests/testArray_defaultConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_getSetSingleParameterResizeIndex.cpp b/unitTests/testArray_getSetSingleParameterResizeIndex.cpp index 318281c4..ad5e857e 100644 --- a/unitTests/testArray_getSetSingleParameterResizeIndex.cpp +++ b/unitTests/testArray_getSetSingleParameterResizeIndex.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_indexing.cpp b/unitTests/testArray_indexing.cpp index 12e093f4..b8163086 100644 --- a/unitTests/testArray_indexing.cpp +++ b/unitTests/testArray_indexing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_moveAssignmentOperator.cpp b/unitTests/testArray_moveAssignmentOperator.cpp index f688e71b..0952c661 100644 --- a/unitTests/testArray_moveAssignmentOperator.cpp +++ b/unitTests/testArray_moveAssignmentOperator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_moveConstructor.cpp b/unitTests/testArray_moveConstructor.cpp index e3d90d51..e7a0efc0 100644 --- a/unitTests/testArray_moveConstructor.cpp +++ b/unitTests/testArray_moveConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_reserveAndCapacity.cpp b/unitTests/testArray_reserveAndCapacity.cpp index 2c353c9d..800663f1 100644 --- a/unitTests/testArray_reserveAndCapacity.cpp +++ b/unitTests/testArray_reserveAndCapacity.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_resize.cpp b/unitTests/testArray_resize.cpp index b04c2dc9..903b8a19 100644 --- a/unitTests/testArray_resize.cpp +++ b/unitTests/testArray_resize.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_resizeDefault.cpp b/unitTests/testArray_resizeDefault.cpp index 7a85b737..63d7f820 100644 --- a/unitTests/testArray_resizeDefault.cpp +++ b/unitTests/testArray_resizeDefault.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_resizeDimension.cpp b/unitTests/testArray_resizeDimension.cpp index 838820b1..f0da9b7d 100644 --- a/unitTests/testArray_resizeDimension.cpp +++ b/unitTests/testArray_resizeDimension.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_resizeFromArgs.cpp b/unitTests/testArray_resizeFromArgs.cpp index 45b557aa..0360065e 100644 --- a/unitTests/testArray_resizeFromArgs.cpp +++ b/unitTests/testArray_resizeFromArgs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_resizeFromPointer.cpp b/unitTests/testArray_resizeFromPointer.cpp index f7f06edb..140b1793 100644 --- a/unitTests/testArray_resizeFromPointer.cpp +++ b/unitTests/testArray_resizeFromPointer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_resizeWithoutInitializationOrDestruction.cpp b/unitTests/testArray_resizeWithoutInitializationOrDestruction.cpp index 055e0e68..efa11d57 100644 --- a/unitTests/testArray_resizeWithoutInitializationOrDestruction.cpp +++ b/unitTests/testArray_resizeWithoutInitializationOrDestruction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_sizedConstructor.cpp b/unitTests/testArray_sizedConstructor.cpp index 2cfc3dd9..0dd937c9 100644 --- a/unitTests/testArray_sizedConstructor.cpp +++ b/unitTests/testArray_sizedConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_toView.cpp b/unitTests/testArray_toView.cpp index 5031318b..8df55fdb 100644 --- a/unitTests/testArray_toView.cpp +++ b/unitTests/testArray_toView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testArray_toViewConst.cpp b/unitTests/testArray_toViewConst.cpp index 9aa31f86..373d2415 100644 --- a/unitTests/testArray_toViewConst.cpp +++ b/unitTests/testArray_toViewConst.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testBuffers.cpp b/unitTests/testBuffers.cpp index 94c5f317..e98c8230 100644 --- a/unitTests/testBuffers.cpp +++ b/unitTests/testBuffers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testCRSMatrix.cpp b/unitTests/testCRSMatrix.cpp index 1270df11..987aa4e9 100644 --- a/unitTests/testCRSMatrix.cpp +++ b/unitTests/testCRSMatrix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testChaiBuffer.cpp b/unitTests/testChaiBuffer.cpp index 6a047789..6d1a6965 100644 --- a/unitTests/testChaiBuffer.cpp +++ b/unitTests/testChaiBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testFloatingPointExceptions.cpp b/unitTests/testFloatingPointExceptions.cpp index a5dcfdca..be6c6684 100644 --- a/unitTests/testFloatingPointExceptions.cpp +++ b/unitTests/testFloatingPointExceptions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testFloatingPointExceptionsHelpers.cpp b/unitTests/testFloatingPointExceptionsHelpers.cpp index a9a13f95..eb6385e7 100644 --- a/unitTests/testFloatingPointExceptionsHelpers.cpp +++ b/unitTests/testFloatingPointExceptionsHelpers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testFloatingPointExceptionsHelpers.hpp b/unitTests/testFloatingPointExceptionsHelpers.hpp index 4eae88e1..b7ba10a6 100644 --- a/unitTests/testFloatingPointExceptionsHelpers.hpp +++ b/unitTests/testFloatingPointExceptionsHelpers.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testIndexing.cpp b/unitTests/testIndexing.cpp index bbf313f8..2f472149 100644 --- a/unitTests/testIndexing.cpp +++ b/unitTests/testIndexing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testInput.cpp b/unitTests/testInput.cpp index d929d7ad..d7194773 100644 --- a/unitTests/testInput.cpp +++ b/unitTests/testInput.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testIntegerConversion.cpp b/unitTests/testIntegerConversion.cpp index 3dce8d8f..1efddb13 100644 --- a/unitTests/testIntegerConversion.cpp +++ b/unitTests/testIntegerConversion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testInvalidOperations.cpp b/unitTests/testInvalidOperations.cpp index 1b907ef6..b421fffa 100644 --- a/unitTests/testInvalidOperations.cpp +++ b/unitTests/testInvalidOperations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testMath.cpp b/unitTests/testMath.cpp index 5405d90c..adc38467 100644 --- a/unitTests/testMath.cpp +++ b/unitTests/testMath.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testMemcpy.cpp b/unitTests/testMemcpy.cpp index 291500f5..49d83964 100644 --- a/unitTests/testMemcpy.cpp +++ b/unitTests/testMemcpy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testSliceHelpers.cpp b/unitTests/testSliceHelpers.cpp index ec9fdfd3..45fae9a9 100644 --- a/unitTests/testSliceHelpers.cpp +++ b/unitTests/testSliceHelpers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testSortedArray.cpp b/unitTests/testSortedArray.cpp index f5ed0089..5198bd24 100644 --- a/unitTests/testSortedArray.cpp +++ b/unitTests/testSortedArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testSortedArrayManipulation.cpp b/unitTests/testSortedArrayManipulation.cpp index afa51350..2090b515 100644 --- a/unitTests/testSortedArrayManipulation.cpp +++ b/unitTests/testSortedArrayManipulation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testSparsityPattern.cpp b/unitTests/testSparsityPattern.cpp index 2082bb00..50ec30f9 100644 --- a/unitTests/testSparsityPattern.cpp +++ b/unitTests/testSparsityPattern.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testStackArray.cpp b/unitTests/testStackArray.cpp index a0cb69cf..e6a3552f 100644 --- a/unitTests/testStackArray.cpp +++ b/unitTests/testStackArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testStackTrace.cpp b/unitTests/testStackTrace.cpp index 2c39e1f5..47a43aff 100644 --- a/unitTests/testStackTrace.cpp +++ b/unitTests/testStackTrace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOps.cpp b/unitTests/testTensorOps.cpp index 8ffc39a7..f5d450e2 100644 --- a/unitTests/testTensorOps.cpp +++ b/unitTests/testTensorOps.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsCommon.hpp b/unitTests/testTensorOpsCommon.hpp index c2a5f48d..e2d8a923 100644 --- a/unitTests/testTensorOpsCommon.hpp +++ b/unitTests/testTensorOpsCommon.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsDeterminant.cpp b/unitTests/testTensorOpsDeterminant.cpp index 04d07029..398f2051 100644 --- a/unitTests/testTensorOpsDeterminant.cpp +++ b/unitTests/testTensorOpsDeterminant.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsEigen.cpp b/unitTests/testTensorOpsEigen.cpp index 8b17d919..46ff354d 100644 --- a/unitTests/testTensorOpsEigen.cpp +++ b/unitTests/testTensorOpsEigen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsFixedSize.cpp b/unitTests/testTensorOpsFixedSize.cpp index ce863288..e66fd5a3 100644 --- a/unitTests/testTensorOpsFixedSize.cpp +++ b/unitTests/testTensorOpsFixedSize.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsInverse.hpp b/unitTests/testTensorOpsInverse.hpp index 81804028..4909a686 100644 --- a/unitTests/testTensorOpsInverse.hpp +++ b/unitTests/testTensorOpsInverse.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsInverseOneArg.cpp b/unitTests/testTensorOpsInverseOneArg.cpp index cd959c69..757e9787 100644 --- a/unitTests/testTensorOpsInverseOneArg.cpp +++ b/unitTests/testTensorOpsInverseOneArg.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsInverseTwoArgs.cpp b/unitTests/testTensorOpsInverseTwoArgs.cpp index 8930d874..b42ea56a 100644 --- a/unitTests/testTensorOpsInverseTwoArgs.cpp +++ b/unitTests/testTensorOpsInverseTwoArgs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsNoSize.cpp b/unitTests/testTensorOpsNoSize.cpp index f22a35b7..b08e5ae1 100644 --- a/unitTests/testTensorOpsNoSize.cpp +++ b/unitTests/testTensorOpsNoSize.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsOneSize.cpp b/unitTests/testTensorOpsOneSize.cpp index 76e8751e..fc351c75 100644 --- a/unitTests/testTensorOpsOneSize.cpp +++ b/unitTests/testTensorOpsOneSize.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsSymDeterminant.cpp b/unitTests/testTensorOpsSymDeterminant.cpp index 7c28ca63..175b8fd1 100644 --- a/unitTests/testTensorOpsSymDeterminant.cpp +++ b/unitTests/testTensorOpsSymDeterminant.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsSymInverseOneArg.cpp b/unitTests/testTensorOpsSymInverseOneArg.cpp index c53f24bb..1ae0d710 100644 --- a/unitTests/testTensorOpsSymInverseOneArg.cpp +++ b/unitTests/testTensorOpsSymInverseOneArg.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsSymInverseTwoArgs.cpp b/unitTests/testTensorOpsSymInverseTwoArgs.cpp index d6b53a0d..aa6835da 100644 --- a/unitTests/testTensorOpsSymInverseTwoArgs.cpp +++ b/unitTests/testTensorOpsSymInverseTwoArgs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsThreeSizes.hpp b/unitTests/testTensorOpsThreeSizes.hpp index 2450c304..5a27092a 100644 --- a/unitTests/testTensorOpsThreeSizes.hpp +++ b/unitTests/testTensorOpsThreeSizes.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsThreeSizes1.cpp b/unitTests/testTensorOpsThreeSizes1.cpp index 9fe8a517..92d9e59f 100644 --- a/unitTests/testTensorOpsThreeSizes1.cpp +++ b/unitTests/testTensorOpsThreeSizes1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsThreeSizes2.cpp b/unitTests/testTensorOpsThreeSizes2.cpp index 26ebb892..b4303fc6 100644 --- a/unitTests/testTensorOpsThreeSizes2.cpp +++ b/unitTests/testTensorOpsThreeSizes2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsThreeSizes3.cpp b/unitTests/testTensorOpsThreeSizes3.cpp index 9acf86bc..9d80b487 100644 --- a/unitTests/testTensorOpsThreeSizes3.cpp +++ b/unitTests/testTensorOpsThreeSizes3.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsThreeSizes4.cpp b/unitTests/testTensorOpsThreeSizes4.cpp index 54731a3b..0905f8f0 100644 --- a/unitTests/testTensorOpsThreeSizes4.cpp +++ b/unitTests/testTensorOpsThreeSizes4.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsThreeSizes5.cpp b/unitTests/testTensorOpsThreeSizes5.cpp index 9d975e09..2811a719 100644 --- a/unitTests/testTensorOpsThreeSizes5.cpp +++ b/unitTests/testTensorOpsThreeSizes5.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsThreeSizes6.cpp b/unitTests/testTensorOpsThreeSizes6.cpp index 7b0f9056..68d11758 100644 --- a/unitTests/testTensorOpsThreeSizes6.cpp +++ b/unitTests/testTensorOpsThreeSizes6.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsTwoSizes.hpp b/unitTests/testTensorOpsTwoSizes.hpp index 3e2d6b30..07978011 100644 --- a/unitTests/testTensorOpsTwoSizes.hpp +++ b/unitTests/testTensorOpsTwoSizes.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsTwoSizes1.cpp b/unitTests/testTensorOpsTwoSizes1.cpp index 32e90d07..7f5a97d5 100644 --- a/unitTests/testTensorOpsTwoSizes1.cpp +++ b/unitTests/testTensorOpsTwoSizes1.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsTwoSizes2.cpp b/unitTests/testTensorOpsTwoSizes2.cpp index 044a247f..9befb4ba 100644 --- a/unitTests/testTensorOpsTwoSizes2.cpp +++ b/unitTests/testTensorOpsTwoSizes2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsTwoSizes3.cpp b/unitTests/testTensorOpsTwoSizes3.cpp index a6b00df4..2b4f6285 100644 --- a/unitTests/testTensorOpsTwoSizes3.cpp +++ b/unitTests/testTensorOpsTwoSizes3.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTensorOpsTwoSizes4.cpp b/unitTests/testTensorOpsTwoSizes4.cpp index 58aa5dc2..a0f4ac5a 100644 --- a/unitTests/testTensorOpsTwoSizes4.cpp +++ b/unitTests/testTensorOpsTwoSizes4.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testTypeManipulation.cpp b/unitTests/testTypeManipulation.cpp index 700dad59..ad842958 100644 --- a/unitTests/testTypeManipulation.cpp +++ b/unitTests/testTypeManipulation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) diff --git a/unitTests/testUtils.hpp b/unitTests/testUtils.hpp index 6366ff30..98e96d22 100644 --- a/unitTests/testUtils.hpp +++ b/unitTests/testUtils.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Lawrence Livermore National Security, LLC and LvArray contributors. + * Copyright (c) 2021, Lawrence Livermore National Security, LLC and LvArray contributors. * All rights reserved. * See the LICENSE file for details. * SPDX-License-Identifier: (BSD-3-Clause) From 043259b6bd718e12b1db66c87e5fa2c027660742 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Wed, 28 Apr 2021 12:35:51 -0700 Subject: [PATCH 10/16] Spack and release changes. --- CMakeLists.txt | 48 +++++++++----- RELEASE_NOTES.md | 24 ++++++- cmake/CMakeBasics.cmake | 2 +- cmake/lvarray-config.cmake.in | 15 +++-- scripts/uberenv/packages/lvarray/package.py | 28 ++++++--- .../blueos_3_ppc64le_ib_p9/compilers.yaml | 41 ++++-------- .../blueos_3_ppc64le_ib_p9/packages.yaml | 9 +++ .../compilers.yaml | 62 +------------------ .../packages.yaml | 11 +++- .../toss_3_x86_64_ib/compilers.yaml | 27 ++++++-- .../toss_3_x86_64_ib/packages.yaml | 4 +- .../toss_3_x86_64_ib_python/packages.yaml | 2 +- src/CMakeLists.txt | 3 +- src/python/CMakeLists.txt | 14 ++++- unitTests/CMakeLists.txt | 2 +- unitTests/python/CMakeLists.txt | 7 +-- unitTests/testArrayView_typeConversion.cpp | 2 +- 17 files changed, 161 insertions(+), 140 deletions(-) mode change 100644 => 120000 scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/compilers.yaml diff --git a/CMakeLists.txt b/CMakeLists.txt index 3939fd37..addd478e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ cmake_minimum_required( VERSION 3.9 ) # Set version number set( LVARRAY_VERSION_MAJOR 0 ) -set( LVARRAY_VERSION_MINOR 1 ) +set( LVARRAY_VERSION_MINOR 2 ) set( LVARRAY_VERSION_PATCHLEVEL 0 ) # check if LvArray is build as a submodule or a separate project @@ -39,33 +39,49 @@ if( NOT is_submodule ) option( ENABLE_CHAI "Build with CHAI" OFF ) option( ENABLE_CALIPER "Build with Caliper" OFF ) - include( cmake/blt/SetupBLT.cmake ) + if( NOT BLT_LOADED ) + if( DEFINED BLT_SOURCE_DIR ) + if( NOT EXISTS ${BLT_SOURCE_DIR}/SetupBLT.cmake ) + message( FATAL_ERROR "Given BLT_SOURCE_DIR does not contain SetupBLT.cmake" ) + endif() + else () + set( BLT_SOURCE_DIR ${PROJECT_SOURCE_DIR}/cmake/blt CACHE PATH "" ) + + if( NOT EXISTS ${BLT_SOURCE_DIR}/SetupBLT.cmake ) + message( FATAL_ERROR "The BLT submodule is not present. If in git repository run the following two commands:\n \ + git submodule init\n \ + git submodule update" ) + endif () + endif () + + include( ${BLT_SOURCE_DIR}/SetupBLT.cmake ) + endif() + include( cmake/CMakeBasics.cmake ) include( cmake/SetupTPL.cmake ) else() + if( NOT BLT_LOADED ) + message( FATAL_ERROR "When using LvArray as a submodule you must have already loaded BLT." ) + endif() + include( cmake/CMakeBasics.cmake ) endif() -include(cmake/Macros.cmake) -include(cmake/Config.cmake) +include( cmake/Macros.cmake ) +include( cmake/Config.cmake ) set( lvarray_dependencies dl ) -if( ENABLE_CHAI ) - set( lvarray_dependencies ${lvarray_dependencies} chai umpire ) -endif() +blt_list_append( TO lvarray_dependencies ELEMENTS camp RAJA ) -if( ENABLE_CUDA ) - set( lvarray_dependencies ${lvarray_dependencies} cuda ) -endif() +blt_list_append( TO lvarray_dependencies ELEMENTS umpire IF ENABLE_UMPIRE ) -if( ENABLE_RAJA ) - set( lvarray_dependencies ${lvarray_dependencies} RAJA ) -endif() +blt_list_append( TO lvarray_dependencies ELEMENTS chai IF ENABLE_CHAI ) + +blt_list_append( TO lvarray_dependencies ELEMENTS cuda IF ENABLE_CUDA ) + +blt_list_append( TO lvarray_dependencies ELEMENTS caliper IF ENABLE_CALIPER ) -if( ENABLE_CALIPER ) - set( lvarray_dependencies ${lvarray_dependencies} caliper ) -endif() add_subdirectory( src ) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ad9f4f40..65edec6f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -2,13 +2,33 @@ Version vxx.yy.zz -- Release date 20yy-mm-dd ============================================ * New features: - * Added various tensorOps functions. - * Added a Python interface to most container classes. + +* API Changes: + +* Build changes/improvements: + +* Bug fixes: + +Version v0.2.0 -- Release date 2020-04-30 +============================================ + +* New features: + * Various tensorOps functions. + * A Python library with interfaces to most container classes. + * Can create an `Array` that begins life on the device. + * Can create an `Array` with specific Umpire allocators. + * Math functions for CUDA's `__half` and `__half2`. + * Better CUDA error messages. + * Added in wrappers around Umpire's `memcpy` and `memset`. * API Changes: * You will now get a compilation error when performing certain undefined operations on rvalues, for example calling `toView` on an `Array` rvalue. + * Now use `camp::resources::Platform` for `MemorySpace`. * Build changes/improvements: + * config-build.py works with Python3. + * Support for object libraries via the CMake variable `LVARRAY_BUILD_OBJ_LIBS`. + * Support for RAJA 0.13. * Bug fixes: * Fixed an indexing bug that produced a compilation error with GCC 10. diff --git a/cmake/CMakeBasics.cmake b/cmake/CMakeBasics.cmake index 711067aa..3b78353f 100644 --- a/cmake/CMakeBasics.cmake +++ b/cmake/CMakeBasics.cmake @@ -9,7 +9,7 @@ endif() option( ENABLE_TOTALVIEW_OUTPUT "" OFF ) -set( LVARRAY_BUILD_OBJ_LIBS TRUE CACHE BOOL "" ) +set( LVARRAY_BUILD_OBJ_LIBS OFF CACHE BOOL "" ) if( NOT BLT_CXX_STD STREQUAL c++14 ) diff --git a/cmake/lvarray-config.cmake.in b/cmake/lvarray-config.cmake.in index 70ae7113..8f7c3c55 100644 --- a/cmake/lvarray-config.cmake.in +++ b/cmake/lvarray-config.cmake.in @@ -5,12 +5,15 @@ # SPDX-License-Identifier: (BSD-3-Clause) ######################################################################################### -if (NOT LVARRAY_CONFIG_LOADED) - set(LVARRAY_CONFIG_LOADED TRUE) - include(@CMAKE_INSTALL_PREFIX@/share/lvarray/cmake/lvarray.cmake) +if( NOT LVARRAY_CONFIG_LOADED ) + set( LVARRAY_CONFIG_LOADED TRUE ) + include( @CMAKE_INSTALL_PREFIX@/share/lvarray/cmake/lvarray.cmake ) + if( @ENABLE_PYLVARRAY@ ) + include( @CMAKE_INSTALL_PREFIX@/share/lvarray/cmake/pylvarray.cmake ) + endif() endif() # Export version number -set(LVARRAY_VERSION_MAJOR @LVARRAY_VERSION_MAJOR@) -set(LVARRAY_VERSION_MINOR @LVARRAY_VERSION_MINOR@) -set(LVARRAY_VERSION_PATCHLEVEL @LVARRAY_VERSION_PATCHLEVEL@) +set( LVARRAY_VERSION_MAJOR @LVARRAY_VERSION_MAJOR@ ) +set( LVARRAY_VERSION_MINOR @LVARRAY_VERSION_MINOR@ ) +set( LVARRAY_VERSION_PATCHLEVEL @LVARRAY_VERSION_PATCHLEVEL@ ) diff --git a/scripts/uberenv/packages/lvarray/package.py b/scripts/uberenv/packages/lvarray/package.py index b8e2ff74..41ef991b 100644 --- a/scripts/uberenv/packages/lvarray/package.py +++ b/scripts/uberenv/packages/lvarray/package.py @@ -38,9 +38,10 @@ class Lvarray(CMakePackage, CudaPackage): homepage = "https://github.com/GEOSX/lvarray" git = "https://github.com/GEOSX/LvArray.git" - version('develop', branch='develop', submodules='True') - version('main', branch='main', submodules='True') - version('0.1.0', tag='v0.1.0', submodules='True') + version('develop', branch='develop', submodules=False) + version('main', branch='main', submodules=False) + version('0.2.0', tag='v0.2.0', submodules=False) + version('0.1.0', tag='v0.1.0', submodules=True) variant('shared', default=True, description='Build Shared Libs') variant('umpire', default=False, description='Build Umpire support') @@ -54,8 +55,7 @@ class Lvarray(CMakePackage, CudaPackage): variant('addr2line', default=True, description='Build support for addr2line.') - depends_on('cmake@3.8:', type='build') - depends_on('cmake@3.9:', when='+cuda', type='build') + depends_on('blt', when='@0.2.0:', type='build') depends_on('camp') depends_on('camp+cuda', when='+cuda') @@ -74,7 +74,7 @@ class Lvarray(CMakePackage, CudaPackage): depends_on('python +shared +pic', when='+pylvarray') depends_on('py-numpy@1.19: +blas +lapack +force-parallel-build', when='+pylvarray') - depends_on('py-scipy@1.5.2: +force-parallel-build', when='+pylvarray') + # depends_on('py-scipy@1.5.2: +force-parallel-build', when='+pylvarray') depends_on('py-pip', when='+pylvarray') depends_on('doxygen@1.8.13:', when='+docs', type='build') @@ -167,6 +167,9 @@ def hostconfig(self, spec, prefix, py_site_pkgs_dir=None): cfg.write("# CMake executable path: %s\n" % cmake_exe) cfg.write("#{0}\n\n".format("-" * 80)) + if 'blt' in spec: + cfg.write(cmake_cache_entry('BLT_SOURCE_DIR', spec['blt'].prefix)) + ####################### # Compiler Settings ####################### @@ -179,10 +182,15 @@ def hostconfig(self, spec, prefix, py_site_pkgs_dir=None): # use global spack compiler flags cflags = ' '.join(spec.compiler_flags['cflags']) + cxxflags = ' '.join(spec.compiler_flags['cxxflags']) + + if "%intel" in spec: + cflags += ' -qoverride-limits' + cxxflags += ' -qoverride-limits' + if cflags: cfg.write(cmake_cache_entry("CMAKE_C_FLAGS", cflags)) - cxxflags = ' '.join(spec.compiler_flags['cxxflags']) if cxxflags: cfg.write(cmake_cache_entry("CMAKE_CXX_FLAGS", cxxflags)) @@ -195,6 +203,9 @@ def hostconfig(self, spec, prefix, py_site_pkgs_dir=None): debug_flags = "-O0 -g" cfg.write(cmake_cache_string("CMAKE_CXX_FLAGS_DEBUG", debug_flags)) + if "%clang arch=linux-rhel7-ppc64le" in spec: + cfg.write(cmake_cache_entry("CMAKE_EXE_LINKER_FLAGS", "-Wl,--no-toc-optimize")) + if "+cuda" in spec: cfg.write("#{0}\n".format("-" * 80)) cfg.write("# Cuda\n") @@ -294,6 +305,7 @@ def hostconfig(self, spec, prefix, py_site_pkgs_dir=None): cfg.write("# Documentation\n") cfg.write("#{0}\n\n".format("-" * 80)) if "+docs" in spec: + cfg.write(cmake_cache_option("ENABLE_DOCS", True)) sphinx_dir = spec['py-sphinx'].prefix cfg.write(cmake_cache_string('SPHINX_EXECUTABLE', os.path.join(sphinx_dir, @@ -305,6 +317,8 @@ def hostconfig(self, spec, prefix, py_site_pkgs_dir=None): os.path.join(doxygen_dir, 'bin', 'doxygen'))) + else: + cfg.write(cmake_cache_option("ENABLE_DOCS", False)) cfg.write("#{0}\n".format("-" * 80)) cfg.write("# addr2line\n") diff --git a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/compilers.yaml b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/compilers.yaml index defa2b1c..b1bf26cb 100644 --- a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/compilers.yaml +++ b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/compilers.yaml @@ -1,26 +1,11 @@ compilers: -- compiler: - spec: clang@9.0.0 - paths: - cc: /usr/tce/packages/clang/clang-upstream-2019.08.15/bin/clang - cxx: /usr/tce/packages/clang/clang-upstream-2019.08.15/bin/clang++ - f77: - fc: - flags: - cflags: -mcpu=native -mtune=native - cxxflags: -mcpu=native -mtune=native - operating_system: rhel7 - target: ppc64le - modules: [] - environment: {} - extra_rpaths: [] - compiler: spec: clang@10.0.1 paths: cc: /usr/tce/packages/clang/clang-ibm-10.0.1/bin/clang cxx: /usr/tce/packages/clang/clang-ibm-10.0.1/bin/clang++ - f77: - fc: + f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran + fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran flags: cflags: -mcpu=native -mtune=native cxxflags: -mcpu=native -mtune=native @@ -30,12 +15,12 @@ compilers: environment: {} extra_rpaths: [] - compiler: - spec: clang@11.0.0 + spec: clang@11.0.1 paths: - cc: /usr/tce/packages/clang/clang-ibm-11.0.0/bin/clang - cxx: /usr/tce/packages/clang/clang-ibm-11.0.0/bin/clang++ - f77: - fc: + cc: /usr/tce/packages/clang/clang-ibm-11.0.1/bin/clang + cxx: /usr/tce/packages/clang/clang-ibm-11.0.1/bin/clang++ + f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran + fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran flags: cflags: -mcpu=native -mtune=native cxxflags: -mcpu=native -mtune=native @@ -49,8 +34,8 @@ compilers: paths: cc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gcc cxx: /usr/tce/packages/gcc/gcc-8.3.1/bin/g++ - f77: - fc: + f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran + fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran flags: cflags: -mcpu=native -mtune=native cxxflags: -mcpu=native -mtune=native @@ -62,10 +47,10 @@ compilers: - compiler: spec: xl@16.1.1 paths: - cc: /usr/tce/packages/xl/xl-2020.09.17-cuda-11.0.2/bin/xlc - cxx: /usr/tce/packages/xl/xl-2020.09.17-cuda-11.0.2/bin/xlC - f77: - fc: + cc: /usr/tce/packages/xl/xl-2021.03.11/bin/xlc + cxx: /usr/tce/packages/xl/xl-2021.03.11/bin/xlC + f77: /usr/tce/packages/xl/xl-2021.03.11/bin/xlf + fc: /usr/tce/packages/xl/xl-2021.03.11/bin/xlf flags: cflags: -qarch=pwr9 -qtune=pwr9 -qxlcompatmacros -qalias=noansi -qsmp=omp -qhot -qnoeh -qsuppress=1500-029 -qsuppress=1500-036 cxxflags: -qarch=pwr9 -qtune=pwr9 -qxlcompatmacros -qlanglvl=extended0x -qalias=noansi -qsmp=omp -qhot -qnoeh -qsuppress=1500-029 -qsuppress=1500-036 diff --git a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/packages.yaml b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/packages.yaml index 4f664dce..d054887c 100644 --- a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/packages.yaml +++ b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9/packages.yaml @@ -9,9 +9,18 @@ packages: - spec: cuda@10.1.243 modules: - cuda/10.1.243 + - spec: cuda@10.2.89 + modules: + - cuda/10.2.89 - spec: cuda@11.0.2 modules: - cuda/11.0.2 + - spec: cuda@11.1.1 + modules: + - cuda/11.1.1 + - spec: cuda@11.2.0 + modules: + - cuda/11.2.0 cmake: buildable: False diff --git a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/compilers.yaml b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/compilers.yaml deleted file mode 100644 index 7ee75090..00000000 --- a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/compilers.yaml +++ /dev/null @@ -1,61 +0,0 @@ -compilers: -- compiler: - spec: clang@9.0.0 - paths: - cc: /usr/tce/packages/clang/clang-upstream-2019.08.15/bin/clang - cxx: /usr/tce/packages/clang/clang-upstream-2019.08.15/bin/clang++ - f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran - fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran - flags: - cflags: -mcpu=native -mtune=native - cxxflags: -mcpu=native -mtune=native - operating_system: rhel7 - target: ppc64le - modules: [] - environment: {} - extra_rpaths: [] -- compiler: - spec: clang@10.0.1 - paths: - cc: /usr/tce/packages/clang/clang-ibm-10.0.1-gcc-8.3.1/bin/clang - cxx: /usr/tce/packages/clang/clang-ibm-10.0.1-gcc-8.3.1/bin/clang++ - f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran - fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran - flags: - cflags: -mcpu=native -mtune=native - cxxflags: -mcpu=native -mtune=native - operating_system: rhel7 - target: ppc64le - modules: [] - environment: {} - extra_rpaths: [] -- compiler: - spec: gcc@8.3.1 - paths: - cc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gcc - cxx: /usr/tce/packages/gcc/gcc-8.3.1/bin/g++ - f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran - fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran - flags: - cflags: -mcpu=native -mtune=native - cxxflags: -mcpu=native -mtune=native - operating_system: rhel7 - target: ppc64le - modules: [] - environment: {} - extra_rpaths: [] -- compiler: - spec: xl@16.1.1 - paths: - cc: /usr/tce/packages/xl/xl-2020.09.17-cuda-11.0.2/bin/xlc - cxx: /usr/tce/packages/xl/xl-2020.09.17-cuda-11.0.2/bin/xlC - f77: - fc: - flags: - cflags: -qarch=pwr9 -qtune=pwr9 -qxlcompatmacros -qalias=noansi -qsmp=omp -qhot -qnoeh -qsuppress=1500-029 -qsuppress=1500-036 - cxxflags: -qarch=pwr9 -qtune=pwr9 -qxlcompatmacros -qlanglvl=extended0x -qalias=noansi -qsmp=omp -qhot -qnoeh -qsuppress=1500-029 -qsuppress=1500-036 - operating_system: rhel7 - target: ppc64le - modules: [] - environment: {} - extra_rpaths: [] diff --git a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/compilers.yaml b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/compilers.yaml new file mode 120000 index 00000000..9de0ea91 --- /dev/null +++ b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/compilers.yaml @@ -0,0 +1 @@ +../blueos_3_ppc64le_ib_p9/compilers.yaml \ No newline at end of file diff --git a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/packages.yaml b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/packages.yaml index 2ea24952..62d93ffe 100644 --- a/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/packages.yaml +++ b/scripts/uberenv/spack_configs/blueos_3_ppc64le_ib_p9_python/packages.yaml @@ -5,7 +5,7 @@ packages: providers: blas: [essl] lapack: [essl] - + essl: buildable: False externals: @@ -18,9 +18,18 @@ packages: - spec: cuda@10.1.243 modules: - cuda/10.1.243 + - spec: cuda@10.2.89 + modules: + - cuda/10.2.89 - spec: cuda@11.0.2 modules: - cuda/11.0.2 + - spec: cuda@11.1.1 + modules: + - cuda/11.1.1 + - spec: cuda@11.2.0 + modules: + - cuda/11.2.0 cmake: buildable: False diff --git a/scripts/uberenv/spack_configs/toss_3_x86_64_ib/compilers.yaml b/scripts/uberenv/spack_configs/toss_3_x86_64_ib/compilers.yaml index 8b6966ff..02db6a1d 100644 --- a/scripts/uberenv/spack_configs/toss_3_x86_64_ib/compilers.yaml +++ b/scripts/uberenv/spack_configs/toss_3_x86_64_ib/compilers.yaml @@ -4,8 +4,23 @@ compilers: paths: cc: /usr/tce/packages/clang/clang-10.0.1/bin/clang cxx: /usr/tce/packages/clang/clang-10.0.1/bin/clang++ - f77: - fc: + f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran + fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran + flags: + cflags: -march=native -mtune=native + cxxflags: -march=native -mtune=native + operating_system: rhel7 + target: x86_64 + modules: [] + environment: {} + extra_rpaths: [] +- compiler: + spec: clang@11.0.1 + paths: + cc: /usr/tce/packages/clang/clang-11.0.1/bin/clang + cxx: /usr/tce/packages/clang/clang-11.0.1/bin/clang++ + f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran + fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran flags: cflags: -march=native -mtune=native cxxflags: -march=native -mtune=native @@ -19,8 +34,8 @@ compilers: paths: cc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gcc cxx: /usr/tce/packages/gcc/gcc-8.3.1/bin/g++ - f77: - fc: + f77: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran + fc: /usr/tce/packages/gcc/gcc-8.3.1/bin/gfortran flags: cflags: -march=native -mtune=native cxxflags: -march=native -mtune=native @@ -34,8 +49,8 @@ compilers: paths: cc: /usr/tce/packages/intel/intel-19.1.2/bin/icc cxx: /usr/tce/packages/intel/intel-19.1.2/bin/icpc - f77: - fc: + f77: /usr/tce/packages/intel/intel-19.1.2/bin/ifort + fc: /usr/tce/packages/intel/intel-19.1.2/bin/ifort flags: cflags: -gcc-name=/usr/tce/packages/gcc/gcc-8.3.1/bin/gcc -march=native -mtune=native cxxflags: -gxx-name=/usr/tce/packages/gcc/gcc-8.3.1/bin/g++ -march=native -mtune=native diff --git a/scripts/uberenv/spack_configs/toss_3_x86_64_ib/packages.yaml b/scripts/uberenv/spack_configs/toss_3_x86_64_ib/packages.yaml index a9bc5cdc..e7ed36f4 100644 --- a/scripts/uberenv/spack_configs/toss_3_x86_64_ib/packages.yaml +++ b/scripts/uberenv/spack_configs/toss_3_x86_64_ib/packages.yaml @@ -18,8 +18,8 @@ packages: py-sphinx: buildable: False externals: - - spec: py@1.6.3 - prefix-sphinx: /collab/usr/gapps/python/build/spack-toss3.2/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/python-2.7.14-7rci3jkmuht2uiwp433afigveuf4ocnu + - spec: py-sphinx@1.6.3 + prefix: /collab/usr/gapps/python/build/spack-toss3.2/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/python-2.7.14-7rci3jkmuht2uiwp433afigveuf4ocnu bison: buildable: False diff --git a/scripts/uberenv/spack_configs/toss_3_x86_64_ib_python/packages.yaml b/scripts/uberenv/spack_configs/toss_3_x86_64_ib_python/packages.yaml index 0178b182..0c6b833b 100644 --- a/scripts/uberenv/spack_configs/toss_3_x86_64_ib_python/packages.yaml +++ b/scripts/uberenv/spack_configs/toss_3_x86_64_ib_python/packages.yaml @@ -22,7 +22,7 @@ packages: buildable: False externals: - spec: py@1.6.3 - prefix-sphinx: /collab/usr/gapps/python/build/spack-toss3.2/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/python-2.7.14-7rci3jkmuht2uiwp433afigveuf4ocnu + prefix: /collab/usr/gapps/python/build/spack-toss3.2/opt/spack/linux-rhel7-x86_64/gcc-4.9.3/python-2.7.14-7rci3jkmuht2uiwp433afigveuf4ocnu zlib: buildable: False diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a85c36bd..03f627c2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,7 +55,7 @@ blt_add_library( NAME lvarray DEPENDS_ON ${lvarray_dependencies} OBJECT ${LVARRAY_BUILD_OBJ_LIBS} ) - + target_include_directories( lvarray PUBLIC $ @@ -76,7 +76,6 @@ install( DIRECTORY . DESTINATION include/LvArray FILES_MATCHING PATTERN *.h ) lvarray_add_code_checks( PREFIX lvarray EXCLUDES "blt/*" ) - if( ENABLE_PYLVARRAY ) add_subdirectory( python ) endif() diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 22bcea50..0528e703 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -31,6 +31,18 @@ blt_add_library( NAME pylvarray CLEAR_PREFIX TRUE ) -target_include_directories( pylvarray PUBLIC ${CMAKE_BINARY_DIR}/include ) +target_include_directories( pylvarray + PUBLIC + $ + $ ) + +install( TARGETS pylvarray + EXPORT pylvarray + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION lib ) + +install( EXPORT pylvarray + DESTINATION share/lvarray/cmake/ ) lvarray_add_code_checks( PREFIX pylvarray ) diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 208def73..4d91681e 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -88,7 +88,7 @@ foreach(test ${testSources}) blt_add_executable( NAME ${test_name} SOURCES ${test} OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY} - DEPENDS_ON gtest lvarray ${lvarray_dependencies}) + DEPENDS_ON gtest lvarray ${lvarray_dependencies} ) target_include_directories( ${test_name} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../src ) diff --git a/unitTests/python/CMakeLists.txt b/unitTests/python/CMakeLists.txt index eb15a648..c8101f36 100644 --- a/unitTests/python/CMakeLists.txt +++ b/unitTests/python/CMakeLists.txt @@ -14,15 +14,14 @@ foreach(test ${pythonTests}) blt_add_library( NAME ${test_name} SOURCES ${test} - DEPENDS_ON pylvarray + DEPENDS_ON pylvarray ${lvarray_dependencies} SHARED TRUE - CLEAR_PREFIX TRUE - ) + CLEAR_PREFIX TRUE ) target_include_directories( ${test_name} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../src ) add_test( NAME ${test_name} - COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/${test_name}Driver.py ) + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${test_name}Driver.py ) set_tests_properties( ${test_name} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/lib ) diff --git a/unitTests/testArrayView_typeConversion.cpp b/unitTests/testArrayView_typeConversion.cpp index 4c5b64a1..9223c8ba 100644 --- a/unitTests/testArrayView_typeConversion.cpp +++ b/unitTests/testArrayView_typeConversion.cpp @@ -109,7 +109,7 @@ void testTypeConversion() } } } -}; +} TEST( ArrayView, MallocBuffer_TypeConversion ) { From 4cc725d0fd3b2d3dde0a04a0cf90668aa40d67e6 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Thu, 29 Apr 2021 14:44:25 -0700 Subject: [PATCH 11/16] Removed need for matrix output macro. --- src/output.hpp | 113 ++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 63 deletions(-) diff --git a/src/output.hpp b/src/output.hpp index 93b93bf0..952c0929 100644 --- a/src/output.hpp +++ b/src/output.hpp @@ -18,7 +18,7 @@ #include "ArrayOfArrays.hpp" #include "CRSMatrix.hpp" #include "Macros.hpp" - +#include "limits.hpp" // TPL includes #include @@ -202,71 +202,58 @@ std::ostream & operator<< ( std::ostream & stream, CRSMatrixView< T const, COL_T /** - * @brief Macro to generate function to output a CRSMatrixView - * @param COL_TYPE The type of index used to specify the column of the matrix. - * @param INDEX_TYPE The type of index used to specify the row of the matrix. - * @param LITOKEN A string literal to give the printf token for the row index type. - * @param GITOKEN A string literal to give the printf token for the column index type. + * @brief Print a CRSMatrixView in a format that can be easily xxdiff'ed on the console. + * @tparam POLICY The policy for the kernel launch. + * @tparam T The value type in @p view. + * @tparam T The column type in @p view. + * @tparam T The index type in @p view. + * @tparam BUFFER_TYPE The type of buffer used by @p view. + * @param view The matrix view object to print. */ -#define MAKE_PRINT_MATVIEW( COL_TYPE, INDEX_TYPE, LITOKEN, GITOKEN ) \ -/** @brief Print a CRSMatrixView in a format that can be easily xxdiff'ed on */ \ -/** the console. */ \ -/** @tparam POLICY The policy for dummy kernel launch. */ \ -/** @tparam T The type of the values in @p view. */ \ -/** @tparam BUFFER_TYPE The type of buffer used by @p view. */ \ -/** @param view The matrix view object to print. */ \ - template< typename POLICY, \ - typename T, \ - template< typename > class BUFFER_TYPE > \ - void print( CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > const & view ) \ - { \ - INDEX_TYPE const numRows = view.numRows(); \ - \ - \ - printf( "numRows = %4" LITOKEN " \n", numRows ); \ - RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, 1 ), [=] LVARRAY_HOST_DEVICE ( INDEX_TYPE const ) \ - { \ - INDEX_TYPE const * const ncols = view.getSizes(); \ - INDEX_TYPE const * const row_indexes = view.getOffsets(); \ - COL_TYPE const * const cols = view.getColumns(); \ - T const * const values = view.getEntries(); \ - \ - printf( "ncols = { " ); for( INDEX_TYPE i=0; i class BUFFER_TYPE > +void print( CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYPE > const & view ) +{ + INDEX_TYPE const numRows = view.numRows(); + + printf( "numRows = %4lld \n", integerConversion< long long >( numRows ) ); + RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, 1 ), [=] LVARRAY_HOST_DEVICE ( INDEX_TYPE const ) + { + INDEX_TYPE const * const ncols = view.getSizes(); + INDEX_TYPE const * const row_indexes = view.getOffsets(); + COL_TYPE const * const cols = view.getColumns(); + T const * const values = view.getEntries(); + + printf( "ncols = { " ); + for( INDEX_TYPE i = 0; i < numRows; ++i ) + { + printf( "%4lld, ", integerConversion< long long >( ncols[ i ] ) ); + } + printf( " }\n" ); -MAKE_PRINT_MATVIEW( int, int, "d", "d" ) -MAKE_PRINT_MATVIEW( int, long long int, "d", "lld" ) -MAKE_PRINT_MATVIEW( long int, long long int, "ld", "lld" ) -MAKE_PRINT_MATVIEW( long long int, long long int, "lld", "lld" ) + printf( "row_indexes = { " ); + for( INDEX_TYPE i = 0; i < numRows + 1; ++i ) + { + printf( "%4lld, ", integerConversion< long long >( row_indexes[ i ] ) ); + } + printf( " }\n" ); + printf( "row col value \n" ); + printf( "---- --------- --------- \n" ); + for( INDEX_TYPE i = 0; i < numRows; ++i ) + { + printf( "%4lld\n", integerConversion< long long >( ncols[ i ] ) ); + for( INDEX_TYPE j = 0; j < ncols[ i ]; ++j ) + { + printf( "%4lld %9lld %9.2g\n", + integerConversion< long long >( i ), + integerConversion< long long >( cols[ row_indexes[ i ] + j ] ), + double( values[ row_indexes[ i ] + j ] ) ); + } + } + } ); + + std::cout << std::endl; +} /** * @brief Output a c-array to a stream. From 31c02f46a1d84bcf953dde91d7acc89e3446b476 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Thu, 29 Apr 2021 17:21:15 -0700 Subject: [PATCH 12/16] Memcpy changes. --- src/ArrayView.hpp | 7 +++++-- src/CRSMatrixView.hpp | 11 +++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ArrayView.hpp b/src/ArrayView.hpp index e12668b7..47b34018 100644 --- a/src/ArrayView.hpp +++ b/src/ArrayView.hpp @@ -628,8 +628,11 @@ class ArrayView LVARRAY_ERROR_IF_NE_MSG( getPreviousSpace(), MemorySpace::host, "Without Umpire only host memory is supported." ); #endif - move( getPreviousSpace(), true ); - umpireInterface::memset( data(), 0, size() * sizeof( T ) ); + if( size() > 0 ) + { + move( getPreviousSpace(), true ); + umpireInterface::memset( data(), 0, size() * sizeof( T ) ); + } } /** diff --git a/src/CRSMatrixView.hpp b/src/CRSMatrixView.hpp index b0e10f77..848e6b0b 100644 --- a/src/CRSMatrixView.hpp +++ b/src/CRSMatrixView.hpp @@ -372,11 +372,14 @@ class CRSMatrixView : protected SparsityPatternView< COL_TYPE, INDEX_TYPE, BUFFE LVARRAY_ERROR_IF_NE_MSG( getPreviousSpace(), MemorySpace::host, "Without Umpire only host memory is supported." ); #endif - ParentClass::move( m_entries.getPreviousSpace(), false ); - m_entries.move( m_entries.getPreviousSpace(), true ); + if( m_entries.capacity() > 0 ) + { + ParentClass::move( m_entries.getPreviousSpace(), false ); + m_entries.move( m_entries.getPreviousSpace(), true ); - INDEX_TYPE const numBytes = m_entries.capacity() * sizeof( T ); - umpireInterface::memset( m_entries.data(), 0, numBytes ); + INDEX_TYPE const numBytes = m_entries.capacity() * sizeof( T ); + umpireInterface::memset( m_entries.data(), 0, numBytes ); + } } /** From b02ac6f324282f3e31cf43123f51e541346478d0 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Thu, 29 Apr 2021 17:21:25 -0700 Subject: [PATCH 13/16] Uncrustify changes. --- src/Array.hpp | 2 +- src/ArrayView.hpp | 2 +- src/Macros.hpp | 74 ++-- src/bufferManipulation.hpp | 2 +- src/memcpy.hpp | 2 +- src/output.hpp | 58 +-- src/typeManipulation.hpp | 10 +- src/umpireInterface.cpp | 2 +- unitTests/testArray.hpp | 2 +- unitTests/testArray_ChaiBuffer.cpp | 6 +- unitTests/testChaiBuffer.cpp | 30 +- unitTests/testMath.cpp | 644 +++++++++++++++-------------- unitTests/testMemcpy.cpp | 32 +- unitTests/testUtils.hpp | 4 +- 14 files changed, 457 insertions(+), 413 deletions(-) diff --git a/src/Array.hpp b/src/Array.hpp index 7c103c85..69fc34e4 100644 --- a/src/Array.hpp +++ b/src/Array.hpp @@ -350,7 +350,7 @@ class Array : public ArrayView< T, { return resizeWithoutInitializationOrDestruction( MemorySpace::host, newDims ... ); } - + /** * @brief Resize the array without initializing any new values or destroying any old values. * Only safe on POD data, however it is much faster for large allocations. diff --git a/src/ArrayView.hpp b/src/ArrayView.hpp index 47b34018..cbbf6690 100644 --- a/src/ArrayView.hpp +++ b/src/ArrayView.hpp @@ -610,7 +610,7 @@ class ArrayView { auto const view = toView(); RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, size() ), - [value, view] LVARRAY_HOST_DEVICE ( INDEX_TYPE const i ) + [value, view] LVARRAY_HOST_DEVICE ( INDEX_TYPE const i ) { view.data()[ i ] = value; } ); diff --git a/src/Macros.hpp b/src/Macros.hpp index 24788617..aa8fe6f4 100644 --- a/src/Macros.hpp +++ b/src/Macros.hpp @@ -93,47 +93,47 @@ */ #if defined(__CUDA_ARCH__) #if !defined(NDEBUG) - #define LVARRAY_ERROR_IF( EXP, MSG ) \ - do \ - { \ - if( EXP ) \ - { \ - assert( false && "EXP = " STRINGIZE( EXP ) "MSG = " STRINGIZE( MSG ) ); \ - } \ - } while( false ) +#define LVARRAY_ERROR_IF( EXP, MSG ) \ + do \ + { \ + if( EXP ) \ + { \ + assert( false && "EXP = " STRINGIZE( EXP ) "MSG = " STRINGIZE( MSG ) ); \ + } \ + } while( false ) #else - #define LVARRAY_ERROR_IF( EXP, MSG ) \ - do \ - { \ - if( EXP ) \ - { \ - constexpr char const * formatString = "***** ERROR\n" \ - "***** LOCATION: " LOCATION "\n" \ - "***** Block: [%u, %u, %u]\n" \ - "***** Thread: [%u, %u, %u]\n" \ - "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n" \ - "***** MSG: " STRINGIZE( MSG ) "\n\n"; \ - printf( formatString, blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, threadIdx.y, threadIdx.z ); \ - asm ( "trap;" ); \ - } \ - } while( false ) +#define LVARRAY_ERROR_IF( EXP, MSG ) \ + do \ + { \ + if( EXP ) \ + { \ + constexpr char const * formatString = "***** ERROR\n" \ + "***** LOCATION: " LOCATION "\n" \ + "***** Block: [%u, %u, %u]\n" \ + "***** Thread: [%u, %u, %u]\n" \ + "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n" \ + "***** MSG: " STRINGIZE( MSG ) "\n\n"; \ + printf( formatString, blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, threadIdx.y, threadIdx.z ); \ + asm ( "trap;" ); \ + } \ + } while( false ) #endif #else - #define LVARRAY_ERROR_IF( EXP, MSG ) \ - do \ +#define LVARRAY_ERROR_IF( EXP, MSG ) \ + do \ + { \ + if( EXP ) \ { \ - if( EXP ) \ - { \ - std::ostringstream __oss; \ - __oss << "***** ERROR\n"; \ - __oss << "***** LOCATION: " LOCATION "\n"; \ - __oss << "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n"; \ - __oss << MSG << "\n"; \ - __oss << LvArray::system::stackTrace( true ); \ - std::cout << __oss.str() << std::endl; \ - LvArray::system::callErrorHandler(); \ - } \ - } while( false ) + std::ostringstream __oss; \ + __oss << "***** ERROR\n"; \ + __oss << "***** LOCATION: " LOCATION "\n"; \ + __oss << "***** Controlling expression (should be false): " STRINGIZE( EXP ) "\n"; \ + __oss << MSG << "\n"; \ + __oss << LvArray::system::stackTrace( true ); \ + std::cout << __oss.str() << std::endl; \ + LvArray::system::callErrorHandler(); \ + } \ + } while( false ) #endif /** diff --git a/src/bufferManipulation.hpp b/src/bufferManipulation.hpp index 8a620dd8..62b94539 100644 --- a/src/bufferManipulation.hpp +++ b/src/bufferManipulation.hpp @@ -50,7 +50,7 @@ inline std::ostream & operator<<( std::ostream & os, MemorySpace const space ) return os << "hip"; if( space == MemorySpace::sycl ) return os << "sycl"; - + LVARRAY_ERROR( "Unrecognized memory space " << static_cast< int >( space ) ); return os; } diff --git a/src/memcpy.hpp b/src/memcpy.hpp index bf1e3564..0ef94ea1 100644 --- a/src/memcpy.hpp +++ b/src/memcpy.hpp @@ -37,7 +37,7 @@ namespace internal */ template< int N_LEFT, typename T, int NDIM, int USD, typename INDEX_TYPE > std::enable_if_t< N_LEFT == 0, ArraySlice< T, NDIM, USD, INDEX_TYPE > > -slice( ArraySlice< T, NDIM, USD, INDEX_TYPE > const curSlice, INDEX_TYPE const *) +slice( ArraySlice< T, NDIM, USD, INDEX_TYPE > const curSlice, INDEX_TYPE const * ) { return curSlice; } /** diff --git a/src/output.hpp b/src/output.hpp index 952c0929..a2c355d8 100644 --- a/src/output.hpp +++ b/src/output.hpp @@ -217,40 +217,40 @@ void print( CRSMatrixView< T const, COL_TYPE const, INDEX_TYPE const, BUFFER_TYP printf( "numRows = %4lld \n", integerConversion< long long >( numRows ) ); RAJA::forall< POLICY >( RAJA::TypedRangeSegment< INDEX_TYPE >( 0, 1 ), [=] LVARRAY_HOST_DEVICE ( INDEX_TYPE const ) - { - INDEX_TYPE const * const ncols = view.getSizes(); - INDEX_TYPE const * const row_indexes = view.getOffsets(); - COL_TYPE const * const cols = view.getColumns(); - T const * const values = view.getEntries(); - - printf( "ncols = { " ); - for( INDEX_TYPE i = 0; i < numRows; ++i ) { - printf( "%4lld, ", integerConversion< long long >( ncols[ i ] ) ); - } - printf( " }\n" ); + INDEX_TYPE const * const ncols = view.getSizes(); + INDEX_TYPE const * const row_indexes = view.getOffsets(); + COL_TYPE const * const cols = view.getColumns(); + T const * const values = view.getEntries(); - printf( "row_indexes = { " ); - for( INDEX_TYPE i = 0; i < numRows + 1; ++i ) - { - printf( "%4lld, ", integerConversion< long long >( row_indexes[ i ] ) ); - } - printf( " }\n" ); + printf( "ncols = { " ); + for( INDEX_TYPE i = 0; i < numRows; ++i ) + { + printf( "%4lld, ", integerConversion< long long >( ncols[ i ] ) ); + } + printf( " }\n" ); - printf( "row col value \n" ); - printf( "---- --------- --------- \n" ); - for( INDEX_TYPE i = 0; i < numRows; ++i ) - { - printf( "%4lld\n", integerConversion< long long >( ncols[ i ] ) ); - for( INDEX_TYPE j = 0; j < ncols[ i ]; ++j ) + printf( "row_indexes = { " ); + for( INDEX_TYPE i = 0; i < numRows + 1; ++i ) { - printf( "%4lld %9lld %9.2g\n", - integerConversion< long long >( i ), - integerConversion< long long >( cols[ row_indexes[ i ] + j ] ), - double( values[ row_indexes[ i ] + j ] ) ); + printf( "%4lld, ", integerConversion< long long >( row_indexes[ i ] ) ); } - } - } ); + printf( " }\n" ); + + printf( "row col value \n" ); + printf( "---- --------- --------- \n" ); + for( INDEX_TYPE i = 0; i < numRows; ++i ) + { + printf( "%4lld\n", integerConversion< long long >( ncols[ i ] ) ); + for( INDEX_TYPE j = 0; j < ncols[ i ]; ++j ) + { + printf( "%4lld %9lld %9.2g\n", + integerConversion< long long >( i ), + integerConversion< long long >( cols[ row_indexes[ i ] + j ] ), + double( values[ row_indexes[ i ] + j ] ) ); + } + } + } ); std::cout << std::endl; } diff --git a/src/typeManipulation.hpp b/src/typeManipulation.hpp index 3a2ec2ac..9b30218d 100644 --- a/src/typeManipulation.hpp +++ b/src/typeManipulation.hpp @@ -27,11 +27,11 @@ #if defined(__GLIBCXX__) && __GLIBCXX__ <= 20150626 namespace std { - /** - * @brief This is a fix for LC's old standard library that doesn't conform to C++14. - */ - template< typename T > - using is_trivially_default_constructible = has_trivial_default_constructor< T >; +/** + * @brief This is a fix for LC's old standard library that doesn't conform to C++14. + */ +template< typename T > +using is_trivially_default_constructible = has_trivial_default_constructor< T >; } #endif diff --git a/src/umpireInterface.cpp b/src/umpireInterface.cpp index 6dd9bfbc..9219564d 100644 --- a/src/umpireInterface.cpp +++ b/src/umpireInterface.cpp @@ -37,7 +37,7 @@ void copy( void * const dstPointer, void * const srcPointer, std::size_t const s std::memcpy( dstPointer, srcPointer, size ); } -camp::resources::Event copy( void * const dstPointer, void * const srcPointer, +camp::resources::Event copy( void * const dstPointer, void * const srcPointer, camp::resources::Resource & resource, std::size_t const size ) { #if defined( LVARRAY_USE_UMPIRE ) diff --git a/unitTests/testArray.hpp b/unitTests/testArray.hpp index f6254d10..093d236d 100644 --- a/unitTests/testArray.hpp +++ b/unitTests/testArray.hpp @@ -434,7 +434,7 @@ class ArrayTest : public ::testing::Test RAJA::as_array< PERMUTATION >::get() ) ); EXPECT_EQ( array.data(), getRAJAViewData( view ) ); - + RAJA::Layout< NDIM > const & layout = getRAJAViewLayout( view ); for( int dim = 0; dim < NDIM; ++dim ) { diff --git a/unitTests/testArray_ChaiBuffer.cpp b/unitTests/testArray_ChaiBuffer.cpp index 48641f58..431b99ff 100644 --- a/unitTests/testArray_ChaiBuffer.cpp +++ b/unitTests/testArray_ChaiBuffer.cpp @@ -74,9 +74,9 @@ class ArrayTest : public ::testing::Test T * const devPtr = array.data(); forall< parallelDevicePolicy< 32 > >( array.size(), [devPtr] LVARRAY_DEVICE ( int const i ) - { - new ( &devPtr[ i ] ) T( i ); - } ); + { + new ( &devPtr[ i ] ) T( i ); + } ); array.move( MemorySpace::host, true ); for( int i = 0; i < array.size(); ++i ) diff --git a/unitTests/testChaiBuffer.cpp b/unitTests/testChaiBuffer.cpp index 6d1a6965..6d8e767d 100644 --- a/unitTests/testChaiBuffer.cpp +++ b/unitTests/testChaiBuffer.cpp @@ -88,9 +88,9 @@ class ChaiBufferTest : public ::testing::Test T * const devPtr = buffer.data(); forall< parallelDevicePolicy< 32 > >( size, [devPtr] LVARRAY_DEVICE ( int const i ) - { - devPtr[ i ] += devPtr[ i ]; - } ); + { + devPtr[ i ] += devPtr[ i ]; + } ); // Check that the device changes are seen on the host. Then modify the values without touching. buffer.move( MemorySpace::host, false ); @@ -104,9 +104,9 @@ class ChaiBufferTest : public ::testing::Test buffer.move( MemorySpace::cuda, true ); EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::cuda ); forall< parallelDevicePolicy< 32 > >( size, [devPtr] LVARRAY_DEVICE ( int const i ) - { - devPtr[ i ] += devPtr[ i ]; - } ); + { + devPtr[ i ] += devPtr[ i ]; + } ); buffer.move( MemorySpace::host, false ); EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::host ); @@ -132,9 +132,9 @@ class ChaiBufferTest : public ::testing::Test } forall< parallelDevicePolicy< 32 > >( size, [buffer] LVARRAY_DEVICE ( int const i ) - { - buffer[ i ] += buffer[ i ]; - } ); + { + buffer[ i ] += buffer[ i ]; + } ); EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::cuda ); @@ -151,9 +151,9 @@ class ChaiBufferTest : public ::testing::Test EXPECT_EQ( constBuffer.getPreviousSpace(), MemorySpace::host ); forall< parallelDevicePolicy< 32 > >( size, [buffer] LVARRAY_DEVICE ( int const i ) - { - buffer[ i ] += buffer[ i ]; - } ); + { + buffer[ i ] += buffer[ i ]; + } ); EXPECT_EQ( buffer.getPreviousSpace(), MemorySpace::cuda ); @@ -177,9 +177,9 @@ class ChaiBufferTest : public ::testing::Test T * const devPtr = buffer.data(); forall< parallelDevicePolicy< 32 > >( size, [devPtr] LVARRAY_DEVICE ( int const i ) - { - new ( &devPtr[ i ] ) T( i ); - } ); + { + new ( &devPtr[ i ] ) T( i ); + } ); buffer.move( MemorySpace::host, true ); for( int i = 0; i < size; ++i ) diff --git a/unitTests/testMath.cpp b/unitTests/testMath.cpp index adc38467..ca638f9c 100644 --- a/unitTests/testMath.cpp +++ b/unitTests/testMath.cpp @@ -34,98 +34,98 @@ struct TestMath : public ::testing::Test void convert() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T const x = math::convert< T >( 5 ); - PORTABLE_EXPECT_EQ( x, T( 5 ) ); - } ); + { + T const x = math::convert< T >( 5 ); + PORTABLE_EXPECT_EQ( x, T( 5 ) ); + } ); } void maxAndMin() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T a = 7; - T b = -55; - PORTABLE_EXPECT_EQ( math::max( a, b ), a ); - PORTABLE_EXPECT_EQ( math::min( a, b ), b ); - - a = 120; - b = 240; - PORTABLE_EXPECT_EQ( math::max( a, b ), b ); - PORTABLE_EXPECT_EQ( math::min( a, b ), a ); - } ); + { + T a = 7; + T b = -55; + PORTABLE_EXPECT_EQ( math::max( a, b ), a ); + PORTABLE_EXPECT_EQ( math::min( a, b ), b ); + + a = 120; + b = 240; + PORTABLE_EXPECT_EQ( math::max( a, b ), b ); + PORTABLE_EXPECT_EQ( math::min( a, b ), a ); + } ); } void abs() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T a = 7; - PORTABLE_EXPECT_EQ( math::abs( a ), a ); + { + T a = 7; + PORTABLE_EXPECT_EQ( math::abs( a ), a ); - a = -55; - PORTABLE_EXPECT_EQ( math::abs( a ), -a ); - } ); + a = -55; + PORTABLE_EXPECT_EQ( math::abs( a ), -a ); + } ); } void square() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - PORTABLE_EXPECT_EQ( math::square( T( 3 ) ), T( 9 ) ); - } ); + { + PORTABLE_EXPECT_EQ( math::square( T( 3 ) ), T( 9 ) ); + } ); } void sqrtAndInvSqrt() { using FloatingPoint = decltype( math::sqrt( T() ) ); forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; + { + FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; - T a = 5 * 5; - PORTABLE_EXPECT_EQ( math::sqrt( a ), FloatingPoint( 5.0 ) ); - PORTABLE_EXPECT_NEAR( math::invSqrt( a ), FloatingPoint( 1.0 / 5.0 ), epsilon ); + T a = 5 * 5; + PORTABLE_EXPECT_EQ( math::sqrt( a ), FloatingPoint( 5.0 ) ); + PORTABLE_EXPECT_NEAR( math::invSqrt( a ), FloatingPoint( 1.0 / 5.0 ), epsilon ); - a = 12 * 12; - PORTABLE_EXPECT_EQ( math::sqrt( a ), FloatingPoint( 12.0 ) ); - PORTABLE_EXPECT_NEAR( math::invSqrt( a ), FloatingPoint( 1.0 / 12.0 ), epsilon ); - } ); + a = 12 * 12; + PORTABLE_EXPECT_EQ( math::sqrt( a ), FloatingPoint( 12.0 ) ); + PORTABLE_EXPECT_NEAR( math::invSqrt( a ), FloatingPoint( 1.0 / 12.0 ), epsilon ); + } ); } void trig() { using FloatingPoint = decltype( math::sin( T() ) ); forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; + { + FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; - PORTABLE_EXPECT_NEAR( math::sin( T( 10 ) ), FloatingPoint( ::sin( 10.0 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( math::cos( T( 10 ) ), FloatingPoint( ::cos( 10.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::sin( T( 10 ) ), FloatingPoint( ::sin( 10.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::cos( T( 10 ) ), FloatingPoint( ::cos( 10.0 ) ), epsilon ); - FloatingPoint s, c; - math::sincos( T( 10 ), s, c ); - PORTABLE_EXPECT_NEAR( s, FloatingPoint( ::sin( 10.0 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( c, FloatingPoint( ::cos( 10.0 ) ), epsilon ); + FloatingPoint s, c; + math::sincos( T( 10 ), s, c ); + PORTABLE_EXPECT_NEAR( s, FloatingPoint( ::sin( 10.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( c, FloatingPoint( ::cos( 10.0 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( math::tan( T( 10 ) ), FloatingPoint( ::tan( 10.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::tan( T( 10 ) ), FloatingPoint( ::tan( 10.0 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( math::asin( T( 1 ) ), FloatingPoint( ::asin( 1.0 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( math::acos( T( 0 ) ), FloatingPoint( ::acos( 0.0 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( math::atan2( T( 1 ), T( 2 ) ), FloatingPoint( ::atan2( 1.0, 2.0 ) ), epsilon ); - } ); + PORTABLE_EXPECT_NEAR( math::asin( T( 1 ) ), FloatingPoint( ::asin( 1.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::acos( T( 0 ) ), FloatingPoint( ::acos( 0.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::atan2( T( 1 ), T( 2 ) ), FloatingPoint( ::atan2( 1.0, 2.0 ) ), epsilon ); + } ); } void exponential() { using FloatingPoint = decltype( math::exp( T() ) ); forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; + { + FloatingPoint const epsilon = NumericLimitsNC< FloatingPoint >{}.epsilon; - PORTABLE_EXPECT_NEAR( math::exp( T( 2 ) ), FloatingPoint( ::exp( 2.0 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( math::log( T( 2 ) ), FloatingPoint( ::log( 2.0 ) ), epsilon ); - } ); + PORTABLE_EXPECT_NEAR( math::exp( T( 2 ) ), FloatingPoint( ::exp( 2.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::log( T( 2 ) ), FloatingPoint( ::log( 2.0 ) ), epsilon ); + } ); } }; @@ -149,28 +149,44 @@ using TestMathTypes = ::testing::Types< TYPED_TEST_SUITE( TestMath, TestMathTypes, ); TYPED_TEST( TestMath, numValues ) -{ this->numValues(); } +{ + this->numValues(); +} TYPED_TEST( TestMath, convert ) -{ this->convert(); } +{ + this->convert(); +} TYPED_TEST( TestMath, maxAndMin ) -{ this->maxAndMin(); } +{ + this->maxAndMin(); +} TYPED_TEST( TestMath, abs ) -{ this->abs(); } +{ + this->abs(); +} TYPED_TEST( TestMath, square ) -{ this->square(); } +{ + this->square(); +} TYPED_TEST( TestMath, sqrtAndInvSqrt ) -{ this->sqrtAndInvSqrt(); } +{ + this->sqrtAndInvSqrt(); +} TYPED_TEST( TestMath, trig ) -{ this->trig(); } +{ + this->trig(); +} TYPED_TEST( TestMath, exponential ) -{ this->exponential(); } +{ + this->exponential(); +} template< typename T_POLICY_PAIR > @@ -189,120 +205,120 @@ struct TestMath2 : public ::testing::Test void convert() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T x = math::convert< T >( 5 ); - PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 5 ) ); - PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 5 ) ); - - x = math::convert< T >( SingleT( 3 ) ); - PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 3 ) ); - PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 3 ) ); - - x = math::convert< T >( SingleT( 1 ), SingleT( 2 ) ); - PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 1 ) ); - PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 2 ) ); - - x = math::convert< T >( 5, 6 ); - PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 5 ) ); - PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 6 ) ); - - SingleT const * const xPtr = reinterpret_cast< SingleT const * >( &x ); - PORTABLE_EXPECT_EQ( xPtr[ 0 ], SingleT( 5 ) ); - PORTABLE_EXPECT_EQ( xPtr[ 1 ], SingleT( 6 ) ); - } ); + { + T x = math::convert< T >( 5 ); + PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 5 ) ); + PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 5 ) ); + + x = math::convert< T >( SingleT( 3 ) ); + PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 3 ) ); + PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 3 ) ); + + x = math::convert< T >( SingleT( 1 ), SingleT( 2 ) ); + PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 1 ) ); + PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 2 ) ); + + x = math::convert< T >( 5, 6 ); + PORTABLE_EXPECT_EQ( math::getFirst( x ), SingleT( 5 ) ); + PORTABLE_EXPECT_EQ( math::getSecond( x ), SingleT( 6 ) ); + + SingleT const * const xPtr = reinterpret_cast< SingleT const * >( &x ); + PORTABLE_EXPECT_EQ( xPtr[ 0 ], SingleT( 5 ) ); + PORTABLE_EXPECT_EQ( xPtr[ 1 ], SingleT( 6 ) ); + } ); } void maxAndMin() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T a = math::convert< T >( -60, 10 ); - T b = math::convert< T >( 64, 13 ); - PORTABLE_EXPECT_EQ( math::max( a, b ), b ); - PORTABLE_EXPECT_EQ( math::min( a, b ), a ); - - a = math::convert< T >( 7, 100 ); - b = math::convert< T >( -55, 110 ); - PORTABLE_EXPECT_EQ( math::max( a, b ), math::convert< T >( 7, 110 ) ); - PORTABLE_EXPECT_EQ( math::min( a, b ), math::convert< T >( -55, 100 ) ); - } ); + { + T a = math::convert< T >( -60, 10 ); + T b = math::convert< T >( 64, 13 ); + PORTABLE_EXPECT_EQ( math::max( a, b ), b ); + PORTABLE_EXPECT_EQ( math::min( a, b ), a ); + + a = math::convert< T >( 7, 100 ); + b = math::convert< T >( -55, 110 ); + PORTABLE_EXPECT_EQ( math::max( a, b ), math::convert< T >( 7, 110 ) ); + PORTABLE_EXPECT_EQ( math::min( a, b ), math::convert< T >( -55, 100 ) ); + } ); } void abs() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T a = math::convert< T >( 7, 8 ); - PORTABLE_EXPECT_EQ( math::abs( a ), a ); + { + T a = math::convert< T >( 7, 8 ); + PORTABLE_EXPECT_EQ( math::abs( a ), a ); - a = math::convert< T >( -101, -4 ); - PORTABLE_EXPECT_EQ( math::abs( a ), -a ); + a = math::convert< T >( -101, -4 ); + PORTABLE_EXPECT_EQ( math::abs( a ), -a ); - a = math::convert< T >( 4, -8 ); - PORTABLE_EXPECT_EQ( math::abs( a ), math::convert< T >( 4, 8 ) ); - } ); + a = math::convert< T >( 4, -8 ); + PORTABLE_EXPECT_EQ( math::abs( a ), math::convert< T >( 4, 8 ) ); + } ); } void square() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T const a = math::convert< T >( 7, 8 ); - PORTABLE_EXPECT_EQ( math::square( a ), math::convert< T >( 49, 64 ) ); - } ); + { + T const a = math::convert< T >( 7, 8 ); + PORTABLE_EXPECT_EQ( math::square( a ), math::convert< T >( 49, 64 ) ); + } ); } void sqrtAndInvSqrt() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T const epsilon = math::convert< T >( NumericLimitsNC< SingleT >{}.epsilon ); + { + T const epsilon = math::convert< T >( NumericLimitsNC< SingleT >{}.epsilon ); - T a = math::convert< T >( 5 * 5, 12 * 12 ); - PORTABLE_EXPECT_EQ( math::sqrt( a ), math::convert< T >( 5.0, 12 ) ); - PORTABLE_EXPECT_NEAR( math::invSqrt( a ), math::convert< T >( 1.0 / 5.0, 1.0 / 12.0 ), epsilon ); - } ); + T a = math::convert< T >( 5 * 5, 12 * 12 ); + PORTABLE_EXPECT_EQ( math::sqrt( a ), math::convert< T >( 5.0, 12 ) ); + PORTABLE_EXPECT_NEAR( math::invSqrt( a ), math::convert< T >( 1.0 / 5.0, 1.0 / 12.0 ), epsilon ); + } ); } void trig() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T const epsilon = math::convert< T >( NumericLimitsNC< SingleT >{}.epsilon ); + { + T const epsilon = math::convert< T >( NumericLimitsNC< SingleT >{}.epsilon ); - PORTABLE_EXPECT_NEAR( math::sin( math::convert< T >( 1, 2 ) ), - math::convert< T >( ::sin( 1.0 ), ::sin( 2.0 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( math::cos( math::convert< T >( 1, 2 ) ), - math::convert< T >( ::cos( 1.0 ), ::cos( 2.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::sin( math::convert< T >( 1, 2 ) ), + math::convert< T >( ::sin( 1.0 ), ::sin( 2.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::cos( math::convert< T >( 1, 2 ) ), + math::convert< T >( ::cos( 1.0 ), ::cos( 2.0 ) ), epsilon ); - T s, c; - math::sincos( math::convert< T >( 1, 2 ), s, c ); - PORTABLE_EXPECT_NEAR( s, math::convert< T >( ::sin( 1.0 ), ::sin( 2.0 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( c, math::convert< T >( ::cos( 1.0 ), ::cos( 2.0 ) ), epsilon ); + T s, c; + math::sincos( math::convert< T >( 1, 2 ), s, c ); + PORTABLE_EXPECT_NEAR( s, math::convert< T >( ::sin( 1.0 ), ::sin( 2.0 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( c, math::convert< T >( ::cos( 1.0 ), ::cos( 2.0 ) ), epsilon ); - T expected = math::convert< T >( ::tan( 1.0 ), ::tan( 2.0 ) ); - PORTABLE_EXPECT_NEAR( math::tan( math::convert< T >( 1, 2 ) ), expected, expected * epsilon ); + T expected = math::convert< T >( ::tan( 1.0 ), ::tan( 2.0 ) ); + PORTABLE_EXPECT_NEAR( math::tan( math::convert< T >( 1, 2 ) ), expected, expected * epsilon ); - PORTABLE_EXPECT_NEAR( math::asin( math::convert< T >( 0.25, 0.75) ), - math::convert< T >( ::asin( 0.25 ), ::asin( 0.75 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::asin( math::convert< T >( 0.25, 0.75 ) ), + math::convert< T >( ::asin( 0.25 ), ::asin( 0.75 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( math::acos( math::convert< T >( 0.25, 0.75) ), - math::convert< T >( ::acos( 0.25 ), ::acos( 0.75 ) ), epsilon ); + PORTABLE_EXPECT_NEAR( math::acos( math::convert< T >( 0.25, 0.75 ) ), + math::convert< T >( ::acos( 0.25 ), ::acos( 0.75 ) ), epsilon ); - PORTABLE_EXPECT_NEAR( math::atan2( math::convert< T >( 1 ), math::convert< T >( 2, -3 ) ), - math::convert< T >( ::atan2( 1.0, 2.0 ), ::atan2( 1.0, -3.0 ) ), epsilon ); - } ); + PORTABLE_EXPECT_NEAR( math::atan2( math::convert< T >( 1 ), math::convert< T >( 2, -3 ) ), + math::convert< T >( ::atan2( 1.0, 2.0 ), ::atan2( 1.0, -3.0 ) ), epsilon ); + } ); } void exponential() { forall< POLICY >( 1, [] LVARRAY_HOST_DEVICE ( int ) - { - T const epsilon = math::convert< T >( NumericLimitsNC< SingleT >{}.epsilon ); + { + T const epsilon = math::convert< T >( NumericLimitsNC< SingleT >{}.epsilon ); - PORTABLE_EXPECT_NEAR( math::exp( math::convert< T >( 2, 3 ) ), math::convert< T >( 7.38905609893, 20.0855369232 ), epsilon ); - PORTABLE_EXPECT_NEAR( math::log( math::convert< T >( 2, 3 ) ), math::convert< T >( 0.69314718056, 1.09861228867 ), epsilon ); - } ); + PORTABLE_EXPECT_NEAR( math::exp( math::convert< T >( 2, 3 ) ), math::convert< T >( 7.38905609893, 20.0855369232 ), epsilon ); + PORTABLE_EXPECT_NEAR( math::log( math::convert< T >( 2, 3 ) ), math::convert< T >( 0.69314718056, 1.09861228867 ), epsilon ); + } ); } }; @@ -315,52 +331,68 @@ using TestMath2Types = ::testing::Types< TYPED_TEST_SUITE( TestMath2, TestMath2Types, ); TYPED_TEST( TestMath2, numValues ) -{ this->numValues(); } +{ + this->numValues(); +} TYPED_TEST( TestMath2, convert ) -{ this->convert(); } +{ + this->convert(); +} TYPED_TEST( TestMath2, maxAndMin ) -{ this->maxAndMin(); } +{ + this->maxAndMin(); +} TYPED_TEST( TestMath2, abs ) -{ this->abs(); } +{ + this->abs(); +} TYPED_TEST( TestMath2, square ) -{ this->square(); } +{ + this->square(); +} TYPED_TEST( TestMath2, sqrtAndInvSqrt ) -{ this->sqrtAndInvSqrt(); } +{ + this->sqrtAndInvSqrt(); +} TYPED_TEST( TestMath2, trig ) -{ this->trig(); } +{ + this->trig(); +} TYPED_TEST( TestMath2, exponential ) -{ this->exponential(); } +{ + this->exponential(); +} template< typename LAMBDA > void forAllHalvesinMinus1to1( bool const include1, LAMBDA && lambda ) { forall< parallelDevicePolicy< 32 > >( 1, [include1, lambda] LVARRAY_DEVICE ( int ) - { - __half limit( 1.0 / ( 1 << 13 ) ); - __half increment( 1.0 / ( 1 << 24 ) ); - - for( __half x( 0 ); x < __half( 1 ); limit *= 2, increment *= 2 ) - { - for( ; x < limit; x += increment ) { - lambda( -x ); - lambda( +x ); - } - } - - if( include1 ) - { - lambda( __half( -1 ) ); - lambda( __half( +1 ) ); - } - } ); + __half limit( 1.0 / ( 1 << 13 ) ); + __half increment( 1.0 / ( 1 << 24 ) ); + + for( __half x( 0 ); x < __half( 1 ); limit *= 2, increment *= 2 ) + { + for(; x < limit; x += increment ) + { + lambda( -x ); + lambda( +x ); + } + } + + if( include1 ) + { + lambda( __half( -1 ) ); + lambda( __half( +1 ) ); + } + } ); } void asinHalfAccuracy() @@ -369,16 +401,16 @@ void asinHalfAccuracy() RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); forAllHalvesinMinus1to1( true, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) - { - double const result = math::asin( x ); - double const expected = math::asin( double( x ) ); + { + double const result = math::asin( x ); + double const expected = math::asin( double( x ) ); - double const diff = LvArray::math::abs( result - expected ); - double const rdiff = math::abs( diff / expected ); + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = math::abs( diff / expected ); - maxDiff.max( diff ); - maxRDiff.max( rdiff ); - } ); + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } ); EXPECT_LT( maxDiff.get(), 1.5 * float( NumericLimitsNC< __half >{}.epsilon ) ); EXPECT_LT( maxRDiff.get(), 8 * float( NumericLimitsNC< __half >{}.epsilon ) ); @@ -393,25 +425,25 @@ void asinHalf2Accuracy() RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); forAllHalvesinMinus1to1( true, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) - { - __half2 const result = math::asin( math::convert< __half2 >( x, -x ) ); - double const expected0 = math::asin( double( x ) ); - double const expected1 = math::asin( double( -x ) ); - - { - double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); - double const rdiff0 = math::abs( diff0 / expected0 ); - maxDiff.max( diff0 ); - maxRDiff.max( rdiff0 ); - } - - { - double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); - double const rdiff1 = math::abs( diff1 / expected1 ); - maxDiff.max( diff1 ); - maxRDiff.max( rdiff1 ); - } - } ); + { + __half2 const result = math::asin( math::convert< __half2 >( x, -x ) ); + double const expected0 = math::asin( double( x ) ); + double const expected1 = math::asin( double( -x ) ); + + { + double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); + double const rdiff0 = math::abs( diff0 / expected0 ); + maxDiff.max( diff0 ); + maxRDiff.max( rdiff0 ); + } + + { + double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); + double const rdiff1 = math::abs( diff1 / expected1 ); + maxDiff.max( diff1 ); + maxRDiff.max( rdiff1 ); + } + } ); EXPECT_LT( maxDiff.get(), 1.5 * float( NumericLimitsNC< __half >{}.epsilon ) ); EXPECT_LT( maxRDiff.get(), 8 * float( NumericLimitsNC< __half >{}.epsilon ) ); @@ -427,16 +459,16 @@ void acosHalfAccuracy() // CUDA acos( +/-1 ) produces a NaN :( forAllHalvesinMinus1to1( false, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) - { - double const result = math::acos( x ); - double const expected = math::acos( double( x ) ); + { + double const result = math::acos( x ); + double const expected = math::acos( double( x ) ); - double const diff = LvArray::math::abs( result - expected ); - double const rdiff = abs( diff / expected ); + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = abs( diff / expected ); - maxDiff.max( diff ); - maxRDiff.max( rdiff ); - } ); + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } ); EXPECT_LT( maxDiff.get(), 3 * float( NumericLimitsNC< __half >{}.epsilon ) ); EXPECT_LT( maxRDiff.get(), 1.5 * float( NumericLimitsNC< __half >{}.epsilon ) ); @@ -451,25 +483,25 @@ void acosHalf2Accuracy() RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); forAllHalvesinMinus1to1( false, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) - { - __half2 const result = math::acos( math::convert< __half2 >( x, -x ) ); - double const expected0 = math::acos( double( x ) ); - double const expected1 = math::acos( double( -x ) ); - - { - double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); - double const rdiff0 = math::abs( diff0 / expected0 ); - maxDiff.max( diff0 ); - maxRDiff.max( rdiff0 ); - } - - { - double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); - double const rdiff1 = math::abs( diff1 / expected1 ); - maxDiff.max( diff1 ); - maxRDiff.max( rdiff1 ); - } - } ); + { + __half2 const result = math::acos( math::convert< __half2 >( x, -x ) ); + double const expected0 = math::acos( double( x ) ); + double const expected1 = math::acos( double( -x ) ); + + { + double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); + double const rdiff0 = math::abs( diff0 / expected0 ); + maxDiff.max( diff0 ); + maxRDiff.max( rdiff0 ); + } + + { + double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); + double const rdiff1 = math::abs( diff1 / expected1 ); + maxDiff.max( diff1 ); + maxRDiff.max( rdiff1 ); + } + } ); EXPECT_LT( maxDiff.get(), 3 * float( NumericLimitsNC< __half >{}.epsilon ) ); EXPECT_LT( maxRDiff.get(), 1.5 * float( NumericLimitsNC< __half >{}.epsilon ) ); @@ -484,55 +516,55 @@ void atan2HalfAccuracy() RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); forAllHalvesinMinus1to1( true, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) - { - // atan2( x, 1 ) - { - double const result = math::atan2( x, __half( 1.0 ) ); - double const expected = math::atan2( double( x ), 1.0 ); + { + // atan2( x, 1 ) + { + double const result = math::atan2( x, __half( 1.0 ) ); + double const expected = math::atan2( double( x ), 1.0 ); - double const diff = LvArray::math::abs( result - expected ); - double const rdiff = abs( diff / expected ); + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = abs( diff / expected ); - maxDiff.max( diff ); - maxRDiff.max( rdiff ); - } + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } - // atan2( x, -1 ) - { - double const result = math::atan2( x, __half( -1.0 ) ); - double const expected = math::atan2( double( x ), -1.0 ); + // atan2( x, -1 ) + { + double const result = math::atan2( x, __half( -1.0 ) ); + double const expected = math::atan2( double( x ), -1.0 ); - double const diff = LvArray::math::abs( result - expected ); - double const rdiff = abs( diff / expected ); + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = abs( diff / expected ); - maxDiff.max( diff ); - maxRDiff.max( rdiff ); - } + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } - // atan2( 1, x ) - { - double const result = math::atan2( __half( 1.0 ), x ); - double const expected = math::atan2( 1.0, double( x ) ); + // atan2( 1, x ) + { + double const result = math::atan2( __half( 1.0 ), x ); + double const expected = math::atan2( 1.0, double( x ) ); - double const diff = LvArray::math::abs( result - expected ); - double const rdiff = abs( diff / expected ); + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = abs( diff / expected ); - maxDiff.max( diff ); - maxRDiff.max( rdiff ); - } + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } - // atan2( -1, x ) - { - double const result = math::atan2( __half( -1.0 ), x ); - double const expected = math::atan2( -1.0, double( x ) ); + // atan2( -1, x ) + { + double const result = math::atan2( __half( -1.0 ), x ); + double const expected = math::atan2( -1.0, double( x ) ); - double const diff = LvArray::math::abs( result - expected ); - double const rdiff = abs( diff / expected ); + double const diff = LvArray::math::abs( result - expected ); + double const rdiff = abs( diff / expected ); - maxDiff.max( diff ); - maxRDiff.max( rdiff ); - } - } ); + maxDiff.max( diff ); + maxRDiff.max( rdiff ); + } + } ); EXPECT_LT( maxDiff.get(), 3 * float( NumericLimitsNC< __half >{}.epsilon ) ); EXPECT_LT( maxRDiff.get(), 2 * float( NumericLimitsNC< __half >{}.epsilon ) ); @@ -547,50 +579,50 @@ void atan2Half2Accuracy() RAJA::ReduceMax< RAJA::cuda_reduce, double > maxRDiff( 0 ); forAllHalvesinMinus1to1( true, [maxDiff, maxRDiff] LVARRAY_DEVICE ( __half const x ) - { - // atan2( x, -1 ), atan2( 1, x ); - { - __half2 const result = math::atan2( math::convert< __half2 >( x, 1 ), math::convert< __half2 >( -1, x ) ); - double const expected0 = math::atan2( double( x ), -1 ); - double const expected1 = math::atan2( 1, double( x ) ); - - { - double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); - double const rdiff0 = math::abs( diff0 / expected0 ); - maxDiff.max( diff0 ); - maxRDiff.max( rdiff0 ); - } - - { - double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); - double const rdiff1 = math::abs( diff1 / expected1 ); - maxDiff.max( diff1 ); - maxRDiff.max( rdiff1 ); - } - } - - // atan2( x, 1 ), atan2( -1, x ); - { - __half2 const result = math::atan2( math::convert< __half2 >( x, -1 ), math::convert< __half2 >( 1, x ) ); - double const expected0 = math::atan2( double( x ), 1 ); - double const expected1 = math::atan2( -1, double( x ) ); - - { - double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); - double const rdiff0 = math::abs( diff0 / expected0 ); - maxDiff.max( diff0 ); - maxRDiff.max( rdiff0 ); - } - { - double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); - double const rdiff1 = math::abs( diff1 / expected1 ); - maxDiff.max( diff1 ); - maxRDiff.max( rdiff1 ); - } - } - - } ); + // atan2( x, -1 ), atan2( 1, x ); + { + __half2 const result = math::atan2( math::convert< __half2 >( x, 1 ), math::convert< __half2 >( -1, x ) ); + double const expected0 = math::atan2( double( x ), -1 ); + double const expected1 = math::atan2( 1, double( x ) ); + + { + double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); + double const rdiff0 = math::abs( diff0 / expected0 ); + maxDiff.max( diff0 ); + maxRDiff.max( rdiff0 ); + } + + { + double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); + double const rdiff1 = math::abs( diff1 / expected1 ); + maxDiff.max( diff1 ); + maxRDiff.max( rdiff1 ); + } + } + + // atan2( x, 1 ), atan2( -1, x ); + { + __half2 const result = math::atan2( math::convert< __half2 >( x, -1 ), math::convert< __half2 >( 1, x ) ); + double const expected0 = math::atan2( double( x ), 1 ); + double const expected1 = math::atan2( -1, double( x ) ); + + { + double const diff0 = LvArray::math::abs( double( math::getFirst( result ) ) - expected0 ); + double const rdiff0 = math::abs( diff0 / expected0 ); + maxDiff.max( diff0 ); + maxRDiff.max( rdiff0 ); + } + + { + double const diff1 = LvArray::math::abs( double( math::getSecond( result ) ) - expected1 ); + double const rdiff1 = math::abs( diff1 / expected1 ); + maxDiff.max( diff1 ); + maxRDiff.max( rdiff1 ); + } + } + + } ); EXPECT_LT( maxDiff.get(), 3 * float( NumericLimitsNC< __half >{}.epsilon ) ); EXPECT_LT( maxRDiff.get(), 2 * float( NumericLimitsNC< __half >{}.epsilon ) ); @@ -603,22 +635,34 @@ void atan2Half2Accuracy() #if defined( NDEBUG ) TEST( TestHalfMath, asinHalfAccuracy ) -{ asinHalfAccuracy(); } +{ + asinHalfAccuracy(); +} TEST( TestHalfMath, asinHalf2Accuracy ) -{ asinHalf2Accuracy(); } +{ + asinHalf2Accuracy(); +} TEST( TestHalfMath, acosHalfAccuracy ) -{ acosHalfAccuracy(); } +{ + acosHalfAccuracy(); +} TEST( TestHalfMath, acosHalf2Accuracy ) -{ acosHalf2Accuracy(); } +{ + acosHalf2Accuracy(); +} TEST( TestHalfMath, atan2HalfAccuracy ) -{ atan2HalfAccuracy(); } +{ + atan2HalfAccuracy(); +} TEST( TestHalfMath, atan2Half2Accuracy ) -{ atan2Half2Accuracy(); } +{ + atan2Half2Accuracy(); +} #endif diff --git a/unitTests/testMemcpy.cpp b/unitTests/testMemcpy.cpp index 49d83964..f3adcece 100644 --- a/unitTests/testMemcpy.cpp +++ b/unitTests/testMemcpy.cpp @@ -161,10 +161,10 @@ void testMemcpyDevice() memcpy< 0, 0 >( y, {}, x.toViewConst(), {} ); forall< RAJA::cuda_exec< 32 > >( y.size(), [yPtr] LVARRAY_DEVICE ( std::ptrdiff_t const i ) - { - PORTABLE_EXPECT_EQ( yPtr[ i ], i ); - yPtr[ i ] *= 2; - } ); + { + PORTABLE_EXPECT_EQ( yPtr[ i ], i ); + yPtr[ i ] *= 2; + } ); memcpy< 0, 0 >( x, {}, y.toViewConst(), {} ); @@ -179,12 +179,12 @@ void testMemcpyDevice() ArrayView< int, 1, 0, std::ptrdiff_t, BUFFER_TYPE > const yView = y.toView(); forall< RAJA::cuda_exec< 32 > >( y.size(), [yView] LVARRAY_DEVICE ( std::ptrdiff_t const i ) - { - yView[ i ] = -i; - } ); + { + yView[ i ] = -i; + } ); memcpy< 0, 0 >( x, {}, y.toViewConst(), {} ); - + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) { EXPECT_EQ( x[ i ], -i ); @@ -211,10 +211,10 @@ void testAsyncMemcpyDevice() stream.wait_for( &e ); forall< RAJA::cuda_exec< 32 > >( y.size(), [yPtr] LVARRAY_DEVICE ( std::ptrdiff_t const i ) - { - PORTABLE_EXPECT_EQ( yPtr[ i ], i ); - yPtr[ i ] *= 2; - } ); + { + PORTABLE_EXPECT_EQ( yPtr[ i ], i ); + yPtr[ i ] *= 2; + } ); e = memcpy< 0, 0 >( stream, x, {}, y.toViewConst(), {} ); stream.wait_for( &e ); @@ -230,13 +230,13 @@ void testAsyncMemcpyDevice() ArrayView< int, 1, 0, std::ptrdiff_t, BUFFER_TYPE > const yView = y.toView(); forall< RAJA::cuda_exec< 32 > >( y.size(), [yView] LVARRAY_DEVICE ( std::ptrdiff_t const i ) - { - yView[ i ] = -i; - } ); + { + yView[ i ] = -i; + } ); e = memcpy< 0, 0 >( stream, x, {}, y.toViewConst(), {} ); stream.wait_for( &e ); - + for( std::ptrdiff_t i = 0; i < x.size(); ++i ) { EXPECT_EQ( x[ i ], -i ); diff --git a/unitTests/testUtils.hpp b/unitTests/testUtils.hpp index 98e96d22..5a2db2bf 100644 --- a/unitTests/testUtils.hpp +++ b/unitTests/testUtils.hpp @@ -105,11 +105,11 @@ LAYOUT const & getRAJAViewLayout( RAJA::View< T, LAYOUT > const & view ) #ifndef __CUDA_ARCH__ #define PORTABLE_EXPECT_EQ( L, R ) EXPECT_EQ( L, R ) -#define PORTABLE_EXPECT_NEAR( L, R, EPSILON ) EXPECT_LE( math::abs( ( L ) - ( R ) ), EPSILON ) << \ +#define PORTABLE_EXPECT_NEAR( L, R, EPSILON ) EXPECT_LE( math::abs( ( L ) -( R ) ), EPSILON ) << \ STRINGIZE( L ) " = " << ( L ) << "\n" << STRINGIZE( R ) " = " << ( R ); #else #define PORTABLE_EXPECT_EQ( L, R ) LVARRAY_ERROR_IF_NE( L, R ) -#define PORTABLE_EXPECT_NEAR( L, R, EPSILON ) LVARRAY_ERROR_IF_GE_MSG( math::abs( ( L ) - ( R ) ), EPSILON, \ +#define PORTABLE_EXPECT_NEAR( L, R, EPSILON ) LVARRAY_ERROR_IF_GE_MSG( math::abs( ( L ) -( R ) ), EPSILON, \ STRINGIZE( L ) " = " << ( L ) << "\n" << STRINGIZE( R ) " = " << ( R ) ); #endif From b7d69ea318feba9c976c719726c08fb817fc89f4 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Thu, 29 Apr 2021 23:18:16 -0700 Subject: [PATCH 14/16] Removed constexpr from math functions. --- src/math.hpp | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/math.hpp b/src/math.hpp index 7fed344b..420c4d7b 100644 --- a/src/math.hpp +++ b/src/math.hpp @@ -457,7 +457,7 @@ T square( T const x ) * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double * and the return type is @c double. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline float sqrt( float const x ) { #if defined(__CUDA_ARCH__) @@ -469,7 +469,7 @@ float sqrt( float const x ) /// @copydoc sqrt( float ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline double sqrt( T const x ) { #if defined(__CUDA_ARCH__) @@ -499,7 +499,7 @@ __half2 sqrt( __half2 const x ) * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double * and the return type is double. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline float invSqrt( float const x ) { #if defined(__CUDA_ARCH__) @@ -511,7 +511,7 @@ float invSqrt( float const x ) /// @copydoc invSqrt( float ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline double invSqrt( T const x ) { #if defined( __CUDA_ARCH__ ) @@ -548,7 +548,7 @@ __half2 invSqrt( __half2 const x ) * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double * and the return type is double. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline float sin( float const theta ) { #if defined(__CUDA_ARCH__) @@ -560,7 +560,7 @@ float sin( float const theta ) /// @copydoc sin( float ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline double sin( T const theta ) { #if defined(__CUDA_ARCH__) @@ -590,7 +590,7 @@ __half2 sin( __half2 const theta ) * @note This set of overloads is valid for any numeric type. If @p theta is not a float * it is converted to a double and the return type is double. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline float cos( float const theta ) { #if defined(__CUDA_ARCH__) @@ -602,7 +602,7 @@ float cos( float const theta ) /// @copydoc cos( float ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline double cos( T const theta ) { #if defined(__CUDA_ARCH__) @@ -632,7 +632,7 @@ __half2 cos( __half2 const theta ) * @param sinTheta The sine of @p theta. * @param cosTheta The cosine of @p theta. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline void sincos( float const theta, float & sinTheta, float & cosTheta ) { #if defined(__CUDA_ARCH__) @@ -645,7 +645,7 @@ void sincos( float const theta, float & sinTheta, float & cosTheta ) /// @copydoc sincos( float, float &, float & ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline void sincos( double const theta, double & sinTheta, double & cosTheta ) { #if defined(__CUDA_ARCH__) @@ -658,7 +658,7 @@ void sincos( double const theta, double & sinTheta, double & cosTheta ) /// @copydoc sincos( float, float &, float & ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline void sincos( T const theta, double & sinTheta, double & cosTheta ) { #if defined(__CUDA_ARCH__) @@ -698,7 +698,7 @@ void sincos( __half2 const theta, __half2 & sinTheta, __half2 & cosTheta ) * @note This set of overloads is valid for any numeric type. If @p theta is not a float * it is converted to a double and the return type is double. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline float tan( float const theta ) { #if defined(__CUDA_ARCH__) @@ -710,7 +710,7 @@ float tan( float const theta ) /// @copydoc tan( float ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline double tan( T const theta ) { #if defined(__CUDA_ARCH__) @@ -764,7 +764,7 @@ namespace internal * @note Modified from https://developer.download.nvidia.com/cg/asin.html */ template< typename T > -LVARRAY_DEVICE inline constexpr +LVARRAY_DEVICE inline T asinImpl( T const x ) { T const negate = lessThan( x, math::convert< T >( 0 ) ); @@ -786,7 +786,7 @@ T asinImpl( T const x ) * @note Modified from https://developer.download.nvidia.com/cg/acos.html */ template< typename T > -LVARRAY_DEVICE inline constexpr +LVARRAY_DEVICE inline T acosImpl( T const x ) { T const negate = lessThan( x, math::convert< T >( 0 ) ); @@ -808,7 +808,7 @@ T acosImpl( T const x ) * @note Modified from https://developer.download.nvidia.com/cg/atan2.html */ template< typename T > -LVARRAY_DEVICE inline constexpr +LVARRAY_DEVICE inline T atan2Impl( T const y, T const x ) { T const absX = abs( x ); @@ -842,7 +842,7 @@ T atan2Impl( T const y, T const x ) * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double * and the return type is double. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline float asin( float const x ) { #if defined(__CUDA_ARCH__) @@ -854,7 +854,7 @@ float asin( float const x ) /// @copydoc asin( float ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline double asin( T const x ) { #if defined(__CUDA_ARCH__) @@ -884,7 +884,7 @@ __half2 asin( __half2 const x ) * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double * and the return type is double. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline float acos( float const x ) { #if defined(__CUDA_ARCH__) @@ -896,7 +896,7 @@ float acos( float const x ) /// @copydoc acos( float ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline double acos( T const x ) { #if defined(__CUDA_ARCH__) @@ -927,7 +927,7 @@ __half2 acos( __half2 const x ) * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double * and the return type is double. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline float atan2( float const y, float const x ) { #if defined(__CUDA_ARCH__) @@ -939,7 +939,7 @@ float atan2( float const y, float const x ) /// @copydoc atan2( float, float ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline double atan2( T const y, T const x ) { #if defined(__CUDA_ARCH__) @@ -976,7 +976,7 @@ __half2 atan2( __half2 const y, __half2 const x ) * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double * and the return type is double. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline float exp( float const x ) { #if defined(__CUDA_ARCH__) @@ -988,7 +988,7 @@ float exp( float const x ) /// @copydoc exp( float ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline double exp( T const x ) { #if defined(__CUDA_ARCH__) @@ -1018,7 +1018,7 @@ __half2 exp( __half2 const x ) * @note This set of overloads is valid for any numeric type. If @p x is integral it is converted to @c double * and the return type is double. */ -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline float log( float const x ) { #if defined(__CUDA_ARCH__) @@ -1030,7 +1030,7 @@ float log( float const x ) /// @copydoc log( float ) template< typename T > -LVARRAY_HOST_DEVICE inline constexpr +LVARRAY_HOST_DEVICE inline double log( T const x ) { #if defined(__CUDA_ARCH__) From 6417ea603e62aaa58f324bc0791e2426a52339b4 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Tue, 4 May 2021 01:39:40 -0700 Subject: [PATCH 15/16] Changes for CUDA 11. --- src/math.hpp | 8 ++++---- src/typeManipulation.hpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/math.hpp b/src/math.hpp index 420c4d7b..f832e0fa 100644 --- a/src/math.hpp +++ b/src/math.hpp @@ -323,7 +323,7 @@ max( T const a, T const b ) LVARRAY_DEVICE inline __half max( __half const a, __half const b ) { -#if CUDART_VERSION > 11000 +#if CUDART_VERSION > 11000 && (__CUDA_ARCH__ >= 800 || !defined(__CUDA_ARCH__)) return __hmax( a, b ); #else return a > b ? a : b; @@ -334,7 +334,7 @@ __half max( __half const a, __half const b ) LVARRAY_DEVICE inline __half2 max( __half2 const a, __half2 const b ) { -#if CUDART_VERSION > 11000 +#if CUDART_VERSION > 11000 && (__CUDA_ARCH__ >= 800 || !defined(__CUDA_ARCH__)) return __hmax2( a, b ); #else __half2 const aFactor = __hge2( a, b ); @@ -370,7 +370,7 @@ min( T const a, T const b ) LVARRAY_DEVICE inline __half min( __half const a, __half const b ) { -#if CUDART_VERSION > 11000 +#if CUDART_VERSION > 11000 && (__CUDA_ARCH__ >= 800 || !defined(__CUDA_ARCH__)) return __hmin( a, b ); #else return a < b ? a : b; @@ -381,7 +381,7 @@ __half min( __half const a, __half const b ) LVARRAY_DEVICE inline __half2 min( __half2 const a, __half2 const b ) { -#if CUDART_VERSION > 11000 +#if CUDART_VERSION > 11000 && (__CUDA_ARCH__ >= 800 || !defined(__CUDA_ARCH__)) return __hmin2( a, b ); #else __half2 const aFactor = __hle2( a, b ); diff --git a/src/typeManipulation.hpp b/src/typeManipulation.hpp index 9b30218d..09ae46e9 100644 --- a/src/typeManipulation.hpp +++ b/src/typeManipulation.hpp @@ -490,7 +490,8 @@ convertSize( INDEX_TYPE const numU ) static_assert( sizeof( T ) % sizeof( U ) == 0, "T and U need to have compatable sizes." ); INDEX_TYPE const numUPerT = sizeof( T ) / sizeof( U ); - LVARRAY_ERROR_IF_NE( numU % numUPerT, 0 ); + INDEX_TYPE const remainder = numU % numUPerT; + LVARRAY_ERROR_IF_NE( remainder, 0 ); return numU / numUPerT; } From 5fc01f5f851586821bd4cfa2148d646691232f58 Mon Sep 17 00:00:00 2001 From: Benjamin Curtice Corbett Date: Wed, 5 May 2021 22:13:22 -0700 Subject: [PATCH 16/16] Updated release date. --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 65edec6f..d7e7fa87 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -9,7 +9,7 @@ Version vxx.yy.zz -- Release date 20yy-mm-dd * Bug fixes: -Version v0.2.0 -- Release date 2020-04-30 +Version v0.2.0 -- Release date 2020-05-05 ============================================ * New features: