<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:v = "urn:schemas-microsoft-com:vml" xmlns:o = 
"urn:schemas-microsoft-com:office:office" xmlns:st2 = 
"urn:schemas-microsoft-com:office:smarttags" xmlns:st1 = "Tencent"><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7601.18487"></HEAD>
<BODY>
<DIV><FONT size=2>
<DIV><FONT color=#0000ff size=2 face=Verdana>Any way to tell compiler I have no 
side effect for memory pointer p and I don't want to load it again?</FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV align=left>
<DIV align=left><FONT size=2 face=Verdana>
<HR style="WIDTH: 122px; HEIGHT: 2px" SIZE=2>
</FONT></DIV>
<DIV><FONT color=#c0c0c0><FONT size=2 face=Verdana>彭席汉</FONT></DIV>
<DIV><FONT size=2 face=Verdana>2015-02-12</FONT></FONT></DIV></DIV>
<DIV><FONT size=2 face=Verdana>
<HR>
</FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>发件人:</STRONG> Zhigang 
Gong</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>发送时间:</STRONG> 
2015-02-12 17:14:36</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>收件人:</STRONG> Song, 
Ruiling</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>抄送:</STRONG> 
beignet@lists.freedesktop.org; 
彭席汿peng_xihan@dahuatech.com></FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>主题:</STRONG> Re: [Beignet] a 
question about default optimize option when building</FONT></FONT></DIV>
<DIV><FONT size=2 face=Verdana></FONT> </DIV>
<DIV><FONT size=2 face=Verdana>
<DIV>Some additional analysis based on ruiling's comment.</DIV>
<DIV> </DIV>
<DIV>The second load from p(to calculate res2) may or may not be issued.</DIV>
<DIV>It depends on whether there are some side effect instructions between</DIV>
<DIV>res1 and res2's assignment. For example, if there is a store instruction</DIV>
<DIV>or there is a barrier, the second load will be issued and you will see</DIV>
<DIV>two loads for the same pointer in the final instruction stream.</DIV>
<DIV> </DIV>
<DIV>As to the a * b + c*d, it will always be optimized and be reused when</DIV>
<DIV>calculate for res2 which means at the res2 assignment it will only</DIV>
<DIV>generate one add instruction to add the 1 to the previous calculated</DIV>
<DIV>value.</DIV>
<DIV> </DIV>
<DIV>On Thu, Feb 12, 2015 at 08:56:57AM +0000, Song, Ruiling wrote:</DIV>
<DIV>> It should not read global memory again. We already enable such kind of optimization pass in LLVM.</DIV>
<DIV>> And (a*b+c*d) should not calculate again. This is common-subexpression. Clang should do it easily. But I am not quite sure whether clang is affected by -O2 or -O0. Anyone know details?</DIV>
<DIV>> </DIV>
<DIV>> To check specific kernel. You may need to ‘export OCL_OUTPUT_LLVM_AFTER_GEN=1’ and build your program again to get the LLVM IR.</DIV>
<DIV>> </DIV>
<DIV>> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf Of 彭席汉</DIV>
<DIV>> Sent: Thursday, February 12, 2015 4:40 PM</DIV>
<DIV>> To: beignet@lists.freedesktop.org</DIV>
<DIV>> Subject: [Beignet] a question about default optimize option when building</DIV>
<DIV>> </DIV>
<DIV>> Hi:</DIV>
<DIV>> </DIV>
<DIV>> My CL kernel program looks like as follow:</DIV>
<DIV>> </DIV>
<DIV>> __global unsigned char *p;</DIV>
<DIV>> int a, b, c, d;</DIV>
<DIV>> </DIV>
<DIV>> res1 = *p * (a*b + c*d);</DIV>
<DIV>> </DIV>
<DIV>>  <some code here ></DIV>
<DIV>> </DIV>
<DIV>> res2 = *p * (a*b + c*d + 1);</DIV>
<DIV>> </DIV>
<DIV>> </DIV>
<DIV>> If I use default build option, for res2, what will EU do? read global memory for pointer p again and do computing of "a*b + c*d" again?</DIV>
<DIV> </DIV>
<DIV>> _______________________________________________</DIV>
<DIV>> Beignet mailing list</DIV>
<DIV>> Beignet@lists.freedesktop.org</DIV>
<DIV>> <A 
href="http://lists.freedesktop.org/mailman/listinfo/beignet">http://lists.freedesktop.org/mailman/listinfo/beignet</A></DIV>
<DIV> </DIV>
<DIV>_______________________________________________</DIV>
<DIV>Beignet mailing list</DIV>
<DIV>Beignet@lists.freedesktop.org</DIV>
<DIV><A 
href="http://lists.freedesktop.org/mailman/listinfo/beignet">http://lists.freedesktop.org/mailman/listinfo/beignet</A></DIV></FONT></DIV></FONT></DIV>
<DIV>= = = = = = = = = = = = = = = = = = = =</DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>        致<BR>礼!<BR>     </FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>           
<BR>               
 2015-02-12</FONT></DIV>
