Loading...
Searching...
No Matches
PointComputeGenerator.h
Go to the documentation of this file.
// Copyright Contributors to the OpenVDB Project
// SPDX-License-Identifier: MPL-2.0
/// @file codegen/PointComputeGenerator.h
///
/// @authors Nick Avramoussis, Matt Warner, Francisco Gochez, Richard Jones
///
/// @brief The visitor framework and function definition for point data
/// grid code generation
///
#ifndef OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
#define OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
#include "ComputeGenerator.h"
#include "FunctionTypes.h"
#include "Types.h"
#include "Utils.h"
#include "../compiler/AttributeRegistry.h"
#include <openvdb/version.h>
#include <openvdb/points/AttributeArray.h>
namespace openvdb {
OPENVDB_USE_VERSION_NAMESPACE
namespace OPENVDB_VERSION_NAME {
namespace ax {
namespace codegen {
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
struct PointKernelValue
{
// The signature of the generated function
using Signature =
void(const void* const,
const int32_t (*)[3],
Index32*, // leaf value buffer
bool, // active
uint64_t, // pindex
void**, // transforms
void**, // values
uint64_t*, // flags
const void* const, // attribute set
void**, // group handles
void*); // leaf data
using FunctionTraitsT = codegen::FunctionTraits<Signature>;
static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
static const std::array<const char*, N_ARGS>& argumentKeys();
static const char* getDefaultName();
};
struct PointKernelAttributeArray
{
// The signature of the generated function
using Signature =
void(const void* const,
const int32_t (*)[3],
Index32*, // leaf value buffer
bool, // active
uint64_t, // pindex
void**, // transforms
void**, // arrays
uint64_t*, // flags
const void* const, // attribute set
void**, // group handles
void*); // leaf data
using FunctionTraitsT = codegen::FunctionTraits<Signature>;
static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
static const std::array<const char*, N_ARGS>& argumentKeys();
static const char* getDefaultName();
};
struct PointKernelBuffer
{
// The signature of the generated function
using Signature =
void(const void* const,
const int32_t (*)[3],
Index32*, // leaf value buffer
bool, // active
uint64_t, // pindex
void**, // transforms
void**, // buffers
uint64_t*, // flags
const void* const, // attribute set
void**, // group handles
void*); // leaf data
using FunctionTraitsT = codegen::FunctionTraits<Signature>;
static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
static const std::array<const char*, N_ARGS>& argumentKeys();
static const char* getDefaultName();
};
struct PointKernelBufferRange
{
// The signature of the generated function
using Signature =
void(const void* const,
const int32_t (*)[3],
Index32*, // leaf value buffer
uint64_t*, // active buffer
int64_t, // leaf buffer size (512)
uint64_t, // mode (0 = off, 1 = active, 2 = both)
void**, // transforms
void**, // buffers
uint64_t*, // flags
const void* const, // attribute set
void**, // group handles
void*); // leaf data
using FunctionTraitsT = codegen::FunctionTraits<Signature>;
static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
static const std::array<const char*, N_ARGS>& argumentKeys();
static const char* getDefaultName();
};
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
namespace codegen_internal {
/// @brief Visitor object which will generate llvm IR for a syntax tree which has been generated from
/// AX that targets point grids. The IR will represent 2 functions : one that executes over
/// single points and one that executes over a collection of points. This is primarily used by the
/// Compiler class.
struct PointComputeGenerator : public ComputeGenerator
{
/// @brief Constructor
/// @param module llvm Module for generating IR
/// @param options Options for the function registry behaviour
/// @param functionRegistry Function registry object which will be used when generating IR
/// for function calls
/// @param logger Logger for collecting logical errors and warnings
PointComputeGenerator(llvm::Module& module,
const FunctionOptions& options,
FunctionRegistry& functionRegistry,
Logger& logger);
~PointComputeGenerator() override = default;
using ComputeGenerator::traverse;
using ComputeGenerator::visit;
AttributeRegistry::Ptr generate(const ast::Tree& node);
bool visit(const ast::Attribute*) override;
private:
void computePKBR(const AttributeRegistry&);
void computePKB(const AttributeRegistry&);
void computePKAA(const AttributeRegistry&);
};
} // namespace namespace codegen_internal
} // namespace codegen
} // namespace ax
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
#endif // OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
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::v10_0::ax::AttributeRegistry
This class stores a list of access names, types and their dependency connections.
Definition AttributeRegistry.h:39
openvdb::v10_0::ax::AttributeRegistry::Ptr
std::shared_ptr< AttributeRegistry > Ptr
Definition AttributeRegistry.h:41
openvdb::v10_0::ax::Logger
Logger for collecting errors and warnings that occur during AX compilation.
Definition Logger.h:58
openvdb::v10_0::ax::codegen::FunctionRegistry
The function registry which is used for function code generation. Each time a function is visited wit...
Definition FunctionRegistry.h:36
openvdb::v10_0::ax::codegen::codegen_internal
Definition ComputeGenerator.h:67
openvdb::v10_0::Index32
uint32_t Index32
Definition Types.h:52
openvdb
Definition Exceptions.h:13
Utils.h
Utility code generation methods for performing various llvm operations.
openvdb::v10_0::ax::FunctionOptions
Options that control how functions behave.
Definition CompilerOptions.h:25
openvdb::v10_0::ax::ast::Attribute
Attributes represent any access to a primitive value, typically associated with the '@' symbol syntax...
Definition AST.h:1874
openvdb::v10_0::ax::ast::Tree
A Tree is the highest concrete (non-abstract) node in the entire AX AST hierarchy....
Definition AST.h:562
openvdb::v10_0::ax::codegen::FunctionTraits
Templated function traits which provides compile-time index access to the types of the function signa...
Definition Types.h:279
openvdb::v10_0::ax::codegen::PointKernelAttributeArray
Definition PointComputeGenerator.h:59
openvdb::v10_0::ax::codegen::PointKernelAttributeArray::argumentKeys
static const std::array< const char *, N_ARGS > & argumentKeys()
openvdb::v10_0::ax::codegen::PointKernelAttributeArray::FunctionTraitsT
codegen::FunctionTraits< Signature > FunctionTraitsT
Definition PointComputeGenerator.h:74
openvdb::v10_0::ax::codegen::PointKernelAttributeArray::N_ARGS
static const size_t N_ARGS
Definition PointComputeGenerator.h:75
openvdb::v10_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::v10_0::ax::codegen::PointKernelAttributeArray::getDefaultName
static const char * getDefaultName()
openvdb::v10_0::ax::codegen::PointKernelBufferRange
Definition PointComputeGenerator.h:105
openvdb::v10_0::ax::codegen::PointKernelBufferRange::argumentKeys
static const std::array< const char *, N_ARGS > & argumentKeys()
openvdb::v10_0::ax::codegen::PointKernelBufferRange::FunctionTraitsT
codegen::FunctionTraits< Signature > FunctionTraitsT
Definition PointComputeGenerator.h:121
openvdb::v10_0::ax::codegen::PointKernelBufferRange::N_ARGS
static const size_t N_ARGS
Definition PointComputeGenerator.h:122
openvdb::v10_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::v10_0::ax::codegen::PointKernelBufferRange::getDefaultName
static const char * getDefaultName()
openvdb::v10_0::ax::codegen::PointKernelBuffer
Definition PointComputeGenerator.h:82
openvdb::v10_0::ax::codegen::PointKernelBuffer::argumentKeys
static const std::array< const char *, N_ARGS > & argumentKeys()
openvdb::v10_0::ax::codegen::PointKernelBuffer::FunctionTraitsT
codegen::FunctionTraits< Signature > FunctionTraitsT
Definition PointComputeGenerator.h:97
openvdb::v10_0::ax::codegen::PointKernelBuffer::N_ARGS
static const size_t N_ARGS
Definition PointComputeGenerator.h:98
openvdb::v10_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::v10_0::ax::codegen::PointKernelBuffer::getDefaultName
static const char * getDefaultName()
openvdb::v10_0::ax::codegen::PointKernelValue
Definition PointComputeGenerator.h:36
openvdb::v10_0::ax::codegen::PointKernelValue::argumentKeys
static const std::array< const char *, N_ARGS > & argumentKeys()
openvdb::v10_0::ax::codegen::PointKernelValue::FunctionTraitsT
codegen::FunctionTraits< Signature > FunctionTraitsT
Definition PointComputeGenerator.h:51
openvdb::v10_0::ax::codegen::PointKernelValue::N_ARGS
static const size_t N_ARGS
Definition PointComputeGenerator.h:52
openvdb::v10_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::v10_0::ax::codegen::PointKernelValue::getDefaultName
static const char * getDefaultName()
openvdb::v10_0::ax::codegen::codegen_internal::ComputeGenerator::ComputeGenerator
ComputeGenerator(llvm::Module &module, const FunctionOptions &options, FunctionRegistry &functionRegistry, Logger &logger)
openvdb::v10_0::ax::codegen::codegen_internal::ComputeGenerator::traverse
bool traverse(const ast::Block *block)
Custom traversal of scoped blocks.
Definition ComputeGenerator.h:111
openvdb::v10_0::ax::codegen::codegen_internal::ComputeGenerator::visit
virtual bool visit(const ast::CommaOperator *)
Visitor methods for all AST nodes which implement IR generation.
openvdb::v10_0::ax::codegen::codegen_internal::PointComputeGenerator::generate
AttributeRegistry::Ptr generate(const ast::Tree &node)
openvdb::v10_0::ax::codegen::codegen_internal::PointComputeGenerator::~PointComputeGenerator
~PointComputeGenerator() override=default
openvdb::v10_0::ax::codegen::codegen_internal::PointComputeGenerator::visit
bool visit(const ast::Attribute *) override
Visitor methods for all AST nodes which implement IR generation.
openvdb::v10_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:212