<?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 Asynchronous data transfer does not work in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Asynchronous-data-transfer-does-not-work/m-p/1036820#M44320</link>
    <description>&lt;P&gt;I try to perform an asynchronous data transfer to an Intel Xeon Phi. Note that asynchronous computation works as expected. If I try to combine data transfer and computation (in an offload statement) timing indicates that the data transfer is done synchronously while the following computation is done asynchronously.&lt;/P&gt;

&lt;P&gt;A test example that illustrates the point is given below. The output is&amp;nbsp;&lt;BR /&gt;
	0.928997 0.288048&lt;BR /&gt;
	which indicates that almost a second is spend in the asynchronous call while only 0.28 seconds are spend in waiting for that asynchronous call.&lt;/P&gt;

&lt;P&gt;Any help would be appreciated.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;iostream&amp;gt;
using namespace std;

#include "timer.hpp"

#define ALLOC   alloc_if(1)
#define FREE    free_if(1)
#define RETAIN  free_if(0)
#define REUSE   alloc_if(0)

int main() {
    int n = 1000*1000*100;
    double *p = (double*)malloc(sizeof(double)*n);
    int rep = 10;

    #pragma offload target(mic:0) in(p:length(n) ALLOC RETAIN)
    {}

    timer t1, t2;
    for(int i=0;i&amp;lt;rep;i++) {
        t1.start();
        #pragma offload_transfer target(mic:0) out(p:length(n) REUSE RETAIN) signal(p)
        /* This works as expected 
        #pragma offload_transfer target(mic:0) signal(p)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { usleep(2e6); }
&amp;nbsp;       */
        t1.stop();

        t2.start();
        #pragma offload_transfer target(mic:0) wait(p)
        t2.stop();

    }

    cout &amp;lt;&amp;lt; t1.total() &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; t2.total() &amp;lt;&amp;lt; endl;

    #pragma offload target(mic:0) nocopy(p:length(n) REUSE FREE)
    {}

}&lt;/PRE&gt;

&lt;P&gt;The hardware seems to work properly&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;MicCheck 3.4.3-r1
Copyright 2013 Intel Corporation All Rights Reserved

Executing default tests for host
  Test 0: Check number of devices the OS sees in the system ... pass
  Test 1: Check mic driver is loaded ... pass
  Test 2: Check number of devices driver sees in the system ... pass
  Test 3: Check mpssd daemon is running ... pass
Executing default tests for device: 0
  Test 4 (mic0): Check device is in online state and its postcode is FF ... pass
  Test 5 (mic0): Check ras daemon is available in device ... pass
  Test 6 (mic0): Check running flash version is correct ... pass
  Test 7 (mic0): Check running SMC firmware version is correct ... pass

Status: OK&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jun 2015 12:06:56 GMT</pubDate>
    <dc:creator>Lukas_E_</dc:creator>
    <dc:date>2015-06-12T12:06:56Z</dc:date>
    <item>
      <title>Asynchronous data transfer does not work</title>
      <link>https://community.intel.com/t5/Software-Archive/Asynchronous-data-transfer-does-not-work/m-p/1036820#M44320</link>
      <description>&lt;P&gt;I try to perform an asynchronous data transfer to an Intel Xeon Phi. Note that asynchronous computation works as expected. If I try to combine data transfer and computation (in an offload statement) timing indicates that the data transfer is done synchronously while the following computation is done asynchronously.&lt;/P&gt;

&lt;P&gt;A test example that illustrates the point is given below. The output is&amp;nbsp;&lt;BR /&gt;
	0.928997 0.288048&lt;BR /&gt;
	which indicates that almost a second is spend in the asynchronous call while only 0.28 seconds are spend in waiting for that asynchronous call.&lt;/P&gt;

&lt;P&gt;Any help would be appreciated.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;iostream&amp;gt;
using namespace std;

#include "timer.hpp"

#define ALLOC   alloc_if(1)
#define FREE    free_if(1)
#define RETAIN  free_if(0)
#define REUSE   alloc_if(0)

int main() {
    int n = 1000*1000*100;
    double *p = (double*)malloc(sizeof(double)*n);
    int rep = 10;

    #pragma offload target(mic:0) in(p:length(n) ALLOC RETAIN)
    {}

    timer t1, t2;
    for(int i=0;i&amp;lt;rep;i++) {
        t1.start();
        #pragma offload_transfer target(mic:0) out(p:length(n) REUSE RETAIN) signal(p)
        /* This works as expected 
        #pragma offload_transfer target(mic:0) signal(p)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { usleep(2e6); }
&amp;nbsp;       */
        t1.stop();

        t2.start();
        #pragma offload_transfer target(mic:0) wait(p)
        t2.stop();

    }

    cout &amp;lt;&amp;lt; t1.total() &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; t2.total() &amp;lt;&amp;lt; endl;

    #pragma offload target(mic:0) nocopy(p:length(n) REUSE FREE)
    {}

}&lt;/PRE&gt;

