我开发了一个处理SIGILL信号的库.因为我想避免libc依赖,并直接使用Linux系统调用.我注意到我的库挂在一些Linux系统上,经过大量的调试后我发现使用rt_sigaction系统调用而不是sigaction解决问题.但是,我没有找到两个系统调用之间差异的描述.SO上有人知道底层细节吗?
更新:我使用信号处理程序来检测某些ARM指令扩展的CPU支持,例如XScale指令MIATT.这是指令探测功能:
static uint32_t probe_xscale() {
register uint32_t retValue asm("r0") = 0;
asm volatile (
// Equivalent of the following code:
// ".arch xscale\n"
// "MIATT acc0, r0, r0;"
// If the next line raises SIGILL, the signal handle will change r0 to 1 and skip the instruction (4 bytes)
"MCR P0, 0x1, r0, c15, c0, 0;"
: "+r" (retValue)
:
:
);
return retValue;
}
Run Code Online (Sandbox Code Playgroud)
在SIGILL处理程序中,我将PC寄存器前进4个字节(此指令的大小),并更改其中一个寄存器以指示已调用SIGILL处理程序.这是信号处理程序代码.
static void probe_signal_handler(int, siginfo_t *, …Run Code Online (Sandbox Code Playgroud) 说实话,这是我第一次使用像Yeppp!这样的任何类型的库,我的意思是SIMD库具有动态运行时选择,或者他们会说出来.最终结果是库应该选择最佳的SIMD汇编代码,以便在运行的任何平台和硬件上运行.
这似乎是在我的项目中使用的一个很好的工具,但是,正如标题所述,我不能称之为任何Yeppp!功能没有发生分段故障.我能够获得的调试信息也没有帮助.
我的系统配置是:
Xubuntu 13.04 'raring' with Linux 3.8.0-31-generic x86_64
GCC 4.8.1 --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu .... etc, there were many more, but I chose the important ones
Code::Blocks IDE and GDB 7.5.91.20130417-cvs-ubuntu debugger through Code::Blocks
Intel Pentium(R) Dual-Core CPU T4400 @ 2.20GHz with SIMD instruction sets MMX, SSE, SSE2, SSSE3
Run Code Online (Sandbox Code Playgroud)
我列出了CPU等等,因为它对Yeppp来说可能很重要!选择正确的运行时,这可能是问题.
下面是我正在使用的简单测试代码,虽然我尝试了其他的Yeppp!具有各种数据类型的函数,都是相同的分段错误.我也尝试了各种对齐方式,如32和64,但我怀疑这是问题所在.
YEP_ALIGN(16) int32_t a[100], b[100], c[100];
//just test values
for( int x = 0; x < 100; x++ ) {
a[x] = x + …Run Code Online (Sandbox Code Playgroud) 我之前从未需要在C#中使用指针,但是,我正在使用的库要求方法参数作为指针传递.该库允许使用SIMD指令集.
为了测试如何使用该库,我试图编写一种方法,该方法使用SIMD一次性计算数组中所有元素的余弦值.
这就是我所拥有的:
double[] ValuesToCalculate = new double[MAX_SIZE];
double[] CalculatedCosines = new double[MAX_SIZE];
long Result;
Result = CalculateCosineArray(ValuesToCalculate, CalculatedCosines);
public static long CalculateCosineArraySIMD(double[] array, double[] result)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
for (int i = 0; i < array.Length; i++)
{
Yeppp.Math.Cos_V64f_V64f(*array, result, MAX_SIZE);
}
stopwatch.Stop();
return stopwatch.ElapsedMilliseconds;
}
Run Code Online (Sandbox Code Playgroud)
但是,我收到这些错误:
The best overloaded method match for 'Yeppp.Math.Cos_V64f_V64f(double*, double*, int)' has some invalid arguments
Argument 1: cannot convert from 'double[]' to 'double*'
The * or -> operator must be …Run Code Online (Sandbox Code Playgroud) linux ×2
simd ×2
yeppp ×2
c ×1
c# ×1
c++ ×1
linux-kernel ×1
pointers ×1
signals ×1
system-calls ×1