iOS:在 64 位中使用 vDSP 功能 [英] iOS: using vDSP functions in 64bit
问题描述
在 iOS 中,我有一个函数调用依赖于 vDSP_vgathr,Apple 加速框架:
In iOS, I have a function call that depends on vDSP_vgathr, a member of Apple's Accelerate framework:
int pix = image.size.height * image.size.width;
float * array = (float *)malloc(sizeof(float) * pix * 4);
float * colorPlane = (float *)malloc(sizeof(float) * pix);
float * y_r = (float *)malloc(sizeof(float) * pix)
int * malloc(sizeof(int) * pix)
vDSP_vgathr(colorPlane, (const vDSP_Length *)idx, 1, y_r, 1, (int)(rate*pix));
我看过一个SO问题与我得到的错误有关,EXC_I386_GPFLT
,以及 64 位系统和非规范指针.解决方案(和另一个) 我已经看到建议包括 tgmath.h
,但是当使用(成功编译)时,它什么也不做,我仍然得到 EXC_I386_GPFLT
.
I've seen an SO question that relating to the error I get, EXC_I386_GPFLT
, and 64 bit systems and non-canonical pointers. The solution (and another one) I've seen suggest including tgmath.h
, but when used (with a successful compile), it does nothing and I still get EXC_I386_GPFLT
.
我尝试了许多其他潜在的解决方案,包括类型转换各种对象和不同的函数调用.我怎样才能使这个函数调用适用于 64 位架构?
I've tried a host of other potential solutions including typecasting various objects and different function calls. How can I do I make this function call work with the 64 bit architecture?
推荐答案
vDSP_vgathr
的文档说它被定义为
The docs for vDSP_vgathr
say it's defined as
void vDSP_vgathr (
float *__vDSP_A,
vDSP_Length *__vDSP_B,
vDSP_Stride __vDSP_J,
float *__vDSP_C,
vDSP_Stride __vDSP_K,
vDSP_Length __vDSP_N
);
您正在将一个 int 传递给该函数,并且 vDSP_Length
被定义为 unsigned long.
因此,将一个 unsigned long 传递给:
You're passing an int into that function and vDSP_Length
is defined as unsigned long.
So, pass an unsigned long in:
unsigned long * idxSend = (unsigned long *)malloc(sizeof(unsigned long) * N);
for (i=0; i<N; i++) idxSend[i] = (unsigned long)idx[i];
vDSP_vgathr(..., idxSend, ...);
这就解决了你的问题.
这篇关于iOS:在 64 位中使用 vDSP 功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!