OpenVDB 13.0.0

Loading...
Searching...
No Matches
PointComputeGenerator.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: Apache-2.0
3
4/// @file codegen/PointComputeGenerator.h
5///
6/// @authors Nick Avramoussis, Matt Warner, Francisco Gochez, Richard Jones
7///
8/// @brief The visitor framework and function definition for point data
9/// grid code generation
10///
11
12#ifndef OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
13#define OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
14
15#include "ComputeGenerator.h"
16#include "FunctionTypes.h"
17#include "Types.h"
18#include "Utils.h"
19
20#include "../compiler/AttributeRegistry.h"
21
22#include <openvdb/version.h>
23#include <openvdb/points/AttributeArray.h>
24
25 namespace openvdb {
26 OPENVDB_USE_VERSION_NAMESPACE
27 namespace OPENVDB_VERSION_NAME {
28
29 namespace ax {
30 namespace codegen {
31
32///////////////////////////////////////////////////////////////////////////////
33///////////////////////////////////////////////////////////////////////////////
34
35 struct PointKernelValue
36{
37 // The signature of the generated function
38 using Signature =
39 void(const void* const,
40 const int32_t (*)[3],
41 Index32*, // leaf value buffer
42 bool, // active
43 uint64_t, // pindex
44 void**, // transforms
45 void**, // values
46 uint64_t*, // flags
47 const void* const, // attribute set
48 void**, // group handles
49 void*); // leaf data
50
51 using FunctionTraitsT = codegen::FunctionTraits<Signature>;
52 static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
53
54 static const std::array<const char*, N_ARGS>& argumentKeys();
55 static const char* getDefaultName();
56};
57
58 struct PointKernelAttributeArray
59{
60 // The signature of the generated function
61 using Signature =
62 void(const void* const,
63 const int32_t (*)[3],
64 Index32*, // leaf value buffer
65 bool, // active
66 uint64_t, // pindex
67 void**, // transforms
68 void**, // arrays
69 uint64_t*, // flags
70 const void* const, // attribute set
71 void**, // group handles
72 void*); // leaf data
73
74 using FunctionTraitsT = codegen::FunctionTraits<Signature>;
75 static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
76
77 static const std::array<const char*, N_ARGS>& argumentKeys();
78 static const char* getDefaultName();
79};
80
81 struct PointKernelBuffer
82{
83 // The signature of the generated function
84 using Signature =
85 void(const void* const,
86 const int32_t (*)[3],
87 Index32*, // leaf value buffer
88 bool, // active
89 uint64_t, // pindex
90 void**, // transforms
91 void**, // buffers
92 uint64_t*, // flags
93 const void* const, // attribute set
94 void**, // group handles
95 void*); // leaf data
96
97 using FunctionTraitsT = codegen::FunctionTraits<Signature>;
98 static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
99
100 static const std::array<const char*, N_ARGS>& argumentKeys();
101 static const char* getDefaultName();
102};
103
104 struct PointKernelBufferRange
105{
106 // The signature of the generated function
107 using Signature =
108 void(const void* const,
109 const int32_t (*)[3],
110 Index32*, // leaf value buffer
111 uint64_t*, // active buffer
112 int64_t, // leaf buffer size (512)
113 uint64_t, // mode (0 = off, 1 = active, 2 = both)
114 void**, // transforms
115 void**, // buffers
116 uint64_t*, // flags
117 const void* const, // attribute set
118 void**, // group handles
119 void*); // leaf data
120
121 using FunctionTraitsT = codegen::FunctionTraits<Signature>;
122 static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
123
124 static const std::array<const char*, N_ARGS>& argumentKeys();
125 static const char* getDefaultName();
126};
127
128
129///////////////////////////////////////////////////////////////////////////
130///////////////////////////////////////////////////////////////////////////
131
132 namespace codegen_internal {
133
134/// @brief Visitor object which will generate llvm IR for a syntax tree which has been generated from
135/// AX that targets point grids. The IR will represent 2 functions : one that executes over
136/// single points and one that executes over a collection of points. This is primarily used by the
137/// Compiler class.
138 struct PointComputeGenerator : public ComputeGenerator
139{
140 /// @brief Constructor
141 /// @param module llvm Module for generating IR
142 /// @param options Options for the function registry behaviour
143 /// @param functionRegistry Function registry object which will be used when generating IR
144 /// for function calls
145 /// @param logger Logger for collecting logical errors and warnings
146 PointComputeGenerator(llvm::Module& module,
147 const FunctionOptions& options,
148 FunctionRegistry& functionRegistry,
149 Logger& logger);
150
151 ~PointComputeGenerator() override = default;
152
153 using ComputeGenerator::traverse;
154 using ComputeGenerator::visit;
155
156 AttributeRegistry::Ptr generate(const ast::Tree& node);
157 bool visit(const ast::Attribute*) override;
158
159 private:
160 void computePKBR(const AttributeRegistry&);
161 void computePKB(const AttributeRegistry&);
162 void computePKAA(const AttributeRegistry&);
163};
164
165} // namespace namespace codegen_internal
166
167} // namespace codegen
168} // namespace ax
169} // namespace OPENVDB_VERSION_NAME
170} // namespace openvdb
171
172#endif // OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
173
AttributeArray.h
Attribute Array storage templated on type and compression codec.
AttributeRegistry.h
These classes contain lists of expected attributes and volumes which are populated by compiler during...
ComputeGenerator.h
The core visitor framework for code generation.
FunctionTypes.h
Contains frameworks for creating custom AX functions which can be registered within the FunctionRegis...
Types.h
Consolidated llvm types for most supported types.
openvdb::v13_0::ax::AttributeRegistry
This class stores a list of access names, types and their dependency connections.
Definition AttributeRegistry.h:40
openvdb::v13_0::ax::AttributeRegistry::Ptr
std::shared_ptr< AttributeRegistry > Ptr
Definition AttributeRegistry.h:42
openvdb::v13_0::ax::Logger
Logger for collecting errors and warnings that occur during AX compilation.
Definition Logger.h:58
openvdb::v13_0::ax::codegen::FunctionRegistry
The function registry which is used for function code generation. Each time a function is visited wit...
Definition FunctionRegistry.h:40
openvdb::v13_0::ax::codegen::codegen_internal
Definition ComputeGenerator.h:68
openvdb::v13_0::Index32
uint32_t Index32
Definition Types.h:32
openvdb
Definition Exceptions.h:13
Utils.h
Utility code generation methods for performing various llvm operations.
openvdb::v13_0::ax::FunctionOptions
Options that control how functions behave.
Definition CompilerOptions.h:25
openvdb::v13_0::ax::ast::Attribute
Attributes represent any access to a primitive value, typically associated with the '@' symbol syntax...
Definition AST.h:1875
openvdb::v13_0::ax::ast::Tree
A Tree is the highest concrete (non-abstract) node in the entire AX AST hierarchy....
Definition AST.h:563
openvdb::v13_0::ax::codegen::FunctionTraits
Templated function traits which provides compile-time index access to the types of the function signa...
Definition Types.h:311
openvdb::v13_0::ax::codegen::PointKernelAttributeArray
Definition PointComputeGenerator.h:59
openvdb::v13_0::ax::codegen::PointKernelAttributeArray::argumentKeys
static const std::array< const char *, N_ARGS > & argumentKeys()
openvdb::v13_0::ax::codegen::PointKernelAttributeArray::FunctionTraitsT
codegen::FunctionTraits< Signature > FunctionTraitsT
Definition PointComputeGenerator.h:74
openvdb::v13_0::ax::codegen::PointKernelAttributeArray::N_ARGS
static const size_t N_ARGS
Definition PointComputeGenerator.h:75
openvdb::v13_0::ax::codegen::PointKernelAttributeArray::Signature
void(const void *const, const int32_t(*)[3], Index32 *, bool, uint64_t, void **, void **, uint64_t *, const void *const, void **, void *) Signature
Definition PointComputeGenerator.h:61
openvdb::v13_0::ax::codegen::PointKernelAttributeArray::getDefaultName
static const char * getDefaultName()
openvdb::v13_0::ax::codegen::PointKernelBuffer
Definition PointComputeGenerator.h:82
openvdb::v13_0::ax::codegen::PointKernelBuffer::argumentKeys
static const std::array< const char *, N_ARGS > & argumentKeys()
openvdb::v13_0::ax::codegen::PointKernelBuffer::FunctionTraitsT
codegen::FunctionTraits< Signature > FunctionTraitsT
Definition PointComputeGenerator.h:97
openvdb::v13_0::ax::codegen::PointKernelBuffer::N_ARGS
static const size_t N_ARGS
Definition PointComputeGenerator.h:98
openvdb::v13_0::ax::codegen::PointKernelBuffer::Signature
void(const void *const, const int32_t(*)[3], Index32 *, bool, uint64_t, void **, void **, uint64_t *, const void *const, void **, void *) Signature
Definition PointComputeGenerator.h:84
openvdb::v13_0::ax::codegen::PointKernelBuffer::getDefaultName
static const char * getDefaultName()
openvdb::v13_0::ax::codegen::PointKernelBufferRange
Definition PointComputeGenerator.h:105
openvdb::v13_0::ax::codegen::PointKernelBufferRange::argumentKeys
static const std::array< const char *, N_ARGS > & argumentKeys()
openvdb::v13_0::ax::codegen::PointKernelBufferRange::FunctionTraitsT
codegen::FunctionTraits< Signature > FunctionTraitsT
Definition PointComputeGenerator.h:121
openvdb::v13_0::ax::codegen::PointKernelBufferRange::N_ARGS
static const size_t N_ARGS
Definition PointComputeGenerator.h:122
openvdb::v13_0::ax::codegen::PointKernelBufferRange::Signature
void(const void *const, const int32_t(*)[3], Index32 *, uint64_t *, int64_t, uint64_t, void **, void **, uint64_t *, const void *const, void **, void *) Signature
Definition PointComputeGenerator.h:107
openvdb::v13_0::ax::codegen::PointKernelBufferRange::getDefaultName
static const char * getDefaultName()
openvdb::v13_0::ax::codegen::PointKernelValue
Definition PointComputeGenerator.h:36
openvdb::v13_0::ax::codegen::PointKernelValue::argumentKeys
static const std::array< const char *, N_ARGS > & argumentKeys()
openvdb::v13_0::ax::codegen::PointKernelValue::FunctionTraitsT
codegen::FunctionTraits< Signature > FunctionTraitsT
Definition PointComputeGenerator.h:51
openvdb::v13_0::ax::codegen::PointKernelValue::N_ARGS
static const size_t N_ARGS
Definition PointComputeGenerator.h:52
openvdb::v13_0::ax::codegen::PointKernelValue::Signature
void(const void *const, const int32_t(*)[3], Index32 *, bool, uint64_t, void **, void **, uint64_t *, const void *const, void **, void *) Signature
Definition PointComputeGenerator.h:38
openvdb::v13_0::ax::codegen::PointKernelValue::getDefaultName
static const char * getDefaultName()
openvdb::v13_0::ax::codegen::codegen_internal::ComputeGenerator::ComputeGenerator
ComputeGenerator(llvm::Module &module, const FunctionOptions &options, FunctionRegistry &functionRegistry, Logger &logger)
openvdb::v13_0::ax::codegen::codegen_internal::ComputeGenerator::traverse
bool traverse(const ast::Block *block)
Custom traversal of scoped blocks.
Definition ComputeGenerator.h:112
openvdb::v13_0::ax::codegen::codegen_internal::ComputeGenerator::visit
virtual bool visit(const ast::CommaOperator *)
Visitor methods for all AST nodes which implement IR generation.
openvdb::v13_0::ax::codegen::codegen_internal::PointComputeGenerator::generate
AttributeRegistry::Ptr generate(const ast::Tree &node)
openvdb::v13_0::ax::codegen::codegen_internal::PointComputeGenerator::~PointComputeGenerator
~PointComputeGenerator() override=default
openvdb::v13_0::ax::codegen::codegen_internal::PointComputeGenerator::visit
bool visit(const ast::Attribute *) override
Visitor methods for all AST nodes which implement IR generation.
openvdb::v13_0::ax::codegen::codegen_internal::PointComputeGenerator::PointComputeGenerator
PointComputeGenerator(llvm::Module &module, const FunctionOptions &options, FunctionRegistry &functionRegistry, Logger &logger)
Constructor.
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218