<?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 Re: Bug Report: MPI_Comm attribute deleter not called in Intel® MPI Library</title>
    <link>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1375216#M9395</link>
    <description>&lt;P&gt;Thanks.&amp;nbsp; Once the bug is fixed, can you post which versions of IntelMPI have the fix included?&lt;/P&gt;</description>
    <pubDate>Thu, 07 Apr 2022 13:54:59 GMT</pubDate>
    <dc:creator>jcrean</dc:creator>
    <dc:date>2022-04-07T13:54:59Z</dc:date>
    <item>
      <title>Bug Report: MPI_Comm attribute deleter not called</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1373444#M9376</link>
      <description>&lt;P&gt;I believe I found a bug in IntelMPI 2021.3. In the code below, the call to MPI_Comm_free() does not cause the deleter function for the attribute to be called. The MPI 3.1 standard specifies that the deleter should be called from MPI_Comm_free (Section 6.4.3, page 248, lines 26-27).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested OpenMPI 4.0, MPICH 3.2, and IntelMPI 2018.4, and they all call the deleter as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code below is a minimal reproducible example. Be sure to compile it in debug mode so the assert() fires.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: the outstanding MPI_Ibarrier() appears to be important. If the MPI_Ibarrier() is not in progress, the callback is executed as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;#include "mpi.h"&lt;BR /&gt;#include &amp;lt;iostream&amp;gt;&lt;BR /&gt;#include &amp;lt;cassert&amp;gt;&lt;BR /&gt;#include &amp;lt;stdexcept&amp;gt;&lt;/P&gt;
