瀏覽代碼

src: slightly improve _starpu_select_sched_policy() and fix heft detection

Nathalie Furmento 8 年之前
父節點
當前提交
d3a6512230
共有 2 個文件被更改,包括 17 次插入10 次删除
  1. 2 1
      src/common/utils.h
  2. 15 9
      src/core/sched_policy.c

+ 2 - 1
src/common/utils.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2012-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016, 2017  CNRS
  *
  * 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
@@ -107,6 +107,7 @@
 #endif
 
 /* TODO: cache */
+#define _STARPU_MSG(fmt, ...) do { fprintf(stderr, STARPU_DEBUG_PREFIX"[%s] " fmt ,__starpu_func__ ,## __VA_ARGS__); } while(0)
 #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 {                                                                          \

+ 15 - 9
src/core/sched_policy.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
- * Copyright (C) 2010-2016  CNRS
+ * Copyright (C) 2010-2017  CNRS
  * Copyright (C) 2011, 2016  INRIA
  * Copyright (C) 2016  Uppsala University
  *
@@ -115,9 +115,12 @@ static struct starpu_sched_policy *find_sched_policy_from_name(const char *polic
 	if (!policy_name)
 		return NULL;
 
-	if (strncmp(policy_name, "heft", 5) == 0)
+	if (strcmp(policy_name, "") == 0)
+		return NULL;
+
+	if (strncmp(policy_name, "heft", 4) == 0)
 	{
-		_STARPU_DISP("Warning: heft is now called \"dmda\".\n");
+		_STARPU_MSG("Warning: heft is now called \"dmda\".\n");
 		return &_starpu_sched_dmda_policy;
 	}
 
@@ -135,7 +138,7 @@ static struct starpu_sched_policy *find_sched_policy_from_name(const char *polic
 		}
 	}
 	if (strcmp(policy_name, "help") != 0)
-	     fprintf(stderr, "Warning: scheduling policy \"%s\" was not found, try \"help\" to get a list\n", policy_name);
+		_STARPU_MSG("Warning: scheduling policy '%s' was not found, try 'help' to get a list\n", policy_name);
 
 	/* nothing was found */
 	return NULL;
@@ -167,8 +170,12 @@ struct starpu_sched_policy *_starpu_select_sched_policy(struct _starpu_machine_c
 	if(required_policy)
 		selected_policy = find_sched_policy_from_name(required_policy);
 
+	/* If there is a policy that matches the required name, return it */
+	if (selected_policy)
+		return selected_policy;
+
 	/* First, we check whether the application explicitely gave a scheduling policy or not */
-	if (!selected_policy && user_conf && (user_conf->sched_policy))
+	if (user_conf && (user_conf->sched_policy))
 		return user_conf->sched_policy;
 
 	/* Otherwise, we look if the application specified the name of a policy to load */
@@ -176,15 +183,14 @@ struct starpu_sched_policy *_starpu_select_sched_policy(struct _starpu_machine_c
 	sched_pol_name = starpu_getenv("STARPU_SCHED");
 	if (sched_pol_name == NULL && user_conf && user_conf->sched_policy_name)
 		sched_pol_name = user_conf->sched_policy_name;
-
-	if (!selected_policy && sched_pol_name)
+	if (sched_pol_name)
 		selected_policy = find_sched_policy_from_name(sched_pol_name);
 
-	/* Perhaps there was no policy that matched the name */
+	/* If there is a policy that matches the name, return it */
 	if (selected_policy)
 		return selected_policy;
 
-	/* If no policy was specified, we use the greedy policy as a default */
+	/* If no policy was specified, we use the eager policy by default */
 	return &_starpu_sched_eager_policy;
 }