我基本上喜欢和http://blog.alexrp.com/2013/09/26/clangs-static-analyzer-and-automake一样,但是使用CMake.
analyze_srcs = foo.c
analyze_plists = $(analyze_srcs:%.c=%.plist)
CLEANFILES = $(analyze_plists)
$(analyze_plists): %.plist: %.c
@echo " CCSA " $@
@$(COMPILE) --analyze $< -o $@
analyze: $(analyze_plists)
.PHONY: analyze
Run Code Online (Sandbox Code Playgroud)
所以你可以跑
make analyze
make clean
Run Code Online (Sandbox Code Playgroud)
我想我需要使用add_custom_command/add_custom_target
并以某种方式更改仅针对该目标的"目标文件"扩展名.
然后获取生成文件的列表,或者将它们传递给脚本,以将它们组合成1个输出文件.
谁能指出我正确的方向?
假设您有一个巨大的(40+ GB)特征值(浮点)矩阵,行是不同的特征,列是样本/图像.
该表是按列预先计算的.然后,它被完全访问行和多线程(每个线程加载整行)几次.
处理这个矩阵的最佳方法是什么?我特别琢磨超过5分:
https://web.archive.org/web/20170227190422/http://hilbert-space.de/?p=22
在这个过时的网站上,它表明手写的asm会比内在的更好.我想知道这是不是现在的真相,即使是现在2012年.
那么使用gnu交叉编译器为内在函数改进了编译优化?
它只是一个简单的编译测试。当clang和msvc拒绝它时,gcc接受以下内容:https : //godbolt.org/z/DlUasL
float test()
{
return reinterpret_cast<float&&>(0x7F800000);
}
Run Code Online (Sandbox Code Playgroud)
根据标准,哪一个是正确的?
OpenMP标准是否保证#pragma omp simd能够正常工作,即如果编译器无法对代码进行矢量化,编译是否会失败?
#include <cstdint>
void foo(uint32_t r[8], uint16_t* ptr)
{
const uint32_t C = 1000;
#pragma omp simd
for (int j = 0; j < 8; ++j)
if (r[j] < C)
r[j] = *(ptr++);
}
Run Code Online (Sandbox Code Playgroud)
gcc和clang无法对此进行矢量化,但根本不会抱怨(除非您使用-fopt-info-vec-optimized-missed
等).
对于以下代码的div/mod部分:
int pow(int x, unsigned int n)
{
int y = 1;
while (n > 1)
{
auto m = n%2;
n = n/2;
if (m)
y *= x;
x = x*x;
}
return x*y;
}
Run Code Online (Sandbox Code Playgroud)
我希望组装像
shr n
cmovc y, yx
Run Code Online (Sandbox Code Playgroud)
但是gcc/clang甚至icc都没有在这里使用进位标志(使用2个寄存器和/和测试代码):https://godbolt.org/z/L6VUZ1
所以我想知道如果你手工编写它以及为什么(ILP,依赖项......)最好的方法.
struct B
{
int a;
void foo() {a = 5;}
};
template <typename T>
struct A
{
A(int i) { B::foo(); }
A(double d) {}
};
int main()
{
A<int> a(5.0);
}
Run Code Online (Sandbox Code Playgroud)
gcc 4.7.2编译它没有错误.clang 3.4svn抱怨:
$ clang -Wall -Wextra test.cpp
test.cpp:10:16: error: call to non-static member function without an object argument
A(int i) { B::foo(); }
~~~^~~
Run Code Online (Sandbox Code Playgroud)
当然代码是错误的,但哪个编译器符合标准?
同样奇怪的是,如果使用5而不是5.0,则clang不会像gcc那样打印任何"实例化"注释:
$ gcc test.cpp
test.cpp: In instantiation of ‘A<T>::A(int) [with T = int]’:
test.cpp:15:12: required from here
test.cpp:9:13: error: cannot call member …
Run Code Online (Sandbox Code Playgroud)