Skip to content

Commit a1b1855

Browse files
authored
Merge pull request #3512 from matcabral/psm_max_message_size
PSM and PSM2 MTLs check on the max message size allowed by API.
2 parents 43b6f00 + 03aa3dd commit a1b1855

File tree

6 files changed

+62
-6
lines changed

6 files changed

+62
-6
lines changed

ompi/mca/mtl/psm/help-mtl-psm.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ Unable to post application receive buffer (psm_mq_irecv).
3737

3838
Error: %s
3939
Buffer: %p
40-
Length: %d
40+
Length: %llu
4141
#
4242
[path query mechanism unknown]
4343
Unknown path record query mechanism %s. Supported mechanisms are %s.
44+
#
45+
[message too big]
46+
Message size %llu bigger than supported by PSM API. Max = %llu

ompi/mca/mtl/psm/mtl_psm_recv.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ ompi_mtl_psm_irecv(struct mca_mtl_base_module_t* mtl,
5050

5151
if (OMPI_SUCCESS != ret) return ret;
5252

53+
if (length >= 1ULL << sizeof(uint32_t) * 8) {
54+
opal_show_help("help-mtl-psm.txt",
55+
"message too big", false,
56+
length, 1ULL << sizeof(uint32_t) * 8);
57+
return OMPI_ERROR;
58+
}
59+
5360
mtl_psm_request->length = length;
5461
mtl_psm_request->convertor = convertor;
5562
mtl_psm_request->type = OMPI_MTL_PSM_IRECV;

ompi/mca/mtl/psm/mtl_psm_send.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "ompi/mca/pml/pml.h"
2525
#include "ompi/communicator/communicator.h"
2626
#include "opal/datatype/opal_convertor.h"
27+
#include "opal/util/show_help.h"
2728

2829
#include "mtl_psm.h"
2930
#include "mtl_psm_types.h"
@@ -56,13 +57,19 @@ ompi_mtl_psm_send(struct mca_mtl_base_module_t* mtl,
5657
&length,
5758
&mtl_psm_request.free_after);
5859

60+
if (OMPI_SUCCESS != ret) return ret;
61+
62+
if (length >= 1ULL << sizeof(uint32_t) * 8) {
63+
opal_show_help("help-mtl-psm.txt",
64+
"message too big", false,
65+
length, 1ULL << sizeof(uint32_t) * 8);
66+
return OMPI_ERROR;
67+
}
5968

6069
mtl_psm_request.length = length;
6170
mtl_psm_request.convertor = convertor;
6271
mtl_psm_request.type = OMPI_MTL_PSM_ISEND;
6372

64-
if (OMPI_SUCCESS != ret) return ret;
65-
6673
if (mode == MCA_PML_BASE_SEND_SYNCHRONOUS)
6774
flags |= PSM_MQ_FLAG_SENDSYNC;
6875

@@ -109,12 +116,20 @@ ompi_mtl_psm_isend(struct mca_mtl_base_module_t* mtl,
109116
&length,
110117
&mtl_psm_request->free_after);
111118

119+
120+
if (OMPI_SUCCESS != ret) return ret;
121+
122+
if (length >= 1ULL << sizeof(uint32_t) * 8) {
123+
opal_show_help("help-mtl-psm.txt",
124+
"message too big", false,
125+
length, 1ULL << sizeof(uint32_t) * 8);
126+
return OMPI_ERROR;
127+
}
128+
112129
mtl_psm_request->length= length;
113130
mtl_psm_request->convertor = convertor;
114131
mtl_psm_request->type = OMPI_MTL_PSM_ISEND;
115132

116-
if (OMPI_SUCCESS != ret) return ret;
117-
118133
if (mode == MCA_PML_BASE_SEND_SYNCHRONOUS)
119134
flags |= PSM_MQ_FLAG_SENDSYNC;
120135

ompi/mca/mtl/psm2/help-mtl-psm2.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ Unable to post application receive buffer (psm2_mq_irecv or psm2_mq_imrecv).
3838

3939
Error: %s
4040
Buffer: %p
41-
Length: %d
41+
Length: %llu
4242
#
4343
[path query mechanism unknown]
4444
Unknown path record query mechanism %s. Supported mechanisms are %s.
45+
#
46+
[message too big]
47+
Message size %llu bigger than supported by PSM2 API. Max = %llu

ompi/mca/mtl/psm2/mtl_psm2_recv.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ ompi_mtl_psm2_irecv(struct mca_mtl_base_module_t* mtl,
5252

5353
if (OMPI_SUCCESS != ret) return ret;
5454

55+
if (length >= 1ULL << sizeof(uint32_t) * 8) {
56+
opal_show_help("help-mtl-psm2.txt",
57+
"message too big", false,
58+
length, 1ULL << sizeof(uint32_t) * 8);
59+
return OMPI_ERROR;
60+
}
61+
5562
mtl_psm2_request->length = length;
5663
mtl_psm2_request->convertor = convertor;
5764
mtl_psm2_request->type = OMPI_mtl_psm2_IRECV;
@@ -102,6 +109,13 @@ ompi_mtl_psm2_imrecv(struct mca_mtl_base_module_t* mtl,
102109

103110
if (OMPI_SUCCESS != ret) return ret;
104111

112+
if (length >= 1ULL << sizeof(uint32_t) * 8) {
113+
opal_show_help("help-mtl-psm2.txt",
114+
"message too big", false,
115+
length, 1ULL << sizeof(uint32_t) * 8);
116+
return OMPI_ERROR;
117+
}
118+
105119
mtl_psm2_request->length = length;
106120
mtl_psm2_request->convertor = convertor;
107121
mtl_psm2_request->type = OMPI_mtl_psm2_IRECV;

ompi/mca/mtl/psm2/mtl_psm2_send.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "ompi/mca/pml/pml.h"
2323
#include "ompi/communicator/communicator.h"
2424
#include "opal/datatype/opal_convertor.h"
25+
#include "opal/util/show_help.h"
2526

2627
#include "mtl_psm2.h"
2728
#include "mtl_psm2_types.h"
@@ -54,6 +55,12 @@ ompi_mtl_psm2_send(struct mca_mtl_base_module_t* mtl,
5455
&length,
5556
&mtl_psm2_request.free_after);
5657

58+
if (length >= 1ULL << sizeof(uint32_t) * 8) {
59+
opal_show_help("help-mtl-psm2.txt",
60+
"message too big", false,
61+
length, 1ULL << sizeof(uint32_t) * 8);
62+
return OMPI_ERROR;
63+
}
5764

5865
mtl_psm2_request.length = length;
5966
mtl_psm2_request.convertor = convertor;
@@ -107,6 +114,13 @@ ompi_mtl_psm2_isend(struct mca_mtl_base_module_t* mtl,
107114
&length,
108115
&mtl_psm2_request->free_after);
109116

117+
if (length >= 1ULL << sizeof(uint32_t) * 8) {
118+
opal_show_help("help-mtl-psm2.txt",
119+
"message too big", false,
120+
length, 1ULL << sizeof(uint32_t) * 8);
121+
return OMPI_ERROR;
122+
}
123+
110124
mtl_psm2_request->length= length;
111125
mtl_psm2_request->convertor = convertor;
112126
mtl_psm2_request->type = OMPI_mtl_psm2_ISEND;

0 commit comments

Comments
 (0)