Skip to content

Commit a8b244e

Browse files
author
hasegawa.kento
committed
COLL/UCC: Standardize flag and mask value assignment
Signed-off-by: hasegawa.kento <hasegawa.kento@fujitsu.com>
1 parent 1b4bf91 commit a8b244e

File tree

9 files changed

+58
-78
lines changed

9 files changed

+58
-78
lines changed

ompi/mca/coll/ucc/coll_ucc_allgather.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ mca_coll_ucc_allgather_init_common(const void *sbuf, size_t scount, struct ompi_
2020
ucc_datatype_t ucc_sdt = UCC_DT_INT8, ucc_rdt = UCC_DT_INT8;
2121
bool is_inplace = (MPI_IN_PLACE == sbuf);
2222
int comm_size = ompi_comm_size(ucc_module->comm);
23+
uint64_t flags = 0;
2324

2425
if (!(is_inplace || ompi_datatype_is_contiguous_memory_layout(sdtype, scount)) ||
2526
!ompi_datatype_is_contiguous_memory_layout(rdtype, rcount * comm_size)) {
@@ -39,9 +40,12 @@ mca_coll_ucc_allgather_init_common(const void *sbuf, size_t scount, struct ompi_
3940
goto fallback;
4041
}
4142

43+
flags = (is_inplace ? UCC_COLL_ARGS_FLAG_IN_PLACE : 0) |
44+
(persistent ? UCC_COLL_ARGS_FLAG_PERSISTENT : 0);
45+
4246
ucc_coll_args_t coll = {
43-
.mask = 0,
44-
.flags = 0,
47+
.mask = flags ? UCC_COLL_ARGS_FIELD_FLAGS : 0,
48+
.flags = flags,
4549
.coll_type = UCC_COLL_TYPE_ALLGATHER,
4650
.src.info = {
4751
.buffer = (void*)sbuf,
@@ -57,14 +61,6 @@ mca_coll_ucc_allgather_init_common(const void *sbuf, size_t scount, struct ompi_
5761
}
5862
};
5963

60-
if (is_inplace) {
61-
coll.mask = UCC_COLL_ARGS_FIELD_FLAGS;
62-
coll.flags = UCC_COLL_ARGS_FLAG_IN_PLACE;
63-
}
64-
if (true == persistent) {
65-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
66-
coll.flags |= UCC_COLL_ARGS_FLAG_PERSISTENT;
67-
}
6864
COLL_UCC_REQ_INIT(coll_req, req, coll, ucc_module);
6965
return UCC_OK;
7066
fallback:

ompi/mca/coll/ucc/coll_ucc_allreduce.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static inline ucc_status_t mca_coll_ucc_allreduce_init_common(const void *sbuf,
1818
{
1919
ucc_datatype_t ucc_dt;
2020
ucc_reduction_op_t ucc_op;
21+
uint64_t flags = 0;
2122

2223
ucc_dt = ompi_dtype_to_ucc_dtype(dtype);
2324
ucc_op = ompi_op_to_ucc_op(op);
@@ -31,9 +32,13 @@ static inline ucc_status_t mca_coll_ucc_allreduce_init_common(const void *sbuf,
3132
op->o_name);
3233
goto fallback;
3334
}
35+
36+
flags = ((MPI_IN_PLACE == sbuf) ? UCC_COLL_ARGS_FLAG_IN_PLACE : 0) |
37+
(persistent ? UCC_COLL_ARGS_FLAG_PERSISTENT : 0);
38+
3439
ucc_coll_args_t coll = {
35-
.mask = 0,
36-
.flags = 0,
40+
.mask = flags ? UCC_COLL_ARGS_FIELD_FLAGS : 0,
41+
.flags = flags,
3742
.coll_type = UCC_COLL_TYPE_ALLREDUCE,
3843
.src.info = {
3944
.buffer = (void*)sbuf,
@@ -49,14 +54,7 @@ static inline ucc_status_t mca_coll_ucc_allreduce_init_common(const void *sbuf,
4954
},
5055
.op = ucc_op,
5156
};
52-
if (MPI_IN_PLACE == sbuf) {
53-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
54-
coll.flags = UCC_COLL_ARGS_FLAG_IN_PLACE;
55-
}
56-
if (true == persistent) {
57-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
58-
coll.flags |= UCC_COLL_ARGS_FLAG_PERSISTENT;
59-
}
57+
6058
COLL_UCC_REQ_INIT(coll_req, req, coll, ucc_module);
6159
return UCC_OK;
6260
fallback:

ompi/mca/coll/ucc/coll_ucc_alltoall.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ mca_coll_ucc_alltoall_init_common(const void *sbuf, size_t scount, struct ompi_d
2020
ucc_datatype_t ucc_sdt = UCC_DT_INT8, ucc_rdt = UCC_DT_INT8;
2121
bool is_inplace = (MPI_IN_PLACE == sbuf);
2222
int comm_size = ompi_comm_size(ucc_module->comm);
23+
uint64_t flags = 0;
2324

2425
if (!(is_inplace || ompi_datatype_is_contiguous_memory_layout(sdtype, scount * comm_size)) ||
2526
!ompi_datatype_is_contiguous_memory_layout(rdtype, rcount * comm_size)) {
@@ -39,9 +40,12 @@ mca_coll_ucc_alltoall_init_common(const void *sbuf, size_t scount, struct ompi_d
3940
goto fallback;
4041
}
4142

43+
flags = (is_inplace ? UCC_COLL_ARGS_FLAG_IN_PLACE : 0) |
44+
(persistent ? UCC_COLL_ARGS_FLAG_PERSISTENT : 0);
45+
4246
ucc_coll_args_t coll = {
43-
.mask = 0,
44-
.flags = 0,
47+
.mask = flags ? UCC_COLL_ARGS_FIELD_FLAGS : 0,
48+
.flags = flags,
4549
.coll_type = UCC_COLL_TYPE_ALLTOALL,
4650
.src.info = {
4751
.buffer = (void*)sbuf,
@@ -57,14 +61,6 @@ mca_coll_ucc_alltoall_init_common(const void *sbuf, size_t scount, struct ompi_d
5761
}
5862
};
5963

60-
if (is_inplace) {
61-
coll.mask = UCC_COLL_ARGS_FIELD_FLAGS;
62-
coll.flags = UCC_COLL_ARGS_FLAG_IN_PLACE;
63-
}
64-
if (true == persistent) {
65-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
66-
coll.flags |= UCC_COLL_ARGS_FLAG_PERSISTENT;
67-
}
6864
COLL_UCC_REQ_INIT(coll_req, req, coll, ucc_module);
6965
return UCC_OK;
7066
fallback:

ompi/mca/coll/ucc/coll_ucc_barrier.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ static inline ucc_status_t mca_coll_ucc_barrier_init_common(bool persistent, mca
1313
ucc_coll_req_h *req,
1414
mca_coll_ucc_req_t *coll_req)
1515
{
16+
uint64_t flags = 0;
17+
18+
flags = (persistent ? UCC_COLL_ARGS_FLAG_PERSISTENT : 0);
19+
1620
ucc_coll_args_t coll = {
17-
.mask = 0,
18-
.flags = 0,
21+
.mask = flags ? UCC_COLL_ARGS_FIELD_FLAGS : 0,
22+
.flags = flags,
1923
.coll_type = UCC_COLL_TYPE_BARRIER
2024
};
2125

22-
if (true == persistent) {
23-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
24-
coll.flags |= UCC_COLL_ARGS_FLAG_PERSISTENT;
25-
}
2626
COLL_UCC_REQ_INIT(coll_req, req, coll, ucc_module);
2727
return UCC_OK;
2828
fallback:

ompi/mca/coll/ucc/coll_ucc_bcast.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ mca_coll_ucc_bcast_init_common(void *buf, size_t count, struct ompi_datatype_t *
1616
mca_coll_ucc_req_t *coll_req)
1717
{
1818
ucc_datatype_t ucc_dt = ompi_dtype_to_ucc_dtype(dtype);
19+
uint64_t flags = 0;
20+
1921
if (COLL_UCC_DT_UNSUPPORTED == ucc_dt) {
2022
UCC_VERBOSE(5, "ompi_datatype is not supported: dtype = %s", dtype->super.name);
2123
goto fallback;
2224
}
2325

26+
flags = (persistent ? UCC_COLL_ARGS_FLAG_PERSISTENT : 0);
27+
2428
ucc_coll_args_t coll = {
25-
.mask = 0,
26-
.flags = 0,
29+
.mask = flags ? UCC_COLL_ARGS_FIELD_FLAGS : 0,
30+
.flags = flags,
2731
.coll_type = UCC_COLL_TYPE_BCAST,
2832
.root = root,
2933
.src.info = {
@@ -34,10 +38,6 @@ mca_coll_ucc_bcast_init_common(void *buf, size_t count, struct ompi_datatype_t *
3438
}
3539
};
3640

37-
if (true == persistent) {
38-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
39-
coll.flags |= UCC_COLL_ARGS_FLAG_PERSISTENT;
40-
}
4141
COLL_UCC_REQ_INIT(coll_req, req, coll, ucc_module);
4242
return UCC_OK;
4343
fallback:

ompi/mca/coll/ucc/coll_ucc_gather.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mca_coll_ucc_gather_init_common(const void *sbuf, size_t scount, struct ompi_dat
2222
bool is_inplace = (MPI_IN_PLACE == sbuf);
2323
int comm_rank = ompi_comm_rank(ucc_module->comm);
2424
int comm_size = ompi_comm_size(ucc_module->comm);
25+
uint64_t flags = 0;
2526

2627
if (comm_rank == root) {
2728
if (!(is_inplace || ompi_datatype_is_contiguous_memory_layout(sdtype, scount)) ||
@@ -54,9 +55,12 @@ mca_coll_ucc_gather_init_common(const void *sbuf, size_t scount, struct ompi_dat
5455
}
5556
}
5657

58+
flags = (is_inplace ? UCC_COLL_ARGS_FLAG_IN_PLACE : 0) |
59+
(persistent ? UCC_COLL_ARGS_FLAG_PERSISTENT : 0);
60+
5761
ucc_coll_args_t coll = {
58-
.mask = 0,
59-
.flags = 0,
62+
.mask = flags ? UCC_COLL_ARGS_FIELD_FLAGS : 0,
63+
.flags = flags,
6064
.coll_type = UCC_COLL_TYPE_GATHER,
6165
.root = root,
6266
.src.info = {
@@ -73,14 +77,6 @@ mca_coll_ucc_gather_init_common(const void *sbuf, size_t scount, struct ompi_dat
7377
},
7478
};
7579

76-
if (is_inplace) {
77-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
78-
coll.flags = UCC_COLL_ARGS_FLAG_IN_PLACE;
79-
}
80-
if (true == persistent) {
81-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
82-
coll.flags |= UCC_COLL_ARGS_FLAG_PERSISTENT;
83-
}
8480
COLL_UCC_REQ_INIT(coll_req, req, coll, ucc_module);
8581
return UCC_OK;
8682
fallback:

ompi/mca/coll/ucc/coll_ucc_reduce.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static inline ucc_status_t mca_coll_ucc_reduce_init_common(const void *sbuf, voi
1818
{
1919
ucc_datatype_t ucc_dt;
2020
ucc_reduction_op_t ucc_op;
21+
uint64_t flags = 0;
2122

2223
ucc_dt = ompi_dtype_to_ucc_dtype(dtype);
2324
ucc_op = ompi_op_to_ucc_op(op);
@@ -31,9 +32,13 @@ static inline ucc_status_t mca_coll_ucc_reduce_init_common(const void *sbuf, voi
3132
op->o_name);
3233
goto fallback;
3334
}
35+
36+
flags = ((MPI_IN_PLACE == sbuf) ? UCC_COLL_ARGS_FLAG_IN_PLACE : 0) |
37+
(persistent ? UCC_COLL_ARGS_FLAG_PERSISTENT : 0);
38+
3439
ucc_coll_args_t coll = {
35-
.mask = 0,
36-
.flags = 0,
40+
.mask = flags ? UCC_COLL_ARGS_FIELD_FLAGS : 0,
41+
.flags = flags,
3742
.coll_type = UCC_COLL_TYPE_REDUCE,
3843
.root = root,
3944
.src.info = {
@@ -50,14 +55,7 @@ static inline ucc_status_t mca_coll_ucc_reduce_init_common(const void *sbuf, voi
5055
},
5156
.op = ucc_op,
5257
};
53-
if (MPI_IN_PLACE == sbuf) {
54-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
55-
coll.flags = UCC_COLL_ARGS_FLAG_IN_PLACE;
56-
}
57-
if (true == persistent) {
58-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
59-
coll.flags |= UCC_COLL_ARGS_FLAG_PERSISTENT;
60-
}
58+
6159
COLL_UCC_REQ_INIT(coll_req, req, coll, ucc_module);
6260
return UCC_OK;
6361
fallback:

ompi/mca/coll/ucc/coll_ucc_reduce_scatter_block.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mca_coll_ucc_reduce_scatter_block_init_common(const void *sbuf, void *rbuf,
2222
ucc_datatype_t ucc_dt;
2323
ucc_reduction_op_t ucc_op;
2424
int comm_size = ompi_comm_size(ucc_module->comm);
25+
uint64_t flags = 0;
2526

2627
if (MPI_IN_PLACE == sbuf) {
2728
/* TODO: UCC defines inplace differently:
@@ -41,9 +42,12 @@ mca_coll_ucc_reduce_scatter_block_init_common(const void *sbuf, void *rbuf,
4142
op->o_name);
4243
goto fallback;
4344
}
45+
46+
flags = (persistent ? UCC_COLL_ARGS_FLAG_PERSISTENT : 0);
47+
4448
ucc_coll_args_t coll = {
45-
.mask = 0,
46-
.flags = 0,
49+
.mask = flags ? UCC_COLL_ARGS_FIELD_FLAGS : 0,
50+
.flags = flags,
4751
.coll_type = UCC_COLL_TYPE_REDUCE_SCATTER,
4852
.src.info = {
4953
.buffer = (void*)sbuf,
@@ -60,10 +64,6 @@ mca_coll_ucc_reduce_scatter_block_init_common(const void *sbuf, void *rbuf,
6064
.op = ucc_op,
6165
};
6266

63-
if (true == persistent) {
64-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
65-
coll.flags |= UCC_COLL_ARGS_FLAG_PERSISTENT;
66-
}
6767
COLL_UCC_REQ_INIT(coll_req, req, coll, ucc_module);
6868
return UCC_OK;
6969
fallback:

ompi/mca/coll/ucc/coll_ucc_scatter.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mca_coll_ucc_scatter_init_common(const void *sbuf, size_t scount,
2323
bool is_inplace = (MPI_IN_PLACE == rbuf);
2424
int comm_rank = ompi_comm_rank(ucc_module->comm);
2525
int comm_size = ompi_comm_size(ucc_module->comm);
26+
uint64_t flags = 0;
2627

2728
if (comm_rank == root) {
2829
if (!(is_inplace || ompi_datatype_is_contiguous_memory_layout(rdtype, rcount)) ||
@@ -55,9 +56,12 @@ mca_coll_ucc_scatter_init_common(const void *sbuf, size_t scount,
5556
}
5657
}
5758

59+
flags = (is_inplace ? UCC_COLL_ARGS_FLAG_IN_PLACE : 0) |
60+
(persistent ? UCC_COLL_ARGS_FLAG_PERSISTENT : 0);
61+
5862
ucc_coll_args_t coll = {
59-
.mask = 0,
60-
.flags = 0,
63+
.mask = flags ? UCC_COLL_ARGS_FIELD_FLAGS : 0,
64+
.flags = flags,
6165
.coll_type = UCC_COLL_TYPE_SCATTER,
6266
.root = root,
6367
.src.info = {
@@ -74,14 +78,6 @@ mca_coll_ucc_scatter_init_common(const void *sbuf, size_t scount,
7478
},
7579
};
7680

77-
if (is_inplace) {
78-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
79-
coll.flags = UCC_COLL_ARGS_FLAG_IN_PLACE;
80-
}
81-
if (true == persistent) {
82-
coll.mask |= UCC_COLL_ARGS_FIELD_FLAGS;
83-
coll.flags |= UCC_COLL_ARGS_FLAG_PERSISTENT;
84-
}
8581
COLL_UCC_REQ_INIT(coll_req, req, coll, ucc_module);
8682
return UCC_OK;
8783
fallback:

0 commit comments

Comments
 (0)