VisionCpp  0.0.1
local_mem_count.hpp
Go to the documentation of this file.
1 // This file is part of VisionCpp, a lightweight C++ template library
2 // for computer vision and image processing.
3 //
4 // Copyright (C) 2016 Codeplay Software Limited. All Rights Reserved.
5 //
6 // Contact: visioncpp@codeplay.com
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 
20 /// \file local_mem_count.hpp
21 /// \brief LocalmemCount used to counting terminal nodes. The total number of
22 /// leaf nodes is used by MakePlaceHolderExprHelper to statically find the order
23 /// of the leaf node in a expression tree.
24 
25 #ifndef VISIONCPP_INCLUDE_FRAMEWORK_EXPR_CONVERTOR_LOCAL_MEM_COUNT_HPP_
26 #define VISIONCPP_INCLUDE_FRAMEWORK_EXPR_CONVERTOR_LOCAL_MEM_COUNT_HPP_
27 
28 namespace visioncpp {
29 namespace internal {
30 /// \brief Partial specialisation of the LocalmemCount when the LeafNode contains
31 /// the const variable. In this case there is no shared memory for const
32 /// variable and the const variable is directly copied to the device and accessed
33 /// by each thread.
34 template <size_t N, size_t Rows, size_t Cols, size_t LVL>
36  expr_category::Unary,
37  LeafNode<PlaceHolder<memory_type::Const, N, Cols, Rows, scope::Global>,
38  LVL>> {
39  static constexpr size_t Count = 0;
40 };
41 /// \brief Partial specialisation of the LocalmemCount when the LeafNode contains
42 /// a sycl buffer created on constant memory. There is no shared memory created
43 /// for a buffer on a device constant memory. Such a buffer is directly accessed
44 /// on the device by each thread.
45 template <size_t MemoryType, size_t N, size_t Rows, size_t Cols, size_t LVL>
47  expr_category::Unary,
48  LeafNode<PlaceHolder<MemoryType, N, Cols, Rows, scope::Constant>, LVL>> {
49  static constexpr size_t Count = 0;
50 };
51 
52 /// \brief specialisation of LocalmemCount when the node is a LeafNode
53 /// template parameters:
54 /// \param RHS is the visionMemory
55 /// \param LVL shows the level of the node in the expression tree
56 template <typename RHSExpr, size_t LVL>
57 struct LocalMemCount<expr_category::Unary, LeafNode<RHSExpr, LVL>> {
58  static constexpr size_t Count = 1;
59 };
60 
61 /// template parameters:
62 /// \brief specialisation of LocalmemCount when the node has one child
63 /// \param RHS is the right-hand side expression of the node
64 /// \param LVL shows the level of the node in the expression tree
65 template <typename Expr>
66 struct LocalMemCount<expr_category::Unary, Expr> {
67  static constexpr size_t Count =
68  1 +
70 };
71 /// \brief specialisation of LocalmemCount when the node has two children
72 /// template parameters:
73 /// \param LHS is the left-hand side expression in the node
74 /// \param RHS is the right-hand side expression in the node
75 /// \param LVL shows the level of the node in the expression tree
76 template <typename Expr>
77 struct LocalMemCount<expr_category::Binary, Expr> {
78  static constexpr size_t Count =
79  1 +
82 };
83 
84 /// \brief Specialisation of ExtractAccessor class where the expression node is
85 /// Assign
86 template <typename LHSExpr, typename RHSExpr, size_t Cols, size_t Rows,
87  size_t LeafType, size_t LVL>
88 struct LocalMemCount<expr_category::Binary,
89  Assign<LHSExpr, RHSExpr, Cols, Rows, LeafType, LVL>> {
90  static constexpr size_t Count =
92 };
93 
94 /// \brief Specialisation of ExtractAccessor class where the expression node is
95 /// is ParallelCopy (partial assign)
96 template <typename LHSExpr, typename RHSExpr, size_t Cols, size_t Rows,
97  size_t OffsetColIn, size_t OffsetRowIn, size_t OffsetColOut,
98  size_t OffsetRowOut, size_t LeafType, size_t LVL>
100  expr_category::Binary,
101  ParallelCopy<LHSExpr, RHSExpr, Cols, Rows, OffsetColIn, OffsetRowIn,
102  OffsetColOut, OffsetRowOut, LeafType, LVL>> {
103  static constexpr size_t Count =
105 };
106 
107 } // internal
108 } // visioncpp
109 #endif // VISIONCPP_INCLUDE_FRAMEWORK_EXPR_CONVERTOR_LOCAL_MEM_COUNT_HPP_
VisionCpp namespace.
Definition: sycl/device.hpp:24
The definition is in Assign file.
Definition: assign.hpp:44
the definition is in LeafNode.
Definition: leaf_node.hpp:38
is used to count the total number of local memory for the subxpression.
The definition is in ParallelCopy file.