OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_c/] [orcc/] [lib/] [orcc_lib.h] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
#ifndef ORCC_LIB_H
2
#define ORCC_LIB_H
3
 
4
#define MAX_ACTORS 1024
5
 
6
 
7
typedef signed char i8;
8
typedef short i16;
9
typedef int i32;
10
typedef long long int i64;
11
 
12
typedef unsigned char u8;
13
typedef unsigned short u16;
14
typedef unsigned int u32;
15
typedef unsigned long long int u64;
16
 
17
///////////////////////////////////////////////////
18
 
19
#ifndef CACHELINE_SIZE
20
#define CACHELINE_SIZE 4 // 
21
#endif
22
 
23
// Declare the FIFO structure with a size equal to (size)
24
#define DECLARE_FIFO(type, size, count, readersnb) static type array_##count[(size)]; \
25
static unsigned int read_inds_##count[readersnb] = {0}; \
26
static FIFO_T(type) fifo_##count = {{0}, read_inds_##count, {0}, 0, {0}, array_##count};
27
 
28
#define FIFO_T(T) FIFO_T_EXPAND(T)
29
#define FIFO_T_EXPAND(T) fifo_##T##_t
30
 
31
#define FIFO_GET_ROOM(T) FIFO_GET_ROOM_EXPAND(T)
32
#define FIFO_GET_ROOM_EXPAND(T) fifo_ ## T ## _get_room
33
 
34
#define FIFO_GET_NUM_TOKENS(T) FIFO_GET_NUM_TOKENS_EXPAND(T)
35
#define FIFO_GET_NUM_TOKENS_EXPAND(T) fifo_ ## T ## _get_num_tokens
36
 
37
/* Define structure and methods for all types thanks to macro expansion */
38
 
39
#define T i8
40
#include "generic_fifo.h"
41
#undef T
42
 
43
#define T i16
44
#include "generic_fifo.h"
45
#undef T
46
 
47
#define T i32
48
#include "generic_fifo.h"
49
#undef T
50
 
51
#define T i64
52
#include "generic_fifo.h"
53
#undef T
54
 
55
#define T u8
56
#include "generic_fifo.h"
57
#undef T
58
 
59
#define T u16
60
#include "generic_fifo.h"
61
#undef T
62
 
63
#define T u32
64
#include "generic_fifo.h"
65
#undef T
66
 
67
#define T u64
68
#include "generic_fifo.h"
69
#undef T
70
 
71
#define T float
72
#include "generic_fifo.h"
73
#undef T
74
 
75
//#endif  /* _ORCC_FIFO_H_ */
76
 
77
///////////////////////////////////////////////////
78
 
79
 
80
typedef int boolean;
81
#define TRUE  1
82
#define FALSE 0
83
 
84
/* Scheduling strategy codes */
85
typedef enum {
86
    ORCC_SS_ROUND_ROBIN,
87
    ORCC_SS_DD_DRIVEN, /* data-driven & demand-driven */
88
    ORCC_SS_SIZE /* only used for string tab declaration */
89
} schedstrategy_et;
90
 
91
/* Mapping strategy codes */
92
typedef enum {
93
#ifdef METIS_ENABLE
94
    ORCC_MS_METIS_REC,
95
    ORCC_MS_METIS_KWAY_CV,
96
    ORCC_MS_METIS_KWAY_EC,
97
#endif /* METIS_ENABLE */
98
    ORCC_MS_ROUND_ROBIN,
99
    ORCC_MS_QM,
100
    ORCC_MS_WLB,
101
    ORCC_MS_COWLB,
102
    ORCC_MS_KRWLB,
103
    ORCC_MS_SIZE /* only used for string tab declaration */
104
} mappingstrategy_et;
105
 
106
typedef enum reasons {
107
    starved,
108
    full
109
} reasons_t;
110
 
111
typedef struct actor_s actor_t;
112
typedef struct waiting_s waiting_t;
113
typedef struct agent_s agent_t;
114
typedef struct action_s action_t;
115
typedef struct local_scheduler_s local_scheduler_t;
116
typedef struct schedinfo_s schedinfo_t;
117
typedef struct options_s options_t;
118
typedef struct global_scheduler_s global_scheduler_t;
119
typedef struct mapping_s mapping_t;
120
typedef struct network_s network_t;
121
typedef struct connection_s connection_t;
122
 
123
/*
124
 * Actors are the vertices of orcc Networks
125
 */
126
struct actor_s {
127
    char *name;
128
    void (*init_func)(schedinfo_t *);
129
    void (*sched_func)(schedinfo_t *);
130
    int num_inputs; /** number of input ports */
131
    int num_outputs; /** number of output ports */
132
    int in_list; /** set to 1 when the actor is in the schedulable list. Used by add_schedulable to do the membership test in O(1). */
133
    int in_waiting; /** idem with the waiting list. */
134
    local_scheduler_t *sched; /** scheduler which execute this actor. */
135
    int processor_id; /** id of the processor core mapped to this actor. */
136
    int id;
137
    int commCost;  /** Used by Quick Mapping algo */
138
    int triedProcId;  /** Used by Quick Mapping algo */
139
    int evaluated;  /** Used by KL algo */
140
    int workload; /** actor's workload */
141
    double ticks; /** elapsed ticks obtained by profiling */
142
    action_t **actions;
143
    int nb_actions;
144
    double scheduler_workload;
145
    char *class_name;
146
    int firings; /** nb of firings for profiling */
147
    int switches; /** nb of switches for profiling */
148
    int misses; /** nb of misses for profiling */
149
};
150
 
151
 
152
struct waiting_s {
153
    actor_t *waiting_actors[MAX_ACTORS];
154
    volatile unsigned int next_entry;
155
    unsigned int next_waiting;
156
};
157
 
