typedef with restrict关键字

我定义了像这样的对齐浮点数

typedef __attribute((aligned(64))) float aligned_float; 

然后我用这样的restrict关键字定义对齐的浮点数

 typedef aligned_float * restrict aligned_floatptr; 

这与我期望的一样。 但由于我几乎总是想要这两个在一起,所以我尝试将typedef放在一行中

 typedef __attribute((aligned(64))) float * restrict aligned_floatptr2 

但是,这不起作用。 仍然可以识别restrict关键字,但不会对齐。 然而,编译器没有给我任何警告。 我只是通过查看组件才意识到对齐不起作用。

为什么组合定义不起作用,为什么我不收到警告?

你可以在这里看到Clang和GCC的组件。


我想这样做的原因是我有这样的代码

 static void kernel(float * restrict a, float * restrict b, float * restrict c, int n) { a = __builtin_assume_aligned(a, 64); b = __builtin_assume_aligned(b, 64); c = __builtin_assume_aligned(c, 64); //rest of code 

}

我有很多变化。 我觉得使用起来更方便

 static void kernel(aligned_flotptr a, aligned_floatptr b, aligned_floatptr c, int n) { //rest of code } 

我刚刚意识到Clang似乎并没有认识到甚至为aligned_float 。 只有海湾合作委员会认可它。 使用Clang我仍然需要使用__builtin_assume_aligned (或者可能是#praga omp sind aligned )。 另一方面,Clang即使没有对齐也能产生良好的代码(未对齐的指令与几代的对齐版本一样快),所以我真正需要GCC才能实现对齐。