Skip to content

Commit c79bc2d

Browse files
committed
opal/datatype: replace int(32) argument types with size_t
This patch prepares the opal datatype engine for large count support. Related function arguments need to accept size_t input, and accordingly we had to modify codes where those functions are called with smaller integer types. Signed-off-by: Wenduo Wang <wenduwan@amazon.com>
1 parent 20b900e commit c79bc2d

8 files changed

+26
-25
lines changed

ompi/datatype/ompi_datatype.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -278,19 +278,20 @@ static inline int32_t
278278
ompi_datatype_copy_content_same_ddt( const ompi_datatype_t* type, size_t count,
279279
char* pDestBuf, char* pSrcBuf )
280280
{
281-
int32_t length, rc;
281+
int32_t rc;
282+
size_t length;
282283
ptrdiff_t extent;
283284

284285
ompi_datatype_type_extent( type, &extent );
285286
while( 0 != count ) {
286287
length = INT_MAX;
287-
if( ((size_t)length) > count ) length = (int32_t)count;
288+
if( length > count ) length = count;
288289
rc = opal_datatype_copy_content_same_ddt( &type->super, length,
289290
pDestBuf, pSrcBuf );
290291
if( 0 != rc ) return rc;
291292
pDestBuf += ((ptrdiff_t)length) * extent;
292293
pSrcBuf += ((ptrdiff_t)length) * extent;
293-
count -= (size_t)length;
294+
count -= length;
294295
}
295296
return 0;
296297
}

