Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Community Forums
- :
- Forums
- :
- Software Development and Acceleration
- :
- HLS
- :
- Matrix multiplication without using DSP

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

abdulparis

Contributor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-27-2015 06:19 AM

11,726 Views

Registered:
05-27-2015

Hello everybody,

I am trying to simulate a c program of matrix multiplication of float numbers. I don't want to use DSPs for doing this. I tried multiple directives (allocate, resource, ...) but i was unable to eliminate DSPs from my design.

Here is my code :

void matrix_multiply_hw(float mat_in1[DIM][DIM], float mat_in2[DIM][DIM], float mat_out[DIM][DIM]) { #pragma HLS INLINE off // matrix multiplication of a A*B matrix L1: for (int y = 0; y < DIM; y++) L2: for (int x = 0; x < DIM; x++) { float sum = 0; L3: for (int i = 0; i < DIM; i++) sum = sum + mat_in1[y][i] * mat_in2[i][x]; mat_out[y][x] = sum; } return; }

My directive file contains the following directive to pipeline a loop:

set_directive_pipeline "matrix_multiply_hw/L2"

If I apply the following directive to limit number of DSPs to 1 :

#pragma HLS ALLOCATION instances=mul limit=1 operation

I get 10 instances of **matrix_multiply_hw** function in my **top function**. I applied the directive to have only 1 instance of this function by using the following directive :

#pragma HLS ALLOCATION instances=matrix_multiply_hw limit=1 function

The __ problem__ is at line :

sum = sum + mat_in1[y][i] * mat_in2[i][x];

As this line does the multiplication and addition, it uses DSPs.

How can i tell Vivado HLS to not use DSPs at all for this design. Any suggestion would be appreciated.

Kind regards,

Abdul

1 Solution

Accepted Solutions

debrajr

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-09-2015 11:20 PM

20,284 Views

Registered:
04-17-2011

In this particular case for DIM = 10, making some minor changes removed all the DSP's with RESOURCE directive.

As this is a floating point operation, the operations which inferred the DSP were fmul & fAddSub.

Try this below:

void matrix_multiply_hw(float mat_in1[10][10], float mat_in2[10][10], float mat_out[10][10])

{

#pragma HLS INLINE off

float sum = 0;

float temp;

#pragma HLS RESOURCE variable=temp core=FMul_nodsp

#pragma HLS RESOURCE variable=sum core=FAddSub_nodsp

// matrix multiplication of a A*B matrix

L1: for (int y = 0; y < 10; y++)

L2: for (int x = 0; x < 10; x++)

{

L3: for (int i = 0; i < 10; i++)

temp = mat_in1[y][i] * mat_in2[i][x];

sum = sum + temp ;

mat_out[y][x] = sum;

}

return;

}

With this, no DSP were inferred as the Floating Point operations would be inferring No DSP.

Regards,

Debraj

----------------------------------------------------------------------------------------------

Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

----------------------------------------------------------------------------------------------

Debraj

----------------------------------------------------------------------------------------------

Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

----------------------------------------------------------------------------------------------

3 Replies

abdulparis

Contributor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-27-2015 07:38 AM

11,713 Views

Registered:
05-27-2015

I have seen multiple times the same question in the forum and the proposed suggestions to resolve it but I was unable to get it done with the suggestions. So, that's why I asked another question about it.

I tried to synthesize in Vivado without using DSPs (by changing max_dsp flag in synthesis settings) but even there it was unable to do it.

Regards,

Abdul

debrajr

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-09-2015 11:20 PM

20,285 Views

Registered:
04-17-2011

In this particular case for DIM = 10, making some minor changes removed all the DSP's with RESOURCE directive.

As this is a floating point operation, the operations which inferred the DSP were fmul & fAddSub.

Try this below:

void matrix_multiply_hw(float mat_in1[10][10], float mat_in2[10][10], float mat_out[10][10])

{

#pragma HLS INLINE off

float sum = 0;

float temp;

#pragma HLS RESOURCE variable=temp core=FMul_nodsp

#pragma HLS RESOURCE variable=sum core=FAddSub_nodsp

// matrix multiplication of a A*B matrix

L1: for (int y = 0; y < 10; y++)

L2: for (int x = 0; x < 10; x++)

{

L3: for (int i = 0; i < 10; i++)

temp = mat_in1[y][i] * mat_in2[i][x];

sum = sum + temp ;

mat_out[y][x] = sum;

}

return;

}

With this, no DSP were inferred as the Floating Point operations would be inferring No DSP.

Regards,

Debraj

----------------------------------------------------------------------------------------------

Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

----------------------------------------------------------------------------------------------

Debraj

----------------------------------------------------------------------------------------------

Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

----------------------------------------------------------------------------------------------

abdulparis

Contributor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-11-2015 03:44 AM

11,541 Views

Registered:
05-27-2015

Thank you very much. I am going to try and if it works, I will accept it as solution.

Regards,

Abdul