&lt;P&gt;MPI_Request request;&lt;BR /&gt;bool is_complete;&lt;/P&gt;
&lt;P&gt;int comm_destructor_callback(MPI_Comm comm, int keyval, void* attribute_val, void* extra_state)&lt;BR /&gt;{&lt;BR /&gt;std::cout &amp;lt;&amp;lt; "destructor callback executing" &amp;lt;&amp;lt; std::endl;&lt;BR /&gt;MPI_Wait(&amp;amp;request, MPI_STATUS_IGNORE);&lt;BR /&gt;is_complete = true;&lt;/P&gt;
&lt;P&gt;return MPI_SUCCESS;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;int main(int argc, char* argv[])&lt;BR /&gt;{&lt;BR /&gt;// initialization&lt;BR /&gt;MPI_Init(&amp;amp;argc, &amp;amp;argv);&lt;BR /&gt;MPI_Comm comm1 = MPI_COMM_WORLD, comm2;&lt;BR /&gt;MPI_Comm_dup(comm1, &amp;amp;comm2);&lt;/P&gt;
&lt;P&gt;// set up attribute&lt;BR /&gt;int keyval;&lt;BR /&gt;MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN, &amp;amp;comm_destructor_callback, &amp;amp;keyval, nullptr);&lt;BR /&gt;MPI_Comm_set_attr(comm2, keyval, nullptr);&lt;/P&gt;
&lt;P&gt;// start Ibarrier then immediately free comm2&lt;BR /&gt;is_complete = false;&lt;BR /&gt;MPI_Ibarrier(comm2, &amp;amp;request);&lt;BR /&gt;std::cout &amp;lt;&amp;lt; "about to free comm2" &amp;lt;&amp;lt; std::endl;&lt;BR /&gt;MPI_Comm_free(&amp;amp;comm2);&lt;BR /&gt;std::cout &amp;lt;&amp;lt; "finished freeing comm2" &amp;lt;&amp;lt; std::endl;&lt;BR /&gt;assert(is_complete);&lt;/P&gt;
&lt;P&gt;MPI_Finalize();&lt;/P&gt;
&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: is there a way to attach C++ source code to a post? I tried attaching main.cxx, but it was rejected because the file contents did not match the extension.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 23:19:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1373444#M9376</guid>
      <dc:creator>jcrean</dc:creator>
      <dc:date>2022-03-31T23:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Bug Report: MPI_Comm attribute deleter not called</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1374813#M9387</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reaching out to us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We were able to reproduce your issue at our end using the latest Intel MPI Library 2021.5 on a Linux machine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have reported this issue to the concerned development team. They are looking into your issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#666699"&gt;&lt;I&gt;&amp;gt;&amp;gt;" is there a way to attach C++ source code to a post? I tried attaching main.cxx, but it was rejected because the file contents did not match the extension."&lt;/I&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Yes, you can share files through a .zip file or you can attach .cpp files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;
&lt;P&gt;Santosh&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 12:11:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1374813#M9387</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2022-04-06T12:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Bug Report: MPI_Comm attribute deleter not called</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1375216#M9395</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; Once the bug is fixed, can you post which versions of IntelMPI have the fix included?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 13:54:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1375216#M9395</guid>
      <dc:creator>jcrean</dc:creator>
      <dc:date>2022-04-07T13:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Bug Report: MPI_Comm attribute deleter not called</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1375518#M9399</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#666699"&gt;&lt;I&gt;&amp;gt;&amp;gt;"Once the bug is fixed, can you post which versions of IntelMPI have the fix included?"&lt;/I&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;We will update you in the forum once the issue is fixed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;
&lt;P&gt;Santosh&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 09:55:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1375518#M9399</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2022-04-08T09:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Bug Report: MPI_Comm attribute deleter not called</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1376148#M9407</link>
      <description>&lt;P&gt;Great, thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 14:07:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1376148#M9407</guid>
      <dc:creator>jcrean</dc:creator>
      <dc:date>2022-04-11T14:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Bug Report: MPI_Comm attribute deleter not called</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1433874#M10093</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to MPI-3.1 standard, section 6.4.3"Communicator Destructors" describing MPI_Comm_free call: "This collective operation marks the communication object for deallocation. The handle is set to MPI_COMM_NULL. Any pending operations that use this communicator will complete normally; &lt;STRONG&gt;the object is actually deallocated only if there are no other active references to it. &lt;/STRONG&gt;This call applies to intra- and inter-communicators. The delete callback functions for all cached attributes (see Section 6.7) are called in arbitrary order. "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;MPI_Ibarrier is a nonblocking version of MPI_barrier. By calling MPI_Ibarrier, a process notifies that it has reached the barrier. The call returns immediately, independent of whether other processes have called MPI_Ibarrier.&amp;nbsp; Since MPI_Ibarrier is in progress at the moment of MPI_Comm_free, the communicator is only marked for deallocation and actual deallocation happens only as soon as all pending operations will complete. So delete callbacks will be called upon pending operations completion.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;That does not seem to be a problem and looks like a valid behavior.&lt;/STRONG&gt; We would recommend waiting till operation completion before the MPI_Comm_free call (in that case all handlers would be called from MPI_Comm_free).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, we have tried multiple MPI versions and the example doesn't work for all of them (please find examples below), except OpenMPI. But it seems that OpenMPI doesn't implement proper reference counting as we can find here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/open-mpi/ompi/blob/main/ompi/mpi/c/comm_free.c#L61" target="_blank" rel="noopener"&gt;https://github.com/open-mpi/ompi/blob/main/ompi/mpi/c/comm_free.c#L61&lt;/A&gt; and here &lt;A href="https://github.com/open-mpi/ompi/blob/main/ompi/communicator/comm.c#L1992" target="_blank" rel="noopener"&gt;https://github.com/open-mpi/ompi/blob/main/ompi/communicator/comm.c#L1992&lt;/A&gt; but just clean all attributes.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;~/tests$ mpicxx.mpich 1.cpp -o test.out
~/tests$ mpirun.mpich -n 2 ./test.out
about to free comm2
finished freeing comm2
about to free comm2
finished freeing comm2
~/tests$ mpirun.mpich --version
HYDRA build details:
    Version:                                 3.3.2

...

~/tests$ mpicxx.openmpi 1.cpp -o test.out
~/tests$ mpirun.openmpi -n 2 ./test.out
about to free comm2
destructor callback executing
finished freeing comm2
about to free comm2
destructor callback executing
finished freeing comm2
~/tests$ mpirun.openmpi --version
mpirun.openmpi (OpenRTE) 4.0.3


~/tests$ mpicxx 1.cpp -o test.out
~/tests$ mpirun -n 2 ./test.out
about to free comm2
finished freeing comm2
about to free comm2
finished freeing comm2
~/tests$ mpirun --version
Intel(R) MPI Library for Linux* OS, Version 2018 Update 5 Build 20190404 (id: 18839)

Copyright 2003-2019 Intel Corporation.

~/tests$ mpicxx 1.cpp -o test.out
~/tests$ mpirun -n 2 ./test.out
about to free comm2
finished freeing comm2
about to free comm2
finished freeing comm2
~/tests$ mpirun --version

Intel(R) MPI Library for Linux* OS, Version 2021.6 Build 20220227 (id: 28877f3f32)
Copyright 2003-2022, Intel Corporation.&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;
&lt;P&gt;Santosh&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 06:42:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1433874#M10093</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2022-11-29T06:42:11Z</dc:date>
    </item>
    <item>
      <title>Re:Bug Report: MPI_Comm attribute deleter not called</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1436080#M10106</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I assume we have answered your query. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Dec 2022 10:16:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/Bug-Report-MPI-Comm-attribute-deleter-not-called/m-p/1436080#M10106</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2022-12-06T10:16:44Z</dc:date>
    </item>
  </channel>
</rss>