<DIV><FONT 
size=2>****************************************************************************************<BR>  </FONT><v:shape 
style="Z-INDEX: 1; POSITION: absolute; TEXT-ALIGN: left; MARGIN-TOP: 26.85pt; WIDTH: 54.4pt; HEIGHT: 15.95pt; MARGIN-LEFT: 63.4pt; LEFT: 0px" 
id=_x0000_s1027 type="#_x0000_t75"><v:imagedata o:title="logo" 
src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg"></v:imagedata></v:shape><v:shape 
style="Z-INDEX: 1; POSITION: absolute; TEXT-ALIGN: left; MARGIN-TOP: 26.85pt; WIDTH: 54.4pt; HEIGHT: 15.95pt; MARGIN-LEFT: 63.4pt; LEFT: 0px" 
id=_x0000_s1026 type="#_x0000_t75"><v:imagedata o:title="logo" 
src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg"><FONT 
size=2></FONT></v:imagedata></v:shape><FONT size=2></FONT><FONT size=2><IMG 
border=0 hspace=0 alt="" align=baseline src="cid:__0@Foxmail.net"> </DIV>
<DIV><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">
<DIV><FONT size=2><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">
<P style="TEXT-ALIGN: left; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan" 
class=MsoNormal align=left><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">   
公司名称:浙江大华技术股份有限公司<SPAN lang=EN-US><o:p></o:p></SPAN></P>
<P style="TEXT-ALIGN: left; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan" 
class=MsoNormal align=left><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" 
lang=EN-US>   ZheJiang Dahua Technology CO.,LTD.<o:p></o:p></SPAN></P>
<P style="TEXT-ALIGN: left; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan" 
class=MsoNormal align=left><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">   
地址:杭州滨江区滨安路<st1:RTX w:st="on"><SPAN lang=EN-US>1199</SPAN></st1:RTX>号</SPAN></P>
<P style="TEXT-ALIGN: left; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan" 
class=MsoNormal align=left><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">   
部门:存储产品线-NVR产品线</SPAN></P>
<DIV>
<P style="TEXT-ALIGN: left; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan" 
class=MsoNormal align=left><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">   
手机:18969076807</SPAN></P>
<P style="TEXT-ALIGN: left; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan" 
class=MsoNormal align=left><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">   </SPAN><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">邮政编码:<st1:RTX 
w:st="on"><SPAN lang=EN-US>3100</SPAN></st1:RTX><SPAN 
lang=EN-US>53<o:p></o:p></SPAN></SPAN></P>
<P style="TEXT-ALIGN: left; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan" 
class=MsoNormal align=left><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" 
lang=EN-US>   E-mail: <A 
href="mailto:peng_xihan@dahuatech.com">peng_xihan@dahuatech.com</A></SPAN></P>
<P style="TEXT-ALIGN: left; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan" 
class=MsoNormal align=left><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" 
lang=EN-US></SPAN><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" 
lang=EN-US>   Http: //www.dahuatech.com</SPAN><FONT 
size=2><BR></FONT></P></DIV>
<P style="TEXT-ALIGN: left; MARGIN: 0cm 0cm 0pt; mso-pagination: widow-orphan" 
class=MsoNormal align=left></SPAN></SPAN><SPAN 
style="FONT-FAMILY: 宋体; FONT-SIZE: 10pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体" 
lang=EN-US></SPAN></FONT></SPAN></FONT><FONT 
size=2>******************************************************************************************</FONT></P></DIV></DIV></BODY></HTML>