OpenVDB  8.0.1
VolumeExecutable.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_COMPILER_VOLUME_EXECUTABLE_HAS_BEEN_INCLUDED
13 #define OPENVDB_AX_COMPILER_VOLUME_EXECUTABLE_HAS_BEEN_INCLUDED
14 
15 #include "CustomData.h"
16 #include "AttributeRegistry.h"
17 
18 #include <openvdb/version.h>
19 #include <openvdb/Grid.h>
20 
21 #include <unordered_map>
22 
23 class TestVolumeExecutable;
24 
25 namespace llvm {
26 class ExecutionEngine;
27 class LLVMContext;
28 }
29 
30 namespace openvdb {
32 namespace OPENVDB_VERSION_NAME {
33 namespace ax {
34 
35 class Compiler;
36 
40 {
41 public:
42  using Ptr = std::shared_ptr<VolumeExecutable>;
44 
49 
51 
53  void execute(openvdb::GridPtrVec& grids) const;
54  void execute(openvdb::GridBase& grid) const;
55 
57 
62  void setCreateMissing(const bool flag);
64  bool getCreateMissing() const;
65 
77  void setTreeExecutionLevel(const Index level);
80 
81  enum class IterType { ON, OFF, ALL };
85  void setValueIterator(const IterType& iter);
88 
92  void setGrainSize(const size_t grain);
94  size_t getGrainSize() const;
95 
97 
98  // foward declaration of settings for this executable
99  struct Settings;
100 
101 private:
102  friend class Compiler;
103  friend class ::TestVolumeExecutable;
104 
116  VolumeExecutable(const std::shared_ptr<const llvm::LLVMContext>& context,
117  const std::shared_ptr<const llvm::ExecutionEngine>& engine,
118  const AttributeRegistry::ConstPtr& accessRegistry,
119  const CustomData::ConstPtr& customData,
120  const std::unordered_map<std::string, uint64_t>& functions);
121 
122 private:
123  // The Context and ExecutionEngine must exist _only_ for object lifetime
124  // management. The ExecutionEngine must be destroyed before the Context
125  const std::shared_ptr<const llvm::LLVMContext> mContext;
126  const std::shared_ptr<const llvm::ExecutionEngine> mExecutionEngine;
127  const AttributeRegistry::ConstPtr mAttributeRegistry;
128  const CustomData::ConstPtr mCustomData;
129  const std::unordered_map<std::string, uint64_t> mFunctionAddresses;
130  std::unique_ptr<Settings> mSettings;
131 };
132 
133 } // namespace ax
134 } // namespace OPENVDB_VERSION_NAME
135 } // namespace openvdb
136 
137 #endif // OPENVDB_AX_COMPILER_VOLUME_EXECUTABLE_HAS_BEEN_INCLUDED
138 
openvdb::v8_0::ax::VolumeExecutable::getCreateMissing
bool getCreateMissing() const
openvdb::v8_0::Index
Index32 Index
Definition: openvdb/Types.h:32
llvm
Definition: Compiler.h:31
openvdb::v8_0::GridPtrVec
std::vector< GridBase::Ptr > GridPtrVec
Definition: Grid.h:514
openvdb::v8_0::points::index::ALL
@ ALL
Definition: IndexIterator.h:43
CustomData.h
Access to the CustomData class which can provide custom user user data to the OpenVDB AX Compiler.
version.h
Library and file format version numbers.
openvdb::v8_0::ax::VolumeExecutable::VolumeExecutable
VolumeExecutable(const VolumeExecutable &other)
Copy constructor. Shares the LLVM constructs but deep copies the settings. Multiple copies of an exec...
openvdb::v8_0::ax::VolumeExecutable::setValueIterator
void setValueIterator(const IterType &iter)
Set the value iterator type to use with this executable. Options are ON, OFF, ALL....
Grid.h
openvdb::v8_0::ax::VolumeExecutable::getGrainSize
size_t getGrainSize() const
openvdb::v8_0::ax::VolumeExecutable::execute
void execute(openvdb::GridPtrVec &grids) const
Execute AX code on target grids.
openvdb::v8_0::ax::VolumeExecutable::setGrainSize
void setGrainSize(const size_t grain)
Set the threading grain size. Default is 1. A value of 0 has the effect of disabling multi-threading.
openvdb::v8_0::ax::VolumeExecutable
Object that encapsulates compiled AX code which can be executed on a collection of VDB volume grids.
Definition: VolumeExecutable.h:40
openvdb::v8_0::ax::VolumeExecutable::getValueIterator
IterType getValueIterator() const
openvdb::v8_0::ax::CustomData::ConstPtr
std::shared_ptr< const CustomData > ConstPtr
Definition: CustomData.h:47
openvdb::v8_0::ax::VolumeExecutable::setTreeExecutionLevel
void setTreeExecutionLevel(const Index level)
Set the execution level for this executable. This controls what nodes are processed when execute is c...
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:153
openvdb::v8_0::ax::VolumeExecutable::IterType
IterType
Definition: VolumeExecutable.h:81
openvdb::v8_0::ax::VolumeExecutable::Ptr
std::shared_ptr< VolumeExecutable > Ptr
Definition: VolumeExecutable.h:42
openvdb::v8_0::ax::VolumeExecutable::execute
void execute(openvdb::GridBase &grid) const
openvdb::v8_0::ax::VolumeExecutable::~VolumeExecutable
~VolumeExecutable()
openvdb::v8_0::ax::VolumeExecutable::setCreateMissing
void setCreateMissing(const bool flag)
Set the behaviour when missing grids are accessed. Default behaviour is true, which creates them with...
openvdb::v8_0::GridBase
Abstract base class for typed grids.
Definition: Grid.h:78
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:101
openvdb::v8_0::ax::AttributeRegistry::ConstPtr
std::shared_ptr< const AttributeRegistry > ConstPtr
Definition: AttributeRegistry.h:40
AttributeRegistry.h
These classes contain lists of expected attributes and volumes which are populated by compiler during...
openvdb
Definition: openvdb/Exceptions.h:13
openvdb::v8_0::ax::Compiler
The compiler class. This holds an llvm context and set of compiler options, and constructs executable...
Definition: Compiler.h:50
openvdb::v8_0::ax::VolumeExecutable::getTreeExecutionLevel
Index getTreeExecutionLevel() const