Package: libopenmpi1.3
Version: 1.4.2-4
Severity: normal
Tags: upstream patch

Hello,

we've identified a problem in OpenMPI as installed by Debian. The issue has
been fixed upstream. I'd wanted to ask you to see to it that future
installations of OpenMPI have the fix applied in r28319[1]. The developers
email response[2] and the original report[3] with test case[4] can be found at
the OpenMPI site.

Regards, Thomas

[1] https://svn.open-mpi.org/trac/ompi/changeset/28319
[2] http://www.open-mpi.org/community/lists/devel/2013/04/12268.php
[3] http://www.open-mpi.org/community/lists/devel/2013/04/12267.php
[4] http://www.open-mpi.org/community/lists/devel/att-12267/mpi_test.c



-- System Information:
Debian Release: 6.0.7
  APT prefers stable
  APT policy: (900, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-0.bpo.4-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libopenmpi1.3 depends on:
ii  libc6               2.11.3-4             Embedded GNU C Library: Shared lib
ii  libgcc1             1:4.6.1-4            GCC support library
ii  libgfortran3        4.6.1-4              Runtime library for GNU Fortran ap
ii  libibverbs1         1.1.3-2              A library for direct userspace use
ii  libnuma1            2.0.5-1              Libraries for controlling NUMA pol
ii  libstdc++6          4.6.1-4              GNU Standard C++ Library v3
ii  libtorque2          2.4.8+dfsg-9squeeze1 shared library for Torque client a

libopenmpi1.3 recommends no packages.

libopenmpi1.3 suggests no packages.

-- no debconf information
Index: /trunk/opal/datatype/opal_datatype_optimize.c
===================================================================
--- /trunk/opal/datatype/opal_datatype_optimize.c	(revision 23690)
+++ /trunk/opal/datatype/opal_datatype_optimize.c	(revision 28319)
@@ -74,13 +74,10 @@
     dt_elem_desc_t* pElemDesc;
     ddt_elem_desc_t opt_elem;
-    OPAL_PTRDIFF_TYPE last_disp = 0;
     dt_stack_t* pStack;            /* pointer to the position on the stack */
     int32_t pos_desc = 0;          /* actual position in the description of the derived datatype */
-    int32_t stack_pos = 0, last_type = OPAL_DATATYPE_UINT1;
-    int32_t type = OPAL_DATATYPE_LOOP, nbElems = 0, changes = 0;
-    int32_t optimized = 0, continuity;
+    int32_t stack_pos = 0, last_type = OPAL_DATATYPE_UINT1, last_length = 0;
+    int32_t type = OPAL_DATATYPE_LOOP, nbElems = 0, continuity;
+    OPAL_PTRDIFF_TYPE total_disp = 0, last_extent = 1, last_disp = 0;
     uint16_t last_flags = 0xFFFF;  /* keep all for the first datatype */
-    OPAL_PTRDIFF_TYPE total_disp = 0, last_extent = 1;
-	int32_t last_length = 0;
     uint32_t i;
 
@@ -135,5 +132,6 @@
                     if( !continuity ) {
                         if( 0 != last_length ) {
-                            CREATE_ELEM( pElemDesc, last_type, OPAL_DATATYPE_FLAG_BASIC, last_length, last_disp, last_extent );
+                            CREATE_ELEM( pElemDesc, last_type, OPAL_DATATYPE_FLAG_BASIC,
+                                         last_length, last_disp, last_extent );
                             pElemDesc++; nbElems++;
                             last_length = 0;
@@ -145,7 +143,7 @@
                     last_type   = OPAL_DATATYPE_UINT1;
                     last_extent = 1;
-                    optimized++;
                 } else {
                     int counter = loop->loops;
+                    OPAL_PTRDIFF_TYPE merged_disp = 0;
                     /* if the previous data is contiguous with this piece and it has a length not ZERO */
                     if( last_length != 0 ) {
@@ -156,6 +154,8 @@
                             last_extent  = 1;
                             counter--;
+                            merged_disp = loop->extent;  /* merged loop, update the disp of the remaining elems */
                         }
-                        CREATE_ELEM( pElemDesc, last_type, OPAL_DATATYPE_FLAG_BASIC, last_length, last_disp, last_extent );
+                        CREATE_ELEM( pElemDesc, last_type, OPAL_DATATYPE_FLAG_BASIC,
+                                     last_length, last_disp, last_extent );
                         pElemDesc++; nbElems++;
                         last_disp += last_length;
@@ -163,18 +163,31 @@
                         last_type = OPAL_DATATYPE_LOOP;
                     }
-                    /* we have a gap in the begining or the end of the loop but the whole
-                     * loop can be merged in just one memcpy.
+                    /**
+                     * The content of the loop is contiguous (maybe with a gap before or after).
+                     *
+                     * If any of the loops have been merged with the previous element, then the
+                     * displacement of the first element (or the displacement of all elements if the
+                     * loop will be removed) must be updated accordingly.
                      */
-                    CREATE_LOOP_START( pElemDesc, counter, 2, loop->extent, loop->common.flags );
-                    pElemDesc++; nbElems++;
-                    CREATE_ELEM( pElemDesc, OPAL_DATATYPE_UINT1, OPAL_DATATYPE_FLAG_BASIC, end_loop->size, loop_disp, 1);
-                    pElemDesc++; nbElems++;
-                    CREATE_LOOP_END( pElemDesc, 2, end_loop->first_elem_disp, end_loop->size,
-                                     end_loop->common.flags );
-                    pElemDesc++; nbElems++;
-                    if( loop->items > 2 ) optimized++;
+                    if( counter <= 2 ) {
+                        merged_disp += end_loop->first_elem_disp;
+                        while( counter > 0 ) {
+                            CREATE_ELEM( pElemDesc, OPAL_DATATYPE_UINT1, OPAL_DATATYPE_FLAG_BASIC,
+                                         end_loop->size, merged_disp, 1);
+                            pElemDesc++; nbElems++; counter--;
+                            merged_disp += loop->extent;
+                        }
+                    } else {
+                        CREATE_LOOP_START( pElemDesc, counter, 2, loop->extent, loop->common.flags );
+                        pElemDesc++; nbElems++;
+                        CREATE_ELEM( pElemDesc, OPAL_DATATYPE_UINT1, OPAL_DATATYPE_FLAG_BASIC,
+                                     end_loop->size, loop_disp, 1);
+                        pElemDesc++; nbElems++;
+                        CREATE_LOOP_END( pElemDesc, 2, end_loop->first_elem_disp + merged_disp,
+                                         end_loop->size, end_loop->common.flags );
+                        pElemDesc++; nbElems++;
+                    }
                 }
                 pos_desc += loop->items + 1;
-                changes++;
             } else {
                 ddt_elem_desc_t* elem = (ddt_elem_desc_t*)&(pData->desc.desc[pos_desc+1]);
@@ -193,5 +206,4 @@
                         pElemDesc++; nbElems++;
                         pos_desc += loop->items + 1;
-                        changes++; optimized++;
                         goto complete_loop;
                     } else if( loop->loops < 3 ) {
@@ -204,5 +216,4 @@
                         }
                         pos_desc += loop->items + 1;
