Przeglądaj źródła

data interface: add new parameter count to function starpu_handle_pack_data()

Nathalie Furmento 12 lat temu
rodzic
commit
1572543957

+ 8 - 5
doc/chapters/basic-api.texi

@@ -757,11 +757,14 @@ Return the unique identifier of the interface associated with the given @var{han
 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}).
+@deftypefun int starpu_handle_pack_data (starpu_data_handle_t @var{handle}, {void **}@var{ptr}, {size_t *}@var{count})
+Execute the packing operation of the interface of the data registered
+at @var{handle} (@pxref{struct starpu_data_interface_ops}). This
+packing operation must allocate a buffer large enough at @var{ptr} and
+copy into the newly allocated buffer the data associated to
+@var{handle}.
+The function also sets @var{count} to the size of the data handle by calling
+@code{starpu_handle_get_size()}.
 @end deftypefun
 
 @deftypefun int starpu_handle_unpack_data (starpu_data_handle_t @var{handle}, {void *}@var{ptr})

+ 2 - 2
include/starpu_data_interfaces.h

@@ -132,7 +132,7 @@ 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 */
+	/* Pack the data handle into a contiguous buffer at the address ptr and store the size of the buffer in count */
 	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);
@@ -434,7 +434,7 @@ 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_pack_data(starpu_data_handle_t handle, void **ptr, size_t *count);
 int starpu_handle_unpack_data(starpu_data_handle_t handle, void *ptr);
 size_t starpu_handle_get_size(starpu_data_handle_t handle);
 

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

@@ -681,9 +681,10 @@ int starpu_data_interface_get_next_id(void)
 	return _data_interface_number-1;
 }
 
-int starpu_handle_pack_data(starpu_data_handle_t handle, void **ptr)
+int starpu_handle_pack_data(starpu_data_handle_t handle, void **ptr, size_t *count)
 {
 	STARPU_ASSERT(handle->ops->pack_data);
+	*count = starpu_handle_get_size(handle);
 	return handle->ops->pack_data(handle, _starpu_get_local_memory_node(), ptr);
 }