<?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 File I/O within the Offload Region in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/File-I-O-within-the-Offload-Region/m-p/977187#M25280</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am trying to test the default code for "Performing File I/O on the Coprocessor" at the end of Chapter 7 in&amp;nbsp;&lt;STRONG&gt;Intel Xeon-Phi Coprocessor High Performance Programming&amp;nbsp;&lt;/STRONG&gt;by Jim Jefferies and James Reinders.&lt;/P&gt;

&lt;P&gt;The code is as follows:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;
#pragma offload_attribute(push,target(mic))
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#pragma offload_attribute(pop)
&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="line-height: 1.5; font-family: Consolas, 'Lucida Console', Menlo, Monaco, 'DejaVu Sans Mono', monospace, sans-serif; font-size: 1em"&gt;int main()&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
{
  FILE *fp;
  char buffer[7];
  #pragma offload target(mic) nocopy(fp)
  {
    fp =fopen("./proxyfs/myfile.txt","wb");
    if(fp==NULL)
    {  
      fprintf(stderr,"Failed to open myfile.txt for write\n");
      exit(1);
    }
    fwrite("Hello\n",1,7,fp);
    fclose(fp);
  }
  #pragma offload target(mic) nocopy(fp) out(buffer)
  {
    fp = fopen("./proxyfs/myfile.txt","rb");
    if(fp==NULL)
    {
      fprintf(stderr,"Failed to open myfile.txt for read\n");
      exit(1);
    }
    fread(buffer, 1, 7, fp);
    fclose(fp);
    if(strcmp(buffer, "Hello\n") != 0)
    {
      fprintf(stderr,"File incorrectly read back on coproc\n");
      exit(1);
    }
  }
  printf("%s", buffer);
  return 0;
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I set MIC_PROXY_FS_ROOT to a relevant location and set MIC_PROXY_IO = 1, just as stated in the book. &amp;nbsp;However, when I run the code, I get the first error:&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 13px"&gt;
"Failed to open myfile.txt for write"&lt;/PRE&gt;

&lt;P&gt;which means that the proxyfs directory is invalid.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Was the software changed so this method doesn't work anymore? &amp;nbsp;Or is there something wrong with the code?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2014 18:58:34 GMT</pubDate>
    <dc:creator>Guthrie_C_</dc:creator>
    <dc:date>2014-02-05T18:58:34Z</dc:date>
    <item>
      <title>File I/O within the Offload Region</title>
      <link>https://community.intel.com/t5/Software-Archive/File-I-O-within-the-Offload-Region/m-p/977187#M25280</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I am trying to test the default code for "Performing File I/O on the Coprocessor" at the end of Chapter 7 in&amp;nbsp;&lt;STRONG&gt;Intel Xeon-Phi Coprocessor High Performance Programming&amp;nbsp;&lt;/STRONG&gt;by Jim Jefferies and James Reinders.&lt;/P&gt;

&lt;P&gt;The code is as follows:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;
#pragma offload_attribute(push,target(mic))
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#pragma offload_attribute(pop)
&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="line-height: 1.5; font-family: Consolas, 'Lucida Console', Menlo, Monaco, 'DejaVu Sans Mono', monospace, sans-serif; font-size: 1em"&gt;int main()&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
{
  FILE *fp;
  char buffer[7];
  #pragma offload target(mic) nocopy(fp)
  {
    fp =fopen("./proxyfs/myfile.txt","wb");
    if(fp==NULL)
    {  
      fprintf(stderr,"Failed to open myfile.txt for write\n");
      exit(1);
    }
    fwrite("Hello\n",1,7,fp);
    fclose(fp);
  }
  #pragma offload target(mic) nocopy(fp) out(buffer)
  {
    fp = fopen("./proxyfs/myfile.txt","rb");
    if(fp==NULL)
    {
      fprintf(stderr,"Failed to open myfile.txt for read\n");
      exit(1);
    }
    fread(buffer, 1, 7, fp);
    fclose(fp);
    if(strcmp(buffer, "Hello\n") != 0)
    {
      fprintf(stderr,"File incorrectly read back on coproc\n");
      exit(1);
    }
  }
  printf("%s", buffer);
  return 0;
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I set MIC_PROXY_FS_ROOT to a relevant location and set MIC_PROXY_IO = 1, just as stated in the book. &amp;nbsp;However, when I run the code, I get the first error:&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 13px"&gt;
"Failed to open myfile.txt for write"&lt;/PRE&gt;

&lt;P&gt;which means that the proxyfs directory is invalid.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Was the software changed so this method doesn't work anymore? &amp;nbsp;Or is there something wrong with the code?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 18:58:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-I-O-within-the-Offload-Region/m-p/977187#M25280</guid>
      <dc:creator>Guthrie_C_</dc:creator>
      <dc:date>2014-02-05T18:58:34Z</dc:date>
    </item>
    <item>
      <title>Yes. There was an earlier</title>
      <link>https://community.intel.com/t5/Software-Archive/File-I-O-within-the-Offload-Region/m-p/977188#M25281</link>
      <description>&lt;P&gt;Yes, the software changed. There was an earlier inquiry on this&amp;nbsp;&lt;A href="http://software.intel.com/en-us/forums/topic/384829" target="_blank"&gt;here &lt;/A&gt;that might help.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 19:15:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-I-O-within-the-Offload-Region/m-p/977188#M25281</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-02-05T19:15:00Z</dc:date>
    </item>
    <item>
      <title>Wow, the code did not show up</title>
      <link>https://community.intel.com/t5/Software-Archive/File-I-O-within-the-Offload-Region/m-p/977189#M25282</link>
      <description>&lt;P&gt;Wow, the code did not show up as expected. However you still seem to understand the issue.&lt;/P&gt;

&lt;P&gt;So I would need to mount the file via NFS to be able to access it in the offload region? &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 19:24:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-I-O-within-the-Offload-Region/m-p/977189#M25282</guid>
      <dc:creator>Guthrie_C_</dc:creator>
      <dc:date>2014-02-05T19:24:56Z</dc:date>
    </item>
    <item>
      <title>Yes, NFS is the recommended</title>
      <link>https://community.intel.com/t5/Software-Archive/File-I-O-within-the-Offload-Region/m-p/977190#M25283</link>
      <description>&lt;P&gt;Yes, NFS is the recommended option. Just to be clear, one can put files on the card into are area like /tmp and read/write them locally also (assuming the user environment permits the user such access). The caution with&amp;nbsp;putting files on the card&amp;nbsp;is that it impacts&amp;nbsp;available memory as the uOS runs via a ramdisk.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2014 19:39:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/File-I-O-within-the-Offload-Region/m-p/977190#M25283</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-02-05T19:39:51Z</dc:date>
    </item>
  </channel>
</rss>

