Explorar el Código

Revert "src: store driver information in _starpu_worker struct"

This reverts commit 2d2203bf2eae99a5a2df85924c30f8aa55b00c5d.
Nathalie Furmento hace 6 años
padre
commit
de7b147914
Se han modificado 3 ficheros con 54 adiciones y 34 borrados
  1. 14 8
      src/core/topology.c
  2. 40 24
      src/core/workers.c
  3. 0 2
      src/core/workers.h

+ 14 - 8
src/core/topology.c

@@ -353,32 +353,38 @@ struct _starpu_worker *_starpu_get_worker_from_driver(struct starpu_driver *d)
 
 	for (workerid = 0; workerid < nworkers; workerid++)
 	{
-		struct _starpu_worker *worker;
-		worker = _starpu_get_worker_struct(workerid);
-
 		if (starpu_worker_get_type(workerid) == d->type)
 		{
+			struct _starpu_worker *worker;
+			worker = _starpu_get_worker_struct(workerid);
 			switch (d->type)
 			{
+#ifdef STARPU_USE_CPU
 			case STARPU_CPU_WORKER:
-			{
-				if (worker->driver.id.cpu_id == d->id.cpu_id)
+				if (worker->devid == d->id.cpu_id)
 					return worker;
 				break;
-			}
+#endif
+#ifdef STARPU_USE_OPENCL
 			case STARPU_OPENCL_WORKER:
 			{
-				if (worker->driver.id.opencl_id == d->id.opencl_id)
+				cl_device_id device;
+				starpu_opencl_get_device(worker->devid, &device);
+				if (device == d->id.opencl_id)
 					return worker;
 				break;
 			}
+#endif
+#ifdef STARPU_USE_CUDA
 			case STARPU_CUDA_WORKER:
 			{
-				if (worker->driver.id.cuda_id == d->id.cuda_id)
+				if (worker->devid == d->id.cuda_id)
 					return worker;
 				break;
 
 			}
+#endif
+
 			default:
 				(void) worker;
 				_STARPU_DEBUG("Invalid device type\n");

+ 40 - 24
src/core/workers.c

@@ -673,18 +673,17 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 
 		_starpu_init_worker_queue(workerarg);
 
-		struct starpu_driver *driver = &(workerarg->driver);
-		driver->type = workerarg->arch;
+		struct starpu_driver driver;
+		driver.type = workerarg->arch;
 		switch (workerarg->arch)
 		{
 #if defined(STARPU_USE_CPU) || defined(STARPU_SIMGRID)
 			case STARPU_CPU_WORKER:
-				driver->id.cpu_id = devid;
+				driver.id.cpu_id = devid;
 				workerarg->driver_ops = &_starpu_driver_cpu_ops;
 				workerarg->wait_for_worker_initialization = 1;
-				workerarg->may_launch_driver = _starpu_may_launch_driver(&pconfig->conf, driver);
 
-				if (workerarg->may_launch_driver)
+				if (_starpu_may_launch_driver(&pconfig->conf, &driver))
 				{
 					STARPU_PTHREAD_CREATE_ON(
 						"CPU",
@@ -703,7 +702,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
 			case STARPU_CUDA_WORKER:
-				driver->id.cuda_id = devid;
+				driver.id.cuda_id = devid;
 				workerarg->driver_ops = &_starpu_driver_cuda_ops;
 				struct _starpu_worker_set *worker_set = workerarg->set;
 
@@ -715,9 +714,8 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 				worker_set->set_is_initialized = 0;
 				worker_set->wait_for_set_initialization = 1;
 				workerarg->wait_for_worker_initialization = 0;
-				workerarg->may_launch_driver = _starpu_may_launch_driver(&pconfig->conf, driver);
 
-				if (workerarg->may_launch_driver)
+				if (_starpu_may_launch_driver(&pconfig->conf, &driver))
 				{
 					STARPU_PTHREAD_CREATE_ON(
 						"CUDA",
@@ -737,12 +735,11 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 #if defined(STARPU_USE_OPENCL) || defined(STARPU_SIMGRID)
 			case STARPU_OPENCL_WORKER:
 #ifndef STARPU_SIMGRID
-				starpu_opencl_get_device(devid, &driver->id.opencl_id);
+				starpu_opencl_get_device(devid, &driver.id.opencl_id);
 				workerarg->driver_ops = &_starpu_driver_opencl_ops;
 				workerarg->wait_for_worker_initialization = 1;
-				workerarg->may_launch_driver = _starpu_may_launch_driver(&pconfig->conf, driver);
 
-				if (workerarg->may_launch_driver)
+				if (_starpu_may_launch_driver(&pconfig->conf, &driver))
 				{
 					STARPU_PTHREAD_CREATE_ON(
 						"OpenCL",
@@ -1550,24 +1547,43 @@ unsigned _starpu_worker_can_block(unsigned memnode STARPU_ATTRIBUTE_UNUSED, stru
 	if (worker->state_changing_ctx_notice)
 		return 0;
 
-	if (worker->driver.type == STARPU_CPU_WORKER || worker->driver.type == STARPU_CUDA_WORKER || worker->driver.type == STARPU_OPENCL_WORKER)
+	unsigned can_block = 1;
+
+	struct starpu_driver driver;
+	driver.type = worker->arch;
+	switch (driver.type)
 	{
-		if (worker->may_launch_driver == 0)
-			return 0;
+	case STARPU_CPU_WORKER:
+		driver.id.cpu_id = worker->devid;
+		break;
+	case STARPU_CUDA_WORKER:
+		driver.id.cuda_id = worker->devid;
+		break;
+#ifdef STARPU_USE_OPENCL
+	case STARPU_OPENCL_WORKER:
+		starpu_opencl_get_device(worker->devid, &driver.id.opencl_id);
+		break;
+#endif
+	default:
+		goto always_launch;
 	}
-	else
-	{
+	if (!_starpu_may_launch_driver(&_starpu_config.conf, &driver))
+		return 0;
+
+always_launch:
+
 #ifndef STARPU_SIMGRID
-		if (!_starpu_check_that_no_data_request_exists(memnode))
-			return 0;
+	if (!_starpu_check_that_no_data_request_exists(memnode))
+		can_block = 0;
 #endif
-		if (!_starpu_machine_is_running())
-			return 0;
 
-		if (!_starpu_execute_registered_progression_hooks())
-			return 0;
-	}
-	return 1;
+	if (!_starpu_machine_is_running())
+		can_block = 0;
+
+	if (!_starpu_execute_registered_progression_hooks())
+		can_block = 0;
+
+	return can_block;
 #endif
 }
 

+ 0 - 2
src/core/workers.h

@@ -154,8 +154,6 @@ LIST_TYPE(_starpu_worker,
 	char short_name[32];
 	unsigned run_by_starpu; /**< Is this run by StarPU or directly by the application ? */
 	struct _starpu_driver_ops *driver_ops;
-	struct starpu_driver driver;
-	unsigned may_launch_driver;
 
 	struct _starpu_sched_ctx_list *sched_ctx_list;
 	int tmp_sched_ctx;