1 #ifndef BAMBOO_MULTICORE_TASK_PROFILE_H
2 #define BAMBOO_MULTICORE_TASK_PROFILE_H
6 // data structures for profile mode
8 #define TASKINFOLENGTH 3000
10 typedef struct task_info {
12 unsigned long long startTime;
13 unsigned long long endTime;
14 unsigned long long exitIndex;
15 struct Queue * newObjs;
18 typedef struct task_profile {
19 TaskInfo_t * taskInfoArray[TASKINFOLENGTH];
21 bool taskInfoOverflow;
24 extern TaskProfile_t taskProfileInfo;
25 #ifdef PROFILE_INTERRUPT
26 #define INTERRUPTINFOLENGTH 50
27 typedef struct interrupt_info {
28 unsigned long long startTime;
29 unsigned long long endTime;
32 typedef struct interrupt_profile {
33 InterruptInfo_t * interruptInfoArray[INTERRUPTINFOLENGTH];
34 int interruptInfoIndex;
35 bool interruptInfoOverflow;
38 extern InterruptProfile_t interruptProfileInfo;
41 void outputProfileData();
42 void inittaskprofiledata();
44 INLINE static void setTaskExitIndex(int index) {
45 taskProfileInfo.taskInfoArray[taskProfileInfo.taskInfoIndex]->exitIndex = index;
48 INLINE static void addNewObjInfo(void * nobj) {
49 if(taskProfileInfo.taskInfoArray[taskProfileInfo.taskInfoIndex]->newObjs==NULL) {
50 taskProfileInfo.taskInfoArray[taskProfileInfo.taskInfoIndex]->newObjs=createQueue();
52 addNewItem(taskProfileInfo.taskInfoArray[taskProfileInfo.taskInfoIndex]->newObjs, nobj);
55 INLINE static void profileTaskStart(char * taskname) {
56 if(!taskProfileInfo.taskInfoOverflow) {
57 TaskInfo* taskInfo=RUNMALLOC(sizeof(struct task_info));
58 taskProfileInfo.taskInfoArray[taskProfileInfo.taskInfoIndex]=taskInfo;
59 taskInfo->taskName=taskname;
60 taskInfo->startTime=BAMBOO_GET_EXE_TIME();
62 taskInfo->exitIndex=-1;
63 taskInfo->newObjs=NULL;
67 INLINE staitc void profileTaskEnd() {
68 if(!taskProfileInfo.taskInfoOverflow) {
69 taskProfileInfo.taskInfoArray[taskProfileInfo.taskInfoIndex]->endTime=BAMBOO_GET_EXE_TIME();
70 taskProfileInfo.taskInfoIndex++;
71 if(taskProfileInfo.taskInfoIndex == TASKINFOLENGTH) {
72 taskProfileInfo.taskInfoOverflow=true;
77 #ifdef PROFILE_INTERRUPT
78 INLINE static void profileInterruptStart_I(void) {
79 if(!interruptProfileInfo.interruptInfoOverflow) {
80 InterruptInfo* intInfo=RUNMALLOC_I(sizeof(struct interrupt_info));
81 interruptProfileInfo.interruptInfoArray[interruptProfileInfo.interruptInfoIndex]=intInfo;
82 intInfo->startTime=BAMBOO_GET_EXE_TIME();
87 INLINE static void profileInterruptEnd_I(void) {
88 if(!interruptProfileInfo.interruptInfoOverflow) {
89 interruptProfileInfo.interruptInfoArray[interruptProfileInfo.interruptInfoIndex]->endTime=BAMBOO_GET_EXE_TIME();
90 interruptProfileInfo.interruptInfoIndex++;
91 if(interruptProfileInfo.interruptInfoIndex==INTERRUPTINFOLENGTH) {
92 interruptProfileInfo.interruptInfoOverflow=true;
96 #endif // PROFILE_INTERRUPT
98 #define INIT_TASKPROFILE_DATA() inittaskprofiledata()
99 #define PROFILE_TASK_START(s) profileTaskStart(s)
100 #define PROFILE_TASK_END() profileTaskEnd()
101 #ifdef PROFILE_INTERRUPT
102 #define PROFILE_INTERRUPT_START() profileInterruptStart_I()
103 #define PROFILE_INTERRUPT_END() profileInterruptEnd_I()
105 #define PROFILE_INTERRUPT_START()
106 #define PROFILE_INTERRUPT_END()
109 #define INIT_TASKPROFILE_DATA()
110 #define PROFILE_TASK_START(s)
111 #define PROFILE_TASK_END()
112 #define PROFILE_INTERRUPT_START()
113 #define PROFILE_INTERRUPT_END()
116 #define INIT_TASKPROFILE_DATA()
117 #define PROFILE_TASK_START(s)
118 #define PROFILE_TASK_END()
119 #define PROFILE_INTERRUPT_START()
120 #define PROFILE_INTERRUPT_END()
122 #endif // BAMBOO_MULTICORE_TASK_PROFILE_H