Hello,

I'm currently using CUDA and Arrayfire on a work for college involving image processing. My question is as how to wrapp a device memory pointer that points towards a CudaMallocPitch-type of memory space in which i saved the results for a filter kernel. This data is float type of 32 rows by 32 columns.

I've tried to wrap the pointer into an array with:

-af::array CKernelR = af::array(32,32, d_ComplexKernelR, af::afDevice);

d_ComplexKernelR = CKernelR.device<float>();

But wasn't able to succesfully convert the device memory to an array, data was not the same....

How could i put this data into an array so i can go on using arrayfire on it?

Here is my cuda kernel that generates the filter:

__global__ void kernel_matrixReal (float *gaborR, float *gaborI, int pitchR, int pitchI, double pi, float lambda, float gama, float theta, float sigma,

int width, int height){

int idx = blockIdx.x * blockDim.x + threadIdx.x;

int x=idx - height/2;

int idy = blockIdx.y * blockDim.y + threadIdx.y;

int y=-(idy - width/2);

float menos05 = -0.5;

double theta_dev = theta;

double x_theta=x*cos(theta_dev)+y*sin(theta_dev);

double y_theta=-x*sin(theta_dev)+y*cos(theta_dev);

double pot_sigma=pow(sigma,2);

double pot_x=pow(x_theta, 2);

double div_pot_x=pot_x / pot_sigma;

double pot_y=pow(y_theta, 2);

double div_pot_y=pot_y / pot_sigma;

gaborR[idy*pitchR + idx] = (float) (1/(sqrt(pi)*sigma)) * exp(menos05 *( div_pot_x + gama *div_pot_y))*cos(2*pi/lambda*x_theta);

gaborI[idy*pitchI + idx] = (float) (1/(sqrt(pi)*sigma)) * exp(menos05 *( div_pot_x + gama *div_pot_y))*sin(2*pi/lambda*x_theta);

}