Browse Source

Use a different structure for ordered buffers

Samuel Thibault 11 years ago
parent
commit
64e93e4cf2
4 changed files with 19 additions and 13 deletions
  1. 2 2
      src/core/jobs.c
  2. 7 2
      src/core/jobs.h
  3. 7 7
      src/datawizard/sort_data_handles.c
  4. 3 2
      src/datawizard/sort_data_handles.h

+ 2 - 2
src/core/jobs.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2013  Université de Bordeaux 1
+ * Copyright (C) 2009-2014  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011  INRIA
@@ -53,7 +53,7 @@ struct _starpu_job* STARPU_ATTRIBUTE_MALLOC _starpu_job_create(struct starpu_tas
 	memset(job, 0, sizeof(*job));
 
 	if (task->dyn_handles)
-	     job->dyn_ordered_buffers = malloc(task->cl->nbuffers * sizeof(struct starpu_data_descr));
+	     job->dyn_ordered_buffers = malloc(task->cl->nbuffers * sizeof(job->dyn_ordered_buffers[0]));
 
 	job->task = task;
 

+ 7 - 2
src/core/jobs.h

@@ -53,6 +53,11 @@ typedef void (*_starpu_cl_func_t)(void **, void *);
 #define _STARPU_MIC_MAY_PERFORM(j)	((j)->task->cl->where & STARPU_MIC)
 #define _STARPU_SCC_MAY_PERFORM(j)	((j)->task->cl->where & STARPU_SCC)
 
+struct _starpu_data_descr {
+	starpu_data_handle_t handle;
+	enum starpu_data_access_mode mode;
+};
+
 /* A job is the internal representation of a task. */
 LIST_TYPE(_starpu_job,
 
@@ -70,8 +75,8 @@ LIST_TYPE(_starpu_job,
 	/* To avoid deadlocks, we reorder the different buffers accessed to by
 	 * the task so that we always grab the rw-lock associated to the
 	 * handles in the same order. */
-	struct starpu_data_descr ordered_buffers[STARPU_NMAXBUFS];
-	struct starpu_data_descr *dyn_ordered_buffers;
+	struct _starpu_data_descr ordered_buffers[STARPU_NMAXBUFS];
+	struct _starpu_data_descr *dyn_ordered_buffers;
 
 	/* If a tag is associated to the job, this points to the internal data
 	 * structure that describes the tag status. */

+ 7 - 7
src/datawizard/sort_data_handles.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2011  Université de Bordeaux 1
+ * Copyright (C) 2010-2011, 2014  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
@@ -64,8 +64,8 @@ static int _compar_data_paths(const unsigned pathA[], unsigned depthA,
 
 /* A comparision function between two handles makes it possible to use qsort to
  * sort a list of handles */
-static int _starpu_compar_handles(const struct starpu_data_descr *descrA,
-				  const struct starpu_data_descr *descrB)
+static int _starpu_compar_handles(const struct _starpu_data_descr *descrA,
+				  const struct _starpu_data_descr *descrB)
 {
 	struct _starpu_data_state *dataA = descrA->handle;
 	struct _starpu_data_state *dataB = descrB->handle;
@@ -109,14 +109,14 @@ static int _starpu_compar_handles(const struct starpu_data_descr *descrA,
 
 static int _starpu_compar_buffer_descr(const void *_descrA, const void *_descrB)
 {
-	const struct starpu_data_descr *descrA = (const struct starpu_data_descr *) _descrA;
-	const struct starpu_data_descr *descrB = (const struct starpu_data_descr *) _descrB;
+	const struct _starpu_data_descr *descrA = (const struct _starpu_data_descr *) _descrA;
+	const struct _starpu_data_descr *descrB = (const struct _starpu_data_descr *) _descrB;
 
 	return _starpu_compar_handles(descrA, descrB);
 }
 
 /* The descr array will be overwritten, so this must be a copy ! */
-void _starpu_sort_task_handles(struct starpu_data_descr descr[], unsigned nbuffers)
+void _starpu_sort_task_handles(struct _starpu_data_descr descr[], unsigned nbuffers)
 {
-	qsort(descr, nbuffers, sizeof(struct starpu_data_descr), _starpu_compar_buffer_descr);
+	qsort(descr, nbuffers, sizeof(descr[0]), _starpu_compar_buffer_descr);
 }

+ 3 - 2
src/datawizard/sort_data_handles.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  Université de Bordeaux 1
+ * Copyright (C) 2010, 2014  Université de Bordeaux 1
  * Copyright (C) 2010  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -23,12 +23,13 @@
 #include <stdlib.h>
 
 #include <stdarg.h>
+#include <core/jobs.h>
 #include <datawizard/coherency.h>
 #include <datawizard/memalloc.h>
 
 /* To avoid deadlocks, we reorder the different buffers accessed to by the task
  * so that we always grab the rw-lock associated to the handles in the same
  * order. */
-void _starpu_sort_task_handles(struct starpu_data_descr descr[], unsigned nbuffers);
+void _starpu_sort_task_handles(struct _starpu_data_descr descr[], unsigned nbuffers);
 
 #endif // SORT_DATA_HANDLES