Sfoglia il codice sorgente

load-balancer: minor fixes

Nathalie Furmento 8 anni fa
parent
commit
173fcc2a6b

+ 2 - 2
include/starpu_scheduler.h

@@ -55,11 +55,11 @@ struct starpu_sched_policy
 };
 
 struct starpu_sched_policy **starpu_sched_get_predefined_policies();
-void starpu_sched_policy_set_post_exec_hook(void (*post_exec_hook)(struct starpu_task *task), const char *policy_name);
+void starpu_sched_policy_set_post_exec_hook(void (*post_exec_hook)(struct starpu_task *task, unsigned sched_ctx_id), const char *policy_name);
 
 void starpu_worker_get_sched_condition(int workerid, starpu_pthread_mutex_t **sched_mutex, starpu_pthread_cond_t **sched_cond);
 
-/* This function must be called to wake up a worker that is sleeping on the cond. 
+/* This function must be called to wake up a worker that is sleeping on the cond.
  * It returns 0 whenever the worker is not in a sleeping state */
 int starpu_wake_worker(int workerid);
 int starpu_wakeup_worker(int workerid, starpu_pthread_cond_t *cond, starpu_pthread_mutex_t *mutex);

+ 5 - 4
mpi/include/starpu_mpi_lb.h

@@ -1,6 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2016  Inria
+ * Copyright (C) 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
@@ -14,8 +15,8 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#ifndef __LOAD_BALANCER_H__
-#define __LOAD_BALANCER_H__
+#ifndef __STARPU_MPI_LOAD_BALANCER_H__
+#define __STARPU_MPI_LOAD_BALANCER_H__
 
 #ifdef __cplusplus
 extern "C" {
@@ -29,7 +30,7 @@ struct starpu_mpi_lb_conf
 };
 
 /* Inits the load balancer's environment with the load policy provided by the
- * user 
+ * user
  */
 void starpu_mpi_lb_init(struct starpu_mpi_lb_conf *);
 void starpu_mpi_lb_shutdown();
@@ -38,4 +39,4 @@ void starpu_mpi_lb_shutdown();
 }
 #endif
 
-#endif // __LOAD_BALANCER_H__
+#endif // __STARPU_MPI_LOAD_BALANCER_H__

+ 16 - 12
mpi/src/load_balancer/load_balancer.c

@@ -1,6 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2016  Inria
+ * Copyright (C) 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
@@ -24,15 +25,15 @@
 #include "policy/load_balancer_policy.h"
 
 static struct load_balancer_policy *defined_policy = NULL;
-static void (*saved_post_exec_hook)(struct starpu_task *task) = NULL;
+static void (*saved_post_exec_hook)(struct starpu_task *task, unsigned sched_ctx_id) = NULL;
 
-static void post_exec_hook_wrapper(struct starpu_task *task)
+static void post_exec_hook_wrapper(struct starpu_task *task, unsigned sched_ctx_id)
 {
 	//fprintf(stderr,"I am called ! \n");
 	if (defined_policy && defined_policy->finished_task_entry_point)
 		defined_policy->finished_task_entry_point();
 	if (saved_post_exec_hook)
-		saved_post_exec_hook(task);
+		saved_post_exec_hook(task, sched_ctx_id);
 }
 
 static struct load_balancer_policy *predefined_policies[] =
@@ -61,17 +62,20 @@ void starpu_mpi_lb_init(struct starpu_mpi_lb_conf *itf)
 		return;
 	}
 
-	struct load_balancer_policy **policy;
-	for(policy=predefined_policies ; *policy!=NULL ; policy++)
+	if (policy_name)
 	{
-		struct load_balancer_policy *p = *policy;
-		if (p->policy_name)
+		struct load_balancer_policy **policy;
+		for(policy=predefined_policies ; *policy!=NULL ; policy++)
 		{
-			if (strcmp(policy_name, p->policy_name) == 0)
+			struct load_balancer_policy *p = *policy;
+			if (p->policy_name)
 			{
-				/* we found a policy with the requested name */
-				defined_policy = p;
-				break;
+				if (strcmp(policy_name, p->policy_name) == 0)
+				{
+					/* we found a policy with the requested name */
+					defined_policy = p;
+					break;
+				}
 			}
 		}
 	}
@@ -82,7 +86,7 @@ void starpu_mpi_lb_init(struct starpu_mpi_lb_conf *itf)
 		return;
 	}
 
-	if (defined_policy->init(itf))
+	if (defined_policy->init(itf) != 0)
 	{
 		fprintf(stderr,"Error in load_balancer->init: invalid starpu_mpi_lb_conf. Load balancing will be disabled for this run.\n");
 		return;

+ 1 - 0
mpi/src/load_balancer/policy/load_balancer_policy.h

@@ -1,6 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2016  Inria
+ * Copyright (C) 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

+ 11 - 11
src/core/sched_policy.c

@@ -87,18 +87,18 @@ struct starpu_sched_policy *_starpu_get_sched_policy(struct _starpu_sched_ctx *s
 	return sched_ctx->sched_policy;
 }
 
-void starpu_sched_policy_set_post_exec_hook(void (*post_exec_hook)(struct starpu_task *task), const char *policy_name)
+void starpu_sched_policy_set_post_exec_hook(void (*post_exec_hook)(struct starpu_task *task, unsigned sched_ctx_id), const char *policy_name)
 {
-    int i;
-    struct _starpu_sched_ctx *sched_ctx;
-    for(i = 0; i < STARPU_NMAX_SCHED_CTXS; i++)
-    {
-        sched_ctx = _starpu_get_sched_ctx_struct(i);
-        if (sched_ctx && sched_ctx->sched_policy)
-            sched_ctx->sched_policy->post_exec_hook = post_exec_hook;
-        else
-            break;
-    }
+	int i;
+	struct _starpu_sched_ctx *sched_ctx;
+	for(i = 0; i < STARPU_NMAX_SCHED_CTXS; i++)
+	{
+		sched_ctx = _starpu_get_sched_ctx_struct(i);
+		if (sched_ctx && sched_ctx->sched_policy)
+			sched_ctx->sched_policy->post_exec_hook = post_exec_hook;
+		else
+			break;
+	}
 }
 
 /*