Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17268 Discussions

Confusion about data type alignment

Altera_Forum
Honored Contributor II
1,336 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