I am currently writing a vectorized version of the QR decomposition (linear system solver) using SSE and AVX intrinsics. One of the substeps requires to select the sign of a value opposite/equal to another value. In the serial version, I used std::copysign for this. Now I want to create a similar function for SSE/AVX registers. Unfortunately, the STL uses a built-in function for that, so I can't just copy the code and turn it into SSE/AVX instructions.
I have not …
我最近更新了我的项目及其 CI 管道以使用 C++20 功能。当我将编译器设置更改为使用 C++20 时,clang-tidy 开始为我检查的所有文件发出以下警告(我将它们视为错误):
error: invalid case style for template parameter 'expr-type' [readability-identifier-naming,-warnings-as-errors]
Run Code Online (Sandbox Code Playgroud)
我可以使用 CMake 和一个 clang-tidy 配置文件将其缩小到以下最小示例:
CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(clang_tidy_warning LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(clang_tidy_warning main.cpp)
Run Code Online (Sandbox Code Playgroud)
.clang-tidy
Checks: >
readability-*,
WarningsAsErrors: '*'
CheckOptions:
- {key: readability-identifier-naming.TemplateParameterCase, value: lower_case}
- {key: readability-identifier-naming.TypeTemplateParameterCase, value: CamelCase }
- {key: readability-identifier-naming.TemplateParameterPrefix, value: t_ }
- {key: readability-identifier-naming.TypeTemplateParameterPrefix, value: T_ }
Run Code Online (Sandbox Code Playgroud)
主程序
error: invalid case style for template parameter 'expr-type' [readability-identifier-naming,-warnings-as-errors]
Run Code Online (Sandbox Code Playgroud)
您应该能够在 Ubuntu 20.04 中使用以下命令在根目录中重现它:
mkdir build …Run Code Online (Sandbox Code Playgroud) 自从我开始使用SSE / AVX内部函数以来已经有一段时间了。我最近开始为矩阵转置编写标题。我使用了很多if constexpr分支,以便编译器始终根据某些模板参数来选择最佳指令集。现在,我想通过使用来检查本地反汇编来检查是否一切正常objdump。使用Clang时,我得到一个清晰的输出,该输出基本上只包含与所使用的内在函数相对应的汇编指令。但是,如果我使用GCC,则在使用其他说明时反汇编会很is肿。快速检查一下Godbolt,我发现GCC拆卸中的这些多余说明不应该存在。
这是一个小例子:
#include <x86intrin.h>
#include <array>
std::array<__m256, 1> Test(std::array<__m256, 1> a)
{
std::array<__m256, 1> b;
b[0] = _mm256_unpacklo_ps(a[0], a[0]);
return b;
}
Run Code Online (Sandbox Code Playgroud)
我编译-march=native -Wall -Wextra -Wpedantic -pthread -O3 -DNDEBUG -std=gnu++1z。然后我objdump -S -Mintel libassembly.a > libassembly.dump在目标文件上使用。对于Clang(6.0.0),结果是:
In archive libassembly.a:
libAssembly.cpp.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <_Z4TestSt5arrayIDv8_fLm1EE>:
0: c4 e3 7d 04 c0 50 vpermilps ymm0,ymm0,0x50
6: c3 ret
Run Code Online (Sandbox Code Playgroud)
这与Godbolt返回的结果相同:Godbolt-Clang 6.0.0
对于GCC(7.4),输出为
In archive libassembly.a:
libAssembly.cpp.o: file …Run Code Online (Sandbox Code Playgroud)