Skip to content

Commit b078bff

Browse files
committed
Address comments on ts.{h,c}
Signed-off-by: Jake Tronge <[email protected]>
1 parent cefe5f4 commit b078bff

File tree

2 files changed

+12
-11
lines changed
  • ompi/mpi/fortran/use-mpi-f08/base

2 files changed

+12
-11
lines changed

ompi/mpi/fortran/use-mpi-f08/base/ts.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int ompi_ts_create_datatype(CFI_cdesc_t *cdesc, int oldcount, MPI_Datatype oldty
2323
int mpi_errno = MPI_SUCCESS;
2424
int accum_elems = 1;
2525
int accum_sm = cdesc->elem_len;
26-
int done = 0; /* Have we created a datatype for oldcount of oldtype? */
26+
int done = false; /* Have we created a datatype for oldcount of oldtype? */
2727
int last; /* Index of the last successfully created datatype in types[] */
2828
int extent;
2929
int i, j;
@@ -34,15 +34,15 @@ int ompi_ts_create_datatype(CFI_cdesc_t *cdesc, int oldcount, MPI_Datatype oldty
3434
assert(cdesc->rank <= MAX_RANK);
3535
ompi_datatype_type_size(oldtype, &size);
3636
/* When cdesc->elem_len != size, things suddenly become complicated. Generally, it is hard to create
37-
* a composite datatype based on two datatypes. Currently we don't support it and doubt it is usefull.
37+
* a composite datatype based on two datatypes. Currently we don't support it and doubt it is useful.
3838
*/
3939
assert(cdesc->elem_len == size);
4040
}
4141
#endif
4242

4343
types[0] = oldtype;
4444
i = 0;
45-
done = 0;
45+
done = false;
4646
while (i < cdesc->rank && !done) {
4747
if (oldcount % accum_elems) {
4848
/* oldcount should be a multiple of accum_elems, otherwise we might need an
@@ -58,7 +58,7 @@ int ompi_ts_create_datatype(CFI_cdesc_t *cdesc, int oldcount, MPI_Datatype oldty
5858
extent = cdesc->dim[i].extent;
5959
} else {
6060
/* Up to now, we have accumlated enough elements */
61-
done = 1;
61+
done = true;
6262
}
6363

6464
if (cdesc->dim[i].sm == accum_sm) {
@@ -90,8 +90,9 @@ int ompi_ts_create_datatype(CFI_cdesc_t *cdesc, int oldcount, MPI_Datatype oldty
9090
}
9191

9292
fn_exit:
93-
for (j = 1; j <= last; j++)
93+
for (j = 1; j <= last; j++) {
9494
PMPI_Type_free(&types[j]);
95+
}
9596
return mpi_errno;
9697
}
9798

ompi/mpi/fortran/use-mpi-f08/base/ts.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern int ompi_ts_copy(CFI_cdesc_t *cdesc, char *buffer);
3636
datatype = type; \
3737
if (x->rank != 0 && !CFI_is_contiguous(x)) { \
3838
rc = ompi_ts_create_datatype(x, count, type, &datatype); \
39-
if (MPI_SUCCESS == rc) { \
39+
if (OPAL_LIKELY(MPI_SUCCESS == rc)) { \
4040
count = 1; \
4141
} \
4242
} else { \
@@ -50,7 +50,7 @@ extern int ompi_ts_copy(CFI_cdesc_t *cdesc, char *buffer);
5050
if (x->rank != 0 && !CFI_is_contiguous(x)) { \
5151
size_t size = ompi_ts_size(x); \
5252
buffer = malloc(size); \
53-
if (NULL == buffer) { \
53+
if (OPAL_UNLIKELY(NULL == buffer)) { \
5454
rc = MPI_ERR_NO_MEM; \
5555
} else { \
5656
rc = MPI_SUCCESS; \
@@ -67,7 +67,7 @@ extern int ompi_ts_copy(CFI_cdesc_t *cdesc, char *buffer);
6767
if (x->rank != 0 && !CFI_is_contiguous(x)) { \
6868
size_t size = ompi_ts_size(x); \
6969
buffer = malloc(size); \
70-
if (NULL == buffer) { \
70+
if (OPAL_UNLIKELY(NULL == buffer)) { \
7171
rc = MPI_ERR_NO_MEM; \
7272
} else { \
7373
rc = ompi_ts_copy(x, buffer); \
@@ -84,18 +84,18 @@ extern int ompi_ts_copy(CFI_cdesc_t *cdesc, char *buffer);
8484
free(buffer); \
8585
} \
8686
if (type != datatype) { \
87-
rc = PMPI_Type_free(&datatype); \
87+
rc = PMPI_Type_free(&datatype); \
8888
} \
8989
} while (0)
9090

9191
#define OMPI_C_2_CFI_COPY(x, buffer, count, type, datatype, rc) \
9292
do { \
9393
if (buffer != x->base_addr) { \
94-
rc = ompi_ts_copy_back(buffer, x); \
94+
rc = ompi_ts_copy_back(buffer, x); \
9595
free(buffer); \
9696
} \
9797
if (type != datatype) { \
98-
rc = PMPI_Type_free(&datatype); \
98+
rc = PMPI_Type_free(&datatype); \
9999
} \
100100
} while (0)
101101

0 commit comments

Comments
 (0)