Przeglądaj źródła

Data interface: define new functions to pack and unpack data handles

 New public functions
   int starpu_handle_pack_data(starpu_data_handle_t handle, void **ptr);
   int starpu_handle_unpack_data(starpu_data_handle_t handle, void *ptr);
   size_t starpu_handle_get_size(starpu_data_handle_t handle);

 New fields in struct starpu_data_interface_ops
    int (*pack_data)(starpu_data_handle_t handle, uint32_t node, void **ptr);
    int (*unpack_data)(starpu_data_handle_t handle, uint32_t node, void *ptr);
Nathalie Furmento 13 lat temu
rodzic
commit
29a60d5852

+ 12 - 0
doc/chapters/advanced-api.texi

@@ -69,6 +69,18 @@ An identifier that is unique to each interface.
 @item @code{size_t interface_size}
 The size of the interface data descriptor.
 
+@item @code{int is_multiformat}
+todo
+
+@item @code{struct starpu_multiformat_data_interface_ops* (*get_mf_ops)(void *data_interface)}
+todo
+
+@item @code{int (*pack_data)(starpu_data_handle_t handle, uint32_t node, void **ptr)}
+Pack the data handle into a contiguous buffer at the address @code{ptr}
+
+@item @code{int (*unpack_data)(starpu_data_handle_t handle, uint32_t node, void *ptr)}
+Unpack the data handle from the contiguous buffer at the address @code{ptr}
+
 @end table
 @end deftp
 

+ 17 - 0
doc/chapters/basic-api.texi

@@ -703,6 +703,23 @@ if @var{handle}'s interface does not have data allocated locally
 Return the unique identifier of the interface associated with the given @var{handle}.
 @end deftypefun
 
+@deftypefun size_t starpu_handle_get_size (starpu_data_handle_t @var{handle})
+Return the size of the data associated with @var{handle}
+@end deftypefun
+
+@deftypefun int starpu_handle_pack_data (starpu_data_handle_t @var{handle}, {void **}@var{ptr})
+Allocates a buffer large enough at @var{ptr} and copy to the newly
+allocated buffer the data associated to @var{handle}. The interface of
+the data registered at @var{handle} must define a packing operation
+(@pxref{struct starpu_data_interface_ops}).
+@end deftypefun
+
+@deftypefun int starpu_handle_unpack_data (starpu_data_handle_t @var{handle}, {void *}@var{ptr})
+Copy in @var{handle} the data located at @var{ptr} as described by the
+interface of the data. The interface registered at @var{handle} must
+define a unpacking operation (@pxref{struct starpu_data_interface_ops}).
+@end deftypefun
+
 @node Accessing Variable Data Interfaces
 @subsubsection Variable Data Interfaces
 

+ 10 - 1
include/starpu_data_interfaces.h

@@ -123,7 +123,7 @@ struct starpu_data_interface_ops
 	void (*display)(starpu_data_handle_t handle, FILE *f);
 #ifdef STARPU_USE_GORDON
 	/* Convert the data size to the spu size format */
-	int (*convert_to_gordon)(void *data_interface, uint64_t *ptr, gordon_strideSize_t *ss); 
+	int (*convert_to_gordon)(void *data_interface, uint64_t *ptr, gordon_strideSize_t *ss);
 #endif
 	/* an identifier that is unique to each interface */
 	enum starpu_data_interface_id interfaceid;
@@ -132,6 +132,11 @@ struct starpu_data_interface_ops
 
 	int is_multiformat;
 	struct starpu_multiformat_data_interface_ops* (*get_mf_ops)(void *data_interface);
+
+	/* Pack the data handle into a contiguous buffer at the address ptr */
+	int (*pack_data)(starpu_data_handle_t handle, uint32_t node, void **ptr);
+	/* Unpack the data handle from the contiguous buffer at the address ptr */
+	int (*unpack_data)(starpu_data_handle_t handle, uint32_t node, void *ptr);
 };
 
 /* Return the next available id for a data interface */
@@ -376,6 +381,10 @@ void starpu_multiformat_data_register(starpu_data_handle_t *handle, uint32_t hom
 
 enum starpu_data_interface_id starpu_handle_get_interface_id(starpu_data_handle_t handle);
 
+int starpu_handle_pack_data(starpu_data_handle_t handle, void **ptr);
+int starpu_handle_unpack_data(starpu_data_handle_t handle, void *ptr);
+size_t starpu_handle_get_size(starpu_data_handle_t handle);
+
 /* Lookup a ram pointer into a StarPU handle */
 extern starpu_data_handle_t starpu_data_lookup(const void *ptr);
 

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

@@ -654,3 +654,20 @@ int starpu_data_interface_get_next_id()
 	_data_interface_number += 1;
 	return _data_interface_number-1;
 }
+
+int starpu_handle_pack_data(starpu_data_handle_t handle, void **ptr)
+{
+	STARPU_ASSERT(handle->ops->pack_data);
+	return handle->ops->pack_data(handle, _starpu_get_local_memory_node(), ptr);
+}
+
+int starpu_handle_unpack_data(starpu_data_handle_t handle, void *ptr)
+{
+	STARPU_ASSERT(handle->ops->unpack_data);
+	return handle->ops->unpack_data(handle, _starpu_get_local_memory_node(), ptr);
+}
+
+size_t starpu_handle_get_size(starpu_data_handle_t handle)
+{
+	return handle->ops->get_size(handle);
+}