OpenVDB  8.1.1
VolumeComputeGenerator.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
11 
12 #ifndef OPENVDB_AX_VOLUME_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
13 #define OPENVDB_AX_VOLUME_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
14 
15 #include "ComputeGenerator.h"
16 #include "FunctionTypes.h"
17 
18 #include "../compiler/AttributeRegistry.h"
19 
20 #include <openvdb/version.h>
21 
22 namespace openvdb {
24 namespace OPENVDB_VERSION_NAME {
25 
26 namespace ax {
27 namespace codegen {
28 
45 {
46  // The signature of the generated function
47  using Signature =
48  void(const void* const,
49  const int32_t (*)[3],
50  void*, // value
51  bool, // active
52  int64_t, // index
53  void**, // r accessors
54  const void* const*,
55  int64_t);
56 
58  static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
59 
60  static const std::array<std::string, N_ARGS>& argumentKeys();
61  static const char* getDefaultName();
62 };
63 
81 {
82  // The signature of the generated function
83  using Signature =
84  void(const void* const,
85  const int32_t (*)[3],
86  void*, // value buffer
87  uint64_t*, // active buffer
88  int64_t, // buffer size
89  uint64_t, // mode (0 = off, 1 = active, 2 = both)
90  void**, // read accessors
91  const void* const*, // transforms
92  int64_t); // write index
93 
95  static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
96 
97  static const std::array<std::string, N_ARGS>& argumentKeys();
98  static const char* getDefaultName();
99 };
100 
117 {
118  // The signature of the generated function
119  using Signature =
120  void(const void* const,
121  const int32_t (*)[3], // index space coord
122  void**, // read accessors
123  const void* const*, // transforms
124  int64_t, // write index
125  void*); // write accessor
126 
128  static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
129 
130  static const std::array<std::string, N_ARGS>& argumentKeys();
131  static const char* getDefaultName();
132 };
133 
136 
137 namespace codegen_internal {
138 
143 {
150  VolumeComputeGenerator(llvm::Module& module,
151  const FunctionOptions& options,
152  FunctionRegistry& functionRegistry,
153  Logger& logger);
154 
155  ~VolumeComputeGenerator() override = default;
156 
157  using ComputeGenerator::traverse;
158  using ComputeGenerator::visit;
159 
160  AttributeRegistry::Ptr generate(const ast::Tree& node);
161  bool visit(const ast::Attribute*) override;
162 
163 private:
164  llvm::Value* accessorHandleFromToken(const std::string&);
165  void getAccessorValue(const std::string&, llvm::Value*);
166 
167  void computek2(llvm::Function*, const AttributeRegistry&);
168  void computek3(llvm::Function*, const AttributeRegistry&);
169 };
170 
171 } // namespace codegen_internal
172 
173 } // namespace codegen
174 } // namespace ax
175 } // namespace OPENVDB_VERSION_NAME
176 } // namespace openvdb
177 
178 #endif // OPENVDB_AX_VOLUME_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
179 
The core visitor framework for code generation.
Visitor object which will generate llvm IR for a syntax tree. This provides the majority of the code ...
Definition: ComputeGenerator.h:86
This class stores a list of access names, types and their dependency connections. ...
Definition: AttributeRegistry.h:38
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:54
Attributes represent any access to a primitive value, typically associated with the &#39;@&#39; symbol syntax...
Definition: AST.h:1873
std::shared_ptr< AttributeRegistry > Ptr
Definition: AttributeRegistry.h:41
Contains frameworks for creating custom AX functions which can be registered within the FunctionRegis...
Templated function traits which provides compile-time index access to the types of the function signa...
Definition: ax/openvdb_ax/codegen/Types.h:259
A Tree is the highest concrete (non-abstract) node in the entire AX AST hierarchy. It represents an entire conversion of a valid AX string.
Definition: AST.h:561
The primary volume kernel. This function holds the generated body of AX programs. ...
Definition: VolumeComputeGenerator.h:44
void(const void *const, const int32_t(*)[3], void *, bool, int64_t, void **, const void *const *, int64_t) Signature
Definition: VolumeComputeGenerator.h:55
void(const void *const, const int32_t(*)[3], void *, uint64_t *, int64_t, uint64_t, void **, const void *const *, int64_t) Signature
Definition: VolumeComputeGenerator.h:92
Definition: openvdb/Exceptions.h:13
The function registry which is used for function code generation. Each time a function is visited wit...
Definition: FunctionRegistry.h:36
Options that control how functions behave.
Definition: CompilerOptions.h:24
void(const void *const, const int32_t(*)[3], void **, const void *const *, int64_t, void *) Signature
Definition: VolumeComputeGenerator.h:125
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
The third volume kernel, providing an agnostic way to modify a single tile value without passing thro...
Definition: VolumeComputeGenerator.h:116
The second volume kernel, responsible for providing the core layer of SIMD optimisations by invoking ...
Definition: VolumeComputeGenerator.h:80
Visitor object which will generate llvm IR for a syntax tree which has been generated from AX that ta...
Definition: VolumeComputeGenerator.h:142
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:178