<?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 Yes, it work! Thanks a lot! in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944550#M17916</link>
    <description>&lt;P&gt;Yes, it work! Thanks a lot!&lt;/P&gt;</description>
    <pubDate>Tue, 24 Dec 2013 14:10:00 GMT</pubDate>
    <dc:creator>Guangming_T_</dc:creator>
    <dc:date>2013-12-24T14:10:00Z</dc:date>
    <item>
      <title>Return pointer from MIC malloc</title>
      <link>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944548#M17914</link>
      <description>&lt;P&gt;In my project, I need to pass pointer among different offload functions. However, I do not want to use global variables. For example.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I want to allocate an array on accelerator in new_array function, and hope that it would return an address on accelerator side so that I could pass the address to the&amp;nbsp;next function&amp;nbsp;exe_array. But, the following codes do not work.&lt;/P&gt;

&lt;P&gt;Any solution to this case? Say again, I do not want to use global variables. Thanks!&lt;/P&gt;

&lt;P&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;
	#include &amp;lt;stdlib.h&amp;gt;&lt;/P&gt;

&lt;P&gt;void* new_array();&lt;BR /&gt;
	void exe_array(int *);&amp;nbsp;&lt;BR /&gt;
	int main()&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp; int i;&lt;BR /&gt;
	&amp;nbsp; int * p;&lt;BR /&gt;
	&amp;nbsp; p = new_array();&lt;BR /&gt;
	&amp;nbsp; exe_array(p);&lt;BR /&gt;
	&amp;nbsp; for(i=0;i&amp;lt;32;i++)&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; printf("p=%p: %d\n",&amp;amp;p&lt;I&gt;, p&lt;I&gt;);&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;#pragma offload target(mic) nocopy(p)&lt;BR /&gt;
	&amp;nbsp; free(p);&lt;BR /&gt;
	}&lt;/P&gt;

&lt;P&gt;void* new_array()&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp; int i;&lt;BR /&gt;
	&amp;nbsp; int *p;&amp;nbsp;&lt;BR /&gt;
	#pragma offload target(mic) nocopy(p)&lt;BR /&gt;
	&amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp; p=(int *) malloc(32*sizeof(int));&lt;BR /&gt;
	&amp;nbsp; for(i=0; i&amp;lt;32; i++)&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; p&lt;I&gt;=i;&lt;BR /&gt;
	&amp;nbsp; }&lt;BR /&gt;
	&amp;nbsp; return p;&lt;BR /&gt;
	}&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;void exe_array(int *p)&amp;nbsp;&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp; int i;&lt;BR /&gt;
	&amp;nbsp; #pragma offload target(mic) nocopy(p)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;
	&amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; for(i=0; i&amp;lt;32;i++)&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; p&lt;I&gt;=-1;&lt;BR /&gt;
	&amp;nbsp; }&lt;BR /&gt;
	}&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2013 03:28:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944548#M17914</guid>
      <dc:creator>Guangming_T_</dc:creator>
      <dc:date>2013-12-24T03:28:50Z</dc:date>
    </item>
    <item>
      <title>Maybe you want something like</title>
      <link>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944549#M17915</link>
      <description>&lt;P&gt;Maybe&amp;nbsp;you want something like this.&lt;/P&gt;

&lt;P&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;
	#include &amp;lt;stdlib.h&amp;gt;&lt;/P&gt;

&lt;P&gt;void* new_array();&lt;BR /&gt;
	void exe_array(void *);&lt;BR /&gt;
	&amp;nbsp;int main()&lt;BR /&gt;
	&amp;nbsp;{&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; int i;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; void * p;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; p = new_array();&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; exe_array(p);&lt;/P&gt;

&lt;P&gt;#pragma offload target(mic)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; free(p);&lt;BR /&gt;
	&amp;nbsp;}&lt;/P&gt;

&lt;P&gt;void* new_array()&lt;BR /&gt;
	&amp;nbsp;{&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; void *p;&lt;BR /&gt;
	&amp;nbsp;#pragma offload target(mic)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; p=malloc(32*sizeof(int));&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; int i;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; int* q=(int*)p;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; for(i=0; i&amp;lt;32; i++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; q&lt;I&gt;=i;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; return p;&lt;BR /&gt;
	&amp;nbsp;}&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;void exe_array(void *p)&lt;BR /&gt;
	&amp;nbsp;{&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; #pragma offload target(mic)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int* q=(int*)p;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0; i&amp;lt;32;i++)&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("%d ",q&lt;I&gt;);&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("\n");&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;
	&amp;nbsp;}&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2013 13:53:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944549#M17915</guid>
      <dc:creator>Gregg_S_Intel</dc:creator>
      <dc:date>2013-12-24T13:53:10Z</dc:date>
    </item>
    <item>
      <title>Yes, it work! Thanks a lot!</title>
      <link>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944550#M17916</link>
      <description>&lt;P&gt;Yes, it work! Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2013 14:10:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944550#M17916</guid>
      <dc:creator>Guangming_T_</dc:creator>
      <dc:date>2013-12-24T14:10:00Z</dc:date>
    </item>
    <item>
      <title>Greg,</title>
      <link>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944551#M17917</link>
      <description>&lt;P&gt;Greg,&lt;/P&gt;

&lt;P&gt;Is there a requirement that the copy of the pointer on the host be void*?&lt;/P&gt;

&lt;P&gt;I would imagine that it is not, however, use of void* will hinder your using the pointer unintentionally and would be good programming practice.&lt;/P&gt;

&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2013 15:35:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944551#M17917</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2013-12-24T15:35:35Z</dc:date>
    </item>
    <item>
      <title>Jim,</title>
      <link>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944552#M17918</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;

&lt;P&gt;I think we do have to use a void type&amp;nbsp;to get a pointer from the coprocessor.&lt;/P&gt;

&lt;P&gt;Gregg Skinner&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2013 19:52:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Return-pointer-from-MIC-malloc/m-p/944552#M17918</guid>
      <dc:creator>Gregg_S_Intel</dc:creator>
      <dc:date>2013-12-24T19:52:50Z</dc:date>
    </item>
  </channel>
</rss>

