Skip to content

Commit

Permalink
Add initial fixes to get MMseqs2 working on s390x
Browse files Browse the repository at this point in the history
  • Loading branch information
milot-mirdita committed Feb 21, 2021
1 parent b1704cc commit 45111b6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set(HAVE_SSE2 0 CACHE BOOL "Have CPU with SSE2")
set(HAVE_POWER9 0 CACHE BOOL "Have POWER9 CPU")
set(HAVE_POWER8 0 CACHE BOOL "Have POWER8 CPU")
set(HAVE_ARM8 0 CACHE BOOL "Have ARMv8 CPU")
set(HAVE_S390X 0 CACHE BOOL "Have s390x architecture")
set(NATIVE_ARCH 1 CACHE BOOL "Assume native architecture for SIMD. Use one of the HAVE_* options or set CMAKE_CXX_FLAGS to the appropriate flags if you disable this.")
set(USE_SYSTEM_ZSTD 0 CACHE BOOL "Use zstd provided by system instead of bundled version")

Expand Down Expand Up @@ -71,6 +72,9 @@ elseif (HAVE_POWER8)
elseif (HAVE_ARM8)
set(MMSEQS_ARCH "${MMSEQS_ARCH} -march=armv8-a+simd")
set(ARM 1)
elseif (HAVE_S390X)
set(MMSEQS_ARCH "${MMSEQS_ARCH} -mzarch -march=z14")
set(ZARCH 1)
endif ()

if (NATIVE_ARCH AND (MMSEQS_ARCH STREQUAL ""))
Expand All @@ -82,6 +86,8 @@ if (NATIVE_ARCH AND (MMSEQS_ARCH STREQUAL ""))
set(X64 1)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "x86|X86")
set(X86 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
set(ZARCH 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
set(SPARC 1)
else ()
Expand Down Expand Up @@ -154,7 +160,7 @@ if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSI
set(DISABLE_IPS4O 1)
endif ()

if (PPC64 OR SPARC)
if (PPC64 OR SPARC OR ZARCH)
# FIXME: investigate why on ppc the regression seems to fail randomly
set(DISABLE_IPS4O 1)
endif ()
Expand Down
4 changes: 4 additions & 0 deletions src/commons/Orf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ inline bool isInCodons(const char* sequence, simd_int codons, simd_int) {
// s: ATGA GTGA TGAT GAGT
// c: ATGA ATGA ATGA ATGA
simd_int c = simdi32_set(*(unsigned int*)sequence);
#if SIMDE_ENDIAN_ORDER == SIMDE_ENDIAN_LITTLE
simd_int mask = simdi32_set(0x00FFFFFF);
#else
simd_int mask = simdi32_set(0xFFFFFF00);
#endif
// c: ATG0 ATG0 ATG0 ATG0
c = simdi_and(mask, c);
// t: FFFF 0000 0000 0000
Expand Down
21 changes: 20 additions & 1 deletion src/commons/itoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,26 @@ THE SOFTWARE.
#include <cstdint>

#define SIMDE_ENABLE_NATIVE_ALIASES
#include <simde/x86/sse2.h>
#include <simde/simde-common.h>

#if SIMDE_ENDIAN_ORDER != SIMDE_ENDIAN_LITTLE
class Itoa{
public:
static char* u32toa_sse2(uint32_t value, char* buffer) {
return buffer + sprintf(buffer, "%d", value) + 1;
}
static char* i32toa_sse2(int32_t value, char* buffer) {
return buffer + sprintf(buffer, "%d", value) + 1;
}
static char* u64toa_sse2(uint64_t value, char* buffer) {
return buffer + sprintf(buffer, "%zu", value) + 1;
}
static char* i64toa_sse2(uint64_t value, char* buffer) {
return buffer + sprintf(buffer, "%zu", value) + 1;
}
};
#else
#include <simde/x86/sse2.h>
// FIXME: NEON throws many warnings due to the reinterpret casts
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
Expand Down Expand Up @@ -309,3 +327,4 @@ class Itoa{
#pragma GCC diagnostic pop

#endif
#endif

0 comments on commit 45111b6

Please sign in to comment.