arrays - vectorize operation in C with Cell BE -
i have following scenario: 1d array of dim size, , 2 arrays of dim/2 size. want copy elements of smaller arrays larger one. using following code(i running code on spu):
unsigned char output_data1[dim/2] __attribute__ ((aligned(16))); unsigned char output_data2[dim/2] __attribute__ ((aligned(16))); unsigned char output_data[dim] __attribute__ ((aligned(16))); (ix = 0; ix < dim; ix++) { if (ix < dim / 2) { output_data[ix] = output_data1[ix]; } else { output_data[ix] = output_data2[ix - dim / 2]; } }
i trying obtain same functionality, vectorizing above operation. have following code:
vector unsigned char *v = (vector unsigned char*)output_data; vector unsigned char *v1 = (vector unsigned char*)output_data1; vector unsigned char *v2 = (vector unsigned char*)output_data2; int length=dim/(16/sizeof(unsigned char)); (j = 0; j < length; j++) { if (j < length / 2) { v[j] = v1[j]; } else { v[j] = v2[j - length / 2]; } }
however code doesn't seem produce right results(the chars in arrays values of pixels in images, , after using vectorized code, images missing lines). can please me out? lot.
Comments
Post a Comment