Commit d1777744 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Sorting: fixed includes, added messages to NotImplementedError

parent e9d6d0d7
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#pragma once

#include <TNL/Algorithms/Sorting/detail/bitonicSort.h>
#include <TNL/Exceptions/NotImplementedError.h>

namespace TNL {
   namespace Algorithms {
@@ -38,12 +39,10 @@ struct BitonicSort
      if( std::is_same< Device, Devices::Cuda >::value )
         bitonicSort( begin, end, compare, swap );
      else
         TNL_ASSERT( false, std::cerr <<  "inplace bitonic sort for CPU is not implemented" << std::endl );
         throw Exceptions::NotImplementedError( "inplace bitonic sort is implemented only for CUDA" );
   }
};

      } // namespace Sorting
   } // namespace Algorithms
} //namespace TNL

+22 −25
Original line number Diff line number Diff line
@@ -13,7 +13,9 @@
#pragma once

#include <algorithm>

#include <TNL/Assert.h>
#include <TNL/Devices/Cuda.h>
#include <TNL/Exceptions/NotImplementedError.h>

namespace TNL {
@@ -25,9 +27,9 @@ struct BubbleSort
   template< typename Device, typename Index, typename Compare, typename Swap >
   void static inplaceSort( const Index begin, const Index end, Compare& compare, Swap& swap )
   {
      if( std::is_same< Device, Devices::Host >::value ||
          std::is_same< Device, Devices::Sequential >::value )
      {
      if( std::is_same< Device, Devices::Cuda >::value )
         throw Exceptions::NotImplementedError( "inplace bubble sort is not implemented for CUDA" );

      Index left( begin ), right( end -1 );
      while( left < right )
      {
@@ -54,13 +56,8 @@ struct BubbleSort
         left++; //lastChange;
      }
   }
      else
         throw Exceptions::NotImplementedError();
   }
};

      } // namespace Sorting
   } // namespace Algorithms
} //namespace TNL

+4 −6
Original line number Diff line number Diff line
@@ -12,8 +12,6 @@

#pragma once

#include <utility>  // std::pair, std::forward

#include <TNL/Devices/Sequential.h>
#include <TNL/Devices/Host.h>
#include <TNL/Devices/Cuda.h>
@@ -30,13 +28,13 @@ template< typename Device >
struct DefaultSorter;

template<>
struct DefaultSorter< Devices::Host >
struct DefaultSorter< Devices::Sequential >
{
   using SorterType = Algorithms::Sorting::STLSort;
};

template<>
struct DefaultSorter< Devices::Sequential >
struct DefaultSorter< Devices::Host >
{
   using SorterType = Algorithms::Sorting::STLSort;
};
@@ -51,13 +49,13 @@ template< typename Device >
struct DefaultInplaceSorter;

template<>
struct DefaultInplaceSorter< Devices::Host >
struct DefaultInplaceSorter< Devices::Sequential >
{
   using SorterType = Algorithms::Sorting::BubbleSort;
};

template<>
struct DefaultInplaceSorter< Devices::Sequential >
struct DefaultInplaceSorter< Devices::Host >
{
   using SorterType = Algorithms::Sorting::BubbleSort;
};
+0 −2
Original line number Diff line number Diff line
@@ -39,5 +39,3 @@ struct Quicksort
      } // namespace Sorting
   } // namespace Algorithms
} //namespace TNL

+0 −2
Original line number Diff line number Diff line
@@ -36,5 +36,3 @@ struct STLSort
      } // namespace Sorting
   } // namespace Algorithms
} //namespace TNL

Loading