Kaynağa Gözat

Fix a bug that caused CUDA devices not to be initialized correctly when using STARPU_CUDAID.

Thanks to Nicolas Collin for reporting this issue.
Cyril Roelandt 13 yıl önce
ebeveyn
işleme
f60fae9bff
1 değiştirilmiş dosya ile 14 ekleme ve 7 silme
  1. 14 7
      src/drivers/cuda/driver_cuda.c

+ 14 - 7
src/drivers/cuda/driver_cuda.c

@@ -304,13 +304,20 @@ static int execute_job_on_cuda(struct _starpu_job *j, struct _starpu_worker *arg
 static struct _starpu_worker*
 _starpu_get_worker_from_driver(struct starpu_driver *d)
 {
-	int workers[d->id.cuda_id + 1];
-	int nworkers;
-	nworkers = starpu_worker_get_ids_by_type(STARPU_CUDA_WORKER, workers, d->id.cuda_id+1);
-	if (nworkers >= 0 && (unsigned) nworkers < d->id.cuda_id)
-		return NULL; // No device was found.
-	
-	return _starpu_get_worker_struct(workers[d->id.cuda_id]);
+	unsigned nworkers = starpu_worker_get_count();
+	unsigned  workerid;
+	for (workerid = 0; workerid < nworkers; workerid++)
+	{
+		if (starpu_worker_get_type(workerid) == d->type)
+		{
+			struct _starpu_worker *worker;
+			worker = _starpu_get_worker_struct(workerid);
+			if (worker->devid == d->id.cuda_id)
+				return worker;
+		}
+	}
+
+	return NULL;
 }
 
 /* XXX Should this be merged with _starpu_init_cuda ? */