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.