<?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 MPI_Recv block a long time in Intel® MPI Library</title>
    <link>https://community.intel.com/t5/Intel-MPI-Library/MPI-Recv-block-a-long-time/m-p/1040852#M4300</link>
    <description>&lt;P&gt;hello:&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;I get into trouble when use MPI_Recv in my programmes.&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;My programme start 3 subprocess,and bind them to cpu 1-3 respectively.&amp;nbsp;In each subprocess, first disabled interrupts , then send message to other process and receive from others. Repeat it a billion times.&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;I except that MPI_Recv will return in a fixed times ,and not use MPI_irecv instead.&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;In order to do that, i disabled interrupts and cancel ticks on cpu1-3,remove other process from cpu 1-3 to cpu 0,and bind interrupts to cpu0.&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; But I found that a very few times(about a billion times may happen 1 times) the MPI_Recv will block for more than 600 ms, but normally the MPI_Recv only take less than 10ms.&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;I don't know why the &amp;nbsp;MPI_Recv some times block so long,is there any method to find the reason and solve the problem?&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp;Use mpirun -n 3 to execute the&amp;nbsp;programmes, use&amp;nbsp;Hydra and&amp;nbsp;Shared memory fabrics.&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp;environment :&amp;nbsp;&amp;nbsp; &amp;nbsp;parallel_studio_xe_2015_update2 &amp;nbsp;linux 3.10&amp;nbsp;&lt;BR /&gt;
	===== &amp;nbsp;Processor composition &amp;nbsp;=====&lt;BR /&gt;
	Processor name &amp;nbsp; &amp;nbsp;: Intel(R) Core(TM) i5-4590 &amp;nbsp;&lt;BR /&gt;
	Packages(sockets) : 1&lt;BR /&gt;
	Cores &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : 4&lt;BR /&gt;
	Processors(CPUs) &amp;nbsp;: 4&lt;BR /&gt;
	Cores per package : 4&lt;BR /&gt;
	Threads per core &amp;nbsp;: 1&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;void emt_comm()
{
    ......
    for (i=0; i&amp;lt;ProcInfo.NumProc; i++)
    {
        if (i != ProcInfo.Id)
            MPI_Send(SendBuf, EMT_COMM_NUM, MPI_DOUBLE_PRECISION, i, i+1, ProcInfo.CommEMTCAL);
    }

    for (i=0; i&amp;lt;ProcInfo.NumProc; i++)
    {
        if (i != ProcInfo.Id)
            MPI_Recv(buf22, EMT_COMM_NUM, MPI_DOUBLE_PRECISION, i, ProcInfo.Id+1, ProcInfo.CommEMTCAL, &amp;amp;MpiStt);    
    }
}
    
    
    

void *thread_emt(__attribute__((unused)) void *arg)
{
    ......
    set_thread_affinity(core_id);
    MPI_Barrier(ProcInfo.CommCAL);
    disabled_inter();
    for(step=1; step&amp;lt;=10000000; step++)
    {
        emt_comm();    
        MPI_Barrier(ProcInfo.CommCAL);    
    }
    open_inter();
}
    
    
int main(int argc,char *argv[])
{
    ......
    isCalculationOver = 0;
    set_thread_affinity(0);
    MPI_Init(&amp;amp;argc, &amp;amp;argv);
    MPI_Comm_rank( MPI_COMM_WORLD, &amp;amp;ProcInfo.Id);
    MPI_Comm_size( MPI_COMM_WORLD, &amp;amp;ProcInfo.NumProc);
    core = ProcInfo.Id+1;
    MPI_Barrier(MPI_COMM_WORLD);
    ......
    pthread_create(&amp;amp;thread, NULL, thread_emt, &amp;amp;core);
    ......
    while(1 != isCalculationOver)
        usleep(100*1000);

    MPI_Barrier(MPI_COMM_WORLD);
    MPI_Finalize();

    return 0;
}&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jun 2015 08:29:30 GMT</pubDate>
    <dc:creator>wang_b_1</dc:creator>
    <dc:date>2015-06-16T08:29:30Z</dc:date>
    <item>
      <title>MPI_Recv block a long time</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/MPI-Recv-block-a-long-time/m-p/1040852#M4300</link>
      <description>&lt;P&gt;hello:&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;I get into trouble when use MPI_Recv in my programmes.&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;My programme start 3 subprocess,and bind them to cpu 1-3 respectively.&amp;nbsp;In each subprocess, first disabled interrupts , then send message to other process and receive from others. Repeat it a billion times.&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;I except that MPI_Recv will return in a fixed times ,and not use MPI_irecv instead.&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;In order to do that, i disabled interrupts and cancel ticks on cpu1-3,remove other process from cpu 1-3 to cpu 0,and bind interrupts to cpu0.&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; But I found that a very few times(about a billion times may happen 1 times) the MPI_Recv will block for more than 600 ms, but normally the MPI_Recv only take less than 10ms.&lt;BR /&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;I don't know why the &amp;nbsp;MPI_Recv some times block so long,is there any method to find the reason and solve the problem?&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp;Use mpirun -n 3 to execute the&amp;nbsp;programmes, use&amp;nbsp;Hydra and&amp;nbsp;Shared memory fabrics.&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp;environment :&amp;nbsp;&amp;nbsp; &amp;nbsp;parallel_studio_xe_2015_update2 &amp;nbsp;linux 3.10&amp;nbsp;&lt;BR /&gt;
	===== &amp;nbsp;Processor composition &amp;nbsp;=====&lt;BR /&gt;
	Processor name &amp;nbsp; &amp;nbsp;: Intel(R) Core(TM) i5-4590 &amp;nbsp;&lt;BR /&gt;
	Packages(sockets) : 1&lt;BR /&gt;
	Cores &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : 4&lt;BR /&gt;
	Processors(CPUs) &amp;nbsp;: 4&lt;BR /&gt;
	Cores per package : 4&lt;BR /&gt;
	Threads per core &amp;nbsp;: 1&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;void emt_comm()
{
    ......
    for (i=0; i&amp;lt;ProcInfo.NumProc; i++)
    {
        if (i != ProcInfo.Id)
            MPI_Send(SendBuf, EMT_COMM_NUM, MPI_DOUBLE_PRECISION, i, i+1, ProcInfo.CommEMTCAL);
    }

    for (i=0; i&amp;lt;ProcInfo.NumProc; i++)
    {
        if (i != ProcInfo.Id)
            MPI_Recv(buf22, EMT_COMM_NUM, MPI_DOUBLE_PRECISION, i, ProcInfo.Id+1, ProcInfo.CommEMTCAL, &amp;amp;MpiStt);    
    }
}
    
    
    

