Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

Malloc Memory corrupted

Altera_Forum
Honored Contributor II
1,442 Views

Hi, so im working on a CNN based OpenCL on De1soc. 

I got the following error: 

 

*** Error in `./host': malloc(): memory corruption: 0x000677e8 ***  

 

This error pops up when the program ran the clCreatebuffer.  

for ( j = 0 ; j < LAYER_NUM ; ++j) { // Create Buffer for Weights each layers buffer_size = layer_config*layer_config*layer_config*layer_config*sizeof(float); weights_buffer = clCreateBuffer(context,CL_MEM_READ_ONLY,buffer_size,NULL,&status); checkError(status,"Failed to create buffer for weights in layer %d", j); // Create Buffer for Bias, Scales, Rolling Mean and Rolling variance buffer_size = layer_config*sizeof(float); bias_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, buffer_size,NULL,&status); checkError(status,"Failed to create buffer for bias in layer %d", j); scales_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, buffer_size, NULL, &status); checkError(status,"Failed to create buffer for scales in layer %d", j); rolling_mean_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, buffer_size, NULL, &status); checkError(status,"Failed to create buffer for rolling mean in layer %d", j); rolling_variance_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, buffer_size, NULL, &status); checkError(status,"Failed to create buffer for rolling variance in layer %d", j); // Create Buffer for convolutional result workspace // Convolutional kernel write data to here // Maxpool Kernel Read data from here buffer_size = layer_config*layer_config*layer_config*layer_config*sizeof(float); data_conv_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE,buffer_size, NULL, &status); checkError(status, "Failed to create buffer to conv buffer in layer %d", j); // Create Buffer for Maxpool result workspace // Maxpool Write data to here buffer_size = layer_config*layer_config*layer_config*sizeof(float); data_maxpool_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, buffer_size, NULL, &status); checkError(status, "Failed to create buffer to maxpool buffer in layer %d", j); // Create buffer for data workspace buffer_size = layer_config * layer_config * layer_config * layer_config * layer_config*sizeof(float); data_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, buffer_size, NULL, &status); checkError(status, "Failed to create buffer to data buffer in layer %d", j); } 

 

Emulation passed but failed when testing on the board
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
578 Views

Your host program is runned on Win or in ARM SoC ? May you stepping our program in debugger ? 

If you know address of violation, 0x000677e8, then may printf() a bytes from this memory region before/after every clCreateBuffer(), printf() the returned addresses and input parameters (sizes), an error (buffer overrun) may be was earlier and become now in last getting heap memory. 

Good idea is see sources for malloc() in debugger with concrete code and seat of problem.
0 Kudos
Altera_Forum
Honored Contributor II
578 Views

Hi, I'm sorry for late reply. So i debug for few days and managed to locate the error, i put a wrong buffer size.  

I ran on an ARM SoC, De1Soc. 

Thanks Witfed.
0 Kudos
Reply