nm_data.h
Go to the documentation of this file.
214EXTERN_C void nm_data_properties_gpu_fill(struct nm_data_properties_s*p_props, const void*p_ptr);
270static inline void nm_datav_add_chunk_data(struct nm_datav_s*p_datav, const struct nm_data_s*p_data);
276static inline void nm_datav_add_chunk_excerpt(struct nm_datav_s*p_datav, struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len);
289static inline void nm_data_op_apply(void*__restrict__ p_ptr, nm_len_t len, struct nm_data_op_s*__restrict__ p_op);
290static 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);
291static 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);
292static 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);
293static 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);
294static 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);
295static 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);
296static 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);
412 NM_DATA_OP_APPLY_KIND_VECT(I, copy_from, blocks_done, op_blocks, (PTR), (LEN), p_chunk->p_op); \
459 NM_DATA_OP_APPLY_KIND_LEN(I, nop, blocks_done, slice_blocks, (PTR), (LEN), &p_slicer->coroutine.op); \
462 NM_DATA_OP_APPLY_KIND_VECT(I, copy_from, blocks_done, slice_blocks, (PTR), (LEN), &p_slicer->coroutine.op); \
644static inline void nm_data_traversal_op_apply(const struct nm_data_s*p_data, struct nm_data_op_s*p_op)
652static inline void nm_data_traversal_apply(const struct nm_data_s*p_data, nm_data_apply_t p_apply, void*_context)
661void nm_data_chunk_extractor_op_traversal(const struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len,
664void nm_data_chunk_extractor_traversal(const struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len,
668static inline const struct nm_data_properties_s*nm_data_properties_get(const struct nm_data_s*p_data)
684void*nm_data_chunk_baseptr_get(const struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len);
687void nm_data_chunk_properties_compute(const struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len,
691nm_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);
697void nm_data_copy_from(const struct nm_data_s*p_data, nm_len_t offset, nm_len_t len, void*destbuf);
700void nm_data_copy_to(const struct nm_data_s*p_data, nm_len_t offset, nm_len_t len, const void*srcbuf);
735typedef void (*nm_data_coroutine_worker_t)(struct nm_data_coroutine_s*p_coroutine, void*_user_data);
742 };
833static inline void nm_datav_add_chunk_data(struct nm_datav_s*p_datav, const struct nm_data_s*p_data)
840 p_datav->p_data = (struct nm_data_s*)padico_malloc(p_datav->allocated * sizeof(struct nm_data_s));
861static inline void nm_datav_add_chunk_excerpt(struct nm_datav_s*p_datav, struct nm_data_s*p_data, nm_len_t chunk_offset, nm_len_t chunk_len)
887static inline void nm_data_propertie_gpu_preinit(struct nm_data_properties_s*p_props __attribute__((unused)))
897static inline void nm_data_propertie_gpu_postinit(const struct nm_data_properties_s*p_props __attribute__((unused)))
902 NM_FATAL("incorrect data properties: is_cuda = %d (should be either 0 or 1)\n", p_props->is_cuda);
908 NM_FATAL("incorrect data properties: is_hip = %d (should be either 0 or 1)\n", p_props->is_hip);
918static 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)
952static 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)
984static 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)
989static 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)
995static 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)
1001static 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)
1006static 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)
1024static 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)
1030 (!(p_chunk->done >= p_chunk->chunk_offset + p_chunk->chunk_len))) /* data after chunk- do nothing */
1033 const nm_len_t block_offset = (p_chunk->done < chunk_offset) ? (chunk_offset - p_chunk->done) : 0;
1041static 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)
1069static 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:181
static void nm_datav_add_chunk_excerpt(struct nm_datav_s *p_datav, struct nm_data_s *p_data, nm_len_t chunk_offset, nm_len_t chunk_len)
add an excerpt of data to datav; given p_data content is not copied.
Definition nm_data.h:861
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:879
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:868
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:854
EXTERN_C 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'
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:90
void(* nm_data_properties_compute_t)(struct nm_data_s *p_data)
function to compute data properties
Definition nm_data.h:184
#define NM_DATA_TYPE(ENAME, CONTENT_TYPE, OPS)
macro to generate typed functions to init/access data fields.
Definition nm_data.h:223
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:833
EXTERN_C void nm_data_default_properties_compute(struct nm_data_s *p_data)
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:674
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
void nm_data_dump(struct nm_data_s *p_data, const char *label)
dump data content for debug
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:644
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:652
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:668
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:795
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:735
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:743
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:766
@ NM_DATA_COROUTINE_LONGJMP
longjmp-based coroutine, when stack jumping is possible with longjmp
Definition nm_data.h:741
@ NM_DATA_COROUTINE_UCONTEXT
ucontext-based coroutines, when stack jumping is not available through longjmp
Definition nm_data.h:740
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:989
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:561
static void nm_data_iov_build(struct nm_data_s *p_data, const struct iovec *v, int n)
Definition nm_data.h:580
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:995
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:599
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:1001
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:984
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:1041
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:952
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:621
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:918
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:1069
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:1024
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:1006
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
This is the common public header for NewMad.
Definition nm_data.h:746
struct nm_data_coroutine_ucontext_s * p_ucontext
Definition nm_data.h:750
struct nm_data_coroutine_longjmp_s * p_longjmp
Definition nm_data.h:751
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:592
Definition nm_data.h:149
Definition nm_data.h:125
Definition nm_data.h:131
Definition nm_data.h:137
Definition nm_data.h:143
Definition nm_data.h:120
struct nm_data_slicer_s * p_slicer
Definition nm_data.h:158
Definition nm_data.h:162
union nm_data_op_s::@20 context
struct nm_data_op_context_slicer_coroutine_s slicer_coroutine
Definition nm_data.h:172
nm_data_properties_compute_t p_properties_compute
optimized function to compute data properties (optionnal)
Definition nm_data.h:191
nm_data_traversal_t p_traversal
operation to apply a given function to all chunks of data (required)
Definition nm_data.h:190
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:97
a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers
Definition nm_data.h:200
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:256