<?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 Get some problem with global variable declaration  in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Get-some-problem-with-global-variable-declaration/m-p/1016787#M6592</link>
    <description>&lt;P&gt;&lt;STRONG&gt;I try use an Intel PHI co-prococessor.But&amp;nbsp;i got some problem with global variable declaration .I decline A,B,C as global variable.But the value of them are equal。Turn out to be，A=5，B=5，C=5.And AA=30.The right AA must be 17.Try to get some help here.Thanks.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;
	#include &amp;lt;math.h&amp;gt;&lt;BR /&gt;
	#include &amp;lt;omp.h&amp;gt;&lt;BR /&gt;
	#pragma offload_attribute(push,target(mic))&lt;BR /&gt;
	float *A;&lt;BR /&gt;
	float *B;&lt;BR /&gt;
	float *C;&lt;BR /&gt;
	#pragma offload_attribute(pop)&lt;/P&gt;

&lt;P&gt;//__attribute__((target(mic))) float *A,*B,*C;&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	void noco (float *A,float *B,float *C,int j)&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp;int i;&lt;BR /&gt;
	#pragma offload target (mic)\&lt;BR /&gt;
	nocopy(A:length(j) alloc_if(1) free_if(0))\&lt;BR /&gt;
	nocopy(B:length(j) alloc_if(1) free_if(0))\&lt;BR /&gt;
	nocopy(C:length(j) alloc_if(1) free_if(0))&lt;BR /&gt;
	&amp;nbsp;for(i=0;i&amp;lt;j;i++)&lt;BR /&gt;
	&amp;nbsp;{&lt;BR /&gt;
	&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;A&lt;I&gt;=2;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;B&lt;I&gt;=3;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;C&lt;I&gt;=5;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;I&gt;&lt;I&gt;&lt;I&gt;&lt;BR /&gt;
	&amp;nbsp;}&lt;BR /&gt;
	}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;void add (float *A,float *B,float *C,float *AA,int j)&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp;int i;&lt;BR /&gt;
	#pragma offload target (mic)\&lt;BR /&gt;
	nocopy(A:length(j) alloc_if(0) free_if(1))\&lt;BR /&gt;
	nocopy(B:length(j) alloc_if(0) free_if(1))\&lt;BR /&gt;
	nocopy(C:length(j) alloc_if(0) free_if(1))\&lt;BR /&gt;
	out(AA:length(j) alloc_if(1) free_if(1))&lt;BR /&gt;
	&amp;nbsp;for(i=0;i&amp;lt;j;i++)&lt;BR /&gt;
	&amp;nbsp;{&lt;BR /&gt;
	&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;AA&lt;I&gt;=A&lt;I&gt;+B&lt;I&gt;*C&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;I&gt;&lt;I&gt;&lt;I&gt;&lt;I&gt;&lt;BR /&gt;
	&amp;nbsp;}&lt;BR /&gt;
	&amp;nbsp;&lt;BR /&gt;
	}&lt;BR /&gt;
	int main()&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp;float *AA =NULL;&lt;BR /&gt;
	&amp;nbsp;float j=11;&lt;BR /&gt;
	&amp;nbsp;AA = (float *) malloc(j*sizeof(float));&lt;BR /&gt;
	&amp;nbsp;noco(A,B,C,j);&lt;BR /&gt;
	&amp;nbsp;add(A,B,C,AA,j);&lt;BR /&gt;
	&amp;nbsp;printf("%f",AA[1]);&lt;BR /&gt;
	&amp;nbsp;return 0;&lt;BR /&gt;
	}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="QQ截图20150409213434.png"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/7447i7899D7C6E2B326EC/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="QQ截图20150409213434.png" alt="QQ截图20150409213434.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Apr 2015 13:58:16 GMT</pubDate>
    <dc:creator>哲_陈_</dc:creator>
    <dc:date>2015-04-09T13:58:16Z</dc:date>
    <item>
      <title>Get some problem with global variable declaration</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Get-some-problem-with-global-variable-declaration/m-p/1016787#M6592</link>
      <description>&lt;P&gt;&lt;STRONG&gt;I try use an Intel PHI co-prococessor.But&amp;nbsp;i got some problem with global variable declaration .I decline A,B,C as global variable.But the value of them are equal。Turn out to be，A=5，B=5，C=5.And AA=30.The right AA must be 17.Try to get some help here.Thanks.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;
	#include &amp;lt;math.h&amp;gt;&lt;BR /&gt;
	#include &amp;lt;omp.h&amp;gt;&lt;BR /&gt;
	#pragma offload_attribute(push,target(mic))&lt;BR /&gt;
	float *A;&lt;BR /&gt;
	float *B;&lt;BR /&gt;
	float *C;&lt;BR /&gt;
	#pragma offload_attribute(pop)&lt;/P&gt;

