OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen 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-2007 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     commSchedule
00027 
00028 Description
00029     Given a set of processors that need to talk to one another determines
00030     the order in which they should do so to
00031     - have maximum overlap
00032     - allow blocking communication without deadlock
00033     Does a very simple scheduling which assumes same time for all operations.
00034 
00035     After construction:
00036     - schedule() gives the order in which the input communication should happen
00037     - procSchedule()[procI] gives per procI  ,,    ,,
00038 
00039     Does not care whether 'talking' is first send, second receive or maybe
00040     full swap. This is all responsability of caller. See ProcessorTopology
00041     class for use in scheduling processor boundary swaps.
00042 
00043 SourceFiles
00044     commSchedule.C
00045 
00046 \*---------------------------------------------------------------------------*/
00047 
00048 #ifndef commSchedule_H
00049 #define commSchedule_H
00050 
00051 #include "DynamicList.H"
00052 #include "labelPair.H"
00053 #include "labelList.H"
00054 
00055 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00056 
00057 namespace Foam
00058 {
00059 
00060 /*---------------------------------------------------------------------------*\
00061                            Class commSchedule Declaration
00062 \*---------------------------------------------------------------------------*/
00063 
00064 class commSchedule
00065 {
00066     // Private data
00067 
00068         //- Order in which input communication has been scheduled
00069         labelList schedule_;
00070 
00071         //- Per processor the order in which communication has been scheduled
00072         labelListList procSchedule_;
00073 
00074     // Private Member Functions
00075 
00076         //- Count the number of outstanding communications for a single
00077         //  processor
00078         label outstandingComms(const labelList&, DynamicList<label>&) const;
00079 
00080 
00081 public:
00082 
00083     ClassName("commSchedule");
00084 
00085     // Constructors
00086 
00087         //- Construct from wanted communication. Wanted communication is between
00088         //  two processors. Can be a one-way communication or
00089         //  two-way communication, that is up to the caller. This class just
00090         //  determines an order for it such that any processor is only talking
00091         //  to one other at a time. After construction:
00092         //  - schedule is the order in which comms is done.
00093         //  - procSchedule[procI] is for procI the order in which comms is done.
00094         commSchedule(const label nProcs, const List<labelPair>& comms);
00095 
00096 
00097     // Member Functions
00098 
00099         //- order in which comms is scheduled
00100         const labelList& schedule() const
00101         {
00102             return schedule_;
00103         }
00104 
00105         //- Per processor the order in which communication has been scheduled
00106         const labelListList& procSchedule() const
00107         {
00108             return procSchedule_;
00109         }
00110 
00111 
00112 };
00113 
00114 
00115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00116 
00117 } // End namespace Foam
00118 
00119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00120 
00121 #endif
00122 
00123 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd