Re: Valgrind master fails to compile

Jeff Hammond <[email protected]>
Newsgroups gmane.comp.debugging.valgrind
Message-ID <CAGKz=u+smAP4WBszUJjsoqmP6DSMOB8c1x-eAu=LF0Z6goyveQ@mail.gmail.com>
The attached patches address these issues, which are caused by the correct
implementation of deprecated function deletion in Open-MPI 4.
https://www.open-mpi.org/faq/?category=mpi-removed has details.

This is my first attempted contribution to Valgrind so please let me know
if the patches need modifications to be accepted.  Do I need to state that
I license them as "GPLv2, or (at your option) any later version," in the
patches?

I would not object at all if someone wants the MPI_UB/MPI_LB workaround to
be different, since there are a bunch of valid ways to implement it.  I
suppose "#ifdef MPI_UB" etc. is simpler, but I can't remember off the top
of my head if the MPI standard requires that identifier to be a
preprocessor symbol or if that is merely common practice, so I did not want
to use a direct preprocessor test on it.

Best,

Jeff

On Sun, Mar 1, 2020 at 1:35 PM Derrick McKee <[email protected]>
wrote:

> I am having a problem compiling Valgrind using OpenMPI 4.0.2.  The
> error is listed below.  It seems it is the same bug logged in [1].
> Has there been any patch made that resolves the issue?  Thanks.
>
> - Derrick
>
> [1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=946329
>
> Error
> -----------------------------------------------------------------------
> mkdir -p ../.in_place; \
> for f in ; do \
>   rm -f ../.in_place/$f.dSYM; \
>   ln -f -s ../mpi/$f.dSYM ../.in_place; \
> done
> In file included from ../../mpi/libmpiwrap.c:116:
> ../../mpi/libmpiwrap.c: In function ‘showTy’:
> ../../mpi/libmpiwrap.c:281:19: error: expected expression before
> ‘_Static_assert’
>   281 |    else if (ty == MPI_UB)             fprintf(f,"UB");
>       |                   ^~~~~~
> ../../mpi/libmpiwrap.c:282:19: error: expected expression before
> ‘_Static_assert’
>   282 |    else if (ty == MPI_LB)             fprintf(f,"LB");
>       |                   ^~~~~~
> ../../mpi/libmpiwrap.c: In function ‘showCombiner’:
> ../../mpi/libmpiwrap.c:354:12: error: expected expression before
> ‘_Static_assert’
>   354 |       case MPI_COMBINER_HVECTOR_INTEGER: fprintf(f,
> "HVECTOR_INTEGER"); break;
>       |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../../mpi/libmpiwrap.c:354:12: error: expected expression before
> ‘_Static_assert’
> ../../mpi/libmpiwrap.c:354:40: error: expected expression before ‘:’ token
>   354 |       case MPI_COMBINER_HVECTOR_INTEGER: fprintf(f,
> "HVECTOR_INTEGER"); break;
>       |                                        ^
> In file included from ../../mpi/libmpiwrap.c:116:
> ../../mpi/libmpiwrap.c:359:12: error: expected expression before
> ‘_Static_assert’
>   359 |       case MPI_COMBINER_HINDEXED_INTEGER: fprintf(f,
> "HINDEXED_INTEGER"); break;
>       |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../../mpi/libmpiwrap.c:359:12: error: expected expression before
> ‘_Static_assert’
> ../../mpi/libmpiwrap.c:359:41: error: expected expression before ‘:’ token
>   359 |       case MPI_COMBINER_HINDEXED_INTEGER: fprintf(f,
> "HINDEXED_INTEGER"); break;
>       |                                         ^
> In file included from ../../mpi/libmpiwrap.c:116:
> ../../mpi/libmpiwrap.c:366:12: error: expected expression before
> ‘_Static_assert’
>   366 |       case MPI_COMBINER_STRUCT_INTEGER: fprintf(f,
> "STRUCT_INTEGER"); break;
>       |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../../mpi/libmpiwrap.c:366:12: error: expected expression before
> ‘_Static_assert’
> ../../mpi/libmpiwrap.c:366:39: error: expected expression before ‘:’ token
>   366 |       case MPI_COMBINER_STRUCT_INTEGER: fprintf(f,
> "STRUCT_INTEGER"); break;
>       |                                       ^
> ../../mpi/libmpiwrap.c: In function ‘extentOfTy’:
> ../../mpi/libmpiwrap.c:462:8: warning: implicit declaration of
> function ‘PMPI_Type_extent’; did you mean ‘MPI_Type_extent’?
> [-Wimplicit-function-declaration]
>   462 |    r = PMPI_Type_extent(ty, &n);
>       |        ^~~~~~~~~~~~~~~~
>       |        MPI_Type_extent
> In file included from ../../mpi/libmpiwrap.c:116:
> ../../mpi/libmpiwrap.c: In function ‘walk_type’:
> ../../mpi/libmpiwrap.c:736:17: error: expected expression before
> ‘_Static_assert’
>   736 |       if (ty == MPI_LB || ty == MPI_UB)
>
> --
> Derrick McKee
> Phone: (703) 957-9362
> Email: [email protected]
>
>
> _______________________________________________
> Valgrind-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
>


-- 
Jeff Hammond
[email protected]
http://jeffhammond.github.io/

_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
0001-use-MPI_Type_get_extent-with-MPI-2-and-later.patch (application/octet-stream, 997 B)
From 238161ceacf18e497fd4e7bc8ff1423975c0b686 Mon Sep 17 00:00:00 2001
From: Jeff Hammond <[email protected]>
Date: Sun, 1 Mar 2020 21:38:45 -0800
Subject: [PATCH 1/2] use MPI_Type_get_extent with MPI-2 and later

This ameliorates the error building with Open-MPI 4, which implements
the deletion of MPI_Type_extent as of MPI-3.

See https://www.open-mpi.org/faq/?category=mpi-removed#mpi-1-mpi-type-extent
for details.

Signed-off-by: Jeff Hammond <[email protected]>
---
 mpi/libmpiwrap.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mpi/libmpiwrap.c b/mpi/libmpiwrap.c
index 488bb13fd..987964396 100644
--- a/mpi/libmpiwrap.c
+++ b/mpi/libmpiwrap.c
@@ -459,7 +459,12 @@ static long extentOfTy ( MPI_Datatype ty )
 {
    int      r;
    MPI_Aint n;
+#if defined(MPI_VERSION) && (MPI_VERSION >= 2)
+   MPI_Aint l;
+   r = PMPI_Type_get_extent(ty, &l, &n);
+#else
    r = PMPI_Type_extent(ty, &n);
+#endif
    assert(r == MPI_SUCCESS);
    return (long)n;
 }
-- 
2.25.0
0002-conditionalize-MPI_UB-MPI_LB-on-existence.patch (application/octet-stream, 1.7 KB)
From 8a53e873d7221e4b9146cf2c21d67d1fec4cd4f2 Mon Sep 17 00:00:00 2001
From: Jeff Hammond <[email protected]>
Date: Sun, 1 Mar 2020 21:41:27 -0800
Subject: [PATCH 2/2] conditionalize MPI_UB/MPI_LB on existence

Open-MPI 4 implements the MPI-3 standard deletion of MPI_UB and MPI_LB.
There is a backwards-compatibility mode, so we test for Open-MPI 4 and
not the compatibility mode when disabling references to these
identifiers.

There may be other valid strategies for dealing with this problem...

See https://www.open-mpi.org/faq/?category=mpi-removed#mpi-1-mpi-lb-ub
for details.

Signed-off-by: Jeff Hammond <[email protected]>
---
 mpi/libmpiwrap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mpi/libmpiwrap.c b/mpi/libmpiwrap.c
index 987964396..c3e069839 100644
--- a/mpi/libmpiwrap.c
+++ b/mpi/libmpiwrap.c
@@ -278,8 +278,10 @@ static void showTy ( FILE* f, MPI_Datatype ty )
    else if (ty == MPI_LONG_INT)       fprintf(f,"LONG_INT");
    else if (ty == MPI_SHORT_INT)      fprintf(f,"SHORT_INT");
    else if (ty == MPI_2INT)           fprintf(f,"2INT");
+#if !((OMPI_MAJOR_VERSION >= 4) && !(OMPI_ENABLE_MPI1_COMPAT))
    else if (ty == MPI_UB)             fprintf(f,"UB");
    else if (ty == MPI_LB)             fprintf(f,"LB");
+#endif
 #  if defined(MPI_WCHAR)
    else if (ty == MPI_WCHAR)          fprintf(f,"WCHAR");
 #  endif
@@ -738,8 +740,10 @@ void walk_type ( void(*f)(void*,long), char* base, MPI_Datatype ty )
          f(base + offsetof(Ty,loc), sizeof(int));
          return;
       }
+#if !((OMPI_MAJOR_VERSION >= 4) && !(OMPI_ENABLE_MPI1_COMPAT))
       if (ty == MPI_LB || ty == MPI_UB)
          return; /* have zero size, so nothing needs to be done */
+#endif
       goto unhandled;
       /*NOTREACHED*/
    }
-- 
2.25.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.