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

Pragma Unroll with variable loop bound

Altera_Forum
Honored Contributor II
1,091 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
368 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. 

 

...
0 Kudos
Reply