<?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   in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002733#M30792</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks Kevin .&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I was looking for the same explanation .&lt;BR /&gt;
	What I understood is the increasing the defined limit would help me to run the code correct.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Apr 2014 09:16:34 GMT</pubDate>
    <dc:creator>chavhan__hitesh</dc:creator>
    <dc:date>2014-04-30T09:16:34Z</dc:date>
    <item>
      <title>Runtime error with Offload</title>
      <link>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002726#M30785</link>
      <description>&lt;P style="FONT-SIZE: 12px"&gt;HOST--ERROR:myoiOSSetPageAccess: mprotect failed!&lt;/P&gt;

&lt;P style="FONT-SIZE: 12px"&gt;&amp;nbsp;Please increase the maximum of memory map areas&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i.e. echo 256000 &amp;gt; /proc/sys/vm/max_map_count&lt;BR /&gt;
	offload error: process on the device 0 unexpectedly exited with code 1&lt;BR /&gt;
	HOST--ERROR:myoiThreadMutexDestroy1: Fail to destroy a mutex (0x18762b8)! error: 16&lt;BR /&gt;
	HOST--ERROR:myoiOSDetachSharedMemory: shmdt failed: Invalid argument&lt;BR /&gt;
	HOST--ERROR:myoiOSDetachSharedMemory: shmdt failed: Invalid argument&lt;BR /&gt;
	HOST--ERROR:myoiOSDestroySharedMemory: shmctl failed: Invalid argument&lt;BR /&gt;
	HOST--ERROR:myoiOSDetachSharedMemory: shmdt failed: Invalid argument&lt;BR /&gt;
	HOST--ERROR:myoiOSDetachSharedMemory: shmdt failed: Invalid argument&lt;BR /&gt;
	HOST--ERROR:myoiOSDestroySharedMemory: shmctl failed: Invalid argument&lt;BR /&gt;
	HOST--ERROR:myoiOSDetachSharedMemory: shmdt failed: Invalid argument&lt;BR /&gt;
	HOST--ERROR:myoiOSDetachSharedMemory: shmdt failed: Invalid argument&lt;BR /&gt;
	HOST--ERROR:myoiOSDestroySharedMemory: shmctl failed: Invalid argument&lt;BR /&gt;
	HOST--ERROR:myoiOSDetachSharedMemory: shmdt failed: Invalid argument&lt;BR /&gt;
	HOST--ERROR:myoiOSDetachSharedMemory: shmdt failed: Invalid argument&lt;/P&gt;

&lt;P style="FONT-SIZE: 12px"&gt;Receiving this message when I try to offload the code using _Cilk_shared .&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 06:49:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002726#M30785</guid>
      <dc:creator>chavhan__hitesh</dc:creator>
      <dc:date>2014-04-28T06:49:02Z</dc:date>
    </item>
    <item>
      <title>Hitesh,</title>
      <link>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002727#M30786</link>
      <description>&lt;P&gt;Hitesh,&lt;/P&gt;

&lt;P&gt;Is this the same code you were having trouble with in&amp;nbsp;https://software.intel.com/en-us/forums/topic/507144?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 22:42:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002727#M30786</guid>
      <dc:creator>Frances_R_Intel</dc:creator>
      <dc:date>2014-04-28T22:42:36Z</dc:date>
    </item>
    <item>
      <title>I believe it is Frances.</title>
      <link>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002728#M30787</link>
      <description>&lt;P&gt;I believe it is Frances.&lt;BR /&gt;
	Hitesh - Have you tried increasing the &lt;STRONG&gt;max_map_count &lt;/STRONG&gt;as suggested in the diagnostics you received and rerunning your app?&lt;BR /&gt;
	This needs to be done on the coprocessor. Perhaps under your configuration you can easily ssh as root to the card and do the following:&lt;BR /&gt;
	[root@-mic0 ~]# cat /proc/sys/vm/max_map_count&lt;BR /&gt;
	65530&lt;BR /&gt;
	[root@-mic0 ~]# echo 256000 &amp;gt; /proc/sys/vm/max_map_count&lt;BR /&gt;
	[root@-mic0 ~]# cat /proc/sys/vm/max_map_count&lt;BR /&gt;
	256000&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2014 23:48:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002728#M30787</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-04-28T23:48:00Z</dc:date>
    </item>
    <item>
      <title>Based on advice from others,</title>
      <link>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002729#M30788</link>
      <description>&lt;P&gt;Based on advice from others, you must increase the max_map_count on &lt;STRONG&gt;both &lt;/STRONG&gt;the host and coprocessor. Changing it only on the coprocessor will not help.&lt;BR /&gt;
	Also, 256000 may be a good start; however, may not be large enough if you have GBs of data.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2014 09:33:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002729#M30788</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-04-29T09:33:43Z</dc:date>
    </item>
    <item>
      <title> </title>
      <link>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002730#M30789</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;thanks for the update.&lt;/P&gt;

