Skip to content

Commit

Permalink
romio: add assertions in large count functions
Browse files Browse the repository at this point in the history
In future PR, we'll make internal count using MPI_Aint. For now, we
simply assert the values to fit in a int, and let compiler convert
MPI_Count into int.
  • Loading branch information
hzhou committed May 18, 2021
1 parent f5b4a8a commit 901d61a
Show file tree
Hide file tree
Showing 28 changed files with 100 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/mpi/romio/mpi-io/iread.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -108,6 +110,7 @@ Output Parameters:
int MPI_File_iread_c(MPI_File fh, void *buf, MPI_Count count, MPI_Datatype datatype,
MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code = MPI_SUCCESS;
static char myname[] = "MPI_FILE_IREAD";
#ifdef MPI_hpux
Expand Down Expand Up @@ -137,6 +140,7 @@ int MPI_File_iread_c(MPI_File fh, void *buf, MPI_Count count, MPI_Datatype datat
int MPIOI_File_iread(MPI_File fh, MPI_Offset offset, int file_ptr_type, void *buf, int count,
MPI_Datatype datatype, char *myname, MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code, buftype_is_contig, filetype_is_contig;
MPI_Count datatype_size;
ADIO_Status status;
Expand Down
4 changes: 4 additions & 0 deletions src/mpi/romio/mpi-io/iread_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -110,6 +112,7 @@ Output Parameters:
int MPI_File_iread_all_c(MPI_File fh, void *buf, MPI_Count count,
MPI_Datatype datatype, MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_IREAD_ALL";
#ifdef MPI_hpux
Expand Down Expand Up @@ -143,6 +146,7 @@ int MPIOI_File_iread_all(MPI_File fh,
void *buf,
int count, MPI_Datatype datatype, char *myname, MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code;
MPI_Count datatype_size;
ADIO_File adio_fh;
Expand Down
3 changes: 3 additions & 0 deletions src/mpi/romio/mpi-io/iread_at.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -112,6 +114,7 @@ Output Parameters:
int MPI_File_iread_at_c(MPI_File fh, MPI_Offset offset, void *buf, MPI_Count count,
MPI_Datatype datatype, MPIO_Request * request)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_IREAD_AT";

Expand Down
3 changes: 3 additions & 0 deletions src/mpi/romio/mpi-io/iread_atall.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -111,6 +113,7 @@ Output Parameters:
int MPI_File_iread_at_all_c(MPI_File fh, MPI_Offset offset, void *buf,
MPI_Count count, MPI_Datatype datatype, MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_IREAD_AT_ALL";
#ifdef MPI_hpux
Expand Down
4 changes: 4 additions & 0 deletions src/mpi/romio/mpi-io/iread_sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -85,13 +87,15 @@ Output Parameters:
int MPI_File_iread_shared_c(MPI_File fh, void *buf, MPI_Count count,
MPI_Datatype datatype, MPI_Request * request)
{
assert(count <= INT_MAX);
return MPIOI_File_iread_shared(fh, buf, count, datatype, request);
}

#ifdef MPIO_BUILD_PROFILING
int MPIOI_File_iread_shared(MPI_File fh, void *buf, int count,
MPI_Datatype datatype, MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code, buftype_is_contig, filetype_is_contig;
ADIO_Offset bufsize;
ADIO_File adio_fh;
Expand Down
4 changes: 4 additions & 0 deletions src/mpi/romio/mpi-io/iwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -108,6 +110,7 @@ Output Parameters:
int MPI_File_iwrite_c(MPI_File fh, ROMIO_CONST void *buf, MPI_Count count,
MPI_Datatype datatype, MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code = MPI_SUCCESS;
static char myname[] = "MPI_FILE_IWRITE";
#ifdef MPI_hpux
Expand Down Expand Up @@ -140,6 +143,7 @@ int MPIOI_File_iwrite(MPI_File fh,
const void *buf,
int count, MPI_Datatype datatype, char *myname, MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code, buftype_is_contig, filetype_is_contig;
MPI_Count datatype_size;
ADIO_Status status;
Expand Down
4 changes: 4 additions & 0 deletions src/mpi/romio/mpi-io/iwrite_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -104,6 +106,7 @@ Output Parameters:
int MPI_File_iwrite_all_c(MPI_File fh, ROMIO_CONST void *buf, MPI_Count count,
MPI_Datatype datatype, MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_IWRITE_ALL";
#ifdef MPI_hpux
Expand Down Expand Up @@ -131,6 +134,7 @@ int MPIOI_File_iwrite_all(MPI_File fh,
const void *buf,
int count, MPI_Datatype datatype, char *myname, MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code;
MPI_Count datatype_size;
ADIO_File adio_fh;
Expand Down
3 changes: 3 additions & 0 deletions src/mpi/romio/mpi-io/iwrite_at.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -115,6 +117,7 @@ Output Parameters:
int MPI_File_iwrite_at_c(MPI_File fh, MPI_Offset offset, ROMIO_CONST void *buf,
MPI_Count count, MPI_Datatype datatype, MPIO_Request * request)
{
assert(count <= INT_MAX);
int error_code;
ADIO_File adio_fh;
static char myname[] = "MPI_FILE_IWRITE_AT";
Expand Down
3 changes: 3 additions & 0 deletions src/mpi/romio/mpi-io/iwrite_atall.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -105,6 +107,7 @@ Output Parameters:
int MPI_File_iwrite_at_all_c(MPI_File fh, MPI_Offset offset, ROMIO_CONST void *buf,
MPI_Count count, MPI_Datatype datatype, MPI_Request * request)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_IWRITE_AT_ALL";
#ifdef MPI_hpux
Expand Down
4 changes: 4 additions & 0 deletions src/mpi/romio/mpi-io/iwrite_sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -89,13 +91,15 @@ Output Parameters:
int MPI_File_iwrite_shared_c(MPI_File fh, ROMIO_CONST void *buf, MPI_Count count,
MPI_Datatype datatype, MPIO_Request * request)
{
assert(count <= INT_MAX);
return MPIOI_File_iwrite_shared(fh, buf, count, datatype, request);
}

#ifdef MPIO_BUILD_PROFILING
int MPIOI_File_iwrite_shared(MPI_File fh, const void *buf, int count,
MPI_Datatype datatype, MPIO_Request * request)
{
assert(count <= INT_MAX);
int error_code, buftype_is_contig, filetype_is_contig;
ADIO_File adio_fh;
ADIO_Offset incr, bufsize;
Expand Down
3 changes: 3 additions & 0 deletions src/mpi/romio/mpi-io/rd_atallb.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -87,6 +89,7 @@ Output Parameters:
int MPI_File_read_at_all_begin_c(MPI_File fh, MPI_Offset offset, void *buf,
MPI_Count count, MPI_Datatype datatype)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_READ_AT_ALL_BEGIN";

Expand Down
4 changes: 4 additions & 0 deletions src/mpi/romio/mpi-io/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -101,6 +103,7 @@ Output Parameters:
int MPI_File_read_c(MPI_File fh, void *buf, MPI_Count count, MPI_Datatype datatype,
MPI_Status * status)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_READ";
#ifdef MPI_hpux
Expand All @@ -126,6 +129,7 @@ int MPIOI_File_read(MPI_File fh,
int file_ptr_type,
void *buf, int count, MPI_Datatype datatype, char *myname, MPI_Status * status)
{
assert(count <= INT_MAX);
int error_code, buftype_is_contig, filetype_is_contig;
MPI_Count datatype_size;
ADIO_File adio_fh;
Expand Down
4 changes: 4 additions & 0 deletions src/mpi/romio/mpi-io/read_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -98,6 +100,7 @@ Output Parameters:
int MPI_File_read_all_c(MPI_File fh, void *buf, MPI_Count count, MPI_Datatype datatype,
MPI_Status * status)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_READ_ALL";
#ifdef MPI_hpux
Expand Down Expand Up @@ -125,6 +128,7 @@ int MPIOI_File_read_all(MPI_File fh,
void *buf,
int count, MPI_Datatype datatype, char *myname, MPI_Status * status)
{
assert(count <= INT_MAX);
int error_code;
MPI_Count datatype_size;
ADIO_File adio_fh;
Expand Down
4 changes: 4 additions & 0 deletions src/mpi/romio/mpi-io/read_allb.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -81,6 +83,7 @@ Output Parameters:
@*/
int MPI_File_read_all_begin_c(MPI_File fh, void *buf, MPI_Count count, MPI_Datatype datatype)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_READ_ALL_BEGIN";

Expand All @@ -97,6 +100,7 @@ int MPIOI_File_read_all_begin(MPI_File fh,
int file_ptr_type,
void *buf, int count, MPI_Datatype datatype, char *myname)
{
assert(count <= INT_MAX);
int error_code;
MPI_Count datatype_size;
ADIO_File adio_fh;
Expand Down
3 changes: 3 additions & 0 deletions src/mpi/romio/mpi-io/read_at.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -101,6 +103,7 @@ Output Parameters:
int MPI_File_read_at_c(MPI_File fh, MPI_Offset offset, void *buf,
MPI_Count count, MPI_Datatype datatype, MPI_Status * status)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_READ_AT";
#ifdef MPI_hpux
Expand Down
3 changes: 3 additions & 0 deletions src/mpi/romio/mpi-io/read_atall.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -101,6 +103,7 @@ Output Parameters:
int MPI_File_read_at_all_c(MPI_File fh, MPI_Offset offset, void *buf,
MPI_Count count, MPI_Datatype datatype, MPI_Status * status)
{
assert(count <= INT_MAX);
int error_code;
static char myname[] = "MPI_FILE_IREAD_AT";
#ifdef MPI_hpux
Expand Down
4 changes: 4 additions & 0 deletions src/mpi/romio/mpi-io/read_ord.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -84,13 +86,15 @@ Output Parameters:
int MPI_File_read_ordered_c(MPI_File fh, void *buf, MPI_Count count,
MPI_Datatype datatype, MPI_Status * status)
{
assert(count <= INT_MAX);
return MPIOI_File_read_ordered(fh, buf, count, datatype, status);
}

#ifdef MPIO_BUILD_PROFILING
int MPIOI_File_read_ordered(MPI_File fh, void *buf, int count,
MPI_Datatype datatype, MPI_Status * status)
{
assert(count <= INT_MAX);
int error_code, nprocs, myrank;
ADIO_Offset incr;
MPI_Count datatype_size;
Expand Down
3 changes: 3 additions & 0 deletions src/mpi/romio/mpi-io/read_ordb.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

#include "mpioimpl.h"
#include <limits.h>
#include <assert.h>

#ifdef HAVE_WEAK_SYMBOLS

Expand Down Expand Up @@ -75,6 +77,7 @@ Output Parameters:
@*/
int MPI_File_read_ordered_begin_c(MPI_File fh, void *buf, MPI_Count count, MPI_Datatype datatype)
{
assert(count <= INT_MAX);
return MPIOI_File_read_ordered_begin(fh, buf, count, datatype);
}

Expand Down
Loading

0 comments on commit 901d61a

Please sign in to comment.