Selaa lähdekoodia

Use simpler loop

Samuel Thibault 8 vuotta sitten
vanhempi
commit
0824d155cd
1 muutettua tiedostoa jossa 15 lisäystä ja 18 poistoa
  1. 15 18
      src/core/topology.c

+ 15 - 18
src/core/topology.c

@@ -797,26 +797,23 @@ _starpu_get_next_bindid (struct _starpu_machine_config *config,
 	}
 
 	for (i = config->current_bindid; i < topology->nhwpus / nhyperthreads; i++)
+		if (!config->currently_bound[i])
+			/* 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)
 	{
-		if (config->currently_bound[i])
-			/* Not available (probably used for driving a GPU), skip it */
-			continue;
-
-		/* Found a cpu ready for use, use it! */
-		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
-			 * case the user really wants overloading */
-			memset(&config->currently_bound, 0, sizeof(config->currently_bound));
-			i = 0;
-		}
-		config->current_bindid = i;
-		return bindid;
+		/* Finished binding on all cpus, restart from start in
+		 * case the user really wants overloading */
+		memset(&config->currently_bound, 0, sizeof(config->currently_bound));
+		i = 0;
 	}
-	STARPU_ASSERT(0);
+	config->current_bindid = i;
+	return bindid;
 }
 
 unsigned