diff --git a/build/preInstall_storage_engine.sh b/build/preInstall_storage_engine.sh index c5f58d59e..1320f0e0d 100644 --- a/build/preInstall_storage_engine.sh +++ b/build/preInstall_storage_engine.sh @@ -1,4 +1,10 @@ +if [ -z $(cat /proc/cpuinfo | grep -E 'sse4_2|neon|asimd' | head -c1) ]; then + echo "error: this machine CPU lacks of support for Intel SSE4.2 or ARM Advanced SIMD instructions. +Columnstore requires one of this instruction sets, installation aborted" + exit 1 +fi + if [ "$1" == "2" ]; then /bin/cp -f /etc/columnstore/storagemanager.cnf /etc/columnstore/storagemanager.cnf.rpmsave > /dev/null 2>&1 columnstore-pre-uninstall diff --git a/debian/mariadb-plugin-columnstore.preinst b/debian/mariadb-plugin-columnstore.preinst new file mode 100644 index 000000000..27818588c --- /dev/null +++ b/debian/mariadb-plugin-columnstore.preinst @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +# Check for sse4.2 or neon support + +if [ -z $(cat /proc/cpuinfo | grep -E 'sse4_2|neon|asimd' | head -c1) ]; then + echo "error: this machine CPU lacks of support for Intel SSE4.2 or ARM Advanced SIMD instructions. +Columnstore requires one of this instruction sets, installation aborted" + exit 1 +fi diff --git a/primitives/primproc/archcheck.h b/primitives/primproc/archcheck.h new file mode 100644 index 000000000..3e9a8effe --- /dev/null +++ b/primitives/primproc/archcheck.h @@ -0,0 +1,66 @@ +/* Copyright (C) 2022 MariaDB Corporation + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; version 2 of + the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#pragma once + +#include + +#ifdef __aarch64__ +#include +#include +#endif + +namespace archcheck +{ + +enum class arcitecture +{ + DEFAULT = 0, + SSE4_2 = 1, + ASIMD = 2, + UNKNOWN = -1 +}; + +#if defined(__x86_64__) +__attribute__ ((target ("default"))) +arcitecture checkArchitecture() +{ + // The default version. + return arcitecture::DEFAULT; +} + +__attribute__ ((target ("sse4.2"))) +arcitecture checkArchitecture () +{ + // version for SSE4.2 + return arcitecture::SSE4_2; +} +#elif defined(__aarch64__) +arcitecture checkArchitecture() +{ + // version for arm + if ((getauxval(AT_HWCAP) & HWCAP_ASIMD) != 0) + return arcitecture::ASIMD; + return arcitecture::DEFAULT; +} +#else +arcitecture checkArchitecture() +{ + return arcitecture::UNKNOWN; +} +#endif +} diff --git a/primitives/primproc/primproc.cpp b/primitives/primproc/primproc.cpp index 7282c0343..b64f9038e 100644 --- a/primitives/primproc/primproc.cpp +++ b/primitives/primproc/primproc.cpp @@ -59,6 +59,9 @@ using namespace logging; #include "umsocketselector.h" using namespace primitiveprocessor; +#include "archcheck.h" +using namespace archcheck; + #include "liboamcpp.h" using namespace oam; @@ -735,6 +738,11 @@ int ServicePrimProc::Child() int main(int argc, char** argv) { + if (checkArchitecture() != arcitecture::SSE4_2 && checkArchitecture() != arcitecture::ASIMD) + { + std::cerr << "Unsupported CPU architecture. ARM Advanced SIMD or x86_64 SSE4.2 required; aborting. \n"; + return 1; + } Opt opt(argc, argv); // Set locale language