Message ID | 20160804193006.99010-2-brian.brooks@linaro.org |
---|---|
State | New |
Headers | show |
On 4 August 2016 at 15:30, Brian Brooks <brian.brooks@linaro.org> wrote: > Use source files in arch/default for undetected archs. This > alleviates the need to use symlinks in the source code > directory structure. > I prefer a behaviour where this fails at config time if a new ARCH appears. If you dont do this you start running with defaults and get rubbish performance or even errors and possibly crashes rather than being notified upfront to pay attention to what you are required to configure. > > Signed-off-by: Brian Brooks <brian.brooks@linaro.org> > --- > configure.ac | 13 +----- > platform/Makefile.inc | 3 -- > platform/linux-generic/arch/arm/odp/api/cpu_arch.h | 1 - > platform/linux-generic/arch/arm/odp_cpu_arch.c | 1 - > .../linux-generic/arch/arm/odp_sysinfo_parse.c | 1 - > platform/linux-generic/arch/powerpc/odp_cpu_arch.c | 49 > +++++++++++++++++++++- > 6 files changed, 49 insertions(+), 19 deletions(-) > delete mode 120000 platform/linux-generic/arch/arm/odp/api/cpu_arch.h > delete mode 120000 platform/linux-generic/arch/arm/odp_cpu_arch.c > delete mode 120000 platform/linux-generic/arch/arm/odp_sysinfo_parse.c > mode change 120000 => 100644 platform/linux-generic/arch/ > powerpc/odp_cpu_arch.c > > diff --git a/configure.ac b/configure.ac > index c0f0f21..a7e058a 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -77,22 +77,11 @@ AS_CASE([$host], > [i686*], [ARCH_DIR=x86], > [mips64*], [ARCH_DIR=mips64], > [powerpc*], [ARCH_DIR=powerpc], > - [aarch64*], [ARCH_DIR=arm], > - [arm*], [ARCH_DIR=arm], > - [ARCH_DIR=undefined] > + [ARCH_DIR=default] > ) > AC_SUBST([ARCH_DIR]) > > ############################################################ > ############## > -# Warn on the defaults if arch is undefined > -########################################################### > ############### > -if test "${ARCH_DIR}" == "undefined"; > -then > - echo "ARCH_DIR is undefined, please add your ARCH_DIR based on > host=${host}" > - exit 1 > -fi > - > -########################################################### > ############### > # Set correct pkgconfig version > ############################################################ > ############## > PKGCONFIG_VERSION=$(echo $VERSION | awk -F '.git' '{print $1}') > diff --git a/platform/Makefile.inc b/platform/Makefile.inc > index a44f88f..2a4255c 100644 > --- a/platform/Makefile.inc > +++ b/platform/Makefile.inc > @@ -62,9 +62,6 @@ odpapispecinclude_HEADERS = \ > $(top_srcdir)/include/odp/api/spec/version.h > > EXTRA_DIST = \ > - arch/arm/odp/api/cpu_arch.h \ > - arch/arm/odp_cpu_arch.c \ > - arch/arm/odp_sysinfo_parse.c \ > arch/default/odp/api/cpu_arch.h \ > arch/default/odp_cpu_arch.c \ > arch/default/odp_sysinfo_parse.c \ > diff --git a/platform/linux-generic/arch/arm/odp/api/cpu_arch.h > b/platform/linux-generic/arch/arm/odp/api/cpu_arch.h > deleted file mode 120000 > index e86e132..0000000 > --- a/platform/linux-generic/arch/arm/odp/api/cpu_arch.h > +++ /dev/null > @@ -1 +0,0 @@ > -../../../default/odp/api/cpu_arch.h > \ No newline at end of file > diff --git a/platform/linux-generic/arch/arm/odp_cpu_arch.c > b/platform/linux-generic/arch/arm/odp_cpu_arch.c > deleted file mode 120000 > index deebc47..0000000 > --- a/platform/linux-generic/arch/arm/odp_cpu_arch.c > +++ /dev/null > @@ -1 +0,0 @@ > -../default/odp_cpu_arch.c > \ No newline at end of file > diff --git a/platform/linux-generic/arch/arm/odp_sysinfo_parse.c > b/platform/linux-generic/arch/arm/odp_sysinfo_parse.c > deleted file mode 120000 > index 39962b8..0000000 > --- a/platform/linux-generic/arch/arm/odp_sysinfo_parse.c > +++ /dev/null > @@ -1 +0,0 @@ > -../default/odp_sysinfo_parse.c > \ No newline at end of file > diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > deleted file mode 120000 > index deebc47..0000000 > --- a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > +++ /dev/null > @@ -1 +0,0 @@ > -../default/odp_cpu_arch.c > \ No newline at end of file > diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > new file mode 100644 > index 0000000..2ac223e > --- /dev/null > +++ b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > @@ -0,0 +1,48 @@ > +/* Copyright (c) 2015, Linaro Limited > + * All rights reserved. > + * > + * SPDX-License-Identifier: BSD-3-Clause > + */ > + > +#include <odp_posix_extensions.h> > + > +#include <stdlib.h> > +#include <time.h> > + > +#include <odp/api/cpu.h> > +#include <odp/api/hints.h> > +#include <odp/api/system_info.h> > +#include <odp_debug_internal.h> > + > +#define GIGA 1000000000 > + > +uint64_t odp_cpu_cycles(void) > +{ > + struct timespec time; > + uint64_t sec, ns, hz, cycles; > + int ret; > + > + ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); > + > + if (ret != 0) > + ODP_ABORT("clock_gettime failed\n"); > + > + hz = odp_cpu_hz_max(); > + sec = (uint64_t)time.tv_sec; > + ns = (uint64_t)time.tv_nsec; > + > + cycles = sec * hz; > + cycles += (ns * hz) / GIGA; > + > + return cycles; > +} > + > +uint64_t odp_cpu_cycles_max(void) > +{ > + return UINT64_MAX; > +} > + > +uint64_t odp_cpu_cycles_resolution(void) > +{ > + return 1; > +} > -- > 2.9.2 > > -- Mike Holmes Technical Manager - Linaro Networking Group Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs "Work should be fun and collaborative, the rest follows"
On Thu, Aug 4, 2016 at 2:48 PM, Mike Holmes <mike.holmes@linaro.org> wrote: > On 4 August 2016 at 15:30, Brian Brooks <brian.brooks@linaro.org> wrote: > > > Use source files in arch/default for undetected archs. This > > alleviates the need to use symlinks in the source code > > directory structure. > > > > I prefer a behaviour where this fails at config time if a new ARCH appears. > If you dont do this you start running with defaults and get rubbish > performance or even errors and possibly crashes rather than being notified > upfront to pay attention to what you are required to configure. > Agree. The earlier the better for misconfiguration detection. > > > > > > > Signed-off-by: Brian Brooks <brian.brooks@linaro.org> > > --- > > configure.ac | 13 +----- > > platform/Makefile.inc | 3 -- > > platform/linux-generic/arch/arm/odp/api/cpu_arch.h | 1 - > > platform/linux-generic/arch/arm/odp_cpu_arch.c | 1 - > > .../linux-generic/arch/arm/odp_sysinfo_parse.c | 1 - > > platform/linux-generic/arch/powerpc/odp_cpu_arch.c | 49 > > +++++++++++++++++++++- > > 6 files changed, 49 insertions(+), 19 deletions(-) > > delete mode 120000 platform/linux-generic/arch/arm/odp/api/cpu_arch.h > > delete mode 120000 platform/linux-generic/arch/arm/odp_cpu_arch.c > > delete mode 120000 platform/linux-generic/arch/arm/odp_sysinfo_parse.c > > mode change 120000 => 100644 platform/linux-generic/arch/ > > powerpc/odp_cpu_arch.c > > > > diff --git a/configure.ac b/configure.ac > > index c0f0f21..a7e058a 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -77,22 +77,11 @@ AS_CASE([$host], > > [i686*], [ARCH_DIR=x86], > > [mips64*], [ARCH_DIR=mips64], > > [powerpc*], [ARCH_DIR=powerpc], > > - [aarch64*], [ARCH_DIR=arm], > > - [arm*], [ARCH_DIR=arm], > > - [ARCH_DIR=undefined] > > + [ARCH_DIR=default] > > ) > > AC_SUBST([ARCH_DIR]) > > > > ############################################################ > > ############## > > -# Warn on the defaults if arch is undefined > > -########################################################### > > ############### > > -if test "${ARCH_DIR}" == "undefined"; > > -then > > - echo "ARCH_DIR is undefined, please add your ARCH_DIR based on > > host=${host}" > > - exit 1 > > -fi > > - > > -########################################################### > > ############### > > # Set correct pkgconfig version > > ############################################################ > > ############## > > PKGCONFIG_VERSION=$(echo $VERSION | awk -F '.git' '{print $1}') > > diff --git a/platform/Makefile.inc b/platform/Makefile.inc > > index a44f88f..2a4255c 100644 > > --- a/platform/Makefile.inc > > +++ b/platform/Makefile.inc > > @@ -62,9 +62,6 @@ odpapispecinclude_HEADERS = \ > > $(top_srcdir)/include/odp/api/spec/version.h > > > > EXTRA_DIST = \ > > - arch/arm/odp/api/cpu_arch.h \ > > - arch/arm/odp_cpu_arch.c \ > > - arch/arm/odp_sysinfo_parse.c \ > > arch/default/odp/api/cpu_arch.h \ > > arch/default/odp_cpu_arch.c \ > > arch/default/odp_sysinfo_parse.c \ > > diff --git a/platform/linux-generic/arch/arm/odp/api/cpu_arch.h > > b/platform/linux-generic/arch/arm/odp/api/cpu_arch.h > > deleted file mode 120000 > > index e86e132..0000000 > > --- a/platform/linux-generic/arch/arm/odp/api/cpu_arch.h > > +++ /dev/null > > @@ -1 +0,0 @@ > > -../../../default/odp/api/cpu_arch.h > > \ No newline at end of file > > diff --git a/platform/linux-generic/arch/arm/odp_cpu_arch.c > > b/platform/linux-generic/arch/arm/odp_cpu_arch.c > > deleted file mode 120000 > > index deebc47..0000000 > > --- a/platform/linux-generic/arch/arm/odp_cpu_arch.c > > +++ /dev/null > > @@ -1 +0,0 @@ > > -../default/odp_cpu_arch.c > > \ No newline at end of file > > diff --git a/platform/linux-generic/arch/arm/odp_sysinfo_parse.c > > b/platform/linux-generic/arch/arm/odp_sysinfo_parse.c > > deleted file mode 120000 > > index 39962b8..0000000 > > --- a/platform/linux-generic/arch/arm/odp_sysinfo_parse.c > > +++ /dev/null > > @@ -1 +0,0 @@ > > -../default/odp_sysinfo_parse.c > > \ No newline at end of file > > diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > > b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > > deleted file mode 120000 > > index deebc47..0000000 > > --- a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > > +++ /dev/null > > @@ -1 +0,0 @@ > > -../default/odp_cpu_arch.c > > \ No newline at end of file > > diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > > b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > > new file mode 100644 > > index 0000000..2ac223e > > --- /dev/null > > +++ b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c > > @@ -0,0 +1,48 @@ > > +/* Copyright (c) 2015, Linaro Limited > > + * All rights reserved. > > + * > > + * SPDX-License-Identifier: BSD-3-Clause > > + */ > > + > > +#include <odp_posix_extensions.h> > > + > > +#include <stdlib.h> > > +#include <time.h> > > + > > +#include <odp/api/cpu.h> > > +#include <odp/api/hints.h> > > +#include <odp/api/system_info.h> > > +#include <odp_debug_internal.h> > > + > > +#define GIGA 1000000000 > > + > > +uint64_t odp_cpu_cycles(void) > > +{ > > + struct timespec time; > > + uint64_t sec, ns, hz, cycles; > > + int ret; > > + > > + ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); > > + > > + if (ret != 0) > > + ODP_ABORT("clock_gettime failed\n"); > > + > > + hz = odp_cpu_hz_max(); > > + sec = (uint64_t)time.tv_sec; > > + ns = (uint64_t)time.tv_nsec; > > + > > + cycles = sec * hz; > > + cycles += (ns * hz) / GIGA; > > + > > + return cycles; > > +} > > + > > +uint64_t odp_cpu_cycles_max(void) > > +{ > > + return UINT64_MAX; > > +} > > + > > +uint64_t odp_cpu_cycles_resolution(void) > > +{ > > + return 1; > > +} > > -- > > 2.9.2 > > > > > > > -- > Mike Holmes > Technical Manager - Linaro Networking Group > Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs > "Work should be fun and collaborative, the rest follows" >
diff --git a/configure.ac b/configure.ac index c0f0f21..a7e058a 100644 --- a/configure.ac +++ b/configure.ac @@ -77,22 +77,11 @@ AS_CASE([$host], [i686*], [ARCH_DIR=x86], [mips64*], [ARCH_DIR=mips64], [powerpc*], [ARCH_DIR=powerpc], - [aarch64*], [ARCH_DIR=arm], - [arm*], [ARCH_DIR=arm], - [ARCH_DIR=undefined] + [ARCH_DIR=default] ) AC_SUBST([ARCH_DIR]) ########################################################################## -# Warn on the defaults if arch is undefined -########################################################################## -if test "${ARCH_DIR}" == "undefined"; -then - echo "ARCH_DIR is undefined, please add your ARCH_DIR based on host=${host}" - exit 1 -fi - -########################################################################## # Set correct pkgconfig version ########################################################################## PKGCONFIG_VERSION=$(echo $VERSION | awk -F '.git' '{print $1}') diff --git a/platform/Makefile.inc b/platform/Makefile.inc index a44f88f..2a4255c 100644 --- a/platform/Makefile.inc +++ b/platform/Makefile.inc @@ -62,9 +62,6 @@ odpapispecinclude_HEADERS = \ $(top_srcdir)/include/odp/api/spec/version.h EXTRA_DIST = \ - arch/arm/odp/api/cpu_arch.h \ - arch/arm/odp_cpu_arch.c \ - arch/arm/odp_sysinfo_parse.c \ arch/default/odp/api/cpu_arch.h \ arch/default/odp_cpu_arch.c \ arch/default/odp_sysinfo_parse.c \ diff --git a/platform/linux-generic/arch/arm/odp/api/cpu_arch.h b/platform/linux-generic/arch/arm/odp/api/cpu_arch.h deleted file mode 120000 index e86e132..0000000 --- a/platform/linux-generic/arch/arm/odp/api/cpu_arch.h +++ /dev/null @@ -1 +0,0 @@ -../../../default/odp/api/cpu_arch.h \ No newline at end of file diff --git a/platform/linux-generic/arch/arm/odp_cpu_arch.c b/platform/linux-generic/arch/arm/odp_cpu_arch.c deleted file mode 120000 index deebc47..0000000 --- a/platform/linux-generic/arch/arm/odp_cpu_arch.c +++ /dev/null @@ -1 +0,0 @@ -../default/odp_cpu_arch.c \ No newline at end of file diff --git a/platform/linux-generic/arch/arm/odp_sysinfo_parse.c b/platform/linux-generic/arch/arm/odp_sysinfo_parse.c deleted file mode 120000 index 39962b8..0000000 --- a/platform/linux-generic/arch/arm/odp_sysinfo_parse.c +++ /dev/null @@ -1 +0,0 @@ -../default/odp_sysinfo_parse.c \ No newline at end of file diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c deleted file mode 120000 index deebc47..0000000 --- a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c +++ /dev/null @@ -1 +0,0 @@ -../default/odp_cpu_arch.c \ No newline at end of file diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c new file mode 100644 index 0000000..2ac223e --- /dev/null +++ b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c @@ -0,0 +1,48 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <odp_posix_extensions.h> + +#include <stdlib.h> +#include <time.h> + +#include <odp/api/cpu.h> +#include <odp/api/hints.h> +#include <odp/api/system_info.h> +#include <odp_debug_internal.h> + +#define GIGA 1000000000 + +uint64_t odp_cpu_cycles(void) +{ + struct timespec time; + uint64_t sec, ns, hz, cycles; + int ret; + + ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); + + if (ret != 0) + ODP_ABORT("clock_gettime failed\n"); + + hz = odp_cpu_hz_max(); + sec = (uint64_t)time.tv_sec; + ns = (uint64_t)time.tv_nsec; + + cycles = sec * hz; + cycles += (ns * hz) / GIGA; + + return cycles; +} + +uint64_t odp_cpu_cycles_max(void) +{ + return UINT64_MAX; +} + +uint64_t odp_cpu_cycles_resolution(void) +{ + return 1; +}
Use source files in arch/default for undetected archs. This alleviates the need to use symlinks in the source code directory structure. Signed-off-by: Brian Brooks <brian.brooks@linaro.org> --- configure.ac | 13 +----- platform/Makefile.inc | 3 -- platform/linux-generic/arch/arm/odp/api/cpu_arch.h | 1 - platform/linux-generic/arch/arm/odp_cpu_arch.c | 1 - .../linux-generic/arch/arm/odp_sysinfo_parse.c | 1 - platform/linux-generic/arch/powerpc/odp_cpu_arch.c | 49 +++++++++++++++++++++- 6 files changed, 49 insertions(+), 19 deletions(-) delete mode 120000 platform/linux-generic/arch/arm/odp/api/cpu_arch.h delete mode 120000 platform/linux-generic/arch/arm/odp_cpu_arch.c delete mode 120000 platform/linux-generic/arch/arm/odp_sysinfo_parse.c mode change 120000 => 100644 platform/linux-generic/arch/powerpc/odp_cpu_arch.c -- 2.9.2