OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

commSchedule.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::commSchedule
00027 
00028 Description
00029     Determines the order in which a set of processors should communicate
00030     with one another.
00031  
00032     The communication order should 
00033       - have maximum overlap
00034       - allow blocking communication without deadlock
00035  
00036     Does a very simple scheduling which assumes same time for all operations.
00037 
00038     After construction:
00039       - schedule() gives the order in which the input communication should occur
00040       - procSchedule()[procI] gives per procI
00041 
00042     Does not care whether 'talking' is first send, second receive or maybe
00043     full swap. This is all responsability of caller. See ProcessorTopology
00044     class for use in scheduling processor boundary swaps.
00045 
00046 SourceFiles
00047     commSchedule.C
00048 
00049 \*---------------------------------------------------------------------------*/
00050 
00051 #ifndef commSchedule_H
00052 #define commSchedule_H
00053 
00054 #include "DynamicList.H"
00055 #include "labelPair.H"
00056 #include "labelList.H"
00057 
00058 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00059 
00060 namespace Foam
00061 {
00062 
00063 /*---------------------------------------------------------------------------*\
00064                            Class commSchedule Declaration
00065 \*---------------------------------------------------------------------------*/
00066 
00067 class commSchedule
00068 {
00069     // Private data
00070 
00071         //- Order in which input communication has been scheduled
00072         labelList schedule_;
00073 
00074         //- Per processor the order in which communication has been scheduled
00075         labelListList procSchedule_;
00076 
00077     // Private Member Functions
00078 
00079         //- Count the number of outstanding communications for a single
00080         //  processor
00081         label outstandingComms(const labelList&, DynamicList<label>&) const;
00082 
00083 
00084 public:
00085 
00086     ClassName("commSchedule");
00087 
00088     // Constructors
00089 
00090         //- Construct from wanted communication. Wanted communication is between
00091         //  two processors. Can be a one-way communication or
00092         //  two-way communication, that is up to the caller. This class just
00093         //  determines an order for it such that any processor is only talking
00094         //  to one other at a time. After construction:
00095         //  - schedule is the order in which comms is done.
00096         //  - procSchedule[procI] is for procI the order in which comms is done.
00097         commSchedule(const label nProcs, const List<labelPair>& comms);
00098 
00099 
00100     // Member Functions
00101 
00102         //- order in which comms is scheduled
00103         const labelList& schedule() const
00104         {
00105             return schedule_;
00106         }
00107 
00108         //- Per processor the order in which communication has been scheduled
00109         const labelListList& procSchedule() const
00110         {
00111             return procSchedule_;
00112         }
00113 
00114 
00115 };
00116 
00117 
00118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00119 
00120 } // End namespace Foam
00121 
00122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00123 
00124 #endif
00125 
00126 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd