iOS:使用64bit的vDSP功能 [英] iOS: using vDSP functions in 64bit

查看:248
本文介绍了iOS:使用64bit的vDSP功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS中,我有一个函数调用依赖于 vDSP_vgathr ,苹果的一名成员加速框架

  int pix = image.size。高度* 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



我尝试了许多其他可能的解决方案,包括类型化各种对象和不同的函数调用。我怎样才能使这个函数调用工作与64位体系结构?

解决方案

文档为 vDSP_vgathr 说它被定义为

  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

 <$> c $ c> unsigned long * idxSend =(unsigned long *)malloc(sizeof(unsigned long)* N); (i = 0; i< N; i ++)idxSend [i] =(unsigned long)idx [i]; 
vDSP_vgathr(...,idxSend,...);

解决了您的问题。


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));

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.

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?

解决方案

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
);

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, ...);

That solves your problem.

这篇关于iOS:使用64bit的vDSP功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