I'm new at Xilinx development, and i'm preparing my master degree with zedboard. I'm trying to develop a convolution accelerator with Opencl on Zedboard using Vivado HLS.
I created the OpenCL block.
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#include <clc.h>
__kernel void __attribute__ ((reqd_work_group_size(26,1,1)))
conv_openCL( __global double*a, __global double*c) {
int i = get_global_id(0);
c[i] = a[i] * 2 ;
}
Then i used it in Vivado to create architecture : Image 1
After exporting it to Vivado SDK and using and modifying the code from here. the OpenCL block does't execute correctly and i don't know the reason for it.
So my question is why when i replace the int type with float or double it gives me an error.
Old code:
volatile char *control = (volatile char*)0x43C00000;
volatile int *wg_x = (volatile int*)0x43C00010;
volatile int *wg_y = (volatile int*)0x43C00018;
volatile int *wg_z = (volatile int*)0x43C00020;
volatile int *o_x = (volatile int*)0x43C00028;
volatile int *o_y = (volatile int*)0x43C00030;
volatile int *o_z = (volatile int*)0x43C00038;
volatile int *a_addr = (volatile int*) 0x43C00040;
volatile int *c_addr = (volatile int*)0x43C00048;
...
void main(){
...
int* a;
int*c;
a = (int*)malloc(WG_SIZE_X *sizeof(int));
c = (int*)malloc(WG_SIZE_X *sizeof(int));
*a_addr =(unsigned int)a;
*c_addr =(unsigned int)c;
...
}
My Code:
volatile char *control = (volatile char*)0x43C00000;
volatile int *wg_x = (volatile int*)0x43C00010;
volatile int *wg_y = (volatile int*)0x43C00018;
volatile int *wg_z = (volatile int*)0x43C00020;
volatile int *o_x = (volatile int*)0x43C00028;
volatile int *o_y = (volatile int*)0x43C00030;
volatile int *o_z = (volatile int*)0x43C00038;
volatile double *a_addr = (volatile double*) 0x43C00040;
volatile double *c_addr = (volatile double*)0x43C00048;
...
void main(){
...
int* a;
int*c;
a = (double*)malloc(WG_SIZE_X *sizeof(double));
c = (double*)malloc(WG_SIZE_X *sizeof(double));
*a_addr =(double)a;
*c_addr =(double)c;
...
}
it gives me this error:
invalid cast from type 'double*' to type 'double'
Please help me, i want to transfer the content of "a" array to the "a_addr" array of the OpenCL block.
You're trying to cast an int*
, a
, to a double
. This cannot be done as pointers store addresses - integers.
You'll need to modify you're code to:
volatile double **a_addr = (volatile double**) 0x43C00040;
volatile double **c_addr = (volatile double**)0x43C00048;
...
void main(){
...
double* a;
double* c;
a = (double*)malloc(WG_SIZE_X *sizeof(double));
c = (double*)malloc(WG_SIZE_X *sizeof(double));
*a_addr =a;
*c_addr =c;
...
}
Or is you want to to do it in a similar way to the original code:
volatile int *a_addr = (volatile int*) 0x43C00040;
volatile int *c_addr = (volatile int*)0x43C00048;
...
void main(){
...
double* a;
double* c;
a = (double*)malloc(WG_SIZE_X *sizeof(double));
c = (double*)malloc(WG_SIZE_X *sizeof(double));
*a_addr =(int)a;
*c_addr =(int)c;
...
}