Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: 1557652 Set BF write method basing on CPU instructions set #764

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions config/m4/compiler.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# compiler.m4 - Parsing compiler capabilities
#
# Copyright (C) Mellanox Technologies Ltd. 2001-2018. ALL RIGHTS RESERVED.
# See file LICENSE for terms.
#


# Check compiler specific attributes
# Usage: CHECK_COMPILER_ATTRIBUTE([attribute], [program], [definition])
# Note:
# - [definition] can be omitted if it is equal to attribute
#
AC_DEFUN([CHECK_COMPILER_ATTRIBUTE], [
AC_CACHE_VAL(vma_cv_attribute_[$1], [
#
# Try to compile using the C compiler
#
AC_TRY_COMPILE([$2],[],
[vma_cv_attribute_$1=yes],
[vma_cv_attribute_$1=no])
AS_IF([test "x$vma_cv_attribute_$1" = "xyes"], [
AC_LANG_PUSH(C++)
AC_TRY_COMPILE([extern "C" {
$2
}],[],
[vma_cv_attribute_$1=yes],
[vma_cv_attribute_$1=no])
AC_LANG_POP(C++)
])
])

AC_MSG_CHECKING([for attribute $1])
AC_MSG_RESULT([$vma_cv_attribute_$1])
AS_IF([test "x$vma_cv_attribute_$1" = "xyes"], [
AS_IF([test "x$3" = "x"],
[AC_DEFINE_UNQUOTED([DEFINED_$1], [1], [Define to 1 if attribute $1 is supported])],
[AC_DEFINE_UNQUOTED([DEFINED_$3], [1], [Define to 1 if attribute $1 is supported])]
)
])
])



##########################
# Set compiler capabilities
#
AC_DEFUN([COMPILER_CAPABILITY_SETUP],
[

CHECK_COMPILER_ATTRIBUTE([optimize],
[int foo (int arg) __attribute__ ((optimize("O0")));],
[ATTRIBUTE_OPTIMIZE])
])
18 changes: 2 additions & 16 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ m4_include([config/m4/opt.m4])
m4_include([config/m4/verbs.m4])
m4_include([config/m4/nl.m4])
m4_include([config/m4/prof.m4])
m4_include([config/m4/compiler.m4])

FUNC_CONFIGURE_INIT()

Expand Down Expand Up @@ -163,6 +164,7 @@ case $CC in
;;
esac

COMPILER_CAPABILITY_SETUP()

dnl===-----------------------------------------------------------------------===
dnl===
Expand Down Expand Up @@ -376,22 +378,6 @@ dnl===
dnl===-----------------------------------------------------------------------===
show_section_title "Check for functions, types and structures"

# Does this compiler have built-in functions for atomic memory access?
AC_MSG_CHECKING([for atomic memory access (__sync_bool_compare_and_swap) support])
AC_TRY_LINK(,
[
int variable = 1;
return (__sync_bool_compare_and_swap(&variable, 1, 2)
&& __sync_add_and_fetch(&variable, 1)) ? 1 : 0;
],
[
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() a.o.])
],
[
AC_MSG_RESULT([no])
])

AC_MSG_CHECKING([for SOF_TIMESTAMPING_SOFTWARE support])
AC_TRY_LINK(
#include <linux/net_tstamp.h>
Expand Down
3 changes: 2 additions & 1 deletion src/utils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ libutils_la_SOURCES = \
clock.h \
lock_wrapper.h \
rdtsc.h \
types.h
types.h \
compiler.h

noinst_PROGRAMS = timetest
timetest_LDADD = -lrt libutils.la
Expand Down
22 changes: 0 additions & 22 deletions src/utils/asm-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,12 @@
#include <stdint.h>
#include <unistd.h>

#define COPY_64B_NT(dst, src) \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++

#define mb() asm volatile("dsb sy" ::: "memory")
#define rmb() asm volatile("dsb ld" ::: "memory")
#define wmb() asm volatile("dsb st" ::: "memory")
#define wc_wmb() wmb()

/**
* Add to the atomic variable.
* @param i integer value to add.
* @param v pointer of type atomic_t.
* @return Value before add.
*/
static inline int atomic_fetch_and_add(int i, volatile int *ptr)
{
return __atomic_fetch_add(ptr, i, __ATOMIC_ACQUIRE);
}

/**
* Read RDTSC register
*/
Expand Down Expand Up @@ -94,6 +74,4 @@ static inline void prefetch_range(void *addr, size_t len)
prefetch(cp);
}



#endif
26 changes: 0 additions & 26 deletions src/utils/asm-ppc64.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,12 @@
#include <stdint.h>
#include <unistd.h>

#define COPY_64B_NT(dst, src) \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++; \
*dst++ = *src++

#define mb() asm volatile("sync" ::: "memory")
#define rmb() asm volatile("lwsync" ::: "memory")
#define wmb() rmb()
#define wc_wmb() mb()

/**
* Add to the atomic variable.
* @param i integer value to add.
* @param v pointer of type atomic_t.
* @return Value before add.
*/
static inline int atomic_fetch_and_add(int i, volatile int *ptr)
{
#ifdef __ATOMIC_ACQUIRE
return __atomic_fetch_add(ptr, i, __ATOMIC_ACQUIRE);
#else
return __sync_fetch_and_add(ptr, i);
#endif
}


/**
* Read RDTSC register
Expand Down Expand Up @@ -97,6 +73,4 @@ static inline void prefetch_range(void *addr, size_t len)
prefetch(cp);
}



#endif
Loading