&lt;P&gt;The hardware seems to work properly&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;MicCheck 3.4.3-r1
Copyright 2013 Intel Corporation All Rights Reserved

Executing default tests for host
  Test 0: Check number of devices the OS sees in the system ... pass
  Test 1: Check mic driver is loaded ... pass
  Test 2: Check number of devices driver sees in the system ... pass
  Test 3: Check mpssd daemon is running ... pass
Executing default tests for device: 0
  Test 4 (mic0): Check device is in online state and its postcode is FF ... pass
  Test 5 (mic0): Check ras daemon is available in device ... pass
  Test 6 (mic0): Check running flash version is correct ... pass
  Test 7 (mic0): Check running SMC firmware version is correct ... pass

Status: OK&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 12:06:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Asynchronous-data-transfer-does-not-work/m-p/1036820#M44320</guid>
      <dc:creator>Lukas_E_</dc:creator>
      <dc:date>2015-06-12T12:06:56Z</dc:date>
    </item>
    <item>
      <title>I'm not sure I understand</title>
      <link>https://community.intel.com/t5/Software-Archive/Asynchronous-data-transfer-does-not-work/m-p/1036821#M44321</link>
      <description>&lt;P&gt;I'm not sure I understand exactly what you are saying when you say: "If I try to combine data transfer and computation (in an offload statement) timing indicates that the data transfer is done synchronously while the following computation is done asynchronously." The example you give doesn't show any computations being done.&lt;/P&gt;

&lt;P&gt;In the section between t1.start() and t1.stop(), the first offload_transfer directive tells the compiler that you want to asynchronously transfer the array p from the coprocessor to the host. The second, commented out offload_transfer, tells the compiler that you want to transfer nothing. The offload_transfer directive does not cause any computation to be done on the coprocessor.&lt;/P&gt;

&lt;P&gt;Is the point you are making that the entire transfer of the array p seems to be occurring between t1:start() and t1.stop()?&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2015 15:24:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Asynchronous-data-transfer-does-not-work/m-p/1036821#M44321</guid>
      <dc:creator>Frances_R_Intel</dc:creator>
      <dc:date>2015-06-13T15:24:09Z</dc:date>
    </item>
    <item>
      <title>Yes the point is that the</title>
      <link>https://community.intel.com/t5/Software-Archive/Asynchronous-data-transfer-does-not-work/m-p/1036822#M44322</link>
      <description>&lt;P&gt;Yes the point is that the entire transfer of the array p occurs between t1.start() and t1.stop().&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;The second observation is that if I use (sorry for the confusion I meant to use offload not offload_transfer in the comments of my code)&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 12.727272033691406px;"&gt;t1.start();
#pragma offload target(mic:0) signal(p)
{ usleep(2e6); }
t1.stop();
&lt;/PRE&gt;

&lt;P&gt;The output of the program is&lt;BR /&gt;
	0.000119681 20.104&lt;BR /&gt;
	which means that indeed the computation is done asynchronously (this is the behavior I would expect).&lt;/P&gt;

&lt;P&gt;If I use&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 12.727272033691406px;"&gt;t1.start();
#pragma offload target(mic:0) out(p:length(n) REUSE RETAIN) signal(p)
{ usleep(2e6); }
t1.stop();&lt;/PRE&gt;

&lt;P&gt;The output of the program is&lt;BR /&gt;
	0.000212038 21.2975&lt;BR /&gt;
	which again means that the computation is done asynchronously (this is the behavior I would expect).&lt;/P&gt;

&lt;P&gt;However, If I use&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 12.727272033691406px;"&gt;t1.start();
#pragma offload target(mic:0) in(p:length(n) REUSE RETAIN) signal(p)
{ usleep(2e6); }
t1.stop();&lt;/PRE&gt;

&lt;P&gt;The output of the program is&lt;BR /&gt;
	0.897727 20.3981&lt;BR /&gt;
	which I believe means that first the transfer of p is done synchronously (between t1.start() and t1.stop()) while the following computation is done asynchronously (instead of doing the entire offload block asynchronously which is the behavior I would expect).&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2015 21:38:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Asynchronous-data-transfer-does-not-work/m-p/1036822#M44322</guid>
      <dc:creator>Lukas_E_</dc:creator>
      <dc:date>2015-06-13T21:38:50Z</dc:date>
    </item>
  </channel>
</rss>

