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

About Loop Unrolling

Altera_Forum
Honored Contributor II
2,416 Views

Hi everyone, 

 

I am wondering if setting a unroll factor that is not multiple of loop count is OK in Altera OpenCL? 

 

For example:# pragma unroll 10 

for( int i = 0; i < n; i++){ 

... 

 

Here n is either a number not divisible by 10 (ex: 128) or not known at compilation time (ex: a variable passed in from host). I know this can be done on CPU or GPU but I am wondering if this will generate incorrect result or cause performance issues on FPGA. 

 

Thanks!
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
1,362 Views

No, this will work. Depending on whether the iterations are independent or not, you may get performance increase because essentially FPGA hardware of the loop will be replicated 10 times.

0 Kudos
Altera_Forum
Honored Contributor II
1,362 Views

Thank you for the reply! 

 

So basically during the last unrolled iteration, only the reminder (in my example 128%10 = 8) number of the FPGA datapath will be used and the rest (again in my example 10 - 8 = 2) of the datapath will be bypassed right? 

 

 

--- Quote Start ---  

No, this will work. Depending on whether the iterations are independent or not, you may get performance increase because essentially FPGA hardware of the loop will be replicated 10 times. 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
1,362 Views

 

--- Quote Start ---  

Thank you for the reply! 

 

So basically during the last unrolled iteration, only the reminder (in my example 128%10 = 8) number of the FPGA datapath will be used and the rest (again in my example 10 - 8 = 2) of the datapath will be bypassed right? 

--- Quote End ---  

 

 

Yes, this is correct.
0 Kudos
Altera_Forum
Honored Contributor II
1,362 Views

 

--- Quote Start ---  

Yes, this is correct. 

--- Quote End ---  

 

 

Thank you!
0 Kudos
Reply