ViennaCL - The Vienna Computing Library  1.5.2
viennacl/device_specific/tree_parsing/prototype_generation.hpp
Go to the documentation of this file.
00001 #ifndef VIENNACL_DEVICE_SPECIFIC_TREE_PARSING_PROTOTYPE_GENERATION_HPP
00002 #define VIENNACL_DEVICE_SPECIFIC_TREE_PARSING_PROTOTYPE_GENERATION_HPP
00003 
00004 /* =========================================================================
00005    Copyright (c) 2010-2013, Institute for Microelectronics,
00006                             Institute for Analysis and Scientific Computing,
00007                             TU Wien.
00008    Portions of this software are copyright by UChicago Argonne, LLC.
00009 
00010                             -----------------
00011                   ViennaCL - The Vienna Computing Library
00012                             -----------------
00013 
00014    Project Head:    Karl Rupp                   rupp@iue.tuwien.ac.at
00015 
00016    (A list of authors and contributors can be found in the PDF manual)
00017 
00018    License:         MIT (X11), see file LICENSE in the base directory
00019 ============================================================================= */
00020 
00021 
00026 #include <set>
00027 
00028 #include "viennacl/forwards.h"
00029 #include "viennacl/scheduler/forwards.h"
00030 #include "viennacl/device_specific/forwards.h"
00031 
00032 #include "viennacl/device_specific/tree_parsing/traverse.hpp"
00033 
00034 
00035 
00036 namespace viennacl{
00037 
00038   namespace device_specific{
00039 
00040     namespace tree_parsing{
00041 
00043       class prototype_generation_traversal : public traversal_functor{
00044         private:
00045           unsigned int simd_width_;
00046           std::set<std::string> & already_generated_;
00047           std::string & str_;
00048           mapping_type const & mapping_;
00049         public:
00050           prototype_generation_traversal(unsigned int simd_width, std::set<std::string> & already_generated, std::string & str, mapping_type const & mapping) : simd_width_(simd_width), already_generated_(already_generated), str_(str),  mapping_(mapping){ }
00051 
00052           void operator()(scheduler::statement const & statement, unsigned int root_idx, node_type node_type) const {
00053               scheduler::statement_node const & root_node = statement.array()[root_idx];
00054               if( (node_type==LHS_NODE_TYPE && root_node.lhs.type_family!=scheduler::COMPOSITE_OPERATION_FAMILY)
00055                 ||(node_type==RHS_NODE_TYPE && root_node.rhs.type_family!=scheduler::COMPOSITE_OPERATION_FAMILY) )
00056                   mapping_.at(std::make_pair(root_idx,node_type))->append_kernel_arguments(simd_width_, already_generated_, str_);
00057           }
00058       };
00059 
00060     }
00061 
00062   }
00063 
00064 }
00065 #endif