void *thread_emt(__attribute__((unused)) void *arg)
{
    ......
    set_thread_affinity(core_id);
    MPI_Barrier(ProcInfo.CommCAL);
    disabled_inter();
    for(step=1; step&amp;lt;=10000000; step++)
    {
        emt_comm();    
        MPI_Barrier(ProcInfo.CommCAL);    
    }
    open_inter();
}
    
    
int main(int argc,char *argv[])
{
    ......
    isCalculationOver = 0;
    set_thread_affinity(0);
    MPI_Init(&amp;amp;argc, &amp;amp;argv);
    MPI_Comm_rank( MPI_COMM_WORLD, &amp;amp;ProcInfo.Id);
    MPI_Comm_size( MPI_COMM_WORLD, &amp;amp;ProcInfo.NumProc);
    core = ProcInfo.Id+1;
    MPI_Barrier(MPI_COMM_WORLD);
    ......
    pthread_create(&amp;amp;thread, NULL, thread_emt, &amp;amp;core);
    ......
    while(1 != isCalculationOver)
        usleep(100*1000);

    MPI_Barrier(MPI_COMM_WORLD);
    MPI_Finalize();

    return 0;
}&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2015 08:29:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/MPI-Recv-block-a-long-time/m-p/1040852#M4300</guid>
      <dc:creator>wang_b_1</dc:creator>
      <dc:date>2015-06-16T08:29:30Z</dc:date>
    </item>
    <item>
      <title>Your code is semantically</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/MPI-Recv-block-a-long-time/m-p/1040853#M4301</link>
      <description>&lt;P&gt;Your code is semantically deadlocking: you start by everyone doing a send. Since this is a blocking send, no one progresses to the receives after, and you have deadlock.&lt;/P&gt;

&lt;P&gt;The reason your code will actually work is that small messages are usually sent without going through the rendez-vous protocol. However, this is up to the mercy of the network and availability of buffer space on the NIC. Since you're repeating this code many times, I imagine that &amp;nbsp;every once in a while this "eager" send does not succeed.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Victor.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 02:00:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/MPI-Recv-block-a-long-time/m-p/1040853#M4301</guid>
      <dc:creator>Victor_E_1</dc:creator>
      <dc:date>2015-07-07T02:00:15Z</dc:date>
    </item>
    <item>
      <title>To clarify more on what</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/MPI-Recv-block-a-long-time/m-p/1040854#M4302</link>
      <description>&lt;P&gt;To clarify more on what Victor said, there are multiple ways to handle MPI_Send (and MPI_Recv).&amp;nbsp; That is up to the implementation.&amp;nbsp; I would highly recommend switching to an explicitly non-blocking MPI_Isend instead.&lt;/P&gt;

&lt;P&gt;Also, are you intending to use multiple threads for MPI calls?&amp;nbsp; If so, you should use MPI_Init_thread instead of MPI_Init.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jul 2015 14:15:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/MPI-Recv-block-a-long-time/m-p/1040854#M4302</guid>
      <dc:creator>James_T_Intel</dc:creator>
      <dc:date>2015-07-07T14:15:15Z</dc:date>
    </item>
  </channel>
</rss>

