00001 /******************************************************************************* 00002 Copyright (c) 2011, Yahoo! Inc. 00003 All rights reserved. 00004 00005 Redistribution and use of this software in source and binary forms, 00006 with or without modification, are permitted provided that the following 00007 conditions are met: 00008 00009 * Redistributions of source code must retain the above 00010 copyright notice, this list of conditions and the 00011 following disclaimer. 00012 00013 * Redistributions in binary form must reproduce the above 00014 copyright notice, this list of conditions and the 00015 following disclaimer in the documentation and/or other 00016 materials provided with the distribution. 00017 00018 * Neither the name of Yahoo! Inc. nor the names of its 00019 contributors may be used to endorse or promote products 00020 derived from this software without specific prior 00021 written permission of Yahoo! Inc. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00024 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00025 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00026 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00027 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00031 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 00035 The Initial Developer of the Original Code is Shravan Narayanamurthy. 00036 ******************************************************************************/ 00037 /* 00038 * TBB_Pipeline.h 00039 * 00040 * 00041 * Created on: 04-Jan-2011 00042 * 00043 */ 00044 00045 #ifndef TBB_PIPELINE_H_ 00046 #define TBB_PIPELINE_H_ 00047 00048 #include "Pipeline.h" 00049 #include "tbb/task_scheduler_init.h" 00050 #include "tbb/pipeline.h" 00051 #include "Model_Refiner.h" 00052 00053 using namespace tbb; 00054 00055 //!An implementation of the Pipeline interface using 00056 //!Intel's Threading Building Blocks. 00057 /** 00058 * TBB::filter is the basic unit of computation and TBB::Pipeline 00059 * puts the filters together. 00060 * 00061 * What filters exist in a pipeline and how the pipeline 00062 * is executed is implemented via an Execution Strategy 00063 * 00064 * Calling each of the add methods adds that particular 00065 * filter to the pipeline 00066 */ 00067 class TBB_Pipeline: public Pipeline { 00068 public: 00069 TBB_Pipeline(Model_Refiner&); 00070 virtual ~TBB_Pipeline(); 00071 void init(); 00072 void add_reader(); 00073 void add_sampler(); 00074 void add_updater(); 00075 void add_optimizer(); 00076 void add_eval(); 00077 void add_writer(); 00078 void add_tester(); 00079 void clear(); 00080 void destroy(); 00081 void run(); 00082 00083 Model_Refiner& get_refiner(); 00084 double get_eval(); 00085 00086 protected: 00087 task_scheduler_init _init; 00088 tbb::pipeline* _pipeline; 00089 Model_Refiner& _refiner; 00090 00091 filter *_reader, *_sampler, *_updater, *_optimizer, *_eval, *_writer, 00092 *_tester; 00093 }; 00094 00095 #endif /* TBB_PIPELINE_H_ */