Simbody  3.4 (development)
Parallel2DExecutor.h
Go to the documentation of this file.
00001 #ifndef SimTK_SimTKCOMMON_PARALLEL_2D_EXECUTOR_H_
00002 #define SimTK_SimTKCOMMON_PARALLEL_2D_EXECUTOR_H_
00003 
00004 /* -------------------------------------------------------------------------- *
00005  *                       Simbody(tm): SimTKcommon                             *
00006  * -------------------------------------------------------------------------- *
00007  * This is part of the SimTK biosimulation toolkit originating from           *
00008  * Simbios, the NIH National Center for Physics-Based Simulation of           *
00009  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
00010  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody.  *
00011  *                                                                            *
00012  * Portions copyright (c) 2008-12 Stanford University and the Authors.        *
00013  * Authors: Peter Eastman                                                     *
00014  * Contributors:                                                              *
00015  *                                                                            *
00016  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
00017  * not use this file except in compliance with the License. You may obtain a  *
00018  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
00019  *                                                                            *
00020  * Unless required by applicable law or agreed to in writing, software        *
00021  * distributed under the License is distributed on an "AS IS" BASIS,          *
00022  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
00023  * See the License for the specific language governing permissions and        *
00024  * limitations under the License.                                             *
00025  * -------------------------------------------------------------------------- */
00026 
00027 #include "ParallelExecutor.h"
00028 #include "PrivateImplementation.h"
00029 
00030 namespace SimTK {
00031 
00032 class Parallel2DExecutor;
00033 class Parallel2DExecutorImpl;
00034 
00035 // We only want the template instantiation to occur once. This symbol is defined in the SimTK core
00036 // compilation unit that defines the Parallel2DExecutor class but should not be defined any other time.
00037 #ifndef SimTK_SIMTKCOMMON_DEFINING_PARALLEL_2D_EXECUTOR
00038     extern template class PIMPLHandle<Parallel2DExecutor, Parallel2DExecutorImpl>;
00039 #endif
00040 
00073 class SimTK_SimTKCOMMON_EXPORT Parallel2DExecutor : public PIMPLHandle<Parallel2DExecutor, Parallel2DExecutorImpl> {
00074 public:
00075     class Task;
00076     enum RangeType {FullMatrix, HalfMatrix, HalfPlusDiagonal};
00084     explicit Parallel2DExecutor(int gridSize, int numThreads = ParallelExecutor::getNumProcessors());
00094     Parallel2DExecutor(int gridSize, ParallelExecutor& executor);
00103     void execute(Task& task, RangeType rangeType);
00107     ParallelExecutor& getExecutor();
00108 };
00109 
00114 class Parallel2DExecutor::Task {
00115 public:
00116     virtual ~Task() {
00117     }
00122     virtual void execute(int i, int j) = 0;
00127     virtual void initialize() {
00128     }
00134     virtual void finish() {
00135     }
00136 };
00137 
00138 } // namespace SimTK
00139 
00140 #endif // SimTK_SimTKCOMMON_PARALLEL_2D_EXECUTOR_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines