2017-05-08 10:47:04 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
remove AVX and AVX512 code from Calc
It's been a source of numerous problems since the beginning.
Poor separation of C++ code causing the compiler to emit some generic
code as CPU-specific, compiler optimizations moving CPU-specific
code out of #ifdef to unguarded static initialization, etc.
And it doesn't seem to even particularly improve performance,
on my Ryzen2500U for one full column (1m cells) sumArray() takes
about 1.6ms with AVX, 1.9ms with SSE2 and 4.6ms with generic code.
So SSE2 code is perhaps worth it, especially given that SSE2 is our
baseline requirement on x86_64 everywhere and x86 on Windows,
but AVX+ is nowhere near worth the trouble.
So this code removes all AVX+ code from Calc, and makes SSE2
a hardcoded option on where it's guaranteed. If we raise the baseline
to AVX, the SSE2 code may be replaced by the one removed by this
commit. Generic code is there for other platforms, if other platforms
add CPU-specific code, they should preferably follow the same rules.
This does not necessarily mean that CPU-specific code cannot
be used at all. Some externals use them, for example. It just
needs to be working, maintained, and worth the trouble.
Change-Id: I5ab919930df9d0223db68a94bf84947984d313ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129733
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
2022-02-09 16:23:33 +01:00
|
|
|
// IMPORTANT: Having CPU-specific routines turned out to be a maintenance
|
|
|
|
// problem, because of various problems such as compilers moving CPU-specific
|
|
|
|
// code out of #ifdef code into static initialization or our code using C++
|
|
|
|
// features that caused the compiler to emit code that used CPU-specific
|
|
|
|
// instructions (even cpuid.hxx isn't safe, see the comment there).
|
|
|
|
// The only safe usage is using CPU-specific code that's always available,
|
|
|
|
// such as SSE2-specific code for x86_64. Do not use for anything else
|
|
|
|
// unless you really know what you are doing (and you check git history
|
|
|
|
// to learn from past problems).
|
|
|
|
|
2017-05-08 10:47:04 +02:00
|
|
|
// Determine the compiler support for SIMD compiler intrinsics.
|
|
|
|
// This changes from one compiled unit to the other, depending if
|
|
|
|
// the support has been detected and if the compiled unit contains
|
|
|
|
// code using intrinsics or not. So we have to (re)set them again
|
|
|
|
// every time this file has been included.
|
|
|
|
|
2020-06-20 16:59:59 +02:00
|
|
|
// In other words... DO NOT ADD "#pragma once" here
|
|
|
|
|
2017-05-08 10:47:04 +02:00
|
|
|
#undef LO_SSE2_AVAILABLE
|
|
|
|
#undef LO_SSSE3_AVAILABLE
|
|
|
|
#undef LO_AVX_AVAILABLE
|
|
|
|
#undef LO_AVX2_AVAILABLE
|
2021-05-16 16:04:20 +02:00
|
|
|
#undef LO_AVX512F_AVAILABLE
|
2017-05-08 10:47:04 +02:00
|
|
|
|
|
|
|
#if defined(_MSC_VER) // VISUAL STUDIO COMPILER
|
|
|
|
|
2022-01-26 13:34:08 +01:00
|
|
|
// With MSVC using -arch is in fact not necessary for being able
|
|
|
|
// to use CPU intrinsics, code using AVX512F intrinsics will compile
|
|
|
|
// even if compiled with -arch:AVX, the -arch option really only affects
|
|
|
|
// instructions generated for C/C++ code.
|
|
|
|
#if defined(_M_X64) || defined(_M_X86)
|
|
|
|
// As such, if we're building for X86 or X64, support for these is always available
|
|
|
|
// with MSVC2019+.
|
2017-05-08 10:47:04 +02:00
|
|
|
#define LO_SSE2_AVAILABLE
|
|
|
|
#define LO_SSSE3_AVAILABLE
|
|
|
|
#define LO_AVX_AVAILABLE
|
|
|
|
#define LO_AVX2_AVAILABLE
|
2021-05-16 16:04:20 +02:00
|
|
|
#define LO_AVX512F_AVAILABLE
|
2022-01-26 13:34:08 +01:00
|
|
|
#include <intrin.h>
|
2021-05-16 16:04:20 +02:00
|
|
|
#include <immintrin.h>
|
2022-01-26 13:34:08 +01:00
|
|
|
#endif
|
2021-05-16 16:04:20 +02:00
|
|
|
|
2019-07-17 21:27:00 +09:00
|
|
|
#else // compiler Clang and GCC
|
2017-05-08 10:47:04 +02:00
|
|
|
|
|
|
|
#if defined(__SSE2__) || defined(__x86_64__) // SSE2 is required for X64
|
|
|
|
#define LO_SSE2_AVAILABLE
|
2020-06-20 16:59:59 +02:00
|
|
|
#include <emmintrin.h>
|
2019-07-17 21:27:00 +09:00
|
|
|
#endif // defined(__SSE2__)
|
2017-05-08 10:47:04 +02:00
|
|
|
|
|
|
|
#if defined(__SSSE3__)
|
|
|
|
#define LO_SSSE3_AVAILABLE
|
2020-06-20 16:59:59 +02:00
|
|
|
#include <tmmintrin.h>
|
2019-07-17 21:27:00 +09:00
|
|
|
#endif // defined(__SSSE3__)
|
|
|
|
|
2017-05-08 10:47:04 +02:00
|
|
|
#if defined(__AVX__)
|
|
|
|
#define LO_AVX_AVAILABLE
|
2020-06-20 16:59:59 +02:00
|
|
|
#include <immintrin.h>
|
2019-07-17 21:27:00 +09:00
|
|
|
#endif // defined(__AVX__)
|
2017-05-08 10:47:04 +02:00
|
|
|
|
|
|
|
#if defined(__AVX2__)
|
|
|
|
#define LO_AVX2_AVAILABLE
|
2020-06-20 16:59:59 +02:00
|
|
|
#include <immintrin.h>
|
2019-07-17 21:27:00 +09:00
|
|
|
#endif // defined(__AVX2__)
|
|
|
|
|
2021-05-16 16:04:20 +02:00
|
|
|
#if defined(__AVX512F__)
|
|
|
|
#define LO_AVX512F_AVAILABLE
|
|
|
|
#include <immintrin.h>
|
|
|
|
#else
|
|
|
|
#endif // defined(__AVX512F__)
|
|
|
|
|
2019-07-17 21:27:00 +09:00
|
|
|
#endif // end compiler Clang and GCC
|
2017-05-08 10:47:04 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|