&lt;P&gt;I don't have root privileges on the system . But I would ask system Admin to look at it.&lt;/P&gt;

&lt;P&gt;I want to know why I am receiving the error for such a small code snippet ,inspite of having large memory of Xeon and Phi.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2014 10:59:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002730#M30789</guid>
      <dc:creator>chavhan__hitesh</dc:creator>
      <dc:date>2014-04-29T10:59:45Z</dc:date>
    </item>
    <item>
      <title>My apologies. I had not</title>
      <link>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002731#M30790</link>
      <description>&lt;P&gt;My apologies. I had not realized the thread Frances cited contained your code. I had not viewed it and mistook it for your more recent thread (https://software.intel.com/en-us/forums/topic/509714) that I helped with. Let me ask about your smaller reproducer.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2014 13:42:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002731#M30790</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-04-29T13:42:59Z</dc:date>
    </item>
    <item>
      <title>I was able to run your</title>
      <link>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002732#M30791</link>
      <description>&lt;P&gt;I was able to run your program following the advice/help received from others. The details are below.&lt;BR /&gt;
	First, regarding the original failure, I was advised that the portion of the error shown below represents the typical error signature when an app exhausts the virtual shared memory space:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;HOST--ERROR:myoiOSSetPageAccess: mprotect failed!
Please increase the maximum of memory map areas
        i.e. echo 256000 &amp;gt; /proc/sys/vm/max_map_count&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
	Next, the default &lt;STRONG&gt;max_map_count &lt;/STRONG&gt;is (currently) low on the coprocessor and also it changes between versions of RHEL on the host. The default setting on my RHEL6.2 system was 65530. The MPSS Development team recommends setting this as high as 10000000.&lt;BR /&gt;
	The source code in your first post that Frances cited produces multiple compile-time warnings (an example is shown below) about a1, b1, and c1.&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;$ icpc -openmp test.cpp
test.cpp(64): warning #2707: pointer argument in _Cilk_offload function call is not pointer-to-shared
      _Cilk_offload_to(1) foo(thrd, nx, nz, bx, bz, halfLength,  a1,  b1,  c1);
                                                                 ^&lt;/PRE&gt;

&lt;P&gt;The following code contains corrections from Development to fix those warnings.&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include &amp;lt;stdio.h&amp;gt;
#include "omp.h"
#include &amp;lt;cilk/cilk.h&amp;gt;
#include &amp;lt;cilk/cilk_api.h&amp;gt;
#include "offload.h"

#define SQUARE(i) i*i
#define mina(a,b) (((a)&amp;lt;(b)) ? (a) : (b))

//_Cilk_shared int  foo(int, int, int, int, int, int, float _Cilk_shared  ** a , float _Cilk_shared ** b, float _Cilk_shared ** c );
 _Cilk_shared int  foo(int, int, int, int, int, int, float *_Cilk_shared  * a , float *_Cilk_shared * b, float *_Cilk_shared * c );


float *_Cilk_shared * a1;
float *_Cilk_shared * b1;
float *_Cilk_shared * c1;

int main(int argc, char* argv[])
{
    /*printf("before the code "); */

    int i,j,bx,bz,halfLength;
     int nx,nz,ITER;
     int thrd;

    halfLength=2;
    nx=14000+halfLength*2;
    nz=3600+halfLength*2;

    if(argc &amp;lt; 2)
    {
        printf("Error !!! Give number of threads to be spawned . \n");
        exit(-1);
    }

    sscanf(argv[1],"%d",&amp;amp;thrd);
    sscanf(argv[2],"%d",&amp;amp;bx);
    sscanf(argv[3],"%d",&amp;amp;bz);
    /*printf("%s %d \n",__FILE__,__LINE__);*/


    /*-----------------------------Aligned memory allocation-------------------------------------------------------*/
     a1=(float  *_Cilk_shared *)_Offload_shared_aligned_malloc(sizeof(float *)*nx,64);
     b1=(float  *_Cilk_shared *)_Offload_shared_aligned_malloc(sizeof(float*)*nx,64);
     c1=(float  *_Cilk_shared *)_Offload_shared_aligned_malloc(sizeof(float*)*nx,64);

    for( i=0;i&amp;lt;nx;i++)
    {
        a1&lt;I&gt;=(float  _Cilk_shared *)_Offload_shared_aligned_malloc(sizeof (float)*nz,64);
        b1&lt;I&gt;=(float  _Cilk_shared *)_Offload_shared_aligned_malloc(sizeof (float)*nz,64);
        c1&lt;I&gt;=(float  _Cilk_shared *)_Offload_shared_aligned_malloc(sizeof (float)*nz,64);
    }

    #pragma omp parallel for private(i,j)
    for(i=0;i&amp;lt;nx;i++)
    {
        for(j=0;j&amp;lt;nz;j++)
        {
            a1&lt;I&gt;&lt;J&gt;=2.0f;
            b1&lt;I&gt;&lt;J&gt;=2.0f;
            c1&lt;I&gt;&lt;J&gt;=2.0f;
        }
    }

    _Cilk_offload_to(1) foo(thrd, nx, nz, bx, bz, halfLength,  a1,  b1,  c1);

    for(i=0;i&amp;lt;nx;i++){
    _Offload_shared_aligned_free(a1&lt;I&gt;);
    _Offload_shared_aligned_free(b1&lt;I&gt;);
    _Offload_shared_aligned_free(c1&lt;I&gt;);
        }

_Offload_shared_aligned_free(a1);
_Offload_shared_aligned_free(b1);
_Offload_shared_aligned_free(c1);

return 0;
}

/*-----------------------------------------------------------------------------------------------------------------------*/
_Cilk_shared  int foo(int thrd, int nx, int nz, int bx, int bz, int halfLength, float *_Cilk_shared *  a, float * _Cilk_shared  *  b, float * _Cilk_shared * c)
{
 int ii,jj,i,j;

   printf("total thread=%d",thrd);

    __assume_aligned(a,64);
    __assume_aligned(b,64);
    __assume_aligned(c,64);

    omp_set_num_threads(thrd);

    #pragma omp parallel for  private (ii,jj,i,j) schedule(dynamic,1)
    for(ii=2;ii&amp;lt;nx-halfLength*2;ii+=bx)
    {
        for(jj=2;jj&amp;lt;nz-halfLength*2;jj+=bz)
        {
            for(i=ii;i&amp;lt;mina(bx+ii,nx-halfLength);++i)
            {
                #pragma simd
                for(j=jj;j&amp;lt;mina(bz+jj,nz-halfLength);++j)
                {
                    a&lt;I&gt;&lt;J&gt; =b&lt;I&gt;&lt;J&gt;+c&lt;I&gt;&lt;J&gt;;
                }
            }
        }
    }

return 0;
}&lt;/J&gt;&lt;/I&gt;&lt;/J&gt;&lt;/I&gt;&lt;/J&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/J&gt;&lt;/I&gt;&lt;/J&gt;&lt;/I&gt;&lt;/J&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;For your case with dimensions 14000 and 3600, it was necessary to increase the available virtual shared memory by increasing the &lt;STRONG&gt;max_map_count&lt;/STRONG&gt; on both the host and coprocessor.&lt;BR /&gt;
	The source code above runs successfully when performing the actions listed below (NOTE: I guessed at the input parameters shown and found other values seemed to work also). Steps 1 and 2 are one-time only changes following any reboot.&lt;BR /&gt;
	1. On the coprocessor (as root), increase max_map_count&lt;BR /&gt;
	&lt;STRONG&gt;echo 10000000 &amp;gt; /proc/sys/vm/max_map_coun&lt;/STRONG&gt;t&lt;BR /&gt;
	2. On the host (as root), check the current value and increase max_map_count accordingly&lt;BR /&gt;
	&lt;STRONG&gt;cat /proc/sys/vm/max_map_count&lt;BR /&gt;
	echo 10000000 &amp;gt; /proc/sys/vm/max_map_count&lt;/STRONG&gt;&lt;BR /&gt;
	3. Compile and run&lt;BR /&gt;
	&lt;STRONG&gt;icpc -openmp test.cpp&lt;BR /&gt;
	./a.out 240 80 80&lt;/STRONG&gt;&lt;BR /&gt;
	Without the settings in steps 1 and 2 above, the code suffers the run-time error you noted:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;./a.out 240 80 80
HOST--ERROR:myoiOSSetPageAccess: mprotect failed!
Please increase the maximum of memory map areas
        i.e. echo 256000 &amp;gt; /proc/sys/vm/max_map_count
offload error: process on the device 0 unexpectedly exited with code 1
HOST--ERROR:myoiThreadMutexDestroy1: Fail to destroy a mutex (0x10cbb08)! error: 16
HOST--ERROR:myoiOSDetachSharedMemory: shmdt failed: Invalid argument
&amp;lt;…many more removed….&amp;gt;&lt;/PRE&gt;

&lt;P&gt;Finally, the current default value of &lt;STRONG&gt;max_map_count&lt;/STRONG&gt; may be increased in a future MPSS release.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2014 08:32:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002732#M30791</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-04-30T08:32:00Z</dc:date>
    </item>
    <item>
      <title> </title>
      <link>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002733#M30792</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thanks Kevin .&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I was looking for the same explanation .&lt;BR /&gt;
	What I understood is the increasing the defined limit would help me to run the code correct.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2014 09:16:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002733#M30792</guid>
      <dc:creator>chavhan__hitesh</dc:creator>
      <dc:date>2014-04-30T09:16:34Z</dc:date>
    </item>
    <item>
      <title>You're welcome. Did you need</title>
      <link>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002734#M30793</link>
      <description>&lt;P&gt;You're welcome.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2014 09:42:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Runtime-error-with-Offload/m-p/1002734#M30793</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2014-04-30T09:42:00Z</dc:date>
    </item>
  </channel>
</rss>