-                        changes += loop->loops; optimized += loop->loops;
                         goto complete_loop;
                     }
@@ -239,5 +250,4 @@
                         last_type = OPAL_DATATYPE_UINT1;
                         last_extent = 1;
-                        optimized++;
                     }
                 }
Index: /trunk/opal/datatype/opal_datatype_optimize.c
===================================================================
--- /trunk/opal/datatype/opal_datatype_optimize.c	(revision 23690)
+++ /trunk/opal/datatype/opal_datatype_optimize.c	(revision 28319)
@@ -74,13 +74,10 @@
     dt_elem_desc_t* pElemDesc;
     ddt_elem_desc_t opt_elem;
-    OPAL_PTRDIFF_TYPE last_disp = 0;
     dt_stack_t* pStack;            /* pointer to the position on the stack */
     int32_t pos_desc = 0;          /* actual position in the description of the derived datatype */
-    int32_t stack_pos = 0, last_type = OPAL_DATATYPE_UINT1;
-    int32_t type = OPAL_DATATYPE_LOOP, nbElems = 0, changes = 0;
-    int32_t optimized = 0, continuity;
+    int32_t stack_pos = 0, last_type = OPAL_DATATYPE_UINT1, last_length = 0;
+    int32_t type = OPAL_DATATYPE_LOOP, nbElems = 0, continuity;
+    OPAL_PTRDIFF_TYPE total_disp = 0, last_extent = 1, last_disp = 0;
     uint16_t last_flags = 0xFFFF;  /* keep all for the first datatype */
-    OPAL_PTRDIFF_TYPE total_disp = 0, last_extent = 1;
-	int32_t last_length = 0;
     uint32_t i;
 
