Skip to content

Commit 61b3308

Browse files
committed
mpiext/pcollreq: check subroutine parameters and add profiling symbols
- check subroutine parameters - implement PMPIX_* subroutines Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
1 parent dec1663 commit 61b3308

30 files changed

+3162
-182
lines changed

ompi/mpiext/pcollreq/c/Makefile.am

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
#
22
# Copyright (c) 2017 FUJITSU LIMITED. All rights reserved.
3+
# Copyright (c) 2018 Research Organization for Information Science
4+
# and Technology (RIST). All rights reserved.
35
# $COPYRIGHT$
46
#
57
# Additional copyrights may follow
68
#
79
# $HEADER$
810
#
911

10-
# We must set these #defines so that the inner OMPI MPI prototype
11-
# header files do the Right Thing.
12-
AM_CPPFLAGS = -DOMPI_PROFILE_LAYER=0 -DOMPI_COMPILING_FORTRAN_WRAPPERS=1
12+
SUBDIRS = profile
13+
14+
# OMPI_BUILD_MPI_PROFILING is enabled when we want our generated MPI_* symbols
15+
# to be replaced by PMPI_*.
16+
# In this directory, we need it to be 0
17+
18+
AM_CPPFLAGS = -DOMPI_BUILD_MPI_PROFILING=0
1319

1420
include $(top_srcdir)/Makefile.ompi-rules
1521

16-
# Convenience libtool library that will be slurped up into libmpi.la.
1722
noinst_LTLIBRARIES = libmpiext_pcollreq_c.la
1823

1924
# This is where the top-level header file (that is included in
@@ -28,8 +33,34 @@ ompi_HEADERS = mpiext_pcollreq_c.h
2833
# conventions.
2934
libmpiext_pcollreq_c_la_SOURCES = \
3035
$(ompi_HEADERS) \
31-
mpiext_pcollreq.c
32-
libmpiext_pcollreq_c_la_LDFLAGS = -module -avoid-version
36+
mpiext_pcollreq_c.c
37+
38+
if BUILD_MPI_BINDINGS_LAYER
39+
libmpiext_pcollreq_c_la_SOURCES += \
40+
allgather_init.c \
41+
allgatherv_init.c \
42+
allreduce_init.c \
43+
alltoall_init.c \
44+
alltoallv_init.c \
45+
alltoallw_init.c \
46+
barrier_init.c \
47+
bcast_init.c \
48+
exscan_init.c \
49+
gather_init.c \
50+
gatherv_init.c \
51+
reduce_init.c \
52+
reduce_scatter_block_init.c \
53+
reduce_scatter_init.c \
54+
scan_init.c \
55+
scatter_init.c \
56+
scatterv_init.c \
57+
\
58+
neighbor_allgather_init.c \
59+
neighbor_allgatherv_init.c \
60+
neighbor_alltoall_init.c \
61+
neighbor_alltoallv_init.c \
62+
neighbor_alltoallw_init.c
63+
endif
3364

