cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
4,444 Views
Registered: ‎09-21-2016

Simulation failed: SIGSEGV. Do not understand how to use malloc.

Jump to solution

Hello everyone,

I was trying very simple input output. AXI Stream input and output but I need to use array for further processing. To save BRAM I use DATAFLOW. My image size is 1920*1080.

I am having following error:

 

ERROR: [SIM 211-100] CSim failed with errors.
@E Simulation failed: SIGSEGV.

I have searched for this kind of issue in the forum. And in some solutions, they suggest to use malloc for large dataset. But I am not sure how to do that for my case. I have tried in a way but still C-simulation failed.

Any suggestion or example of declaration by malloc for my case will be helpful.

Thank you

Rappy Saha

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Advisor
Advisor
5,843 Views
Registered: ‎04-26-2015

The easy solution is to just declare "_buff" static:

 

static uint_24 _buff[1920*1080];

This shifts it off the stack, and should eliminate the segmentation fault.

 

However, I must point out that virtually any task that actually requires a 1920x1080x24-bit buffer on-chip is going to be very problematic. 1920x1080x24-bit = 2700 18K block RAMs, even if it's packed perfectly. You'd have to go up to the Virtex 7 XC7VX690T just to get enough space for that buffer.

 

DATAFLOW will resolve that issue, but only if the buffer access is something that you could have done with a stream anyway.

View solution in original post

9 Replies
Highlighted
Advisor
Advisor
5,844 Views
Registered: ‎04-26-2015

The easy solution is to just declare "_buff" static:

 

static uint_24 _buff[1920*1080];

This shifts it off the stack, and should eliminate the segmentation fault.

 

However, I must point out that virtually any task that actually requires a 1920x1080x24-bit buffer on-chip is going to be very problematic. 1920x1080x24-bit = 2700 18K block RAMs, even if it's packed perfectly. You'd have to go up to the Virtex 7 XC7VX690T just to get enough space for that buffer.

 

DATAFLOW will resolve that issue, but only if the buffer access is something that you could have done with a stream anyway.

View solution in original post

Highlighted
Adventurer
Adventurer
4,410 Views
Registered: ‎09-21-2016

Hi @u4223374,

 

Thank you very much for your quick reply. Actually, by the buffer accessing, at first I want to verify my input and output is okay. Then, I will write the simple algorithm. 

 

I have tried in your way and it was working but after displaying the row and column value I am having this type of warning continuously. And after some time My PC hangs. 

Image row:1080 Cols:1920
WARNING: Hls::stream 'hls::stream<ap_axiu<24, 1, 1, 1> >.2' is read while empty, which may result in RTL simulation hanging.
WARNING: Hls::stream 'hls::stream<ap_axiu<24, 1, 1, 1> >.2' is read while empty, which may result in RTL simulation hanging.
WARNING: Hls::stream 'hls::stream<ap_axiu<24, 1, 1, 1> >.2' is read while empty, which may result in RTL simulation hanging.
WARNING: Hls::stream 'hls::stream<ap_axiu<24, 1, 1, 1> >.2' is read while empty, which may result in RTL simulation hanging.
WARNING: Hls::stream 'hls::stream<ap_axiu<24, 1, 1, 1> >.2' is read while empty, which may result in RTL simulation hanging.
WARNING: Hls::stream 'hls::stream<ap_axiu<24, 1, 1, 1> >.2' is read while empty, which may result in RTL simulation hanging.
WARNING: Hls::stream 'hls::stream<ap_axiu<24, 1, 1, 1> >.2' is read while empty, which may result in RTL simulation hanging.
WARNING: Hls::stream 'hls::stream<ap_axiu<24, 1, 1, 1> >.2' is read while empty, which may result in RTL simulation hanging.

How can I solve this issue? Any suggestion will be quite helpful.

 

Thank you

Rappy Saha

 

 

0 Kudos
Highlighted
Advisor
Advisor
4,402 Views
Registered: ‎04-26-2015

I think this is because you're only buffering the pixel data itself - not the side-channel data that goes with it in the stream (TUSER and TLAST in particular). The AXIvideo2IplImage function probably relies on TUSER/TLAST to tell it where the ends of the image are; without those it's just reading forever (and causing the problem you describe). You will need to either buffer all the data (ie _buff should have type stream_24, not uint_24) or regenerate the side-channel data in the output loop.

0 Kudos
Highlighted
Adventurer
Adventurer
4,356 Views
Registered: ‎09-21-2016

Hello @u4223374,

 

Thanks for suggestion. It is working now. But, I have another problem with dataflow. My code is not in sequential manner. So, dataflow can't work. I need to change my code. I will study on it. 

 

Rappy Saha

0 Kudos
Highlighted
Advisor
Advisor
4,345 Views
Registered: ‎04-26-2015

@rappysaha Welcome to the most painful part of using HLS!

 

Organizing the flow of data in a way that makes sense on an FPGA is almost always a challenge. Organizing it in a way that HLS can correctly recognize just makes that more difficult.

 

If you can post exactly what you're trying to do then people here might be able to offer some advice.

Highlighted
Participant
Participant
3,650 Views
Registered: ‎11-30-2017

hello rappysaha

   I met the same problem,can you tell me how did you do in more details?

WARNING Hls::stream 'hls::stream<ap_axiu<24, 1, 1, 1> >.2' is read while empty, which may result in RTL simulation hanging. Thanks very much!

 

0 Kudos
Highlighted
Participant
Participant
3,646 Views
Registered: ‎11-30-2017

hello @u4223374

   I met the same problem,can you tell me how did you do in more details?

WARNING Hls::stream 'hls::stream<ap_axiu<24, 1, 1, 1> >.2' is read while empty, which may result in RTL simulation hanging. Thanks very much!

0 Kudos
Highlighted
Adventurer
Adventurer
3,635 Views
Registered: ‎09-21-2016

Hello hitpmpm@163.com,

I don't know exactly your case. In my case I was using buffer like following:

1. Input loop take data input by stream based pipeline and save it to buffer.

2. output loop read the data from the buffer and send it to the stream based pipeline.

In this kind of scenario, I specify tuser and tlast signal in the output loop by following code:

	Output: for (int R=0; R<rows*cols; R++)
	{
#pragma HLS LOOP_TRIPCOUNT min=2000 max=222940
#pragma HLS PIPELINE
			stream_24  pixel_out;
			pixel_out.data = buff[R];
			if ((R%(rows-1))==0 && R !=0) pixel_out.last=1;
			else pixel_out.last =0;
			if (R==0) pixel_out.user = 1;
			else pixel_out.user =0;
			video_out.write(pixel_out);
	}
}

And that solved my problem. Hope it will be helpful for you.

Thank you. 

Highlighted
Participant
Participant
3,631 Views
Registered: ‎11-30-2017

hello @rappysaha my case is described as follows,can you tell me  how to solve the problem?  Sincere appreciation!

 

top.h

#ifndef _TOP_H_
#define _TOP_H_
#include"hls_video.h" //这里调用可以综合的视频库
// maximum image size
#define MAX_WIDTH 1920
#define MAX_HEIGHT 1080
// I/O Image Settings
#define INPUT_IMAGE1 "dog.jpg"
#define INPUT_IMAGE2 "dog1.jpg"
#define OUTPUT_IMAGE "dogp.jpg"
#define OUTPUT_IMAGE_GOLDEN "result_1080p_golden.jpg"
typedef hls::Mat<MAX_HEIGHT, MAX_WIDTH, HLS_8UC3> RGB_IMAGE;
typedef hls::Mat<MAX_HEIGHT, MAX_WIDTH, HLS_8UC1> GRAY_IMAGE;
typedef hls::stream<ap_axiu<24,1,1,1> > AXI_STREAM_IN;
typedef hls::stream<ap_axiu<24,1,1,1> > AXI_STREAM_OUT;
void hls_chafen(AXI_STREAM_IN& src1_axi, AXI_STREAM_IN& src2_axi, AXI_STREAM_OUT& dst_axi, int rows, int cols);

