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

How to solve data dependency problem?

Altera_Forum
Honored Contributor II
1,678 Views

After I compiled my kernel,I got the report as following: 

 

Block2: 

II bottleneck due to data dependency on variable(s): 

value (kernels.cl:42) 

Largest critical path contributor(s): 

64%: Floating Point Multiply Operation (kernels.cl:83) 

36%: Fadd Operation (kernels.cl:83)Block2: 

 

code is here:# define NUM 128# define M 512 

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

double A[NUM]; 

double B[NUM]; 

double Value[M+1]; 

for(int m=0;m<M;m++){ 

for (int n=0; n < M - m; n++) 

Value[n] =A*value[n] + b*Value[n+1]; 

}  

 

There are nested loops and data dependency in the code,How to optimize it?Can anyone give me some advise?Thanks so much
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
455 Views

Your code does not make much sense to me, it is just overwriting Value[n] and your computation does not depend on "m". Are you sure you are not forgetting a "+" before "="? Furthermore, your inner loop is not pipelineable due to variable exit condition.

0 Kudos
Altera_Forum
Honored Contributor II
455 Views

"m" is only used in the loop exit condition, and I want to get the final "Value[0]"

0 Kudos
Altera_Forum
Honored Contributor II
455 Views

Well, either way, your loop on "m" is unpipelineable the way it is. You should either merge the loops on "m" and "n" into one loop, or convert your kernel to NDRange with both "m" and "n" absorbed into the thread dimensions, and let the runtime scheduler handle the job of minimizing the pipeline stalls/bubbles.

0 Kudos
Reply