Add cmake option to disable AVX

This commit is contained in:
Russell Sears 2020-05-01 13:37:29 -07:00
parent e77f9701f3
commit 11f658cfe2
3 changed files with 20 additions and 7 deletions

View File

@ -243,6 +243,12 @@ else()
-Wno-tautological-pointer-compare
-Wno-format
-Woverloaded-virtual)
set(USE_AVX ON CACHE BOOL "Enable AVX instructions")
if (USE_AVX)
add_compile_options(-mavx)
else()
add_compile_options(-msse4)
endif()
if (USE_CCACHE)
add_compile_options(
-Wno-register
@ -254,7 +260,12 @@ else()
endif()
if (GCC)
add_compile_options(-Wno-pragmas)
add_compile_options(-mavx)
set(USE_AVX ON CACHE BOOL "Enable AVX instructions")
if (USE_AVX)
add_compile_options(-mavx)
else()
add_compile_options(-msse4)
endif()
# Intentionally using builtin memcpy. G++ does a good job on small memcpy's when the size is known at runtime.
# If the size is not known, then it falls back on the memcpy that's available at runtime (rte_memcpy, as of this
# writing; see flow.cpp).

View File

@ -50,8 +50,10 @@ extern "C" {
static force_inline void *
rte_memcpy(void *dst, const void *src, size_t n);
//#define RTE_MACHINE_CPUFLAG_AVX512F
#ifdef __AVX__
//#define RTE_MACHINE_CPUFLAG_AVX512F -- our g++ is too old for this
#define RTE_MACHINE_CPUFLAG_AVX2
#endif
#ifdef RTE_MACHINE_CPUFLAG_AVX512F

View File

@ -58,16 +58,16 @@ test_single_memcpy(unsigned int off_src, unsigned int off_dst, size_t size)
}
/* Do the copy */
ret = rte_memcpy(dest + off_dst, src + off_src, size);
ret = memcpy(dest + off_dst, src + off_src, size);
if (ret != (dest + off_dst)) {
printf("rte_memcpy() returned %p, not %p\n",
printf("memcpy() returned %p, not %p\n",
ret, dest + off_dst);
}
/* Check nothing before offset is affected */
for (i = 0; i < off_dst; i++) {
if (dest[i] != 0) {
printf("rte_memcpy() failed for %u bytes (offsets=%u,%u): "
printf("memcpy() failed for %u bytes (offsets=%u,%u): "
"[modified before start of dst].\n",
(unsigned)size, off_src, off_dst);
return -1;
@ -77,7 +77,7 @@ test_single_memcpy(unsigned int off_src, unsigned int off_dst, size_t size)
/* Check everything was copied */
for (i = 0; i < size; i++) {
if (dest[i + off_dst] != src[i + off_src]) {
printf("rte_memcpy() failed for %u bytes (offsets=%u,%u): "
printf("memcpy() failed for %u bytes (offsets=%u,%u): "
"[didn't copy byte %u].\n",
(unsigned)size, off_src, off_dst, i);
return -1;
@ -87,7 +87,7 @@ test_single_memcpy(unsigned int off_src, unsigned int off_dst, size_t size)
/* Check nothing after copy was affected */
for (i = size; i < SMALL_BUFFER_SIZE; i++) {
if (dest[i + off_dst] != 0) {
printf("rte_memcpy() failed for %u bytes (offsets=%u,%u): "
printf("memcpy() failed for %u bytes (offsets=%u,%u): "
"[copied too many].\n",
(unsigned)size, off_src, off_dst);
return -1;