瀏覽代碼

topology: fix crash when core preference array includes the last CPU

In that case, the last non-preference CPU binding will not be the last
CPU.

Instead of preparing currently_bound for future binding, better just
cure when it happens to be full

(cherry picked from commit 7dd9790f3b3a84db808dbb9fc3b45b419677d64d)
Samuel Thibault 6 年之前
父節點
當前提交
aa38d7d57e
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      src/core/topology.c

+ 4 - 4
src/core/topology.c

@@ -1074,10 +1074,6 @@ _starpu_get_next_bindid (struct _starpu_machine_config *config,
 			/* Found a cpu ready for use, use it! */
 			break;
 
-	STARPU_ASSERT(i < topology->nhwpus / nhyperthreads);
-	int bindid = topology->workers_bindid[i];
-	config->currently_bound[i] = 1;
-	i++;
 	if (i == topology->nhwpus / nhyperthreads)
 	{
 		/* Finished binding on all cpus, restart from start in
@@ -1085,6 +1081,10 @@ _starpu_get_next_bindid (struct _starpu_machine_config *config,
 		memset(&config->currently_bound, 0, sizeof(config->currently_bound));
 		i = 0;
 	}
+
+	STARPU_ASSERT(i < topology->nhwpus / nhyperthreads);
+	int bindid = topology->workers_bindid[i];
+	config->currently_bound[i] = 1;
 	config->current_bindid = i;
 	return bindid;
 }