Просмотр исходного кода

max: Also support host:* patterns

Samuel Thibault лет назад: 3
Родитель
Сommit
c35766b102
1 измененных файлов с 20 добавлено и 8 удалено
  1. 20 8
      src/drivers/max/driver_fpga.c

+ 20 - 8
src/drivers/max/driver_fpga.c

@@ -99,7 +99,8 @@ void _starpu_fpga_discover_devices (struct _starpu_machine_config *config)
 
 		/* First check if we have a star, we will want to subtract non-star loads from it */
 		for (cur =  load; cur->engine_id_pattern; cur++)
-			if (!strcmp(cur->engine_id_pattern, "*"))
+			if (!strcmp(cur->engine_id_pattern, "*")
+			 ||  strstr(cur->engine_id_pattern, ":*"))
 			{
 				STARPU_ASSERT_MSG(!cur[1].file, "in starpu_max_load array, * pattern must be last");
 				star = cur;
@@ -108,7 +109,7 @@ void _starpu_fpga_discover_devices (struct _starpu_machine_config *config)
 					/* not specified, assume 1 */
 					nstar = 1;
 				else
-					nstar = max_count_engines_free(cur->file, cur->engine_id_pattern);
+					nstar = max_count_engines_free(cur->file, star->engine_id_pattern);
 				break;
 			}
 
@@ -123,9 +124,9 @@ void _starpu_fpga_discover_devices (struct _starpu_machine_config *config)
 			/* One FPGA more to be used */
 			n++;
 
-			if (nstar)
+			if (star)
 			{
-				size = max_count_engines_free(load->file, "*");
+				size = max_count_engines_free(load->file, star->engine_id_pattern);
 				if (size > 1)
 					/* One of the star devices will be used to load this file */
 					nstar--;
@@ -181,7 +182,8 @@ static void init_device_context(unsigned devid)
 		/* Which load we shall use */
 		for (n = 0; load->file; n++, load++)
 		{
-			if (!strcmp(load->engine_id_pattern, "*"))
+			if (!strcmp(load->engine_id_pattern, "*")
+			 ||  strstr(load->engine_id_pattern, ":*"))
 				break;
 			if (n == devid)
 				break;
@@ -189,10 +191,20 @@ static void init_device_context(unsigned devid)
 
 		STARPU_ASSERT(load->file);
 
-		if (!strcmp(load->engine_id_pattern, "*"))
+		if (!strcmp(load->engine_id_pattern, "*")
+		  || strstr(load->engine_id_pattern, ":*"))
 		{
-			char s[32];
-			snprintf(s, sizeof(s), "*:%u", (unsigned) devid);
+			char s[strlen(load->engine_id_pattern) + 32];
+			if (!strcmp(load->engine_id_pattern, "*"))
+				snprintf(s, sizeof(s), "*:%u", (unsigned) devid);
+			else
+			{
+				char *colon = strstr(load->engine_id_pattern, ":*");
+				snprintf(s, sizeof(s), "%.*s:%u",
+						colon - load->engine_id_pattern,
+						load->engine_id_pattern
+						(unsigned) devid);
+			}
 			/* FIXME: this assumes that the loads are in-order.
 			 * Ideally we'd detect which ones had an explicit load */
 			engines[devid] = max_load(load->file, s);