2004-07-14 18:11:03 +04:00
|
|
|
// -*- c++ -*-
|
|
|
|
//
|
2005-11-05 22:57:48 +03:00
|
|
|
// Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
// University Research and Technology
|
|
|
|
// Corporation. All rights reserved.
|
|
|
|
// Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
// of Tennessee Research Foundation. All rights
|
|
|
|
// reserved.
|
2015-06-24 06:59:57 +03:00
|
|
|
// Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
// University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
// Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
// All rights reserved.
|
2009-10-22 20:50:45 +04:00
|
|
|
// Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
// $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
//
|
2004-11-22 04:38:40 +03:00
|
|
|
// Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
//
|
2004-07-14 18:11:03 +04:00
|
|
|
// $HEADER$
|
|
|
|
//
|
|
|
|
|
2007-12-07 16:09:07 +03:00
|
|
|
// Typedefs for C++ callbacks registered via MPI::Register_datarep
|
2015-06-24 06:59:57 +03:00
|
|
|
typedef void Datarep_extent_function(const Datatype& datatype,
|
2007-12-07 16:09:07 +03:00
|
|
|
Aint& file_extent, void* extra_state);
|
2015-06-24 06:59:57 +03:00
|
|
|
typedef void Datarep_conversion_function(void* userbuf, Datatype& datatype,
|
|
|
|
int count, void* filebuf,
|
2007-12-07 16:09:07 +03:00
|
|
|
Offset position, void* extra_state);
|
|
|
|
|
|
|
|
// Both callback functions in C++
|
2015-06-24 06:59:57 +03:00
|
|
|
void Register_datarep(const char* datarep,
|
|
|
|
Datarep_conversion_function* read_conversion_fn,
|
|
|
|
Datarep_conversion_function* write_conversion_fn,
|
|
|
|
Datarep_extent_function* dtype_file_extent_fn,
|
2007-12-07 16:09:07 +03:00
|
|
|
void* extra_state);
|
|
|
|
|
|
|
|
// Overload for C read callback function (MPI_CONVERSION_FN_NULL)
|
2015-06-24 06:59:57 +03:00
|
|
|
void Register_datarep(const char* datarep,
|
|
|
|
MPI_Datarep_conversion_function* read_conversion_fn,
|
|
|
|
Datarep_conversion_function* write_conversion_fn,
|
|
|
|
Datarep_extent_function* dtype_file_extent_fn,
|
2007-12-07 16:09:07 +03:00
|
|
|
void* extra_state);
|
|
|
|
|
|
|
|
// Overload for C write callback function (MPI_CONVERSION_FN_NULL)
|
2015-06-24 06:59:57 +03:00
|
|
|
void Register_datarep(const char* datarep,
|
|
|
|
Datarep_conversion_function* read_conversion_fn,
|
|
|
|
MPI_Datarep_conversion_function* write_conversion_fn,
|
|
|
|
Datarep_extent_function* dtype_file_extent_fn,
|
2007-12-07 16:09:07 +03:00
|
|
|
void* extra_state);
|
|
|
|
|
|
|
|
// Overload for C read and write callback functions (MPI_CONVERSION_FN_NULL)
|
2015-06-24 06:59:57 +03:00
|
|
|
void Register_datarep(const char* datarep,
|
|
|
|
MPI_Datarep_conversion_function* read_conversion_fn,
|
|
|
|
MPI_Datarep_conversion_function* write_conversion_fn,
|
|
|
|
Datarep_extent_function* dtype_file_extent_fn,
|
2007-12-07 16:09:07 +03:00
|
|
|
void* extra_state);
|
|
|
|
|
2004-07-14 18:11:03 +04:00
|
|
|
class File {
|
|
|
|
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
|
|
|
// friend class P;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
friend class MPI::Comm; //so I can access pmpi_file data member in comm.cc
|
|
|
|
friend class MPI::Request; //and also from request.cc
|
|
|
|
|
|
|
|
public:
|
|
|
|
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
|
|
|
|
|
|
|
// construction / destruction
|
|
|
|
File() { }
|
|
|
|
virtual ~File() { }
|
|
|
|
|
|
|
|
|
|
|
|
// copy / assignment
|
|
|
|
File(const File& data) : pmpi_file(data.pmpi_file) { }
|
|
|
|
|
This is a workaround to bug in the Intel C++ compiler, version 9.1
(all versions up to and including 20060925). The issue has been
reported to Intel, along with a small [non-MPI] test program that
reproduces the problem (the test program and the OMPI C++ bindings
work fine with Intel C++ 9.0 and many other C++ compilers).
In short, a static initializer for a global variable (i.e., its
constructor is fired before main()) that takes as an argument a
reference to a typedef'd type will simply get the wrong value in the
argument. Specifically:
{{{
namespace MPI {
Intracomm COMM_WORLD(MPI_COMM_WORLD);
}
}}}
The constructor for MPI::Intracomm should get the value of
&ompi_mpi_comm_world. It does not; it seems to get a random value.
As mandated by MPI-2, annex B.13.4, for C/C++ interoperability, the
prototype for this constructor is:
{{{
class Intracomm {
public:
Intracomm(const MPI_Comm& data);
};
}}}
Experiments with icpc 9.1/20060925 have shown that removing the
reference from the prototype makes it work (!). After lots of
discussions about this issue with a C++ expert (Doug Gregor from IU),
we decided the following (cut-n-paste from an e-mail):
-----
> So here's my question: given that OMPI's MPI_<CLASS> types are all
> pointers, is there any legal MPI program that adheres to the above
> bindings that would fail to compile or work properly if we simply
> removed the "&" from the second binding, above?
I don't know of any way that a program could detect this change. FWIW,
the C++ committee has agreed that implementation of the C++ standard
library are allowed to decide arbitrarily between const& and by-value.
If they don't care, MPI users won't care.
When you remove the '&', I suggest also removing the "const". It is
redundant, but can trigger some strange name mangling in Sun's C++
compiler.
-----
So with this change:
* we now work again with the Intel 9.1 compiler
* our C++ bindings do not exactly conform to the MPI-2 spec, but
valid/legal MPI C++ apps cannot tell the difference (i.e., the
functionality is the same)
This commit was SVN r12514.
2006-11-09 20:34:12 +03:00
|
|
|
File(MPI_File i) : pmpi_file(i) { }
|
2004-07-14 18:11:03 +04:00
|
|
|
|
|
|
|
File& operator=(const File& data) {
|
|
|
|
pmpi_file = data.pmpi_file; return *this; }
|
|
|
|
|
|
|
|
// comparison, don't need for file
|
|
|
|
|
|
|
|
// inter-language operability
|
|
|
|
File& operator= (const MPI_File &i) {
|
|
|
|
pmpi_file = i; return *this; }
|
|
|
|
operator MPI_File () const { return pmpi_file; }
|
|
|
|
// operator MPI_File* () const { return pmpi_file; }
|
|
|
|
operator const PMPI::File&() const { return pmpi_file; }
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2008-08-12 17:13:02 +04:00
|
|
|
File() : mpi_file(MPI_FILE_NULL) { }
|
2004-07-14 18:11:03 +04:00
|
|
|
// copy
|
|
|
|
File(const File& data) : mpi_file(data.mpi_file) { }
|
|
|
|
|
This is a workaround to bug in the Intel C++ compiler, version 9.1
(all versions up to and including 20060925). The issue has been
reported to Intel, along with a small [non-MPI] test program that
reproduces the problem (the test program and the OMPI C++ bindings
work fine with Intel C++ 9.0 and many other C++ compilers).
In short, a static initializer for a global variable (i.e., its
constructor is fired before main()) that takes as an argument a
reference to a typedef'd type will simply get the wrong value in the
argument. Specifically:
{{{
namespace MPI {
Intracomm COMM_WORLD(MPI_COMM_WORLD);
}
}}}
The constructor for MPI::Intracomm should get the value of
&ompi_mpi_comm_world. It does not; it seems to get a random value.
As mandated by MPI-2, annex B.13.4, for C/C++ interoperability, the
prototype for this constructor is:
{{{
class Intracomm {
public:
Intracomm(const MPI_Comm& data);
};
}}}
Experiments with icpc 9.1/20060925 have shown that removing the
reference from the prototype makes it work (!). After lots of
discussions about this issue with a C++ expert (Doug Gregor from IU),
we decided the following (cut-n-paste from an e-mail):
-----
> So here's my question: given that OMPI's MPI_<CLASS> types are all
> pointers, is there any legal MPI program that adheres to the above
> bindings that would fail to compile or work properly if we simply
> removed the "&" from the second binding, above?
I don't know of any way that a program could detect this change. FWIW,
the C++ committee has agreed that implementation of the C++ standard
library are allowed to decide arbitrarily between const& and by-value.
If they don't care, MPI users won't care.
When you remove the '&', I suggest also removing the "const". It is
redundant, but can trigger some strange name mangling in Sun's C++
compiler.
-----
So with this change:
* we now work again with the Intel 9.1 compiler
* our C++ bindings do not exactly conform to the MPI-2 spec, but
valid/legal MPI C++ apps cannot tell the difference (i.e., the
functionality is the same)
This commit was SVN r12514.
2006-11-09 20:34:12 +03:00
|
|
|
File(MPI_File i) : mpi_file(i) { }
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-07-14 18:11:03 +04:00
|
|
|
virtual ~File() { }
|
|
|
|
|
|
|
|
File& operator=(const File& data) {
|
|
|
|
mpi_file = data.mpi_file; return *this; }
|
|
|
|
|
|
|
|
// comparison, don't need for file
|
|
|
|
|
|
|
|
// inter-language operability
|
|
|
|
File& operator= (const MPI_File &i) {
|
|
|
|
mpi_file = i; return *this; }
|
|
|
|
operator MPI_File () const { return mpi_file; }
|
|
|
|
// operator MPI_File* () const { return (MPI_File*)&mpi_file; }
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
// from the I/o chapter of MPI - 2
|
2004-07-14 18:11:03 +04:00
|
|
|
|
|
|
|
void Close();
|
|
|
|
|
|
|
|
static void Delete(const char* filename, const MPI::Info& info);
|
|
|
|
|
|
|
|
int Get_amode() const;
|
|
|
|
|
|
|
|
bool Get_atomicity() const;
|
|
|
|
|
|
|
|
MPI::Offset Get_byte_offset(const MPI::Offset disp) const;
|
|
|
|
|
|
|
|
MPI::Group Get_group() const;
|
|
|
|
|
|
|
|
MPI::Info Get_info() const;
|
|
|
|
|
|
|
|
MPI::Offset Get_position() const;
|
|
|
|
|
|
|
|
MPI::Offset Get_position_shared() const;
|
|
|
|
|
|
|
|
MPI::Offset Get_size() const;
|
|
|
|
|
|
|
|
MPI::Aint Get_type_extent(const MPI::Datatype& datatype) const;
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
void Get_view(MPI::Offset& disp, MPI::Datatype& etype,
|
2004-07-14 18:11:03 +04:00
|
|
|
MPI::Datatype& filetype, char* datarep) const;
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
MPI::Request Iread(void* buf, int count,
|
2004-07-14 18:11:03 +04:00
|
|
|
const MPI::Datatype& datatype);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
|
|
|
MPI::Request Iread_at(MPI::Offset offset, void* buf, int count,
|
2004-07-14 18:11:03 +04:00
|
|
|
const MPI::Datatype& datatype);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-07-14 18:11:03 +04:00
|
|
|
MPI::Request Iread_shared(void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
MPI::Request Iwrite(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
MPI::Request Iwrite_at(MPI::Offset offset, const void* buf,
|
2004-07-14 18:11:03 +04:00
|
|
|
int count, const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
MPI::Request Iwrite_shared(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
static MPI::File Open(const MPI::Intracomm& comm,
|
|
|
|
const char* filename, int amode,
|
|
|
|
const MPI::Info& info);
|
|
|
|
|
|
|
|
void Preallocate(MPI::Offset size);
|
|
|
|
|
|
|
|
void Read(void* buf, int count, const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Read(void* buf, int count, const MPI::Datatype& datatype,
|
|
|
|
MPI::Status& status);
|
|
|
|
|
|
|
|
void Read_all(void* buf, int count, const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Read_all(void* buf, int count, const MPI::Datatype& datatype,
|
|
|
|
MPI::Status& status);
|
|
|
|
|
|
|
|
void Read_all_begin(void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Read_all_end(void* buf);
|
|
|
|
|
|
|
|
void Read_all_end(void* buf, MPI::Status& status);
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
void Read_at(MPI::Offset offset,
|
2004-07-14 18:11:03 +04:00
|
|
|
void* buf, int count, const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Read_at(MPI::Offset offset, void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype, MPI::Status& status);
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
void Read_at_all(MPI::Offset offset, void* buf, int count,
|
2004-07-14 18:11:03 +04:00
|
|
|
const MPI::Datatype& datatype);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-07-14 18:11:03 +04:00
|
|
|
void Read_at_all(MPI::Offset offset, void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype, MPI::Status& status);
|
|
|
|
|
|
|
|
void Read_at_all_begin(MPI::Offset offset, void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-07-14 18:11:03 +04:00
|
|
|
void Read_at_all_end(void* buf);
|
|
|
|
|
|
|
|
void Read_at_all_end(void* buf, MPI::Status& status);
|
|
|
|
|
|
|
|
void Read_ordered(void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Read_ordered(void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype,
|
|
|
|
MPI::Status& status);
|
|
|
|
|
|
|
|
void Read_ordered_begin(void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Read_ordered_end(void* buf);
|
|
|
|
|
|
|
|
void Read_ordered_end(void* buf, MPI::Status& status);
|
|
|
|
|
|
|
|
void Read_shared(void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Read_shared(void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype, MPI::Status& status);
|
|
|
|
|
|
|
|
void Seek(MPI::Offset offset, int whence);
|
|
|
|
|
|
|
|
void Seek_shared(MPI::Offset offset, int whence);
|
|
|
|
|
|
|
|
void Set_atomicity(bool flag);
|
|
|
|
|
|
|
|
void Set_info(const MPI::Info& info);
|
|
|
|
|
|
|
|
void Set_size(MPI::Offset size);
|
|
|
|
|
|
|
|
void Set_view(MPI::Offset disp, const MPI::Datatype& etype,
|
|
|
|
const MPI::Datatype& filetype, const char* datarep,
|
|
|
|
const MPI::Info& info);
|
|
|
|
|
|
|
|
void Sync();
|
|
|
|
|
|
|
|
void Write(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Write(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype, MPI::Status& status);
|
|
|
|
|
|
|
|
void Write_all(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Write_all(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype, MPI::Status& status);
|
|
|
|
|
|
|
|
void Write_all_begin(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Write_all_end(const void* buf);
|
|
|
|
|
|
|
|
void Write_all_end(const void* buf, MPI::Status& status);
|
|
|
|
|
|
|
|
void Write_at(MPI::Offset offset, const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Write_at(MPI::Offset offset, const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype, MPI::Status& status);
|
|
|
|
|
|
|
|
void Write_at_all(MPI::Offset offset, const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Write_at_all(MPI::Offset offset, const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype,
|
|
|
|
MPI::Status& status);
|
|
|
|
|
|
|
|
void Write_at_all_begin(MPI::Offset offset, const void* buf,
|
|
|
|
int count, const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Write_at_all_end(const void* buf);
|
|
|
|
|
|
|
|
void Write_at_all_end(const void* buf, MPI::Status& status);
|
|
|
|
|
|
|
|
void Write_ordered(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Write_ordered(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype, MPI::Status& status);
|
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
void Write_ordered_begin(const void* buf, int count,
|
2004-07-14 18:11:03 +04:00
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Write_ordered_end(const void* buf);
|
|
|
|
|
|
|
|
void Write_ordered_end(const void* buf, MPI::Status& status);
|
|
|
|
|
|
|
|
void Write_shared(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype);
|
|
|
|
|
|
|
|
void Write_shared(const void* buf, int count,
|
|
|
|
const MPI::Datatype& datatype, MPI::Status& status);
|
2006-12-31 02:41:42 +03:00
|
|
|
|
2008-02-10 22:29:25 +03:00
|
|
|
//
|
|
|
|
// Errhandler
|
|
|
|
//
|
2009-10-22 20:50:45 +04:00
|
|
|
typedef void Errhandler_function(MPI::File &, int *, ... );
|
|
|
|
typedef Errhandler_function Errhandler_fn
|
|
|
|
__mpi_interface_deprecated__("MPI::File::Errhandler_fn was deprecated in MPI-2.2; use MPI::File::Errhandler_function instead");
|
2006-12-31 02:41:42 +03:00
|
|
|
|
2015-06-24 06:59:57 +03:00
|
|
|
static MPI::Errhandler Create_errhandler(Errhandler_function* function);
|
2006-12-31 02:41:42 +03:00
|
|
|
|
2004-07-14 18:11:03 +04:00
|
|
|
MPI::Errhandler Get_errhandler() const;
|
2008-02-10 22:29:25 +03:00
|
|
|
|
|
|
|
void Set_errhandler(const MPI::Errhandler& errhandler) const;
|
|
|
|
|
|
|
|
void Call_errhandler(int errorcode) const;
|
|
|
|
|
2004-07-14 18:11:03 +04:00
|
|
|
protected:
|
|
|
|
#if 0 /* OMPI_ENABLE_MPI_PROFILING */
|
|
|
|
PMPI::File pmpi_file;
|
|
|
|
|
|
|
|
#else
|
|
|
|
MPI_File mpi_file;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|