Skip to content

Commit b814b33

Browse files
committed
Add function to lookup ompi datatype from opal datatype id.
Signed-off-by: Chris Chambreau <[email protected]>
1 parent c2627ab commit b814b33

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

ompi/datatype/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ libdatatype_la_SOURCES = \
4141
ompi_datatype_create_subarray.c \
4242
ompi_datatype_external.c \
4343
ompi_datatype_external32.c \
44+
ompi_datatype_lookup_by_opal_id.c \
4445
ompi_datatype_match_size.c \
4546
ompi_datatype_module.c \
4647
ompi_datatype_sndrcv.c \

ompi/datatype/ompi_datatype.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ ompi_datatype_copy_content_same_ddt( const ompi_datatype_t* type, size_t count,
295295
return 0;
296296
}
297297

298+
OMPI_DECLSPEC ompi_datatype_t* ompi_datatype_lookup_by_opal_id( uint16_t opal_id );
299+
298300
OMPI_DECLSPEC const ompi_datatype_t* ompi_datatype_match_size( int size, uint16_t datakind, uint16_t datalang );
299301

300302
/*
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; -*- */
2+
/*
3+
* $COPYRIGHT$
4+
*
5+
* Additional copyrights may follow
6+
*
7+
* $HEADER$
8+
*/
9+
10+
#include "ompi_config.h"
11+
#include "ompi/datatype/ompi_datatype.h"
12+
#include "ompi/datatype/ompi_datatype_internal.h"
13+
14+
15+
ompi_datatype_t* ompi_datatype_lookup_by_opal_id( uint16_t opal_id )
16+
{
17+
int32_t i;
18+
const ompi_datatype_t* datatype = NULL;
19+
20+
for (int j = 0 ; j < OMPI_DATATYPE_MPI_MAX_PREDEFINED ; ++j) {
21+
if (ompi_datatype_basicDatatypes[j]->super.id == opal_id) {
22+
datatype = (ompi_datatype_t *) ompi_datatype_basicDatatypes[j];
23+
break;
24+
}
25+
}
26+
27+
return datatype;
28+
}

ompi/mpi/tool/event_get_info.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717

1818
#include "ompi/mpi/tool/mpit-internal.h"
1919

20-
/* needed to convert between opal and ompi datatypes until a function is provided */
21-
#include "ompi/datatype/ompi_datatype_internal.h"
22-
2320
#if OMPI_BUILD_MPI_PROFILING
2421
#if OPAL_HAVE_WEAK_SYMBOLS
2522
#pragma weak MPI_T_event_get_info = PMPI_T_event_get_info
@@ -89,16 +86,8 @@ int MPI_T_event_get_info (int event_index, char *name, int *name_len,
8986
if (max_datatypes) {
9087
if (array_of_datatypes) {
9188
for (int i = 0 ; i < max_datatypes ; i++) {
92-
ompi_datatype_t *ompi_datatype = NULL;
93-
94-
for (int j = 0 ; j < OMPI_DATATYPE_MPI_MAX_PREDEFINED ; ++j) {
95-
if (ompi_datatype_basicDatatypes[j]->super.id == event->event_datatypes[i]->id) {
96-
ompi_datatype = (ompi_datatype_t *) ompi_datatype_basicDatatypes[j];
97-
break;
98-
}
99-
}
10089

101-
array_of_datatypes[i] = ompi_datatype;
90+
array_of_datatypes[i] = ompi_datatype_lookup_by_opal_id(event->event_datatypes[i]->id);
10291
}
10392
}
10493

0 commit comments

Comments
 (0)