Browse Source

Cache values gotten from environment variables, to fix concurrency with putenv() calls, and also reduce cost

Samuel Thibault 10 years ago
parent
commit
bf8e9c78cb

+ 8 - 1
src/common/utils.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2012-2014  Université de Bordeaux
+ * Copyright (C) 2010, 2012-2015  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -33,6 +33,13 @@
 #endif
 #endif
 
+int _starpu_silent;
+
+void _starpu_util_init(void)
+{
+	_starpu_silent = starpu_get_env_number_default("STARPU_SILENT", 0);
+}
+
 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
 #include <direct.h>
 static char * dirname(char * path)

+ 10 - 5
src/common/utils.h

@@ -91,22 +91,23 @@
 #endif
 
 #ifdef STARPU_VERBOSE
-#  define _STARPU_DEBUG(fmt, ...) do { if (!getenv("STARPU_SILENT")) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%s] " fmt ,__starpu_func__ ,## __VA_ARGS__); fflush(stderr); }} while(0)
+#  define _STARPU_DEBUG(fmt, ...) do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%s] " fmt ,__starpu_func__ ,## __VA_ARGS__); fflush(stderr); }} while(0)
 #else
 #  define _STARPU_DEBUG(fmt, ...) do { } while (0)
 #endif
 
 #ifdef STARPU_EXTRA_VERBOSE
-#  define _STARPU_LOG_IN()             do { if (!getenv("STARPU_SILENT")) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] -->\n", pthread_self(), __starpu_func__,__FILE__,  __LINE__); }} while(0)
-#  define _STARPU_LOG_OUT()            do { if (!getenv("STARPU_SILENT")) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] <--\n", pthread_self(), __starpu_func__, __FILE__,  __LINE__); }} while(0)
-#  define _STARPU_LOG_OUT_TAG(outtag)  do { if (!getenv("STARPU_SILENT")) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] <-- (%s)\n", pthread_self(), __starpu_func__, __FILE__, __LINE__, outtag); }} while(0)
+#  define _STARPU_LOG_IN()             do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] -->\n", pthread_self(), __starpu_func__,__FILE__,  __LINE__); }} while(0)
+#  define _STARPU_LOG_OUT()            do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] <--\n", pthread_self(), __starpu_func__, __FILE__,  __LINE__); }} while(0)
+#  define _STARPU_LOG_OUT_TAG(outtag)  do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%ld][%s:%s@%d] <-- (%s)\n", pthread_self(), __starpu_func__, __FILE__, __LINE__, outtag); }} while(0)
 #else
 #  define _STARPU_LOG_IN()
 #  define _STARPU_LOG_OUT()
 #  define _STARPU_LOG_OUT_TAG(outtag)
 #endif
 
