Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Robert Maynard
VTK-m
Commits
2b490a12
Commit
2b490a12
authored
Oct 03, 2019
by
Robert Maynard
Browse files
Provide convenience macros to make Worklet markup easier for new users
parent
5b403f9d
Pipeline
#147709
failed with stage
in 0 seconds
Changes
65
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
docs/changelog/provide-macros-to-make-worklet-signature-easier.md
0 → 100644
View file @
2b490a12
VTK-m now provides three convenience macros to make worklet writing easier
`VTKM_INVOKE_SIG`
is a convenience macro that replaces the
`Control`
and
`Execution`
Signature typedefs for a VTK-m worklet. This assumes the worklet
has no return value, and each
`ControlSignature`
argument is passed to the
worklet in the same order. It is used like:
```
cxx
struct DotProduct : public vtkm::worklet::WorkletMapField
{
VTKM_INVOKE_SIG(FieldIn, FieldIn, FieldOut);
template <typename T, vtkm::IdComponent Size>
VTKM_EXEC void operator()(const vtkm::Vec<T, Size>& v1,
const vtkm::Vec<T, Size>& v2,
T& outValue) const
{
outValue = vtkm::Dot(v1, v2);
}
};
```
VTKM_CONT_INVOKE_SIG is a convenience macro that replaces the
`Control`
Signature typedef for a VTK-m worklet. It is used like:
```
cxx
VTKM_CONT_INVOKE_SIG(FieldIn, FieldOut);
```
Instead of the user having to write:
```
using ControlSignature = void(FieldIn, FieldOut);
```
VTKM_EXEC_INVOKE_SIG is a convenience macro that replaces the
`Execution`
Signature typedef for a VTK-m worklet that has a
`void`
return type. It is used like:
```
cxx
VTKM_EXEC_INVOKE_SIG(_1, _2, WorkId);
```
Instead of the user having to write:
```
using ExecutionSignature = void(_1, _2, WorkId);
```
examples/hello_worklet/HelloWorklet.cxx
View file @
2b490a12
...
...
@@ -28,9 +28,7 @@ namespace worklet
struct
HelloWorklet
:
public
vtkm
::
worklet
::
WorkletMapField
{
using
ControlSignature
=
void
(
FieldIn
inVector
,
FieldOut
outMagnitude
);
using
ExecutionSignature
=
void
(
_1
,
_2
);
VTKM_INVOKE_SIG
(
FieldIn
inVector
,
FieldOut
outMagnitude
);
VTKM_EXEC
void
operator
()(
const
vtkm
::
Vec3f
&
inVector
,
vtkm
::
FloatDefault
&
outMagnitude
)
const
{
outMagnitude
=
vtkm
::
Magnitude
(
inVector
);
...
...
examples/multi_backend/IOGenerator.cxx
View file @
2b490a12
...
...
@@ -24,8 +24,7 @@
struct
WaveField
:
public
vtkm
::
worklet
::
WorkletMapField
{
using
ControlSignature
=
void
(
FieldIn
,
FieldOut
);
using
ExecutionSignature
=
void
(
_1
,
_2
);
VTKM_INVOKE_SIG
(
FieldIn
,
FieldOut
);
template
<
typename
T
>
VTKM_EXEC
void
operator
()(
const
vtkm
::
Vec
<
T
,
3
>&
input
,
vtkm
::
Vec
<
T
,
3
>&
output
)
const
...
...
vtkm/cont/CellSetExtrude.hxx
View file @
2b490a12
...
...
@@ -14,8 +14,7 @@ namespace
{
struct
ComputeReverseMapping
:
public
vtkm
::
worklet
::
WorkletMapField
{
using
ControlSignature
=
void
(
FieldIn
cellIndex
,
WholeArrayOut
cellIds
);
using
ExecutionSignature
=
void
(
_1
,
_2
);
VTKM_INVOKE_SIG
(
FieldIn
cellIndex
,
WholeArrayOut
cellIds
);
VTKM_SUPPRESS_EXEC_WARNINGS
template
<
typename
PortalType
>
...
...
@@ -31,8 +30,8 @@ struct ComputeReverseMapping : public vtkm::worklet::WorkletMapField
struct
ComputePrevNode
:
public
vtkm
::
worklet
::
WorkletMapField
{
typedef
void
ControlSignature
(
FieldIn
nextNode
,
WholeArrayOut
prevNodeArray
);
typedef
void
ExecutionSignature
(
InputIndex
,
_1
,
_2
);
VTKM_CONT_INVOKE_SIG
(
FieldIn
nextNode
,
WholeArrayOut
prevNodeArray
);
VTKM_EXEC_INVOKE_SIG
(
InputIndex
,
_1
,
_2
);
template
<
typename
PortalType
>
VTKM_EXEC
void
operator
()(
vtkm
::
Id
idx
,
vtkm
::
Int32
next
,
PortalType
&
prevs
)
const
...
...
vtkm/cont/CellSetPermutation.h
View file @
2b490a12
...
...
@@ -47,8 +47,8 @@ class RConnTableHelpers
public:
struct
WriteNumIndices
:
public
vtkm
::
worklet
::
WorkletVisitCellsWithPoints
{
using
ControlSignature
=
void
(
CellSetIn
cellset
,
FieldOutCell
numIndices
);
using
ExecutionSignature
=
void
(
PointCount
,
_2
);
VTKM_CONT_INVOKE_SIG
(
CellSetIn
cellset
,
FieldOutCell
numIndices
);
VTKM_EXEC_INVOKE_SIG
(
PointCount
,
_2
);
using
InputDomain
=
_1
;
VTKM_EXEC
void
operator
()(
vtkm
::
IdComponent
pointCount
,
vtkm
::
IdComponent
&
numIndices
)
const
...
...
@@ -59,8 +59,8 @@ public:
struct
WriteConnectivity
:
public
vtkm
::
worklet
::
WorkletVisitCellsWithPoints
{
using
ControlSignature
=
void
(
CellSetIn
cellset
,
FieldOutCell
connectivity
);
using
ExecutionSignature
=
void
(
PointCount
,
PointIndices
,
_2
);
VTKM_CONT_INVOKE_SIG
(
CellSetIn
cellset
,
FieldOutCell
connectivity
);
VTKM_EXEC_INVOKE_SIG
(
PointCount
,
PointIndices
,
_2
);
using
InputDomain
=
_1
;
template
<
typename
PointIndicesType
,
typename
OutConnectivityType
>
...
...
vtkm/cont/PointLocatorUniformGrid.cxx
View file @
2b490a12
...
...
@@ -30,9 +30,8 @@ namespace internal
class
BinPointsWorklet
:
public
vtkm
::
worklet
::
WorkletMapField
{
public:
using
ControlSignature
=
void
(
FieldIn
coord
,
FieldOut
label
);
using
ExecutionSignature
=
void
(
_1
,
_2
);
VTKM_CONT_INVOKE_SIG
(
FieldIn
coord
,
FieldOut
label
);
VTKM_EXEC_INVOKE_SIG
(
_1
,
_2
);
VTKM_CONT
BinPointsWorklet
(
vtkm
::
Vec3f
min
,
vtkm
::
Vec3f
max
,
vtkm
::
Id3
dims
)
...
...
vtkm/filter/GhostCellClassify.hxx
View file @
2b490a12
...
...
@@ -32,8 +32,8 @@ public:
{
}
using
ControlSignature
=
void
(
CellSetIn
,
FieldOut
);
using
ExecutionSignature
=
void
(
Boundary
,
_2
);
VTKM_CONT_INVOKE_SIG
(
CellSetIn
,
FieldOut
);
VTKM_EXEC_INVOKE_SIG
(
Boundary
,
_2
);
VTKM_EXEC
void
operator
()(
const
vtkm
::
exec
::
BoundaryState
&
boundary
,
vtkm
::
UInt8
&
value
)
const
{
...
...
@@ -53,8 +53,8 @@ public:
{
}
using
ControlSignature
=
void
(
CellSetIn
,
FieldOut
);
using
ExecutionSignature
=
void
(
Boundary
,
_2
);
VTKM_CONT_INVOKE_SIG
(
CellSetIn
,
FieldOut
);
VTKM_EXEC_INVOKE_SIG
(
Boundary
,
_2
);
VTKM_EXEC
void
operator
()(
const
vtkm
::
exec
::
BoundaryState
&
boundary
,
vtkm
::
UInt8
&
value
)
const
{
...
...
@@ -75,8 +75,8 @@ public:
{
}
using
ControlSignature
=
void
(
CellSetIn
,
FieldOut
);
using
ExecutionSignature
=
void
(
Boundary
,
_2
);
VTKM_CONT_INVOKE_SIG
(
CellSetIn
,
FieldOut
);
VTKM_EXEC_INVOKE_SIG
(
Boundary
,
_2
);
VTKM_EXEC
void
operator
()(
const
vtkm
::
exec
::
BoundaryState
&
boundary
,
vtkm
::
UInt8
&
value
)
const
{
...
...
vtkm/filter/Lagrangian.hxx
View file @
2b490a12
...
...
@@ -38,9 +38,7 @@ namespace
class
ValidityCheck
:
public
vtkm
::
worklet
::
WorkletMapField
{
public:
using
ControlSignature
=
void
(
FieldIn
end_point
,
FieldIn
steps
,
FieldInOut
output
);
using
ExecutionSignature
=
void
(
_1
,
_2
,
_3
);
using
InputDomain
=
_1
;
VTKM_INVOKE_SIG
(
FieldIn
end_point
,
FieldIn
steps
,
FieldInOut
output
);
ValidityCheck
(
vtkm
::
Bounds
b
)
:
bounds
(
b
)
...
...
vtkm/source/Tangle.cxx
View file @
2b490a12
...
...
@@ -20,9 +20,8 @@ namespace tangle
class
TangleField
:
public
vtkm
::
worklet
::
WorkletVisitPointsWithCells
{
public:
using
ControlSignature
=
void
(
CellSetIn
,
FieldOut
v
);
using
ExecutionSignature
=
void
(
ThreadIndices
,
_2
);
using
InputDomain
=
_1
;
VTKM_CONT_INVOKE_SIG
(
CellSetIn
,
FieldOut
v
);
VTKM_EXEC_INVOKE_SIG
(
ThreadIndices
,
_2
);
const
vtkm
::
Vec3f
CellDimsf
;
const
vtkm
::
Vec3f
Mins
;
...
...
vtkm/source/Wavelet.cxx
View file @
2b490a12
...
...
@@ -28,9 +28,8 @@ namespace wavelet
struct
WaveletField
:
public
vtkm
::
worklet
::
WorkletVisitPointsWithCells
{
using
ControlSignature
=
void
(
CellSetIn
,
FieldOut
v
);
using
ExecutionSignature
=
void
(
ThreadIndices
,
_2
);
using
InputDomain
=
_1
;
VTKM_CONT_INVOKE_SIG
(
CellSetIn
,
FieldOut
v
);
VTKM_EXEC_INVOKE_SIG
(
ThreadIndices
,
_2
);
using
Vec3F
=
vtkm
::
Vec3f
;
...
...
vtkm/thirdparty/taotuple/vtkmtaotuple/include/Tuple.h
View file @
2b490a12
...
...
@@ -43,11 +43,13 @@ namespace vtkmstd
using
simple_tuple
::
get
;
using
simple_tuple
::
make_tuple
;
using
simple_tuple
::
tuple
;
using
simple_tuple
::
tuple_element
;
using
simple_tuple
::
tuple_size
;
#else
using
tao
::
get
;
using
tao
::
make_tuple
;
using
tao
::
tuple
;
using
tao
::
tuple_element
;
using
tao
::
tuple_size
;
#endif
...
...
vtkm/worklet/AverageByKey.h
View file @
2b490a12
...
...
@@ -104,8 +104,8 @@ struct AverageByKey
struct
DivideWorklet
:
public
vtkm
::
worklet
::
WorkletMapField
{
using
ControlSignature
=
void
(
FieldIn
,
FieldIn
,
FieldOut
);
using
ExecutionSignature
=
void
(
_1
,
_2
,
_3
);
VTKM_CONT_INVOKE_SIG
(
FieldIn
,
FieldIn
,
FieldOut
);
VTKM_EXEC_INVOKE_SIG
(
_1
,
_2
,
_3
);
template
<
class
ValueType
>
VTKM_EXEC
void
operator
()(
const
ValueType
&
v
,
const
vtkm
::
Id
&
count
,
ValueType
&
vout
)
const
...
...
vtkm/worklet/CellAverage.h
View file @
2b490a12
...
...
@@ -24,8 +24,8 @@ namespace worklet
class
CellAverage
:
public
vtkm
::
worklet
::
WorkletVisitCellsWithPoints
{
public:
using
ControlSignature
=
void
(
CellSetIn
cellset
,
FieldInPoint
inPoints
,
FieldOutCell
outCells
);
using
ExecutionSignature
=
void
(
PointCount
,
_2
,
_3
);
VTKM_CONT_INVOKE_SIG
(
CellSetIn
cellset
,
FieldInPoint
inPoints
,
FieldOutCell
outCells
);
VTKM_EXEC_INVOKE_SIG
(
PointCount
,
_2
,
_3
);
using
InputDomain
=
_1
;
template
<
typename
PointValueVecType
,
typename
OutType
>
...
...
vtkm/worklet/CellDeepCopy.h
View file @
2b490a12
...
...
@@ -39,8 +39,8 @@ struct CellDeepCopy
struct
PassCellStructure
:
vtkm
::
worklet
::
WorkletVisitCellsWithPoints
{
using
ControlSignature
=
void
(
CellSetIn
inputTopology
,
FieldOut
shapes
,
FieldOut
pointIndices
);
using
ExecutionSignature
=
void
(
CellShape
,
PointIndices
,
_2
,
_3
);
VTKM_CONT_INVOKE_SIG
(
CellSetIn
inputTopology
,
FieldOut
shapes
,
FieldOut
pointIndices
);
VTKM_EXEC_INVOKE_SIG
(
CellShape
,
PointIndices
,
_2
,
_3
);
template
<
typename
CellShape
,
typename
InPointIndexType
,
typename
OutPointIndexType
>
VTKM_EXEC
void
operator
()(
const
CellShape
&
inShape
,
...
...
vtkm/worklet/CellMeasure.h
View file @
2b490a12
...
...
@@ -63,11 +63,8 @@ template <typename IntegrationTypeList>
class
CellMeasure
:
public
vtkm
::
worklet
::
WorkletVisitCellsWithPoints
{
public:
using
ControlSignature
=
void
(
CellSetIn
cellset
,
FieldInPoint
pointCoords
,
FieldOutCell
volumesOut
);
using
ExecutionSignature
=
void
(
CellShape
,
PointCount
,
_2
,
_3
);
using
InputDomain
=
_1
;
VTKM_CONT_INVOKE_SIG
(
CellSetIn
cellset
,
FieldInPoint
pointCoords
,
FieldOutCell
volumesOut
);
VTKM_EXEC_INVOKE_SIG
(
CellShape
,
PointCount
,
_2
,
_3
);
template
<
typename
CellShape
,
typename
PointCoordVecType
,
typename
OutType
>
VTKM_EXEC
void
operator
()(
CellShape
shape
,
...
...
vtkm/worklet/CrossProduct.h
View file @
2b490a12
...
...
@@ -22,8 +22,7 @@ namespace worklet
class
CrossProduct
:
public
vtkm
::
worklet
::
WorkletMapField
{
public:
using
ControlSignature
=
void
(
FieldIn
,
FieldIn
,
FieldOut
);
using
ExecutionSignature
=
void
(
_1
,
_2
,
_3
);
VTKM_INVOKE_SIG
(
FieldIn
,
FieldIn
,
FieldOut
);
template
<
typename
T
>
VTKM_EXEC
void
operator
()(
const
vtkm
::
Vec
<
T
,
3
>&
vec1
,
...
...
vtkm/worklet/DotProduct.h
View file @
2b490a12
...
...
@@ -22,8 +22,7 @@ namespace worklet
class
DotProduct
:
public
vtkm
::
worklet
::
WorkletMapField
{
public:
using
ControlSignature
=
void
(
FieldIn
,
FieldIn
,
FieldOut
);
using
ExecutionSignature
=
void
(
_1
,
_2
,
_3
);
VTKM_INVOKE_SIG
(
FieldIn
,
FieldIn
,
FieldOut
);
template
<
typename
T
,
vtkm
::
IdComponent
Size
>
VTKM_EXEC
void
operator
()(
const
vtkm
::
Vec
<
T
,
Size
>&
v1
,
...
...
vtkm/worklet/FieldEntropy.h
View file @
2b490a12
...
...
@@ -34,8 +34,7 @@ public:
class
SetBinInformationContent
:
public
vtkm
::
worklet
::
WorkletMapField
{
public:
using
ControlSignature
=
void
(
FieldIn
freq
,
FieldOut
informationContent
);
using
ExecutionSignature
=
void
(
_1
,
_2
);
VTKM_INVOKE_SIG
(
FieldIn
freq
,
FieldOut
informationContent
);
vtkm
::
Float64
FreqSum
;
...
...
vtkm/worklet/FieldHistogram.h
View file @
2b490a12
...
...
@@ -58,9 +58,7 @@ public:
class
SetHistogramBin
:
public
vtkm
::
worklet
::
WorkletMapField
{
public:
using
ControlSignature
=
void
(
FieldIn
value
,
FieldOut
binIndex
);
using
ExecutionSignature
=
void
(
_1
,
_2
);
using
InputDomain
=
_1
;
VTKM_INVOKE_SIG
(
FieldIn
value
,
FieldOut
binIndex
);
vtkm
::
Id
numberOfBins
;
FieldType
minValue
;
...
...
@@ -89,9 +87,7 @@ public:
class
AdjacentDifference
:
public
vtkm
::
worklet
::
WorkletMapField
{
public:
using
ControlSignature
=
void
(
FieldIn
inputIndex
,
WholeArrayIn
counts
,
FieldOut
outputCount
);
using
ExecutionSignature
=
void
(
_1
,
_2
,
_3
);
using
InputDomain
=
_1
;
VTKM_INVOKE_SIG
(
FieldIn
inputIndex
,
WholeArrayIn
counts
,
FieldOut
outputCount
);
template
<
typename
WholeArrayType
>
VTKM_EXEC
void
operator
()(
const
vtkm
::
Id
&
index
,
...
...
vtkm/worklet/FieldStatistics.h
View file @
2b490a12
...
...
@@ -57,13 +57,12 @@ public:
class
CalculatePowers
:
public
vtkm
::
worklet
::
WorkletMapField
{
public:
using
ControlSignature
=
void
(
FieldIn
value
,
FieldOut
pow1Array
,
FieldOut
pow2Array
,
FieldOut
pow3Array
,
FieldOut
pow4Array
);
using
ExecutionSignature
=
void
(
_1
,
_2
,
_3
,
_4
,
_5
);
using
InputDomain
=
_1
;
VTKM_CONT_INVOKE_SIG
(
FieldIn
value
,
FieldOut
pow1Array
,
FieldOut
pow2Array
,
FieldOut
pow3Array
,
FieldOut
pow4Array
);
VTKM_EXEC_INVOKE_SIG
(
_1
,
_2
,
_3
,
_4
,
_5
);
vtkm
::
Id
numPowers
;
...
...
Prev
1
2
3
4
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment