cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

yanmin950122
Journeyman III

Why my VGPRs Usage increases so fast when I use this assignment statement code in OpenCL?

if (condition) {*foundFlag = 1; dst[gid] = gid * crack_cnt + num; break; } 

This code is used in ending kernel funtion when password is found(2 AMD 7970 devices and OpenCL platform). *foundFlag is a pointer to a char value,defined in kernel funtion formal parameters as follows:

__global char * foundFlag, 

when I Comment * foundFlag = 1,the usage of VGPRs by CodeXL,only use 4 VGPRs Registers:Snipaste_2018-04-12_15-13-30.png

But when this line code running,the usage of VGPRs increase to 88 VGPRs Registers:

2.png

I guarantee that I just modified this line of code, and that foundFlag is only used here. I'm confused.If you can help me solve this problem I will be grateful.(0_0)

0 Likes
1 Reply
matszpk
Adept III

Very often OpenCL compiler just optimizes code and it removes obsolete code from final program and finally generates code that does nothing. Very likely in your case, this last line uses all work of the rest (or almost this rest) your code for this kernel, and if this last line will be comment then compiler removes rest of a code your kernel generating kernel that does nothing. Or, just compiler (very unlikely) has the bug. By default, an OpenCL compiler uses some optimization while generating code.

0 Likes