-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner_seq.cpp
51 lines (47 loc) · 1.48 KB
/
runner_seq.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "runner.hpp"
#include <fstream>
#include <queue>
/*
* ==================================================================================
* | [START] DO NOT MODFIY THIS FILE, THIS IS THE REFERENCE SEQUENTIAL CODE [START] |
*
* This is used to compile the reference sequential executable regardless of
* how you change runner.cpp.
* ==================================================================================
*/
void run_all_tasks(int rank, int num_procs, metric_t &stats, params_t ¶ms)
{
if (rank == 0)
{
std::queue<task_t> task_queue;
std::ifstream istrm(params.input_path, std::ios::binary);
// Read initial tasks
int count;
istrm >> count;
for (int i = 0; i < count; ++i)
{
task_t task;
int type;
istrm >> type >> task.arg_seed;
task.type = static_cast<TaskType>(type);
task.id = task.arg_seed;
task.gen = 0;
task_queue.push(task);
}
// Declare array to store generated descendant tasks
int num_new_tasks = 0;
std::vector<task_t> task_buffer(Nmax);
// std::cout << "Running: ";
while (!task_queue.empty())
{
execute_task(stats, task_queue.front(), num_new_tasks, task_buffer);
// std::cout << "g" << task_queue.front().gen << "." << (int)task_queue.front().type << "#" << task_queue.front().id << " ";
for (int i = 0; i < num_new_tasks; ++i)
{
task_queue.push(task_buffer[i]);
}
task_queue.pop();
}
// std::cout << std::endl;
}
}