Ping. I think we agreed to merge this and potentially add some more common C lib calls in the future.
Here's some cycle count measurements from x86 with DPDK. Compiled with -O2 -mavx2, so that GCC knows about AVX2 and memcpy could use the same vector instructions that DPDK uses (== best case results for memcpy). Code warms up caches before measuring and repeats each data len 6 times. Generally rte_memcpy is at least 20% faster. -Petri len memcpy rte_memcpy 256 232 156 88 88 88 88 148 72 68 72 72 68 512 208 104 104 104 104 104 136 112 80 80 80 80 768 156 120 120 116 120 120 192 116 92 92 88 88 1024 224 136 132 136 136 136 136 100 100 100 96 100 1280 184 168 152 152 152 152 136 112 104 104 108 104 1536 200 168 164 164 168 168 156 152 136 140 140 140 1792 208 212 184 184 180 180 160 132 124 124 120 120 2048 220 212 204 204 200 200 148 144 128 128 132 128 2304 252 228 220 216 216 212 152 144 136 140 136 136 2560 272 240 232 232 228 232 164 144 148 144 144 148 2816 280 256 248 248 248 248 164 164 152 152 152 156 3072 296 272 264 264 268 264 188 172 160 160 164 164 3328 312 288 284 280 284 280 180 176 168 168 172 168 3584 324 304 300 300 296 296 180 184 176 176 176 176 3840 340 320 320 316 316 316 208 188 184 188 184 188 4096 348 348 332 332 332 332 204 204 192 196 196 192 > -----Original Message----- > From: EXT Jerin Jacob [mailto:[email protected]] > Sent: Monday, October 19, 2015 1:35 PM > To: Savolainen, Petri (Nokia - FI/Espoo) > Cc: [email protected] > Subject: Re: [lng-odp] [API-NEXT PATCH] api: clib: added standard c library > api > > On Fri, Oct 16, 2015 at 03:13:48PM +0300, Petri Savolainen wrote: > > Some C library calls are often used in data plane code. This > > API enables possibility to HW optimized implementation of those. > > Added first memcpy and memset. > > > > Signed-off-by: Petri Savolainen <[email protected]> > > Reviewed-by: Jerin Jacob <[email protected]> > > > --- > > include/odp.h | 1 + > > include/odp/api/std_clib.h | 64 > +++++++++++++++++++++++++++ > > platform/linux-generic/Makefile.am | 2 + > > platform/linux-generic/include/odp/std_clib.h | 30 +++++++++++++ > > 4 files changed, 97 insertions(+) > > create mode 100644 include/odp/api/std_clib.h > > create mode 100644 platform/linux-generic/include/odp/std_clib.h > > > > diff --git a/include/odp.h b/include/odp.h > > index 825c7e1..f2cd2d3 100644 > > --- a/include/odp.h > > +++ b/include/odp.h > > @@ -56,6 +56,7 @@ extern "C" { > > #include <odp/thrmask.h> > > #include <odp/spinlock_recursive.h> > > #include <odp/rwlock_recursive.h> > > +#include <odp/std_clib.h> > > > > #ifdef __cplusplus > > } > > diff --git a/include/odp/api/std_clib.h b/include/odp/api/std_clib.h > > new file mode 100644 > > index 0000000..2119ec4 > > --- /dev/null > > +++ b/include/odp/api/std_clib.h > > @@ -0,0 +1,64 @@ > > +/* Copyright (c) 2015, Linaro Limited > > + * All rights reserved. > > + * > > + * SPDX-License-Identifier: BSD-3-Clause > > + */ > > + > > +/** > > + * @file > > + * > > + * ODP version of often used C library calls > > + */ > > + > > +#ifndef ODP_API_STD_CLIB_H_ > > +#define ODP_API_STD_CLIB_H_ > > + > > +#ifdef __cplusplus > > +extern "C" { > > +#endif > > + > > +/** > > + * @defgroup odp_std_clib ODP STD CLIB > > + * @details > > + * ODP version of often used C library calls > > + * @{ > > + */ > > + > > +/** > > + * Memcpy > > + * > > + * ODP version of C library memcpy function. It copies 'num' bytes from > source > > + * to destination address. Source and destination memory blocks must not > > + * overlap. > > + * > > + * @param dst Pointer to destination memory block > > + * @param src Pointer to source memory block > > + * @param num Number of bytes to copy > > + * > > + * @return 'dst' address > > + */ > > +void *odp_memcpy(void *dst, const void *src, size_t num); > > + > > +/** > > + * Memset > > + * > > + * ODP version of C library memset function. It sets 'value' to first > 'num' > > + * bytes of memory block pointed by 'ptr'. > > + * > > + * @param ptr Pointer to the memory block > > + * @param value Value to be set > > + * @param num Number of bytes to set > > + * > > + * @return 'ptr' address > > + */ > > +void *odp_memset(void *ptr, int value, size_t num); > > + > > +/** > > + * @} > > + */ > > + > > +#ifdef __cplusplus > > +} > > +#endif > > + > > +#endif > > diff --git a/platform/linux-generic/Makefile.am b/platform/linux- > generic/Makefile.am > > index 85c976d..fc202cc 100644 > > --- a/platform/linux-generic/Makefile.am > > +++ b/platform/linux-generic/Makefile.am > > @@ -41,6 +41,7 @@ odpinclude_HEADERS = \ > > $(srcdir)/include/odp/shared_memory.h \ > > $(srcdir)/include/odp/spinlock.h \ > > $(srcdir)/include/odp/spinlock_recursive.h \ > > + $(srcdir)/include/odp/std_clib.h \ > > $(srcdir)/include/odp/std_types.h \ > > $(srcdir)/include/odp/sync.h \ > > $(srcdir)/include/odp/system_info.h \ > > @@ -108,6 +109,7 @@ odpapiinclude_HEADERS = \ > > $(top_srcdir)/include/odp/api/shared_memory.h \ > > $(top_srcdir)/include/odp/api/spinlock.h \ > > $(top_srcdir)/include/odp/api/spinlock_recursive.h \ > > + $(top_srcdir)/include/odp/api/std_clib.h \ > > $(top_srcdir)/include/odp/api/std_types.h \ > > $(top_srcdir)/include/odp/api/sync.h \ > > $(top_srcdir)/include/odp/api/system_info.h \ > > diff --git a/platform/linux-generic/include/odp/std_clib.h > b/platform/linux-generic/include/odp/std_clib.h > > new file mode 100644 > > index 0000000..c939c48 > > --- /dev/null > > +++ b/platform/linux-generic/include/odp/std_clib.h > > @@ -0,0 +1,30 @@ > > +/* Copyright (c) 2015, Linaro Limited > > + * All rights reserved. > > + * > > + * SPDX-License-Identifier: BSD-3-Clause > > + */ > > + > > +#ifndef ODP_PLAT_STD_CLIB_H_ > > +#define ODP_PLAT_STD_CLIB_H_ > > + > > +#ifdef __cplusplus > > +extern "C" { > > +#endif > > + > > +#include <odp/api/std_types.h> > > + > > +static inline void *odp_memcpy(void *dst, const void *src, size_t num) > > +{ > > + return memcpy(dst, src, num); > > +} > > + > > +static inline void *odp_memset(void *ptr, int value, size_t num) > > +{ > > + return memset(ptr, value, num); > > +} > > + > > +#ifdef __cplusplus > > +} > > +#endif > > + > > +#endif > > -- > > 2.6.0 > > > > _______________________________________________ > > lng-odp mailing list > > [email protected] > > https://lists.linaro.org/mailman/listinfo/lng-odp _______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
