Nathalie Furmento 12 роки тому
батько
коміт
04ee334338

+ 1 - 0
ChangeLog

@@ -71,6 +71,7 @@ Changes:
     threshold before a blocking lock.
   * Data interfaces (variable, vector, matrix and block) now define
     pack und unpack functions
+  * Fix for properly dealing with NAN on windows systems
 
 StarPU 1.1.0 (svn revision xxxx)
 ==============================================

+ 14 - 14
doc/doxygen/Makefile.am

@@ -104,36 +104,36 @@ starpu_config.h: $(top_srcdir)/include/starpu_config.h.in
 chapters/version.sty: $(chapters)
 	for f in $(chapters) ; do \
                 if test -f $(top_srcdir)/doc/doxygen/$$f ; then stat --format=%Y $(top_srcdir)/doc/doxygen/$$f ; fi \
-        done | sort -r | head -1 > timestamp
-	if test -s timestamp ; then \
-		LC_ALL=C date --date=@`cat timestamp` +"%d %B %Y" > timestamp_updated ;\
-		LC_ALL=C date --date=@`cat timestamp` +"%B %Y" > timestamp_updated_month ;\
+        done | sort -r | head -1 > timestamp_sty
+	if test -s timestamp_sty ; then \
+		LC_ALL=C date --date=@`cat timestamp_sty` +"%d %B %Y" > timestamp_sty_updated ;\
+		LC_ALL=C date --date=@`cat timestamp_sty` +"%B %Y" > timestamp_sty_updated_month ;\
 	fi
-	if test -s timestamp_updated ; then \
-		echo "\newcommand{\STARPUUPDATED}{"`cat timestamp_updated`"}" > $(top_srcdir)/doc/doxygen/chapters/version.sty;\
+	if test -s timestamp_sty_updated ; then \
+		echo "\newcommand{\STARPUUPDATED}{"`cat timestamp_sty_updated`"}" > $(top_srcdir)/doc/doxygen/chapters/version.sty;\
 	else \
 		echo "\newcommand{\STARPUUPDATED}{unknown date}" > $(top_srcdir)/doc/doxygen/chapters/version.sty;\
 	fi
 	echo "\newcommand{\STARPUVERSION}{$(VERSION)}" >> $(top_srcdir)/doc/doxygen/chapters/version.sty
-	for f in timestamp timestamp_updated timestamp_updated_month ; do \
+	for f in timestamp_sty timestamp_sty_updated timestamp_sty_updated_month ; do \
 		if test -f $$f ; then $(RM) $$f ; fi ;\
 	done
 
 chapters/version.html: $(chapters)
 	for f in $(chapters) ; do \
                 if test -f $(top_srcdir)/doc/doxygen/$$f ; then stat --format=%Y $(top_srcdir)/doc/doxygen/$$f ; fi \
-        done | sort -r | head -1 > timestamp
-	if test -s timestamp ; then \
-		LC_ALL=C date --date=@`cat timestamp` +"%d %B %Y" > timestamp_updated ;\
-		LC_ALL=C date --date=@`cat timestamp` +"%B %Y" > timestamp_updated_month ;\
+        done | sort -r | head -1 > timestamp_html
+	if test -s timestamp_html ; then \
+		LC_ALL=C date --date=@`cat timestamp_html` +"%d %B %Y" > timestamp_html_updated ;\
+		LC_ALL=C date --date=@`cat timestamp_html` +"%B %Y" > timestamp_html_updated_month ;\
 	fi
 	echo "This manual documents the usage of StarPU version $(VERSION)." > $(top_srcdir)/doc/doxygen/chapters/version.html
-	if test -s timestamp_updated ; then \
-		echo "Its contents was last updated on "`cat timestamp_updated`"." >> $(top_srcdir)/doc/doxygen/chapters/version.html;\
+	if test -s timestamp_html_updated ; then \
+		echo "Its contents was last updated on "`cat timestamp_html_updated`"." >> $(top_srcdir)/doc/doxygen/chapters/version.html;\
 	else \
 		echo "Its contents was last updated on <em>unknown_date</em>." >> $(top_srcdir)/doc/doxygen/chapters/version.html;\
 	fi
