VPP  0.8
A high-level modern C++ API for Vulkan
vppctGroupAlg.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2016-2019 SOFT-ERG, Przemek Kuczmierczyk (www.softerg.com)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification,
6  are permitted provided that the following conditions are met:
7 
8  1. Redistributions of source code must retain the above copyright notice,
9  this list of conditions and the following disclaimer.
10 
11  2. Redistributions in binary form must reproduce the above copyright notice,
12  this list of conditions and the following disclaimer in the documentation
13  and/or other materials provided with the distribution.
14 
15  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
29 // -----------------------------------------------------------------------------
31 namespace vpp {
32 // -----------------------------------------------------------------------------
33 // -----------------------------------------------------------------------------
35 namespace ct {
36 // -----------------------------------------------------------------------------
37 // -----------------------------------------------------------------------------
39 namespace group {
40 // -----------------------------------------------------------------------------
41 
43 {
44 public:
45  GroupInvocation ( ComputeShader* pShader );
46 
47  ComputeShader* shader() const;
48  const vpp::Int& LocalId() const;
49  const vpp::Int& LocalCount() const;
50  int localCount() const;
51 };
52 
53 // -----------------------------------------------------------------------------
54 
55 template< typename ArrayT, class FunctorT >
56 void Apply ( const ArrayT& arr, FunctorT&& fFunctor, const GroupInvocation& inv );
57 
58 // -----------------------------------------------------------------------------
59 
60 template< typename ArrayT, typename ValueT >
61 void Fill ( const ArrayT& arr, const ValueT& val, const GroupInvocation& inv );
62 
63 // -----------------------------------------------------------------------------
64 
65 template< typename ArrayT, class FunctorT >
66 void Generate ( const ArrayT& arr, FunctorT&& fFunctor, const GroupInvocation& inv );
67 
68 // -----------------------------------------------------------------------------
69 
70 template< typename ArrayT, class FunctorT >
71 void Transform (
72  const ArrayT& inArr, const ArrayT& outArr,
73  FunctorT&& fFunctor, const GroupInvocation& inv );
74 
75 // -----------------------------------------------------------------------------
76 
77 template< typename ArrayT >
78 void Copy (
79  const ArrayT& inArr, const ArrayT& outArr, const GroupInvocation& inv );
80 
81 // -----------------------------------------------------------------------------
82 
83 template< class SourceArrayT, typename ArrayT >
84 void Load (
85  const SourceArrayT& inArr, const Int& sourceStartIndex, const ArrayT& outArr,
86  const GroupInvocation& inv );
87 
88 template< class SourceArrayT, typename ArrayT >
89 void Load (
90  const SourceArrayT& inArr, bool bColumnMajor, const Int& sourceStartIndex,
91  const ArrayT& outArr, const GroupInvocation& inv );
92 
93 // -----------------------------------------------------------------------------
94 
95 template< class TargetArrayT, typename ArrayT >
96 void Store (
97  const ArrayT& inArr, const TargetArrayT& outArr, const Int& destStartIndex,
98  const GroupInvocation& inv );
99 
100 template< class TargetArrayT, typename ArrayT >
101 void Store (
102  const ArrayT& inArr, const TargetArrayT& outArr, bool bColumnMajor,
103  const Int& destStartIndex, const GroupInvocation& inv );
104 
105 // -----------------------------------------------------------------------------
106 
107 template< typename ValueT, typename VValueT, class FunctorT >
108 ValueT Reduce (
109  WArray< ValueT >& arr, FunctorT&& fFunctor,
110  VValueT& temporaryVal, WArray< ValueT >& tmpArr,
111  const GroupInvocation& inv );
112 
113 // -----------------------------------------------------------------------------
114 
115 template< typename ValueT, typename VValueT, class FunctorT >
116 void InclusiveScan (
117  WArray< ValueT >& arr, FunctorT&& fFunctor,
118  VValueT& temporaryVal, WArray< ValueT >& tmpArr,
119  const GroupInvocation& inv );
120 
121 // -----------------------------------------------------------------------------
122 
123 template< typename ValueT, typename VValueT, class FunctorT >
124 void ExclusiveScan (
125  WArray< ValueT >& arr, FunctorT&& fFunctor,
126  VValueT& temporaryVal, WArray< ValueT >& tmpArr,
127  const GroupInvocation& inv );
128 
129 // -----------------------------------------------------------------------------
130 
131 template< typename ArrayT, typename FunctorT >
132 void Sort (
133  const ArrayT& arr, FunctorT&& fFunctor,
134  const GroupInvocation& inv );
135 
136 // -----------------------------------------------------------------------------
137 
138 template< typename ArrayT, typename ValueT, typename FunctorT >
139 Int LowerBound (
140  const ArrayT& arr, const ValueT& v, FunctorT&& fFunctor,
141  WArray< Int >& tmpArr, const GroupInvocation& inv );
142 
143 template< typename ArrayT, typename ValueT, typename FunctorT >
144 Int UpperBound (
145  const ArrayT& arr, const ValueT& v, FunctorT&& fFunctor,
146  WArray< Int >& tmpArr, const GroupInvocation& inv );
147 
148 // -----------------------------------------------------------------------------
149 } // namespace group
150 // -----------------------------------------------------------------------------
151 // -----------------------------------------------------------------------------
152 } // namespace ct
153 // -----------------------------------------------------------------------------
154 // -----------------------------------------------------------------------------
155 } // namespace vpp
156 // -----------------------------------------------------------------------------
The VPP namespace.
Definition: main.hpp:1
Definition: vppctGroupAlg.hpp:42
Compute shader interface.
Definition: vppLangIntInOut.hpp:432
Shader (GPU-side) data type for 32-bit signed integer values.
Definition: vppLangScalarTypes.hpp:162
Declares workgroup-scoped variable of array type.
Definition: vppLangAggregates.hpp:215