Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
15471 Discussions

Pragma Unroll with variable loop bound

Altera_Forum
Honored Contributor II
861 Views

Is it compulsory for the loop bound to be constant for unrolling? 

 

Would the below kernel generate 50 times hw replication? What will happen if host sets the k = 60?  

 

 

__kernel 

__attribute__((task)) 

void test_multiplier(global char *restrict in, global char *restrict weights, global int *restrict out, int k) { 

 

 

int output = 0; 

#pragma unroll 50 

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

output += in * weights

}
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
138 Views

 

--- Quote Start ---  

Is it compulsory for the loop bound to be constant for unrolling? 

--- Quote End ---  

 

No. However, for minimum area overhead and maximum performance, it is best if the loop bound is known at compile-time and is divisible by the unroll factor. 

 

 

--- Quote Start ---  

Would the below kernel generate 50 times hw replication? What will happen if host sets the k = 60?  

--- Quote End ---  

 

The compiler will create a pipeline that can process 50 iteration per clock by using more FPGA resources. If you set k = 60, then the pipeline will work for two clocks + pipeline latency; nothing will go wrong, just the pipeline utilization will be low in the last clock. 

 

...
Reply