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

Graviton2-b #330

Open
wants to merge 5 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
37 changes: 30 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if (CMAKE_VERSION VERSION_LESS "3.1")
else ()
set(CMAKE_CXX_STANDARD 11)
endif ()
# target_compile_features(<proj> PUBLIC cxx_std_11)

option(COVERAGE "Generate coverage report" OFF)
option(STATIC_BUILD "Build static executation" OFF)
Expand Down Expand Up @@ -34,7 +35,7 @@ LIST(APPEND OTHER_SOURCE

if (STATIC_BUILD)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif (STATIC_BUILD)
endif ()

find_package(ZLIB REQUIRED)
find_package(OpenMP REQUIRED)
Expand All @@ -54,34 +55,56 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g -ggdb -O1 -D_LIBCPP_DEBUG -D_GLIBCXX_DEBUG")
if (COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage")
set(COV_PY "coverage run")
endif (COVERAGE)
endif ()

if (SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined")
endif (SANITIZER)
endif ()

if (TSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
endif (TSAN)
endif ()


message(STATUS "Build type: ${CMAKE_BUILD_TYPE}: ${CMAKE_CXX_FLAGS}")
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}" )

add_executable(megahit_core ${OTHER_SOURCE} ${ASMBL_SOURCE} ${IDBA_SOURCE} ${SDBG_SOURCE} ${LCASM_SOURCE} ${SEQ_SOURCE}
${CX1_SOURCE} ${TOOLKIT_SOURCE})
add_executable(megahit_core_popcnt ${OTHER_SOURCE} ${ASMBL_SOURCE} ${IDBA_SOURCE} ${SDBG_SOURCE} ${LCASM_SOURCE} ${SEQ_SOURCE}
${CX1_SOURCE} ${TOOLKIT_SOURCE})
add_executable(megahit_core_no_hw_accel ${OTHER_SOURCE} ${ASMBL_SOURCE} ${IDBA_SOURCE} ${SDBG_SOURCE} ${LCASM_SOURCE}
${SEQ_SOURCE} ${CX1_SOURCE} ${TOOLKIT_SOURCE})
set_target_properties(megahit_core PROPERTIES COMPILE_FLAGS "-mbmi2 -DUSE_BMI2 -mpopcnt")
set_target_properties(megahit_core_popcnt PROPERTIES COMPILE_FLAGS "-mpopcnt")

include(CheckCXXCompilerFlag)
#check_cxx_compiler_flag("-march=native" USE_ARCH_NATIVE)
#if(USE_ARCH_NATIVE)
# message(STATUS "Using native tuning (-march=native compiler flag set)")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
#endif()

check_cxx_compiler_flag("-mpopcnt" USE_POPCNT)
if(USE_POPCNT)
message(STATUS "Using popcnt instructions (-mpopcnt compiler flag set)")
set_target_properties(megahit_core_popcnt PROPERTIES COMPILE_FLAGS "-mpopcnt")
else()
message(STATUS "popcnt not found ")
endif()

check_cxx_compiler_flag("-mbmi2" USE_BMI2)
if(USE_BMI2 AND USE_POPCNT)
message(STATUS "Using bmi2 instructions (-mbmi2 compiler flag set)")
set_target_properties(megahit_core PROPERTIES COMPILE_FLAGS "-mbmi2 -DUSE_BMI2 -mpopcnt")
else()
message(STATUS "bmi2 not found")
endif()

if (STATIC_BUILD)
# TODO dirty
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -static")
set_target_properties(megahit_core megahit_core_popcnt megahit_core_no_hw_accel PROPERTIES LINK_SEARCH_START_STATIC ON)
set_target_properties(megahit_core megahit_core_popcnt megahit_core_no_hw_accel PROPERTIES LINK_SEARCH_END_STATIC ON)
endif (STATIC_BUILD)
endif ()

target_link_libraries(megahit_core ${ZLIB_LIBRARIES})
target_link_libraries(megahit_core_popcnt ${ZLIB_LIBRARIES})
Expand Down
7 changes: 6 additions & 1 deletion src/kmlib/kmrns.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <x86intrin.h>
#if defined(__GNUC__) && defined(__aarch64__)
#define SIMDE_ENABLE_NATIVE_ALIASES
#include "../simde/x86/avx2.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR.

Where is ../simde/x86/avx2.h?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why limit it to aarch64? ppc64* could probably be fixed by this as well.

#else
#include <x86intrin.h>
#endif
#include <vector>

namespace kmlib {
Expand Down
6 changes: 6 additions & 0 deletions src/utils/cpu_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#ifndef MEGAHIT_CPU_DISPATCH_H
#define MEGAHIT_CPU_DISPATCH_H

#if defined(__GNUC__) && defined(__aarch64__)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, why only aarch64?

inline bool HasPopcnt() { return false; }
inline bool HasBmi2() { return false; }
#else

inline bool HasPopcnt() {
unsigned eax, ebx, ecx, edx;
#ifdef _MSC_VER
Expand Down Expand Up @@ -32,5 +37,6 @@ inline bool HasBmi2() {
#endif
return ebx >> 8U & 1U;
}
#endif

#endif // MEGAHIT_CPU_DISPATCH_H