annotate include/TaskManager/Scheduler.h @ 1559:c60caac2f345 draft

fix fft
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Sat, 09 Mar 2013 21:23:40 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1559
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #ifndef INCLUDED_SCHEDULER
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #define INCLUDED_SCHEDULER
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include <stdlib.h>
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 #include <stdarg.h>
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "base.h"
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "TaskList.h"
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #include "ListData.h"
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "DmaManager.h"
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #include "SchedTaskBase.h"
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 #include "MemList.h"
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "MemHash.h"
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #include "types.h"
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #ifdef __CERIUM_GPU__
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #ifdef __APPLE__
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 #include <OpenCL/opencl.h>
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 #else
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 #include <CL/cl.h>
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 #endif
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #endif
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #define MAX_USER_TASK 100
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #define MAX_SYSTEM_TASK 2
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #define MAX_TASK_OBJECT MAX_USER_TASK + MAX_SYSTEM_TASK
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #define MAX_GLOBAL_AREA 32
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 #define MAX_MAINMEM_AREA 32
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 class SchedTaskBase;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 class SchedTask;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 class SchedTaskList;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 class TaskManagerImpl;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 class HTask;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 typedef int (*TaskObjectRun)(SchedTask* smanager, void* r, void *w);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 typedef struct gpu_task_object {
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 #ifdef __CERIUM_GPU__
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 cl_program *program;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #endif
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 } GpuTaskObject;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 // Task Object Table
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 // this is named TaskObjectRun but it is not an object.
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 // It is a pointer to an object creation function
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 // 大きいので、SPEには置かない方が本当は良い...
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 // get_segment で取って来るのが、おそらくは正しい。
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 typedef struct task_object {
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 CPU_TYPE cpu_type;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 TaskObjectRun run;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 memaddr location; // location address in a.out
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 memaddr end;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 uint32 entry_offset; // offset for create();
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 MemorySegment *segment;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 const char *name;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 void (*load)(Scheduler *,int);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 void (*wait)(Scheduler *,int);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 GpuTaskObject *gputask;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 } __attribute__ ((aligned (DEFAULT_ALIGNMENT))) //sizeはどれくらい?
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 TaskObject, *TaskObjectPtr;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 extern "C" {
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 extern long random();
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 }
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 class Scheduler {
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 private:
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 TaskManagerImpl* manager_tmp;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 public:
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 virtual ~Scheduler();
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 BASE_NEW_DELETE(Scheduler);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 /* variables */
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 int id;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 MemHash *hash;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 // double buffering
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 TaskListPtr buff_taskList[2];
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 int buffFlag_taskList;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 /* GlobalMemoryList */
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 /* global among Tasks in the same CPU */
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 void* globalList[MAX_GLOBAL_AREA];
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 /* MainMemory Allocate Command List */
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 memaddr mainMemList[MAX_MAINMEM_AREA];
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 /* Code Area */
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 MemList *code_segment_pool;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 DmaManager* connector;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 TaskManagerImpl* manager;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 /* functions */
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 void init(TaskManagerImpl *m, int useRefDma=0, int export_task_log=0);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 virtual void run(){};
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 void run(SchedTaskBase* task1);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 virtual void init_impl(int useRefDma) {};
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 void finish();
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 TaskListPtr get_curListBuf();
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 TaskListPtr get_renewListBuf();
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 void set_backupTaskList(TaskListPtr cur_taskList);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 void set_backupTaskListIndex(int cur_index);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 SchedTaskList* get_nextRenewTaskList();
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 TaskListPtr get_backupTaskList();
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 int get_backupTaskListIndex();
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 /* GlobalMemory */
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 void* global_alloc(int id, int size);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 void* global_get(int id);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 void global_set(int id, void *addr);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 void global_free(int id);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 //MemList* createMemList(int size, int count);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 MemList* createMemList(int size, int count);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 void free_(void *p) { free(p); }
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 virtual void mainMem_alloc(int id, int size) {};
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 virtual void mainMem_wait() {};
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 memaddr mainMem_get(int id);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 MemorySegment * get_segment(memaddr addr, MemList *m);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 MemorySegment * get_segment(memaddr addr, MemList *m, int size);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 MemorySegment * get_free_segment(memaddr addr, MemList *m);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 void overwrite_segment(MemorySegment *s, memaddr addr);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 void allocate_code_segment(int size, int count,struct tbl *table);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 void put_segment(MemorySegment *s);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 void wait_segment(MemorySegment *s);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 /* manager */
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 void set_manager(TaskManagerImpl *m) {
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 manager = m;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 };
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 /* user */
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 long get_random() ;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 Scheduler *get_scheduler() { return this; };
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 int printf(const char *format, ...);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 int vprintf0(const char *format, va_list ap);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 } ;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 extern void register_task(int cmd, TaskObjectRun run, const char *str);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 extern void register_dynamic_task(int cmd,
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 memaddr start, int size, TaskObjectRun run,
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 int entry_offset,
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 const char *str);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 struct tbl {
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 unsigned int vma;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 unsigned int size;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 unsigned int file_offset;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 unsigned int buf;
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 };
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 extern TaskObject task_list[MAX_TASK_OBJECT];
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 int null_run(SchedTask* smanager, void* r, void *w);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 void null_loader(Scheduler *m, int task_id);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 extern int entry_cmd[MAX_TASK_OBJECT];
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 inline void
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 loadSchedTask(Scheduler *scheduler,int command)
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 {
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 task_list[command].load(scheduler,command);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 }
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 #endif
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 #define SchedConstructor(str) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 str() {} \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 BASE_NEW_DELETE(str) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 #define SchedDefineTask(str) SchedDefineTask1(str,run) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 #define SchedDefineTask1(str,run) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 static int run(SchedTask *smanager, void *rbuf, void *wbuf); \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 extern "C" { \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 int runTask_##str(SchedTask *smanager, void *rbuf, void *wbuf) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 { \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 return run(smanager, rbuf, wbuf); \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 } \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 }
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 #define SchedExternTask(str) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 extern "C" { \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 extern int runTask_##str(SchedTask *manager, void *rbuf, void *wbuf) ; \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 }
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 #define SchedRegisterTask(cmd, str) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 register_task(cmd, runTask_##str, #str);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 #define SchedRegister(str) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 register_task(str, runTask_##str, #str);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 #define SchedDefineDynamicTask(str,segment) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 SchedDefineTask(str)
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 #ifndef NO_OVERLAY
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 #define SchedExternDynamicTask(str,segment) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 extern "C" { \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 extern unsigned long long _EAR_; \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 extern struct tbl _ovly_table[]; \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 extern int runTask_##str(SchedTask *manager, void *rbuf, void *wbuf) ; \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 }
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 #else
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 #define SchedExternDynamicTask(str,segment) SchedExternTask(str)
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 #endif
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 #ifndef NO_OVERLAY
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 #define SchedRegisterDynamicTask(cmd, str, segment) \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 register_dynamic_task(cmd, (memaddr)(_EAR_+_ovly_table[segment].file_offset), \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 _ovly_table[segment].size, \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 runTask_##str, \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 runTask_##str##_offset, \
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 #str);
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 #define SchedRegisterDynamic(str, segment) SchedRegisterDynamicTask(str, str, segment)
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 #else
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 #define SchedRegisterDynamicTask(cmd, str, segment) SchedRegisterTask(cmd, str)
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 #define SchedRegisterDynamic(str, segment) SchedRegisterDynamicTask(str, str, segment)
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 #endif
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239
c60caac2f345 fix fft
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 /* end */