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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "../../../context.h"
int cpu_num = 1;
int length = 102400;
int split = 8;
int* array_ptr;
int gpu_num = 0;
int CPU_ANY = -1;
int CPU_CUDA = -1;
__code initDataGears(struct Context *context,struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
// loopCounter->tree = createRedBlackTree(context);
loopCounter->i = 0;
taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
goto meta(context, C_prevTask);
}
__code initDataGears_stub(struct Context* context) {
LoopCounter* loopCounter = Gearef(context, LoopCounter);
TaskManager* taskManager = Gearef(context, TaskManager);
goto initDataGears(context, loopCounter, taskManager);
}
__code prevTask(struct Context *context,struct LoopCounter* loopCounter) {
printf("cpus:\t\t%d\n", cpu_num);
printf("gpus:\t\t%d\n", gpu_num);
printf("length:\t\t%d\n", length);
printf("length/task:\t%d\n", length/split);
/* puts("queue"); */
/* print_queue(context->data[ActiveQueue]->queue.first); */
/* puts("tree"); */
/* print_tree(context->data[Tree]->tree.root); */
/* puts("result"); */
goto meta(context, C_createTask);
}
__code prevTask_stub(struct Context* context) {
LoopCounter* loopCounter = Gearef(context, LoopCounter);
goto prevTask(context, loopCounter);
}
__code createTask(struct Context *context,struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
Stack* stack = createSingleLinkedStack(context);
StackTest* stackTest = createStackTestImpl3(context);
Gearef(context, StackTest)->stackTest = (union Data*) stackTest;
Gearef(context, StackTest)->stack = stack;
Gearef(context, StackTest)->next = C_shutdown;
goto meta(context, stackTest->insertTest1);
}
__code createTask_stub(struct Context* context) {
LoopCounter* loopCounter = Gearef(context, LoopCounter);
TaskManager* taskManager = Gearef(context, TaskManager);
goto createTask(context, loopCounter, taskManager);
}
__code shutdown(struct Context *context,struct TaskManager* taskManager) {
Gearef(context, TaskManager)->taskManager = (union Data*) taskManager;
Gearef(context, TaskManager)->next = C_exit_code;
goto meta(context, taskManager->shutdown);
}
__code shutdown_stub(struct Context* context) {
goto shutdown(context, &Gearef(context, TaskManager)->taskManager->TaskManager);
}
void init(int argc, char** argv) {
for (int i = 1; argv[i]; ++i) {
if (strcmp(argv[i], "-cpu") == 0)
cpu_num = (int)atoi(argv[i+1]);
else if (strcmp(argv[i], "-l") == 0)
length = (int)atoi(argv[i+1]);
else if (strcmp(argv[i], "-s") == 0)
split = (int)atoi(argv[i+1]);
else if (strcmp(argv[i], "-cuda") == 0) {
gpu_num = 1;
CPU_CUDA = 0;
}
}
}
int main(int argc, char** argv) {
init(argc, argv);
struct Context* main_context = NEW(struct Context);
initContext(main_context);
main_context->next = C_initDataGears;
goto start_code(main_context);
}
|