Pārlūkot izejas kodu

Display the evolution of the number of ready/submitted task in the activity
output.

Cédric Augonnet 15 gadi atpakaļ
vecāks
revīzija
09f2bf484d
4 mainītis faili ar 70 papildinājumiem un 8 dzēšanām
  1. 6 0
      src/common/fxt.h
  2. 6 0
      src/core/task.c
  3. 32 4
      tools/activity.sh
  4. 26 4
      tools/fxt_tool.c

+ 6 - 0
src/common/fxt.h

@@ -45,6 +45,8 @@
 #define STARPU_FUT_JOB_PUSH		0x5105
 #define STARPU_FUT_JOB_POP		0x5106
 
+#define STARPU_FUT_UPDATE_TASK_CNT	0x5141
+
 #define STARPU_FUT_START_FETCH_INPUT	0x5107
 #define STARPU_FUT_END_FETCH_INPUT	0x5108
 #define STARPU_FUT_START_PUSH_OUTPUT	0x5109
@@ -173,6 +175,9 @@ do {									\
 #define STARPU_TRACE_JOB_POP(task, prio)	\
 	FUT_DO_PROBE3(STARPU_FUT_JOB_POP, task, prio, syscall(SYS_gettid));
 
+#define STARPU_TRACE_UPDATE_TASK_CNT(counter)	\
+	FUT_DO_PROBE2(STARPU_FUT_UPDATE_TASK_CNT, counter, syscall(SYS_gettid))
+
 #define STARPU_TRACE_START_FETCH_INPUT(job)	\
 	FUT_DO_PROBE2(STARPU_FUT_START_FETCH_INPUT, job, syscall(SYS_gettid));
 
@@ -295,6 +300,7 @@ do {										\
 #define STARPU_TRACE_END_CALLBACK(job)		do {} while(0);
 #define STARPU_TRACE_JOB_PUSH(task, prio)	do {} while(0);
 #define STARPU_TRACE_JOB_POP(task, prio)	do {} while(0);
+#define STARPU_TRACE_UPDATE_TASK_CNT(counter)	do {} while(0);
 #define STARPU_TRACE_START_FETCH_INPUT(job)	do {} while(0);
 #define STARPU_TRACE_END_FETCH_INPUT(job)	do {} while(0);
 #define STARPU_TRACE_START_PUSH_OUTPUT(job)	do {} while(0);

+ 6 - 0
src/core/task.c

@@ -298,6 +298,8 @@ void _starpu_decrement_nsubmitted_tasks(void)
 	if (--nsubmitted == 0)
 		PTHREAD_COND_BROADCAST(&submitted_cond);
 
+	STARPU_TRACE_UPDATE_TASK_CNT(nsubmitted);
+
 	PTHREAD_MUTEX_UNLOCK(&submitted_mutex);
 
 }
@@ -305,7 +307,11 @@ void _starpu_decrement_nsubmitted_tasks(void)
 static void _starpu_increment_nsubmitted_tasks(void)
 {
 	PTHREAD_MUTEX_LOCK(&submitted_mutex);
+
 	nsubmitted++;
+
+	STARPU_TRACE_UPDATE_TASK_CNT(nsubmitted);
+
 	PTHREAD_MUTEX_UNLOCK(&submitted_mutex);
 }
 

+ 32 - 4
tools/activity.sh

@@ -16,10 +16,21 @@
 # See the GNU Lesser General Public License in COPYING.LGPL for more details.
 #
 
+# TODO display help if -h is passed
+
 # The input file must be generated by the fxt_tool command
-inputfile=$1
+inputfile_with_counters=$1
 
-# TODO display help if -h is passed
+# We extract the counters out of the input file
+inputfile=.$inputfile_with_counters.activity
+inputfile_cnt_ready=.$1.cnt_ready
+inputfile_cnt_submitted=.$1.cnt_submitted
+
+grep -v "^cnt" $inputfile_with_counters > $inputfile
+grep "^cnt_ready" $inputfile_with_counters > $inputfile_cnt_ready
+grep "^cnt_submitted" $inputfile_with_counters > $inputfile_cnt_submitted
+
+max_cnt_submitted=`cut -f2 $inputfile_cnt_submitted |sort -n|tail -1`
 
 # Count the number of workers in the trace
 workers=`cut -f1 $inputfile | sort -n | uniq`
@@ -27,7 +38,7 @@ nworkers=`cut -f1 $inputfile | sort -n | uniq|wc -l`
 
 # size of the entire graph
 width=2.5
-heigth=$(echo "0.5 * $nworkers"|bc -l)
+heigth=$(echo "0.5 + (0.5 * $nworkers)"|bc -l)
 
 # In case 3 arguments are provided, the 2nd (resp. 3rd) indicates the start
 # (resp. the end) of the interval to be displayed.
@@ -46,6 +57,13 @@ set output "activity.eps"
 set xrange [$starttime:$endtime]
 set size $width,$heigth
 set multiplot;
+
+set origin 0.0,0.0;
+set size $width,0.5;
+
+plot "$inputfile_cnt_submitted" using 2:3 with filledcurves lt rgb "#999999" title "submitted",\
+	"$inputfile_cnt_ready" using 2:3 with filledcurves lt rgb "#000000" title "ready"
+
 EOF
 
 cnt=0
@@ -53,7 +71,7 @@ for worker in $workers
 do
 	grep "^$worker" $inputfile > .tmp.$worker
 
-	starty=$(echo "0.5 * $cnt"|bc -l)
+	starty=$(echo "0.5 + (0.5 * $cnt)"|bc -l)
 
 cat >> gnuplotcmd << EOF
 
@@ -76,3 +94,13 @@ unset multiplot
 EOF
 
 gnuplot < gnuplotcmd
+
+rm gnuplotcmd
+rm $inputfile
+rm $inputfile_cnt_ready
+rm $inputfile_cnt_submitted
+
+for worker in $workers
+do
+	rm .tmp.$worker
+done

+ 26 - 4
tools/fxt_tool.c

@@ -546,14 +546,34 @@ static int curq_size = 0;
 
 static void handle_job_push(void)
 {
+	float current_timestamp = get_event_time_stamp();
+
 	curq_size++;
-	fprintf(out_paje_file, "13       %f ntask %ssched %f\n", get_event_time_stamp(), prefix, (float)curq_size);
+
+	if (!no_counter)
+		fprintf(out_paje_file, "13       %f ntask %ssched %f\n", current_timestamp, prefix, (float)curq_size);
+
+
+	fprintf(activity_file, "cnt_ready\t%lf\t%ld\n", current_timestamp, curq_size);
 }
 
 static void handle_job_pop(void)
 {
+	float current_timestamp = get_event_time_stamp();
+
 	curq_size--;
-	fprintf(out_paje_file, "13       %f ntask %ssched %f\n", get_event_time_stamp(), prefix, (float)curq_size);
+
+	if (!no_counter)
+		fprintf(out_paje_file, "13       %f ntask %ssched %f\n", current_timestamp, prefix, (float)curq_size);
+
+	fprintf(activity_file, "cnt_ready\t%lf\t%ld\n", current_timestamp, curq_size);
+}
+
+void handle_update_task_cnt(void)
+{
+	float current_timestamp = get_event_time_stamp();
+	unsigned long nsubmitted = ev.param[0]; 
+	fprintf(activity_file, "cnt_submitted\t%lf\t%ld\n", current_timestamp, nsubmitted);
 }
 
 static void handle_codelet_tag_deps(void)
@@ -804,13 +824,15 @@ void parse_new_file(char *filename_in, char *file_prefix, uint64_t file_offset)
 				handle_end_callback();
 				break;
 
+			case STARPU_FUT_UPDATE_TASK_CNT:
+				handle_update_task_cnt();
+				break;
+
 			/* monitor stack size */
 			case STARPU_FUT_JOB_PUSH:
-				if (!no_counter)
 				handle_job_push();
 				break;
 			case STARPU_FUT_JOB_POP:
-				if (!no_counter)
 				handle_job_pop();
 				break;