-	for f in timestamp timestamp_updated timestamp_updated_month ; do \
+	for f in timestamp_html timestamp_html_updated timestamp_html_updated_month ; do \
 		if test -f $$f ; then $(RM) $$f ; fi ;\
 	done
 

+ 4 - 4
examples/callback/prologue.c

@@ -51,8 +51,8 @@ void callback_func(void *callback_arg)
 
 void prologue_callback_func(void *callback_arg)
 {
-	int *x = (int*)callback_arg;
-	printf("x = %d\n", *x);
+	double *x = (double*)callback_arg;
+	printf("x = %lf\n", *x);
 }
 
 
@@ -78,8 +78,8 @@ int main(int argc, char **argv)
 	if (ret == -ENODEV) goto enodev;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
-	int *x = (int*)malloc(sizeof(int));
-	*x = -999;
+	double *x = (double*)malloc(sizeof(double));
+	*x = -999.0;
 	int ret2 = starpu_insert_task(&cl,
 				      STARPU_RW, handle,
 				      STARPU_PROLOGUE_CALLBACK, prologue_callback_func,

+ 14 - 14
include/starpu_task_util.h

@@ -31,20 +31,20 @@ extern "C"
 
 void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps, void (*callback)(void *), void *callback_arg);
 
-#define STARPU_VALUE		 (1<<19)
-#define STARPU_CALLBACK		 (1<<20)
-#define STARPU_CALLBACK_WITH_ARG (1<<21)
-#define STARPU_CALLBACK_ARG	 (1<<22)
-#define STARPU_PRIORITY		 (1<<23)
-#define STARPU_EXECUTE_ON_NODE	 (1<<24)
-#define STARPU_EXECUTE_ON_DATA	 (1<<25)
-#define STARPU_DATA_ARRAY        (1<<26)
-#define STARPU_TAG               (1<<27)
-#define STARPU_HYPERVISOR_TAG	 (1<<28)
-#define STARPU_FLOPS	         (1<<29)
-#define STARPU_SCHED_CTX	 (1<<30)
-#define STARPU_PROLOGUE_CALLBACK   (1<<31)
-#define STARPU_PROLOGUE_CALLBACK_ARG (1ULL<<32)
+#define STARPU_VALUE		 (1<<16)
+#define STARPU_CALLBACK		 (2<<16)
+#define STARPU_CALLBACK_WITH_ARG (3<<16)
+#define STARPU_CALLBACK_ARG	 (4<<16)
+#define STARPU_PRIORITY		 (5<<16)
+#define STARPU_EXECUTE_ON_NODE	 (6<<16)
+#define STARPU_EXECUTE_ON_DATA	 (7<<16)
+#define STARPU_DATA_ARRAY        (8<<16)
+#define STARPU_TAG               (9<<16)
+#define STARPU_HYPERVISOR_TAG	 (10<<16)
+#define STARPU_FLOPS	         (11<<16)
+#define STARPU_SCHED_CTX	 (12<<16)
+#define STARPU_PROLOGUE_CALLBACK   (13<<16)
+#define STARPU_PROLOGUE_CALLBACK_ARG (14<<16)
 
 int starpu_insert_task(struct starpu_codelet *cl, ...);
 

+ 4 - 1
sc_hypervisor/include/sc_hypervisor_config.h

@@ -38,6 +38,7 @@ extern "C"
 #define SC_HYPERVISOR_NULL -11
 #define	SC_HYPERVISOR_ISPEED_W_SAMPLE -12
 #define SC_HYPERVISOR_ISPEED_CTX_SAMPLE -13
+#define SC_HYPERVISOR_TIME_SAMPLE -14
 
 
 #define MAX_IDLE_TIME 5000000000
@@ -76,7 +77,9 @@ struct sc_hypervisor_policy_config
 
 	/* sample used to compute the instant speed per ctx*/
 	double ispeed_ctx_sample;
-
+	
+        /* sample used to compute the instant speed per ctx (in seconds)*/
+	double time_sample;
 };
 
 /* set a certain configuration to a context */

+ 2 - 15
sc_hypervisor/src/policies_utils/speed.c

