Commit 1d4b1533 by Tobias Langer

Added refinement in idle loop and task starting.

parent 59981aa2
......@@ -114,6 +114,9 @@ def main():
header = os.path.join(template_path, 'defines.h')
makefile = os.path.join(template_path, 'Makefile')
cpp = os.path.join(template_path, 'experiment.cpp')
timewaste_h = os.path.join(template_path, 'fun.h')
timewaste_cpp = os.path.join(template_path, 'fun.cpp')
timetable = os.path.join(template_path, 'timing_header.h')
try:
output_path = experiment['output']
......@@ -145,6 +148,12 @@ def main():
print('Add C++ file(s)…', file=sys.stderr)
cpp_file_path = os.path.join(experiment_dir, 'experiment.cpp')
shutil.copyfile(cpp, cpp_file_path)
fun_cpp_file_path = os.path.join(experiment_dir, 'fun.cpp')
shutil.copyfile(timewaste_cpp, fun_cpp_file_path)
fun_h_file_path = os.path.join(experiment_dir, 'fun.h')
shutil.copyfile(timewaste_h, fun_h_file_path)
timetable_file_path = os.path.join(experiment_dir, 'timing_header.h')
shutil.copyfile(timetable, timetable_file_path)
if __name__ == '__main__':
main()
......@@ -8,12 +8,27 @@
#include "defines.h"
#include "timing_header.h"
#include "fun.h"
#define UNUSED(x) ((void)(x))
#define DOMAIN_ID 1
#define NODE_ID 1
#define ACTION_ID 2
auto loop_count(int duration) -> long long
{
if(duration < sizeof(timetable) / sizeof(int)) {
return timetable[duration];
}
float m = ((float)timetable[94] - (float)timetable[4]) / (90.0f);
float t = ((float)timetable[9] - m * 9);
return m * (float) duration + t;
}
auto gcd(long long a, long long b) -> long long
{
return b == 0 ? a : gcd(b, a % b);
......@@ -109,8 +124,11 @@ static void IdleTask(const void* args, mtapi_size_t, void*, mtapi_size_t,
auto start_time = base_clock::now();
/* idle until task completion. */
auto idle_time = cpp_time_base(taskset[task_id].wcet);
std::this_thread::sleep_for(idle_time);
auto idle_time = taskset[task_id].wcet;
for(int i = 0; i < loop_count(idle_time); i++) {
donotoptimize();
}
/* Store our benchmarking data. */
auto end_time = base_clock::now();
......@@ -185,7 +203,7 @@ static void TaskStarter()
/* Detached TaskAttribute so we don't have to wait for task completion. */
embb::mtapi::TaskAttributes detached_attribute;
// detached_attribute.SetDetached(true);
detached_attribute.SetDetached(true);
detached_attribute.SetPolicy(deadline_policy[i]);
int tmp; auto t = node.Start(job, &task_arguments[i][count - 1], &tmp, detached_attribute);
......@@ -196,17 +214,6 @@ static void TaskStarter()
}
}
auto wait_start = base_clock::now();
while(min.count() > 0 && running.size() > 0) {
auto status = running.front().Wait(min.count()); // TODO factor for anything bigger than milliseconds
if(status == MTAPI_SUCCESS) {
running.erase(running.begin());
}
auto remain = duration_cast<cpp_time_base>(wait_start - base_clock::now());
if(remain.count() > 0) {
min -= remain;
}
}
std::this_thread::sleep_for(min);
cur_time = duration_cast<cpp_time_base>(base_clock::now() - start);
}
......
#include "fun.h"
void donotoptimize() {}
void donotoptimize();
int timetable[] = {
0,
933, 1564, 2196, 2827, 3459, 4091, 4716, 5353, 5984, 6610, 7230, 7864, 8473, 9110, 9724, 10347, 10968, 11588, 12207, 12816,
13432, 14054, 14710, 15393, 16034, 16664, 17291, 17920, 18545, 19171, 19798, 20425, 21057, 21681, 22308, 22929, 23555, 24182, 24815, 25445,
26073, 26698, 27320, 27952, 28570, 29205, 29828, 30454, 31098, 31713, 32341, 32963, 33589, 34221, 34836, 35461, 36103, 36708, 37340, 37981,
38607, 39241, 39878, 40512, 41136, 41766, 42409, 43041, 43677, 44311, 44943, 45566, 46195, 46833, 47451, 48079, 48707, 49340, 49949, 50590,
51214, 51836, 52454, 53084, 53709, 54346, 54971, 55586, 56233, 56859, 57480, 58106, 58746, 59350, 59980, 60614, 61238, 61862, 62504, 63125,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment