cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
1,209 Views
Registered: ‎05-01-2018

Use the SDSOC to speed up the algorithm and run problems on the zedboard

Jump to solution

   Recently, I was studying the acceleration of image processing algorithm on zedboard. When I use SDSOC to generate startup files, After electric start of the board,the program will stop automatically, as shown in the following figure.111.jpg

 

Here's my code

#include "gaosi.h"
#include <stdio.h>
//#include <Windows.h>
#pragma SDS data sys_port(kern:AFI,src:AFI, dst:AFI)
#pragma SDS data mem_attribute(kern:PHYSICAL_CONTIGUOUS)
#pragma SDS data mem_attribute(src:PHYSICAL_CONTIGUOUS)
#pragma SDS data mem_attribute(dst:NON_CACHEABLE|PHYSICAL_CONTIGUOUS)
#pragma SDS data access_pattern(kern:SEQUENTIAL)
#pragma SDS data access_pattern(dst:SEQUENTIAL)
#pragma SDS data access_pattern(src:SEQUENTIAL)
#pragma SDS data copy(kern[0:10*10],src[0:rows*cols], dst[0:rows*cols])
void Convolve1DWidth(float kern[100], int dim, float src[307200], float dst[307200], int rows, int cols)
{
//#define DST(ROW,COL) ((float*)(dst + (cols)*ROW))[(COL)]
//#define Src(ROW,COL) ((float*)(src + (cols)*ROW))[(COL)]
int i, j;
//int ii=0;
for (j = 0; j < rows; j++)
{
for (i = 0; i < cols; i++)
{
#pragma HLS PIPELINE
int p;
float pixel = 0;
int col;
int cen = dim / 2;
float temp1 = 0;
float temp2 = 0;
//printf("ConvolveLoc(): Applying convoluation at location (%d, %d)\n", i, j);
for (p = 0; p < dim; p++)
{
col = i + (p - cen);
if (col < 0)
col = 0;
if (col >= cols)
col = cols - 1;
//pixel += *kern++ * Src(j, col);
//pixel += *(kern+p)*(*(src + j*cols+col));
temp1 = *(kern + p)*(*(src + j*cols + col));
temp2 = pixel;
pixel = temp1 + temp2;
}

if (pixel > 1)
pixel = 1;
*dst++ = pixel;
}
}
}

 

The function above is the function I want to accelerate, nested in the following function

 

int BlurImage(CvMat * src, CvMat * dst, float sigma)
{
float* convkernel;
int dim = (int)MAX(3.0f, 2.0 * GAUSSKERN * sigma + 1.0f);
float *array1 = (float *)malloc(sizeof(float)*src->rows*src->cols);
float *array2 = (float *)malloc(sizeof(float)*src->rows*src->cols);
for (unsigned int i = 0; i < src->rows; i++)
{
for (unsigned int j = 0; j < src->cols; j++)
{
array1[i*src->cols+j] = *(src->data.fl + i*src->cols + j);
}
}
CvMat *tempMat;
tempMat = cvCreateMat(src->rows, src->cols, CV_32FC1);

// make dim odd
if (dim % 2 == 0)
dim++;

 

convkernel = GaussianKernel1D(sigma, dim);
Convolve1DWidth(convkernel, dim, array1, array2, src->rows, src->cols);
cvInitMatHeader(tempMat,src->rows,src->cols, CV_32FC1, array2);
Convolve1DHeight(convkernel, dim, tempMat->data.fl, dst->data.fl, tempMat->rows, tempMat->cols);
cvReleaseMat(&tempMat);
return dim;
}

 

Can anyone help me solve this problem? Thank you very much.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Visitor
Visitor
1,306 Views
Registered: ‎05-01-2018

    I solved this problem by adjusting the parameter order of the function and adding a return value to the function.

View solution in original post

0 Kudos
4 Replies
Highlighted
Visitor
Visitor
1,097 Views
Registered: ‎05-01-2018

anyone else?

0 Kudos
Highlighted
Observer
Observer
1,089 Views
Registered: ‎03-09-2017

Which version of SDSoC are you using?

0 Kudos
Highlighted
Visitor
Visitor
1,307 Views
Registered: ‎05-01-2018

    I solved this problem by adjusting the parameter order of the function and adding a return value to the function.

View solution in original post

0 Kudos
Highlighted
Visitor
Visitor
1,054 Views
Registered: ‎05-01-2018

I using the 2015.4

0 Kudos