Browse Source

Add option to draw W and GFlop/W

Samuel Thibault 4 years ago
parent
commit
2177e31ab0

+ 65 - 1
doc/doxygen/chapters/380_offline_performance_tools.doxy

@@ -400,7 +400,7 @@ starpu_perfmodel_load_symbol(). The source code of the tool
 
 An XML output can also be printed by using the <c>-x</c> option:
 \verbatim
-tools/starpu_perfmodel_display -x -s non_linear_memset_regression_based 
+$ tools/starpu_perfmodel_display -x -s non_linear_memset_regression_based 
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE StarPUPerfmodel SYSTEM "starpu-perfmodel.dtd">
 <!-- symbol non_linear_memset_regression_based -->
@@ -425,6 +425,12 @@ The tool <c>starpu_perfmodel_plot</c> can be used to draw performance
 models. It writes a <c>.gp</c> file in the current directory, to be
 run with the tool <c>gnuplot</c>, which shows the corresponding curve.
 
+\verbatim
+$ tools/starpu_perfmodel_plot -s non_linear_memset_regression_based 
+$ gnuplot starpu_non_linear_memset_regression_based.gp
+$ gv starpu_non_linear_memset_regression_based.eps
+\endverbatim
+
 \image html starpu_non_linear_memset_regression_based.png
 \image latex starpu_non_linear_memset_regression_based.eps "" width=\textwidth
 
@@ -482,6 +488,64 @@ histogram of the codelet execution time distribution.
 \image html distrib_data_histo.png
 \image latex distrib_data_histo.eps "" width=\textwidth
 
+\section EnergyOfCodelets Energy Of Codelets
+
+A performance model of the energy of codelets can also be recorded thanks to
+the ::energy_model field of the starpu_codelet structure. StarPU usually cannot
+record this automatically since the energy measurement probes are usually not
+fine-grain enough.  It is however possible to measure it by writing a program
+that submits batches of tasks, let StarPU measure the energy requirement of
+the batch, and compute an average, see \ref MeasuringEnergyandPower .
+
+The energy performance model can then be displayed in Joules with
+<c>starpu_perfmodel_display</c> just like the time performance model.  The
+<c>starpu_perfmodel_plot</c> needs an extra <c>-e</c> option to display the
+proper unit in the graph:
+
+\verbatim
+$ tools/starpu_perfmodel_plot -e -s my_energy_perfmodel
+$ gnuplot starpu_my_energy_perfmodel.gp
+$ gv starpu_my_energy_perfmodel.eps
+\endverbatim
+
+\image html starpu_my_energy_perfmodel.png
+\image latex starpu_my_energy_perfmodel.eps "" width=\textwidth
+
+The <c>-f</c> option can also be used to display the performance in terms of GFlop/J:
+
+\verbatim
+$ tools/starpu_perfmodel_plot -f -e -s my_energy_perfmodel
+$ gnuplot starpu_my_energy_perfmodel.gp
+$ gv starpu_my_energy_perfmodel.eps
+\endverbatim
+
+\image html starpu_my_energy_perfmodel_flops.png
+\image latex starpu_my_energy_perfmodel_flops.eps "" width=\textwidth
+
+One can combine the two time and energy performance models to draw Watts:
+
+\verbatim
+$ tools/starpu_perfmodel_plot -se my_perfmodel my_energy_perfmodel
+$ gnuplot starpu_my_perfmodel.gp
+$ gv starpu_my_perfmodel.eps
+\endverbatim
+
+\image html starpu_my_perfmodel.png
+\image latex starpu_my_perfmodel.eps "" width=\textwidth
+
+Or last but not least, GFlop/W, i.e. the efficiency:
+
+\verbatim
+$ tools/starpu_perfmodel_plot -f -se my_perfmodel my_energy_perfmodel
+$ gnuplot starpu_my_perfmodel.gp
+$ gv starpu_my_perfmodel.eps
+\endverbatim
+
+\image html starpu_my_perfmodel_flops.png
+\image latex starpu_my_perfmodel_flops.eps "" width=\textwidth
+
+We clearly see here that it is much more energy-efficient to stay in the L3 cache.
+
 \section DataTrace Data trace and tasks length
 
 It is possible to get statistics about tasks length and data size by using :

File diff suppressed because it is too large
+ 1349 - 0
doc/doxygen/chapters/images/starpu_my_energy_perfmodel.eps


BIN
doc/doxygen/chapters/images/starpu_my_energy_perfmodel.pdf


BIN
doc/doxygen/chapters/images/starpu_my_energy_perfmodel.png


File diff suppressed because it is too large
+ 1305 - 0
doc/doxygen/chapters/images/starpu_my_energy_perfmodel_flops.eps


BIN
doc/doxygen/chapters/images/starpu_my_energy_perfmodel_flops.pdf


BIN
doc/doxygen/chapters/images/starpu_my_energy_perfmodel_flops.png


File diff suppressed because it is too large
+ 1222 - 0
doc/doxygen/chapters/images/starpu_my_perfmodel.eps