#endif

 

hls_chafen.cpp

#include "top.h"
void hls_chafen(AXI_STREAM_IN& input1, AXI_STREAM_IN& input2, AXI_STREAM_OUT& output, int rows, int cols) {
#pragma HLS INTERFACE axis port=input1 bundle=INPUT_STREAM
#pragma HLS INTERFACE axis port=input2 bundle=INPUT_STREAM
#pragma HLS INTERFACE axis port=output bundle=OUTPUT_STREAM
#pragma HLS interface ap_ctrl_none port=return
#pragma HLS INTERFACE ap_stable port=rows
#pragma HLS INTERFACE ap_stable port=cols

RGB_IMAGE img_0(rows, cols);
RGB_IMAGE img_1(rows, cols);
GRAY_IMAGE img_2(rows, cols);
GRAY_IMAGE img_3(rows, cols);
GRAY_IMAGE img_4(rows, cols);
GRAY_IMAGE img_5(rows, cols);
GRAY_IMAGE img_6(rows, cols);
GRAY_IMAGE img_7(rows, cols);
#pragma HLS DATAFLOW // must use data flow to stream the data
hls::AXIvideo2Mat(input1, img_0); //read video stream by frames AXI4-STREAM IO 函数
hls::AXIvideo2Mat(input2, img_1); //read video stream by frames
hls::CvtColor<HLS_RGB2GRAY>(img_0, img_2); //转换到灰度空间

hls::CvtColor<HLS_RGB2GRAY>(img_1, img_3); //转换到灰度空间
//差分
hls::AbsDiff(img_2, img_3, img_4);//计算两个相同类型相同大小的数组差的绝对值

//二值化操作,找大于20(阈值)的像素点,把cur中对应的点设为255的
hls::Threshold(img_4, img_5, 100, 255, HLS_THRESH_BINARY);

//形态学操作,膨胀使图像变大一圈,那是指图像中的白色目标区域扩大了一圈
//尽量不使用默认的膨胀与腐蚀模板,那样的效果太差了。

//hls::Mat element = cvgetStructuringElement(MORPH_CROSS, Size(3, 3));
hls::Dilate(img_5, img_6);//矩形: MORPH_RECT 交叉形: MORPH_CROSS椭圆形: MORPH_ELLIPSE
hls::Erode(img_6, img_7);//Point中心位置 iterations迭代次数;borderType 用于推断图像外部像素的某种边界模式;borderValue,当边界为常数时的边界值,有默认值morphologyDefaultBorderValue()

//hls::Sobel<1,0,3>(img_0, img_1);//use Hls Sobel
hls::Mat2AXIvideo(img_7, output); //write the frames to video stream
}

 

 

 

test.cpp

#include "top.h"
#include "opencv/cv.h"
#include "opencv/cxcore.h"
#include "opencv/highgui.h"
#include "hls_opencv.h"
int main (int argc, char** argv) {
IplImage* src1 = cvLoadImage(INPUT_IMAGE1);
IplImage* src2 = cvLoadImage(INPUT_IMAGE2);
IplImage* dst = cvCreateImage(cvGetSize(src1), src1->depth, src1->nChannels);
AXI_STREAM_IN src1_axi;
AXI_STREAM_IN src2_axi;
AXI_STREAM_OUT dst_axi;
IplImage2AXIvideo(src1, src1_axi); //将图像转为视频流结构 opencv接口函数
IplImage2AXIvideo(src2, src2_axi); //将图像转为视频流结构
hls_chafen(src1_axi,src2_axi, dst_axi, src1->height, src1->width);
AXIvideo2IplImage(dst_axi, dst);
cvSaveImage(OUTPUT_IMAGE, dst);
cvReleaseImage(&src1);
cvReleaseImage(&src2);
cvReleaseImage(&dst);
}

0 Kudos