-
Notifications
You must be signed in to change notification settings - Fork 0
/
core_api.h
54 lines (41 loc) · 1.19 KB
/
core_api.h
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
/* 046267 Computer Architecture - Spring 2020 - HW #4 */
#ifndef CORE_API_H_
#define CORE_API_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#define REGS_COUNT 8
typedef enum {
CMD_NOP = 0,
CMD_ADD, // dst <- src1 + src2
CMD_SUB, // dst <- src1 - src2
CMD_ADDI, // dst <- src1 + imm
CMD_SUBI, // dst <- src1 - imm
CMD_LOAD, // dst <- Mem[src1 + src2] (src2 may be an immediate)
CMD_STORE, // Mem[dst + src2] <- src1 (src2 may be an immediate)
CMD_HALT,
} cmd_opcode;
typedef struct _inst {
cmd_opcode opcode;
int dst_index;
int src1_index;
int src2_index_imm;
bool isSrc2Imm; // if the second argument is immediate
} Instruction;
typedef struct _regs {
int reg[REGS_COUNT];
} tcontext;
/* Simulates blocked MT and fine-grained MT behavior, respectively */
void CORE_BlockedMT();
void CORE_FinegrainedMT();
/* Get thread register file through the context pointer */
void CORE_BlockedMT_CTX(tcontext context[], int threadid);
void CORE_FinegrainedMT_CTX(tcontext context[], int threadid);
/* Return performance in CPI metric */
double CORE_BlockedMT_CPI();
double CORE_FinegrainedMT_CPI();
#ifdef __cplusplus
}
#endif
#endif /* CORE_API_H_ */