VPP  0.7
A high-level modern C++ API for Vulkan
vppLangConstructs.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2016-2018 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 // -----------------------------------------------------------------------------
30 namespace vpp {
31 // -----------------------------------------------------------------------------
32 
65 void If ( Bool v );
66 
101 void Else();
102 
109 void Fi();
110 
111 // -----------------------------------------------------------------------------
156 void Do();
157 
170 void While ( Bool v );
171 
183 void Od();
184 
185 // -----------------------------------------------------------------------------
234 void For ( VInt& variable, Int begin, Int end, Int step = 1 );
235 
237 void For ( VUInt& variable, UInt begin, UInt end, UInt step = 1 );
238 
244 void Rof();
245 
246 // -----------------------------------------------------------------------------
247 
260 void Switch ( Int expr );
261 
266 void Case ( int value );
267 
272 void Default();
273 
278 void Break();
279 
284 void EndSwitch();
285 
286 // -----------------------------------------------------------------------------
287 // -----------------------------------------------------------------------------
288 
289 template< class ReturnType, typename... Args >
290 struct Function : public detail::KFunction
291 {
292  Function ( const char* pName = "unnamedFunction" );
293 
294  ReturnType operator()( typename Args::rvalue_type ... args );
295 };
296 
297 template< class ParamType >
298 struct Par
299 {
300  Par();
301 
302  inline operator rvalue_type() const
303  {
304  ParamType par ( d_variableId );
305  return rvalue_type ( par );
306  }
307 
308  template< typename IndexT >
309  inline auto operator[]( const IndexT& idx ) const
310  {
311  const rvalue_type rValue = *this;
312  return rValue [ idx ];
313  }
314 
315  inline int size() const
316  {
317  const rvalue_type rValue = *this;
318  return rValue.size();
319  }
320 
321  inline int Size() const
322  {
323  const rvalue_type rValue = *this;
324  return rValue.Size();
325  }
326 
327  VPP_DEFINE_PARAM_OPERATORS
328 };
329 
330 // -----------------------------------------------------------------------------
331 
332 void Begin();
333 
334 void End();
335 
336 void Return();
337 
338 template< typename ValueT >
339 void Return ( const ValueT& value );
340 
341 // -----------------------------------------------------------------------------
342 
366 template< class CondT, class Arg1T, class Arg2T >
367 auto Select ( const CondT& cond, const Arg1T& argIfTrue, const Arg2T& argIfFalse );
368 
369 // -----------------------------------------------------------------------------
370 
376 void Shared();
377 
383 void Static();
384 
385 // -----------------------------------------------------------------------------
386 
387 enum EMemorySemantics
388 {
389  MSM_NONE,
390  MSM_ACQ,
391  MSM_REL,
392  MSM_ACQREL,
393  MSM_SEQCONS,
394  MSM_UNIFORM,
395  MSM_SUBGROUP,
396  MSM_WORKGROUP,
397  MSM_CROSSWG,
398  MSM_ATOMIC,
399  MSM_IMAGE
400 };
401 
402 // -----------------------------------------------------------------------------
403 
408 void WorkgroupBarrier (
409  EMemorySemantics msClass = MSM_WORKGROUP,
410  EMemorySemantics msSem = MSM_ACQREL );
411 
415 void DeviceBarrier (
416  EMemorySemantics msClass = MSM_CROSSWG,
417  EMemorySemantics msSem = MSM_ACQREL );
418 
419 // -----------------------------------------------------------------------------
420 } // namespace vpp
421 // -----------------------------------------------------------------------------
void Fi()
Creates the ending clause of the conditional construct.
void Do()
Creates the do clause of the loop construct.
The VPP namespace.
Definition: main.hpp:1
Definition: vppLangConstructs.hpp:290
void Rof()
Creates the closing clause of the &#39;for&#39; loop construct.
void WorkgroupBarrier(EMemorySemantics msClass=MSM_WORKGROUP, EMemorySemantics msSem=MSM_ACQREL)
Creates control and memory barrier affecting threads in workgroup.
void Else()
Creates the else clause of the conditional construct.
void Switch(Int expr)
Creates the switch construct.
void EndSwitch()
Creates the closing clause of the switch construct.
void Default()
Creates the default clause of the switch construct.
void DeviceBarrier(EMemorySemantics msClass=MSM_CROSSWG, EMemorySemantics msSem=MSM_ACQREL)
Creates control and memory barrier affecting threads in all workgroups.
Definition: vppLangConstructs.hpp:298
void While(Bool v)
Creates the while clause of the loop construct.
void Shared()
Tags the next declared variable to be allocated in shared memory.
void Case(int value)
Creates the case clause of the switch construct.
void Break()
Creates the break clause of the switch construct.
auto Select(const CondT &cond, const Arg1T &argIfTrue, const Arg2T &argIfFalse)
A conditional expression.
void Od()
Creates the closing clause of the loop construct.
void Static()
Tags the next declared variable to be visible across functions.
void If(Bool v)
Creates the if clause of the conditional construct.
void For(VInt &variable, Int begin, Int end, Int step=1)
Creates the for clause of the &#39;for&#39; loop construct.