BIN
doc/doxygen/chapters/images/starpu_my_perfmodel.pdf


BIN
doc/doxygen/chapters/images/starpu_my_perfmodel.png


File diff suppressed because it is too large
+ 1310 - 0
doc/doxygen/chapters/images/starpu_my_perfmodel_flops.eps


BIN
doc/doxygen/chapters/images/starpu_my_perfmodel_flops.pdf


BIN
doc/doxygen/chapters/images/starpu_my_perfmodel_flops.png


+ 79 - 20
tools/starpu_perfmodel_plot.c

@@ -44,6 +44,8 @@ struct _perfmodel_plot_options
 	int directory;
 	/* what kernel ? */
 	char *symbol;
+	/* what energy model ? */
+	char *energy_symbol;
 	/* which combination */
 	int comb_is_set;
 	int comb;
@@ -74,6 +76,8 @@ static void usage()
         fprintf(stderr, "   -l                  display all available models\n");
         fprintf(stderr, "   -s <symbol>         specify the symbol\n");
 	fprintf(stderr, "   -e                  display perfmodel as energy instead of time\n");
+	fprintf(stderr, "   -se <time_symbol> <energy_symbol> \n");
+	fprintf(stderr, "                       specify both a time symbol and an energy symbol\n");
 	fprintf(stderr, "   -f                  draw GFlops instead of time\n");
 	fprintf(stderr, "   -i <Fxt files>      input FxT files generated by StarPU\n");
 	fprintf(stderr, "   -lc                 display all combinations of a given model\n");
@@ -115,6 +119,14 @@ static void parse_args(int argc, char **argv, struct _perfmodel_plot_options *op
 			continue;
 		}
 
+		if (strcmp(argv[i], "-se") == 0)
+		{
+			options->symbol = argv[++i];
+			options->energy_symbol = argv[++i];
+			correct_usage = 1;
+			continue;
+		}
+
 		if (strcmp(argv[i], "-o") == 0)
 		{
 			free(*directory);
@@ -122,7 +134,6 @@ static void parse_args(int argc, char **argv, struct _perfmodel_plot_options *op
 #ifdef STARPU_USE_FXT
 			options->fxt_options.dir = strdup(*directory);
 #endif
-			correct_usage = 1;
 			continue;
 		}
 
@@ -285,7 +296,7 @@ static void display_perf_model(FILE *gnuplot_file, struct starpu_perfmodel_arch*
 	}
 }
 
