Add support for ARM
- Build system fixes - No user-mode high-precision timer by default, use clock_gettime - Use C11 aligned_alloc pending C++17 std::aligned_alloc Change-Id: I268365bdfd11d1e817a89584b9e086ee5b86e1dc
This commit is contained in:
@@ -57,9 +57,9 @@ if(UNIX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--unresolved-symbols=ignore-in-shared-libs")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
|
||||
if ( IS64BIT )
|
||||
if ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse -msse2" )
|
||||
else ()
|
||||
elseif ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" )
|
||||
endif ()
|
||||
if ( "${CMAKE_BUILD_TYPE}" STREQUAL Debug )
|
||||
|
||||
@@ -89,9 +89,9 @@ set ( CMAKE_CXX_FLAGS "-std=c++11 " )
|
||||
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-deprecated-declarations -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -fPIC" )
|
||||
|
||||
if ( IS64BIT )
|
||||
if ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse -msse2" )
|
||||
else ()
|
||||
elseif ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" )
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -88,9 +88,9 @@ set ( CMAKE_CXX_FLAGS "-std=c++11 " )
|
||||
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-deprecated-declarations -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -fPIC" )
|
||||
|
||||
if ( IS64BIT )
|
||||
if ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse -msse2" )
|
||||
else ()
|
||||
elseif ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" )
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ set ( CMAKE_CXX_FLAGS "-std=c++11 ")
|
||||
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-error=enum-compare -Wno-sign-compare -Wno-write-strings -Wno-deprecated-declarations -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -fPIC" )
|
||||
|
||||
if (IS64BIT)
|
||||
if ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse -msse2" )
|
||||
else ()
|
||||
elseif ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" )
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ if(UNIX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--unresolved-symbols=ignore-in-shared-libs")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
|
||||
if ( IS64BIT )
|
||||
if ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse -msse2" )
|
||||
else ()
|
||||
elseif ( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" )
|
||||
endif ()
|
||||
if ( "${CMAKE_BUILD_TYPE}" STREQUAL Debug )
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "core/util/utils.h"
|
||||
#include "core/util/os.h"
|
||||
#include <chrono>
|
||||
|
||||
#include <time.h>
|
||||
#include <type_traits>
|
||||
|
||||
namespace timer {
|
||||
@@ -144,8 +144,18 @@ class fast_clock {
|
||||
typedef uint64_t raw_rep;
|
||||
typedef double raw_frequency;
|
||||
|
||||
#ifdef __x86_64__
|
||||
static __forceinline raw_rep raw_now() { return __rdtsc(); }
|
||||
static __forceinline raw_frequency raw_freq() { return freq; }
|
||||
#endif
|
||||
#ifdef __aarch64__
|
||||
static __forceinline raw_rep raw_now() {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
|
||||
return (raw_rep(ts.tv_sec) * 1000000000 + raw_rep(ts.tv_nsec));
|
||||
}
|
||||
static __forceinline raw_frequency raw_freq() { return 1.e-9; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
static double period_ps;
|
||||
|
||||
@@ -54,9 +54,9 @@ typedef unsigned int uint;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#include "mm_malloc.h"
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#include <x86intrin.h>
|
||||
#elif defined(__aarch64__)
|
||||
#else
|
||||
#error \
|
||||
"Processor or compiler not identified. " \
|
||||
@@ -70,9 +70,9 @@ typedef uint64_t uint64;
|
||||
#define __ALIGNED__(x) __attribute__((aligned(x)))
|
||||
|
||||
static __forceinline void* _aligned_malloc(size_t size, size_t alignment) {
|
||||
return _mm_malloc(size, alignment);
|
||||
return aligned_alloc(alignment, size);
|
||||
}
|
||||
static __forceinline void _aligned_free(void* ptr) { return _mm_free(ptr); }
|
||||
static __forceinline void _aligned_free(void* ptr) { return free(ptr); }
|
||||
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
|
||||
#include "intrin.h"
|
||||
#define __ALIGNED__(x) __declspec(align(x))
|
||||
|
||||
Verwijs in nieuw issue
Block a user