DPDK contains the line: #define rte_memcpy(d, s, n) memcpy((d), (s), (n))
All of the other definitions in rte_memcpy.h for the various "optimized" moves do the same. So I'm not sure what's the point here. It's not as if these functions aren't already heavily optimized by C compilers. On Fri, Oct 16, 2015 at 7:22 AM, Savolainen, Petri (Nokia - FI/Espoo) < [email protected]> wrote: > If that’s the case an platform can implement these without extra effort. > But when that’s not the case, an implementation can use whatever special > instructions, vector engines or DMA HW it has to speed up these calls. See > e.g. rte_memcpy in DPDK - it’s not just plain memcpy wrapper (they must > have had a reason for optimizing it). > > > > -Petri > > > > *From:* EXT Bill Fischofer [mailto:[email protected]] > *Sent:* Friday, October 16, 2015 3:17 PM > *To:* Savolainen, Petri (Nokia - FI/Espoo) > *Cc:* LNG ODP Mailman List > *Subject:* Re: [lng-odp] [API-NEXT PATCH] api: clib: added standard c > library api > > > > Why would you not expect a platform to provide an optimized implementation > of these stdlib functions itself? GCC, in particular, seems to do a good > job of this for most platforms. > > > > On Fri, Oct 16, 2015 at 7:13 AM, Petri Savolainen < > [email protected]> 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]> > --- > 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
