diff options
| author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-04-11 11:00:35 -0400 |
|---|---|---|
| committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-04-11 11:00:35 -0400 |
| commit | 7f5bca0f5d1c1bfc56c83e248360720ef45c842a (patch) | |
| tree | 542dc955de70f2d573de50848680046f923029e0 /native/include | |
| parent | 20f6bc1e25b366c55fb95fb084ded37407042071 (diff) | |
Rename time types used in C++ schedulablity analysis
integral_t == integral time units
fractional_t == fractions of integral time units
This is hopefully less of an eyesore than mpq_class and mpz_class.
Diffstat (limited to 'native/include')
| -rw-r--r-- | native/include/edf/baker.h | 4 | ||||
| -rw-r--r-- | native/include/edf/baruah.h | 16 | ||||
| -rw-r--r-- | native/include/edf/bcl.h | 2 | ||||
| -rw-r--r-- | native/include/edf/ffdbf.h | 6 | ||||
| -rw-r--r-- | native/include/edf/load.h | 2 | ||||
| -rw-r--r-- | native/include/math-helper.h | 6 | ||||
| -rw-r--r-- | native/include/tasks.h | 34 | ||||
| -rw-r--r-- | native/include/time-types.h | 15 |
8 files changed, 47 insertions, 38 deletions
diff --git a/native/include/edf/baker.h b/native/include/edf/baker.h index c3716df..44493e5 100644 --- a/native/include/edf/baker.h +++ b/native/include/edf/baker.h | |||
| @@ -8,8 +8,8 @@ class BakerGedf : public SchedulabilityTest | |||
| 8 | unsigned int m; | 8 | unsigned int m; |
| 9 | 9 | ||
| 10 | private: | 10 | private: |
| 11 | void beta(const Task &t_i, const Task &t_k, const mpq_class &lambda_k, | 11 | void beta(const Task &t_i, const Task &t_k, const fractional_t &lambda_k, |
| 12 | mpq_class &beta_i); | 12 | fractional_t &beta_i); |
| 13 | bool is_task_schedulable(unsigned int k, const TaskSet &ts); | 13 | bool is_task_schedulable(unsigned int k, const TaskSet &ts); |
| 14 | 14 | ||
| 15 | public: | 15 | public: |
diff --git a/native/include/edf/baruah.h b/native/include/edf/baruah.h index c79b49d..f6f9217 100644 --- a/native/include/edf/baruah.h +++ b/native/include/edf/baruah.h | |||
| @@ -9,14 +9,14 @@ private: | |||
| 9 | 9 | ||
| 10 | bool is_task_schedulable(unsigned int k, | 10 | bool is_task_schedulable(unsigned int k, |
| 11 | const TaskSet &ts, | 11 | const TaskSet &ts, |
| 12 | const mpz_class &ilen, | 12 | const integral_t &ilen, |
| 13 | mpz_class &i1, | 13 | integral_t &i1, |
| 14 | mpz_class &sum, | 14 | integral_t &sum, |
| 15 | mpz_class *idiff, | 15 | integral_t *idiff, |
| 16 | mpz_class **ptr); | 16 | integral_t **ptr); |
| 17 | 17 | ||
| 18 | void get_max_test_points(const TaskSet &ts, mpq_class& m_minus_u, | 18 | void get_max_test_points(const TaskSet &ts, fractional_t& m_minus_u, |
| 19 | mpz_class* maxp); | 19 | integral_t* maxp); |
| 20 | 20 | ||
| 21 | public: | 21 | public: |
| 22 | BaruahGedf(unsigned int num_processors) : m(num_processors) {}; | 22 | BaruahGedf(unsigned int num_processors) : m(num_processors) {}; |
diff --git a/native/include/edf/bcl.h b/native/include/edf/bcl.h index 31bf1e3..aa4d818 100644 --- a/native/include/edf/bcl.h +++ b/native/include/edf/bcl.h | |||
| @@ -9,7 +9,7 @@ class BCLGedf : public SchedulabilityTest | |||
| 9 | 9 | ||
| 10 | private: | 10 | private: |
| 11 | unsigned long max_jobs_contained(const Task &t_i, const Task &t_k); | 11 | unsigned long max_jobs_contained(const Task &t_i, const Task &t_k); |
| 12 | void beta(const Task &t_i, const Task &t_k, mpq_class &beta_i); | 12 | void beta(const Task &t_i, const Task &t_k, fractional_t &beta_i); |
| 13 | bool is_task_schedulable(unsigned int k, const TaskSet &ts); | 13 | bool is_task_schedulable(unsigned int k, const TaskSet &ts); |
| 14 | 14 | ||
| 15 | public: | 15 | public: |
diff --git a/native/include/edf/ffdbf.h b/native/include/edf/ffdbf.h index 7e3dac6..a5fb834 100644 --- a/native/include/edf/ffdbf.h +++ b/native/include/edf/ffdbf.h | |||
| @@ -6,12 +6,12 @@ class FFDBFGedf : public SchedulabilityTest | |||
| 6 | private: | 6 | private: |
| 7 | const unsigned int m; | 7 | const unsigned int m; |
| 8 | const unsigned long epsilon_denom; | 8 | const unsigned long epsilon_denom; |
| 9 | const mpq_class sigma_step; | 9 | const fractional_t sigma_step; |
| 10 | 10 | ||
| 11 | private: | 11 | private: |
| 12 | bool witness_condition(const TaskSet &ts, | 12 | bool witness_condition(const TaskSet &ts, |
| 13 | const mpz_class q[], const mpq_class r[], | 13 | const integral_t q[], const fractional_t r[], |
| 14 | const mpq_class &time, const mpq_class &speed); | 14 | const fractional_t &time, const fractional_t &speed); |
| 15 | 15 | ||
| 16 | public: | 16 | public: |
| 17 | FFDBFGedf(unsigned int num_processors, | 17 | FFDBFGedf(unsigned int num_processors, |
diff --git a/native/include/edf/load.h b/native/include/edf/load.h index 36c8f5a..50d7850 100644 --- a/native/include/edf/load.h +++ b/native/include/edf/load.h | |||
| @@ -5,7 +5,7 @@ class LoadGedf : public SchedulabilityTest | |||
| 5 | { | 5 | { |
| 6 | private: | 6 | private: |
| 7 | unsigned int m; | 7 | unsigned int m; |
| 8 | mpq_class epsilon; | 8 | fractional_t epsilon; |
| 9 | 9 | ||
| 10 | public: | 10 | public: |
| 11 | LoadGedf(unsigned int num_processors, | 11 | LoadGedf(unsigned int num_processors, |
diff --git a/native/include/math-helper.h b/native/include/math-helper.h index 10c42c2..063558c 100644 --- a/native/include/math-helper.h +++ b/native/include/math-helper.h | |||
| @@ -1,12 +1,6 @@ | |||
| 1 | #ifndef MATH_HELPER_H | 1 | #ifndef MATH_HELPER_H |
| 2 | #define MATH_HELPER_H | 2 | #define MATH_HELPER_H |
| 3 | 3 | ||
| 4 | static inline void mpq_truncate(mpq_class &val) | ||
| 5 | { | ||
| 6 | val.get_num() -= val.get_num() % val.get_den(); | ||
| 7 | val.canonicalize(); | ||
| 8 | } | ||
| 9 | |||
| 10 | static inline unsigned long divide_with_ceil(unsigned long numer, | 4 | static inline unsigned long divide_with_ceil(unsigned long numer, |
| 11 | unsigned long denom) | 5 | unsigned long denom) |
| 12 | { | 6 | { |
diff --git a/native/include/tasks.h b/native/include/tasks.h index 175206a..dbba8d1 100644 --- a/native/include/tasks.h +++ b/native/include/tasks.h | |||
| @@ -6,10 +6,10 @@ | |||
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | #include <algorithm> | 7 | #include <algorithm> |
| 8 | 8 | ||
| 9 | #include <gmpxx.h> | ||
| 10 | |||
| 11 | #include <math.h> | 9 | #include <math.h> |
| 12 | 10 | ||
| 11 | #include "time-types.h" | ||
| 12 | |||
| 13 | #endif | 13 | #endif |
| 14 | 14 | ||
| 15 | class Task | 15 | class Task |
| @@ -43,8 +43,8 @@ class Task | |||
| 43 | bool is_feasible() const; | 43 | bool is_feasible() const; |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | void get_utilization(mpq_class &util) const; | 46 | void get_utilization(fractional_t &util) const; |
| 47 | void get_density(mpq_class &density) const; | 47 | void get_density(fractional_t &density) const; |
| 48 | 48 | ||
| 49 | // Demand bound function (DBF) and LOAD support. | 49 | // Demand bound function (DBF) and LOAD support. |
| 50 | // This implements Fisher, Baker, and Baruah's PTAS | 50 | // This implements Fisher, Baker, and Baruah's PTAS |
| @@ -64,7 +64,7 @@ class Task | |||
| 64 | } | 64 | } |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | void bound_demand(const mpz_class &time, mpz_class &demand) const | 67 | void bound_demand(const integral_t &time, integral_t &demand) const |
| 68 | { | 68 | { |
| 69 | if (time <= deadline) | 69 | if (time <= deadline) |
| 70 | demand = 0; | 70 | demand = 0; |
| @@ -79,9 +79,9 @@ class Task | |||
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | void bound_load(const mpz_class &time, mpq_class &load) const | 82 | void bound_load(const integral_t &time, fractional_t &load) const |
| 83 | { | 83 | { |
| 84 | mpz_class demand; | 84 | integral_t demand; |
| 85 | 85 | ||
| 86 | if (time > 0) | 86 | if (time > 0) |
| 87 | { | 87 | { |
| @@ -107,14 +107,14 @@ class Task | |||
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | void approx_demand(const mpz_class &time, mpz_class &demand, | 110 | void approx_demand(const integral_t &time, integral_t &demand, |
| 111 | unsigned int k) const | 111 | unsigned int k) const |
| 112 | { | 112 | { |
| 113 | if (time < k * period + deadline) | 113 | if (time < k * period + deadline) |
| 114 | bound_demand(time, demand); | 114 | bound_demand(time, demand); |
| 115 | else | 115 | else |
| 116 | { | 116 | { |
| 117 | mpz_class approx; | 117 | integral_t approx; |
| 118 | 118 | ||
| 119 | approx = time; | 119 | approx = time; |
| 120 | approx -= deadline; | 120 | approx -= deadline; |
| @@ -126,10 +126,10 @@ class Task | |||
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | void approx_load(const mpz_class &time, mpq_class &load, | 129 | void approx_load(const integral_t &time, fractional_t &load, |
| 130 | unsigned int k) const | 130 | unsigned int k) const |
| 131 | { | 131 | { |
| 132 | mpz_class demand; | 132 | integral_t demand; |
| 133 | 133 | ||
| 134 | if (time > 0) | 134 | if (time > 0) |
| 135 | { | 135 | { |
| @@ -148,8 +148,8 @@ class TaskSet | |||
| 148 | { | 148 | { |
| 149 | private: | 149 | private: |
| 150 | Tasks tasks; | 150 | Tasks tasks; |
| 151 | 151 | ||
| 152 | unsigned long k_for_epsilon(unsigned int idx, const mpq_class &epsilon) const; | 152 | unsigned long k_for_epsilon(unsigned int idx, const fractional_t &epsilon) const; |
| 153 | 153 | ||
| 154 | public: | 154 | public: |
| 155 | TaskSet(); | 155 | TaskSet(); |
| @@ -172,11 +172,11 @@ class TaskSet | |||
| 172 | bool has_only_feasible_tasks() const; | 172 | bool has_only_feasible_tasks() const; |
| 173 | bool is_not_overutilized(unsigned int num_processors) const; | 173 | bool is_not_overutilized(unsigned int num_processors) const; |
| 174 | 174 | ||
| 175 | void get_utilization(mpq_class &util) const; | 175 | void get_utilization(fractional_t &util) const; |
| 176 | void get_density(mpq_class &density) const; | 176 | void get_density(fractional_t &density) const; |
| 177 | void get_max_density(mpq_class &max_density) const; | 177 | void get_max_density(fractional_t &max_density) const; |
| 178 | 178 | ||
| 179 | void approx_load(mpq_class &load, const mpq_class &epsilon = 0.1) const; | 179 | void approx_load(fractional_t &load, const fractional_t &epsilon = 0.1) const; |
| 180 | 180 | ||
| 181 | /* wrapper for Python access */ | 181 | /* wrapper for Python access */ |
| 182 | unsigned long get_period(unsigned int idx) const | 182 | unsigned long get_period(unsigned int idx) const |
diff --git a/native/include/time-types.h b/native/include/time-types.h new file mode 100644 index 0000000..a2250d3 --- /dev/null +++ b/native/include/time-types.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | #ifndef TIME_TYPES_H | ||
| 2 | #define TIME_TYPES_H | ||
| 3 | |||
| 4 | #include <gmpxx.h> | ||
| 5 | |||
| 6 | typedef mpz_class integral_t; | ||
| 7 | typedef mpq_class fractional_t; | ||
| 8 | |||
| 9 | static inline void truncate_fraction(fractional_t &val) | ||
| 10 | { | ||
| 11 | val.get_num() -= val.get_num() % val.get_den(); | ||
| 12 | val.canonicalize(); | ||
| 13 | } | ||
| 14 | |||
| 15 | #endif | ||
