Selaa lähdekoodia

Adding configure option --enable-calibration-heuristic which allows the user to set the maximum authorized deviation of the history-based calibrator

Marc Sergent 11 vuotta sitten
vanhempi
commit
b2f8911c89

+ 3 - 0
ChangeLog

@@ -75,6 +75,9 @@ Small features:
   * Functions starpu_insert_task and starpu_mpi_insert_task are
     renamed in starpu_task_insert and starpu_mpi_task_insert. Old
     names are kept to avoid breaking old codes.
+  * New configure option --enable-calibration-heuristic which allows
+    the user to set the maximum authorized deviation of the 
+    history-based calibrator. 
 
 Changes:
   * Fix of the livelock issue discovered while executing applications

+ 13 - 0
configure.ac

@@ -1601,6 +1601,19 @@ STARPU_HAVE_LIBRARY(LEVELDB, [leveldb])
 AM_CONDITIONAL(STARPU_HAVE_LEVELDB, test "x$ac_cv_lib_leveldb_main" = "xyes")
 AC_LANG_POP([C++])
 
+# Defines the calibration heuristic for the history-based calibration of StarPU
+AC_MSG_CHECKING(calibration heuristic of history-based StarPU calibrator)
+AC_ARG_ENABLE(calibration-heuristic, [AS_HELP_STRING([--enable-calibration-heuristic=<number>],
+			[Define the maximum authorized deviation of StarPU history-based calibrator.])],
+			calibration_heuristic=$enableval, calibration_heuristic=10)
+if test $calibration_heuristic -gt 100; then
+	AC_MSG_RESULT(uncorrect parameter $calibration_heuristic  set default parameter 10)
+	AC_DEFINE_UNQUOTED(STARPU_HISTORYMAXERROR, [$calibration_heuristic], [calibration heuristic value])
+else
+	AC_MSG_RESULT($calibration_heuristic)
+	AC_DEFINE_UNQUOTED(STARPU_HISTORYMAXERROR, [$calibration_heuristic], [calibration heuristic value])
+fi
+
 
 ###############################################################################
 #                                                                             #

+ 10 - 0
doc/doxygen/chapters/configure_options.doxy

@@ -526,6 +526,16 @@ export SIMGRID_LIBS="-L/usr/local/simgrid/lib -lsimgrid"
 
 </dd>
 
+<dt>--enable-calibration-heuristic</dt>
+<dd>
+\anchor enable-calibration-heuristic
+\addindex __configure__--enable-calibration-heuristic
+Allows to set the maximum authorized percentage of deviation 
+for the history-based calibrator of StarPU. A correct value 
+of this parameter must be in [0..100]. The default value of 
+this parameter is 10. Experimental.
+</dd>
+
 </dl>
 
 */

+ 1 - 0
include/starpu_perfmodel.h

@@ -49,6 +49,7 @@ struct starpu_perfmodel_history_entry
 	double sum;
 	double sum2;
 	unsigned nsample;
+	unsigned nerror;
 	uint32_t footprint;
 #ifdef STARPU_HAVE_WINDOWS
 	unsigned size;

+ 33 - 8
src/core/perfmodel/perfmodel_history.c

@@ -35,6 +35,7 @@
 #include <windows.h>
 #endif
 
+#define HISTORYMAXERROR	(STARPU_HISTORYMAXERROR > 100 ? 10 : STARPU_HISTORYMAXERROR)
 #define HASH_ADD_UINT32_T(head,field,add) HASH_ADD(hh,head,field,sizeof(uint32_t),add)
 #define HASH_FIND_UINT32_T(head,find,out) HASH_FIND(hh,head,find,sizeof(uint32_t),out)
 
@@ -1311,19 +1312,43 @@ void _starpu_update_perfmodel_history(struct _starpu_job *j, struct starpu_perfm
 
 				entry->footprint = key;
 				entry->nsample = 1;
+				entry->nerror = 0;
 
 				insert_history_entry(entry, list, &per_arch_model->history);
 			}
 			else
 			{
-				/* there is already some entry with the same footprint */
-				entry->sum += measured;
-				entry->sum2 += measured*measured;
-				entry->nsample++;
-
-				unsigned n = entry->nsample;
-				entry->mean = entry->sum / n;
-				entry->deviation = sqrt((entry->sum2 - (entry->sum*entry->sum)/n)/n);
+				/* There is already an entry with the same footprint */
+
+				double local_deviation = (measured/entry->mean)*100;
+				
+				if (entry->nsample && (local_deviation < (100 - HISTORYMAXERROR) || local_deviation > (100 + HISTORYMAXERROR)))
+				{
+					entry->nerror++;
+
+					/* Too many errors: we flush out all the entries */
+					if (entry->nerror >= entry->nsample)
+					{
+						entry->sum = 0.0;
+						entry->sum2 = 0.0;
+						entry->nsample = 0;
+						entry->nerror = 0;
+						entry->mean = 0.0;
+						entry->deviation = 0.0;
+						_STARPU_DEBUG("Too many errors for model %s\n", model->symbol);
+					}
+				}
+				else
+				{
+					entry->sum += measured;
+					entry->sum2 += measured*measured;
+					entry->nsample++;
+
+					unsigned n = entry->nsample;
+					entry->mean = entry->sum / n;
+					entry->deviation = sqrt((entry->sum2 - (entry->sum*entry->sum)/n)/n);
+				}
+
 				if (j->task->flops != 0.)
 				{
 					if (entry->flops == 0.)