Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Teuchos_Comm.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //                    Teuchos: Common Tools Package
00005 //                 Copyright (2004) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef TEUCHOS_COMM_HPP
00043 #define TEUCHOS_COMM_HPP
00044 
00045 #include "Teuchos_ReductionOp.hpp"
00046 #include "Teuchos_ArrayRCP.hpp"
00047 
00048 
00049 namespace Teuchos {
00050 
00070 template<class OrdinalType>
00071 class CommStatus {
00072 public:
00074   virtual ~CommStatus() {}
00075 
00077   virtual OrdinalType getSourceRank () = 0;
00078 
00080   virtual OrdinalType getTag () = 0;
00081 };
00082 
00083 // Forward declaration for CommRequest::wait.
00084 template<class OrdinalType>
00085 class Comm;
00086 
00136 template<class OrdinalType>
00137 class CommRequest : public Teuchos::Describable {
00138 public:
00146   virtual ~CommRequest() {}
00147 
00149   virtual RCP<CommStatus<OrdinalType> > wait () = 0;
00150 };
00151 
00309 template<typename Ordinal>
00310 class Comm : virtual public Describable {
00311 public:
00317   virtual int getTag () const = 0;
00318 
00320 
00321 
00323   virtual ~Comm() {}
00325 
00327 
00328 
00335   virtual int getRank() const = 0;
00336 
00343   virtual int getSize() const = 0;
00344 
00346 
00348 
00349 
00353   virtual void barrier() const = 0;
00354 
00369   virtual void broadcast(
00370     const int rootRank, const Ordinal bytes, char buffer[]
00371     ) const = 0;
00372 
00374   virtual void
00375   gather (const Ordinal sendBytes, const char sendBuffer[],
00376           const Ordinal recvBytes, char recvBuffer[],
00377           const int root) const = 0;
00378 
00401   virtual void gatherAll(
00402     const Ordinal sendBytes, const char sendBuffer[]
00403     ,const Ordinal recvBytes, char recvBuffer[]
00404     ) const = 0;
00405 
00419   virtual void reduceAll(
00420     const ValueTypeReductionOp<Ordinal,char> &reductOp
00421     ,const Ordinal bytes, const char sendBuffer[], char globalReducts[]
00422     ) const = 0;
00423 
00447   virtual void reduceAllAndScatter(
00448     const ValueTypeReductionOp<Ordinal,char> &reductOp
00449     ,const Ordinal sendBytes, const char sendBuffer[]
00450     ,const Ordinal recvCounts[], char myGlobalReducts[]
00451     ) const = 0;
00452 
00466         virtual void scan(
00467     const ValueTypeReductionOp<Ordinal,char> &reductOp
00468     ,const Ordinal bytes, const char sendBuffer[], char scanReducts[]
00469     ) const = 0;
00470 
00472 
00473 
00494   virtual void send(
00495     const Ordinal bytes, const char sendBuffer[], const int destRank
00496     ) const = 0;
00497 
00499   virtual void
00500   send (const Ordinal bytes,
00501         const char sendBuffer[],
00502         const int destRank,
00503         const int tag) const = 0;
00504 
00524   virtual void ssend(
00525     const Ordinal bytes, const char sendBuffer[], const int destRank
00526     ) const = 0;
00527 
00529   virtual void
00530   ssend (const Ordinal bytes,
00531          const char sendBuffer[],
00532          const int destRank,
00533          const int tag) const = 0;
00534 
00555   virtual int receive(
00556     const int sourceRank, const Ordinal bytes, char recvBuffer[]
00557     ) const = 0;
00558 
00559 
00571   virtual void readySend(
00572     const ArrayView<const char> &sendBuffer,
00573     const int destRank
00574     ) const = 0;
00575 
00577   virtual void
00578   readySend (const Ordinal bytes,
00579              const char sendBuffer[],
00580              const int destRank,
00581              const int tag) const = 0;
00582 
00584 
00585 
00586 
00598   virtual RCP<CommRequest<Ordinal> > isend(
00599     const ArrayView<const char> &sendBuffer,
00600     const int destRank
00601     ) const = 0;
00602 
00604   virtual RCP<CommRequest<Ordinal> >
00605   isend (const ArrayView<const char> &sendBuffer,
00606          const int destRank,
00607          const int tag) const = 0;
00608 
00623   virtual RCP<CommRequest<Ordinal> > ireceive(
00624     const ArrayView<char> &recvBuffer,
00625     const int sourceRank
00626     ) const = 0;
00627 
00629   virtual RCP<CommRequest<Ordinal> >
00630   ireceive (const ArrayView<char> &recvBuffer,
00631             const int sourceRank,
00632             const int tag) const = 0;
00633 
00644   virtual void waitAll(
00645     const ArrayView<RCP<CommRequest<Ordinal> > > &requests
00646     ) const = 0;
00647 
00664   virtual void
00665   waitAll (const ArrayView<RCP<CommRequest<Ordinal> > >& requests,
00666            const ArrayView<RCP<CommStatus<Ordinal> > >& statuses) const = 0;
00667 
00691   virtual RCP<CommStatus<Ordinal> >
00692   wait (const Ptr<RCP<CommRequest<Ordinal> > >& request) const = 0;
00693 
00695 
00697 
00698 
00766   virtual RCP< Comm > duplicate() const = 0;
00767 
00805   virtual RCP<Comm> split (const int color, const int key) const = 0;
00806 
00829   virtual RCP<Comm>
00830   createSubcommunicator (const ArrayView<const int>& ranks) const = 0;
00832 
00833 }; // class Comm
00834 
00835 } // namespace Teuchos
00836 
00837 #endif // TEUCHOS_COMM_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines