nm_data.h
Go to the documentation of this file.
267static inline void nm_datav_add_chunk_data(struct nm_datav_s*p_datav, const struct nm_data_s*p_data);
280static inline void nm_data_op_apply(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_s*__restrict__ p_op);
281static inline void nm_data_op_apply_nop(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_nop_s*__restrict__ p_nop);
282static inline void nm_data_op_apply_copy_from(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_copy_from_s*__restrict__ p_copy_from);
283static inline void nm_data_op_apply_copy_to(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_copy_to_s*__restrict__ p_copy_to);
284static inline void nm_data_op_apply_dynamic(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_dynamic_s*__restrict__ p_dynamic);
285static inline void nm_data_op_apply_getprops(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_getprops_s*__restrict__ p_getprops);
286static inline void nm_data_op_apply_chunk(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_chunk_s*__restrict__ p_chunk);
287static inline void nm_data_op_apply_slicer_coroutine(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_slicer_coroutine_s*__restrict__ p_slicer_coroutine);
403 NM_DATA_OP_APPLY_KIND_VECT(I, copy_from, blocks_done, op_blocks, (PTR), (LEN), p_chunk->p_op); \
450 NM_DATA_OP_APPLY_KIND_LEN(I, nop, blocks_done, slice_blocks, (PTR), (LEN), &p_slicer->coroutine.op); \
453 NM_DATA_OP_APPLY_KIND_VECT(I, copy_from, blocks_done, slice_blocks, (PTR), (LEN), &p_slicer->coroutine.op); \
635static inline void nm_data_traversal_op_apply(const struct nm_data_s*p_data, struct nm_data_op_s*p_op)
643static inline void nm_data_traversal_apply(const struct nm_data_s*p_data, nm_data_apply_t p_apply, void*_context)
652void nm_data_chunk_extractor_op_traversal(const struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len,
655void nm_data_chunk_extractor_traversal(const struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len,
659static inline const struct nm_data_properties_s*nm_data_properties_get(const struct nm_data_s*p_data)
675void*nm_data_chunk_baseptr_get(const struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len);
678void nm_data_chunk_properties_compute(const struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len,
682nm_len_t nm_data_chunk_first_get(const struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len, int n);
688void nm_data_copy_from(const struct nm_data_s*p_data, nm_len_t offset, nm_len_t len, void*destbuf);
691void nm_data_copy_to(const struct nm_data_s*p_data, nm_len_t offset, nm_len_t len, const void*srcbuf);
723typedef void (*nm_data_coroutine_worker_t)(struct nm_data_coroutine_s*p_coroutine, void*_user_data);
730 };
821static inline void nm_datav_add_chunk_data(struct nm_datav_s*p_datav, const struct nm_data_s*p_data)
828 p_datav->p_data = (struct nm_data_s*)padico_malloc(p_datav->allocated * sizeof(struct nm_data_s));
868static inline void nm_data_propertie_gpu_preinit(struct nm_data_properties_s*p_props __attribute__((unused)))
878static inline void nm_data_propertie_gpu_postinit(const struct nm_data_properties_s*p_props __attribute__((unused)))
883 NM_FATAL("incorrect data properties: is_cuda = %d (should be either 0 or 1)\n", p_props->is_cuda);
889 NM_FATAL("incorrect data properties: is_hip = %d (should be either 0 or 1)\n", p_props->is_hip);
899static inline void nm_data_memcpy_from(void*p_dest, const void*p_src, nm_len_t len, const struct nm_data_properties_s*p_props)
933static inline void nm_data_memcpy_to(void*p_dest, const void*p_src, nm_len_t len, const struct nm_data_properties_s*p_props)
966static inline void nm_data_op_apply_nop(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_nop_s*__restrict__ p_nop)
971static inline void nm_data_op_apply_copy_from(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_copy_from_s*__restrict__ p_copy_from)
977static inline void nm_data_op_apply_copy_to(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_copy_to_s*__restrict__ p_copy_to)
983static inline void nm_data_op_apply_dynamic(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_dynamic_s*__restrict__ p_dynamic)
988static inline void nm_data_op_apply_getprops(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_getprops_s*__restrict__ p_getprops)
1006static inline void nm_data_op_apply_chunk(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_chunk_s*__restrict__ p_chunk)
1012 (!(p_chunk->done >= p_chunk->chunk_offset + p_chunk->chunk_len))) /* data after chunk- do nothing */
1015 const nm_len_t block_offset = (p_chunk->done < chunk_offset) ? (chunk_offset - p_chunk->done) : 0;
1023static inline void nm_data_op_apply_slicer_coroutine(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_slicer_coroutine_s*__restrict__ p_slicer_coroutine)
1051static inline void nm_data_op_apply(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_s*__restrict__ p_op)
struct nm_data_contiguous_s __attribute__
void(* nm_data_traversal_t)(const void *_data_content, struct nm_data_op_s *p_op)
funtion to traverse data with app layout, i.e.
Definition nm_data.h:180
static void nm_datav_uncommit(struct nm_datav_s *p_datav)
'uncommit' a datav: explicitely declare that nm_data pointing to this datav has been destroyed.
Definition nm_data.h:860
static void nm_data_propertie_gpu_preinit(struct nm_data_properties_s *p_props)
pre-init GPU part of data properties
static nm_len_t nm_datav_size(struct nm_datav_s *p_datav)
get the size (number of bytes) of data contained in the datav
Definition nm_data.h:849
void nm_data_properties_gpu_fill(struct nm_data_properties_s *p_props, const void *p_ptr)
fill in the GPU part of data properties, following pointer 'p_ptr'
static void nm_datav_add_chunk(struct nm_datav_s *p_datav, const void *ptr, nm_len_t len)
add a chunk of contiguous data to a datav
Definition nm_data.h:842
void(* nm_data_apply_t)(void *ptr, nm_len_t len, void *_context)
function to apply to each data chunk upon traversal
Definition nm_data.h:89
void(* nm_data_properties_compute_t)(struct nm_data_s *p_data)
function to compute data properties
Definition nm_data.h:183
#define NM_DATA_TYPE(ENAME, CONTENT_TYPE, OPS)
macro to generate typed functions to init/access data fields.
Definition nm_data.h:222
void nm_data_default_properties_compute(struct nm_data_s *p_data)
static void nm_data_propertie_gpu_postinit(const struct nm_data_properties_s *p_props)
post-init GPU part of data properties: check that p_properties_compute function actually filled the G...
static void nm_datav_add_chunk_data(struct nm_datav_s *p_datav, const struct nm_data_s *p_data)
add a chunk of data to datav; given p_data content is copied.
Definition nm_data.h:821
void nm_data_chunk_extractor_op_traversal(const struct nm_data_s *p_data, nm_len_t chunk_offset, nm_len_t chunk_len, struct nm_data_op_s *p_op)
static nm_len_t nm_data_size(const struct nm_data_s *p_data)
returns the amount of data contained in the descriptor
Definition nm_data.h:665
void nm_data_copy(struct nm_data_s *p_dest, struct nm_data_s *p_from)
copy from nm_data to another nm_data
void nm_data_chunk_properties_compute(const struct nm_data_s *p_data, nm_len_t chunk_offset, nm_len_t chunk_len, struct nm_data_properties_s *p_props)
compute properties of the given chunk inside the data
static void nm_data_traversal_op_apply(const struct nm_data_s *p_data, struct nm_data_op_s *p_op)
Definition nm_data.h:635
static void nm_data_traversal_apply(const struct nm_data_s *p_data, nm_data_apply_t p_apply, void *_context)
helper function to apply iterator to data
Definition nm_data.h:643
void nm_data_copy_to(const struct nm_data_s *p_data, nm_len_t offset, nm_len_t len, const void *srcbuf)
copy chunk of data from contiguous buffer to user layout
void * nm_data_baseptr_get(const struct nm_data_s *p_data)
find base pointer for a data known to be contiguous
void nm_data_copy_from(const struct nm_data_s *p_data, nm_len_t offset, nm_len_t len, void *destbuf)
copy chunk of data from user layout to contiguous buffer
void nm_data_chunk_extractor_traversal(const struct nm_data_s *p_data, nm_len_t chunk_offset, nm_len_t chunk_len, nm_data_apply_t p_apply, void *p_apply_context)
nm_len_t nm_data_chunk_first_get(const struct nm_data_s *p_data, nm_len_t chunk_offset, nm_len_t chunk_len, int n)
get length of first n blocks in given chunk
static const struct nm_data_properties_s * nm_data_properties_get(const struct nm_data_s *p_data)
returns the properties block for the data
Definition nm_data.h:659
void * nm_data_chunk_baseptr_get(const struct nm_data_s *p_data, nm_len_t chunk_offset, nm_len_t chunk_len)
find base pointer for a data chunk known to be contiguous
static int nm_data_slicer_isnull(const nm_data_slicer_t *p_slicer)
tests whether a slicer is null
Definition nm_data.h:783
void nm_data_slicer_forward(nm_data_slicer_t *p_slicer, nm_len_t offset)
void nm_data_coroutine_yield_to_data(struct nm_data_coroutine_s *p_coroutine)
void nm_data_slicer_copy_to(nm_data_slicer_t *p_slicer, const void *src_ptr, nm_len_t slice_len)
void(* nm_data_coroutine_worker_t)(struct nm_data_coroutine_s *p_coroutine, void *_user_data)
Definition nm_data.h:723
void nm_data_slicer_destroy(nm_data_slicer_t *p_slicer)
void nm_data_coroutine_yield_to_caller(struct nm_data_coroutine_s *p_coroutine)
void nm_data_slicer_copy_from(nm_data_slicer_t *p_slicer, void *dest_ptr, nm_len_t slice_len)
enum nm_data_coroutine_kind_e nm_data_coroutine_kind_t
Definition nm_data.h:731
void nm_data_slicer_init(nm_data_slicer_t *p_slicer, const struct nm_data_s *p_data)
@ NM_DATA_SLICER_COROUTINE
coroutine-based slicer, using generic data traversal
Definition nm_data.h:754
@ NM_DATA_COROUTINE_LONGJMP
longjmp-based coroutine, when stack jumping is possible with longjmp
Definition nm_data.h:729
@ NM_DATA_COROUTINE_UCONTEXT
ucontext-based coroutines, when stack jumping is not available through longjmp
Definition nm_data.h:728
assert(p_data->ops.p_traversal !=NULL)
static void nm_data_op_apply_copy_from(void *__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_copy_from_s *__restrict__ p_copy_from)
Definition nm_data.h:971
const struct nm_data_ops_s nm_data_ops_excerpt
static void nm_data_contiguous_build(struct nm_data_s *p_data, void *ptr, nm_len_t len)
Definition nm_data.h:552
static void nm_data_iov_build(struct nm_data_s *p_data, const struct iovec *v, int n)
Definition nm_data.h:571
static void nm_data_op_apply_copy_to(void *__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_copy_to_s *__restrict__ p_copy_to)
Definition nm_data.h:977
static void nm_data_datav_build(struct nm_data_s *p_datav_data, struct nm_datav_s *p_datav)
frontend to build a nm_data from a datav
Definition nm_data.h:590
static void nm_data_op_apply_dynamic(void *__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_dynamic_s *__restrict__ p_dynamic)
Definition nm_data.h:983
const struct nm_data_ops_s nm_data_ops_null
static void nm_data_op_apply_nop(void *__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_nop_s *__restrict__ p_nop)
Definition nm_data.h:966
static void nm_data_op_apply_slicer_coroutine(void *__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_slicer_coroutine_s *__restrict__ p_slicer_coroutine)
Definition nm_data.h:1023
const struct nm_data_ops_s nm_data_ops_iov
static void nm_data_memcpy_to(void *p_dest, const void *p_src, nm_len_t len, const struct nm_data_properties_s *p_props)
copy chunks of data.
Definition nm_data.h:933
static void nm_data_excerpt_build(struct nm_data_s *p_data, struct nm_data_s *p_inner_data, nm_len_t chunk_offset, nm_len_t chunk_len)
build a data descriptor as an excerpt of another data.
Definition nm_data.h:612
static void nm_data_memcpy_from(void *p_dest, const void *p_src, nm_len_t len, const struct nm_data_properties_s *p_props)
copy chunks of data.
Definition nm_data.h:899
static void nm_data_op_apply(void *__restrict__ p_ptr, nm_len_t len, struct nm_data_op_s *__restrict__ p_op)
apply op on block (p_ptr, len)
Definition nm_data.h:1051
static void nm_data_op_apply_chunk(void *__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_chunk_s *__restrict__ p_chunk)
Definition nm_data.h:1006
static void nm_data_op_apply_getprops(void *__restrict__ p_ptr, nm_len_t len, struct nm_data_op_context_getprops_s *__restrict__ p_getprops)
Definition nm_data.h:988
const struct nm_data_ops_s nm_data_ops_contiguous
const struct nm_data_ops_s nm_data_ops_datav
nm_len_t size
size of the onsided data (not incuding target-side completion)
Definition nm_onesided_private.h:1
Definition nm_data.h:734
struct nm_data_coroutine_ucontext_s * p_ucontext
Definition nm_data.h:738
struct nm_data_coroutine_longjmp_s * p_longjmp
Definition nm_data.h:739
union nm_data_coroutine_s::@21 impl
data descriptor for datav in a nm_data (embedd a vector of nm_data in nm_data)
Definition nm_data.h:583
Definition nm_data.h:148
Definition nm_data.h:124
Definition nm_data.h:130
Definition nm_data.h:136
Definition nm_data.h:142
Definition nm_data.h:119
struct nm_data_slicer_s * p_slicer
Definition nm_data.h:157
Definition nm_data.h:161
union nm_data_op_s::@20 context
struct nm_data_op_context_slicer_coroutine_s slicer_coroutine
Definition nm_data.h:171
nm_data_properties_compute_t p_properties_compute
optimized function to compute data properties (optionnal)
Definition nm_data.h:190
nm_data_traversal_t p_traversal
operation to apply a given function to all chunks of data (required)
Definition nm_data.h:189
int is_contig
data is contiguous; data may be contiguous even with blocks > 1, if blocks are next to each other
Definition nm_data.h:96
a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers
Definition nm_data.h:199
struct nm_data_slicer_s::@22::@25 contig
slicer for contiguous data; no context switch
struct nm_data_s * p_data
vector of nm_data; either dynamically allocated, or points to data[0]
Definition nm_data.h:255