dax tutorial
DESCRIPTION
Dax Tutorial. Many-Core Code Sprint September 19, 2012. Dax: A Toolkit for Accelerated Visualization. The Dax Toolkit brings together parallel modules to supplement combinable visualization algorithms. Mapping on Fields. Topology Generation. Connectivity Reconstruction. Extracted cells - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/1.jpg)
Sandia National Laboratories is a multi-program laboratory managed and operated by Sandia Corporation, a wholly owned subsidiary of Lockheed Martin Corporation, for the U.S. Department of Energy’s National Nuclear Security Administration under contract DE-AC04-94AL85000. SAND NO. 2012-7796P
Dax TutorialMany-Core Code Sprint
September 19, 2012
![Page 2: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/2.jpg)
Dax: A Toolkit for Accelerated Visualization
Mapping on Fields
Topology Generation
Connectivity Reconstruction
The Dax Toolkit brings together parallel modules to supplement combinable visualization algorithms.
Extracted cellsof large gradient and compacted points Simplical subdivision
with quadratic smoothing
Surface improvements through connection construction.
Contour with subsequent vertex welding, coarsening, subdivision, and curvature estimation
![Page 3: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/3.jpg)
GETTING STARTED
![Page 4: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/4.jpg)
Prerequisites
git CMake (2.8.8 or newer recommended) Boost 1.48.0 CUDA Toolkit 4+ (for CUDA backend) Thrust 1.4 or 1.5 (comes with CUDA)
![Page 5: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/5.jpg)
Getting Dax
Clone from one of the git repositories http://public.kitware.com/DaxToolkit.git https://github.com/Kitware/DaxToolkit.git
git clone http://public.kitware.com/DaxToolkit.git
![Page 6: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/6.jpg)
Configuring Dax
Create a build directory Run ccmake (or cmake-gui) pointing back to source directory
git clone http://public.kitware.com/DaxToolkit.gitmkdir daxBuildcd daxBuildccmake ../DaxToolkit
![Page 7: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/7.jpg)
Important Configuration Parameters
Variable DescriptionDAX_ENABLE_CUDA Turn this ON to enable CUDA backend. Requires
CUDA Toolkit and Thrust.DAX_ENABLE_OPENMP Turn this ON to enable OpenMP backend.
Requires Thrust and OpenMP compiler support (not Clang).
DAX_ENABLE_TESTING Turn on header, unit, and benchmark tests.
DAX_USE_64BIT_IDS Enable 64bit index support. Using this with CUDA backend generally requires a Tesla card.
DAX_USE_DOUBLE_PRECISION Enable using double as the representation type for dax::Scalar. Using this with CUDA backend generally requires a Tesla card.
CMAKE_BUILD_TYPE Debug, RelWithDebInfo, or Release
CMAKE_INSTALL_PREFIX Location to install headers
![Page 8: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/8.jpg)
Building Dax
(Technically optional but a good check for your system.) Run make (or use your favorite IDE) Run tests (“make test” or “ctest”) Parallel builds (-j flag) work, too.
git clone http://public.kitware.com/DaxToolkit.gitmkdir daxBuildcd daxBuildccmake ../DaxToolkitmakectest
![Page 9: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/9.jpg)
Installing Dax
(Optional but good if your project doesn’t use CMake) make install target
git clone http://public.kitware.com/DaxToolkit.gitmkdir daxBuildcd daxBuildccmake ../DaxToolkitmakectestmake install
![Page 10: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/10.jpg)
More Information
We know, documentation is sparse http://daxtoolkit.org
Click down to “Using Dax” Doxygen: http://daxtoolkit.org/Doc/classes.html
![Page 11: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/11.jpg)
BASIC COMMON SUPPORT TYPES AND FUNCTIONS
![Page 12: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/12.jpg)
Basic Types
#include <dax/Types.h> dax::Id
Integer/index type dax::Scalar
Floating point Use of core C types (int, float, double, etc.) discouraged.
![Page 13: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/13.jpg)
Basic Tuples
#include <dax/Types.h> dax::Id3, dax::Vector2, dax::Vector3, dax::Vector4
Operator [] overloaded for component access Operators +, -, *, / overloaded for component-wise arithmetic make_Id3(), make_Vector2(), make_Vector3(), etc. dax::dot() Generic dax::Tuple<type,size>
![Page 14: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/14.jpg)
Vector Traits
#include<dax/VectorTraits.h> template<class VectorType> struct VectorTraits
NUM_COMPONENTS GetComponent() SetComponent()
![Page 15: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/15.jpg)
Basic Math
#include <dax/math/Compare.h> dax::math::Min(x,y), dax::math::Max(x,y)
#include <dax/math/Precision.h> dax::math::Nan(), dax::math::Infinity(), dax::math::NegativeInfinity(), dax::math::Epsilon()
dax::math::IsNan() dax::math::IsInf(), dax::math::IsFinite() dax::math::FMod(), dax::math::Remainder(), dax::math::RemainderQuotient(), dax::math::ModF()
dax::math::Ceil(), dax::math::Floor(), dax::math::Round()
#include <dax/math/Sign.h> dax::math::Abs(), dax::math::IsNegative(), dax::math::CopySign()
![Page 16: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/16.jpg)
Basic Math
#include <dax/math/Exp.h> dax::math::Pow() , dax::math::Sqrt(), dax::math::RSqrt() , dax::math::Cbrt(), dax::math::RCbrt()
dax::math::Exp(), dax::math::Exp2(), dax::math::ExpM1(), dax::math::Exp10()
dax::math::Log(), dax::math::Log2(), dax::math::Log10(), dax::math::Log1P()
#include <dax/math/Trig.h> dax::math::Pi() dax::math::Sin(), dax::math::Cos(), dax::math::Tan() dax::math::ASin(), dax::math::ACos(), dax::math::ATan() , dax::math::ATan2()
dax::math::SinH(), dax::math::CosH(), dax::math::TanH() , dax::math::ASinH(), dax::math::ACosH(), dax::math::ATanH()
![Page 17: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/17.jpg)
Basic Vector Operations
#include <dax/math/VectorAnalysis.h> dax::math::MagnitudeSquared(), dax::math::Magnitude(), dax::math::RMagnitude()
dax::math::Normal(), dax::math::Normalize() dax::math::Cross() dax::math::TriangleNormal()
![Page 18: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/18.jpg)
Basic Small Matrix Operations
#include <dax::math::Matrix.h> class dax::math::Matrix<Type, numRow, numCol>
Access components by matrix(row,col) or matrix[row][col] Specialty types dax::math::Matrix2x2, dax::math::Matrix3x3, dax::math::Matrix4x4
dax::math::MatrixRow(matrix, rowIndex), dax::math::MatrixColumn(matrix, colIndex)
dax::math::MatrixSetRow(matrix,rowIndex,rowValues), dax::math::MatrixSetColumn(matrix,colIndex,colValues)
dax::math::MatrixMultiply(leftFactor, rightFactor) dax::math::MatrixIdentity() dax::math::MatrixTranspose() dax::math::MatrixInverse() dax::math::MatrixDeterminant()
![Page 19: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/19.jpg)
Other Linear and Numeric Algorithms
#include <dax/math/Matrix.h> dax::math::SolveLinearSystem()
#include <dax/math/Numerical.h> dax::math::NewtonsMethod()
![Page 20: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/20.jpg)
SYSTEM OVERVIEW
![Page 21: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/21.jpg)
Execution Environment
Control Environment
Dax Framework
dax::cont dax::exec
![Page 22: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/22.jpg)
Execution Environment
Control Environment
Grid TopologyArray HandleInvoke
Dax Framework
dax::cont dax::exec
![Page 23: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/23.jpg)
Execution Environment
Cell OperationsField Operations
Basic MathMake Cells
Control Environment
Grid TopologyArray HandleInvoke W
orkletDax Framework
dax::cont dax::exec
![Page 24: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/24.jpg)
Execution Environment
Cell OperationsField Operations
Basic MathMake Cells
Control Environment
Grid TopologyArray HandleInvoke W
orkletDax Framework
dax::cont dax::exec
![Page 25: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/25.jpg)
Execution Environment
Cell OperationsField Operations
Basic MathMake Cells
Control Environment
Grid TopologyArray HandleInvoke
Device Adapter
AllocateTransferSchedule
Sort…
Worklet
Dax Framework
dax::cont dax::exec
![Page 26: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/26.jpg)
Export Macros
DAX_CONT_EXPORT Functions/methods for control environment. Think __host__ in CUDA.
DAX_EXEC_EXPORT Functions/methods for execution environment. Think __device__ in CUDA.
DAX_EXEC_CONT_EXPORT Either environment.
![Page 27: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/27.jpg)
CREATING WORKLETS IN THE EXECUTION ENVIRONMENT
![Page 28: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/28.jpg)
Creating Worklets
Worklets are functors with extra syntax sugar.
struct Dot{
dax::Scalar operator()(const dax::Vector3& coord) const {
return dax::dot(coord,coord);}
};
![Page 29: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/29.jpg)
Worklets Base Classes
All Worklets must derive from a dax worklet class. WorkletMapField WorkletMapCell WorkletGenerateTopology
struct Dot : dax::exec::WorkletMapField
WorkletMapField Operate on arbitrary fields. Has no geometric information
WorkletMapCell Operate with access to the cell’s topology and point fields.
WorkletGenerateTopology Operate on input cell’s to create new cell topology
![Page 30: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/30.jpg)
Creating Worklets
struct Dot : dax::exec::WorkletMapField{
dax::Scalar operator()(const dax::Vector3& coord) const {
dax::Scalar dot = dax::dot(coord,coord);}
};
![Page 31: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/31.jpg)
Worklet Control Signature
Control signature defines how we interpret the control parameter Consider it to define the interface that must be met Currently two interface types: Field and Topology
Field converts to a single value passed to the worklet Array Constant value Function ( Under Development )
Topology converts to a single cell passed to the worklet Unstructured Uniform
![Page 32: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/32.jpg)
Worklet Control Signature
Control Signature have modifiers that combined with worklet type determine how we access the argument
Field Context Execution RepresentationIn Read only value
Out Writable value
Point (In,Out) Tuple containing the point values for a field.
Cell (In,Out) Same as In or Out for WorkletMapCell.
Topology Context Execution RepresentationCell (In,Out) Read / Write Cell. Only able to modify cell point ids.
![Page 33: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/33.jpg)
Creating Worklets
struct Dot : dax::exec::WorkletMapField{
typdef void ControlSignature(Field(In),Field(Out));
dax::Scalar operator()(const dax::Vector3& coord) const {
dax::Scalar dot = dax::dot(coord,coord);}
};
![Page 34: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/34.jpg)
Worklet Execution Signature
Execution signature maps control arguments to worklets arguments
typedef void ControlSignature(Field(In))
typedef void ExecutionSignature(_1)
void operator()(const dax::Vector3& v) const
![Page 35: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/35.jpg)
Worklet Execution Signature
Execution signature maps control arguments to worklets arguments
typedef void ControlSignature(Field(In))
typedef void ExecutionSignature(_1)
void operator()(const dax::Vector3& v) const
_1 = First Control Arg
![Page 36: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/36.jpg)
Worklet Execution Signature
Execution signature maps control arguments to worklets arguments
typedef void ControlSignature(Field(In))
typedef void ExecutionSignature(_1)
void operator()(const dax::Vector3& v) const
_1 = First Control Arg
![Page 37: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/37.jpg)
Worklet Execution Signature
Execution Signature Options Effect_1, _2, _3 … _10 Reference argument _1 in control signature
WorkId Fill the argument with the current iteration index
Topology::PointIds( _N ) Convert a topology cell argument to cell’s point ids
Execution signature and Control signature can be different lengths Can use a control argument multiple times Can transform a control side argument
Neighbors Cell Point Ids
![Page 38: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/38.jpg)
Finished Worklet
struct Dot : dax::exec::WorkletMapField {
typedef void ControlSignature(Field(In),Field(Out))typedef _2 ExecutionSignature(_1)
dax::Scalar operator()(const dax::Vector3& coord) const {
dax::Scalar dot = dax::dot(coord,coord);}
};
![Page 39: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/39.jpg)
Execution Cell Types
Some worklets can receive a cell as a parameter Usually the cell type is templated, but can be specified directly
Cell classes defined in dax/exec/Cell*.h No shared superclass, but all implement at a minimum
Constants NUM_POINTS and TOPOLOGICAL_DIMENSIONS GetNumberOfPoints() GetPointIndex(vertexIndex) GetPointIndices()
Returns a Tuple defined by the typedef Cell::PointConnectionsType Currently supported cells: Vertex, Line, Triangle, Quadrilateral,
Voxel, Tetrahedron, Wedge, Hexahedron
![Page 40: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/40.jpg)
Cell Operations
#include <dax/exec/ParametricCoordintes.h> dax::exec::ParametricCoordinates<CellType>::Center() dax::exec::ParametricCoordinates<CellType>::Vertex() dax::exec::ParametricCoordinatesToWorldCoordinates() dax::exec::WorldCoordinatesToParametericCoordinates()
#include <dax/exec/Interpolate.h> dax::exec::CellInterpolate()
#include <dax/exec/Derivative.h> dax::exec::CellDerivative()
![Page 41: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/41.jpg)
Errors in the Execution Environment
All worklet classes have a RaiseError() method this->RaiseError("Precondition failed"); Will cause an exception with that message to be thrown in the control
environment from whence the worklet was invoked But, you cannot catch the error while still in the execution environment In fact, execution might not immediately stop
#include <dax/exec/Assert.h> DAX_ASSERT_EXEC(condition, worklet) Behaves like the POSIX assert except that it throws this error rather than
crashing the program to a halt DAX_ASSERT_EXEC(vertexIndex < 8, this)
![Page 42: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/42.jpg)
INVOKING ALGORITHMS ON DATA IN THE CONTROL ENVIRONMENT
![Page 43: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/43.jpg)
Catching Errors
Dax throws errors in anomalous conditions Thrown class always a subclass of dax::cont::Error If the error originated in control environment, then a subclass of
dax::cont::ErrorControl If the error came from a worklet in the execution environment, then it will be
dax::cont::ErrorExecution
try { ... }catch (dax::cont::Error error) { std::cout << "Dax encountered an error: " << error.GetMessage() << std::endl; }
![Page 44: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/44.jpg)
DeviceAdapter
The DeviceAdapter is an interface between control and execution environments. Adapts to different devices/compilers.
Easiest way to select is to define DAX_DEVICE_ADAPTER Use one of the following (before including any Dax header)
#define DAX_DEVICE_ADAPTER DAX_DEVICE_ADAPTER_SERIAL #define DAX_DEVICE_ADAPTER DAX_DEVICE_ADAPTER_OPENMP #define DAX_DEVICE_ADAPTER DAX_DEVICE_ADAPTER_CUDA
If you select none, a reasonable default will be selected for you There are other ways to select (and create) a DeviceAdapter
Won’t be talking about them today
![Page 45: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/45.jpg)
ArrayHandle
dax::cont::ArrayHandle<type> manages an “array” of data Acts like a reference-counted smart pointer to an array Manages transfer of data between control and execution Can allocate data for output
Relevant methods GetNumberOfValues() CopyInto() ReleaseResources(), ReleaseResourcesExecution()
Functions to create an ArrayHandle dax::cont::make_ArrayHandle(const T *array, dax::Id size)
dax::cont::make_ArrayHandle(const std::vector<T> vector)
Both of these do a shallow (reference) copy. Do not let the original array be deleted or vector to go out of scope!
![Page 46: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/46.jpg)
Other Important ArrayHandle Features We’re Skipping ArrayContainerControl template parameter
Selects array layout for zero-copy semantics Supports implicit arrays Yes, we have a container for vtkDataArray
Generic array interface through an ArrayPortal In principle like an STL iterator, but simpler
![Page 47: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/47.jpg)
UniformGrid
#include <dax/cont/UniformGrid.h> dax::cont::UniformGrid<> (template parameters default)
Get/SetExtent(), Get/SetOrigin(), Get/SetSpacing() GetNumberOfPoints(), GetNumberOfCells() ComputePointIndex(dax::Id3), ComputeCellIndex(dax::Id3)
ComputePointLocation(dax::Id) ComputeCellLocation(dax::Id) ComputePointCoordinates(dax::Id or dax::Id3) GetPointCoordinates()
![Page 48: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/48.jpg)
UnstructuredGrid
#include <dax/cont/UnstructuredGrid.h> dax::cont::UnstructuredGrid<CellType>
Get/SetCellConnections() Stored in ArrayHandle<dax::Id>, one entry per cell vertex
Get/SetPointCoordinates() Stored in ArrayHandle<dax::Vector3>, one entry per point Note that GetPointCoordinates() is match in UniformGrid
GetNumberOfPoints(), GetNumberOfCells()
![Page 49: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/49.jpg)
Invoking Worklets
#include <dax/cont/Schedule.h> dax::cont::Schedule< > (template parameters default)
void operator() (Worklet w, typename… Parameters) Number of parameters must match the worklet’s ControlSignature Determines execution length based on parameters length
![Page 50: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/50.jpg)
Other Important Scheduler Features
#include <dax/cont/ScheduleMapAdapter.h> dax::cont::make_MapAdapter(Keys k, Values v, dax::Id valuesLength) Wraps a parameter to allow many to one access Invisible mapping of workId through the Keys object when executing
#include <dax/cont/ScheduleGenerateTopology.h> Constructs new topology with ability to remove duplicate points Requires an array that represents the classification of each input cell Can also convert point fields Pass to the Schedule class as a worklet!
![Page 51: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/51.jpg)
PUTTING IT ALL TOGETHER
![Page 52: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/52.jpg)
The Functor
struct Normal {
template<typename T>dax::Scalar operator()(const T& coord) const
{dax::Scalar dot = dax::dot(coord,coord);return coord * dax::math::RSqrt(dot);
} };
![Page 53: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/53.jpg)
The Worklet struct Normal: dax::exec::WorkletMapField {
typedef void ControlSignature(Field(In),Field(Out));typedef _2 ExecutionSignature(_1);
template<typename T>T operator()(const T& coord) const
{dax::Scalar dot = dax::dot(coord,coord);return coord * dax::math::RSqrt(dot);
} };
![Page 54: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/54.jpg)
The Control Code int main()
{ using namespace dax::cont;
std::vector<dax::Vector3> coords(10); for(int i=0; i < 10; i++) { const dax::Scalar x(1.0f + i); coords[i] = dax::Vector3(dax::math::Sin(x)/i+1, 1/(x*x), 0); } //make a dax array handle to the coordinates ArrayHandle<dax::Vector3> coordHandle = make_ArrayHandle(coords);
//make a dax array handle to store the results ArrayHandle<dax::Vector3> normals;
Schedule< > scheduler;//note two parameters passed to scheduler like the control signature requests scheduler(Normal(), coordHandle, normals);
std::vector<dax::Vector3> results(normals.GetNumberOfValues()); normals.CopyInto (results.begin());
}
![Page 55: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/55.jpg)
OTHER INFORMATION
![Page 56: Dax Tutorial](https://reader035.vdocuments.us/reader035/viewer/2022081417/56816439550346895dd600b7/html5/thumbnails/56.jpg)
Dax VTK Module
https://github.com/robertmaynard/DaxVTKModule Currently exposes Dax threshold as a VTK Filter Uses VTK memory without copying to and from execution