浏览代码

Do not even create the watchdog thread when STARPU_WATCHDOG_TIMEOUT is not set

Samuel Thibault 10 年之前
父节点
当前提交
117254cf3b
共有 1 个文件被更改,包括 8 次插入6 次删除
  1. 8 6
      src/core/task.c

+ 8 - 6
src/core/task.c

@@ -1116,15 +1116,12 @@ unsigned starpu_task_get_implementation(struct starpu_task *task)
 static starpu_pthread_t watchdog_thread;
 static starpu_pthread_t watchdog_thread;
 
 
 /* Check from times to times that StarPU does finish some tasks */
 /* Check from times to times that StarPU does finish some tasks */
-static void *watchdog_func(void *foo STARPU_ATTRIBUTE_UNUSED)
+static void *watchdog_func(void *arg)
 {
 {
 	struct timespec ts;
 	struct timespec ts;
-	char *timeout_env;
+	char *timeout_env = arg;
 	unsigned long long timeout;
 	unsigned long long timeout;
 
 
-	if (! (timeout_env = getenv("STARPU_WATCHDOG_TIMEOUT")))
-		return NULL;
-
 #ifdef _MSC_VER
 #ifdef _MSC_VER
 	timeout = (unsigned long long) _atoi64(timeout_env);
 	timeout = (unsigned long long) _atoi64(timeout_env);
 #else
 #else
@@ -1166,8 +1163,13 @@ static void *watchdog_func(void *foo STARPU_ATTRIBUTE_UNUSED)
 void _starpu_watchdog_init(void)
 void _starpu_watchdog_init(void)
 {
 {
 	struct _starpu_machine_config *config = (struct _starpu_machine_config *)_starpu_get_machine_config();
 	struct _starpu_machine_config *config = (struct _starpu_machine_config *)_starpu_get_machine_config();
+	char *timeout_env = getenv("STARPU_WATCHDOG_TIMEOUT");
+
+	if (!timeout_env)
+		return;
+
 	STARPU_PTHREAD_MUTEX_INIT(&config->submitted_mutex, NULL);
 	STARPU_PTHREAD_MUTEX_INIT(&config->submitted_mutex, NULL);
-	STARPU_PTHREAD_CREATE(&watchdog_thread, NULL, watchdog_func, NULL);
+	STARPU_PTHREAD_CREATE(&watchdog_thread, NULL, watchdog_func, timeout_env);
 }
 }
 
 
 void _starpu_watchdog_shutdown(void)
 void _starpu_watchdog_shutdown(void)