32 #include <eztrace_list.h>
33 #include <eztrace_convert.h>
37 #define min( a, b ) ( (a) < (b) ? (a) : (b) )
40 #define max( a, b ) ( (a) > (b) ? (a) : (b) )
43 #define COREBLAS_STATE "ST_Thread"
44 #define COREBLAS_TASK_NAME "Submitted Tasks counter"
45 #define COREBLAS_TASK_ALIAS "STasks"
47 #define COREBLAS_TASKR_NAME "Global Ready Tasks counter"
48 #define COREBLAS_TASKR_ALIAS "GRTasks"
50 #define COREBLAS_TASKWR_NAME "Local Ready Tasks counter"
51 #define COREBLAS_TASKWR_ALIAS "LRTasks"
53 #define COREBLAS_THREADS_MAX 4096
74 static int nbtrhd = 0;
82 #ifdef TRACE_BY_SEQUENCE
84 #define MAX_SEQUENCE 100
85 typedef struct sequence_s {
91 gtg_color_t colors[20];
94 seqtab = (sequence_t*)malloc(MAX_SEQUENCE *
sizeof(sequence_t));
95 memset(seqtab, 0, MAX_SEQUENCE *
sizeof(sequence_t));
98 colors[ 1] = GTG_GREEN;
99 colors[ 2] = GTG_BLUE;
100 colors[ 3] = GTG_WHITE;
101 colors[ 4] = GTG_TEAL;
102 colors[ 5] = GTG_DARKGREY;
103 colors[ 6] = GTG_YELLOW;
104 colors[ 7] = GTG_PURPLE;
105 colors[ 8] = GTG_LIGHTBROWN;
106 colors[ 9] = GTG_DARKBLUE;
107 colors[10] = GTG_PINK;
108 colors[11] = GTG_DARKPINK;
109 colors[12] = GTG_SEABLUE;
110 colors[13] = GTG_KAKI;
111 colors[14] = GTG_REDBLOOD;
112 colors[15] = GTG_BROWN;
113 colors[16] = GTG_GRENAT;
114 colors[17] = GTG_ORANGE;
115 colors[18] = GTG_MAUVE;
116 colors[19] = GTG_LIGHTPINK;
120 void sequenceDestroy(){
122 while( i < MAX_SEQUENCE && seqtab[i].
id != 0)
124 free(seqtab[i].
name);
130 char *getSequence(uint64_t seq)
134 while ( (i < MAX_SEQUENCE)
135 && (seqtab[i].
id != 0)
136 && (seqtab[i].
id != seq) )
139 if (i < MAX_SEQUENCE)
141 if ( seqtab[i].
id == seq )
143 return seqtab[i].name;
148 if ( asprintf(&(seqtab[i].
name),
"Sequence%03d", i) < 0 ) {
149 fprintf(stderr,
"Failed to create new sequence name\n");
153 addEntityValue(seqtab[i].name,
COREBLAS_STATE, seqtab[i].name, colors[i%20] );
154 return seqtab[i].name;
157 fprintf(stderr,
"WARNING: Too many sequences, you need to increase the limit and recompile\n");
158 return "SequenceOutOfRange";
161 #define HANDLE(func) \
162 void handle_coreblas_##func##_start (struct fxt_ev_64 *ev) \
165 INIT_THREAD_ID(_threadstr); \
166 if ( GET_NBPARAMS(ev) > 0 ) { \
167 CHANGE() setState (CURRENT, COREBLAS_STATE, _threadstr, getSequence(GET_PARAM(ev, 2))); \
169 CHANGE() setState (CURRENT, COREBLAS_STATE, _threadstr, #func); \
174 #define HANDLE(func) \
175 void handle_coreblas_##func##_start (struct fxt_ev_64 *ev) \
178 INIT_THREAD_ID(_threadstr); \
179 if ( GET_NBPARAMS(ev) > 0 ) { \
180 CHANGE() setState (CURRENT, COREBLAS_STATE, _threadstr, #func); \
182 CHANGE() setState (CURRENT, COREBLAS_STATE, _threadstr, #func); \
191 INIT_PROCESS_ID(process_id);
192 assert( GET_NBPARAMS(ev) == 1 );
193 int value = (int)GET_PARAM(ev, 1);
201 assert( GET_NBPARAMS(ev) == 2 );
202 INIT_PROCESS_ID(process_id);
203 INIT_SPECIFIC_THREAD_ID(thread_id, CUR_ID, (
unsigned int)GET_PARAM(ev, 1));
204 int value = (int)GET_PARAM(ev, 2);
322 INIT_THREAD_ID(_threadstr);
434 addEntityValue(
"brdalg",
COREBLAS_STATE,
"brdalg", GTG_LIGHTPINK );
435 addEntityValue(
"trdalg",
COREBLAS_STATE,
"trdalg", GTG_LIGHTPINK );
444 #ifdef TRACE_BY_SEQUENCE
588 if ( statsarray == NULL ) {
600 for (i=0; i<nbtrhd; i++) {
601 if ( thrdstate[i].tid == (
unsigned int)CUR_THREAD_ID) {
602 if ( thrdstate[i].active == 0 ) {
603 fprintf(stderr,
"WARNING: The end of a state appears before the beginning\n");
607 time = ( CURRENT - thrdstate[i].
lasttime );
609 if( statsarray[ thrdstate[i].active ].nb == 0 ) {
610 statsarray[ thrdstate[i].
active ].
sum = 0.;
611 statsarray[ thrdstate[i].
active ].
max = 0.;
612 statsarray[ thrdstate[i].
active ].
min = 999999999999.;
614 statsarray[ thrdstate[i].
active ].
nb++;
615 statsarray[ thrdstate[i].
active ].
sum += time;
616 statsarray[ thrdstate[i].
active ].
max =
max( statsarray[ thrdstate[i].active ].
max, time );
617 statsarray[ thrdstate[i].
active ].
min =
min( statsarray[ thrdstate[i].active ].
min, time );
635 for (i=0; i<nbtrhd; i++) {
636 if ( thrdstate[i].tid == (
unsigned int)CUR_THREAD_ID) {
637 if ( thrdstate[i].active != 0 ) {
638 fprintf(stderr,
"WARNING: thread %d change to state %d before to stop previous state %d\n",
650 thrdstate[nbtrhd].
tid = (
unsigned int)CUR_THREAD_ID;
652 thrdstate[nbtrhd].
lasttime = CURRENT;
671 printf (
"\nCoreblas Module:\n");
672 printf (
"-----------\n");
675 if ( statsarray[ i ].nb > 0 ) {
676 printf (
"%s : %d calls\n"
677 "\tAverage time: %.3f ms\n"
678 "\tMaximun time: %.3f ms\n"
679 "\tMinimun time: %.3f ms\n",
680 coreblas_stats_strings[ i ], statsarray[ i ].nb,
681 statsarray[ i ].
sum / (
double)(statsarray[ i ].nb), statsarray[ i ].
max, statsarray[ i ].
min);
688 void libinit(
void) __attribute__ ((constructor));
714 fprintf(stderr,
"Failed to create module name\n");
717 if ( asprintf(&
coreblas_module.description,
"Module for kernels used in PLASMA (BLAS, LAPACK and coreblas)") < 0 ) {
718 fprintf(stderr,
"Failed to create module description\n");
727 printf(
"module Coreblas loaded\n");
733 #ifdef TRACE_BY_SEQUENCE