opal/datatype/opal_datatype.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ OPAL_DECLSPEC extern const opal_datatype_t opal_datatype_unsigned_long;
194194
*/
195195
int opal_datatype_register_params(void);
196196
OPAL_DECLSPEC int32_t opal_datatype_init(void);
197-
OPAL_DECLSPEC opal_datatype_t *opal_datatype_create(int32_t expectedSize);
198-
OPAL_DECLSPEC int32_t opal_datatype_create_desc(opal_datatype_t *datatype, int32_t expectedSize);
197+
OPAL_DECLSPEC opal_datatype_t *opal_datatype_create(size_t expectedSize);
198+
OPAL_DECLSPEC int32_t opal_datatype_create_desc(opal_datatype_t *datatype, size_t expectedSize);
199199
OPAL_DECLSPEC int32_t opal_datatype_commit(opal_datatype_t *pData);
200200
OPAL_DECLSPEC int32_t opal_datatype_destroy(opal_datatype_t **);
201201
OPAL_DECLSPEC int32_t opal_datatype_is_monotonic(opal_datatype_t *type);
@@ -225,7 +225,7 @@ static inline int32_t opal_datatype_is_predefined(const opal_datatype_t *type)
225225
* is contiguous in the memory. And false (0) otherwise.
226226
*/
227227
static inline int32_t opal_datatype_is_contiguous_memory_layout(const opal_datatype_t *datatype,
228-
int32_t count)
228+
size_t count)
229229
{
230230
if (!(datatype->flags & OPAL_DATATYPE_FLAG_CONTIGUOUS))
231231
return 0;
@@ -246,7 +246,7 @@ OPAL_DECLSPEC int32_t opal_datatype_clone(const opal_datatype_t *src_type,
246246
/**
247247
* A contiguous array of identical datatypes.
248248
*/
249-
OPAL_DECLSPEC int32_t opal_datatype_create_contiguous(int count, const opal_datatype_t *oldType,
249+
OPAL_DECLSPEC int32_t opal_datatype_create_contiguous(size_t count, const opal_datatype_t *oldType,
250250
opal_datatype_t **newType);
251251
/**
252252
* Add a new datatype to the base type description. The count is the number
@@ -306,7 +306,7 @@ OPAL_DECLSPEC ssize_t opal_datatype_get_element_count(const opal_datatype_t *pDa
306306
OPAL_DECLSPEC int32_t opal_datatype_set_element_count(const opal_datatype_t *pData, size_t count,
307307
size_t *length);
308308
OPAL_DECLSPEC int32_t opal_datatype_copy_content_same_ddt(const opal_datatype_t *pData,
309-
int32_t count, char *pDestBuf,
309+
size_t count, char *pDestBuf,
310310
char *pSrcBuf);
311311

312312
OPAL_DECLSPEC int opal_datatype_compute_ptypes(opal_datatype_t *datatype);
@@ -348,10 +348,10 @@ static inline ptrdiff_t opal_datatype_span(const opal_datatype_t *pData, size_t
348348
* to make it stop on all pack and unpack errors.
349349
*/
350350
OPAL_DECLSPEC int opal_datatype_safeguard_pointer_debug_breakpoint(const void *actual_ptr,
351-
int length,
351+
size_t length,
352352
const void *initial_ptr,
353353
const opal_datatype_t *pData,
354-
int count);
354+
size_t count);
355355
#endif /* OPAL_ENABLE_DEBUG */
356356

357357
END_C_DECLS

opal/datatype/opal_datatype_copy.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ static void *opal_datatype_accelerator_memmove(void *dest, const void *src, size
137137
#define MEM_OP opal_datatype_accelerator_memmove
138138
#include "opal_datatype_copy.h"
139139

140-
int32_t opal_datatype_copy_content_same_ddt(const opal_datatype_t *datatype, int32_t count,
140+
int32_t opal_datatype_copy_content_same_ddt(const opal_datatype_t *datatype, size_t count,
141141
char *destination_base, char *source_base)
142142
{
143143
ptrdiff_t extent;
144-
int32_t (*fct)(const opal_datatype_t *, int32_t, char *, char *);
144+
int32_t (*fct)(const opal_datatype_t *, size_t, char *, char *);
145145

146-
DO_DEBUG(opal_output(0, "opal_datatype_copy_content_same_ddt( %p, %d, dst %p, src %p )\n",
146+
DO_DEBUG(opal_output(0, "opal_datatype_copy_content_same_ddt( %p, %zu, dst %p, src %p )\n",
147147
(void *) datatype, count, (void *) destination_base,
148148
(void *) source_base););
149149

opal/datatype/opal_datatype_copy.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static inline void _contiguous_loop(const dt_elem_desc_t *ELEM, const opal_datat
109109
*(SPACE) -= _copy_loops;
110110
}
111111

112-
static inline int32_t _copy_content_same_ddt(const opal_datatype_t *datatype, int32_t count,
112+
static inline int32_t _copy_content_same_ddt(const opal_datatype_t *datatype, size_t count,
113113
char *destination_base, char *source_base)
114114
{
115115
dt_stack_t *pStack; /* pointer to the position on the stack */
@@ -122,10 +122,10 @@ static inline int32_t _copy_content_same_ddt(const opal_datatype_t *datatype, in
122122
unsigned char *source = (unsigned char *) source_base,
123123
*destination = (unsigned char *) destination_base;
124124

125-
DO_DEBUG(opal_output(0, "_copy_content_same_ddt( %p, %d, dst %p, src %p )\n", (void *) datatype,
125+
DO_DEBUG(opal_output(0, "_copy_content_same_ddt( %p, %zu, dst %p, src %p )\n", (void *) datatype,
126126
count, (void *) destination_base, (void *) source_base););
127127

128-
iov_len_local = (size_t) count * datatype->size;
128+
iov_len_local = count * datatype->size;
129129

130130
/* If we have to copy a contiguous datatype then simply
131131
* do a MEM_OP.
@@ -155,7 +155,7 @@ static inline int32_t _copy_content_same_ddt(const opal_datatype_t *datatype, in
155155
}
156156
return 0; /* completed */
157157
}
158-
for (pos_desc = 0; (int32_t) pos_desc < count; pos_desc++) {
158+
for (pos_desc = 0; pos_desc < count; pos_desc++) {
159159
OPAL_DATATYPE_SAFEGUARD_POINTER(destination, datatype->size,
160160
(unsigned char *) destination_base, datatype, count);
161161
OPAL_DATATYPE_SAFEGUARD_POINTER(source, datatype->size, (unsigned char *) source_base,

opal/datatype/opal_datatype_create.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ static void opal_datatype_destruct(opal_datatype_t *datatype)
9191

9292
OBJ_CLASS_INSTANCE(opal_datatype_t, opal_object_t, opal_datatype_construct, opal_datatype_destruct);
9393

94-
opal_datatype_t *opal_datatype_create(int32_t expectedSize)
94+
opal_datatype_t *opal_datatype_create(size_t expectedSize)
9595
{
9696
opal_datatype_t *datatype = (opal_datatype_t *) OBJ_NEW(opal_datatype_t);
9797

98-
if (expectedSize == -1) {
98+
if (expectedSize == (size_t) -1) {
9999
expectedSize = DT_INCREASE_STACK;
100100
}
101101
datatype->desc.length = expectedSize + 1; /* one for the fake elem at the end */
@@ -107,9 +107,9 @@ opal_datatype_t *opal_datatype_create(int32_t expectedSize)
107107
return datatype;
108108
}
109109

110-
int32_t opal_datatype_create_desc(opal_datatype_t *datatype, int32_t expectedSize)
110+
int32_t opal_datatype_create_desc(opal_datatype_t *datatype, size_t expectedSize)
111111
{
112-
if (expectedSize == -1) {
112+
if (expectedSize == (size_t) -1) {
113113
expectedSize = DT_INCREASE_STACK;
114114
}
115115
datatype->desc.length = expectedSize + 1; /* one for the fake elem at the end */

opal/datatype/opal_datatype_create_contiguous.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "opal/datatype/opal_datatype.h"
2525
#include "opal/datatype/opal_datatype_internal.h"
2626

27-
int32_t opal_datatype_create_contiguous(int count, const opal_datatype_t *oldType,
27+
int32_t opal_datatype_create_contiguous(size_t count, const opal_datatype_t *oldType,
2828
opal_datatype_t **newType)
2929
{
3030
opal_datatype_t *pdt;

opal/datatype/opal_datatype_module.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ int32_t opal_datatype_init(void)
293293
* Set a breakpoint to this function in your favorite debugger
294294
* to make it stop on all pack and unpack errors.
295295
*/
296-
int opal_datatype_safeguard_pointer_debug_breakpoint(const void *actual_ptr, int length,
296+
int opal_datatype_safeguard_pointer_debug_breakpoint(const void *actual_ptr, size_t length,
297297
const void *initial_ptr,
298-
const opal_datatype_t *pData, int count)
298+
const opal_datatype_t *pData, size_t count)
299299
{
300300
return 0;
301301
}

test/datatype/opal_ddt_lib.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static int32_t opal_datatype_create_struct(int count, const int *pBlockLength,
408408
lastDisp = pDisp[0];
409409
endto = pDisp[0] + lastExtent * lastBlock;
410410

411-
pdt = opal_datatype_create((int32_t) disp);
411+
pdt = opal_datatype_create((size_t) disp);
412412

413413
/* Do again the same loop but now add the elements */
414414
for (i = 1; i < count; i++) {

0 commit comments

Comments
 (0)