@@ -40,13 +40,7 @@ double sc_hypervisor_get_ctx_speed(struct sc_hypervisor_wrapper* sc_w)
 	unsigned can_compute_speed = 0;
 	char *speed_sample_criteria = getenv("SC_HYPERVISOR_SAMPLE_CRITERIA");
 	if(speed_sample_criteria && (strcmp(speed_sample_criteria, "time") == 0))
-	{
-		int n_all_cpus = starpu_cpu_worker_get_count();
-		int n_all_cuda = starpu_cuda_worker_get_count();
-		double th_speed = SC_HYPERVISOR_DEFAULT_CPU_SPEED * n_all_cpus + SC_HYPERVISOR_DEFAULT_CUDA_SPEED * n_all_cuda;
-		double time_sample = 0.1 * ((total_flops/1000000000.0) / th_speed);
-		can_compute_speed = elapsed_time > 1.0;//time_sample;
-	}
+		can_compute_speed = elapsed_time > config->time_sample;
 	else
 		can_compute_speed = elapsed_flops >= redim_sample;
 
@@ -121,14 +115,7 @@ double sc_hypervisor_get_speed_per_worker_type(struct sc_hypervisor_wrapper* sc_
 	unsigned can_compute_speed = 0;
 	char *speed_sample_criteria = getenv("SC_HYPERVISOR_SAMPLE_CRITERIA");
 	if(speed_sample_criteria && (strcmp(speed_sample_criteria, "time") == 0))
-	{
-		int n_all_cpus = starpu_cpu_worker_get_count();
-		int n_all_cuda = starpu_cuda_worker_get_count();
-		double th_speed = SC_HYPERVISOR_DEFAULT_CPU_SPEED * n_all_cpus + SC_HYPERVISOR_DEFAULT_CUDA_SPEED * n_all_cuda;
-		double total_flops = sc_w->total_flops;
-		double time_sample = 0.1 * ((total_flops/1000000000.0) / th_speed);
-		can_compute_speed = elapsed_time > 1.0;
-	}
+		can_compute_speed = elapsed_time > config->time_sample;
 	else
 		can_compute_speed = ctx_elapsed_flops > ctx_sample;
 

+ 6 - 0
sc_hypervisor/src/sc_config.c

@@ -23,6 +23,7 @@ static struct sc_hypervisor_policy_config* _create_config(void)
 	config->max_nworkers = -1;
 	config->new_workers_max_idle = -1.0;
 	config->ispeed_ctx_sample = 0.0;
+	config->time_sample = 0.5;
 
 	int i;
 	for(i = 0; i < STARPU_NMAXWORKERS; i++)
@@ -184,6 +185,11 @@ static struct sc_hypervisor_policy_config* _ctl(unsigned sched_ctx, va_list varg
 			config->ispeed_ctx_sample = va_arg(varg_list, double);
 			break;
 
+		case SC_HYPERVISOR_TIME_SAMPLE:
+			config->time_sample = va_arg(varg_list, double);
+			break;
+
+
 /* not important for the strateg, needed just to jump these args in the iteration of the args */
 		case SC_HYPERVISOR_TIME_TO_APPLY:
 			va_arg(varg_list, int);

+ 1 - 0
src/Makefile.am

@@ -167,6 +167,7 @@ libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES = 						\
 	core/perfmodel/perfmodel_bus.c				\
 	core/perfmodel/perfmodel.c				\
 	core/perfmodel/perfmodel_print.c			\
+	core/perfmodel/perfmodel_nan.c				\
 	core/perfmodel/regression.c				\
 	core/sched_policy.c					\
 	core/simgrid.c						\

+ 2 - 0
src/core/perfmodel/perfmodel.h

@@ -89,6 +89,8 @@ int *_starpu_get_opencl_affinity_vector(unsigned gpuid);
 void _starpu_save_bandwidth_and_latency_disk(double bandwidth_write, double bandwidth_read, 
 					    double latency_write, double latency_read, unsigned node);
 
+int _starpu_read_double(FILE *f, char *format, double *val);
+
 #ifdef __cplusplus
 }
 #endif

+ 4 - 4
src/core/perfmodel/perfmodel_bus.c

@@ -1000,7 +1000,7 @@ static int load_bus_latency_file_content(void)
 		_starpu_drop_comments(f);
 		for (dst = 0; dst < STARPU_MAXNODES; dst++)
 		{
-			n = fscanf(f, "%lf", &latency);
+			n = _starpu_read_double(f, "%lf", &latency);
 			if (n != 1)
 			{
 				_STARPU_DISP("Error while reading latency file <%s>. Expected a number\n", path);
@@ -1039,7 +1039,7 @@ static int load_bus_latency_file_content(void)
 				break;
 			ungetc(n, f);
 
-			n = fscanf(f, "%lf", &latency);
+			n = _starpu_read_double(f, "%lf", &latency);
 			if (n && !isnan(latency))
 			{
 				_STARPU_DISP("Too many nodes in latency file %s for this configuration (%d)\n", path, STARPU_MAXNODES);
@@ -1217,7 +1217,7 @@ static int load_bus_bandwidth_file_content(void)
 		_starpu_drop_comments(f);
 		for (dst = 0; dst < STARPU_MAXNODES; dst++)
 		{
-			n = fscanf(f, "%lf", &bandwidth);
+			n = _starpu_read_double(f, "%lf", &bandwidth);
 			if (n != 1)
 			{
 				_STARPU_DISP("Error while reading bandwidth file <%s>. Expected a number\n", path);
@@ -1256,7 +1256,7 @@ static int load_bus_bandwidth_file_content(void)
 				break;
 			ungetc(n, f);
 
-			n = fscanf(f, "%lf", &bandwidth);
+			n = _starpu_read_double(f, "%lf", &bandwidth);
 			if (n && !isnan(bandwidth))
 			{
 				_STARPU_DISP("Too many nodes in bandwidth file %s for this configuration (%d)\n", path, STARPU_MAXNODES);

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

@@ -152,12 +152,14 @@ static void scan_reg_model(FILE *f, struct starpu_perfmodel_regression_model *re
 
 	_starpu_drop_comments(f);
 
-	res = fscanf(f, "%le\t%le\t%le\t%le\t%le\t%le\t%u\t%lu\t%lu\n",
-		&reg_model->sumlnx, &reg_model->sumlnx2, &reg_model->sumlny,
-		&reg_model->sumlnxlny, &reg_model->alpha, &reg_model->beta,
-		&reg_model->nsample,
-		&reg_model->minx, &reg_model->maxx);
-	STARPU_ASSERT_MSG(res == 9, "Incorrect performance model file");
+	res = fscanf(f, "%le\t%le\t%le\t%le", &reg_model->sumlnx, &reg_model->sumlnx2, &reg_model->sumlny, &reg_model->sumlnxlny);
+	STARPU_ASSERT_MSG(res == 4, "Incorrect performance model file");
+	res = _starpu_read_double(f, "\t%le", &reg_model->alpha);
+	STARPU_ASSERT_MSG(res == 1, "Incorrect performance model file");
+	res = _starpu_read_double(f, "\t%le", &reg_model->beta);
+	STARPU_ASSERT_MSG(res == 1, "Incorrect performance model file");
+	res = fscanf(f, "\t%u\t%lu\t%lu\n", &reg_model->nsample, &reg_model->minx, &reg_model->maxx);
+	STARPU_ASSERT_MSG(res == 3, "Incorrect performance model file");
 
 	/* If any of the parameters describing the linear regression model is NaN, the model is invalid */
 	unsigned invalid = (isnan(reg_model->alpha)||isnan(reg_model->beta));
@@ -169,8 +171,12 @@ static void scan_reg_model(FILE *f, struct starpu_perfmodel_regression_model *re
 
 	_starpu_drop_comments(f);
 
-	res = fscanf(f, "%le\t%le\t%le\n", &reg_model->a, &reg_model->b, &reg_model->c);
-	STARPU_ASSERT_MSG(res == 3, "Incorrect performance model file");
+	res = _starpu_read_double(f, "%le\t", &reg_model->a);
+	STARPU_ASSERT_MSG(res == 1, "Incorrect performance model file");
+	res = _starpu_read_double(f, "%le\t", &reg_model->b);
+	STARPU_ASSERT_MSG(res == 1, "Incorrect performance model file");
+	res = _starpu_read_double(f, "%le\n", &reg_model->c);
+	STARPU_ASSERT_MSG(res == 1, "Incorrect performance model file");
 
 	/* If any of the parameters describing the non-linear regression model is NaN, the model is invalid */
 	unsigned nl_invalid = (isnan(reg_model->a)||isnan(reg_model->b)||isnan(reg_model->c));

+ 54 - 0
src/core/perfmodel/perfmodel_nan.c

@@ -0,0 +1,54 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2013  Centre National de la Recherche Scientifique
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#include <config.h>
+
+int _starpu_read_double(FILE *f, char *format, double *val)
+{
+#ifdef STARPU_HAVE_WINDOWS
+/** Windows cannot read NAN values, yes, it is really bad ... */
+	int x1 = getc(f);
+
+	if (x1 == 'n')
+	{
+	     int x2 = getc(f);
+	     int x3 = getc(f);
+	     if (x2 == 'a' && x3 == 'n')
+	     {
+		     *val = NAN;
+		     return 1;
+	     }
+	     else
+	     {
+		     return 0;
+	     }
+	}
+	else
+	{
+		ungetc(x1, f);
+		return fscanf(f, format, val);
+	}
+#else
+	return fscanf(f, format, val);
+#endif
+}

+ 0 - 3
src/util/starpu_insert_task_utils.c

@@ -322,11 +322,8 @@ int _starpu_insert_task_create_and_submit(void *arg_buffer, size_t arg_buffer_si
 		else if (arg_type==STARPU_PROLOGUE_CALLBACK)
 		{
 			void (*callback_func)(void *);
-			void *callback_arg;
 			callback_func = va_arg(varg_list, _starpu_callback_func_t);
-			callback_arg = va_arg(varg_list, void *);
 			prologue_cl_arg_wrapper->callback_func = callback_func;
-			prologue_cl_arg_wrapper->callback_arg = callback_arg;
 		}
 		else if (arg_type==STARPU_PROLOGUE_CALLBACK_ARG)
 		{

+ 1 - 0
tests/Makefile.am

@@ -223,6 +223,7 @@ noinst_PROGRAMS =				\
 	perfmodels/non_linear_regression_based	\
 	perfmodels/feed				\
 	perfmodels/valid_model			\
+	perfmodels/value_nan			\
 	sched_policies/data_locality            \
 	sched_policies/execute_all_tasks        \
 	sched_policies/prio        		\

+ 65 - 0
tests/perfmodels/value_nan.c

@@ -0,0 +1,65 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2013  Centre National de la Recherche Scientifique
+ *
+ * StarPU is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#include <config.h>
+#include <core/perfmodel/perfmodel.h>
+#include "../helper.h"
+
+#define STRING "booh"
+
+int _check_number(double val, int nan)
+{
+	char *filename = tmpnam(NULL);
+
+	/* write the double value in the file followed by a predefined string */
+	FILE *f = fopen(filename, "w");
+	fprintf(f, "%lf %s\n", val, STRING);
+	fclose(f);
+
+	/* read the double value and the string back from the file */
+	f = fopen(filename, "r");
+	double lat;
+	char str[10];
+	int x = _starpu_read_double(f, "%lf", &lat);
+	int y = fscanf(f, "%s", str);
+	fclose(f);
+
+	/* check that what has been read is identical to what has been written */
+	int pass;
+	pass = (x == 1) && (y == 1);
+	pass = pass && strcmp(str, STRING) == 0;
+	if (nan)
+		pass = pass && isnan(val) && isnan(lat);
+	else
+		pass = pass && lat == val;
+	return pass?0:1;
+}
+
+int main(int argc, char **argv)
+{
+	int ret;
+
+	ret = _check_number(42.0, 0);
+	FPRINTF(stderr, "%s when reading %lf\n", ret?"Success":"Error", 42.0);
+
+	if (ret==0)
+	{
+	     ret = _check_number(NAN, 1);
+	     FPRINTF(stderr, "%s when reading %lf\n", ret?"Success":"Error", NAN);
+	}
+
+	return ret;
+}