<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Hi Stephen, in OpenCL* for CPU</title>
    <link>https://community.intel.com/t5/OpenCL-for-CPU/Integer-Overflow-AMD-and-Intel-difference/m-p/1089174#M4871</link>
    <description>&lt;P&gt;Hi Stephen,&lt;/P&gt;

&lt;P&gt;This looks like a bug in the compiler. Thanks for reporting! I will let the driver people know.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Dec 2015 02:27:51 GMT</pubDate>
    <dc:creator>Robert_I_Intel</dc:creator>
    <dc:date>2015-12-02T02:27:51Z</dc:date>
    <item>
      <title>Integer Overflow - AMD and Intel difference</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/Integer-Overflow-AMD-and-Intel-difference/m-p/1089173#M4870</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;This is my first OpenCL project so I might be doing something wrong but I am having a very strange issue.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Below is my kernel code:&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:;"&gt;__kernel void collatz(__global int* in, __global int* out)
{
    uint id = get_global_id(0);
    unsigned long n = (unsigned long)id;
    uint count = 0;

    while (n &amp;gt; 1) { 
        if (n % 2 == 0) {
            n = n / 2; 
        } else { 
            if(n == 1572066143) {
                printf("BEFORE - %lu\n", n);
                n = (3 * n) + 1; 
                printf("AFTER  - %lu\n", n);
             } else {
                 n = (3 * n) + 1; 
            }

       }

       count = count + 1;
    }

    out[id] = count;
}&lt;/PRE&gt;

&lt;P&gt;And here is the output:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;BEFORE - 1572066143
AFTER  - 421231134&lt;/PRE&gt;

&lt;P&gt;To me it looks as if the "n" variable is overflowing but I can't figure out why that is happening as it is a unsigned long.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The really strange thing is if I update the kernel to set the value of 'n' to 1572066143 then it works correctly.&lt;/P&gt;

&lt;PRE class="brush:;"&gt;__kernel void collatz(__global int* in, __global int* out)
{
    uint id = get_global_id(0);
    unsigned long n = (unsigned long)id;
    uint count = 0;

    while (n &amp;gt; 1) { 
        if (n % 2 == 0) {
            n = n / 2; 
        } else { 
            if(n == 1572066143) {
		n = 1572066143;
                printf("BEFORE - %lu\n", n);
                n = (3 * n) + 1; 
                printf("AFTER  - %lu\n", n);
             } else {
                 n = (3 * n) + 1; 
            }

       }

       count = count + 1;
    }

    out[id] = count;
}&lt;/PRE&gt;

&lt;P&gt;Output:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;BEFORE - 1572066143
AFTER  - 4716198430&lt;/PRE&gt;

&lt;P&gt;In addition if I run the exact same code on my AMD GPU then I get the correct value.&lt;/P&gt;

&lt;P&gt;Please let us know what Processor, Operating System, Graphics Driver Version, and Tool Version you are using:&lt;/P&gt;

&lt;P&gt;Processor: i5 4670K (HD Graphics 4600)&lt;BR /&gt;
	Operating System: Windows 10&lt;BR /&gt;
	Graphics Driver Version:&amp;nbsp;20.19.15.4300&lt;BR /&gt;
	Tool Version: Intel SDK for OpenCL&amp;nbsp;5.3.0.713&lt;/P&gt;

&lt;P&gt;I have attached a zip file containing the host and kernel code.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Any assistance would be great!&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
	Stephen&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;OL style="color: rgb(96, 96, 96); font-size: 13.008px; line-height: 19.512px;"&gt;
	&lt;LI&gt;If code is involved, it is great to create a small "Reproducer" sample and attach it to the message in the form of a zip file&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sun, 29 Nov 2015 18:49:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/Integer-Overflow-AMD-and-Intel-difference/m-p/1089173#M4870</guid>
      <dc:creator>Stephen_H_4</dc:creator>
      <dc:date>2015-11-29T18:49:05Z</dc:date>
    </item>
    <item>
      <title>Hi Stephen,</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/Integer-Overflow-AMD-and-Intel-difference/m-p/1089174#M4871</link>
      <description>&lt;P&gt;Hi Stephen,&lt;/P&gt;

&lt;P&gt;This looks like a bug in the compiler. Thanks for reporting! I will let the driver people know.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 02:27:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/Integer-Overflow-AMD-and-Intel-difference/m-p/1089174#M4871</guid>
      <dc:creator>Robert_I_Intel</dc:creator>
      <dc:date>2015-12-02T02:27:51Z</dc:date>
    </item>
  </channel>
</rss>

