cd /path/to/MEGAHIT
tar -xvf v1.2.9.tar.gz
cd megahit-1.2.9
vi CMakeLists.txt
6 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") … 76 set_target_properties(megahit_core PROPERTIES COMPILE_FLAGS "-mbmi2 -DUSE_BMI2 -mpopcnt") 77 set_target_properties(megahit_core_popcnt PROPERTIES COMPILE_FLAGS "-mpopcnt")
6 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -march=armv8.2-a") … 76 set_target_properties(megahit_core PROPERTIES COMPILE_FLAGS "") 77 set_target_properties(megahit_core_popcnt PROPERTIES COMPILE_FLAGS "")
cd ./src/utils/
cp /path/to/PORT_ADVISOR/portadv/tools/inline_asm/config/KunpengTrans.h ./
vi cpu_dispatch.h
新增代码已标记:
#if defined(__aarch64__) //新增代码 #include "KunpengTrans.h" //新增代码 #endif //新增代码 #ifndef MEGAHIT_CPU_DISPATCH_H #define MEGAHIT_CPU_DISPATCH_H inline bool HasPopcnt() { unsigned eax, ebx, ecx, edx; #ifdef _MSC_VER int cpuid[4]; __cpuid(cpuid, 1); eax = cpuid[0], ebx = cpuid[1], ecx = cpuid[2], edx = cpuid[3]; #else #if defined(__x86_64__) //新增代码 asm volatile("cpuid\n\t" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "0"(1)); #elif defined(__aarch64__) //新增代码 { eax = 1; //新增代码 GetSupportedCPUID(&eax,&ebx,&ecx,&edx); //新增代码 } #endif //新增代码 #endif return ecx >> 23U & 1U; } inline bool HasBmi2() { unsigned eax, ebx, ecx, edx; #ifdef _MSC_VER int cpuid[4]; __cpuidex(cpuid, 7, 0); eax = cpuid[0], ebx = cpuid[1], ecx = cpuid[2], edx = cpuid[3]; #else #if defined(__x86_64__) //新增代码 asm volatile("cpuid\n\t" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "0"(7), "2"(0)); #elif defined(__aarch64__) //新增代码 { eax = 7; //新增代码 ecx = 0; //新增代码 GetSupportedCPUID(&eax,&ebx,&ecx,&edx); //新增代码 } #endif //新增代码 #endif return ebx >> 8U & 1U; } #endif // MEGAHIT_CPU_DISPATCH_H
cd ../kmlib/
vi kmrns.h
#include <x86intrin.h>
#include <sse2neon.h>
cp /path/to/SSE2NEON/sse2neon-1.5.0/sse2neon.h /path/to/MEGAHIT/megahit-1.2.9/src
mkdir /path/to/MEGAHIT/build && cd /path/to/MEGAHIT/build
CC=`which gcc` CXX=`which g++` cmake -DCMAKE_INSTALL_PREFIX=/path/to/MEGAHIT -DCMAKE_BUILD_TYPE=Release ../ make -j 16 make install
export PATH=/path/to/MEGAHIT/bin:$PATH