Skip to content

Commit d5a9f22

Browse files
committed
clang 10.0.1 changes.
1 parent d28620b commit d5a9f22

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

src/sortedArrayManipulation.hpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,20 +315,17 @@ std::ptrdiff_t removeDuplicates( ITER first, ITER const last, Compare && comp=Co
315315

316316
std::ptrdiff_t numUnique = 1;
317317

318-
ITER next = first;
319-
320318
/**
321-
* For whatever reason the standard approach doesn't work with XL in release on device.
319+
* The following statement should be
320+
* ITER next = first;
321+
* ++next;
322+
* This works host only however with some host compilers (clang 10.0.1 and XL) it breaks on device in release.
322323
* It does some really strange things, for example `last - next == 0` and they can have identical
323-
* values but `next != last`. If you print out the array each iteration it works as expected. I even
324-
* tried substituting the example code for std::unique from cppreference and that exhibited the same problem.
325-
* My guess is it's most likely a compiler bug.
324+
* values but `next != last`. If you print out the array each iteration it works as expected. It's not a big deal
325+
* since it amounts to just a single extra iteration, but very strange.
326326
*/
327-
#if defined( __ibmxl__ ) && defined( __CUDA_ARCH__ )
328-
while( arrayManipulation::iterDistance( ++next, last ) > 0 )
329-
#else
330-
while( ++next != last )
331-
#endif
327+
ITER next = first;
328+
for(; next != last; ++next )
332329
{
333330
if( comp( *first, *next ) )
334331
{

unitTests/testSortedArrayManipulation.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ class SingleArrayTest : public ::testing::Test
181181
using SingleArrayTestTypes = ::testing::Types<
182182
std::tuple< int, sortedArrayManipulation::less< int >, serialPolicy >
183183
, std::tuple< int, sortedArrayManipulation::greater< int >, serialPolicy >
184+
, std::tuple< Tensor, sortedArrayManipulation::less< Tensor >, serialPolicy >
184185
, std::tuple< Tensor, sortedArrayManipulation::greater< Tensor >, serialPolicy >
185-
, std::tuple< Tensor, sortedArrayManipulation::greater< Tensor >, serialPolicy >
186-
, std::tuple< TestString, sortedArrayManipulation::greater< TestString >, serialPolicy >
186+
, std::tuple< TestString, sortedArrayManipulation::less< TestString >, serialPolicy >
187187
, std::tuple< TestString, sortedArrayManipulation::greater< TestString >, serialPolicy >
188188

189189
#if defined(LVARRAY_USE_CUDA) && defined(LVARRAY_USE_CHAI)
@@ -304,3 +304,11 @@ TYPED_TEST( DualArrayTest, makeSorted )
304304

305305
} // namespace testing
306306
} // namespace LvArray
307+
308+
// This is the default gtest main method. It is included for ease of debugging.
309+
int main( int argc, char * * argv )
310+
{
311+
::testing::InitGoogleTest( &argc, argv );
312+
int const result = RUN_ALL_TESTS();
313+
return result;
314+
}

unitTests/testTensorOpsOneSize.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ class OneSizeTest : public ::testing::Test
372372
T const ( &vectorB_local )[ N ] = m_vectorB_local;
373373

374374
std::ptrdiff_t const aSeed = m_seedVectorA;
375-
T const epsilon = NumericLimitsNC< T >{}.epsilon;
376-
forall< POLICY >( 1, [vectorA_IJ, vectorA_JI, vectorB_IJ, vectorB_JI, vectorB_local, aSeed, epsilon] LVARRAY_HOST_DEVICE ( int )
375+
forall< POLICY >( 1, [vectorA_IJ, vectorA_JI, vectorB_IJ, vectorB_JI, vectorB_local, aSeed] LVARRAY_HOST_DEVICE ( int )
377376
{
378377
#define _TEST( a, b ) \
379378
tensorOps::scaledAdd< N >( a, b, scale ); \
@@ -385,6 +384,8 @@ class OneSizeTest : public ::testing::Test
385384
_TEST( a, b1 ); \
386385
_TEST( a, b2 )
387386

387+
T const epsilon = NumericLimitsNC< T >{}.epsilon;
388+
388389
T vectorA_local[ N ];
389390
fill( vectorA_local, aSeed );
390391

0 commit comments

Comments
 (0)