158
 
159
 
160
struct agent_s {
161
    options_t *options; /** Mapping options */
162
    global_scheduler_t *scheduler;
163
    network_t *network;
164
    mapping_t *mapping;
165
    int nb_threads;
166
#ifdef THREADS_ENABLE
167
    orcc_semaphore_t sem_agent;
168
#endif
169
};
170
 
171
 
172
/*
173
 * Actions
174
 */
175
struct action_s {
176
    char *name;
177
    double workload; /** action's workload */
178
    double ticks; /** elapsed ticks obtained by profiling */
179
    double min_ticks; /** elapsed min clockcycles obtained by profiling */
180
    double avg_ticks; /** elapsed average clockcycles obtained by profiling */
181
    double max_ticks; /** elapsed max clockcycles obtained by profiling */
182
    double variance_ticks; /** elapsed clockcycles variance obtained by profiling */
183
    int firings; /** nb of firings for profiling */
184
};
185
 
186
 
187
 
188
struct schedinfo_s {
189
    int num_firings;
190
    reasons_t reason;
191
    int ports; /** contains a mask that indicate the ports affected */
192
};
193
 
194
struct options_s
195
{
196
    /* Video specific options */
197
    char *input_file;
198
    char *input_directory;               // Directory for input files.
199
 
200
    /* Video specific options */
201
    char display_flags;                  // Display flags
202
    int nbLoops;                         // (Deprecated) Number of times the input file is read
203
    int nbFrames;                        // Number of frames to display before closing application
204
    char *yuv_file;                      // Reference YUV file
205
 
206
    /* Runtime options */
207
    schedstrategy_et sched_strategy;     // Strategy for the actor scheduling
208
    char *mapping_input_file;            // Predefined mapping configuration
209
    char *mapping_output_file;           //
210
    int nb_processors;
211
    boolean enable_dynamic_mapping;
212
    mappingstrategy_et mapping_strategy; // Strategy for the actor mapping
213
    int nbProfiledFrames;                // Number of frames to display before remapping application
214
    int mapping_repetition;              // Repetition of the actor remapping
215
 
216
    char *profiling_file; // profiling file
217
    char *write_file; // write file
218
 
219
    /* Debugging options */
220
    boolean print_firings;
221
};
222
 
223
 
224
 
225
struct global_scheduler_s {
226
    local_scheduler_t **schedulers;
227
    int nb_schedulers;
228
    agent_t *agent;
229
};
230
 
231
/*
232
 * Mapping structure store the mapping result
233
 */
234
struct mapping_s {
235
    int number_of_threads;
236
    int *threads_affinities;
237
    actor_t ***partitions_of_actors;
238
    int *partitions_size;
239
};
240
 
241
/*
242
 * Orcc Networks are directed graphs
243
 */
244
struct network_s {
245
    char *name;
246
    actor_t **actors;
247
    connection_t **connections;
248
    int nb_actors;
249
    int nb_connections;
250
};
251
 
252
/*
253
 * Connections are the edges of orcc Networks
254
 */
255
struct connection_s {
256
    actor_t *src;
257
    actor_t *dst;
258
    int workload; /** connections's workload */
259
    long rate; /** communication rate obtained by profiling */
260
};
261
 
262
 
263
 
264
 
265
 
266
struct local_scheduler_s {
267
    int id; /** Unique ID of this scheduler */
268
    int nb_schedulers;
269
    schedstrategy_et strategy; /** Scheduling strategy */
270
 
271
    /* Round robin */
272
    int num_actors; /** number of actors managed by this scheduler */
273
    actor_t **actors; /** static list of actors managed by this scheduler */
274
    int rr_next_schedulable; /** index of the next actor to schedule in last list */
275
 
276
    /* Data demand/driven scheduler */
277
    actor_t *schedulable[MAX_ACTORS]; /** dynamic list of the next actors to schedule */
278
    unsigned int ddd_next_entry; /** index of the next actor to schedule in last list */
279
    unsigned int ddd_next_schedulable; /** index of next actor added in the list */
280
 
281
    /* Multicore with data demand/driven scheduler */
282
    int round_robin; /** set to 1 when last scheduled actor is a result of round robin scheduling */
283
    waiting_t **waiting_schedulable; /** receiving lists from other schedulers of some actors to schedule */
284
 
285
    /* Mapping synchronization */
286
    agent_t *agent;
287
#ifdef THREADS_ENABLE
288
    orcc_semaphore_t sem_thread;
289
#endif
290
};
291
 
292
 
293
 
294
 
295
 
296
 
297
/*
298
 
299
 
300
// a simple delay function
301
 
302
void delay ( unsigned int num ){
303
 
304
        while (num>0){
305
                num--;
306
                nop(); // asm volatile ("nop");
307
        }
308
        return;
309
 
310
}
311
 
312
#ifndef RANDOM_H
313
        #define RANDOM_H
314
 
315
// KISS is one random number generator according to three numbers.
316
static unsigned int x=123456789,y=234567891,z=345678912,w=456789123,c=0;
317
 
318
unsigned int JKISS32() {
319
    unsigned int t;
320
 
321
    y ^= (y<<5); y ^= (y>>7); y ^= (y<<22);
322
 
323
    t = z+w+c; z = w; c = t < 0; w = t&2147483647;
324
 
325
    x += 1411392427;
326
 
327
    return x + y + w;
328
}
329
 
330
unsigned int rand(void){
331
        return JKISS32();
332
}
333
 
334
void srand(unsigned int seed){
335
        x^=seed; y+=seed; z^=seed; w-=seed;
336
}
337
 
338
#endif
339
*/
340
 
341
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.