3465
# Man page installation
3566
nodist_man_MANS = \
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
4+
* University Research and Technology
5+
* Corporation. All rights reserved.
6+
* Copyright (c) 2004-2018 The University of Tennessee and The University
7+
* of Tennessee Research Foundation. All rights
8+
* reserved.
9+
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
10+
* University of Stuttgart. All rights reserved.
11+
* Copyright (c) 2004-2005 The Regents of the University of California.
12+
* All rights reserved.
13+
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2012 Oak Ridge National Laboratory. All rights reserved.
15+
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
16+
* reserved.
17+
* Copyright (c) 2015-2018 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
19+
* $COPYRIGHT$
20+
*
21+
* Additional copyrights may follow
22+
*
23+
* $HEADER$
24+
*/
25+
26+
#include "ompi_config.h"
27+
#include <stdio.h>
28+
29+
#include "ompi/mpi/c/bindings.h"
30+
#include "ompi/runtime/params.h"
31+
#include "ompi/communicator/communicator.h"
32+
#include "ompi/errhandler/errhandler.h"
33+
#include "ompi/datatype/ompi_datatype.h"
34+
#include "ompi/memchecker.h"
35+
#include "ompi/mpiext/pcollreq/c/mpiext_pcollreq_c.h"
36+
#include "ompi/runtime/ompi_spc.h"
37+
38+
#if OMPI_BUILD_MPI_PROFILING
39+
#if OPAL_HAVE_WEAK_SYMBOLS
40+
#pragma weak MPIX_Allgather_init = PMPIX_Allgather_init
41+
#endif
42+
#define MPIX_Allgather_init PMPIX_Allgather_init
43+
#endif
44+
45+
static const char FUNC_NAME[] = "MPIX_Allgather_init";
46+
47+
48+
int MPIX_Allgather_init(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
49+
void *recvbuf, int recvcount, MPI_Datatype recvtype,
50+
MPI_Comm comm, MPI_Info info, MPI_Request *request)
51+
{
52+
int err;
53+
54+
SPC_RECORD(OMPI_SPC_ALLGATHER_INIT, 1);
55+
56+
MEMCHECKER(
57+
int rank;
58+
ptrdiff_t ext;
59+
60+
rank = ompi_comm_rank(comm);
61+
ompi_datatype_type_extent(recvtype, &ext);
62+
63+
memchecker_datatype(recvtype);
64+
memchecker_comm(comm);
65+
/* check whether the actual send buffer is defined. */
66+
if (MPI_IN_PLACE == sendbuf) {
67+
memchecker_call(&opal_memchecker_base_isdefined,
68+
(char *)(recvbuf)+rank*ext,
69+
recvcount, recvtype);
70+
} else {
71+
memchecker_datatype(sendtype);
72+
memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
73+
}
74+
/* check whether the receive buffer is addressable. */
75+
memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, recvcount, recvtype);
76+
);
77+
78+
if (MPI_PARAM_CHECK) {
79+
80+
/* Unrooted operation -- same checks for all ranks on both
81+
intracommunicators and intercommunicators */
82+
83+
err = MPI_SUCCESS;
84+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
85+
if (ompi_comm_invalid(comm)) {
86+
OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);
87+
} else if (MPI_DATATYPE_NULL == recvtype || NULL == recvtype) {
88+
err = MPI_ERR_TYPE;
89+
} else if (recvcount < 0) {
90+
err = MPI_ERR_COUNT;
91+
} else if ((MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
92+
MPI_IN_PLACE == recvbuf) {
93+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
94+
} else if (MPI_IN_PLACE != sendbuf) {
95+
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
96+
}
97+
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
98+
}
99+
100+
OPAL_CR_ENTER_LIBRARY();
101+
102+
/* Invoke the coll component to perform the back-end operation */
103+
err = comm->c_coll->coll_allgather_init(sendbuf, sendcount, sendtype,
104+
recvbuf, recvcount, recvtype, comm,
105+
info, request, comm->c_coll->coll_allgather_init_module);
106+
107+
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
108+
}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2+
/*
3+
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
4+
* University Research and Technology
5+
* Corporation. All rights reserved.
6+
* Copyright (c) 2004-2018 The University of Tennessee and The University
7+
* of Tennessee Research Foundation. All rights
8+
* reserved.
9+
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
10+
* University of Stuttgart. All rights reserved.
11+
* Copyright (c) 2004-2005 The Regents of the University of California.
12+
* All rights reserved.
13+
* Copyright (c) 2010 University of Houston. All rights reserved.
14+
* Copyright (c) 2012 Cisco Systems, Inc. All rights reserved.
15+
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
16+
* reserved.
17+
* Copyright (c) 2015-2018 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
19+
* $COPYRIGHT$
20+
*
21+
* Additional copyrights may follow
22+
*
23+
* $HEADER$
24+
*/
25+
26+
#include "ompi_config.h"
27+
#include <stdio.h>
28+
29+
#include "ompi/mpi/c/bindings.h"
30+
#include "ompi/runtime/params.h"
31+
#include "ompi/communicator/communicator.h"
32+
#include "ompi/errhandler/errhandler.h"
33+
#include "ompi/datatype/ompi_datatype.h"
34+
#include "ompi/memchecker.h"
35+
#include "ompi/mpiext/pcollreq/c/mpiext_pcollreq_c.h"
36+
#include "ompi/runtime/ompi_spc.h"
37+
38+
#if OMPI_BUILD_MPI_PROFILING
39+
#if OPAL_HAVE_WEAK_SYMBOLS
40+
#pragma weak MPIX_Allgatherv_init = PMPIX_Allgatherv_init
41+
#endif
42+
#define MPIX_Allgatherv_init PMPIX_Allgatherv_init
43+
#endif
44+
45+
static const char FUNC_NAME[] = "MPIX_Allgatherv_init";
46+
47+
48+
int MPIX_Allgatherv_init(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
49+
void *recvbuf, const int recvcounts[], const int displs[],
50+
MPI_Datatype recvtype, MPI_Comm comm,
51+
MPI_Info info, MPI_Request *request)
52+
{
53+
int i, size, err;
54+
55+
SPC_RECORD(OMPI_SPC_ALLGATHERV_INIT, 1);
56+
57+
MEMCHECKER(
58+
int rank;
59+
ptrdiff_t ext;
60+
61+
rank = ompi_comm_rank(comm);
62+
size = ompi_comm_size(comm);
63+
ompi_datatype_type_extent(recvtype, &ext);
64+
65+
memchecker_datatype(recvtype);
66+
memchecker_comm (comm);
67+
/* check whether the receive buffer is addressable. */
68+
for (i = 0; i < size; i++) {
69+
memchecker_call(&opal_memchecker_base_isaddressable,
70+
(char *)(recvbuf)+displs[i]*ext,
71+
recvcounts[i], recvtype);
72+
}
73+
74+
/* check whether the actual send buffer is defined. */
75+
if (MPI_IN_PLACE == sendbuf) {
76+
memchecker_call(&opal_memchecker_base_isdefined,
77+
(char *)(recvbuf)+displs[rank]*ext,
78+
recvcounts[rank], recvtype);
79+
} else {
80+
memchecker_datatype(sendtype);
81+
memchecker_call(&opal_memchecker_base_isdefined, sendbuf, sendcount, sendtype);
82+
}
83+
);
84+
85+
if (MPI_PARAM_CHECK) {
86+
87+
/* Unrooted operation -- same checks for all ranks on both
88+
intracommunicators and intercommunicators */
89+
90+
err = MPI_SUCCESS;
91+
OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
92+
if (ompi_comm_invalid(comm)) {
93+
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
94+
FUNC_NAME);
95+
} else if ((MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
96+
MPI_IN_PLACE == recvbuf) {
97+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
98+
} else if (MPI_DATATYPE_NULL == recvtype) {
99+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME);
100+
}
101+
102+
if (MPI_IN_PLACE != sendbuf) {
103+
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
104+
}
105+
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
106+
107+
/* We always define the remote group to be the same as the local
108+
group in the case of an intracommunicator, so it's safe to
109+
get the size of the remote group here for both intra- and
110+
intercommunicators */
111+
112+
size = ompi_comm_remote_size(comm);
113+
for (i = 0; i < size; ++i) {
114+
if (recvcounts[i] < 0) {
115+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME);
116+
}
117+
}
118+
119+
if (NULL == displs) {
120+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_BUFFER, FUNC_NAME);
121+
}
122+
}
123+
124+
OPAL_CR_ENTER_LIBRARY();
125+
126+
/* Invoke the coll component to perform the back-end operation */
127+
err = comm->c_coll->coll_allgatherv_init(sendbuf, sendcount, sendtype,
128+
recvbuf, recvcounts, displs,
129+
recvtype, comm, info, request,
130+
comm->c_coll->coll_allgatherv_init_module);
131+
OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
132+
}
133+

0 commit comments

Comments
 (0)