
#ifndef PLS_ALGO_LOOP_PARTITION_STRATEGY_H_
#define PLS_ALGO_LOOP_PARTITION_STRATEGY_H_

#include "pls/internal/scheduling/scheduler.h"
#include "pls/internal/scheduling/thread_state.h"

namespace pls::algorithm {
class dynamic_strategy {
 public:
  explicit dynamic_strategy(const unsigned int tasks_per_thread = 4) : tasks_per_thread_{tasks_per_thread} {};

  [[nodiscard]] long calculate_min_elements(long num_elements) const {
    const long num_threads = pls::internal::scheduling::thread_state::get().get_scheduler().num_threads();
    return num_elements / (num_threads * tasks_per_thread_);
  }
 private:
  unsigned const int tasks_per_thread_;
};

class fixed_strategy {
 public:
  explicit fixed_strategy(const long min_elements_per_task) : min_elements_per_task_{min_elements_per_task} {};

  [[nodiscard]] long calculate_min_elements(long /*num_elements*/) const {
    return min_elements_per_task_;
  }
 private:
  const long min_elements_per_task_;
};
}

#endif //PLS_ALGO_LOOP_PARTITION_STRATEGY_H_