@@ -135,5 +132,6 @@
                     if( !continuity ) {
                         if( 0 != last_length ) {
-                            CREATE_ELEM( pElemDesc, last_type, OPAL_DATATYPE_FLAG_BASIC, last_length, last_disp, last_extent );
+                            CREATE_ELEM( pElemDesc, last_type, OPAL_DATATYPE_FLAG_BASIC,
+                                         last_length, last_disp, last_extent );
                             pElemDesc++; nbElems++;
                             last_length = 0;
@@ -145,7 +143,7 @@
                     last_type   = OPAL_DATATYPE_UINT1;
                     last_extent = 1;
-                    optimized++;
                 } else {
                     int counter = loop->loops;
+                    OPAL_PTRDIFF_TYPE merged_disp = 0;
                     /* if the previous data is contiguous with this piece and it has a length not ZERO */
                     if( last_length != 0 ) {
@@ -156,6 +154,8 @@
                             last_extent  = 1;
                             counter--;
+                            merged_disp = loop->extent;  /* merged loop, update the disp of the remaining elems */
                         }
-                        CREATE_ELEM( pElemDesc, last_type, OPAL_DATATYPE_FLAG_BASIC, last_length, last_disp, last_extent );
+                        CREATE_ELEM( pElemDesc, last_type, OPAL_DATATYPE_FLAG_BASIC,
+                                     last_length, last_disp, last_extent );
                         pElemDesc++; nbElems++;
                         last_disp += last_length;
@@ -163,18 +163,31 @@
                         last_type = OPAL_DATATYPE_LOOP;
                     }
-                    /* we have a gap in the begining or the end of the loop but the whole
-                     * loop can be merged in just one memcpy.
+                    /**
+                     * The content of the loop is contiguous (maybe with a gap before or after).
+                     *
+                     * If any of the loops have been merged with the previous element, then the
+                     * displacement of the first element (or the displacement of all elements if the
+                     * loop will be removed) must be updated accordingly.
                      */
-                    CREATE_LOOP_START( pElemDesc, counter, 2, loop->extent, loop->common.flags );
-                    pElemDesc++; nbElems++;
-                    CREATE_ELEM( pElemDesc, OPAL_DATATYPE_UINT1, OPAL_DATATYPE_FLAG_BASIC, end_loop->size, loop_disp, 1);
-                    pElemDesc++; nbElems++;
-                    CREATE_LOOP_END( pElemDesc, 2, end_loop->first_elem_disp, end_loop->size,
-                                     end_loop->common.flags );
-                    pElemDesc++; nbElems++;
-                    if( loop->items > 2 ) optimized++;
+                    if( counter <= 2 ) {
+                        merged_disp += end_loop->first_elem_disp;
+                        while( counter > 0 ) {
+                            CREATE_ELEM( pElemDesc, OPAL_DATATYPE_UINT1, OPAL_DATATYPE_FLAG_BASIC,
+                                         end_loop->size, merged_disp, 1);
+                            pElemDesc++; nbElems++; counter--;
+                            merged_disp += loop->extent;
+                        }
+                    } else {
+                        CREATE_LOOP_START( pElemDesc, counter, 2, loop->extent, loop->common.flags );
+                        pElemDesc++; nbElems++;
+                        CREATE_ELEM( pElemDesc, OPAL_DATATYPE_UINT1, OPAL_DATATYPE_FLAG_BASIC,
+                                     end_loop->size, loop_disp, 1);
+                        pElemDesc++; nbElems++;
+                        CREATE_LOOP_END( pElemDesc, 2, end_loop->first_elem_disp + merged_disp,
+                                         end_loop->size, end_loop->common.flags );
+                        pElemDesc++; nbElems++;
+                    }
                 }
                 pos_desc += loop->items + 1;
-                changes++;
             } else {
                 ddt_elem_desc_t* elem = (ddt_elem_desc_t*)&(pData->desc.desc[pos_desc+1]);
@@ -193,5 +206,4 @@
                         pElemDesc++; nbElems++;
                         pos_desc += loop->items + 1;
-                        changes++; optimized++;
                         goto complete_loop;
                     } else if( loop->loops < 3 ) {
@@ -204,5 +216,4 @@
                         }
                         pos_desc += loop->items + 1;
-                        changes += loop->loops; optimized += loop->loops;
                         goto complete_loop;
                     }
@@ -239,5 +250,4 @@
                         last_type = OPAL_DATATYPE_UINT1;
                         last_extent = 1;
-                        optimized++;
                     }
                 }

Reply via email to