&lt;P&gt;//__attribute__((target(mic))) float *A,*B,*C;&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	void noco (float *A,float *B,float *C,int j)&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp;int i;&lt;BR /&gt;
	#pragma offload target (mic)\&lt;BR /&gt;
	nocopy(A:length(j) alloc_if(1) free_if(0))\&lt;BR /&gt;
	nocopy(B:length(j) alloc_if(1) free_if(0))\&lt;BR /&gt;
	nocopy(C:length(j) alloc_if(1) free_if(0))&lt;BR /&gt;
	&amp;nbsp;for(i=0;i&amp;lt;j;i++)&lt;BR /&gt;
	&amp;nbsp;{&lt;BR /&gt;
	&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;A&lt;I&gt;=2;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;B&lt;I&gt;=3;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp;C&lt;I&gt;=5;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;I&gt;&lt;I&gt;&lt;I&gt;&lt;BR /&gt;
	&amp;nbsp;}&lt;BR /&gt;
	}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;void add (float *A,float *B,float *C,float *AA,int j)&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp;int i;&lt;BR /&gt;
	#pragma offload target (mic)\&lt;BR /&gt;
	nocopy(A:length(j) alloc_if(0) free_if(1))\&lt;BR /&gt;
	nocopy(B:length(j) alloc_if(0) free_if(1))\&lt;BR /&gt;
	nocopy(C:length(j) alloc_if(0) free_if(1))\&lt;BR /&gt;
	out(AA:length(j) alloc_if(1) free_if(1))&lt;BR /&gt;
	&amp;nbsp;for(i=0;i&amp;lt;j;i++)&lt;BR /&gt;
	&amp;nbsp;{&lt;BR /&gt;
	&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;AA&lt;I&gt;=A&lt;I&gt;+B&lt;I&gt;*C&lt;I&gt;;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;I&gt;&lt;I&gt;&lt;I&gt;&lt;I&gt;&lt;BR /&gt;
	&amp;nbsp;}&lt;BR /&gt;
	&amp;nbsp;&lt;BR /&gt;
	}&lt;BR /&gt;
	int main()&lt;BR /&gt;
	{&lt;BR /&gt;
	&amp;nbsp;float *AA =NULL;&lt;BR /&gt;
	&amp;nbsp;float j=11;&lt;BR /&gt;
	&amp;nbsp;AA = (float *) malloc(j*sizeof(float));&lt;BR /&gt;
	&amp;nbsp;noco(A,B,C,j);&lt;BR /&gt;
	&amp;nbsp;add(A,B,C,AA,j);&lt;BR /&gt;
	&amp;nbsp;printf("%f",AA[1]);&lt;BR /&gt;
	&amp;nbsp;return 0;&lt;BR /&gt;
	}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="QQ截图20150409213434.png"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/7447i7899D7C6E2B326EC/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="QQ截图20150409213434.png" alt="QQ截图20150409213434.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2015 13:58:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Get-some-problem-with-global-variable-declaration/m-p/1016787#M6592</guid>
      <dc:creator>哲_陈_</dc:creator>
      <dc:date>2015-04-09T13:58:16Z</dc:date>
    </item>
    <item>
      <title>There is a specific moderated</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Get-some-problem-with-global-variable-declaration/m-p/1016788#M6593</link>
      <description>&lt;P&gt;There is a specific moderated forum for MIC, while you have no guarantee that the right people will see your questions on this apparently un-moderated forum.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2015 15:21:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Get-some-problem-with-global-variable-declaration/m-p/1016788#M6593</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2015-04-24T15:21:29Z</dc:date>
    </item>
  </channel>
</rss>

