Przeglądaj źródła

src: add hook to struct _starpu_data_state which will be called when unregistering the data

Nathalie Furmento 11 lat temu
rodzic
commit
84b8576862

+ 5 - 1
src/datawizard/coherency.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2009-2014  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) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * 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
  * it under the terms of the GNU Lesser General Public License as published by
@@ -879,3 +879,7 @@ unsigned _starpu_is_data_present_or_requested(starpu_data_handle_t handle, unsig
 	return ret;
 	return ret;
 }
 }
 
 
+void _starpu_data_set_unregister_hook(starpu_data_handle_t handle, _starpu_data_handle_unregister_hook func)
+{
+	handle->hook = func;
+}

+ 8 - 1
src/datawizard/coherency.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2009-2013  Université de Bordeaux 1
  * Copyright (C) 2009-2013  Université de Bordeaux 1
- * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * 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
  * it under the terms of the GNU Lesser General Public License as published by
@@ -100,6 +100,8 @@ struct _starpu_task_wrapper_list
 
 
 extern int _starpu_has_not_important_data;
 extern int _starpu_has_not_important_data;
 
 
+typedef void (*_starpu_data_handle_unregister_hook)(starpu_data_handle_t);
+
 struct _starpu_data_state
 struct _starpu_data_state
 {
 {
 	struct _starpu_data_requester_list *req_list;
 	struct _starpu_data_requester_list *req_list;
@@ -216,6 +218,9 @@ struct _starpu_data_state
 	_starpu_memory_stats_t memory_stats;
 	_starpu_memory_stats_t memory_stats;
 
 
 	unsigned int mf_node; //XXX
 	unsigned int mf_node; //XXX
+
+	/* hook to be called when unregistering the data */
+	_starpu_data_handle_unregister_hook hook;
 };
 };
 
 
 void _starpu_display_msi_stats(void);
 void _starpu_display_msi_stats(void);
@@ -267,4 +272,6 @@ void _starpu_data_start_reduction_mode(starpu_data_handle_t handle);
 void _starpu_data_end_reduction_mode(starpu_data_handle_t handle);
 void _starpu_data_end_reduction_mode(starpu_data_handle_t handle);
 void _starpu_data_end_reduction_mode_terminate(starpu_data_handle_t handle);
 void _starpu_data_end_reduction_mode_terminate(starpu_data_handle_t handle);
 
 
+void _starpu_data_set_unregister_hook(starpu_data_handle_t handle, _starpu_data_handle_unregister_hook func);
+
 #endif // __COHERENCY__H__
 #endif // __COHERENCY__H__

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

@@ -704,6 +704,8 @@ static void _starpu_data_unregister(starpu_data_handle_t handle, unsigned cohere
 
 
 	size_t size = _starpu_data_get_size(handle);
 	size_t size = _starpu_data_get_size(handle);
 
 
+	if (handle->hook) handle->hook(handle);
+
 	_starpu_data_free_interfaces(handle);
 	_starpu_data_free_interfaces(handle);
 
 
 	/* Destroy the data now */
 	/* Destroy the data now */