sa2304

Parallel LowerBound

Feb 28th, 2021
785
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // <execution>
  2. // EXECUTION POLICIES
  3. namespace execution {
  4.     class sequenced_policy {
  5.         // indicates support for only sequential execution, and requests termination on exceptions
  6.     public:
  7.         using _Standard_execution_policy   = int;
  8.         static constexpr bool _Parallelize = false;
  9.         static constexpr bool _Ivdep       = false;
  10.     };
  11.  
  12.     inline constexpr sequenced_policy seq{/* unspecified */};
  13.  
  14.     class parallel_policy {
  15.         // indicates support by element access functions for parallel execution with parallel forward progress
  16.         // guarantees, and requests termination on exceptions
  17.     public:
  18.         using _Standard_execution_policy   = int;
  19.         static constexpr bool _Parallelize = true;
  20.         static constexpr bool _Ivdep       = true;
  21.     };
  22.  
  23.     inline constexpr parallel_policy par{/* unspecified */};
  24.  
  25.     class parallel_unsequenced_policy {
  26.         // indicates support by element access functions for parallel execution with weakly parallel forward progress
  27.         // guarantees, and requests termination on exceptions
  28.         //
  29.         // (at this time, equivalent to parallel_policy)
  30.     public:
  31.         using _Standard_execution_policy   = int;
  32.         static constexpr bool _Parallelize = true;
  33.         static constexpr bool _Ivdep       = true;
  34.     };
  35.  
  36.     inline constexpr parallel_unsequenced_policy par_unseq{/* unspecified */};
  37. /* ... */
  38.  
  39. }
  40.  
  41. // main.cpp https://praktikum.yandex.ru/trainer/cpp/lesson/967eacdd-7320-4832-8f65-57ff96ec2d5a/task/e9f59bfc-56e9-4cf8-aed2-92010996a7fd/?hideTheory=1
  42.  
  43. template <typename RandomAccessIterator, typename Value>
  44. RandomAccessIterator LowerBound(const execution::sequenced_policy&, RandomAccessIterator range_begin, RandomAccessIterator range_end, const Value& value) { ... }
  45.  
  46. template <typename RandomAccessIterator, typename Value>
  47. RandomAccessIterator LowerBound(RandomAccessIterator range_begin, RandomAccessIterator range_end, const Value& value) { ... }
  48.  
  49. template <typename RandomAccessIterator, typename Value>
  50. RandomAccessIterator LowerBound(const execution::parallel_policy&, RandomAccessIterator range_begin, RandomAccessIterator range_end, const Value& value) { ... }
  51.  
  52. // https://en.cppreference.com/w/cpp/algorithm/transform
  53.  
  54. template< class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class UnaryOperation >
  55. ForwardIt2 transform( ExecutionPolicy&& policy, ForwardIt1 first1, ForwardIt1 last1,
  56.                     ForwardIt2 d_first, UnaryOperation unary_op );
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×