eLynx SDK
v3.3.0 C++ image processing API reference |
00001 //============================================================================ 00002 // ParallelAlgorithms.h Core.Component package 00003 //============================================================================ 00004 // Usage : parallel tasks. 00005 //---------------------------------------------------------------------------- 00006 // Copyright (C) 2008 by eLynx project 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free 00020 // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00021 // 00022 //---------------------------------------------------------------------------- 00023 #ifndef __ParallelAlgorithms_h__ 00024 #define __ParallelAlgorithms_h__ 00025 00026 #include <elx/core/CoreLib.h> 00027 #include <elx/core/CoreTypes.h> 00028 #include <elx/core/TaskScheduler.h> 00029 00030 namespace eLynx { 00031 00033 enum ESubRangePosition 00034 { 00035 SRP_NONE, 00036 SRP_ALL, 00037 SRP_FIRST, 00038 SRP_MIDDLE, 00039 SRP_LAST 00040 }; 00041 00045 class ExportedByCore IterationRange 00046 { 00047 public: 00054 IterationRange( 00055 size_t iBegin, 00056 size_t iEnd, 00057 size_t iGrainSize = 1, 00058 size_t iMinSize = 1, 00059 ESubRangePosition iPosition = SRP_ALL); 00060 00066 IterationRange Split(size_t iSegment, size_t iIndex); 00067 00070 bool IsEmpty() const; 00071 00074 bool IsSplitable() const; 00075 00076 size_t GetBegin() const; 00077 size_t GetEnd() const; 00078 bool IsFirst() const; 00079 bool IsMiddle() const; 00080 bool IsLast() const; 00081 bool IsAll() const; 00082 00083 private: 00084 friend class IterationRangeTask; 00085 00086 size_t _begin; 00087 size_t _end; 00088 size_t _grainSize; 00089 size_t _minSize; 00090 ESubRangePosition _position; 00091 }; 00092 00099 template <typename Range, typename Task> 00100 uint32 elxParallelFor(Range iRange, const Task& iTask); 00101 00110 template <typename Range, typename Task> 00111 uint32 elxParallelReduce(Range iRange, Task& ioTask); 00112 00113 } // namespace eLynx 00114 00115 #include "inl/ParallelAlgorithms.inl" 00116 00117 #endif // __ParallelAlgorithms_h__