<?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 malloc issue on more than one MIC in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/malloc-issue-on-more-than-one-MIC/m-p/996689#M28417</link>
    <description>&lt;P&gt;I have a source code:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include&amp;lt;offload.h&amp;gt;
#include&amp;lt;stdio.h&amp;gt;


int main() {
    int ndev = _Offload_number_of_devices();
    printf("Ndev = %d\n", ndev);
    void *u;
    for (int d = 0; d &amp;lt; ndev; d++) {
#pragma offload target(mic: d) nocopy(u)
        {
            u = malloc(1); // 1 is just for demo, it's actually nz*ny*nx in my application
            printf("u on %d is %x\n", d, u);
            fflush(0);
        }
    }


    for (int d = 0; d &amp;lt; ndev; d++) {
#pragma offload target(mic: d) nocopy(u)
        {
            printf("u on %d is %x\n", d, u);
            fflush(0);
        }
    }

    return 0;
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I have a server with 2 Intel Xeon Phi installed.&lt;/P&gt;

&lt;P&gt;I found an issue is the address of pointer u on device 0 is changed after the malloc on device 1&lt;/P&gt;

&lt;P&gt;Here is the output:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;Ndev = 2
u on 0 is ac000b30
u on 1 is 60000b30
u on 0 is 60000b30
u on 1 is 60000b30
&lt;/PRE&gt;

&lt;P&gt;Then any access operation on u in MIC(device 0) will get segfault as the pointer address is changed.&lt;/P&gt;

&lt;P&gt;Please help&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 19 Apr 2014 17:38:17 GMT</pubDate>
    <dc:creator>SKAL_H_</dc:creator>
    <dc:date>2014-04-19T17:38:17Z</dc:date>
    <item>
      <title>malloc issue on more than one MIC</title>
      <link>https://community.intel.com/t5/Software-Archive/malloc-issue-on-more-than-one-MIC/m-p/996689#M28417</link>
      <description>&lt;P&gt;I have a source code:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include&amp;lt;offload.h&amp;gt;
#include&amp;lt;stdio.h&amp;gt;


int main() {
    int ndev = _Offload_number_of_devices();
    printf("Ndev = %d\n", ndev);
    void *u;
    for (int d = 0; d &amp;lt; ndev; d++) {
#pragma offload target(mic: d) nocopy(u)
        {
            u = malloc(1); // 1 is just for demo, it's actually nz*ny*nx in my application
            printf("u on %d is %x\n", d, u);
            fflush(0);
        }
    }


    for (int d = 0; d &amp;lt; ndev; d++) {
#pragma offload target(mic: d) nocopy(u)
        {
            printf("u on %d is %x\n", d, u);
            fflush(0);
        }
    }

    return 0;
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I have a server with 2 Intel Xeon Phi installed.&lt;/P&gt;

&lt;P&gt;I found an issue is the address of pointer u on device 0 is changed after the malloc on device 1&lt;/P&gt;

&lt;P&gt;Here is the output:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;Ndev = 2
u on 0 is ac000b30
u on 1 is 60000b30
u on 0 is 60000b30
u on 1 is 60000b30
&lt;/PRE&gt;

&lt;P&gt;Then any access operation on u in MIC(device 0) will get segfault as the pointer address is changed.&lt;/P&gt;

&lt;P&gt;Please help&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Apr 2014 17:38:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/malloc-issue-on-more-than-one-MIC/m-p/996689#M28417</guid>
      <dc:creator>SKAL_H_</dc:creator>
      <dc:date>2014-04-19T17:38:17Z</dc:date>
    </item>
    <item>
      <title>This is a defect with data</title>
      <link>https://community.intel.com/t5/Software-Archive/malloc-issue-on-more-than-one-MIC/m-p/996690#M28418</link>
      <description>&lt;P&gt;This is a defect with data persistence of a local variable in the current (CXE 2013 SP1) release that is fixed in the next major release planned for later this year. It is related to an earlier discussion &lt;A href="https://software.intel.com/en-us/forums/topic/393649" target="_blank"&gt;&lt;STRONG&gt;here&lt;/STRONG&gt;&lt;/A&gt;.&lt;BR /&gt;
	You can work around this by temporarily using static as in:&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp; __declspec(target (mic)) static void *u;&lt;BR /&gt;
	The Beta program for the next major release is currently underway. If you interested in participating in our Beta program, please refer to the invitation posted in our User Forum:&lt;A href="https://software.intel.com/en-us/forums/topic/509641" target="_blank"&gt;&lt;STRONG&gt; Invitation to join the Intel® Software Development Tools 2015 Beta program&lt;/STRONG&gt;&lt;/A&gt;&lt;BR /&gt;
	Our apologies for the inconvenience of this defect.&lt;BR /&gt;
	(Internal tracking id: DPD200245213)&lt;/P&gt;</description>
      <pubDate>Sun, 20 Apr 2014 10:36:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/malloc-issue-on-more-than-one-MIC/m-p/996690#M28418</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-04-20T10:36:59Z</dc:date>
    </item>
  </channel>
</rss>

