Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
15332 Discussions

Confusion about data type alignment

Altera_Forum
Honored Contributor II
791 Views

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
Reply