-#define _STARPU_DISP(fmt, ...) do { if (!getenv("STARPU_SILENT")) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%s] " fmt ,__starpu_func__ ,## __VA_ARGS__); }} while(0)
+/* TODO: cache */
+#define _STARPU_DISP(fmt, ...) do { if (!_starpu_silent) {fprintf(stderr, STARPU_DEBUG_PREFIX"[%s] " fmt ,__starpu_func__ ,## __VA_ARGS__); }} while(0)
 #define _STARPU_ERROR(fmt, ...)                                                  \
 	do {                                                                          \
                 fprintf(stderr, "\n\n[starpu][%s] Error: " fmt ,__starpu_func__ ,## __VA_ARGS__);    \
@@ -146,4 +147,8 @@ int _starpu_check_mutex_deadlock(starpu_pthread_mutex_t *mutex);
 
 void _starpu_sleep(struct timespec ts);
 
+extern int _starpu_silent;
+
+void _starpu_util_init(void);
+
 #endif // __COMMON_UTILS_H__

+ 1 - 1
src/core/disk_ops/disk_leveldb.cpp

@@ -28,7 +28,7 @@
 #include <datawizard/memory_manager.h>
 #include <starpu_parameters.h>
 
-#define NITER	_STARPU_CALIBRATION_MINIMUM
+#define NITER	_starpu_calibration_minimum
 
 /* ------------------- use leveldb to write on disk -------------------  */
 

+ 1 - 1
src/core/disk_ops/disk_stdio.c

@@ -34,7 +34,7 @@
 #  include <io.h>
 #endif
 
-#define NITER	_STARPU_CALIBRATION_MINIMUM
+#define NITER	_starpu_calibration_minimum
 
 /* ------------------- use STDIO to write on disk -------------------  */
 

+ 1 - 1
src/core/disk_ops/unistd/disk_unistd_global.c

@@ -40,7 +40,7 @@
 #  include <io.h>
 #endif
 
-#define NITER	_STARPU_CALIBRATION_MINIMUM
+#define NITER	_starpu_calibration_minimum
 
 #ifdef O_DIRECT
 #  define MEM_SIZE getpagesize()

+ 3 - 1
src/core/perfmodel/perfmodel.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2014  Université de Bordeaux
+ * Copyright (C) 2009-2015  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  *
@@ -63,6 +63,8 @@ struct starpu_data_descr;
 struct _starpu_job;
 struct starpu_perfmodel_arch;
 
+extern unsigned _starpu_calibration_minimum;
+
 char *_starpu_get_perf_model_dir_codelet();
 char *_starpu_get_perf_model_dir_bus();
 char *_starpu_get_perf_model_dir_debug();

+ 10 - 4
src/core/perfmodel/perfmodel_history.c

@@ -46,6 +46,11 @@ static struct starpu_perfmodel_arch **arch_combs;
 static int current_arch_comb;
 static int nb_arch_combs;
 static starpu_pthread_rwlock_t arch_combs_mutex;
+static int historymaxerror;
+
+/* How many executions a codelet will have to be measured before we
+ * consider that calibration will provide a value good enough for scheduling */
+unsigned _starpu_calibration_minimum;
 
 struct starpu_perfmodel_history_table
 {
@@ -56,7 +61,7 @@ struct starpu_perfmodel_history_table
 
 /* We want more than 10% variance on X to trust regression */
 #define VALID_REGRESSION(reg_model) \
-	((reg_model)->minx < (9*(reg_model)->maxx)/10 && (reg_model)->nsample >= _STARPU_CALIBRATION_MINIMUM)
+	((reg_model)->minx < (9*(reg_model)->maxx)/10 && (reg_model)->nsample >= _starpu_calibration_minimum)
 
 static starpu_pthread_rwlock_t registered_models_rwlock;
 static struct _starpu_perfmodel_list *registered_models = NULL;
@@ -812,6 +817,8 @@ void _starpu_initialize_registered_performance_models(void)
 	arch_combs = (struct starpu_perfmodel_arch**) malloc(nb_arch_combs*sizeof(struct starpu_perfmodel_arch*));
 	current_arch_comb = 0;
 	STARPU_PTHREAD_RWLOCK_INIT(&arch_combs_mutex, NULL);
+	historymaxerror = starpu_get_env_number_default("STARPU_HISTORY_MAX_ERROR", STARPU_HISTORYMAXERROR);
+	_starpu_calibration_minimum = starpu_get_env_number_default("STARPU_CALIBRATE_MINIMUM", 10);
 }
 
 void _starpu_deinitialize_performance_model(struct starpu_perfmodel *model)
@@ -1188,7 +1195,7 @@ double _starpu_non_linear_regression_based_job_expected_perf(struct starpu_perfm
 		 * We do not care about racing access to the mean, we only want
 		 * a good-enough estimation */
 
-		if (entry && entry->history_entry && entry->history_entry->nsample >= _STARPU_CALIBRATION_MINIMUM)
+		if (entry && entry->history_entry && entry->history_entry->nsample >= _starpu_calibration_minimum)
 			exp = entry->history_entry->mean;
 
 docal:
@@ -1236,7 +1243,7 @@ double _starpu_history_based_job_expected_perf(struct starpu_perfmodel *model, s
 	 * We do not care about racing access to the mean, we only want
 	 * a good-enough estimation */
 
-	if (entry && entry->nsample >= _STARPU_CALIBRATION_MINIMUM)
+	if (entry && entry->nsample >= _starpu_calibration_minimum)
 		/* TODO: report differently if we've scheduled really enough
 		 * of that task and the scheduler should perhaps put it aside */
 		/* Calibrated enough */
@@ -1364,7 +1371,6 @@ void _starpu_update_perfmodel_history(struct _starpu_job *j, struct starpu_perfm
 				/* There is already an entry with the same footprint */
 
 				double local_deviation = measured/entry->mean;
-				int historymaxerror = starpu_get_env_number_default("STARPU_HISTORY_MAX_ERROR", STARPU_HISTORYMAXERROR);
 
 				if (entry->nsample &&
 					(100 * local_deviation > (100 + historymaxerror)

+ 3 - 3
src/core/sched_ctx.c

@@ -31,6 +31,7 @@ static double hyp_start_allow_sample[STARPU_NMAX_SCHED_CTXS];
 static double flops[STARPU_NMAX_SCHED_CTXS][STARPU_NMAXWORKERS];
 static size_t data_size[STARPU_NMAX_SCHED_CTXS][STARPU_NMAXWORKERS];
 static double hyp_actual_start_sample[STARPU_NMAX_SCHED_CTXS];
+static double window_size;
 
 static unsigned _starpu_get_first_free_sched_ctx(struct _starpu_machine_config *config);
 static void _starpu_sched_ctx_add_workers_to_master(unsigned sched_ctx_id, int *workerids, int nworkers, int new_master);
@@ -986,9 +987,7 @@ unsigned _starpu_can_push_task(struct _starpu_sched_ctx *sched_ctx, struct starp
 {
 	if(sched_ctx->sched_policy && sched_ctx->sched_policy->simulate_push_task)
 	{
-		const char *env_window_size = getenv("STARPU_WINDOW_TIME_SIZE");
-		if(!env_window_size) return 1;
-		double window_size = atof(env_window_size);
+		if (window_size == 0.0) return 1;
 		
 		STARPU_PTHREAD_RWLOCK_RDLOCK(&changing_ctx_mutex[sched_ctx->id]);
 		double expected_end = sched_ctx->sched_policy->simulate_push_task(task);
@@ -1166,6 +1165,7 @@ int _starpu_nworkers_able_to_execute_task(struct starpu_task *task, struct _star
 void _starpu_init_all_sched_ctxs(struct _starpu_machine_config *config)
 {
 	STARPU_PTHREAD_KEY_CREATE(&sched_ctx_key, NULL);
+	window_size = starpu_get_env_float_default("STARPU_WINDOW_TIME_SIZE", 0.0);
 
 	unsigned i;
 	for(i = 0; i < STARPU_NMAX_SCHED_CTXS; i++)

+ 18 - 13
src/core/task.c

@@ -50,6 +50,23 @@
  * possible that we have a task with a NULL codelet, which means its callback
  * could be executed by a user thread as well. */
 static starpu_pthread_key_t current_task_key;
+static int limit_min_submitted_tasks;
+static int limit_max_submitted_tasks;
+static int watchdog_crash;
+
+/* Called once at starpu_init */
+void _starpu_task_init(void)
+{
+	STARPU_PTHREAD_KEY_CREATE(&current_task_key, NULL);
+	limit_min_submitted_tasks = starpu_get_env_number("STARPU_LIMIT_MIN_SUBMITTED_TASKS");
+	limit_max_submitted_tasks = starpu_get_env_number("STARPU_LIMIT_MAX_SUBMITTED_TASKS");
+	watchdog_crash = starpu_get_env_number("STARPU_WATCHDOG_CRASH");
+}
+
+void _starpu_task_deinit(void)
+{
+	STARPU_PTHREAD_KEY_DELETE(current_task_key);
+}
 
 void starpu_task_init(struct starpu_task *task)
 {
@@ -606,8 +623,6 @@ int starpu_task_submit(struct starpu_task *task)
 
 	if (!j->internal)
 	{
-		int limit_min_submitted_tasks = starpu_get_env_number("STARPU_LIMIT_MIN_SUBMITTED_TASKS");
-		int limit_max_submitted_tasks = starpu_get_env_number("STARPU_LIMIT_MAX_SUBMITTED_TASKS");
 		int nsubmitted_tasks = starpu_task_nsubmitted();
 		if (limit_max_submitted_tasks >= 0 && limit_max_submitted_tasks < nsubmitted_tasks
 			&& limit_min_submitted_tasks >= 0 && limit_min_submitted_tasks < nsubmitted_tasks)
@@ -991,16 +1006,6 @@ int starpu_task_nready(void)
 	return nready;
 }
 
-void _starpu_initialize_current_task_key(void)
-{
-	STARPU_PTHREAD_KEY_CREATE(&current_task_key, NULL);
-}
-
-void _starpu_deinitialize_current_task_key(void)
-{
-	STARPU_PTHREAD_KEY_DELETE(current_task_key);
-}
-
 /* Return the task currently executed by the worker, or NULL if this is called
  * either from a thread that is not a task or simply because there is no task
  * being executed at the moment. */
@@ -1158,7 +1163,7 @@ static void *watchdog_func(void *arg)
 				&& last_nsubmitted == starpu_task_nsubmitted())
 		{
 			fprintf(stderr,"The StarPU watchdog detected that no task finished for %u.%06us (can be configure through STARPU_WATCHDOG_TIMEOUT)\n", (unsigned)ts.tv_sec, (unsigned)ts.tv_nsec/1000);
-			if (getenv("STARPU_WATCHDOG_CRASH"))
+			if (watchdog_crash)
 			{
 				fprintf(stderr,"Crashing the process\n");
 				raise(SIGABRT);

+ 4 - 4
src/core/task.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2014  Université de Bordeaux
+ * Copyright (C) 2009-2015  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2013, 2015  CNRS
  * Copyright (C) 2011, 2014 INRIA
  *
@@ -33,10 +33,10 @@ int _starpu_task_test_termination(struct starpu_task *task);
 #endif
 
 /* A pthread key is used to store the task currently executed on the thread.
- * _starpu_initialize_current_task_key initializes this pthread key and
+ * _starpu_task_init initializes this pthread key and
  * _starpu_set_current_task updates its current value. */
-void _starpu_initialize_current_task_key(void);
-void _starpu_deinitialize_current_task_key(void);
+void _starpu_task_init(void);
+void _starpu_task_deinit(void);
 void _starpu_set_current_task(struct starpu_task *task);
 
 /* NB the second argument makes it possible to count regenerable tasks only

+ 18 - 8
src/core/workers.c

@@ -58,6 +58,9 @@ static starpu_pthread_key_t worker_set_key;
 
 static struct _starpu_machine_config config;
 
+static int check_entire_platform;
+static int disable_kernels;
+
 /* Pointers to argc and argv
  */
 static int *my_argc = 0;
@@ -91,6 +94,11 @@ struct _starpu_machine_config *_starpu_get_machine_config(void)
 	return &config;
 }
 
+int _starpu_get_disable_kernels(void)
+{
+	return disable_kernels;
+}
+
 /* Makes sure that at least one of the workers of type <arch> can execute
  * <task>, for at least one of its implementations. */
 static uint32_t _starpu_worker_exists_and_can_execute(struct starpu_task *task,
@@ -103,7 +111,6 @@ static uint32_t _starpu_worker_exists_and_can_execute(struct starpu_task *task,
 	   task, independent of the sched_ctx, this latter may receive latter on
 	   the necessary worker - the user or the hypervisor should take care this happens */
 
-	int check_entire_platform = starpu_get_env_number("STARPU_CHECK_ENTIRE_PLATFORM");
 	struct _starpu_sched_ctx *sched_ctx = check_entire_platform == 1 ? _starpu_get_initial_sched_ctx() : _starpu_get_sched_ctx_struct(task->sched_ctx);
 	struct starpu_worker_collection *workers = sched_ctx->workers;
 	struct starpu_sched_ctx_iterator it;
@@ -1158,6 +1165,8 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
 
 	srand(2008);
 
+	_starpu_util_init();
+
 #ifdef HAVE_AYUDAME_H
 #ifndef AYU_RT_STARPU
 #define AYU_RT_STARPU 4
@@ -1231,16 +1240,13 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
 		return ret;
 	}
 
-	/* Allocate swap, if any */
-	_starpu_swap_init();
-
-	/* We need to store the current task handled by the different
-	 * threads */
-	_starpu_initialize_current_task_key();
+	_starpu_task_init();
 
 	for (worker = 0; worker < config.topology.nworkers; worker++)
 		_starpu_worker_init(&config.workers[worker], &config);
 
+	check_entire_platform = starpu_get_env_number("STARPU_CHECK_ENTIRE_PLATFORM");
+	disable_kernels = starpu_get_env_number("STARPU_DISABLE_KERNELS");
 	STARPU_PTHREAD_KEY_CREATE(&worker_key, NULL);
 	STARPU_PTHREAD_KEY_CREATE(&worker_set_key, NULL);
 
@@ -1258,6 +1264,9 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
 	if (!is_a_sink)
 		_starpu_launch_drivers(&config);
 
+	/* Allocate swap, if any */
+	_starpu_swap_init();
+
 	_starpu_watchdog_init();
 
 	STARPU_PTHREAD_MUTEX_LOCK(&init_mutex);
@@ -1501,7 +1510,6 @@ void starpu_shutdown(void)
 	starpu_profiling_bus_helper_display_summary();
 	starpu_profiling_worker_helper_display_summary();
 
-	_starpu_deinitialize_current_task_key();
 	_starpu_deinitialize_registered_performance_models();
 
 	_starpu_watchdog_shutdown();
@@ -1544,6 +1552,8 @@ void starpu_shutdown(void)
 	STARPU_PTHREAD_KEY_DELETE(worker_key);
 	STARPU_PTHREAD_KEY_DELETE(worker_set_key);
 
+	_starpu_task_deinit();
+
 	STARPU_PTHREAD_MUTEX_LOCK(&init_mutex);
 	initialized = UNINITIALIZED;
 	/* Let someone else that wants to initialize it again do it */

+ 3 - 0
src/core/workers.h

@@ -425,6 +425,9 @@ int _starpu_is_initialized(void);
  * all workers and topology). */
 struct _starpu_machine_config *_starpu_get_machine_config(void);
 
+/* Return whether kernels should be run (<=0) or not (>0) */
+int _starpu_get_disable_kernels(void);
+
 /* Retrieve the status which indicates what the worker is currently doing. */
 enum _starpu_worker_status _starpu_worker_get_status(int workerid);
 

+ 6 - 4
src/datawizard/malloc.c

@@ -29,6 +29,7 @@
 #include <core/simgrid.h>
 
 static size_t _malloc_align = sizeof(void*);
+static int disable_pinning;
 
 void starpu_malloc_set_align(size_t align)
 {
@@ -114,7 +115,7 @@ int starpu_malloc_flags(void **A, size_t dim, int flags)
 			starpu_memory_allocate(STARPU_MAIN_RAM, dim, STARPU_MEMORY_OVERFLOW);
 	}
 
-	if (flags & STARPU_MALLOC_PINNED && starpu_get_env_number("STARPU_DISABLE_PINNING") <= 0 && STARPU_RUNNING_ON_VALGRIND == 0)
+	if (flags & STARPU_MALLOC_PINNED && disable_pinning <= 0 && STARPU_RUNNING_ON_VALGRIND == 0)
 	{
 #ifdef STARPU_SIMGRID
 		/* FIXME: CUDA seems to be taking 650µs every 1MiB.
@@ -289,7 +290,7 @@ static struct starpu_codelet free_pinned_cl =
 int starpu_free_flags(void *A, size_t dim, int flags)
 {
 #ifndef STARPU_SIMGRID
-	if (flags & STARPU_MALLOC_PINNED && starpu_get_env_number("STARPU_DISABLE_PINNING") <= 0 && STARPU_RUNNING_ON_VALGRIND == 0)
+	if (flags & STARPU_MALLOC_PINNED && disable_pinning <= 0 && STARPU_RUNNING_ON_VALGRIND == 0)
 	{
 		if (_starpu_can_submit_cuda_task())
 		{
@@ -606,7 +607,7 @@ _starpu_free_on_node(unsigned dst_node, uintptr_t addr, size_t size)
 int
 starpu_memory_pin(void *addr STARPU_ATTRIBUTE_UNUSED, size_t size STARPU_ATTRIBUTE_UNUSED)
 {
-	if (STARPU_MALLOC_PINNED && starpu_get_env_number("STARPU_DISABLE_PINNING") <= 0 && STARPU_RUNNING_ON_VALGRIND == 0)
+	if (STARPU_MALLOC_PINNED && disable_pinning <= 0 && STARPU_RUNNING_ON_VALGRIND == 0)
 	{
 #if defined(STARPU_USE_CUDA) && defined(HAVE_CUDA_MEMCPY_PEER)
 		if (cudaHostRegister(addr, size, cudaHostRegisterPortable) != cudaSuccess)
@@ -619,7 +620,7 @@ starpu_memory_pin(void *addr STARPU_ATTRIBUTE_UNUSED, size_t size STARPU_ATTRIBU
 int
 starpu_memory_unpin(void *addr STARPU_ATTRIBUTE_UNUSED, size_t size STARPU_ATTRIBUTE_UNUSED)
 {
-	if (STARPU_MALLOC_PINNED && starpu_get_env_number("STARPU_DISABLE_PINNING") <= 0 && STARPU_RUNNING_ON_VALGRIND == 0)
+	if (STARPU_MALLOC_PINNED && disable_pinning <= 0 && STARPU_RUNNING_ON_VALGRIND == 0)
 	{
 #if defined(STARPU_USE_CUDA) && defined(HAVE_CUDA_MEMCPY_PEER)
 		if (cudaHostUnregister(addr) != cudaSuccess)
@@ -689,6 +690,7 @@ _starpu_malloc_init(unsigned dst_node)
 	_starpu_chunk_list_init(&chunks[dst_node]);
 	nfreechunks[dst_node] = 0;
 	STARPU_PTHREAD_MUTEX_INIT(&chunk_mutex[dst_node], NULL);
+	disable_pinning = starpu_get_env_number("STARPU_DISABLE_PINNING");
 }
 
 void

+ 15 - 5
src/datawizard/memalloc.c

@@ -23,6 +23,15 @@
 #include <starpu.h>
 #include <common/uthash.h>
 
+/* Minimum percentage of available memory in each node */
+static unsigned minimum_p;
+static unsigned target_p;
+/* Minimum percentage of number of clean buffer in each node */
+static unsigned minimum_clean_p;
+static unsigned target_clean_p;
+/* Whether CPU memory has been explicitly limited by user */
+static int limit_cpu_mem;
+
 /* This per-node RW-locks protect mc_list and memchunk_cache entries */
 /* Note: handle header lock is always taken before this (normal add/remove case) */
 static struct _starpu_spinlock mc_lock[STARPU_MAXNODES];
@@ -111,6 +120,11 @@ void _starpu_init_mem_chunk_lists(void)
 		STARPU_HG_DISABLE_CHECKING(mc_nb[i]);
 		STARPU_HG_DISABLE_CHECKING(mc_clean_nb[i]);
 	}
+	minimum_p = starpu_get_env_number_default("STARPU_MINIMUM_AVAILABLE_MEM", 5);
+	target_p = starpu_get_env_number_default("STARPU_TARGET_AVAILABLE_MEM", 10);
+	minimum_clean_p = starpu_get_env_number_default("STARPU_MINIMUM_CLEAN_BUFFERS", 10);
+	target_clean_p = starpu_get_env_number_default("STARPU_TARGET_CLEAN_BUFFERS", 25);
+	limit_cpu_mem = starpu_get_env_number("STARPU_LIMIT_CPU_MEM");
 }
 
 void _starpu_deinit_mem_chunk_lists(void)
@@ -876,10 +890,6 @@ void starpu_memchunk_tidy(unsigned node)
 	starpu_ssize_t total = starpu_memory_get_total(node);
 	starpu_ssize_t available = starpu_memory_get_available(node);
 	size_t target, amount;
-	unsigned minimum_p = starpu_get_env_number_default("STARPU_MINIMUM_AVAILABLE_MEM", 5);
-	unsigned target_p = starpu_get_env_number_default("STARPU_TARGET_AVAILABLE_MEM", 10);
-	unsigned minimum_clean_p = starpu_get_env_number_default("STARPU_MINIMUM_CLEAN_BUFFERS", 10);
-	unsigned target_clean_p = starpu_get_env_number_default("STARPU_TARGET_CLEAN_BUFFERS", 25);
 
 	if (mc_clean_nb[node] < (mc_nb[node] * minimum_clean_p) / 100)
 	{
@@ -1128,7 +1138,7 @@ void _starpu_request_mem_chunk_removal(starpu_data_handle_t handle, struct _star
 	 * STARPU_USE_ALLOCATION_CACHE is not enabled, as we
 	 * wouldn't even re-use these allocations!
 	 */
-	if (handle->ops->dontcache || (starpu_node_get_kind(node) == STARPU_CPU_RAM && starpu_get_env_number("STARPU_LIMIT_CPU_MEM") < 0))
+	if (handle->ops->dontcache || (starpu_node_get_kind(node) == STARPU_CPU_RAM && limit_cpu_mem < 0))
 	{
 		/* Free data immediately */
 		free_memory_on_node(mc, node);

+ 1 - 1
src/drivers/cpu/driver_cpu.c

@@ -100,7 +100,7 @@ static int execute_job_on_cpu(struct _starpu_job *j, struct starpu_task *worker_
 			/* bind to parallel worker */
 			_starpu_bind_thread_on_cpus(cpu_args->config, _starpu_get_combined_worker_struct(j->combined_workerid));
 		STARPU_ASSERT_MSG(func, "when STARPU_CPU is defined in 'where', cpu_func or cpu_funcs has to be defined");
-		if (starpu_get_env_number("STARPU_DISABLE_KERNELS") <= 0)
+		if (_starpu_get_disable_kernels() <= 0)
 		{
 			_STARPU_TRACE_START_EXECUTING();
 #ifdef STARPU_SIMGRID

+ 1 - 1
src/drivers/cuda/driver_cuda.c

@@ -452,7 +452,7 @@ static int start_job_on_cuda(struct _starpu_job *j, struct _starpu_worker *worke
 	starpu_cuda_func_t func = _starpu_task_get_cuda_nth_implementation(cl, j->nimpl);
 	STARPU_ASSERT_MSG(func, "when STARPU_CUDA is defined in 'where', cuda_func or cuda_funcs has to be defined");
 
-	if (starpu_get_env_number("STARPU_DISABLE_KERNELS") <= 0)
+	if (_starpu_get_disable_kernels <= 0)
 	{
 		_STARPU_TRACE_START_EXECUTING();
 #ifdef STARPU_SIMGRID

+ 1 - 1
src/drivers/mp_common/sink_common.c

@@ -466,7 +466,7 @@ static void _starpu_sink_common_execute_kernel(struct _starpu_mp_node *node, int
 	}
 	if(task->type != STARPU_FORKJOIN || worker->current_rank == 0)
 	{
-		if (starpu_get_env_number("STARPU_DISABLE_KERNELS") <= 0)
+		if (_starpu_get_disable_kernels <= 0)
 		{
 			/* execute the task */
 			task->kernel(task->interfaces,task->cl_arg);

+ 1 - 1
src/drivers/opencl/driver_opencl.c

@@ -896,7 +896,7 @@ static int _starpu_opencl_start_job(struct _starpu_job *j, struct _starpu_worker
 	starpu_opencl_func_t func = _starpu_task_get_opencl_nth_implementation(cl, j->nimpl);
 	STARPU_ASSERT_MSG(func, "when STARPU_OPENCL is defined in 'where', opencl_func or opencl_funcs has to be defined");
 
-	if (starpu_get_env_number("STARPU_DISABLE_KERNELS") <= 0)
+	if (_starpu_get_disable_kernels <= 0)
 	{
 		_STARPU_TRACE_START_EXECUTING();
 #ifdef STARPU_SIMGRID

+ 1 - 5
src/starpu_parameters.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011, 2014  Université de Bordeaux
+ * Copyright (C) 2011, 2014-2015  Université de Bordeaux
  *
  * 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
@@ -20,10 +20,6 @@
 /* Parameters which are not worth being added to ./configure options, but
  * still interesting to easily change */
 
-/* How many executions a codelet will have to be measured before we
- * consider that calibration will provide a value good enough for scheduling */
-#define _STARPU_CALIBRATION_MINIMUM ((unsigned) starpu_get_env_number_default("STARPU_CALIBRATE_MINIMUM", 10))
-
 /* Assumed relative performance ratios */
 /* TODO: benchmark a bit instead */
 #define _STARPU_CPU_ALPHA	1.0f