Ver código fonte

data interface: update the prototype of the function pack_data to be able to return a negative value for the size

Pack the data handle into a contiguous buffer at the address ptr and
set the size of the newly created buffer in count. If ptr is NULL, the
function should not copy the data in the buffer but just set count to
the size of the buffer which would have been allocated. The special value
-1 indicates the size is yet unknown.
Nathalie Furmento 12 anos atrás
pai
commit
94cd5e98eb

+ 7 - 2
doc/chapters/advanced-api.texi

@@ -332,8 +332,13 @@ 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, unsigned node, void **ptr, size_t *count)}
-Pack the data handle into a contiguous buffer at the address @code{ptr} and set the size of the newly created buffer in @code{count}
+@item @code{int (*pack_data)(starpu_data_handle_t handle, unsigned node, void **ptr, ssize_t *count)}
+Pack the data handle into a contiguous buffer at the address
+@code{ptr} and set the size of the newly created buffer in
+@code{count}. If @var{ptr} is @code{NULL}, the function should not copy the data in the
+buffer but just set @var{count} to the size of the buffer which
+would have been allocated. The special value @code{-1} indicates the
+size is yet unknown.
 
 @item @code{int (*unpack_data)(starpu_data_handle_t handle, unsigned node, void *ptr, size_t count)}
 Unpack the data handle from the contiguous buffer at the address @code{ptr} of size @var{count}

+ 7 - 4
doc/chapters/basic-api.texi

@@ -782,14 +782,17 @@ 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}, {size_t *}@var{count})
+@deftypefun int starpu_handle_pack_data (starpu_data_handle_t @var{handle}, {void **}@var{ptr}, {ssize_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()}.
+@var{handle}. @var{count} will be set to the size of the allocated
+buffer.
+If @var{ptr} is @code{NULL}, the function should not copy the data in the
+buffer but just set @var{count} to the size of the buffer which
+would have been allocated. The special value @code{-1} indicates the
+size is yet unknown.
 @end deftypefun
 
 @deftypefun int starpu_handle_unpack_data (starpu_data_handle_t @var{handle}, {void *}@var{ptr}, size_t @var{count})

+ 1 - 1
doc/chapters/mpi-support.texi

@@ -179,7 +179,7 @@ handle.
 
 @cartouche
 @smallexample
-static int complex_pack_data(starpu_data_handle_t handle, unsigned node, void **ptr, size_t *count)
+static int complex_pack_data(starpu_data_handle_t handle, unsigned node, void **ptr, ssize_t *count)
 @{
   STARPU_ASSERT(starpu_data_test_if_allocated_on_node(handle, node));
 

+ 1 - 1
examples/interface/complex_interface.c

@@ -118,7 +118,7 @@ static void *complex_handle_to_pointer(starpu_data_handle_t handle, unsigned nod
 	return (void*) complex_interface->real;
 }
 
-static int complex_pack_data(starpu_data_handle_t handle, unsigned node, void **ptr, size_t *count)
+static int complex_pack_data(starpu_data_handle_t handle, unsigned node, void **ptr, ssize_t *count)
 {
 	STARPU_ASSERT(starpu_data_test_if_allocated_on_node(handle, node));
 

+ 2 - 2
include/starpu_data_interfaces.h

@@ -124,7 +124,7 @@ struct starpu_data_interface_ops
 	struct starpu_multiformat_data_interface_ops* (*get_mf_ops)(void *data_interface);
 
 	/* 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, unsigned node, void **ptr, size_t *count);
+	int (*pack_data)(starpu_data_handle_t handle, unsigned node, void **ptr, ssize_t *count);
 	/* Unpack the data handle from the contiguous buffer at the address ptr */
 	int (*unpack_data)(starpu_data_handle_t handle, unsigned node, void *ptr, size_t count);
 };
@@ -422,7 +422,7 @@ void starpu_multiformat_data_register(starpu_data_handle_t *handle, unsigned 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, size_t *count);
+int starpu_handle_pack_data(starpu_data_handle_t handle, void **ptr, ssize_t *count);
 int starpu_handle_unpack_data(starpu_data_handle_t handle, void *ptr, size_t count);
 size_t starpu_handle_get_size(starpu_data_handle_t handle);
 

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

@@ -648,7 +648,7 @@ 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, size_t *count)
+int starpu_handle_pack_data(starpu_data_handle_t handle, void **ptr, ssize_t *count)
 {
 	STARPU_ASSERT(handle->ops->pack_data);
 	return handle->ops->pack_data(handle, _starpu_memory_node_get_local_key(), ptr, count);