浏览代码

Add starpu_data_set_user_data and starpu_data_get_user_data.

Samuel Thibault 8 年之前
父节点
当前提交
26f550995f

+ 1 - 0
AUTHORS

@@ -4,6 +4,7 @@ Olivier Aumage <olivier.aumage@inria.fr>
 William Braik <wbraik@gmail.com>
 Berenger Bramas <berenger.bramas@inria.fr>
 Alfredo Buttari <alfredo.buttari@enseeiht.fr>
+Adrien Cassagne <adrien.cassagne@inria.fr>
 Jérôme Clet-Ortega <jerome.clet-ortega@labri.fr>
 Nicolas Collin <nicolas.collin@inria.fr>
 Ludovic Courtès <ludovic.courtes@inria.fr>

+ 1 - 0
ChangeLog

@@ -41,6 +41,7 @@ New features:
   * Add starpu_tasks_rec_complete tool to add estimation times in tasks.rec
     files.
   * Add STARPU_FXT_TRACE environment variable.
+  * Add starpu_data_set_user_data and starpu_data_get_user_data.
 
 StarPU 1.2.0 (svn revision 18521)
 ==============================================

+ 11 - 0
doc/doxygen/chapters/api/data_management.doxy

@@ -243,6 +243,17 @@ done with the codelet \p redux_cl.
 \ingroup API_Data_Management
 todo
 
+\fn void starpu_data_set_user_data(starpu_data_handle_t handle, void* user_data)
+\ingroup API_Data_Management
+This sets the "user_data" field for the \p handle to \p user_data . It can
+then be retrieved with starpu_data_get_user_data. \p user_data can be any
+application-defined value, for instance a pointer to an object-oriented
+container for the data.
+
+\fn void *starpu_data_get_user_data(starpu_data_handle_t handle)
+\ingroup API_Data_Management
+This retrieves the "user_data" field previously set for the \p handle .
+
 @name Access registered data from the application
 \ingroup API_Data_Management
 

+ 3 - 0
include/starpu_data.h

@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2016  Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -141,6 +142,8 @@ unsigned starpu_data_test_if_allocated_on_node(starpu_data_handle_t handle, unsi
 
 void starpu_memchunk_tidy(unsigned memory_node);
 
+void starpu_data_set_user_data(starpu_data_handle_t handle, void* user_data);
+void *starpu_data_get_user_data(starpu_data_handle_t handle);
 
 #ifdef __cplusplus
 }

+ 6 - 1
src/datawizard/coherency.h

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
- * Copyright (C) 2014-2015  Inria
+ * Copyright (C) 2014-2016  Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -113,6 +113,7 @@ extern int _starpu_has_not_important_data;
 
 typedef void (*_starpu_data_handle_unregister_hook)(starpu_data_handle_t);
 
+/* This is initialized in both _starpu_register_new_data and _starpu_data_partition */
 struct _starpu_data_state
 {
 	int magic;
@@ -264,6 +265,10 @@ struct _starpu_data_state
 	/* Last worker that took this data in locality mode, or -1 if nobody
 	 * took it yet */
 	int last_locality;
+
+	/* A generic pointer to data in the user land (could be anything and this
+	 * is not manage by StarPU) */
+	void *user_data;
 };
 
 void _starpu_display_msi_stats(void);

+ 2 - 1
src/datawizard/filters.c

@@ -3,7 +3,7 @@
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
  * Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016  CNRS
- * Copyright (C) 2012 INRIA
+ * Copyright (C) 2012, 2016  Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -312,6 +312,7 @@ static void _starpu_data_partition(starpu_data_handle_t initial_handle, starpu_d
 		}
 
 		child->per_worker = NULL;
+		child->user_data = NULL;
 
 		/* We compute the size and the footprint of the child once and
 		 * store it in the handle */

+ 2 - 1
src/datawizard/interfaces/data_interface.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
- * Copyright (C) 2014  INRIA
+ * Copyright (C) 2014, 2016  Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -350,6 +350,7 @@ static void _starpu_register_new_data(starpu_data_handle_t handle,
 	}
 
 	handle->per_worker = NULL;
+	handle->user_data = NULL;
 
 	/* now the data is available ! */
 	_starpu_spin_unlock(&handle->header_lock);

+ 11 - 0
src/datawizard/memalloc.c

@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
+ * Copyright (C) 2016  Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -1632,3 +1633,13 @@ choose_target(starpu_data_handle_t handle, unsigned node)
 
 	return target;
 }
+
+void starpu_data_set_user_data(starpu_data_handle_t handle, void* user_data)
+{
+	handle->user_data = user_data;
+}
+
+void *starpu_data_get_user_data(starpu_data_handle_t handle)
+{
+	return handle->user_data;
+}