-
Notifications
You must be signed in to change notification settings - Fork 9
Adding wrappers for device math functions and polar decomposition #349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 44 commits
d52e573
6d4875e
02e0e1c
63a85d1
943b300
ddcd7b4
f591570
ab63869
1339ea7
82f1ce3
1e0127a
343432d
bf73593
8e86706
c021cc5
efc221d
9275fe7
882b587
e599472
00e117d
1ccdce5
956aa7c
8eb4727
2fa2667
2343b7d
ddc611e
52c1d5e
58fc69d
d89ed76
ac6c0fd
c2efd00
e60fa8f
4194bc9
65c00ec
cff7f1b
1ada56a
2522acf
557f07c
6a90517
c3fcf1f
fead905
00327f8
95aa41e
85136be
34a4ea5
fa06984
ebf14c8
7d4a46b
a1f3c56
bed5b66
8aebaa5
d452637
cd4a94d
c485354
53da4ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -249,7 +249,7 @@ class ArrayOfArraysView | |
|
|
||
| /** | ||
| * @brief Move assignment operator.. | ||
| * @param src the SparsityPatternView to be moved from. | ||
| * @param src the ArrayOfArraysView to be moved from. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice |
||
| * @return *this. | ||
| */ | ||
| LVARRAY_HOST_DEVICE | ||
|
|
@@ -858,10 +858,10 @@ class ArrayOfArraysView | |
| destroyValues( 0, m_numArrays, pairs.first ... ); | ||
|
|
||
| INDEX_TYPE const offsetsSize = ( m_numArrays == 0 ) ? 0 : m_numArrays + 1; | ||
|
|
||
| bufferManipulation::copyInto( m_offsets, offsetsSize, srcOffsets, srcNumArrays + 1 ); | ||
| bufferManipulation::copyInto( m_sizes, m_numArrays, srcSizes, srcNumArrays ); | ||
|
|
||
| INDEX_TYPE const maxOffset = m_offsets[ m_numArrays ]; | ||
| typeManipulation::forEachArg( [maxOffset, srcMaxOffset]( auto & dstBuffer ) | ||
| { | ||
|
|
@@ -1087,4 +1087,23 @@ class ArrayOfArraysView | |
| } | ||
| }; | ||
|
|
||
| /** | ||
| * @brief True if the template type is an ArrayOfArraysView. | ||
| */ | ||
| template< class > | ||
| constexpr bool isArrayOfArraysView = false; | ||
|
|
||
| /** | ||
| * @tparam T The type contained in the ArrayOfArraysView. | ||
| * @tparam INDEX_TYPE The integral type used as an index. | ||
| * @tparam CONST_SIZES True iff the size of each array is constant. | ||
| * @tparam BUFFER_TYPE The type used to manager the underlying allocation. | ||
| * @brief Specialization of isArrayOfArraysView for the ArrayOfArraysView class. | ||
| */ | ||
| template< typename T, | ||
| typename INDEX_TYPE, | ||
| bool CONST_SIZES, | ||
| template< typename > class BUFFER_TYPE > | ||
| constexpr bool isArrayOfArraysView< ArrayOfArraysView< T, INDEX_TYPE, CONST_SIZES, BUFFER_TYPE > > = true; | ||
|
|
||
| } /* namespace LvArray */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -340,7 +340,7 @@ class ChaiBuffer | |
|
|
||
| if( size > 0 ) | ||
| { | ||
| LVARRAY_ERROR_IF_NE_MSG( space, MemorySpace::host, "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 supported for the GPU." ); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice |
||
| std::ptrdiff_t const overlapAmount = std::min( newCapacity, size ); | ||
| arrayManipulation::uninitializedMove( newPointer, overlapAmount, m_pointer ); | ||
| arrayManipulation::destroy( m_pointer, size ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -440,6 +440,113 @@ __half2 abs( __half2 const x ) | |
|
|
||
| #endif | ||
|
|
||
|
|
||
| /** | ||
| * @return The ceiling value of @p x. | ||
| * @param x The number to get the ceiling value of. | ||
| * @note This set of overloads is valid for any numeric type. | ||
| */ | ||
| LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE | ||
| float ceil( float const x ) | ||
| { | ||
| #if defined(LVARRAY_DEVICE_COMPILE) | ||
| return ::ceilf( x ); | ||
| #else | ||
| return std::ceil( x ); | ||
| #endif | ||
| } | ||
|
|
||
| template< typename T > | ||
| LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr | ||
| double ceil( T const x ) | ||
| { | ||
| #if defined(LVARRAY_DEVICE_COMPILE) | ||
| return ::ceil( double ( x ) ); | ||
| #else | ||
| return std::ceil( x ); | ||
| #endif | ||
| } | ||
|
|
||
| #if defined( LVARRAY_USE_DEVICE ) | ||
|
|
||
| /// @copydoc ceil( T ) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless you added tests for |
||
| LVARRAY_DEVICE LVARRAY_FORCE_INLINE | ||
| __half ceil( __half const x ) | ||
| { | ||
| #if CUDART_VERSION > 11000 | ||
| return hceil( x ); | ||
| #else | ||
| return x > __half( 0 ) ? x : -x; | ||
| #endif | ||
| } | ||
|
|
||
| /// @copydoc ceil( T ) | ||
| LVARRAY_DEVICE LVARRAY_FORCE_INLINE | ||
| __half2 ceil( __half2 const x ) | ||
| { | ||
| #if CUDART_VERSION > 11000 | ||
| return h2ceil( x ); | ||
| #else | ||
| return LVARRAY_THROW( "h2ceil is not implemented for host", std::runtime_error ); // This is wrong, copied from other function used to mimic | ||
| #endif | ||
| } | ||
|
|
||
| #endif | ||
|
|
||
|
|
||
| /** | ||
| * @return The floor value of @p x. | ||
| * @param x The number to get the floor value of. | ||
| * @note This set of overloads is valid for any numeric type. | ||
| */ | ||
| LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE | ||
| float floor( float const x ) | ||
| { | ||
| #if defined(LVARRAY_DEVICE_COMPILE) | ||
| return ::floorf( x ); | ||
| #else | ||
| return std::floor( x ); | ||
| #endif | ||
| } | ||
|
|
||
| template< typename T > | ||
| LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr | ||
| double floor( T const x ) | ||
| { | ||
| #if defined(LVARRAY_DEVICE_COMPILE) | ||
| return ::floor( double ( x ) ); | ||
| #else | ||
| return std::floor( x ); | ||
| #endif | ||
| } | ||
|
|
||
| #if defined( LVARRAY_USE_DEVICE ) | ||
|
|
||
| /// @copydoc floor( T ) | ||
| LVARRAY_DEVICE LVARRAY_FORCE_INLINE | ||
| __half floor( __half const x ) | ||
| { | ||
| #if CUDART_VERSION > 11000 | ||
| return hfloor( x ); | ||
| #else | ||
| return x > __half( 0 ) ? x : -x; | ||
| #endif | ||
| } | ||
|
|
||
| /// @copydoc floor( T ) | ||
| LVARRAY_DEVICE LVARRAY_FORCE_INLINE | ||
| __half2 floor( __half2 const x ) | ||
| { | ||
| #if CUDART_VERSION > 11000 | ||
| return h2floor( x ); | ||
| #else | ||
| return LVARRAY_THROW( "h2floor is not implemented for host", std::runtime_error ); | ||
| #endif | ||
| } | ||
|
|
||
| #endif | ||
|
|
||
|
|
||
| /** | ||
| * @return @code x * x @endcode. | ||
| * @tparam T The typeof @p x. | ||
|
|
@@ -452,6 +559,44 @@ T square( T const x ) | |
|
|
||
| ///@} | ||
|
|
||
|
|
||
| /** | ||
| * @name Power. | ||
| */ | ||
| ///@{ | ||
|
|
||
| /** | ||
| * @return The power of @p x. | ||
| * @param x The number to get the power of. | ||
| * @param n The exponent. | ||
| * @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 LVARRAY_FORCE_INLINE | ||
| float pow( float const x, float const n ) | ||
| { | ||
| #if defined(LVARRAY_DEVICE_COMPILE) | ||
| return ::powf( x, n ); | ||
| #else | ||
| return std::pow( x, n ); | ||
| #endif | ||
| } | ||
|
|
||
| /// @copydoc pow( float ) | ||
| template< typename T > | ||
| LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE | ||
| double pow( T const x, T const n ) | ||
| { | ||
| #if defined(LVARRAY_DEVICE_COMPILE) | ||
| return ::pow( double( x ), double( n ) ); | ||
| #else | ||
| return std::pow( x, n ); | ||
| #endif | ||
| } | ||
|
|
||
| ///@} | ||
|
|
||
|
|
||
| /** | ||
| * @name Square root and inverse square root. | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little unsure if this should go here or in GEOS itself.