-static void display_history_based_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, int *first, struct _perfmodel_plot_options *options)
+static void display_history_based_perf_models(FILE *gnuplot_file, struct starpu_perfmodel *model, struct starpu_perfmodel *energy_model, int *first, struct _perfmodel_plot_options *options)
 {
 	FILE *datafile;
 	struct starpu_perfmodel_history_list *ptr;
@@ -353,6 +364,7 @@ static void display_history_based_perf_models(FILE *gnuplot_file, struct starpu_
 
 		fprintf(stderr, "%lu ", minimum);
 		fprintf(datafile, "%-15lu ", minimum);
+		/* Find that minimum */
 		for(i = 0; i < model->state->ncombs; i++)
 		{
 			int comb = model->state->combs[i];
@@ -362,30 +374,68 @@ static void display_history_based_perf_models(FILE *gnuplot_file, struct starpu_
 
 				for(impl = 0; impl < model->state->nimpls[comb]; impl++)
 				{
+					int found = 0;
 					struct starpu_perfmodel_per_arch *arch_model = &model->state->per_arch[comb][impl];
 					for (ptr = arch_model->list; ptr; ptr = ptr->next)
 					{
 						struct starpu_perfmodel_history_entry *entry = ptr->entry;
 						if (entry->size == minimum)
 						{
-							if (options->gflops)
-								if (options->energy)
-									fprintf(datafile, "\t%-15le\t%-15le", entry->flops / entry->mean,
-										entry->flops * entry->deviation / (entry->mean * entry->mean)
-										);
-								else
-									fprintf(datafile, "\t%-15le\t%-15le", entry->flops / (entry->mean * 1000),
-										entry->flops * entry->deviation / (entry->mean * entry->mean * 1000)
-										);
+							if (options->energy_symbol)
+							{
+								/* Look for the same in the energy model */
+
+								if (impl >= energy_model->state->nimpls[comb])
+									/* Doesn't have measurements for this impl */
+									break;
+
+								struct starpu_perfmodel_per_arch *arch_model2 = &energy_model->state->per_arch[comb][impl];
+								struct starpu_perfmodel_history_list *ptr2;
+								for (ptr2 = arch_model2->list; ptr2; ptr2 = ptr2->next)
+								{
+									struct starpu_perfmodel_history_entry *entry2 = ptr2->entry;
+									if (entry2->size == minimum)
+									{
+										/* Found the same size, can print */
+
+										double rel_delta = sqrt(
+											(entry2->deviation * entry2->deviation) / (entry2->mean * entry2->mean)
+											+ (entry->deviation * entry->deviation) / (entry->mean * entry->mean));
+
+										if (options->gflops)
+											fprintf(datafile, "\t%-15le\t%-15le", entry->flops / (entry->mean * 1000) / entry2->mean,
+													entry->flops / (entry->mean * 1000) / entry2->mean * rel_delta);
+										else
+											fprintf(datafile, "\t%-15le\t%-15le", entry2->mean / (entry->mean / 1000000),
+													entry2->mean / (entry->mean / 1000000) * rel_delta);
+										found = 1;
+										break;
+									}
+								}
+
+							}
 							else
-								if (options->energy)
-									fprintf(datafile, "\t%-15le\t%-15le", entry->mean, entry->deviation);
+							{
+								if (options->gflops)
+									if (options->energy)
+										fprintf(datafile, "\t%-15le\t%-15le", entry->flops / entry->mean / 1000000000,
+											entry->flops * entry->deviation / (entry->mean * entry->mean) / 1000000000
+											);
+									else
+										fprintf(datafile, "\t%-15le\t%-15le", entry->flops / (entry->mean * 1000),
+											entry->flops * entry->deviation / (entry->mean * entry->mean * 1000)
+											);
 								else
-									fprintf(datafile, "\t%-15le\t%-15le", 0.001*entry->mean, 0.001*entry->deviation);
+									if (options->energy)
+										fprintf(datafile, "\t%-15le\t%-15le", entry->mean, entry->deviation);
+									else
+										fprintf(datafile, "\t%-15le\t%-15le", 0.001*entry->mean, 0.001*entry->deviation);
+								found = 1;
+							}
 							break;
 						}
 					}
-					if (!ptr && arch_model->list)
+					if (!found && arch_model->list)
 						/* No value for this arch. */
 						fprintf(datafile, "\t\"\"\t\"\"");
 				}
@@ -443,7 +493,7 @@ static void dump_data_file(FILE *data_file, struct _perfmodel_plot_options *opti
 }
 #endif
 
-static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel *model, struct _perfmodel_plot_options *options)
+static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel *model, struct starpu_perfmodel *energy_model, struct _perfmodel_plot_options *options)
 {
 	char *symbol = replace_char(options->symbol, '_', '-');
 
@@ -454,12 +504,16 @@ static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel
 	fprintf(gnuplot_file, "set title \"Model for codelet %s\"\n", symbol);
 	fprintf(gnuplot_file, "set xlabel \"Total data size\"\n");
 	if (options->gflops)
-		if (options->energy)
+		if (options->energy_symbol)
+			fprintf(gnuplot_file, "set ylabel \"GFlop/W\"\n");
+		else if (options->energy)
 			fprintf(gnuplot_file, "set ylabel \"GFlop/J\"\n");
 		else
 			fprintf(gnuplot_file, "set ylabel \"GFlop/s\"\n");
 	else
-		if (options->energy)
+		if (options->energy_symbol)
+			fprintf(gnuplot_file, "set ylabel \"Power (W)\"\n");
+		else if (options->energy)
 			fprintf(gnuplot_file, "set ylabel \"Energy (J)\"\n");
 		else
 			fprintf(gnuplot_file, "set ylabel \"Time (ms)\"\n");
@@ -479,7 +533,9 @@ static void display_selected_models(FILE *gnuplot_file, struct starpu_perfmodel
 
 	/* display all or selected combinations */
 	display_all_perf_models(gnuplot_file, model, &first, options);
-	display_history_based_perf_models(gnuplot_file, model, &first, options);
+	if (options->energy_symbol)
+		display_all_perf_models(gnuplot_file, energy_model, &first, options);
+	display_history_based_perf_models(gnuplot_file, model, energy_model, &first, options);
 
 	free(symbol);
 }
@@ -488,6 +544,7 @@ int main(int argc, char **argv)
 {
 	int ret = 0;
 	struct starpu_perfmodel model = { .type = STARPU_PERFMODEL_INVALID };
+	struct starpu_perfmodel energy_model = { .type = STARPU_PERFMODEL_INVALID };
 	char gnuplot_file_name[256];
 	struct _perfmodel_plot_options options;
 	char *directory = strdup("./");
@@ -516,6 +573,8 @@ int main(int argc, char **argv)
 	{
 		/* Load the performance model associated to the symbol */
 		ret = starpu_perfmodel_load_symbol(options.symbol, &model);
+		if (options.energy_symbol)
+			ret = starpu_perfmodel_load_symbol(options.energy_symbol, &energy_model);
 		if (ret)
 		{
 			_STARPU_DISP("The performance model for the symbol <%s> could not be loaded\n", options.symbol);
@@ -550,7 +609,7 @@ int main(int argc, char **argv)
 
 			FILE *gnuplot_file = fopen(gnuplot_file_name, "w+");
 			STARPU_ASSERT_MSG(gnuplot_file, "Cannot create file <%s>\n", gnuplot_file_name);
-			display_selected_models(gnuplot_file, &model, &options);
+			display_selected_models(gnuplot_file, &model, &energy_model, &options);
 			fprintf(gnuplot_file,"\n");
 			fclose(gnuplot_file);