From a30fe80449a623e6b8c532f4efb53dd1e5e786e0 Mon Sep 17 00:00:00 2001 From: chunlin Date: Tue, 30 Mar 2021 19:33:35 +0800 Subject: [PATCH 1/3] x86intrin.h is not supported in ARM. --- src/Geno.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Geno.cpp b/src/Geno.cpp index 853a86a..77980c3 100644 --- a/src/Geno.cpp +++ b/src/Geno.cpp @@ -91,7 +91,7 @@ uint64_t fill_inter_zero(uint64_t x) { x = x ^ t ^ (t << 1); return x; } -#ifdef __linux__ +#if defined(__linux__) && (defined(_WIN32) || defined(_WIN64)) #include __attribute__((target("bmi2"))) uint64_t fill_inter_zero(uint64_t x) { -- Gitee From 43c6115ef9456ddbcd9d5722d95ad4761702445d Mon Sep 17 00:00:00 2001 From: kydkyky <834352945@qq.com> Date: Tue, 30 Mar 2021 20:21:15 +0800 Subject: [PATCH 2/3] add arm judgement. --- src/Geno.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Geno.cpp b/src/Geno.cpp index 77980c3..3975cb4 100644 --- a/src/Geno.cpp +++ b/src/Geno.cpp @@ -91,7 +91,7 @@ uint64_t fill_inter_zero(uint64_t x) { x = x ^ t ^ (t << 1); return x; } -#if defined(__linux__) && (defined(_WIN32) || defined(_WIN64)) +#if defined(__linux__) && !(defined(__arm__) || defined(__aarch64__)) #include __attribute__((target("bmi2"))) uint64_t fill_inter_zero(uint64_t x) { -- Gitee From 76795bd3f4ee8a1fe5d3b9adcc9b879eea1eb1c6 Mon Sep 17 00:00:00 2001 From: kydkyky <834352945@qq.com> Date: Wed, 31 Mar 2021 16:58:22 +0800 Subject: [PATCH 3/3] add ARM support. --- src/Geno.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Geno.cpp b/src/Geno.cpp index 3975cb4..77dc4a8 100644 --- a/src/Geno.cpp +++ b/src/Geno.cpp @@ -43,6 +43,26 @@ #include "submods/Pgenlib/PgenReader.h" #include +#if defined( __i386__ ) || defined(i386) || defined(_M_IX86) + /* + * __i386__ is defined by gcc and Intel compiler on Linux, + * _M_IX86 by VS compiler, + * i386 by Sun compilers on opensolaris at least + */ + #define CPU_X86 +#elif defined(__x86_64__) || defined(__amd64__) || defined(__x86_64) || defined(_M_AMD64) + /* + * both __x86_64__ and __amd64__ are defined by gcc + * __x86_64 defined by sun compiler on opensolaris at least + * _M_AMD64 defined by MS compiler + */ + #define CPU_AMD64 +#elif defined(__arm__) || defined(__aarch64__) + #define CPU_ARM +#else + #error Unknown CPU +#endif + #ifdef _WIN64 #include uint32_t __inline CTZ64U(uint64_t value){ @@ -59,13 +79,13 @@ #else //#define CTZU __builtin_ctz //#define CLZU __builtin_clz - #ifdef __linux__ + #if defined(__linux__) && !defined(CPU_ARM) __attribute__((target("default"))) #endif uint32_t CTZ64U(uint64_t value){ return __builtin_ctzll(value); } - #ifdef __linux__ + #if defined(__linux__) && !defined(CPU_ARM) __attribute__((target("popcnt"))) uint32_t CTZ64U(uint64_t value){ return __builtin_ctzll(value); @@ -74,7 +94,7 @@ #endif -#ifdef __linux__ +#if defined(__linux__) && !defined(CPU_ARM) __attribute__((target("default"))) #endif uint64_t fill_inter_zero(uint64_t x) { @@ -91,7 +111,7 @@ uint64_t fill_inter_zero(uint64_t x) { x = x ^ t ^ (t << 1); return x; } -#if defined(__linux__) && !(defined(__arm__) || defined(__aarch64__)) +#if defined(__linux__) && !defined(CPU_ARM) #include __attribute__((target("bmi2"))) uint64_t fill_inter_zero(uint64_t x) { -- Gitee