<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        color:black;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="ZH-CN" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi
</span><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Anastasia,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks for your detailed explanation.</span><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D"> Using
 zero is OK enough to solve the issue.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">So, when Clang do semantic check, 0 is interpreted as integer instead of null pointer?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">I previously thought Clang treat 0 as null pointer here directly, which it is finally transformed into.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">BTW, in C language, NULL may be defined as 0 or (void*)0 in different implementation.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">Ruiling<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> Anastasia Stulova [mailto:anastasia.stulova@arm.com]
<br>
<b>Sent:</b> Friday, February 13, 2015 6:23 PM<br>
<b>To:</b> 'Sameer Sahasrabuddhe'; Song, Ruiling<br>
<b>Cc:</b> cfe-dev@cs.uiuc.edu<br>
<b>Subject:</b> RE: Got compile error 'comparison between non-overlapping address spaces' on 3.6 branch<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Ruiling,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I agree with Sameer, in general in CL2.0 your example will have a comparison between global and generic address spaces, which is allowed.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">However, for all CL versions Clang still uses private as default address space of pointers. Some time ago, I’ve sent a patch changing this to comply
 with CL2.0 rules. My patch wasn’t complete though, because default address space rules are a bit more complex, i.e. program scope pointers should have global address space as default and all other pointers generic. I will see if I can find time to rework this
 patch.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">In  the meantime, would this be sufficient for you:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#define NULL 0<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">This will result in the comparison between a pointer and an integer literal, which is allowed in OpenCL. Also this is the only solution for CL
 earlier than v2.0.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Anastasia<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> Sameer Sahasrabuddhe [<a href="mailto:sameer.sahasrabuddhe@amd.com">mailto:sameer.sahasrabuddhe@amd.com</a>]
<br>
<b>Sent:</b> 13 February 2015 06:17<br>
<b>To:</b> Song, Ruiling; Anastasia Stulova<br>
<b>Cc:</b> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: Got compile error 'comparison between non-overlapping address spaces' on 3.6 branch<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US"><br>
Hello Ruiling,<br>
<br>
As far as I can see, the C spec defines the literal "0" as the null pointer, so the following macro seems better:<br>
<br>
#define NULL 0<br>
<br>
But ignoring the NULL, I think the behaviour might change between OpenCL 1.2 and OpenCL 2.0. In CL12, the "void *" is likely to be a pointer to the private address space. In that case, the comparison is undefined. In CL20, it is likely to be a pointer to the
 generic address space, and it should be allowed by the frontend. (Because generic address space includes global address space).<br>
<br>
I have to use words like "should" and "likely to" because this needs confirmation from language lawyers ... the question actually pushes the boundaries of how much I understand the details of OpenCL! :)<br>
<br>
Sameer.<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US">On 2/13/2015 11:25 AM, Song, Ruiling wrote:<o:p></o:p></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt" id="mid_148B1B7A67D1C24B9EF0BE42EA4977062B7D75D8_SHSMSX101_ccr_corp_intel_com">
<pre><span lang="EN-US">Hi Sameer, Anastasia,<o:p></o:p></span></pre>
<pre><span lang="EN-US"><o:p> </o:p></span></pre>
<pre><span lang="EN-US">Do you have any comment on this? Thanks!<o:p></o:p></span></pre>
<pre><span lang="EN-US"><o:p> </o:p></span></pre>
<pre><span lang="EN-US">Ruiling<o:p></o:p></span></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt" id="Cite_2351749">
<pre><span lang="EN-US">-----Original Message-----<o:p></o:p></span></pre>
<pre><span lang="EN-US">From: Song, Ruiling<o:p></o:p></span></pre>
<pre><span lang="EN-US">Sent: Wednesday, February 11, 2015 10:38 AM<o:p></o:p></span></pre>
<pre><span lang="EN-US">To: '<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>'<o:p></o:p></span></pre>
<pre><span lang="EN-US">Subject: Got compile error 'comparison between non-overlapping address<o:p></o:p></span></pre>
<pre><span lang="EN-US">spaces' on 3.6 branch<o:p></o:p></span></pre>
<pre><span lang="EN-US"><o:p> </o:p></span></pre>
<pre><span lang="EN-US">I am a developer working on Beignet (OpenCL driver for Intel Graphics card).<o:p></o:p></span></pre>
<pre><span lang="EN-US">I am trying Clang 3.6 branch, and encounter below problem. It works well in<o:p></o:p></span></pre>
<pre><span lang="EN-US">older clang version.<o:p></o:p></span></pre>
<pre><span lang="EN-US">We define NULL as "#define NULL (void *)0", so user could directly use it in<o:p></o:p></span></pre>
<pre><span lang="EN-US">OpenCL language like __kernel void test(__global unsigned int *dst)<o:p></o:p></span></pre>
<pre><span lang="EN-US">   if (dst != NULL) {do something;}<o:p></o:p></span></pre>
<pre><span lang="EN-US">}<o:p></o:p></span></pre>
<pre><span lang="EN-US">But I got below error when compiling using clang 3.6.<o:p></o:p></span></pre>
<pre><span lang="EN-US">"error: comparison between  ('__global unsigned int *' and 'void *') which<o:p></o:p></span></pre>
<pre><span lang="EN-US">are pointers to non-overlapping address spaces"<o:p></o:p></span></pre>
<pre><span lang="EN-US"><o:p> </o:p></span></pre>
<pre><span lang="EN-US">Is this the expected behavior or a bug?<o:p></o:p></span></pre>
<pre><span lang="EN-US"><o:p> </o:p></span></pre>
<pre><span lang="EN-US">Thanks!<o:p></o:p></span></pre>
<pre><span lang="EN-US">Ruiling<o:p></o:p></span></pre>
</blockquote>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</div>
</body>
</html>