6 // Core Prof turned off
8 #define CP_LOGEVENT( eventID, eventType ) ;
22 #define CP_MAXEVENTS (1024*1024*128)
26 // MASK should be enough bits to mask
27 // the values of the following event types
28 // and BASESHIFT is for shifting IDs
30 #define CP_EVENT_MASK 3
31 #define CP_EVENT_BASESHIFT 2
33 #define CP_EVENTTYPE_BEGIN 0
34 #define CP_EVENTTYPE_END 1
35 #define CP_EVENTTYPE_ONEOFF 2
38 #define CP_EVENTID_MAIN 0
39 #define CP_EVENTID_RUNMALLOC 1
40 #define CP_EVENTID_RUNFREE 2
41 #define CP_EVENTID_TASKDISPATCH 3
42 #define CP_EVENTID_TASKRETIRE 4
43 #define CP_EVENTID_TASKSTALLVAR 5
44 #define CP_EVENTID_TASKSTALLMEM 6
47 struct coreprofmonitor {
48 struct coreprofmonitor* next;
50 // index for next empty slot in the following arrays
52 unsigned int events [CP_MAXEVENTS];
53 long long logTimes_ms[CP_MAXEVENTS];
57 extern __thread int cp_threadnum;
58 extern __thread struct coreprofmonitor* cp_monitor;
59 extern struct coreprofmonitor* cp_monitorList;
62 #ifndef COREPROF_CHECKOVERFLOW
63 // normal, no overflow check version
64 #define CP_LOGEVENT( eventID, eventType ) { \
65 cp_monitor->events[cp_monitor->numEvents] = \
66 ((eventID<<CP_EVENT_BASESHIFT)|eventType); \
67 cp_monitor->logTimes_ms[cp_monitor->numEvents] = rdtsc(); \
68 cp_monitor->numEvents++; \
71 // check for event overflow, DEBUG ONLY!
72 void cp_reportOverflow();
73 #define CP_LOGEVENT( eventID, eventType ) { \
74 if( cp_monitor->numEvents == CP_MAXEVENTS ) \
75 { cp_reportOverflow(); } \
76 cp_monitor->events[cp_monitor->numEvents] = \
77 ((eventID<<CP_EVENT_BASESHIFT)|eventType); \
78 cp_monitor->logTimes_ms[cp_monitor->numEvents] = rdtsc(); \
79 cp_monitor->numEvents++; \
84 #define CP_CREATE() cp_create();
85 #define CP_EXIT() cp_exit();
86 #define CP_DUMP() cp_dump();
94 static inline void* cp_calloc( int size ) {
95 //CP_LOGEVENT( CP_EVENTID_RUNMALLOC, CP_EVENTTYPE_BEGIN );
96 void* mem = calloc( 1, size );
97 //CP_LOGEVENT( CP_EVENTID_RUNMALLOC, CP_EVENTTYPE_END );
101 static inline void cp_free( void* ptr ) {
102 //CP_LOGEVENT( CP_EVENTID_RUNFREE, CP_EVENTTYPE_BEGIN );
104 //CP_LOGEVENT( CP_EVENTID_RUNFREE, CP_EVENTTYPE_END );