Przeglądaj źródła

Count the number of workers in memory nodes, to avoid scheduling transfers from memory nodes without a worker (e.g. 0 cpus). Fixes at least the wt mask when no CPU is enabled.

Samuel Thibault 13 lat temu
rodzic
commit
73123b92d6

+ 4 - 0
src/core/topology.c

@@ -670,11 +670,13 @@ static void _starpu_init_workers_binding(struct starpu_machine_config_s *config)
 			/* "dedicate" a cpu cpu to that worker */
 				is_a_set_of_accelerators = 0;
 				memory_node = ram_memory_node;
+				_starpu_memory_node_worker_add(ram_memory_node);
 				break;
 #ifdef STARPU_USE_GORDON
 			case STARPU_GORDON_WORKER:
 				is_a_set_of_accelerators = 1;
 				memory_node = ram_memory_node;
+				_starpu_memory_node_worker_add(ram_memory_node);
 				break;
 #endif
 #ifdef STARPU_USE_CUDA
@@ -687,6 +689,7 @@ static void _starpu_init_workers_binding(struct starpu_machine_config_s *config)
 				}
 				is_a_set_of_accelerators = 0;
 				memory_node = _starpu_register_memory_node(STARPU_CUDA_RAM, workerarg->devid);
+				_starpu_memory_node_worker_add(memory_node);
 
 				_starpu_register_bus(0, memory_node);
 				_starpu_register_bus(memory_node, 0);
@@ -703,6 +706,7 @@ static void _starpu_init_workers_binding(struct starpu_machine_config_s *config)
 				}
 				is_a_set_of_accelerators = 0;
 				memory_node = _starpu_register_memory_node(STARPU_OPENCL_RAM, workerarg->devid);
+				_starpu_memory_node_worker_add(memory_node);
 				_starpu_register_bus(0, memory_node);
 				_starpu_register_bus(memory_node, 0);
 				break;

+ 5 - 1
src/datawizard/coherency.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2009-2011  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -111,6 +111,10 @@ static int worker_supports_direct_access(unsigned node, unsigned handling_node)
 	if (node == handling_node)
 		return 1;
 
+	if (!_starpu_memory_node_workers(handling_node))
+		/* No worker to process the request from that node */
+		return 0;
+
 	int type = _starpu_get_node_kind(node);
 	switch (type)
 	{

+ 14 - 2
src/datawizard/memory_nodes.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2009-2011  Université de Bordeaux 1
  * Copyright (C) 2010  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -35,8 +35,10 @@ void _starpu_init_memory_nodes(void)
 	pthread_key_create(&memory_node_key, NULL);
 
 	unsigned i;
-	for (i = 0; i < STARPU_MAXNODES; i++) 
+	for (i = 0; i < STARPU_MAXNODES; i++) {
 		descr.nodes[i] = STARPU_UNUSED; 
+		descr.nworkers[i] = 0;
+	}
 
 	_starpu_init_mem_chunk_lists();
 	_starpu_init_data_request_lists();
@@ -71,6 +73,16 @@ unsigned _starpu_get_local_memory_node(void)
 	return *memory_node;
 }
 
+void _starpu_memory_node_worker_add(unsigned node)
+{
+	descr.nworkers[node]++;
+}
+
+unsigned _starpu_memory_node_workers(unsigned node)
+{
+	return descr.nworkers[node];
+}
+
 starpu_mem_node_descr *_starpu_get_memory_node_description(void)
 {
 	return &descr;

+ 5 - 1
src/datawizard/memory_nodes.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010  Université de Bordeaux 1
+ * Copyright (C) 2009-2011  Université de Bordeaux 1
  * Copyright (C) 2010  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -49,6 +49,8 @@ typedef struct {
 	/* Get the device id associated to this node, or -1 if not applicable */
 	int devid[STARPU_MAXNODES];
 
+	unsigned nworkers[STARPU_MAXNODES];
+
 	// TODO move this 2 lists outside starpu_mem_node_descr
 	/* Every worker is associated to a condition variable on which the
 	 * worker waits when there is task available. It is possible that
@@ -68,6 +70,8 @@ void _starpu_init_memory_nodes(void);
 void _starpu_deinit_memory_nodes(void);
 void _starpu_set_local_memory_node_key(unsigned *node);
 unsigned _starpu_get_local_memory_node(void);
+void _starpu_memory_node_worker_add(unsigned node);
+unsigned _starpu_memory_node_workers(unsigned node);
 unsigned _starpu_register_memory_node(starpu_node_kind kind, int devid);
 //void _starpu_memory_node_attach_queue(struct starpu_jobq_s *q, unsigned nodeid);
 void _starpu_memory_node_register_condition(pthread_cond_t *cond, pthread_mutex_t *mutex, unsigned memory_node);