Skip to content

Commit

Permalink
mpidummy: get rid of MPI_File and friends
Browse files Browse the repository at this point in the history
There is already an abstraction layers for File I/O (`Transport`),
so if one were to use MPI I/O in the future, it'd make sense to add
it there, but only offers value if it's actually available (ie,
we're building with MPI), so there wouldn't be a need for a dummy
implementation even then.
  • Loading branch information
germasch committed Jun 7, 2019
1 parent 8b8b4d5 commit 3bec6ec
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 82 deletions.
71 changes: 0 additions & 71 deletions source/adios2/helper/mpidummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,77 +299,6 @@ int MPI_Wait(MPI_Request * /*request*/, MPI_Status * /*status*/)
RETURN_CHECK(MPI_SUCCESS);
}

#ifndef ADIOS2_HAVE_MPI

int MPI_File_open(MPI_Comm /*comm*/, const char *filename, int amode,
MPI_Info /*info*/, MPI_File *fh)
{
std::string mode;
if (amode | MPI_MODE_RDONLY)
{
mode += "r";
}
if (amode | MPI_MODE_WRONLY)
{
mode += "w";
}
if (amode | MPI_MODE_APPEND)
{
mode += "a";
}
mode += "b";

*fh = std::fopen(filename, mode.c_str());
if (!*fh)
{
return -1;
}
RETURN_CHECK(MPI_SUCCESS);
}

int MPI_File_close(MPI_File *fh) { return fclose(*fh); }

int MPI_File_get_size(MPI_File fh, MPI_Offset *size)
{
long curpos = std::ftell(fh);
fseek(fh, 0, SEEK_END); // go to end, returned is the size in bytes
long endpos = std::ftell(fh);
std::fseek(fh, curpos, SEEK_SET); // go back where we were
*size = static_cast<MPI_Offset>(endpos);
// printf("MPI_File_get_size: fh=%d, size=%lld\n", fh, *size);
RETURN_CHECK(MPI_SUCCESS);
}

int MPI_File_read(MPI_File fh, void *buf, int count, MPI_Datatype datatype,
MPI_Status *status)
{
// FIXME: int count can read only 2GB (*datatype size) array at max
size_t bytes_to_read = static_cast<size_t>(count) * datatype;
size_t bytes_read;
bytes_read = std::fread(buf, 1, bytes_to_read, fh);
if (bytes_read != bytes_to_read)
{
return -2;
}
*status = bytes_read;
// printf("MPI_File_read: fh=%d, count=%d, typesize=%d, bytes read=%lld\n",
// fh, count, datatype, *status);
RETURN_CHECK(MPI_SUCCESS);
}

int MPI_File_seek(MPI_File fh, MPI_Offset offset, int whence)
{
return std::fseek(fh, offset, whence) == MPI_SUCCESS;
}

int MPI_Get_count(const MPI_Status *status, MPI_Datatype, int *count)
{
*count = static_cast<int>(*status);
RETURN_CHECK(MPI_SUCCESS);
}

#endif

double MPI_Wtime()
{
std::chrono::duration<double> now =
Expand Down
11 changes: 0 additions & 11 deletions source/adios2/helper/mpidummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
typedef int MPI_Comm;
typedef uint64_t MPI_Status;
typedef uint64_t MPI_Request;
typedef FILE *MPI_File;
typedef int MPI_Info;
typedef int MPI_Datatype;
typedef long int MPI_Offset;
typedef int MPI_Fint;
typedef int MPI_Op;

Expand Down Expand Up @@ -168,15 +166,6 @@ int MPI_Wait(MPI_Request *request, MPI_Status *status);

int MPI_Type_size(MPI_Datatype datatype, int *size);

int MPI_File_open(MPI_Comm comm, const char *filename, int amode, MPI_Info info,
MPI_File *fh);
int MPI_File_close(MPI_File *fh);
int MPI_File_get_size(MPI_File fh, MPI_Offset *size);
int MPI_File_read(MPI_File fh, void *buf, int count, MPI_Datatype datatype,
MPI_Status *status);
int MPI_File_seek(MPI_File fh, MPI_Offset offset, int whence);

int MPI_Get_count(const MPI_Status *status, MPI_Datatype datatype, int *count);
int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *comm_out);

int MPI_Get_processor_name(char *name, int *resultlen);
Expand Down

0 comments on commit 3bec6ec

Please sign in to comment.