Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
719 Views

Confusion about data type alignment

I need to transfer 128 structures from host to FPGA. In the host code,I define the structure as following: 

 

*********************************************************************# define AOCL_ALIGNMENT 64 

typedef struct 

double S;  

double X;  

double u;  

double e_rt_p; 

double e_rt_q; 

int CP; 

}struct_A; 

struct_A* input_A; 

input_A=(struct_A *)_aligned_malloc(128*sizeof(struct_A),AOCL_ALIGNMENT); 

*********************************************************************** 

in the kernel code,I define the structure as following: 

********************************************************************** 

typedef struct __attribute__((packed)) __attribute__((aligned(64))) 

double S;  

double X;  

double u;  

double e_rt_p; 

double e_rt_q; 

int CP; 

}struct_A; 

 

 

__kernel void kernels(__global double* restrict output_data, __global struct_A* restrict input_data) 

 

for (int i=0;i<128;i++){ 

S = input_data.S; 

X = input_data.X; 

u = input_data.u; 

e_rt_p = input_data.e_rt_p; 

e_rt_q = input_data.e_rt_q; 

CP = input_data.CP; 

************************************************************************************* 

BUT, I can't get the values of S~cp in right order, when I remove "__attribute__((packed)) __attribute__((aligned(64)))", I can get the right values of S~cp

Can anyone figure out what's the problem in my code?Thanks very much.
0 Kudos
0 Replies