mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Fixing unit test
This commit is contained in:
commit
22ca8bce15
@ -3,14 +3,11 @@
|
|||||||
# Compares the output from BenchmarkDeviceAdapter from the serial
|
# Compares the output from BenchmarkDeviceAdapter from the serial
|
||||||
# device to a parallel device and prints a table containing the results.
|
# device to a parallel device and prints a table containing the results.
|
||||||
#
|
#
|
||||||
# While this was written for the device adapter algorithms, it could be used
|
|
||||||
# to compare any VTKM benchmark output.
|
|
||||||
#
|
|
||||||
# Example usage:
|
# Example usage:
|
||||||
#
|
#
|
||||||
# $ BenchmarkDeviceAdapter_SERIAL > serial.out
|
# $ BenchmarkDeviceAdapter_SERIAL > serial.out
|
||||||
# $ BenchmarkDeviceAdapter_TBB > tbb.out
|
# $ BenchmarkDeviceAdapter_TBB > tbb.out
|
||||||
# $ devAlgoBenchSummary.py serial.out tbb.out
|
# $ benchCompare.py serial.out tbb.out
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# The number of threads (optional -- only used to generate the "Warn" column)
|
# The number of threads (optional -- only used to generate the "Warn" column)
|
111
Utilities/Scripts/benchSummary.py
Executable file
111
Utilities/Scripts/benchSummary.py
Executable file
@ -0,0 +1,111 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Prints a concise summary of a benchmark output as a TSV blob.
|
||||||
|
#
|
||||||
|
# Example usage:
|
||||||
|
#
|
||||||
|
# $ BenchmarkXXX_DEVICE > bench.out
|
||||||
|
# $ benchSummary.py bench.out
|
||||||
|
#
|
||||||
|
# Options SortByType, SortByName, or SortByMean may be passed after the
|
||||||
|
# filename to sort the output by the indicated quantity. If no sort option
|
||||||
|
# is provided, the output order matches the input. If multiple options are
|
||||||
|
# specified, the list will be sorted repeatedly in the order requested.
|
||||||
|
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
assert(len(sys.argv) >= 2)
|
||||||
|
|
||||||
|
# Parses "*** vtkm::Float64 ***************" --> vtkm::Float64
|
||||||
|
typeParser = re.compile("\\*{3} ([^*]+) \\*{15}")
|
||||||
|
|
||||||
|
# Parses "Benchmark 'Benchmark name' results:" --> Benchmark name
|
||||||
|
nameParser = re.compile("Benchmark '([^-]+)' results:")
|
||||||
|
|
||||||
|
# Parses "mean = 0.0125s" --> 0.0125
|
||||||
|
meanParser = re.compile("\\s+mean = ([0-9.Ee+-]+)s")
|
||||||
|
|
||||||
|
# Parses "std dev = 0.0125s" --> 0.0125
|
||||||
|
stdDevParser = re.compile("\\s+std dev = ([naN0-9.Ee+-]+)s")
|
||||||
|
|
||||||
|
filename = sys.argv[1]
|
||||||
|
benchFile = open(filename, 'r')
|
||||||
|
|
||||||
|
sortOpt = None
|
||||||
|
if len(sys.argv) > 2:
|
||||||
|
sortOpt = sys.argv[2:]
|
||||||
|
|
||||||
|
class BenchKey:
|
||||||
|
def __init__(self, name_, type_):
|
||||||
|
self.name = name_
|
||||||
|
self.type = type_
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return self.name == other.name and self.type == other.type
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
if self.name < other.name: return True
|
||||||
|
elif self.name > other.name: return False
|
||||||
|
else: return self.type < other.type
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return (self.name + self.type).__hash__()
|
||||||
|
|
||||||
|
class BenchData:
|
||||||
|
def __init__(self, mean_, stdDev_):
|
||||||
|
self.mean = mean_
|
||||||
|
self.stdDev = stdDev_
|
||||||
|
|
||||||
|
def parseFile(f, benchmarks):
|
||||||
|
type = ""
|
||||||
|
bench = ""
|
||||||
|
mean = -1.
|
||||||
|
stdDev = -1.
|
||||||
|
for line in f:
|
||||||
|
typeRes = typeParser.match(line)
|
||||||
|
if typeRes:
|
||||||
|
type = typeRes.group(1)
|
||||||
|
continue
|
||||||
|
|
||||||
|
nameRes = nameParser.match(line)
|
||||||
|
if nameRes:
|
||||||
|
name = nameRes.group(1)
|
||||||
|
continue
|
||||||
|
|
||||||
|
meanRes = meanParser.match(line)
|
||||||
|
if meanRes:
|
||||||
|
mean = float(meanRes.group(1))
|
||||||
|
continue
|
||||||
|
|
||||||
|
stdDevRes = stdDevParser.match(line)
|
||||||
|
if stdDevRes:
|
||||||
|
stdDev = float(stdDevRes.group(1))
|
||||||
|
|
||||||
|
# stdDev is always the last parse for a given benchmark, add entry now
|
||||||
|
benchmarks[BenchKey(name, type)] = BenchData(mean, stdDev)
|
||||||
|
|
||||||
|
mean = -1.
|
||||||
|
stdDev = -1.
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
|
benchmarks = {}
|
||||||
|
parseFile(benchFile, benchmarks)
|
||||||
|
|
||||||
|
# Sort keys by type:
|
||||||
|
keys = benchmarks.keys()
|
||||||
|
if sortOpt:
|
||||||
|
for opt in sortOpt:
|
||||||
|
if opt.lower() == "sortbytype":
|
||||||
|
keys = sorted(keys, key=lambda k: k.type)
|
||||||
|
elif opt.lower() == "sortbyname":
|
||||||
|
keys = sorted(keys, key=lambda k: k.name)
|
||||||
|
elif opt.lower() == "sortbymean":
|
||||||
|
keys = sorted(keys, key=lambda k: benchmarks[k].mean)
|
||||||
|
|
||||||
|
print("# Summary: (%s)"%filename)
|
||||||
|
print("%-9s\t%-9s\t%-s"%("Mean", "Stdev", "Benchmark (type)"))
|
||||||
|
for key in keys:
|
||||||
|
data = benchmarks[key]
|
||||||
|
print("%9.6f\t%9.6f\t%s (%s)"%(data.mean, data.stdDev, key.name, key.type))
|
156
Utilities/Scripts/benchSummaryWithBaselines.py
Executable file
156
Utilities/Scripts/benchSummaryWithBaselines.py
Executable file
@ -0,0 +1,156 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Prints a concise summary of a benchmark output as a TSV blob. Benchmarks are
|
||||||
|
# expected to have "Baseline" in the name, and a matching benchmark with the
|
||||||
|
# same name but Baseline replaced with something else. For example,
|
||||||
|
#
|
||||||
|
# Baseline benchmark name: "Some benchmark: Baseline, Size=4"
|
||||||
|
# Test benchmark name: "Some benchmark: Blahblah, Size=4"
|
||||||
|
#
|
||||||
|
# The output will print the baseline, test, and overhead times for the
|
||||||
|
# benchmarks.
|
||||||
|
#
|
||||||
|
# Example usage:
|
||||||
|
#
|
||||||
|
# $ BenchmarkXXX_DEVICE > bench.out
|
||||||
|
# $ benchSummaryWithBaselines.py bench.out
|
||||||
|
#
|
||||||
|
# Options SortByType, SortByName, SortByOverhead, or SortByRatio
|
||||||
|
# (testtime/baseline) may be passed after the filename to sort the output by
|
||||||
|
# the indicated quantity. If no sort option is provided, the output order
|
||||||
|
# matches the input. If multiple options are specified, the list will be sorted
|
||||||
|
# repeatedly in the order requested.
|
||||||
|
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
assert(len(sys.argv) >= 2)
|
||||||
|
|
||||||
|
# Parses "*** vtkm::Float64 ***************" --> vtkm::Float64
|
||||||
|
typeParser = re.compile("\\*{3} ([^*]+) \\*{15}")
|
||||||
|
|
||||||
|
# Parses "Benchmark 'Benchmark name' results:" --> Benchmark name
|
||||||
|
nameParser = re.compile("Benchmark '([^-]+)' results:")
|
||||||
|
|
||||||
|
# Parses "mean = 0.0125s" --> 0.0125
|
||||||
|
meanParser = re.compile("\\s+mean = ([0-9.Ee+-]+)s")
|
||||||
|
|
||||||
|
# Parses "std dev = 0.0125s" --> 0.0125
|
||||||
|
stdDevParser = re.compile("\\s+std dev = ([naN0-9.Ee+-]+)s")
|
||||||
|
|
||||||
|
# Parses "SomeText Baseline Other Text" --> ("SomeText ", " Other Text")
|
||||||
|
baselineParser = re.compile("(.*)Baseline(.*)")
|
||||||
|
|
||||||
|
filename = sys.argv[1]
|
||||||
|
benchFile = open(filename, 'r')
|
||||||
|
|
||||||
|
sortOpt = None
|
||||||
|
if len(sys.argv) > 2:
|
||||||
|
sortOpt = sys.argv[2:]
|
||||||
|
|
||||||
|
class BenchKey:
|
||||||
|
def __init__(self, name_, type_):
|
||||||
|
self.name = name_
|
||||||
|
self.type = type_
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return self.name == other.name and self.type == other.type
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
if self.name < other.name: return True
|
||||||
|
elif self.name > other.name: return False
|
||||||
|
else: return self.type < other.type
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return (self.name + self.type).__hash__()
|
||||||
|
|
||||||
|
class BenchData:
|
||||||
|
def __init__(self, mean_, stdDev_):
|
||||||
|
self.mean = mean_
|
||||||
|
self.stdDev = stdDev_
|
||||||
|
|
||||||
|
def parseFile(f, benchmarks):
|
||||||
|
type = ""
|
||||||
|
bench = ""
|
||||||
|
mean = -1.
|
||||||
|
stdDev = -1.
|
||||||
|
for line in f:
|
||||||
|
typeRes = typeParser.match(line)
|
||||||
|
if typeRes:
|
||||||
|
type = typeRes.group(1)
|
||||||
|
continue
|
||||||
|
|
||||||
|
nameRes = nameParser.match(line)
|
||||||
|
if nameRes:
|
||||||
|
name = nameRes.group(1)
|
||||||
|
continue
|
||||||
|
|
||||||
|
meanRes = meanParser.match(line)
|
||||||
|
if meanRes:
|
||||||
|
mean = float(meanRes.group(1))
|
||||||
|
continue
|
||||||
|
|
||||||
|
stdDevRes = stdDevParser.match(line)
|
||||||
|
if stdDevRes:
|
||||||
|
stdDev = float(stdDevRes.group(1))
|
||||||
|
|
||||||
|
# stdDev is always the last parse for a given benchmark, add entry now
|
||||||
|
benchmarks[BenchKey(name, type)] = BenchData(mean, stdDev)
|
||||||
|
|
||||||
|
mean = -1.
|
||||||
|
stdDev = -1.
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
|
class BaselinedBenchData:
|
||||||
|
def __init__(self, baseline, test):
|
||||||
|
self.baseline = baseline.mean
|
||||||
|
self.test = test.mean
|
||||||
|
self.overhead = test.mean - baseline.mean
|
||||||
|
|
||||||
|
def findBaselines(benchmarks):
|
||||||
|
result = {}
|
||||||
|
|
||||||
|
for baseKey in benchmarks.keys():
|
||||||
|
# Look for baseline entries
|
||||||
|
baselineRes = baselineParser.match(baseKey.name)
|
||||||
|
if baselineRes:
|
||||||
|
prefix = baselineRes.group(1)
|
||||||
|
suffix = baselineRes.group(2)
|
||||||
|
|
||||||
|
# Find the test entry matching the baseline:
|
||||||
|
for testKey in benchmarks.keys():
|
||||||
|
if baseKey.type != testKey.type: # Need same type
|
||||||
|
continue
|
||||||
|
if baseKey.name == testKey.name: # Skip the base key
|
||||||
|
continue
|
||||||
|
if testKey.name.startswith(prefix) and testKey.name.endswith(suffix):
|
||||||
|
newName = (prefix + suffix).replace(", ,", ",")
|
||||||
|
newKey = BenchKey(newName, testKey.type)
|
||||||
|
newVal = BaselinedBenchData(benchmarks[baseKey], benchmarks[testKey])
|
||||||
|
result[newKey] = newVal
|
||||||
|
return result
|
||||||
|
|
||||||
|
benchmarks = {}
|
||||||
|
parseFile(benchFile, benchmarks)
|
||||||
|
benchmarks = findBaselines(benchmarks)
|
||||||
|
|
||||||
|
# Sort keys by type:
|
||||||
|
keys = benchmarks.keys()
|
||||||
|
if sortOpt:
|
||||||
|
for opt in sortOpt:
|
||||||
|
if opt.lower() == "sortbytype":
|
||||||
|
keys = sorted(keys, key=lambda k: k.type)
|
||||||
|
elif opt.lower() == "sortbyname":
|
||||||
|
keys = sorted(keys, key=lambda k: k.name)
|
||||||
|
elif opt.lower() == "sortbyoverhead":
|
||||||
|
keys = sorted(keys, key=lambda k: benchmarks[k].overhead)
|
||||||
|
elif opt.lower() == "sortbyratio":
|
||||||
|
keys = sorted(keys, key=lambda k: benchmarks[k].overhead / benchmarks[k].baseline)
|
||||||
|
|
||||||
|
print("# Summary: (%s)"%filename)
|
||||||
|
print("%-9s\t%-9s\t%-9s\t%-9s\t%-s"%("Baseline", "TestTime", "Overhead", "Test/Base", "Benchmark (type)"))
|
||||||
|
for key in keys:
|
||||||
|
data = benchmarks[key]
|
||||||
|
print("%9.6f\t%9.6f\t%9.6f\t%9.6f\t%s (%s)"%(data.baseline, data.test,
|
||||||
|
data.overhead, data.test / data.baseline, key.name, key.type))
|
581
benchmarking/BenchmarkAtomicArray.cxx
Normal file
581
benchmarking/BenchmarkAtomicArray.cxx
Normal file
@ -0,0 +1,581 @@
|
|||||||
|
//============================================================================
|
||||||
|
// Copyright (c) Kitware, Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
// See LICENSE.txt for details.
|
||||||
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||||
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE. See the above copyright notice for more information.
|
||||||
|
//
|
||||||
|
// Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
||||||
|
// Copyright 2018 UT-Battelle, LLC.
|
||||||
|
// Copyright 2018 Los Alamos National Security.
|
||||||
|
//
|
||||||
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||||
|
// the U.S. Government retains certain rights in this software.
|
||||||
|
//
|
||||||
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||||
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||||
|
// this software.
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#include "Benchmarker.h"
|
||||||
|
|
||||||
|
#include <vtkm/cont/ArrayHandle.h>
|
||||||
|
#include <vtkm/cont/AtomicArray.h>
|
||||||
|
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||||
|
#include <vtkm/cont/Timer.h>
|
||||||
|
|
||||||
|
#include <vtkm/exec/FunctorBase.h>
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace benchmarking
|
||||||
|
{
|
||||||
|
|
||||||
|
// This is 32x larger than the largest array size.
|
||||||
|
static constexpr vtkm::Id NumWrites = 33554432; // 2^25
|
||||||
|
|
||||||
|
#define MAKE_ATOMIC_BENCHMARKS(Name, Class) \
|
||||||
|
VTKM_MAKE_BENCHMARK(Name##1, Class, 1); \
|
||||||
|
VTKM_MAKE_BENCHMARK(Name##8, Class, 8); \
|
||||||
|
VTKM_MAKE_BENCHMARK(Name##32, Class, 32); \
|
||||||
|
VTKM_MAKE_BENCHMARK(Name##512, Class, 512); \
|
||||||
|
VTKM_MAKE_BENCHMARK(Name##2048, Class, 2048); \
|
||||||
|
VTKM_MAKE_BENCHMARK(Name##32768, Class, 32768); \
|
||||||
|
VTKM_MAKE_BENCHMARK(Name##1048576, Class, 1048576)
|
||||||
|
|
||||||
|
#define RUN_ATOMIC_BENCHMARKS(Name) \
|
||||||
|
VTKM_RUN_BENCHMARK(Name##1, vtkm::cont::AtomicArrayTypeListTag{}); \
|
||||||
|
VTKM_RUN_BENCHMARK(Name##8, vtkm::cont::AtomicArrayTypeListTag{}); \
|
||||||
|
VTKM_RUN_BENCHMARK(Name##32, vtkm::cont::AtomicArrayTypeListTag{}); \
|
||||||
|
VTKM_RUN_BENCHMARK(Name##512, vtkm::cont::AtomicArrayTypeListTag{}); \
|
||||||
|
VTKM_RUN_BENCHMARK(Name##2048, vtkm::cont::AtomicArrayTypeListTag{}); \
|
||||||
|
VTKM_RUN_BENCHMARK(Name##32768, vtkm::cont::AtomicArrayTypeListTag{}); \
|
||||||
|
VTKM_RUN_BENCHMARK(Name##1048576, vtkm::cont::AtomicArrayTypeListTag{})
|
||||||
|
|
||||||
|
template <class Device>
|
||||||
|
class BenchmarkAtomicArray
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Algo = vtkm::cont::DeviceAdapterAlgorithm<Device>;
|
||||||
|
using Timer = vtkm::cont::Timer<Device>;
|
||||||
|
|
||||||
|
// Benchmarks AtomicArray::Add such that each work index writes to adjacent
|
||||||
|
// indices.
|
||||||
|
template <typename ValueType>
|
||||||
|
struct BenchAddSeq
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> Data;
|
||||||
|
|
||||||
|
template <typename PortalType>
|
||||||
|
struct Worker : public vtkm::exec::FunctorBase
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
PortalType Portal;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
Worker(vtkm::Id arraySize, PortalType portal)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Portal(portal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_EXEC
|
||||||
|
void operator()(vtkm::Id i) const { this->Portal.Add(i % this->ArraySize, 1); }
|
||||||
|
};
|
||||||
|
|
||||||
|
BenchAddSeq(vtkm::Id arraySize)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
{
|
||||||
|
this->Data.PrepareForOutput(this->ArraySize, Device{});
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Float64 operator()()
|
||||||
|
{
|
||||||
|
vtkm::cont::AtomicArray<ValueType> array(this->Data);
|
||||||
|
auto portal = array.PrepareForExecution(Device{});
|
||||||
|
Worker<decltype(portal)> worker{ this->ArraySize, portal };
|
||||||
|
|
||||||
|
Timer timer;
|
||||||
|
Algo::Schedule(worker, NumWrites);
|
||||||
|
return timer.GetElapsedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
std::string Description() const
|
||||||
|
{
|
||||||
|
std::ostringstream desc;
|
||||||
|
desc << "Add (Seq, Atomic, " << std::setw(7) << std::setfill('0') << this->ArraySize << ")";
|
||||||
|
return desc.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MAKE_ATOMIC_BENCHMARKS(AddSeq, BenchAddSeq);
|
||||||
|
|
||||||
|
// Provides a non-atomic baseline for BenchAddSeq
|
||||||
|
template <typename ValueType>
|
||||||
|
struct BenchAddSeqBaseline
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> Data;
|
||||||
|
|
||||||
|
template <typename PortalType>
|
||||||
|
struct Worker : public vtkm::exec::FunctorBase
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
PortalType Portal;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
Worker(vtkm::Id arraySize, PortalType portal)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Portal(portal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_EXEC
|
||||||
|
void operator()(vtkm::Id i) const
|
||||||
|
{
|
||||||
|
vtkm::Id idx = i % this->ArraySize;
|
||||||
|
this->Portal.Set(idx, this->Portal.Get(idx) + 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BenchAddSeqBaseline(vtkm::Id arraySize)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Float64 operator()()
|
||||||
|
{
|
||||||
|
auto portal = this->Data.PrepareForOutput(this->ArraySize, Device{});
|
||||||
|
Worker<decltype(portal)> worker{ this->ArraySize, portal };
|
||||||
|
|
||||||
|
Timer timer;
|
||||||
|
Algo::Schedule(worker, NumWrites);
|
||||||
|
return timer.GetElapsedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
std::string Description() const
|
||||||
|
{
|
||||||
|
std::ostringstream desc;
|
||||||
|
desc << "Add (Seq, Baseline, " << std::setw(7) << std::setfill('0') << this->ArraySize << ")";
|
||||||
|
return desc.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MAKE_ATOMIC_BENCHMARKS(AddSeqBase, BenchAddSeqBaseline);
|
||||||
|
|
||||||
|
// Benchmarks AtomicArray::Add such that each work index writes to a strided
|
||||||
|
// index ( floor(i / stride) + stride * (i % stride)
|
||||||
|
template <typename ValueType>
|
||||||
|
struct BenchAddStride
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::Id Stride;
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> Data;
|
||||||
|
|
||||||
|
template <typename PortalType>
|
||||||
|
struct Worker : public vtkm::exec::FunctorBase
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::Id Stride;
|
||||||
|
PortalType Portal;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
Worker(vtkm::Id arraySize, vtkm::Id stride, PortalType portal)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Stride(stride)
|
||||||
|
, Portal(portal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_EXEC
|
||||||
|
void operator()(vtkm::Id i) const
|
||||||
|
{
|
||||||
|
vtkm::Id idx = (i / this->Stride + this->Stride * (i % this->Stride)) % this->ArraySize;
|
||||||
|
this->Portal.Add(idx % this->ArraySize, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BenchAddStride(vtkm::Id arraySize, vtkm::Id stride = 32)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Stride(stride)
|
||||||
|
{
|
||||||
|
this->Data.PrepareForOutput(this->ArraySize, Device{});
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Float64 operator()()
|
||||||
|
{
|
||||||
|
vtkm::cont::AtomicArray<ValueType> array(this->Data);
|
||||||
|
auto portal = array.PrepareForExecution(Device{});
|
||||||
|
Worker<decltype(portal)> worker{ this->ArraySize, this->Stride, portal };
|
||||||
|
|
||||||
|
Timer timer;
|
||||||
|
Algo::Schedule(worker, NumWrites);
|
||||||
|
return timer.GetElapsedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
std::string Description() const
|
||||||
|
{
|
||||||
|
std::ostringstream desc;
|
||||||
|
desc << "Add (Stride=" << this->Stride << ", Atomic, " << std::setw(7) << std::setfill('0')
|
||||||
|
<< this->ArraySize << ")";
|
||||||
|
return desc.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MAKE_ATOMIC_BENCHMARKS(AddStride, BenchAddStride);
|
||||||
|
|
||||||
|
// Non-atomic baseline for AddStride
|
||||||
|
template <typename ValueType>
|
||||||
|
struct BenchAddStrideBaseline
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::Id Stride;
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> Data;
|
||||||
|
|
||||||
|
template <typename PortalType>
|
||||||
|
struct Worker : public vtkm::exec::FunctorBase
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::Id Stride;
|
||||||
|
PortalType Portal;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
Worker(vtkm::Id arraySize, vtkm::Id stride, PortalType portal)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Stride(stride)
|
||||||
|
, Portal(portal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_EXEC
|
||||||
|
void operator()(vtkm::Id i) const
|
||||||
|
{
|
||||||
|
vtkm::Id idx = (i / this->Stride + this->Stride * (i % this->Stride)) % this->ArraySize;
|
||||||
|
this->Portal.Set(idx, this->Portal.Get(idx) + 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BenchAddStrideBaseline(vtkm::Id arraySize, vtkm::Id stride = 32)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Stride(stride)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Float64 operator()()
|
||||||
|
{
|
||||||
|
auto portal = this->Data.PrepareForOutput(this->ArraySize, Device{});
|
||||||
|
Worker<decltype(portal)> worker{ this->ArraySize, this->Stride, portal };
|
||||||
|
|
||||||
|
Timer timer;
|
||||||
|
Algo::Schedule(worker, NumWrites);
|
||||||
|
return timer.GetElapsedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
std::string Description() const
|
||||||
|
{
|
||||||
|
std::ostringstream desc;
|
||||||
|
desc << "Add (Stride=" << this->Stride << ", Baseline, " << std::setw(7) << std::setfill('0')
|
||||||
|
<< this->ArraySize << ")";
|
||||||
|
return desc.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MAKE_ATOMIC_BENCHMARKS(AddStrideBase, BenchAddStrideBaseline);
|
||||||
|
|
||||||
|
// Benchmarks AtomicArray::CompareAndSwap such that each work index writes to adjacent
|
||||||
|
// indices.
|
||||||
|
template <typename ValueType>
|
||||||
|
struct BenchCASSeq
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> Data;
|
||||||
|
|
||||||
|
template <typename PortalType>
|
||||||
|
struct Worker : public vtkm::exec::FunctorBase
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
PortalType Portal;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
Worker(vtkm::Id arraySize, PortalType portal)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Portal(portal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_EXEC
|
||||||
|
void operator()(vtkm::Id i) const
|
||||||
|
{
|
||||||
|
vtkm::Id idx = i % this->ArraySize;
|
||||||
|
ValueType val = static_cast<ValueType>(i);
|
||||||
|
// Get the old val with a no-op
|
||||||
|
ValueType oldVal = this->Portal.Add(idx, static_cast<ValueType>(0));
|
||||||
|
ValueType assumed = static_cast<ValueType>(0);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
assumed = oldVal;
|
||||||
|
oldVal = this->Portal.CompareAndSwap(idx, assumed + val, assumed);
|
||||||
|
} while (assumed != oldVal);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BenchCASSeq(vtkm::Id arraySize)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
{
|
||||||
|
this->Data.PrepareForOutput(this->ArraySize, Device{});
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Float64 operator()()
|
||||||
|
{
|
||||||
|
vtkm::cont::AtomicArray<ValueType> array(this->Data);
|
||||||
|
auto portal = array.PrepareForExecution(Device{});
|
||||||
|
Worker<decltype(portal)> worker{ this->ArraySize, portal };
|
||||||
|
|
||||||
|
Timer timer;
|
||||||
|
Algo::Schedule(worker, NumWrites);
|
||||||
|
return timer.GetElapsedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
std::string Description() const
|
||||||
|
{
|
||||||
|
std::ostringstream desc;
|
||||||
|
desc << "CAS (Seq, Atomic, " << std::setw(7) << std::setfill('0') << this->ArraySize << ")";
|
||||||
|
return desc.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MAKE_ATOMIC_BENCHMARKS(CASSeq, BenchCASSeq);
|
||||||
|
|
||||||
|
// Provides a non-atomic baseline for BenchCASSeq
|
||||||
|
template <typename ValueType>
|
||||||
|
struct BenchCASSeqBaseline
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> Data;
|
||||||
|
|
||||||
|
template <typename PortalType>
|
||||||
|
struct Worker : public vtkm::exec::FunctorBase
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
PortalType Portal;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
Worker(vtkm::Id arraySize, PortalType portal)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Portal(portal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_EXEC
|
||||||
|
void operator()(vtkm::Id i) const
|
||||||
|
{
|
||||||
|
vtkm::Id idx = i % this->ArraySize;
|
||||||
|
ValueType val = static_cast<ValueType>(i);
|
||||||
|
ValueType oldVal = this->Portal.Get(idx);
|
||||||
|
this->Portal.Set(idx, oldVal + val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BenchCASSeqBaseline(vtkm::Id arraySize)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Float64 operator()()
|
||||||
|
{
|
||||||
|
auto portal = this->Data.PrepareForOutput(this->ArraySize, Device{});
|
||||||
|
Worker<decltype(portal)> worker{ this->ArraySize, portal };
|
||||||
|
|
||||||
|
Timer timer;
|
||||||
|
Algo::Schedule(worker, NumWrites);
|
||||||
|
return timer.GetElapsedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
std::string Description() const
|
||||||
|
{
|
||||||
|
std::ostringstream desc;
|
||||||
|
desc << "CAS (Seq, Baseline, " << std::setw(7) << std::setfill('0') << this->ArraySize << ")";
|
||||||
|
return desc.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MAKE_ATOMIC_BENCHMARKS(CASSeqBase, BenchCASSeqBaseline);
|
||||||
|
|
||||||
|
// Benchmarks AtomicArray::CompareAndSwap such that each work index writes to
|
||||||
|
// a strided index:
|
||||||
|
// ( floor(i / stride) + stride * (i % stride)
|
||||||
|
template <typename ValueType>
|
||||||
|
struct BenchCASStride
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::Id Stride;
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> Data;
|
||||||
|
|
||||||
|
template <typename PortalType>
|
||||||
|
struct Worker : public vtkm::exec::FunctorBase
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::Id Stride;
|
||||||
|
PortalType Portal;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
Worker(vtkm::Id arraySize, vtkm::Id stride, PortalType portal)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Stride(stride)
|
||||||
|
, Portal(portal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_EXEC
|
||||||
|
void operator()(vtkm::Id i) const
|
||||||
|
{
|
||||||
|
vtkm::Id idx = (i / this->Stride + this->Stride * (i % this->Stride)) % this->ArraySize;
|
||||||
|
ValueType val = static_cast<ValueType>(i);
|
||||||
|
// Get the old val with a no-op
|
||||||
|
ValueType oldVal = this->Portal.Add(idx, static_cast<ValueType>(0));
|
||||||
|
ValueType assumed = static_cast<ValueType>(0);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
assumed = oldVal;
|
||||||
|
oldVal = this->Portal.CompareAndSwap(idx, assumed + val, assumed);
|
||||||
|
} while (assumed != oldVal);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BenchCASStride(vtkm::Id arraySize, vtkm::Id stride = 32)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Stride(stride)
|
||||||
|
{
|
||||||
|
this->Data.PrepareForOutput(this->ArraySize, Device{});
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Float64 operator()()
|
||||||
|
{
|
||||||
|
vtkm::cont::AtomicArray<ValueType> array(this->Data);
|
||||||
|
auto portal = array.PrepareForExecution(Device{});
|
||||||
|
Worker<decltype(portal)> worker{ this->ArraySize, this->Stride, portal };
|
||||||
|
|
||||||
|
Timer timer;
|
||||||
|
Algo::Schedule(worker, NumWrites);
|
||||||
|
return timer.GetElapsedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
std::string Description() const
|
||||||
|
{
|
||||||
|
std::ostringstream desc;
|
||||||
|
desc << "CAS (Stride=" << this->Stride << ", Atomic, " << std::setw(7) << std::setfill('0')
|
||||||
|
<< this->ArraySize << ")";
|
||||||
|
return desc.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MAKE_ATOMIC_BENCHMARKS(CASStride, BenchCASStride);
|
||||||
|
|
||||||
|
// Non-atomic baseline for CASStride
|
||||||
|
template <typename ValueType>
|
||||||
|
struct BenchCASStrideBaseline
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::Id Stride;
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> Data;
|
||||||
|
|
||||||
|
template <typename PortalType>
|
||||||
|
struct Worker : public vtkm::exec::FunctorBase
|
||||||
|
{
|
||||||
|
vtkm::Id ArraySize;
|
||||||
|
vtkm::Id Stride;
|
||||||
|
PortalType Portal;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
Worker(vtkm::Id arraySize, vtkm::Id stride, PortalType portal)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Stride(stride)
|
||||||
|
, Portal(portal)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_EXEC
|
||||||
|
void operator()(vtkm::Id i) const
|
||||||
|
{
|
||||||
|
vtkm::Id idx = (i / this->Stride + this->Stride * (i % this->Stride)) % this->ArraySize;
|
||||||
|
ValueType val = static_cast<ValueType>(i);
|
||||||
|
ValueType oldVal = this->Portal.Get(idx);
|
||||||
|
this->Portal.Set(idx, oldVal + val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BenchCASStrideBaseline(vtkm::Id arraySize, vtkm::Id stride = 32)
|
||||||
|
: ArraySize(arraySize)
|
||||||
|
, Stride(stride)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Float64 operator()()
|
||||||
|
{
|
||||||
|
auto portal = this->Data.PrepareForOutput(this->ArraySize, Device{});
|
||||||
|
Worker<decltype(portal)> worker{ this->ArraySize, this->Stride, portal };
|
||||||
|
|
||||||
|
Timer timer;
|
||||||
|
Algo::Schedule(worker, NumWrites);
|
||||||
|
return timer.GetElapsedTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
std::string Description() const
|
||||||
|
{
|
||||||
|
std::ostringstream desc;
|
||||||
|
desc << "CAS (Stride=" << this->Stride << ", Baseline, " << std::setw(7) << std::setfill('0')
|
||||||
|
<< this->ArraySize << ")";
|
||||||
|
return desc.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
MAKE_ATOMIC_BENCHMARKS(CASStrideBase, BenchCASStrideBaseline);
|
||||||
|
|
||||||
|
static void Run()
|
||||||
|
{
|
||||||
|
RUN_ATOMIC_BENCHMARKS(AddSeq);
|
||||||
|
RUN_ATOMIC_BENCHMARKS(AddSeqBase);
|
||||||
|
RUN_ATOMIC_BENCHMARKS(AddStride);
|
||||||
|
RUN_ATOMIC_BENCHMARKS(AddStrideBase);
|
||||||
|
|
||||||
|
RUN_ATOMIC_BENCHMARKS(CASSeq);
|
||||||
|
RUN_ATOMIC_BENCHMARKS(CASSeqBase);
|
||||||
|
RUN_ATOMIC_BENCHMARKS(CASStride);
|
||||||
|
RUN_ATOMIC_BENCHMARKS(CASStrideBase);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} // end namespace vtkm::benchmarking
|
||||||
|
|
||||||
|
int main(int, char* [])
|
||||||
|
{
|
||||||
|
using Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
|
||||||
|
auto tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker();
|
||||||
|
tracker.ForceDevice(Device{});
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
vtkm::benchmarking::BenchmarkAtomicArray<Device>::Run();
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << "Benchmark encountered an exception: " << e.what() << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -631,8 +631,9 @@ private:
|
|||||||
vtkm::cont::ArrayHandle<Value> result;
|
vtkm::cont::ArrayHandle<Value> result;
|
||||||
|
|
||||||
Timer timer;
|
Timer timer;
|
||||||
vtkm::worklet::DispatcherMapField<InterpolateField, DeviceAdapterTag>().Invoke(
|
vtkm::worklet::DispatcherMapField<InterpolateField> dispatcher;
|
||||||
this->EdgePairHandle, this->WeightHandle, this->FieldHandle, result);
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
|
dispatcher.Invoke(this->EdgePairHandle, this->WeightHandle, this->FieldHandle, result);
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,8 +664,9 @@ private:
|
|||||||
vtkm::cont::ArrayHandle<Value> result;
|
vtkm::cont::ArrayHandle<Value> result;
|
||||||
|
|
||||||
Timer timer;
|
Timer timer;
|
||||||
vtkm::worklet::DispatcherMapField<InterpolateField, DeviceAdapterTag>().Invoke(
|
vtkm::worklet::DispatcherMapField<InterpolateField> dispatcher;
|
||||||
dedges, dweight, dfield, result);
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
|
dispatcher.Invoke(dedges, dweight, dfield, result);
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,7 +721,7 @@ private:
|
|||||||
vtkm::Float64 operator()()
|
vtkm::Float64 operator()()
|
||||||
{
|
{
|
||||||
using EvalWorklet = EvaluateImplicitFunction<vtkm::Sphere>;
|
using EvalWorklet = EvaluateImplicitFunction<vtkm::Sphere>;
|
||||||
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet, DeviceAdapterTag>;
|
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet>;
|
||||||
|
|
||||||
auto handle = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
|
auto handle = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
|
||||||
auto function =
|
auto function =
|
||||||
@ -727,7 +729,9 @@ private:
|
|||||||
EvalWorklet eval(function);
|
EvalWorklet eval(function);
|
||||||
|
|
||||||
vtkm::cont::Timer<DeviceAdapterTag> timer;
|
vtkm::cont::Timer<DeviceAdapterTag> timer;
|
||||||
EvalDispatcher(eval).Invoke(this->Internal.Points, this->Internal.Result);
|
EvalDispatcher dispatcher(eval);
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
|
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -755,13 +759,15 @@ private:
|
|||||||
vtkm::Float64 operator()()
|
vtkm::Float64 operator()()
|
||||||
{
|
{
|
||||||
using EvalWorklet = EvaluateImplicitFunction<vtkm::ImplicitFunction>;
|
using EvalWorklet = EvaluateImplicitFunction<vtkm::ImplicitFunction>;
|
||||||
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet, DeviceAdapterTag>;
|
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet>;
|
||||||
|
|
||||||
auto sphere = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
|
auto sphere = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
|
||||||
EvalWorklet eval(sphere.PrepareForExecution(DeviceAdapterTag()));
|
EvalWorklet eval(sphere.PrepareForExecution(DeviceAdapterTag()));
|
||||||
|
|
||||||
vtkm::cont::Timer<DeviceAdapterTag> timer;
|
vtkm::cont::Timer<DeviceAdapterTag> timer;
|
||||||
EvalDispatcher(eval).Invoke(this->Internal.Points, this->Internal.Result);
|
EvalDispatcher dispatcher(eval);
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
|
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,7 +795,7 @@ private:
|
|||||||
vtkm::Float64 operator()()
|
vtkm::Float64 operator()()
|
||||||
{
|
{
|
||||||
using EvalWorklet = Evaluate2ImplicitFunctions<vtkm::Sphere, vtkm::Sphere>;
|
using EvalWorklet = Evaluate2ImplicitFunctions<vtkm::Sphere, vtkm::Sphere>;
|
||||||
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet, DeviceAdapterTag>;
|
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet>;
|
||||||
|
|
||||||
auto h1 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
|
auto h1 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
|
||||||
auto h2 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere2);
|
auto h2 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere2);
|
||||||
@ -798,7 +804,9 @@ private:
|
|||||||
EvalWorklet eval(f1, f2);
|
EvalWorklet eval(f1, f2);
|
||||||
|
|
||||||
vtkm::cont::Timer<DeviceAdapterTag> timer;
|
vtkm::cont::Timer<DeviceAdapterTag> timer;
|
||||||
EvalDispatcher(eval).Invoke(this->Internal.Points, this->Internal.Result);
|
EvalDispatcher dispatcher(eval);
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
|
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,7 +835,7 @@ private:
|
|||||||
{
|
{
|
||||||
using EvalWorklet =
|
using EvalWorklet =
|
||||||
Evaluate2ImplicitFunctions<vtkm::ImplicitFunction, vtkm::ImplicitFunction>;
|
Evaluate2ImplicitFunctions<vtkm::ImplicitFunction, vtkm::ImplicitFunction>;
|
||||||
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet, DeviceAdapterTag>;
|
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet>;
|
||||||
|
|
||||||
auto s1 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
|
auto s1 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
|
||||||
auto s2 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere2);
|
auto s2 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere2);
|
||||||
@ -835,7 +843,9 @@ private:
|
|||||||
s2.PrepareForExecution(DeviceAdapterTag()));
|
s2.PrepareForExecution(DeviceAdapterTag()));
|
||||||
|
|
||||||
vtkm::cont::Timer<DeviceAdapterTag> timer;
|
vtkm::cont::Timer<DeviceAdapterTag> timer;
|
||||||
EvalDispatcher(eval).Invoke(this->Internal.Points, this->Internal.Result);
|
EvalDispatcher dispatcher(eval);
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
|
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
|
||||||
return timer.GetElapsedTime();
|
return timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,7 +934,8 @@ void CreateFields(bool needPointScalars, bool needCellScalars, bool needPointVec
|
|||||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> pvecs;
|
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> pvecs;
|
||||||
|
|
||||||
PointVectorGenerator worklet(bounds);
|
PointVectorGenerator worklet(bounds);
|
||||||
vtkm::worklet::DispatcherMapField<PointVectorGenerator, Device> dispatch(worklet);
|
vtkm::worklet::DispatcherMapField<PointVectorGenerator> dispatch(worklet);
|
||||||
|
dispatch.SetDevice(Device());
|
||||||
dispatch.Invoke(points, pvecs);
|
dispatch.Invoke(points, pvecs);
|
||||||
InputDataSet.AddField(
|
InputDataSet.AddField(
|
||||||
vtkm::cont::Field("GeneratedPointVectors", vtkm::cont::Field::Association::POINTS, pvecs));
|
vtkm::cont::Field("GeneratedPointVectors", vtkm::cont::Field::Association::POINTS, pvecs));
|
||||||
|
@ -60,6 +60,7 @@ endfunction()
|
|||||||
|
|
||||||
set(benchmarks
|
set(benchmarks
|
||||||
BenchmarkArrayTransfer
|
BenchmarkArrayTransfer
|
||||||
|
BenchmarkAtomicArray
|
||||||
BenchmarkCopySpeeds
|
BenchmarkCopySpeeds
|
||||||
BenchmarkDeviceAdapter
|
BenchmarkDeviceAdapter
|
||||||
BenchmarkFieldAlgorithms
|
BenchmarkFieldAlgorithms
|
||||||
|
26
docs/changelog/agorithms_support_runtime_device.md
Normal file
26
docs/changelog/agorithms_support_runtime_device.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# vtkm::cont::Algorithm now can be told which device to use at runtime
|
||||||
|
|
||||||
|
The `vtkm::cont::Algorithm` has been extended to support the user specifying
|
||||||
|
which device to use at runtime previously Algorithm would only use the first
|
||||||
|
enabled device, requiring users to modify the `vtkm::cont::GlobalRuntimeDeviceTracker`
|
||||||
|
if they wanted a specific device used.
|
||||||
|
|
||||||
|
To select a specific device with vtkm::cont::Algorithm pass the `vtkm::cont::DeviceAdapterId`
|
||||||
|
as the first parameter.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
vtkm::cont::ArrayHandle<double> values;
|
||||||
|
|
||||||
|
|
||||||
|
//call with no tag, will run on first enabled device
|
||||||
|
auto result = vtkm::cont::Algorithm::Reduce(values, 0.0);
|
||||||
|
|
||||||
|
//call with an explicit device tag, will only run on serial
|
||||||
|
vtkm::cont::DeviceAdapterTagSerial serial;
|
||||||
|
result = vtkm::cont::Algorithm::Reduce(serial, values, 0.0);
|
||||||
|
|
||||||
|
//call with an runtime device tag, will only run on serial
|
||||||
|
vtkm::cont::DeviceAdapterId device = serial;
|
||||||
|
result = vtkm::cont::Algorithm::Reduce(device, values, 0.0);
|
||||||
|
|
||||||
|
```
|
23
docs/changelog/array-handle-view.md
Normal file
23
docs/changelog/array-handle-view.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Add `ArrayHandleView` fancy array
|
||||||
|
|
||||||
|
Added a new class named `ArrayHandleView` that allows you to get a subset
|
||||||
|
of an array. You use the `ArrayHandleView` by giving it a target array, a
|
||||||
|
starting index, and a length. Here is a simple example of usage:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Id> sourceArray;
|
||||||
|
|
||||||
|
vtkm::cont::ArrayCopy(vtkm::cont::ArrayHandleIndex(10), sourceArray);
|
||||||
|
// sourceArray has [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
|
|
||||||
|
vtkm::cont::ArrayHandleView<vtkm::cont::ArrayHandle<vtkm::Id>>
|
||||||
|
viewArray(sourceArray, 3, 5);
|
||||||
|
// viewArray has [3, 4, 5, 6, 7]
|
||||||
|
```
|
||||||
|
|
||||||
|
There is also a convenience `make_ArraHandleView` function to create view
|
||||||
|
arrays. The following makes the same view array as before.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
auto viewArray = vtkm::cont::make_ArrayHandleView(sourceArray, 3, 5);
|
||||||
|
```
|
15
docs/changelog/dispatcher-auto-device.md
Normal file
15
docs/changelog/dispatcher-auto-device.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Make DispatcherBase invoke using a TryExecute
|
||||||
|
|
||||||
|
Rather than force all dispatchers to be templated on a device adapter,
|
||||||
|
instead use a TryExecute internally within the invoke to select a device
|
||||||
|
adapter.
|
||||||
|
|
||||||
|
Because this removes the need to declare a device when invoking a worklet,
|
||||||
|
this commit also removes the need to declare a device in several other
|
||||||
|
areas of the code.
|
||||||
|
|
||||||
|
This changes touches quite a bit a code. The first pass of the change
|
||||||
|
usually does the minimum amount of work, which is to change the
|
||||||
|
compile-time specification of the device to a run-time call to `SetDevice`
|
||||||
|
on the dispatcher. Although functionally equivalent, it might mean calling
|
||||||
|
`TryExecute` within itself.
|
@ -139,7 +139,7 @@ public:
|
|||||||
this->PrintedDeviceMsg = true;
|
this->PrintedDeviceMsg = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
using DispatcherType = vtkm::worklet::DispatcherPointNeighborhood<UpdateLifeState, Device>;
|
using DispatcherType = vtkm::worklet::DispatcherPointNeighborhood<UpdateLifeState>;
|
||||||
|
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::UInt8> state;
|
vtkm::cont::ArrayHandle<vtkm::UInt8> state;
|
||||||
@ -153,7 +153,9 @@ public:
|
|||||||
input.GetField("state", vtkm::cont::Field::Association::POINTS).GetData().CopyTo(prevstate);
|
input.GetField("state", vtkm::cont::Field::Association::POINTS).GetData().CopyTo(prevstate);
|
||||||
|
|
||||||
//Update the game state
|
//Update the game state
|
||||||
DispatcherType().Invoke(vtkm::filter::ApplyPolicy(cells, policy), prevstate, state, colors);
|
DispatcherType dispatcher;
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cells, policy), prevstate, state, colors);
|
||||||
|
|
||||||
//save the results
|
//save the results
|
||||||
vtkm::cont::DataSet output;
|
vtkm::cont::DataSet output;
|
||||||
|
@ -53,7 +53,7 @@ vtkm::cont::DataSet make_test3DImageData(vtkm::Id3 dims)
|
|||||||
vtkm::cont::DataSet ds = Builder::Create(dims);
|
vtkm::cont::DataSet ds = Builder::Create(dims);
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> field;
|
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> field;
|
||||||
vtkm::worklet::DispatcherMapField<WaveField, vtkm::cont::DeviceAdapterTagSerial> dispatcher;
|
vtkm::worklet::DispatcherMapField<WaveField> dispatcher;
|
||||||
dispatcher.Invoke(ds.GetCoordinateSystem(), field);
|
dispatcher.Invoke(ds.GetCoordinateSystem(), field);
|
||||||
|
|
||||||
FieldAdd::AddPointField(ds, "vec_field", field);
|
FieldAdd::AddPointField(ds, "vec_field", field);
|
||||||
|
@ -317,30 +317,71 @@ struct UpperBoundsFunctor
|
|||||||
struct Algorithm
|
struct Algorithm
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template <typename T, typename U, class CIn, class COut>
|
||||||
|
VTKM_CONT static void Copy(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
vtkm::cont::ArrayHandle<U, COut>& output)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::CopyFunctor(), input, output);
|
||||||
|
}
|
||||||
template <typename T, typename U, class CIn, class COut>
|
template <typename T, typename U, class CIn, class COut>
|
||||||
VTKM_CONT static void Copy(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static void Copy(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
vtkm::cont::ArrayHandle<U, COut>& output)
|
vtkm::cont::ArrayHandle<U, COut>& output)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::CopyFunctor(), input, output);
|
Copy(vtkm::cont::DeviceAdapterTagAny(), input, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename U, class CIn, class CStencil, class COut>
|
||||||
|
VTKM_CONT static void CopyIf(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
const vtkm::cont::ArrayHandle<U, CStencil>& stencil,
|
||||||
|
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::CopyIfFunctor(), input, stencil, output);
|
||||||
|
}
|
||||||
template <typename T, typename U, class CIn, class CStencil, class COut>
|
template <typename T, typename U, class CIn, class CStencil, class COut>
|
||||||
VTKM_CONT static void CopyIf(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static void CopyIf(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
const vtkm::cont::ArrayHandle<U, CStencil>& stencil,
|
const vtkm::cont::ArrayHandle<U, CStencil>& stencil,
|
||||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::CopyIfFunctor(), input, stencil, output);
|
CopyIf(vtkm::cont::DeviceAdapterTagAny(), input, stencil, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename U, class CIn, class CStencil, class COut, class UnaryPredicate>
|
||||||
|
VTKM_CONT static void CopyIf(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
const vtkm::cont::ArrayHandle<U, CStencil>& stencil,
|
||||||
|
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||||
|
UnaryPredicate unary_predicate)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(
|
||||||
|
devId, detail::CopyIfFunctor(), input, stencil, output, unary_predicate);
|
||||||
|
}
|
||||||
template <typename T, typename U, class CIn, class CStencil, class COut, class UnaryPredicate>
|
template <typename T, typename U, class CIn, class CStencil, class COut, class UnaryPredicate>
|
||||||
VTKM_CONT static void CopyIf(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static void CopyIf(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
const vtkm::cont::ArrayHandle<U, CStencil>& stencil,
|
const vtkm::cont::ArrayHandle<U, CStencil>& stencil,
|
||||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||||
UnaryPredicate unary_predicate)
|
UnaryPredicate unary_predicate)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::CopyIfFunctor(), input, stencil, output, unary_predicate);
|
CopyIf(vtkm::cont::DeviceAdapterTagAny(), input, stencil, output, unary_predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename U, class CIn, class COut>
|
||||||
|
VTKM_CONT static bool CopySubRange(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
vtkm::Id inputStartIndex,
|
||||||
|
vtkm::Id numberOfElementsToCopy,
|
||||||
|
vtkm::cont::ArrayHandle<U, COut>& output,
|
||||||
|
vtkm::Id outputIndex = 0)
|
||||||
|
{
|
||||||
|
detail::CopySubRangeFunctor functor;
|
||||||
|
vtkm::cont::TryExecuteOnDevice(
|
||||||
|
devId, functor, input, inputStartIndex, numberOfElementsToCopy, output, outputIndex);
|
||||||
|
return functor.valid;
|
||||||
|
}
|
||||||
template <typename T, typename U, class CIn, class COut>
|
template <typename T, typename U, class CIn, class COut>
|
||||||
VTKM_CONT static bool CopySubRange(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static bool CopySubRange(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
vtkm::Id inputStartIndex,
|
vtkm::Id inputStartIndex,
|
||||||
@ -348,54 +389,124 @@ struct Algorithm
|
|||||||
vtkm::cont::ArrayHandle<U, COut>& output,
|
vtkm::cont::ArrayHandle<U, COut>& output,
|
||||||
vtkm::Id outputIndex = 0)
|
vtkm::Id outputIndex = 0)
|
||||||
{
|
{
|
||||||
detail::CopySubRangeFunctor functor;
|
return CopySubRange(vtkm::cont::DeviceAdapterTagAny(),
|
||||||
vtkm::cont::TryExecute(
|
input,
|
||||||
functor, input, inputStartIndex, numberOfElementsToCopy, output, outputIndex);
|
inputStartIndex,
|
||||||
return functor.valid;
|
numberOfElementsToCopy,
|
||||||
|
output,
|
||||||
|
outputIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class CIn, class CVal, class COut>
|
||||||
|
VTKM_CONT static void LowerBounds(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::LowerBoundsFunctor(), input, values, output);
|
||||||
|
}
|
||||||
template <typename T, class CIn, class CVal, class COut>
|
template <typename T, class CIn, class CVal, class COut>
|
||||||
VTKM_CONT static void LowerBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static void LowerBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output)
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::LowerBoundsFunctor(), input, values, output);
|
LowerBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
|
||||||
|
VTKM_CONT static void LowerBounds(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output,
|
||||||
|
BinaryCompare binary_compare)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(
|
||||||
|
devId, detail::LowerBoundsFunctor(), input, values, output, binary_compare);
|
||||||
|
}
|
||||||
template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
|
template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
|
||||||
VTKM_CONT static void LowerBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static void LowerBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output,
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output,
|
||||||
BinaryCompare binary_compare)
|
BinaryCompare binary_compare)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::LowerBoundsFunctor(), input, values, output, binary_compare);
|
LowerBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output, binary_compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class CIn, class COut>
|
||||||
|
VTKM_CONT static void LowerBounds(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<vtkm::Id, CIn>& input,
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& values_output)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::LowerBoundsFunctor(), input, values_output);
|
||||||
|
}
|
||||||
template <class CIn, class COut>
|
template <class CIn, class COut>
|
||||||
VTKM_CONT static void LowerBounds(const vtkm::cont::ArrayHandle<vtkm::Id, CIn>& input,
|
VTKM_CONT static void LowerBounds(const vtkm::cont::ArrayHandle<vtkm::Id, CIn>& input,
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& values_output)
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& values_output)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::LowerBoundsFunctor(), input, values_output);
|
LowerBounds(vtkm::cont::DeviceAdapterTagAny(), input, values_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename U, class CIn>
|
||||||
|
VTKM_CONT static U Reduce(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
U initialValue)
|
||||||
|
{
|
||||||
|
detail::ReduceFunctor<U> functor;
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, functor, input, initialValue);
|
||||||
|
return functor.result;
|
||||||
|
}
|
||||||
template <typename T, typename U, class CIn>
|
template <typename T, typename U, class CIn>
|
||||||
VTKM_CONT static U Reduce(const vtkm::cont::ArrayHandle<T, CIn>& input, U initialValue)
|
VTKM_CONT static U Reduce(const vtkm::cont::ArrayHandle<T, CIn>& input, U initialValue)
|
||||||
{
|
{
|
||||||
detail::ReduceFunctor<U> functor;
|
return Reduce(vtkm::cont::DeviceAdapterTagAny(), input, initialValue);
|
||||||
vtkm::cont::TryExecute(functor, input, initialValue);
|
|
||||||
return functor.result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename U, class CIn, class BinaryFunctor>
|
||||||
|
VTKM_CONT static U Reduce(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
U initialValue,
|
||||||
|
BinaryFunctor binary_functor)
|
||||||
|
{
|
||||||
|
detail::ReduceFunctor<U> functor;
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, functor, input, initialValue, binary_functor);
|
||||||
|
return functor.result;
|
||||||
|
}
|
||||||
template <typename T, typename U, class CIn, class BinaryFunctor>
|
template <typename T, typename U, class CIn, class BinaryFunctor>
|
||||||
VTKM_CONT static U Reduce(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static U Reduce(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
U initialValue,
|
U initialValue,
|
||||||
BinaryFunctor binary_functor)
|
BinaryFunctor binary_functor)
|
||||||
{
|
{
|
||||||
detail::ReduceFunctor<U> functor;
|
return Reduce(vtkm::cont::DeviceAdapterTagAny(), input, initialValue, binary_functor);
|
||||||
vtkm::cont::TryExecute(functor, input, initialValue, binary_functor);
|
|
||||||
return functor.result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T,
|
||||||
|
typename U,
|
||||||
|
class CKeyIn,
|
||||||
|
class CValIn,
|
||||||
|
class CKeyOut,
|
||||||
|
class CValOut,
|
||||||
|
class BinaryFunctor>
|
||||||
|
VTKM_CONT static void ReduceByKey(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CKeyIn>& keys,
|
||||||
|
const vtkm::cont::ArrayHandle<U, CValIn>& values,
|
||||||
|
vtkm::cont::ArrayHandle<T, CKeyOut>& keys_output,
|
||||||
|
vtkm::cont::ArrayHandle<U, CValOut>& values_output,
|
||||||
|
BinaryFunctor binary_functor)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId,
|
||||||
|
detail::ReduceByKeyFunctor(),
|
||||||
|
keys,
|
||||||
|
values,
|
||||||
|
keys_output,
|
||||||
|
values_output,
|
||||||
|
binary_functor);
|
||||||
|
}
|
||||||
template <typename T,
|
template <typename T,
|
||||||
typename U,
|
typename U,
|
||||||
class CKeyIn,
|
class CKeyIn,
|
||||||
@ -409,39 +520,81 @@ struct Algorithm
|
|||||||
vtkm::cont::ArrayHandle<U, CValOut>& values_output,
|
vtkm::cont::ArrayHandle<U, CValOut>& values_output,
|
||||||
BinaryFunctor binary_functor)
|
BinaryFunctor binary_functor)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(
|
ReduceByKey(
|
||||||
detail::ReduceByKeyFunctor(), keys, values, keys_output, values_output, binary_functor);
|
vtkm::cont::DeviceAdapterTagAny(), keys, values, keys_output, values_output, binary_functor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class CIn, class COut>
|
||||||
|
VTKM_CONT static T ScanInclusive(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||||
|
{
|
||||||
|
detail::ScanInclusiveResultFunctor<T> functor;
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, functor, input, output);
|
||||||
|
return functor.result;
|
||||||
|
}
|
||||||
template <typename T, class CIn, class COut>
|
template <typename T, class CIn, class COut>
|
||||||
VTKM_CONT static T ScanInclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static T ScanInclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||||
{
|
{
|
||||||
detail::ScanInclusiveResultFunctor<T> functor;
|
return ScanInclusive(vtkm::cont::DeviceAdapterTagAny(), input, output);
|
||||||
vtkm::cont::TryExecute(functor, input, output);
|
|
||||||
return functor.result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class CIn, class COut>
|
||||||
|
VTKM_CONT static T StreamingScanExclusive(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::Id numBlocks,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||||
|
{
|
||||||
|
detail::StreamingScanExclusiveFunctor<T> functor;
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, functor, numBlocks, input, output);
|
||||||
|
return functor.result;
|
||||||
|
}
|
||||||
template <typename T, class CIn, class COut>
|
template <typename T, class CIn, class COut>
|
||||||
VTKM_CONT static T StreamingScanExclusive(const vtkm::Id numBlocks,
|
VTKM_CONT static T StreamingScanExclusive(const vtkm::Id numBlocks,
|
||||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||||
{
|
{
|
||||||
detail::StreamingScanExclusiveFunctor<T> functor;
|
return StreamingScanExclusive(vtkm::cont::DeviceAdapterTagAny(), numBlocks, input, output);
|
||||||
vtkm::cont::TryExecute(functor, numBlocks, input, output);
|
|
||||||
return functor.result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||||
|
VTKM_CONT static T ScanInclusive(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||||
|
BinaryFunctor binary_functor)
|
||||||
|
{
|
||||||
|
detail::ScanInclusiveResultFunctor<T> functor;
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, functor, input, output, binary_functor);
|
||||||
|
return functor.result;
|
||||||
|
}
|
||||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||||
VTKM_CONT static T ScanInclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static T ScanInclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||||
BinaryFunctor binary_functor)
|
BinaryFunctor binary_functor)
|
||||||
{
|
{
|
||||||
detail::ScanInclusiveResultFunctor<T> functor;
|
return ScanInclusive(vtkm::cont::DeviceAdapterTagAny(), input, output, binary_functor);
|
||||||
vtkm::cont::TryExecute(functor, input, output, binary_functor);
|
|
||||||
return functor.result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T,
|
||||||
|
typename U,
|
||||||
|
typename KIn,
|
||||||
|
typename VIn,
|
||||||
|
typename VOut,
|
||||||
|
typename BinaryFunctor>
|
||||||
|
VTKM_CONT static void ScanInclusiveByKey(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||||
|
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||||
|
vtkm::cont::ArrayHandle<U, VOut>& values_output,
|
||||||
|
BinaryFunctor binary_functor)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(
|
||||||
|
devId, detail::ScanInclusiveByKeyFunctor(), keys, values, values_output, binary_functor);
|
||||||
|
}
|
||||||
template <typename T,
|
template <typename T,
|
||||||
typename U,
|
typename U,
|
||||||
typename KIn,
|
typename KIn,
|
||||||
@ -453,38 +606,84 @@ struct Algorithm
|
|||||||
vtkm::cont::ArrayHandle<U, VOut>& values_output,
|
vtkm::cont::ArrayHandle<U, VOut>& values_output,
|
||||||
BinaryFunctor binary_functor)
|
BinaryFunctor binary_functor)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(
|
ScanInclusiveByKey(
|
||||||
detail::ScanInclusiveByKeyFunctor(), keys, values, values_output, binary_functor);
|
vtkm::cont::DeviceAdapterTagAny(), keys, values, values_output, binary_functor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename U, typename KIn, typename VIn, typename VOut>
|
||||||
|
VTKM_CONT static void ScanInclusiveByKey(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||||
|
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||||
|
vtkm::cont::ArrayHandle<U, VOut>& values_output)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(
|
||||||
|
devId, detail::ScanInclusiveByKeyFunctor(), keys, values, values_output);
|
||||||
|
}
|
||||||
template <typename T, typename U, typename KIn, typename VIn, typename VOut>
|
template <typename T, typename U, typename KIn, typename VIn, typename VOut>
|
||||||
VTKM_CONT static void ScanInclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
VTKM_CONT static void ScanInclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||||
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||||
vtkm::cont::ArrayHandle<U, VOut>& values_output)
|
vtkm::cont::ArrayHandle<U, VOut>& values_output)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::ScanInclusiveByKeyFunctor(), keys, values, values_output);
|
ScanInclusiveByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values, values_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class CIn, class COut>
|
||||||
|
VTKM_CONT static T ScanExclusive(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||||
|
{
|
||||||
|
detail::ScanExclusiveFunctor<T> functor;
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, functor, input, output);
|
||||||
|
return functor.result;
|
||||||
|
}
|
||||||
template <typename T, class CIn, class COut>
|
template <typename T, class CIn, class COut>
|
||||||
VTKM_CONT static T ScanExclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static T ScanExclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
vtkm::cont::ArrayHandle<T, COut>& output)
|
vtkm::cont::ArrayHandle<T, COut>& output)
|
||||||
{
|
{
|
||||||
detail::ScanExclusiveFunctor<T> functor;
|
return ScanExclusive(vtkm::cont::DeviceAdapterTagAny(), input, output);
|
||||||
vtkm::cont::TryExecute(functor, input, output);
|
|
||||||
return functor.result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||||
|
VTKM_CONT static T ScanExclusive(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||||
|
BinaryFunctor binaryFunctor,
|
||||||
|
const T& initialValue)
|
||||||
|
{
|
||||||
|
detail::ScanExclusiveFunctor<T> functor;
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, functor, input, output, binaryFunctor, initialValue);
|
||||||
|
return functor.result;
|
||||||
|
}
|
||||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||||
VTKM_CONT static T ScanExclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static T ScanExclusive(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||||
BinaryFunctor binaryFunctor,
|
BinaryFunctor binaryFunctor,
|
||||||
const T& initialValue)
|
const T& initialValue)
|
||||||
{
|
{
|
||||||
detail::ScanExclusiveFunctor<T> functor;
|
return ScanExclusive(
|
||||||
vtkm::cont::TryExecute(functor, input, output, binaryFunctor, initialValue);
|
vtkm::cont::DeviceAdapterTagAny(), input, output, binaryFunctor, initialValue);
|
||||||
return functor.result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename U, typename KIn, typename VIn, typename VOut, class BinaryFunctor>
|
||||||
|
VTKM_CONT static void ScanExclusiveByKey(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||||
|
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||||
|
vtkm::cont::ArrayHandle<U, VOut>& output,
|
||||||
|
const U& initialValue,
|
||||||
|
BinaryFunctor binaryFunctor)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId,
|
||||||
|
detail::ScanExclusiveByKeyFunctor(),
|
||||||
|
keys,
|
||||||
|
values,
|
||||||
|
output,
|
||||||
|
initialValue,
|
||||||
|
binaryFunctor);
|
||||||
|
}
|
||||||
template <typename T, typename U, typename KIn, typename VIn, typename VOut, class BinaryFunctor>
|
template <typename T, typename U, typename KIn, typename VIn, typename VOut, class BinaryFunctor>
|
||||||
VTKM_CONT static void ScanExclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
VTKM_CONT static void ScanExclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||||
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||||
@ -492,60 +691,139 @@ struct Algorithm
|
|||||||
const U& initialValue,
|
const U& initialValue,
|
||||||
BinaryFunctor binaryFunctor)
|
BinaryFunctor binaryFunctor)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(
|
ScanExclusiveByKey(
|
||||||
detail::ScanExclusiveByKeyFunctor(), keys, values, output, initialValue, binaryFunctor);
|
vtkm::cont::DeviceAdapterTagAny(), keys, values, output, initialValue, binaryFunctor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename U, class KIn, typename VIn, typename VOut>
|
||||||
|
VTKM_CONT static void ScanExclusiveByKey(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||||
|
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||||
|
vtkm::cont::ArrayHandle<U, VOut>& output)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(
|
||||||
|
devId, detail::ScanExclusiveByKeyFunctor(), keys, values, output);
|
||||||
|
}
|
||||||
template <typename T, typename U, class KIn, typename VIn, typename VOut>
|
template <typename T, typename U, class KIn, typename VIn, typename VOut>
|
||||||
VTKM_CONT static void ScanExclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
VTKM_CONT static void ScanExclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
|
||||||
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
const vtkm::cont::ArrayHandle<U, VIn>& values,
|
||||||
vtkm::cont::ArrayHandle<U, VOut>& output)
|
vtkm::cont::ArrayHandle<U, VOut>& output)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::ScanExclusiveByKeyFunctor(), keys, values, output);
|
ScanExclusiveByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Functor>
|
||||||
|
VTKM_CONT static void Schedule(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
Functor functor,
|
||||||
|
vtkm::Id numInstances)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::ScheduleFunctor(), functor, numInstances);
|
||||||
|
}
|
||||||
template <class Functor>
|
template <class Functor>
|
||||||
VTKM_CONT static void Schedule(Functor functor, vtkm::Id numInstances)
|
VTKM_CONT static void Schedule(Functor functor, vtkm::Id numInstances)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::ScheduleFunctor(), functor, numInstances);
|
Schedule(vtkm::cont::DeviceAdapterTagAny(), functor, numInstances);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class Functor>
|
||||||
|
VTKM_CONT static void Schedule(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
Functor functor,
|
||||||
|
vtkm::Id3 rangeMax)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::ScheduleFunctor(), functor, rangeMax);
|
||||||
|
}
|
||||||
template <class Functor>
|
template <class Functor>
|
||||||
VTKM_CONT static void Schedule(Functor functor, vtkm::Id3 rangeMax)
|
VTKM_CONT static void Schedule(Functor functor, vtkm::Id3 rangeMax)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::ScheduleFunctor(), functor, rangeMax);
|
Schedule(vtkm::cont::DeviceAdapterTagAny(), functor, rangeMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class Storage>
|
||||||
|
VTKM_CONT static void Sort(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
vtkm::cont::ArrayHandle<T, Storage>& values)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::SortFunctor(), values);
|
||||||
|
}
|
||||||
template <typename T, class Storage>
|
template <typename T, class Storage>
|
||||||
VTKM_CONT static void Sort(vtkm::cont::ArrayHandle<T, Storage>& values)
|
VTKM_CONT static void Sort(vtkm::cont::ArrayHandle<T, Storage>& values)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::SortFunctor(), values);
|
Sort(vtkm::cont::DeviceAdapterTagAny(), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class Storage, class BinaryCompare>
|
||||||
|
VTKM_CONT static void Sort(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
vtkm::cont::ArrayHandle<T, Storage>& values,
|
||||||
|
BinaryCompare binary_compare)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::SortFunctor(), values, binary_compare);
|
||||||
|
}
|
||||||
template <typename T, class Storage, class BinaryCompare>
|
template <typename T, class Storage, class BinaryCompare>
|
||||||
VTKM_CONT static void Sort(vtkm::cont::ArrayHandle<T, Storage>& values,
|
VTKM_CONT static void Sort(vtkm::cont::ArrayHandle<T, Storage>& values,
|
||||||
BinaryCompare binary_compare)
|
BinaryCompare binary_compare)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::SortFunctor(), values, binary_compare);
|
Sort(vtkm::cont::DeviceAdapterTagAny(), values, binary_compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename U, class StorageT, class StorageU>
|
||||||
|
VTKM_CONT static void SortByKey(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
vtkm::cont::ArrayHandle<T, StorageT>& keys,
|
||||||
|
vtkm::cont::ArrayHandle<U, StorageU>& values)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::SortByKeyFunctor(), keys, values);
|
||||||
|
}
|
||||||
template <typename T, typename U, class StorageT, class StorageU>
|
template <typename T, typename U, class StorageT, class StorageU>
|
||||||
VTKM_CONT static void SortByKey(vtkm::cont::ArrayHandle<T, StorageT>& keys,
|
VTKM_CONT static void SortByKey(vtkm::cont::ArrayHandle<T, StorageT>& keys,
|
||||||
vtkm::cont::ArrayHandle<U, StorageU>& values)
|
vtkm::cont::ArrayHandle<U, StorageU>& values)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::SortByKeyFunctor(), keys, values);
|
SortByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
|
||||||
|
VTKM_CONT static void SortByKey(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
vtkm::cont::ArrayHandle<T, StorageT>& keys,
|
||||||
|
vtkm::cont::ArrayHandle<U, StorageU>& values,
|
||||||
|
BinaryCompare binary_compare)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::SortByKeyFunctor(), keys, values, binary_compare);
|
||||||
|
}
|
||||||
template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
|
template <typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
|
||||||
VTKM_CONT static void SortByKey(vtkm::cont::ArrayHandle<T, StorageT>& keys,
|
VTKM_CONT static void SortByKey(vtkm::cont::ArrayHandle<T, StorageT>& keys,
|
||||||
vtkm::cont::ArrayHandle<U, StorageU>& values,
|
vtkm::cont::ArrayHandle<U, StorageU>& values,
|
||||||
BinaryCompare binary_compare)
|
BinaryCompare binary_compare)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::SortByKeyFunctor(), keys, values, binary_compare);
|
SortByKey(vtkm::cont::DeviceAdapterTagAny(), keys, values, binary_compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT static void Synchronize() { vtkm::cont::TryExecute(detail::SynchronizeFunctor()); }
|
|
||||||
|
|
||||||
|
VTKM_CONT static void Synchronize(vtkm::cont::DeviceAdapterId devId)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::SynchronizeFunctor());
|
||||||
|
}
|
||||||
|
VTKM_CONT static void Synchronize() { Synchronize(vtkm::cont::DeviceAdapterTagAny()); }
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T,
|
||||||
|
typename U,
|
||||||
|
typename V,
|
||||||
|
typename StorageT,
|
||||||
|
typename StorageU,
|
||||||
|
typename StorageV,
|
||||||
|
typename BinaryFunctor>
|
||||||
|
VTKM_CONT static void Transform(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, StorageT>& input1,
|
||||||
|
const vtkm::cont::ArrayHandle<U, StorageU>& input2,
|
||||||
|
vtkm::cont::ArrayHandle<V, StorageV>& output,
|
||||||
|
BinaryFunctor binaryFunctor)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(
|
||||||
|
devId, detail::TransformFunctor(), input1, input2, output, binaryFunctor);
|
||||||
|
}
|
||||||
template <typename T,
|
template <typename T,
|
||||||
typename U,
|
typename U,
|
||||||
typename V,
|
typename V,
|
||||||
@ -558,44 +836,87 @@ struct Algorithm
|
|||||||
vtkm::cont::ArrayHandle<V, StorageV>& output,
|
vtkm::cont::ArrayHandle<V, StorageV>& output,
|
||||||
BinaryFunctor binaryFunctor)
|
BinaryFunctor binaryFunctor)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::TransformFunctor(), input1, input2, output, binaryFunctor);
|
Transform(vtkm::cont::DeviceAdapterTagAny(), input1, input2, output, binaryFunctor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class Storage>
|
||||||
|
VTKM_CONT static void Unique(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
vtkm::cont::ArrayHandle<T, Storage>& values)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::UniqueFunctor(), values);
|
||||||
|
}
|
||||||
template <typename T, class Storage>
|
template <typename T, class Storage>
|
||||||
VTKM_CONT static void Unique(vtkm::cont::ArrayHandle<T, Storage>& values)
|
VTKM_CONT static void Unique(vtkm::cont::ArrayHandle<T, Storage>& values)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::UniqueFunctor(), values);
|
Unique(vtkm::cont::DeviceAdapterTagAny(), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class Storage, class BinaryCompare>
|
||||||
|
VTKM_CONT static void Unique(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
vtkm::cont::ArrayHandle<T, Storage>& values,
|
||||||
|
BinaryCompare binary_compare)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::UniqueFunctor(), values, binary_compare);
|
||||||
|
}
|
||||||
template <typename T, class Storage, class BinaryCompare>
|
template <typename T, class Storage, class BinaryCompare>
|
||||||
VTKM_CONT static void Unique(vtkm::cont::ArrayHandle<T, Storage>& values,
|
VTKM_CONT static void Unique(vtkm::cont::ArrayHandle<T, Storage>& values,
|
||||||
BinaryCompare binary_compare)
|
BinaryCompare binary_compare)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::UniqueFunctor(), values, binary_compare);
|
Unique(vtkm::cont::DeviceAdapterTagAny(), values, binary_compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class CIn, class CVal, class COut>
|
||||||
|
VTKM_CONT static void UpperBounds(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::UpperBoundsFunctor(), input, values, output);
|
||||||
|
}
|
||||||
template <typename T, class CIn, class CVal, class COut>
|
template <typename T, class CIn, class CVal, class COut>
|
||||||
VTKM_CONT static void UpperBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static void UpperBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output)
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::UpperBoundsFunctor(), input, values, output);
|
UpperBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
|
||||||
|
VTKM_CONT static void UpperBounds(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
|
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output,
|
||||||
|
BinaryCompare binary_compare)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(
|
||||||
|
devId, detail::UpperBoundsFunctor(), input, values, output, binary_compare);
|
||||||
|
}
|
||||||
template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
|
template <typename T, class CIn, class CVal, class COut, class BinaryCompare>
|
||||||
VTKM_CONT static void UpperBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
VTKM_CONT static void UpperBounds(const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||||
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
const vtkm::cont::ArrayHandle<T, CVal>& values,
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output,
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& output,
|
||||||
BinaryCompare binary_compare)
|
BinaryCompare binary_compare)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::UpperBoundsFunctor(), input, values, output, binary_compare);
|
UpperBounds(vtkm::cont::DeviceAdapterTagAny(), input, values, output, binary_compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class CIn, class COut>
|
||||||
|
VTKM_CONT static void UpperBounds(vtkm::cont::DeviceAdapterId devId,
|
||||||
|
const vtkm::cont::ArrayHandle<vtkm::Id, CIn>& input,
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& values_output)
|
||||||
|
{
|
||||||
|
vtkm::cont::TryExecuteOnDevice(devId, detail::UpperBoundsFunctor(), input, values_output);
|
||||||
|
}
|
||||||
template <class CIn, class COut>
|
template <class CIn, class COut>
|
||||||
VTKM_CONT static void UpperBounds(const vtkm::cont::ArrayHandle<vtkm::Id, CIn>& input,
|
VTKM_CONT static void UpperBounds(const vtkm::cont::ArrayHandle<vtkm::Id, CIn>& input,
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id, COut>& values_output)
|
vtkm::cont::ArrayHandle<vtkm::Id, COut>& values_output)
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(detail::UpperBoundsFunctor(), input, values_output);
|
UpperBounds(vtkm::cont::DeviceAdapterTagAny(), input, values_output);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ public:
|
|||||||
{
|
{
|
||||||
return this->Internals->ExecutionArrayValid
|
return this->Internals->ExecutionArrayValid
|
||||||
? this->Internals->ExecutionArray->GetDeviceAdapterId()
|
? this->Internals->ExecutionArray->GetDeviceAdapterId()
|
||||||
: DeviceAdapterIdUndefined{};
|
: DeviceAdapterTagUndefined{};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VTKM_ALWAYS_EXPORT InternalStruct
|
struct VTKM_ALWAYS_EXPORT InternalStruct
|
||||||
|
310
vtkm/cont/ArrayHandleView.h
Normal file
310
vtkm/cont/ArrayHandleView.h
Normal file
@ -0,0 +1,310 @@
|
|||||||
|
//============================================================================
|
||||||
|
// Copyright (c) Kitware, Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
// See LICENSE.txt for details.
|
||||||
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||||
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE. See the above copyright notice for more information.
|
||||||
|
//
|
||||||
|
// Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
||||||
|
// Copyright 2018 UT-Battelle, LLC.
|
||||||
|
// Copyright 2018 Los Alamos National Security.
|
||||||
|
//
|
||||||
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||||
|
// the U.S. Government retains certain rights in this software.
|
||||||
|
//
|
||||||
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||||
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||||
|
// this software.
|
||||||
|
//============================================================================
|
||||||
|
#ifndef vtk_m_cont_ArrayHandleView_h
|
||||||
|
#define vtk_m_cont_ArrayHandleView_h
|
||||||
|
|
||||||
|
#include <vtkm/Assert.h>
|
||||||
|
|
||||||
|
#include <vtkm/cont/ArrayHandle.h>
|
||||||
|
#include <vtkm/cont/ArrayPortal.h>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace cont
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace internal
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename TargetPortalType>
|
||||||
|
class ArrayPortalView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using ValueType = typename TargetPortalType::ValueType;
|
||||||
|
|
||||||
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||||
|
VTKM_EXEC_CONT
|
||||||
|
ArrayPortalView() {}
|
||||||
|
|
||||||
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||||
|
VTKM_EXEC_CONT
|
||||||
|
ArrayPortalView(const TargetPortalType& targetPortal, vtkm::Id startIndex, vtkm::Id numValues)
|
||||||
|
: TargetPortal(targetPortal)
|
||||||
|
, StartIndex(startIndex)
|
||||||
|
, NumValues(numValues)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||||
|
template <typename OtherPortalType>
|
||||||
|
VTKM_EXEC_CONT ArrayPortalView(const ArrayPortalView<OtherPortalType>& otherPortal)
|
||||||
|
: TargetPortal(otherPortal.GetTargetPortal())
|
||||||
|
, StartIndex(otherPortal.GetStartIndex())
|
||||||
|
, NumValues(otherPortal.GetNumberOfValues())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_EXEC_CONT
|
||||||
|
vtkm::Id GetNumberOfValues() const { return this->NumValues; }
|
||||||
|
|
||||||
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||||
|
VTKM_EXEC_CONT
|
||||||
|
ValueType Get(vtkm::Id index) const { return this->TargetPortal.Get(index + this->StartIndex); }
|
||||||
|
|
||||||
|
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||||
|
VTKM_EXEC_CONT
|
||||||
|
void Set(vtkm::Id index, const ValueType& value) const
|
||||||
|
{
|
||||||
|
this->TargetPortal.Set(index + this->StartIndex, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_EXEC_CONT
|
||||||
|
const TargetPortalType& GetTargetPortal() const { return this->TargetPortal; }
|
||||||
|
VTKM_EXEC_CONT
|
||||||
|
vtkm::Id GetStartIndex() const { return this->StartIndex; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
TargetPortalType TargetPortal;
|
||||||
|
vtkm::Id StartIndex;
|
||||||
|
vtkm::Id NumValues;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
template <typename ArrayHandleType>
|
||||||
|
struct StorageTagView
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace internal
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename ArrayHandleType>
|
||||||
|
class Storage<typename ArrayHandleType::ValueType, StorageTagView<ArrayHandleType>>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using ValueType = typename ArrayHandleType::ValueType;
|
||||||
|
|
||||||
|
using PortalType = ArrayPortalView<typename ArrayHandleType::PortalControl>;
|
||||||
|
using PortalConstType = ArrayPortalView<typename ArrayHandleType::PortalConstControl>;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
Storage()
|
||||||
|
: Valid(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
Storage(const ArrayHandleType& array, vtkm::Id startIndex, vtkm::Id numValues)
|
||||||
|
: Array(array)
|
||||||
|
, StartIndex(startIndex)
|
||||||
|
, NumValues(numValues)
|
||||||
|
, Valid(true)
|
||||||
|
{
|
||||||
|
VTKM_ASSERT(this->StartIndex >= 0);
|
||||||
|
VTKM_ASSERT((this->StartIndex + this->NumValues) <= this->Array.GetNumberOfValues());
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
PortalType GetPortal()
|
||||||
|
{
|
||||||
|
VTKM_ASSERT(this->Valid);
|
||||||
|
return PortalType(this->Array.GetPortalControl(), this->StartIndex, this->NumValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
PortalConstType GetPortalConst() const
|
||||||
|
{
|
||||||
|
VTKM_ASSERT(this->Valid);
|
||||||
|
return PortalConstType(this->Array.GetPortalConstControl(), this->StartIndex, this->NumValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Id GetNumberOfValues() const { return this->NumValues; }
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
void Allocate(vtkm::Id vtkmNotUsed(numberOfValues))
|
||||||
|
{
|
||||||
|
throw vtkm::cont::ErrorInternal("ArrayHandleView should not be allocated explicitly. ");
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
void Shrink(vtkm::Id numberOfValues)
|
||||||
|
{
|
||||||
|
VTKM_ASSERT(this->Valid);
|
||||||
|
if (numberOfValues > this->NumValues)
|
||||||
|
{
|
||||||
|
throw vtkm::cont::ErrorBadValue("Shrink method cannot be used to grow array.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this->NumValues = numberOfValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
void ReleaseResources()
|
||||||
|
{
|
||||||
|
VTKM_ASSERT(this->Valid);
|
||||||
|
this->Array.ReleaseResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requried for later use in ArrayTransfer class.
|
||||||
|
VTKM_CONT
|
||||||
|
const ArrayHandleType& GetArray() const
|
||||||
|
{
|
||||||
|
VTKM_ASSERT(this->Valid);
|
||||||
|
return this->Array;
|
||||||
|
}
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Id GetStartIndex() const { return this->StartIndex; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
ArrayHandleType Array;
|
||||||
|
vtkm::Id StartIndex;
|
||||||
|
vtkm::Id NumValues;
|
||||||
|
bool Valid;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename ArrayHandleType, typename Device>
|
||||||
|
class ArrayTransfer<typename ArrayHandleType::ValueType, StorageTagView<ArrayHandleType>, Device>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using ValueType = typename ArrayHandleType::ValueType;
|
||||||
|
|
||||||
|
private:
|
||||||
|
using StorageTag = StorageTagView<ArrayHandleType>;
|
||||||
|
using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using PortalControl = typename StorageType::PortalType;
|
||||||
|
using PortalConstControl = typename StorageType::PortalConstType;
|
||||||
|
|
||||||
|
using PortalExecution =
|
||||||
|
ArrayPortalView<typename ArrayHandleType::template ExecutionTypes<Device>::Portal>;
|
||||||
|
using PortalConstExecution =
|
||||||
|
ArrayPortalView<typename ArrayHandleType::template ExecutionTypes<Device>::PortalConst>;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
ArrayTransfer(StorageType* storage)
|
||||||
|
: Array(storage->GetArray())
|
||||||
|
, StartIndex(storage->GetStartIndex())
|
||||||
|
, NumValues(storage->GetNumberOfValues())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
vtkm::Id GetNumberOfValues() const { return this->NumValues; }
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
PortalConstExecution PrepareForInput(bool vtkmNotUsed(updateData))
|
||||||
|
{
|
||||||
|
return PortalConstExecution(
|
||||||
|
this->Array.PrepareForInput(Device()), this->StartIndex, this->NumValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
PortalExecution PrepareForInPlace(bool vtkmNotUsed(updateData))
|
||||||
|
{
|
||||||
|
return PortalExecution(
|
||||||
|
this->Array.PrepareForInPlace(Device()), this->StartIndex, this->NumValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
PortalExecution PrepareForOutput(vtkm::Id numberOfValues)
|
||||||
|
{
|
||||||
|
if (numberOfValues != this->GetNumberOfValues())
|
||||||
|
{
|
||||||
|
throw vtkm::cont::ErrorBadValue(
|
||||||
|
"An ArrayHandleView can be used as an output array, "
|
||||||
|
"but it cannot be resized. Make sure the index array is sized "
|
||||||
|
"to the appropriate length before trying to prepare for output.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// We cannot practically allocate ValueArray because we do not know the
|
||||||
|
// range of indices. We try to check by seeing if ValueArray has no
|
||||||
|
// entries, which clearly indicates that it is not allocated. Otherwise,
|
||||||
|
// we have to assume the allocation is correct.
|
||||||
|
if ((numberOfValues > 0) && (this->Array.GetNumberOfValues() < 1))
|
||||||
|
{
|
||||||
|
throw vtkm::cont::ErrorBadValue(
|
||||||
|
"The value array must be pre-allocated before it is used for the "
|
||||||
|
"output of ArrayHandlePermutation.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return PortalExecution(this->Array.PrepareForOutput(this->Array.GetNumberOfValues(), Device()),
|
||||||
|
this->StartIndex,
|
||||||
|
this->NumValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
void RetrieveOutputData(StorageType* vtkmNotUsed(storage)) const
|
||||||
|
{
|
||||||
|
// No implementation necessary
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
void Shrink(vtkm::Id numberOfValues) { this->NumValues = numberOfValues; }
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
void ReleaseResources() { this->Array.ReleaseResourcesExecution(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
ArrayHandleType Array;
|
||||||
|
vtkm::Id StartIndex;
|
||||||
|
vtkm::Id NumValues;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
template <typename ArrayHandleType>
|
||||||
|
class ArrayHandleView : public vtkm::cont::ArrayHandle<typename ArrayHandleType::ValueType,
|
||||||
|
StorageTagView<ArrayHandleType>>
|
||||||
|
{
|
||||||
|
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
|
||||||
|
|
||||||
|
public:
|
||||||
|
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleView,
|
||||||
|
(ArrayHandleView<ArrayHandleType>),
|
||||||
|
(vtkm::cont::ArrayHandle<typename ArrayHandleType::ValueType,
|
||||||
|
StorageTagView<ArrayHandleType>>));
|
||||||
|
|
||||||
|
private:
|
||||||
|
using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
VTKM_CONT
|
||||||
|
ArrayHandleView(const ArrayHandleType& array, vtkm::Id startIndex, vtkm::Id numValues)
|
||||||
|
: Superclass(StorageType(array, startIndex, numValues))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename ArrayHandleType>
|
||||||
|
ArrayHandleView<ArrayHandleType> make_ArrayHandleView(const ArrayHandleType& array,
|
||||||
|
vtkm::Id startIndex,
|
||||||
|
vtkm::Id numValues)
|
||||||
|
{
|
||||||
|
VTKM_IS_ARRAY_HANDLE(ArrayHandleType);
|
||||||
|
|
||||||
|
return ArrayHandleView<ArrayHandleType>(array, startIndex, numValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace vtkm::cont
|
||||||
|
|
||||||
|
#endif //vtk_m_cont_ArrayHandleView_h
|
@ -135,15 +135,16 @@ VTKM_CONT void BoundingIntervalHierarchy::CalculatePlaneSplitCost(
|
|||||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> splitPlanes;
|
vtkm::cont::ArrayHandle<vtkm::FloatDefault> splitPlanes;
|
||||||
vtkm::worklet::spatialstructure::SplitPlaneCalculatorWorklet splitPlaneCalcWorklet(planeIndex,
|
vtkm::worklet::spatialstructure::SplitPlaneCalculatorWorklet splitPlaneCalcWorklet(planeIndex,
|
||||||
numPlanes);
|
numPlanes);
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::SplitPlaneCalculatorWorklet,
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::SplitPlaneCalculatorWorklet>
|
||||||
DeviceAdapter>
|
|
||||||
splitDispatcher(splitPlaneCalcWorklet);
|
splitDispatcher(splitPlaneCalcWorklet);
|
||||||
|
splitDispatcher.SetDevice(DeviceAdapter());
|
||||||
splitDispatcher.Invoke(segmentRanges, splitPlanes);
|
splitDispatcher.Invoke(segmentRanges, splitPlanes);
|
||||||
|
|
||||||
// Check if a point is to the left of the split plane or right
|
// Check if a point is to the left of the split plane or right
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> isLEQOfSplitPlane, isROfSplitPlane;
|
vtkm::cont::ArrayHandle<vtkm::Id> isLEQOfSplitPlane, isROfSplitPlane;
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::LEQWorklet, DeviceAdapter>()
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::LEQWorklet> LEQDispatcher;
|
||||||
.Invoke(coords, splitPlanes, isLEQOfSplitPlane, isROfSplitPlane);
|
LEQDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
LEQDispatcher.Invoke(coords, splitPlanes, isLEQOfSplitPlane, isROfSplitPlane);
|
||||||
|
|
||||||
// Count of points to the left
|
// Count of points to the left
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> pointsToLeft;
|
vtkm::cont::ArrayHandle<vtkm::Id> pointsToLeft;
|
||||||
@ -270,9 +271,11 @@ public:
|
|||||||
//START_TIMER(s12);
|
//START_TIMER(s12);
|
||||||
CoordsArrayHandle centerXs, centerYs, centerZs;
|
CoordsArrayHandle centerXs, centerYs, centerZs;
|
||||||
RangeArrayHandle xRanges, yRanges, zRanges;
|
RangeArrayHandle xRanges, yRanges, zRanges;
|
||||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::spatialstructure::CellRangesExtracter,
|
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::spatialstructure::CellRangesExtracter>
|
||||||
DeviceAdapter>()
|
cellRangesExtracterDispatcher;
|
||||||
.Invoke(cellSet, points, xRanges, yRanges, zRanges, centerXs, centerYs, centerZs);
|
cellRangesExtracterDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
cellRangesExtracterDispatcher.Invoke(
|
||||||
|
cellSet, points, xRanges, yRanges, zRanges, centerXs, centerYs, centerZs);
|
||||||
//PRINT_TIMER("1.2", s12);
|
//PRINT_TIMER("1.2", s12);
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
@ -39,6 +39,7 @@ set(headers
|
|||||||
ArrayHandleSwizzle.h
|
ArrayHandleSwizzle.h
|
||||||
ArrayHandleTransform.h
|
ArrayHandleTransform.h
|
||||||
ArrayHandleUniformPointCoordinates.h
|
ArrayHandleUniformPointCoordinates.h
|
||||||
|
ArrayHandleView.h
|
||||||
ArrayHandleVirtualCoordinates.h
|
ArrayHandleVirtualCoordinates.h
|
||||||
ArrayHandleZip.h
|
ArrayHandleZip.h
|
||||||
ArrayPortal.h
|
ArrayPortal.h
|
||||||
@ -133,6 +134,7 @@ set(sources
|
|||||||
FieldRangeGlobalCompute.cxx
|
FieldRangeGlobalCompute.cxx
|
||||||
internal/ArrayHandleBasicImpl.cxx
|
internal/ArrayHandleBasicImpl.cxx
|
||||||
internal/ArrayManagerExecutionShareWithControl.cxx
|
internal/ArrayManagerExecutionShareWithControl.cxx
|
||||||
|
internal/DeviceAdapterTag.cxx
|
||||||
internal/SimplePolymorphicContainer.cxx
|
internal/SimplePolymorphicContainer.cxx
|
||||||
MultiBlock.cxx
|
MultiBlock.cxx
|
||||||
PresetColorTables.cxx
|
PresetColorTables.cxx
|
||||||
|
@ -138,8 +138,9 @@ public:
|
|||||||
auto coordinates =
|
auto coordinates =
|
||||||
this->Coordinates.GetData().Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
|
this->Coordinates.GetData().Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
|
||||||
auto cellset = this->CellSet.ResetCellSetList(StructuredCellSetList());
|
auto cellset = this->CellSet.ResetCellSetList(StructuredCellSetList());
|
||||||
vtkm::worklet::DispatcherMapField<FindCellWorklet, DeviceAdapter>().Invoke(
|
vtkm::worklet::DispatcherMapField<FindCellWorklet> dispatcher;
|
||||||
points, cellset, coordinates, cellIds, parametricCoords);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
dispatcher.Invoke(points, cellset, coordinates, cellIds, parametricCoords);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -513,8 +513,9 @@ public:
|
|||||||
// 2: For each cell, find the number of top level bins they intersect
|
// 2: For each cell, find the number of top level bins they intersect
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> binCounts;
|
vtkm::cont::ArrayHandle<vtkm::Id> binCounts;
|
||||||
CountBinsL1 countL1(ls.TopLevel);
|
CountBinsL1 countL1(ls.TopLevel);
|
||||||
vtkm::worklet::DispatcherMapTopology<CountBinsL1, DeviceAdapter>(countL1).Invoke(
|
vtkm::worklet::DispatcherMapTopology<CountBinsL1> countL1Dispatcher(countL1);
|
||||||
cellset, coords, binCounts);
|
countL1Dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
countL1Dispatcher.Invoke(cellset, coords, binCounts);
|
||||||
|
|
||||||
// 3: Total number of unique (cell, bin) pairs (for pre-allocating arrays)
|
// 3: Total number of unique (cell, bin) pairs (for pre-allocating arrays)
|
||||||
vtkm::Id numPairsL1 = Algorithm::ScanExclusive(binCounts, binCounts);
|
vtkm::Id numPairsL1 = Algorithm::ScanExclusive(binCounts, binCounts);
|
||||||
@ -523,8 +524,9 @@ public:
|
|||||||
vtkm::cont::ArrayHandle<vtkm::Id> binIds;
|
vtkm::cont::ArrayHandle<vtkm::Id> binIds;
|
||||||
binIds.Allocate(numPairsL1);
|
binIds.Allocate(numPairsL1);
|
||||||
FindBinsL1 findL1(ls.TopLevel);
|
FindBinsL1 findL1(ls.TopLevel);
|
||||||
vtkm::worklet::DispatcherMapTopology<FindBinsL1, DeviceAdapter>(findL1).Invoke(
|
vtkm::worklet::DispatcherMapTopology<FindBinsL1> findL1Dispatcher(findL1);
|
||||||
cellset, coords, binCounts, binIds);
|
findL1Dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
findL1Dispatcher.Invoke(cellset, coords, binCounts, binIds);
|
||||||
binCounts.ReleaseResources();
|
binCounts.ReleaseResources();
|
||||||
|
|
||||||
// 5: From above, find the number of cells that intersect each top level bin
|
// 5: From above, find the number of cells that intersect each top level bin
|
||||||
@ -544,8 +546,9 @@ public:
|
|||||||
Algorithm::Copy(vtkm::cont::make_ArrayHandleConstant(DimVec3(0), numberOfBins),
|
Algorithm::Copy(vtkm::cont::make_ArrayHandleConstant(DimVec3(0), numberOfBins),
|
||||||
ls.LeafDimensions);
|
ls.LeafDimensions);
|
||||||
GenerateBinsL1 generateL1(ls.TopLevel.BinSize, this->DensityL2);
|
GenerateBinsL1 generateL1(ls.TopLevel.BinSize, this->DensityL2);
|
||||||
vtkm::worklet::DispatcherMapField<GenerateBinsL1, DeviceAdapter>(generateL1)
|
vtkm::worklet::DispatcherMapField<GenerateBinsL1> generateL1Dispatcher(generateL1);
|
||||||
.Invoke(bins, cellsPerBin, ls.LeafDimensions);
|
generateL1Dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
generateL1Dispatcher.Invoke(bins, cellsPerBin, ls.LeafDimensions);
|
||||||
bins.ReleaseResources();
|
bins.ReleaseResources();
|
||||||
cellsPerBin.ReleaseResources();
|
cellsPerBin.ReleaseResources();
|
||||||
|
|
||||||
@ -557,8 +560,9 @@ public:
|
|||||||
|
|
||||||
// 8: For each cell, find the number of l2 bins they intersect
|
// 8: For each cell, find the number of l2 bins they intersect
|
||||||
CountBinsL2 countL2(ls.TopLevel);
|
CountBinsL2 countL2(ls.TopLevel);
|
||||||
vtkm::worklet::DispatcherMapTopology<CountBinsL2, DeviceAdapter>(countL2).Invoke(
|
vtkm::worklet::DispatcherMapTopology<CountBinsL2> countL2Dispatcher(countL2);
|
||||||
cellset, coords, ls.LeafDimensions, binCounts);
|
countL2Dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
countL2Dispatcher.Invoke(cellset, coords, ls.LeafDimensions, binCounts);
|
||||||
|
|
||||||
// 9: Total number of unique (cell, bin) pairs (for pre-allocating arrays)
|
// 9: Total number of unique (cell, bin) pairs (for pre-allocating arrays)
|
||||||
vtkm::Id numPairsL2 = Algorithm::ScanExclusive(binCounts, binCounts);
|
vtkm::Id numPairsL2 = Algorithm::ScanExclusive(binCounts, binCounts);
|
||||||
@ -567,7 +571,9 @@ public:
|
|||||||
binIds.Allocate(numPairsL2);
|
binIds.Allocate(numPairsL2);
|
||||||
ls.CellIds.Allocate(numPairsL2);
|
ls.CellIds.Allocate(numPairsL2);
|
||||||
FindBinsL2 findL2(ls.TopLevel);
|
FindBinsL2 findL2(ls.TopLevel);
|
||||||
vtkm::worklet::DispatcherMapTopology<FindBinsL2, DeviceAdapter>(findL2).Invoke(
|
vtkm::worklet::DispatcherMapTopology<FindBinsL2> findL2Dispatcher(findL2);
|
||||||
|
findL2Dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
findL2Dispatcher.Invoke(
|
||||||
cellset, coords, ls.LeafDimensions, ls.LeafStartIndex, binCounts, binIds, ls.CellIds);
|
cellset, coords, ls.LeafDimensions, ls.LeafStartIndex, binCounts, binIds, ls.CellIds);
|
||||||
binCounts.ReleaseResources();
|
binCounts.ReleaseResources();
|
||||||
|
|
||||||
@ -587,8 +593,9 @@ public:
|
|||||||
Algorithm::Copy(vtkm::cont::ArrayHandleConstant<vtkm::Id>(0, numberOfLeaves),
|
Algorithm::Copy(vtkm::cont::ArrayHandleConstant<vtkm::Id>(0, numberOfLeaves),
|
||||||
ls.CellStartIndex);
|
ls.CellStartIndex);
|
||||||
Algorithm::Copy(vtkm::cont::ArrayHandleConstant<vtkm::Id>(0, numberOfLeaves), ls.CellCount);
|
Algorithm::Copy(vtkm::cont::ArrayHandleConstant<vtkm::Id>(0, numberOfLeaves), ls.CellCount);
|
||||||
vtkm::worklet::DispatcherMapField<GenerateBinsL2, DeviceAdapter>().Invoke(
|
vtkm::worklet::DispatcherMapField<GenerateBinsL2> dispatchGenerateBinsL2;
|
||||||
bins, cellsStart, cellsPerBin, ls.CellStartIndex, ls.CellCount);
|
dispatchGenerateBinsL2.SetDevice(DeviceAdapter());
|
||||||
|
dispatchGenerateBinsL2.Invoke(bins, cellsStart, cellsPerBin, ls.CellStartIndex, ls.CellCount);
|
||||||
|
|
||||||
std::swap(this->LookupStructure, ls);
|
std::swap(this->LookupStructure, ls);
|
||||||
}
|
}
|
||||||
@ -708,13 +715,14 @@ public:
|
|||||||
DeviceAdapter,
|
DeviceAdapter,
|
||||||
CellSetList cellSetTypes = CellSetList()) const
|
CellSetList cellSetTypes = CellSetList()) const
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<FindCellWorklet, DeviceAdapter>().Invoke(
|
vtkm::worklet::DispatcherMapField<FindCellWorklet> dispatcher;
|
||||||
points,
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
this->CellSet.ResetCellSetList(cellSetTypes),
|
dispatcher.Invoke(points,
|
||||||
this->Coordinates,
|
this->CellSet.ResetCellSetList(cellSetTypes),
|
||||||
this->LookupStructure,
|
this->Coordinates,
|
||||||
cellIds,
|
this->LookupStructure,
|
||||||
parametricCoords);
|
cellIds,
|
||||||
|
parametricCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -48,17 +48,18 @@ public:
|
|||||||
throw vtkm::cont::ErrorInternal("Cell set is not 3D structured type");
|
throw vtkm::cont::ErrorInternal("Cell set is not 3D structured type");
|
||||||
|
|
||||||
Bounds = coords.GetBounds();
|
Bounds = coords.GetBounds();
|
||||||
Dims = cellSet.Cast<StructuredType>().GetSchedulingRange(vtkm::TopologyElementTagPoint());
|
vtkm::Vec<vtkm::Id, 3> dims =
|
||||||
|
cellSet.Cast<StructuredType>().GetSchedulingRange(vtkm::TopologyElementTagPoint());
|
||||||
|
|
||||||
RangeTransform[0] = static_cast<vtkm::FloatDefault>((Dims[0] - 1.0l) / (Bounds.X.Lenght()));
|
RangeTransform[0] = static_cast<vtkm::FloatDefault>((dims[0] - 1.0l) / (Bounds.X.Length()));
|
||||||
RangeTransform[1] = static_cast<vtkm::FloatDefault>((Dims[1] - 1.0l) / (Bounds.Y.Length()));
|
RangeTransform[1] = static_cast<vtkm::FloatDefault>((dims[1] - 1.0l) / (Bounds.Y.Length()));
|
||||||
RangeTransform[2] = static_cast<vtkm::FloatDefault>((Dims[2] - 1.0l) / (Bounds.Z.Length()));
|
RangeTransform[2] = static_cast<vtkm::FloatDefault>((dims[2] - 1.0l) / (Bounds.Z.Length()));
|
||||||
|
|
||||||
// Since we are calculating the cell Id, and the number of cells is
|
// Since we are calculating the cell Id, and the number of cells is
|
||||||
// 1 less than the number of points in each direction, the -1 from Dims
|
// 1 less than the number of points in each direction, the -1 from dims
|
||||||
// is necessary.
|
// is necessary.
|
||||||
PlaneSize = (Dims[0] - 1) * (Dims[1] - 1);
|
PlaneSize = (dims[0] - 1) * (dims[1] - 1);
|
||||||
RowSize = (Dims[0] - 1);
|
RowSize = (dims[0] - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PrepareForExecutionFunctor
|
struct PrepareForExecutionFunctor
|
||||||
@ -71,7 +72,6 @@ public:
|
|||||||
using ExecutionType = vtkm::exec::CellLocatorUniformGrid<DeviceAdapter>;
|
using ExecutionType = vtkm::exec::CellLocatorUniformGrid<DeviceAdapter>;
|
||||||
ExecutionType* execObject =
|
ExecutionType* execObject =
|
||||||
new ExecutionType(contLocator.Bounds,
|
new ExecutionType(contLocator.Bounds,
|
||||||
contLocator.Dims,
|
|
||||||
contLocator.RangeTransform,
|
contLocator.RangeTransform,
|
||||||
contLocator.PlaneSize,
|
contLocator.PlaneSize,
|
||||||
contLocator.RowSize,
|
contLocator.RowSize,
|
||||||
@ -101,7 +101,6 @@ private:
|
|||||||
using StructuredType = vtkm::cont::CellSetStructured<3>;
|
using StructuredType = vtkm::cont::CellSetStructured<3>;
|
||||||
|
|
||||||
vtkm::Bounds Bounds;
|
vtkm::Bounds Bounds;
|
||||||
vtkm::Vec<vtkm::Id, 3> Dims;
|
|
||||||
vtkm::Vec<vtkm::FloatDefault, 3> RangeTransform;
|
vtkm::Vec<vtkm::FloatDefault, 3> RangeTransform;
|
||||||
vtkm::Id PlaneSize;
|
vtkm::Id PlaneSize;
|
||||||
vtkm::Id RowSize;
|
vtkm::Id RowSize;
|
||||||
|
@ -405,7 +405,7 @@ VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
|
|||||||
OffsetsStorageTag>::GetShapesArray(FromTopology, ToTopology) const
|
OffsetsStorageTag>::GetShapesArray(FromTopology, ToTopology) const
|
||||||
-> const typename ConnectivityChooser<FromTopology, ToTopology>::ShapeArrayType&
|
-> const typename ConnectivityChooser<FromTopology, ToTopology>::ShapeArrayType&
|
||||||
{
|
{
|
||||||
this->BuildConnectivity(vtkm::cont::DeviceAdapterIdAny{}, FromTopology(), ToTopology());
|
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, FromTopology(), ToTopology());
|
||||||
return this->GetConnectivity(FromTopology(), ToTopology()).Shapes;
|
return this->GetConnectivity(FromTopology(), ToTopology()).Shapes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +421,7 @@ VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
|
|||||||
ToTopology) const -> const
|
ToTopology) const -> const
|
||||||
typename ConnectivityChooser<FromTopology, ToTopology>::NumIndicesArrayType&
|
typename ConnectivityChooser<FromTopology, ToTopology>::NumIndicesArrayType&
|
||||||
{
|
{
|
||||||
this->BuildConnectivity(vtkm::cont::DeviceAdapterIdAny{}, FromTopology(), ToTopology());
|
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, FromTopology(), ToTopology());
|
||||||
return this->GetConnectivity(FromTopology(), ToTopology()).NumIndices;
|
return this->GetConnectivity(FromTopology(), ToTopology()).NumIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +437,7 @@ VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
|
|||||||
ToTopology) const -> const
|
ToTopology) const -> const
|
||||||
typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityArrayType&
|
typename ConnectivityChooser<FromTopology, ToTopology>::ConnectivityArrayType&
|
||||||
{
|
{
|
||||||
this->BuildConnectivity(vtkm::cont::DeviceAdapterIdAny{}, FromTopology(), ToTopology());
|
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, FromTopology(), ToTopology());
|
||||||
return this->GetConnectivity(FromTopology(), ToTopology()).Connectivity;
|
return this->GetConnectivity(FromTopology(), ToTopology()).Connectivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ VTKM_CONT auto CellSetExplicit<ShapeStorageTag,
|
|||||||
ToTopology) const -> const
|
ToTopology) const -> const
|
||||||
typename ConnectivityChooser<FromTopology, ToTopology>::IndexOffsetArrayType&
|
typename ConnectivityChooser<FromTopology, ToTopology>::IndexOffsetArrayType&
|
||||||
{
|
{
|
||||||
this->BuildConnectivity(vtkm::cont::DeviceAdapterIdAny{}, FromTopology(), ToTopology());
|
this->BuildConnectivity(vtkm::cont::DeviceAdapterTagAny{}, FromTopology(), ToTopology());
|
||||||
return this->GetConnectivity(FromTopology(), ToTopology()).IndexOffsets;
|
return this->GetConnectivity(FromTopology(), ToTopology()).IndexOffsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +92,9 @@ public:
|
|||||||
vtkm::Id connectivityLength = vtkm::cont::DeviceAdapterAlgorithm<Device>::ScanExclusive(
|
vtkm::Id connectivityLength = vtkm::cont::DeviceAdapterAlgorithm<Device>::ScanExclusive(
|
||||||
vtkm::cont::make_ArrayHandleCast(conn.NumIndices, vtkm::Id()), conn.IndexOffsets);
|
vtkm::cont::make_ArrayHandleCast(conn.NumIndices, vtkm::Id()), conn.IndexOffsets);
|
||||||
conn.Connectivity.Allocate(connectivityLength);
|
conn.Connectivity.Allocate(connectivityLength);
|
||||||
vtkm::worklet::DispatcherMapTopology<WriteConnectivity, Device>().Invoke(
|
vtkm::worklet::DispatcherMapTopology<WriteConnectivity> dispatcher;
|
||||||
cellset, conn.IndexOffsets, conn.Connectivity);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(cellset, conn.IndexOffsets, conn.Connectivity);
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
@ -126,8 +127,9 @@ public:
|
|||||||
conn.NumIndices = make_ArrayHandleConstant(numPointsInCell, numberOfCells);
|
conn.NumIndices = make_ArrayHandleConstant(numPointsInCell, numberOfCells);
|
||||||
conn.IndexOffsets = ArrayHandleCounting<vtkm::Id>(0, numPointsInCell, numberOfCells);
|
conn.IndexOffsets = ArrayHandleCounting<vtkm::Id>(0, numPointsInCell, numberOfCells);
|
||||||
conn.Connectivity.Allocate(connectivityLength);
|
conn.Connectivity.Allocate(connectivityLength);
|
||||||
vtkm::worklet::DispatcherMapTopology<WriteConnectivity, Device>().Invoke(
|
vtkm::worklet::DispatcherMapTopology<WriteConnectivity> dispatcher;
|
||||||
cellset, conn.IndexOffsets, conn.Connectivity);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(cellset, conn.IndexOffsets, conn.Connectivity);
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,8 @@ struct map_color_table
|
|||||||
{
|
{
|
||||||
using namespace vtkm::worklet::colorconversion;
|
using namespace vtkm::worklet::colorconversion;
|
||||||
TransferFunction transfer(colors->PrepareForExecution(device));
|
TransferFunction transfer(colors->PrepareForExecution(device));
|
||||||
vtkm::worklet::DispatcherMapField<TransferFunction, DeviceAdapter> dispatcher(transfer);
|
vtkm::worklet::DispatcherMapField<TransferFunction> dispatcher(transfer);
|
||||||
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
dispatcher.Invoke(std::forward<Args>(args)...);
|
dispatcher.Invoke(std::forward<Args>(args)...);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -71,7 +72,8 @@ struct map_color_table_with_samples
|
|||||||
Args&&... args) const
|
Args&&... args) const
|
||||||
{
|
{
|
||||||
using namespace vtkm::worklet::colorconversion;
|
using namespace vtkm::worklet::colorconversion;
|
||||||
vtkm::worklet::DispatcherMapField<LookupTable, DeviceAdapter> dispatcher(lookupTable);
|
vtkm::worklet::DispatcherMapField<LookupTable> dispatcher(lookupTable);
|
||||||
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
dispatcher.Invoke(std::forward<Args>(args)...);
|
dispatcher.Invoke(std::forward<Args>(args)...);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#ifndef vtk_m_cont_DataSetBuilderRectilinear_h
|
#ifndef vtk_m_cont_DataSetBuilderRectilinear_h
|
||||||
#define vtk_m_cont_DataSetBuilderRectilinear_h
|
#define vtk_m_cont_DataSetBuilderRectilinear_h
|
||||||
|
|
||||||
|
#include <vtkm/cont/ArrayCopy.h>
|
||||||
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
|
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
|
||||||
#include <vtkm/cont/ArrayPortalToIterators.h>
|
#include <vtkm/cont/ArrayPortalToIterators.h>
|
||||||
#include <vtkm/cont/CoordinateSystem.h>
|
#include <vtkm/cont/CoordinateSystem.h>
|
||||||
@ -43,8 +44,7 @@ class VTKM_CONT_EXPORT DataSetBuilderRectilinear
|
|||||||
VTKM_CONT static void CopyInto(const vtkm::cont::ArrayHandle<T>& input,
|
VTKM_CONT static void CopyInto(const vtkm::cont::ArrayHandle<T>& input,
|
||||||
vtkm::cont::ArrayHandle<U>& output)
|
vtkm::cont::ArrayHandle<U>& output)
|
||||||
{
|
{
|
||||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>;
|
vtkm::cont::ArrayCopy(input, output);
|
||||||
Algorithm::Copy(input, output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
|
@ -32,7 +32,7 @@ void throwFailedRuntimeDeviceTransfer(const std::string& className,
|
|||||||
vtkm::cont::DeviceAdapterId deviceId)
|
vtkm::cont::DeviceAdapterId deviceId)
|
||||||
{ //Should we support typeid() instead of className?
|
{ //Should we support typeid() instead of className?
|
||||||
const std::string msg = "VTK-m was unable to transfer " + className + " to DeviceAdapter[id=" +
|
const std::string msg = "VTK-m was unable to transfer " + className + " to DeviceAdapter[id=" +
|
||||||
std::to_string(deviceId.GetValue()) +
|
std::to_string(deviceId.GetValue()) + ", name=" + deviceId.GetName() +
|
||||||
"]. This is generally caused by asking for execution on a DeviceAdapter that "
|
"]. This is generally caused by asking for execution on a DeviceAdapter that "
|
||||||
"isn't compiled into VTK-m. In the case of CUDA it can also be caused by accidentally "
|
"isn't compiled into VTK-m. In the case of CUDA it can also be caused by accidentally "
|
||||||
"compiling source files as C++ files instead of CUDA.";
|
"compiling source files as C++ files instead of CUDA.";
|
||||||
|
@ -36,7 +36,7 @@ class VTKM_ALWAYS_EXPORT ErrorBadValue : public Error
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ErrorBadValue(const std::string& message)
|
ErrorBadValue(const std::string& message)
|
||||||
: Error(message)
|
: Error(message, true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,7 @@ class VTKM_ALWAYS_EXPORT ErrorExecution : public vtkm::cont::Error
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ErrorExecution(const std::string& message)
|
ErrorExecution(const std::string& message)
|
||||||
: Error(message)
|
: Error(message, true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -20,10 +20,9 @@
|
|||||||
#ifndef vtk_m_cont_PointLocatorUniformGrid_h
|
#ifndef vtk_m_cont_PointLocatorUniformGrid_h
|
||||||
#define vtk_m_cont_PointLocatorUniformGrid_h
|
#define vtk_m_cont_PointLocatorUniformGrid_h
|
||||||
|
|
||||||
|
#include <vtkm/cont/Algorithm.h>
|
||||||
|
#include <vtkm/cont/ArrayCopy.h>
|
||||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||||
#include <vtkm/cont/DeviceAdapter.h>
|
|
||||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
|
||||||
#include <vtkm/cont/TryExecute.h>
|
|
||||||
#include <vtkm/worklet/DispatcherMapField.h>
|
#include <vtkm/worklet/DispatcherMapField.h>
|
||||||
#include <vtkm/worklet/WorkletMapField.h>
|
#include <vtkm/worklet/WorkletMapField.h>
|
||||||
|
|
||||||
@ -77,62 +76,29 @@ public:
|
|||||||
vtkm::Vec<vtkm::FloatDefault, 3> Dxdydz;
|
vtkm::Vec<vtkm::FloatDefault, 3> Dxdydz;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Construct a 3D uniform grid for nearest neighbor search.
|
|
||||||
///
|
|
||||||
/// \param coords An ArrayHandle of x, y, z coordinates of input points.
|
|
||||||
/// \param device Tag for selecting device adapter
|
|
||||||
|
|
||||||
struct BuildFunctor
|
|
||||||
{
|
|
||||||
BuildFunctor(vtkm::cont::PointLocatorUniformGrid* self)
|
|
||||||
: Self(self)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
bool operator()(Device)
|
|
||||||
{
|
|
||||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<Device>;
|
|
||||||
|
|
||||||
// Save training data points.
|
|
||||||
Algorithm::Copy(this->Self->GetCoordinates().GetData(), this->Self->coords);
|
|
||||||
|
|
||||||
// generate unique id for each input point
|
|
||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> pointCounting(
|
|
||||||
0, 1, this->Self->coords.GetNumberOfValues());
|
|
||||||
Algorithm::Copy(pointCounting, this->Self->pointIds);
|
|
||||||
|
|
||||||
// bin points into cells and give each of them the cell id.
|
|
||||||
BinPointsWorklet cellIdWorklet(this->Self->Min, this->Self->Max, this->Self->Dims);
|
|
||||||
vtkm::worklet::DispatcherMapField<BinPointsWorklet, Device> dispatchCellId(cellIdWorklet);
|
|
||||||
dispatchCellId.Invoke(this->Self->coords, this->Self->cellIds);
|
|
||||||
|
|
||||||
// Group points of the same cell together by sorting them according to the cell ids
|
|
||||||
Algorithm::SortByKey(this->Self->cellIds, this->Self->pointIds);
|
|
||||||
|
|
||||||
// for each cell, find the lower and upper bound of indices to the sorted point ids.
|
|
||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> cell_ids_counting(
|
|
||||||
0, 1, this->Self->Dims[0] * this->Self->Dims[1] * this->Self->Dims[2]);
|
|
||||||
Algorithm::UpperBounds(this->Self->cellIds, cell_ids_counting, this->Self->cellUpper);
|
|
||||||
Algorithm::LowerBounds(this->Self->cellIds, cell_ids_counting, this->Self->cellLower);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
vtkm::cont::PointLocatorUniformGrid* Self;
|
|
||||||
};
|
|
||||||
|
|
||||||
void Build() override
|
void Build() override
|
||||||
{
|
{
|
||||||
BuildFunctor functor(this);
|
// Save training data points.
|
||||||
|
vtkm::cont::ArrayCopy(this->GetCoordinates().GetData(), this->coords);
|
||||||
|
|
||||||
bool success = vtkm::cont::TryExecute(functor);
|
// generate unique id for each input point
|
||||||
if (!success)
|
vtkm::cont::ArrayHandleCounting<vtkm::Id> pointCounting(0, 1, this->coords.GetNumberOfValues());
|
||||||
{
|
vtkm::cont::ArrayCopy(pointCounting, this->pointIds);
|
||||||
throw vtkm::cont::ErrorExecution("Could not build point locator structure");
|
|
||||||
}
|
// bin points into cells and give each of them the cell id.
|
||||||
};
|
BinPointsWorklet cellIdWorklet(this->Min, this->Max, this->Dims);
|
||||||
|
vtkm::worklet::DispatcherMapField<BinPointsWorklet> dispatchCellId(cellIdWorklet);
|
||||||
|
dispatchCellId.Invoke(this->coords, this->cellIds);
|
||||||
|
|
||||||
|
// Group points of the same cell together by sorting them according to the cell ids
|
||||||
|
vtkm::cont::Algorithm::SortByKey(this->cellIds, this->pointIds);
|
||||||
|
|
||||||
|
// for each cell, find the lower and upper bound of indices to the sorted point ids.
|
||||||
|
vtkm::cont::ArrayHandleCounting<vtkm::Id> cell_ids_counting(
|
||||||
|
0, 1, this->Dims[0] * this->Dims[1] * this->Dims[2]);
|
||||||
|
vtkm::cont::Algorithm::UpperBounds(this->cellIds, cell_ids_counting, this->cellUpper);
|
||||||
|
vtkm::cont::Algorithm::LowerBounds(this->cellIds, cell_ids_counting, this->cellLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
using HandleType = vtkm::cont::VirtualObjectHandle<vtkm::exec::PointLocator>;
|
using HandleType = vtkm::cont::VirtualObjectHandle<vtkm::exec::PointLocator>;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
//Bring in each device adapters runtime class
|
//Bring in each device adapters runtime class
|
||||||
#include <vtkm/cont/cuda/internal/DeviceAdapterRuntimeDetectorCuda.h>
|
#include <vtkm/cont/cuda/internal/DeviceAdapterRuntimeDetectorCuda.h>
|
||||||
#include <vtkm/cont/internal/DeviceAdapterError.h>
|
#include <vtkm/cont/internal/DeviceAdapterError.h>
|
||||||
|
#include <vtkm/cont/openmp/internal/DeviceAdapterRuntimeDetectorOpenMP.h>
|
||||||
#include <vtkm/cont/serial/internal/DeviceAdapterRuntimeDetectorSerial.h>
|
#include <vtkm/cont/serial/internal/DeviceAdapterRuntimeDetectorSerial.h>
|
||||||
#include <vtkm/cont/tbb/internal/DeviceAdapterRuntimeDetectorTBB.h>
|
#include <vtkm/cont/tbb/internal/DeviceAdapterRuntimeDetectorTBB.h>
|
||||||
|
|
||||||
|
@ -34,6 +34,34 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
struct VTKM_NEVER_EXPORT GetDeviceNameFunctor
|
||||||
|
{
|
||||||
|
vtkm::cont::DeviceAdapterNameType* Names;
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
GetDeviceNameFunctor(vtkm::cont::DeviceAdapterNameType* names)
|
||||||
|
: Names(names)
|
||||||
|
{
|
||||||
|
std::fill_n(this->Names, VTKM_MAX_DEVICE_ADAPTER_ID, "InvalidDeviceId");
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Device>
|
||||||
|
VTKM_CONT void operator()(Device device)
|
||||||
|
{
|
||||||
|
auto id = device.GetValue();
|
||||||
|
|
||||||
|
if (id > 0 && id < VTKM_MAX_DEVICE_ADAPTER_ID)
|
||||||
|
{
|
||||||
|
this->Names[id] = vtkm::cont::DeviceAdapterTraits<Device>::GetName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end anon namespace
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm
|
||||||
{
|
{
|
||||||
namespace cont
|
namespace cont
|
||||||
@ -45,6 +73,7 @@ namespace detail
|
|||||||
struct RuntimeDeviceTrackerInternals
|
struct RuntimeDeviceTrackerInternals
|
||||||
{
|
{
|
||||||
bool RuntimeValid[VTKM_MAX_DEVICE_ADAPTER_ID];
|
bool RuntimeValid[VTKM_MAX_DEVICE_ADAPTER_ID];
|
||||||
|
DeviceAdapterNameType DeviceNames[VTKM_MAX_DEVICE_ADAPTER_ID];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +81,9 @@ VTKM_CONT
|
|||||||
RuntimeDeviceTracker::RuntimeDeviceTracker()
|
RuntimeDeviceTracker::RuntimeDeviceTracker()
|
||||||
: Internals(new detail::RuntimeDeviceTrackerInternals)
|
: Internals(new detail::RuntimeDeviceTrackerInternals)
|
||||||
{
|
{
|
||||||
|
GetDeviceNameFunctor functor(this->Internals->DeviceNames);
|
||||||
|
vtkm::ListForEach(functor, VTKM_DEFAULT_DEVICE_ADAPTER_LIST_TAG());
|
||||||
|
|
||||||
this->Reset();
|
this->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,31 +93,28 @@ RuntimeDeviceTracker::~RuntimeDeviceTracker()
|
|||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
void RuntimeDeviceTracker::CheckDevice(vtkm::cont::DeviceAdapterId deviceId,
|
void RuntimeDeviceTracker::CheckDevice(vtkm::cont::DeviceAdapterId deviceId) const
|
||||||
const vtkm::cont::DeviceAdapterNameType& deviceName) const
|
|
||||||
{
|
{
|
||||||
if (!deviceId.IsValueValid())
|
if (!deviceId.IsValueValid())
|
||||||
{
|
{
|
||||||
std::stringstream message;
|
std::stringstream message;
|
||||||
message << "Device '" << deviceName << "' has invalid ID of " << (int)deviceId.GetValue();
|
message << "Device '" << deviceId.GetName() << "' has invalid ID of "
|
||||||
|
<< (int)deviceId.GetValue();
|
||||||
throw vtkm::cont::ErrorBadValue(message.str());
|
throw vtkm::cont::ErrorBadValue(message.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
bool RuntimeDeviceTracker::CanRunOnImpl(vtkm::cont::DeviceAdapterId deviceId,
|
bool RuntimeDeviceTracker::CanRunOnImpl(vtkm::cont::DeviceAdapterId deviceId) const
|
||||||
const vtkm::cont::DeviceAdapterNameType& deviceName) const
|
|
||||||
{
|
{
|
||||||
this->CheckDevice(deviceId, deviceName);
|
this->CheckDevice(deviceId);
|
||||||
return this->Internals->RuntimeValid[deviceId.GetValue()];
|
return this->Internals->RuntimeValid[deviceId.GetValue()];
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
void RuntimeDeviceTracker::SetDeviceState(vtkm::cont::DeviceAdapterId deviceId,
|
void RuntimeDeviceTracker::SetDeviceState(vtkm::cont::DeviceAdapterId deviceId, bool state)
|
||||||
const vtkm::cont::DeviceAdapterNameType& deviceName,
|
|
||||||
bool state)
|
|
||||||
{
|
{
|
||||||
this->CheckDevice(deviceId, deviceName);
|
this->CheckDevice(deviceId);
|
||||||
this->Internals->RuntimeValid[deviceId.GetValue()] = state;
|
this->Internals->RuntimeValid[deviceId.GetValue()] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,18 +164,16 @@ void RuntimeDeviceTracker::DeepCopy(const vtkm::cont::RuntimeDeviceTracker& src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
void RuntimeDeviceTracker::ForceDeviceImpl(vtkm::cont::DeviceAdapterId deviceId,
|
void RuntimeDeviceTracker::ForceDeviceImpl(vtkm::cont::DeviceAdapterId deviceId, bool runtimeExists)
|
||||||
const vtkm::cont::DeviceAdapterNameType& deviceName,
|
|
||||||
bool runtimeExists)
|
|
||||||
{
|
{
|
||||||
if (!runtimeExists)
|
if (!runtimeExists)
|
||||||
{
|
{
|
||||||
std::stringstream message;
|
std::stringstream message;
|
||||||
message << "Cannot force to device '" << deviceName
|
message << "Cannot force to device '" << deviceId.GetName()
|
||||||
<< "' because that device is not available on this system";
|
<< "' because that device is not available on this system";
|
||||||
throw vtkm::cont::ErrorBadValue(message.str());
|
throw vtkm::cont::ErrorBadValue(message.str());
|
||||||
}
|
}
|
||||||
this->CheckDevice(deviceId, deviceName);
|
this->CheckDevice(deviceId);
|
||||||
|
|
||||||
std::fill_n(this->Internals->RuntimeValid, VTKM_MAX_DEVICE_ADAPTER_ID, false);
|
std::fill_n(this->Internals->RuntimeValid, VTKM_MAX_DEVICE_ADAPTER_ID, false);
|
||||||
|
|
||||||
@ -177,5 +204,41 @@ vtkm::cont::RuntimeDeviceTracker GetGlobalRuntimeDeviceTracker()
|
|||||||
return runtimeDeviceTracker;
|
return runtimeDeviceTracker;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VTKM_CONT
|
||||||
|
DeviceAdapterNameType RuntimeDeviceTracker::GetDeviceName(DeviceAdapterId device) const
|
||||||
|
{
|
||||||
|
auto id = device.GetValue();
|
||||||
|
|
||||||
|
if (id < 0)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case VTKM_DEVICE_ADAPTER_ERROR:
|
||||||
|
return vtkm::cont::DeviceAdapterTraits<vtkm::cont::DeviceAdapterTagError>::GetName();
|
||||||
|
case VTKM_DEVICE_ADAPTER_UNDEFINED:
|
||||||
|
return vtkm::cont::DeviceAdapterTraits<vtkm::cont::DeviceAdapterTagUndefined>::GetName();
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (id >= VTKM_MAX_DEVICE_ADAPTER_ID)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case VTKM_DEVICE_ADAPTER_ANY:
|
||||||
|
return vtkm::cont::DeviceAdapterTraits<vtkm::cont::DeviceAdapterTagAny>::GetName();
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // id is valid:
|
||||||
|
{
|
||||||
|
return this->Internals->DeviceNames[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Device 0 is invalid:
|
||||||
|
return this->Internals->DeviceNames[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // namespace vtkm::cont
|
} // namespace vtkm::cont
|
||||||
|
@ -64,8 +64,7 @@ public:
|
|||||||
template <typename DeviceAdapterTag>
|
template <typename DeviceAdapterTag>
|
||||||
VTKM_CONT bool CanRunOn(DeviceAdapterTag device) const
|
VTKM_CONT bool CanRunOn(DeviceAdapterTag device) const
|
||||||
{
|
{
|
||||||
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
|
return this->CanRunOnImpl(device);
|
||||||
return this->CanRunOnImpl(device, Traits::GetName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Report a failure to allocate memory on a device, this will flag the
|
/// Report a failure to allocate memory on a device, this will flag the
|
||||||
@ -76,8 +75,7 @@ public:
|
|||||||
VTKM_CONT void ReportAllocationFailure(DeviceAdapterTag device,
|
VTKM_CONT void ReportAllocationFailure(DeviceAdapterTag device,
|
||||||
const vtkm::cont::ErrorBadAllocation&)
|
const vtkm::cont::ErrorBadAllocation&)
|
||||||
{
|
{
|
||||||
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
|
this->SetDeviceState(device, false);
|
||||||
this->SetDeviceState(device, Traits::GetName(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Report a failure to allocate memory on a device, this will flag the
|
/// Report a failure to allocate memory on a device, this will flag the
|
||||||
@ -85,10 +83,9 @@ public:
|
|||||||
/// the filter.
|
/// the filter.
|
||||||
///
|
///
|
||||||
VTKM_CONT void ReportAllocationFailure(vtkm::cont::DeviceAdapterId deviceId,
|
VTKM_CONT void ReportAllocationFailure(vtkm::cont::DeviceAdapterId deviceId,
|
||||||
const std::string& name,
|
|
||||||
const vtkm::cont::ErrorBadAllocation&)
|
const vtkm::cont::ErrorBadAllocation&)
|
||||||
{
|
{
|
||||||
this->SetDeviceState(deviceId, name, false);
|
this->SetDeviceState(deviceId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
@ -96,15 +93,13 @@ public:
|
|||||||
template <typename DeviceAdapterTag>
|
template <typename DeviceAdapterTag>
|
||||||
VTKM_CONT void ReportBadDeviceFailure(DeviceAdapterTag device, const vtkm::cont::ErrorBadDevice&)
|
VTKM_CONT void ReportBadDeviceFailure(DeviceAdapterTag device, const vtkm::cont::ErrorBadDevice&)
|
||||||
{
|
{
|
||||||
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
|
this->SetDeviceState(device, false);
|
||||||
this->SetDeviceState(device, Traits::GetName(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT void ReportBadDeviceFailure(vtkm::cont::DeviceAdapterId deviceId,
|
VTKM_CONT void ReportBadDeviceFailure(vtkm::cont::DeviceAdapterId deviceId,
|
||||||
const std::string& name,
|
|
||||||
const vtkm::cont::ErrorBadDevice&)
|
const vtkm::cont::ErrorBadDevice&)
|
||||||
{
|
{
|
||||||
this->SetDeviceState(deviceId, name, false);
|
this->SetDeviceState(deviceId, false);
|
||||||
}
|
}
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
@ -114,9 +109,8 @@ public:
|
|||||||
template <typename DeviceAdapterTag>
|
template <typename DeviceAdapterTag>
|
||||||
VTKM_CONT void ResetDevice(DeviceAdapterTag device)
|
VTKM_CONT void ResetDevice(DeviceAdapterTag device)
|
||||||
{
|
{
|
||||||
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
|
|
||||||
vtkm::cont::RuntimeDeviceInformation<DeviceAdapterTag> runtimeDevice;
|
vtkm::cont::RuntimeDeviceInformation<DeviceAdapterTag> runtimeDevice;
|
||||||
this->SetDeviceState(device, Traits::GetName(), runtimeDevice.Exists());
|
this->SetDeviceState(device, runtimeDevice.Exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reset the tracker to its default state for default devices.
|
/// Reset the tracker to its default state for default devices.
|
||||||
@ -180,8 +174,7 @@ public:
|
|||||||
template <typename DeviceAdapterTag>
|
template <typename DeviceAdapterTag>
|
||||||
VTKM_CONT void DisableDevice(DeviceAdapterTag device)
|
VTKM_CONT void DisableDevice(DeviceAdapterTag device)
|
||||||
{
|
{
|
||||||
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
|
this->SetDeviceState(device, false);
|
||||||
this->SetDeviceState(device, Traits::GetName(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Disable all devices except the specified one.
|
/// \brief Disable all devices except the specified one.
|
||||||
@ -199,35 +192,32 @@ public:
|
|||||||
template <typename DeviceAdapterTag>
|
template <typename DeviceAdapterTag>
|
||||||
VTKM_CONT void ForceDevice(DeviceAdapterTag device)
|
VTKM_CONT void ForceDevice(DeviceAdapterTag device)
|
||||||
{
|
{
|
||||||
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceAdapterTag>;
|
|
||||||
vtkm::cont::RuntimeDeviceInformation<DeviceAdapterTag> runtimeDevice;
|
vtkm::cont::RuntimeDeviceInformation<DeviceAdapterTag> runtimeDevice;
|
||||||
this->ForceDeviceImpl(device, Traits::GetName(), runtimeDevice.Exists());
|
this->ForceDeviceImpl(device, runtimeDevice.Exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
VTKM_CONT
|
||||||
|
DeviceAdapterNameType GetDeviceName(DeviceAdapterId id) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<detail::RuntimeDeviceTrackerInternals> Internals;
|
std::shared_ptr<detail::RuntimeDeviceTrackerInternals> Internals;
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
void CheckDevice(vtkm::cont::DeviceAdapterId deviceId,
|
void CheckDevice(vtkm::cont::DeviceAdapterId deviceId) const;
|
||||||
const vtkm::cont::DeviceAdapterNameType& deviceName) const;
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
bool CanRunOnImpl(vtkm::cont::DeviceAdapterId deviceId,
|
bool CanRunOnImpl(vtkm::cont::DeviceAdapterId deviceId) const;
|
||||||
const vtkm::cont::DeviceAdapterNameType& deviceName) const;
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
void SetDeviceState(vtkm::cont::DeviceAdapterId deviceId,
|
void SetDeviceState(vtkm::cont::DeviceAdapterId deviceId, bool state);
|
||||||
const vtkm::cont::DeviceAdapterNameType& deviceName,
|
|
||||||
bool state);
|
|
||||||
|
|
||||||
VTKM_CONT_EXPORT
|
VTKM_CONT_EXPORT
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
void ForceDeviceImpl(vtkm::cont::DeviceAdapterId deviceId,
|
void ForceDeviceImpl(vtkm::cont::DeviceAdapterId deviceId, bool runtimeExists);
|
||||||
const vtkm::cont::DeviceAdapterNameType& deviceName,
|
|
||||||
bool runtimeExists);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Get the \c RuntimeDeviceTracker for the current thread.
|
/// \brief Get the \c RuntimeDeviceTracker for the current thread.
|
||||||
|
@ -32,7 +32,6 @@ namespace detail
|
|||||||
{
|
{
|
||||||
|
|
||||||
void HandleTryExecuteException(vtkm::cont::DeviceAdapterId deviceId,
|
void HandleTryExecuteException(vtkm::cont::DeviceAdapterId deviceId,
|
||||||
const std::string& name,
|
|
||||||
vtkm::cont::RuntimeDeviceTracker& tracker)
|
vtkm::cont::RuntimeDeviceTracker& tracker)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -45,12 +44,12 @@ void HandleTryExecuteException(vtkm::cont::DeviceAdapterId deviceId,
|
|||||||
std::cerr << "caught ErrorBadAllocation " << e.GetMessage() << std::endl;
|
std::cerr << "caught ErrorBadAllocation " << e.GetMessage() << std::endl;
|
||||||
//currently we only consider OOM errors worth disabling a device for
|
//currently we only consider OOM errors worth disabling a device for
|
||||||
//than we fallback to another device
|
//than we fallback to another device
|
||||||
tracker.ReportAllocationFailure(deviceId, name, e);
|
tracker.ReportAllocationFailure(deviceId, e);
|
||||||
}
|
}
|
||||||
catch (vtkm::cont::ErrorBadDevice& e)
|
catch (vtkm::cont::ErrorBadDevice& e)
|
||||||
{
|
{
|
||||||
std::cerr << "caught ErrorBadDevice: " << e.GetMessage() << std::endl;
|
std::cerr << "caught ErrorBadDevice: " << e.GetMessage() << std::endl;
|
||||||
tracker.ReportBadDeviceFailure(deviceId, name, e);
|
tracker.ReportBadDeviceFailure(deviceId, e);
|
||||||
}
|
}
|
||||||
catch (vtkm::cont::ErrorBadType& e)
|
catch (vtkm::cont::ErrorBadType& e)
|
||||||
{
|
{
|
||||||
@ -58,11 +57,11 @@ void HandleTryExecuteException(vtkm::cont::DeviceAdapterId deviceId,
|
|||||||
//deferring to another device adapter?
|
//deferring to another device adapter?
|
||||||
std::cerr << "caught ErrorBadType : " << e.GetMessage() << std::endl;
|
std::cerr << "caught ErrorBadType : " << e.GetMessage() << std::endl;
|
||||||
}
|
}
|
||||||
catch (vtkm::cont::ErrorBadValue& e)
|
catch (vtkm::cont::ErrorBadValue&)
|
||||||
{
|
{
|
||||||
//should bad value errors should stop the filter, instead of deferring
|
// Should bad values be deferred to another device? Seems unlikely they will succeed.
|
||||||
//to another device adapter?
|
// Re-throw instead.
|
||||||
std::cerr << "caught ErrorBadValue : " << e.GetMessage() << std::endl;
|
throw;
|
||||||
}
|
}
|
||||||
catch (vtkm::cont::Error& e)
|
catch (vtkm::cont::Error& e)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,6 @@ namespace detail
|
|||||||
{
|
{
|
||||||
|
|
||||||
VTKM_CONT_EXPORT void HandleTryExecuteException(vtkm::cont::DeviceAdapterId,
|
VTKM_CONT_EXPORT void HandleTryExecuteException(vtkm::cont::DeviceAdapterId,
|
||||||
const std::string&,
|
|
||||||
vtkm::cont::RuntimeDeviceTracker&);
|
vtkm::cont::RuntimeDeviceTracker&);
|
||||||
|
|
||||||
template <typename DeviceTag, typename Functor, typename... Args>
|
template <typename DeviceTag, typename Functor, typename... Args>
|
||||||
@ -44,7 +43,7 @@ inline bool TryExecuteIfValid(std::true_type,
|
|||||||
vtkm::cont::RuntimeDeviceTracker& tracker,
|
vtkm::cont::RuntimeDeviceTracker& tracker,
|
||||||
Args&&... args)
|
Args&&... args)
|
||||||
{
|
{
|
||||||
if ((tag == devId || devId == DeviceAdapterIdAny()) && tracker.CanRunOn(tag))
|
if ((tag == devId || devId == DeviceAdapterTagAny()) && tracker.CanRunOn(tag))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -52,8 +51,7 @@ inline bool TryExecuteIfValid(std::true_type,
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
using Traits = vtkm::cont::DeviceAdapterTraits<DeviceTag>;
|
detail::HandleTryExecuteException(tag, tracker);
|
||||||
detail::HandleTryExecuteException(tag, Traits::GetName(), tracker);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +342,7 @@ template <typename Functor, typename... Args>
|
|||||||
VTKM_CONT bool TryExecute(Functor&& functor, Args&&... args)
|
VTKM_CONT bool TryExecute(Functor&& functor, Args&&... args)
|
||||||
{
|
{
|
||||||
return TryExecuteOnDevice(
|
return TryExecuteOnDevice(
|
||||||
vtkm::cont::DeviceAdapterIdAny(), std::forward<Functor>(functor), std::forward<Args>(args)...);
|
vtkm::cont::DeviceAdapterTagAny(), std::forward<Functor>(functor), std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,9 +131,9 @@ public:
|
|||||||
if (!this->Internals->Transfers[static_cast<std::size_t>(deviceId.GetValue())])
|
if (!this->Internals->Transfers[static_cast<std::size_t>(deviceId.GetValue())])
|
||||||
{
|
{
|
||||||
std::string msg =
|
std::string msg =
|
||||||
"VTK-m was asked to transfer a VirtualObjectHandle for execution on DeviceAdapter " +
|
"VTK-m was asked to transfer a VirtualObjectHandle for execution on DeviceAdapter '" +
|
||||||
std::to_string(deviceId.GetValue()) +
|
deviceId.GetName() + "' (" + std::to_string(deviceId.GetValue()) +
|
||||||
". It can't as this VirtualObjectHandle was not constructed/bound with this "
|
"). It can't as this VirtualObjectHandle was not constructed/bound with this "
|
||||||
"DeviceAdapter in the list of valid DeviceAdapters.";
|
"DeviceAdapter in the list of valid DeviceAdapters.";
|
||||||
throw vtkm::cont::ErrorBadDevice(msg);
|
throw vtkm::cont::ErrorBadDevice(msg);
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,10 @@ public:
|
|||||||
T* lockedValue = ::thrust::raw_pointer_cast(this->Portal.GetIteratorBegin() + index);
|
T* lockedValue = ::thrust::raw_pointer_cast(this->Portal.GetIteratorBegin() + index);
|
||||||
return this->vtkmAtomicAdd(lockedValue, value);
|
return this->vtkmAtomicAdd(lockedValue, value);
|
||||||
#else
|
#else
|
||||||
|
// Shut up, compiler
|
||||||
|
(void)index;
|
||||||
|
(void)value;
|
||||||
|
|
||||||
throw vtkm::cont::ErrorExecution("AtomicArray used in control environment, "
|
throw vtkm::cont::ErrorExecution("AtomicArray used in control environment, "
|
||||||
"or incorrect array implementation used "
|
"or incorrect array implementation used "
|
||||||
"for device.");
|
"for device.");
|
||||||
@ -85,6 +89,11 @@ public:
|
|||||||
T* lockedValue = ::thrust::raw_pointer_cast(this->Portal.GetIteratorBegin() + index);
|
T* lockedValue = ::thrust::raw_pointer_cast(this->Portal.GetIteratorBegin() + index);
|
||||||
return this->vtkmCompareAndSwap(lockedValue, newValue, oldValue);
|
return this->vtkmCompareAndSwap(lockedValue, newValue, oldValue);
|
||||||
#else
|
#else
|
||||||
|
// Shut up, compiler.
|
||||||
|
(void)index;
|
||||||
|
(void)newValue;
|
||||||
|
(void)oldValue;
|
||||||
|
|
||||||
throw vtkm::cont::ErrorExecution("AtomicArray used in control environment, "
|
throw vtkm::cont::ErrorExecution("AtomicArray used in control environment, "
|
||||||
"or incorrect array implementation used "
|
"or incorrect array implementation used "
|
||||||
"for device.");
|
"for device.");
|
||||||
|
@ -92,7 +92,7 @@ struct TriggerICE : public vtkm::worklet::WorkletMapField
|
|||||||
template <class ValueType>
|
template <class ValueType>
|
||||||
ValueType operator()(const ValueType& bad, const ValueType& sane, const vtkm::Id sequenceId) const
|
ValueType operator()(const ValueType& bad, const ValueType& sane, const vtkm::Id sequenceId) const
|
||||||
{
|
{
|
||||||
return bad + sane * sequenceId;
|
return bad + sane * static_cast<ValueType>(sequenceId);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -156,7 +156,8 @@ void RunEdgeCases()
|
|||||||
auto bad = vtkm::cont::make_ArrayHandle(badvalues);
|
auto bad = vtkm::cont::make_ArrayHandle(badvalues);
|
||||||
auto sane = vtkm::cont::make_ArrayHandle(sanevalues);
|
auto sane = vtkm::cont::make_ArrayHandle(sanevalues);
|
||||||
decltype(sane) result;
|
decltype(sane) result;
|
||||||
vtkm::worklet::DispatcherMapField<TriggerICE, Device> dispatcher;
|
vtkm::worklet::DispatcherMapField<TriggerICE> dispatcher;
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
dispatcher.Invoke(bad, sane, result);
|
dispatcher.Invoke(bad, sane, result);
|
||||||
|
|
||||||
auto portal = result.GetPortalConstControl();
|
auto portal = result.GetPortalConstControl();
|
||||||
|
@ -250,7 +250,7 @@ bool ArrayHandleImpl::PrepareForDevice(DeviceAdapterId devId, vtkm::UInt64 sizeO
|
|||||||
DeviceAdapterId ArrayHandleImpl::GetDeviceAdapterId() const
|
DeviceAdapterId ArrayHandleImpl::GetDeviceAdapterId() const
|
||||||
{
|
{
|
||||||
return this->ExecutionArrayValid ? this->ExecutionInterface->GetDeviceId()
|
return this->ExecutionArrayValid ? this->ExecutionInterface->GetDeviceId()
|
||||||
: DeviceAdapterIdUndefined{};
|
: DeviceAdapterTagUndefined{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
35
vtkm/cont/internal/DeviceAdapterTag.cxx
Normal file
35
vtkm/cont/internal/DeviceAdapterTag.cxx
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
//============================================================================
|
||||||
|
// Copyright (c) Kitware, Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
// See LICENSE.txt for details.
|
||||||
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||||
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE. See the above copyright notice for more information.
|
||||||
|
//
|
||||||
|
// Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
||||||
|
// Copyright 2018 UT-Battelle, LLC.
|
||||||
|
// Copyright 2018 Los Alamos National Security.
|
||||||
|
//
|
||||||
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||||
|
// the U.S. Government retains certain rights in this software.
|
||||||
|
//
|
||||||
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||||
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||||
|
// this software.
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||||
|
|
||||||
|
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace cont
|
||||||
|
{
|
||||||
|
|
||||||
|
DeviceAdapterNameType DeviceAdapterId::GetName() const
|
||||||
|
{
|
||||||
|
return vtkm::cont::GetGlobalRuntimeDeviceTracker().GetDeviceName(*this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // end namespace vtkm::cont
|
@ -25,6 +25,8 @@
|
|||||||
#include <vtkm/internal/Configure.h>
|
#include <vtkm/internal/Configure.h>
|
||||||
#include <vtkm/internal/ExportMacros.h>
|
#include <vtkm/internal/ExportMacros.h>
|
||||||
|
|
||||||
|
#include <vtkm/cont/vtkm_cont_export.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define VTKM_DEVICE_ADAPTER_ERROR -2
|
#define VTKM_DEVICE_ADAPTER_ERROR -2
|
||||||
@ -42,6 +44,8 @@ namespace vtkm
|
|||||||
namespace cont
|
namespace cont
|
||||||
{
|
{
|
||||||
|
|
||||||
|
using DeviceAdapterNameType = std::string;
|
||||||
|
|
||||||
struct DeviceAdapterId
|
struct DeviceAdapterId
|
||||||
{
|
{
|
||||||
constexpr bool operator==(DeviceAdapterId other) const { return this->Value == other.Value; }
|
constexpr bool operator==(DeviceAdapterId other) const { return this->Value == other.Value; }
|
||||||
@ -55,6 +59,9 @@ struct DeviceAdapterId
|
|||||||
|
|
||||||
constexpr vtkm::Int8 GetValue() const { return this->Value; }
|
constexpr vtkm::Int8 GetValue() const { return this->Value; }
|
||||||
|
|
||||||
|
VTKM_CONT_EXPORT
|
||||||
|
DeviceAdapterNameType GetName() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
constexpr explicit DeviceAdapterId(vtkm::Int8 id)
|
constexpr explicit DeviceAdapterId(vtkm::Int8 id)
|
||||||
: Value(id)
|
: Value(id)
|
||||||
@ -65,27 +72,6 @@ private:
|
|||||||
vtkm::Int8 Value;
|
vtkm::Int8 Value;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Represents when using TryExecute that the functor
|
|
||||||
// can be executed on any device instead of a specific
|
|
||||||
// one
|
|
||||||
struct DeviceAdapterIdAny : DeviceAdapterId
|
|
||||||
{
|
|
||||||
constexpr DeviceAdapterIdAny()
|
|
||||||
: DeviceAdapterId(127)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DeviceAdapterIdUndefined : DeviceAdapterId
|
|
||||||
{
|
|
||||||
constexpr DeviceAdapterIdUndefined()
|
|
||||||
: DeviceAdapterId(VTKM_DEVICE_ADAPTER_UNDEFINED)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
using DeviceAdapterNameType = std::string;
|
|
||||||
|
|
||||||
template <typename DeviceAdapter>
|
template <typename DeviceAdapter>
|
||||||
struct DeviceAdapterTraits;
|
struct DeviceAdapterTraits;
|
||||||
}
|
}
|
||||||
@ -139,6 +125,13 @@ struct DeviceAdapterTraits;
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Represents when using TryExecute that the functor
|
||||||
|
// can be executed on any device instead of a specific
|
||||||
|
// one
|
||||||
|
VTKM_VALID_DEVICE_ADAPTER(Any, VTKM_DEVICE_ADAPTER_ANY)
|
||||||
|
|
||||||
|
VTKM_INVALID_DEVICE_ADAPTER(Undefined, VTKM_DEVICE_ADAPTER_UNDEFINED)
|
||||||
|
|
||||||
/// Checks that the argument is a proper device adapter tag. This is a handy
|
/// Checks that the argument is a proper device adapter tag. This is a handy
|
||||||
/// concept check for functions and classes to make sure that a template
|
/// concept check for functions and classes to make sure that a template
|
||||||
/// argument is actually a device adapter tag. (You can get weird errors
|
/// argument is actually a device adapter tag. (You can get weird errors
|
||||||
|
@ -73,6 +73,7 @@ set(unit_tests
|
|||||||
UnitTestFieldRangeCompute.cxx
|
UnitTestFieldRangeCompute.cxx
|
||||||
UnitTestMultiBlock.cxx
|
UnitTestMultiBlock.cxx
|
||||||
UnitTestRuntimeDeviceInformation.cxx
|
UnitTestRuntimeDeviceInformation.cxx
|
||||||
|
UnitTestRuntimeDeviceNames.cxx
|
||||||
UnitTestStorageBasic.cxx
|
UnitTestStorageBasic.cxx
|
||||||
UnitTestStorageImplicit.cxx
|
UnitTestStorageImplicit.cxx
|
||||||
UnitTestStorageListTag.cxx
|
UnitTestStorageListTag.cxx
|
||||||
|
@ -63,12 +63,11 @@ struct DoubleWorklet : public vtkm::worklet::WorkletMapField
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename S, typename DeviceAdapter>
|
template <typename T, typename S>
|
||||||
inline void TestVirtualAccess(const vtkm::cont::ArrayHandle<T, S>& in,
|
inline void TestVirtualAccess(const vtkm::cont::ArrayHandle<T, S>& in,
|
||||||
vtkm::cont::ArrayHandle<T>& out,
|
vtkm::cont::ArrayHandle<T>& out)
|
||||||
DeviceAdapter)
|
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<CopyWorklet, DeviceAdapter>().Invoke(
|
vtkm::worklet::DispatcherMapField<CopyWorklet>().Invoke(
|
||||||
vtkm::cont::ArrayHandleVirtualCoordinates(in), vtkm::cont::ArrayHandleVirtualCoordinates(out));
|
vtkm::cont::ArrayHandleVirtualCoordinates(in), vtkm::cont::ArrayHandleVirtualCoordinates(out));
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(test_equal_portals(in.GetPortalConstControl(), out.GetPortalConstControl()),
|
VTKM_TEST_ASSERT(test_equal_portals(in.GetPortalConstControl(), out.GetPortalConstControl()),
|
||||||
@ -103,11 +102,11 @@ private:
|
|||||||
{
|
{
|
||||||
a1.GetPortalControl().Set(i, TestValue(i, PointType()));
|
a1.GetPortalControl().Set(i, TestValue(i, PointType()));
|
||||||
}
|
}
|
||||||
TestVirtualAccess(a1, out, DeviceAdapter{});
|
TestVirtualAccess(a1, out);
|
||||||
|
|
||||||
std::cout << "Testing ArrayHandleUniformPointCoordinates as input\n";
|
std::cout << "Testing ArrayHandleUniformPointCoordinates as input\n";
|
||||||
auto t = vtkm::cont::ArrayHandleUniformPointCoordinates(vtkm::Id3(4, 4, 4));
|
auto t = vtkm::cont::ArrayHandleUniformPointCoordinates(vtkm::Id3(4, 4, 4));
|
||||||
TestVirtualAccess(t, out, DeviceAdapter{});
|
TestVirtualAccess(t, out);
|
||||||
|
|
||||||
std::cout << "Testing ArrayHandleCartesianProduct as input\n";
|
std::cout << "Testing ArrayHandleCartesianProduct as input\n";
|
||||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> c1, c2, c3;
|
vtkm::cont::ArrayHandle<vtkm::FloatDefault> c1, c2, c3;
|
||||||
@ -121,13 +120,12 @@ private:
|
|||||||
c2.GetPortalControl().Set(i, p[1]);
|
c2.GetPortalControl().Set(i, p[1]);
|
||||||
c3.GetPortalControl().Set(i, p[2]);
|
c3.GetPortalControl().Set(i, p[2]);
|
||||||
}
|
}
|
||||||
TestVirtualAccess(
|
TestVirtualAccess(vtkm::cont::make_ArrayHandleCartesianProduct(c1, c2, c3), out);
|
||||||
vtkm::cont::make_ArrayHandleCartesianProduct(c1, c2, c3), out, DeviceAdapter{});
|
|
||||||
|
|
||||||
std::cout << "Testing resources releasing on ArrayHandleVirtualCoordinates\n";
|
std::cout << "Testing resources releasing on ArrayHandleVirtualCoordinates\n";
|
||||||
vtkm::cont::ArrayHandleVirtualCoordinates virtualC =
|
vtkm::cont::ArrayHandleVirtualCoordinates virtualC =
|
||||||
vtkm::cont::ArrayHandleVirtualCoordinates(a1);
|
vtkm::cont::ArrayHandleVirtualCoordinates(a1);
|
||||||
vtkm::worklet::DispatcherMapField<DoubleWorklet, DeviceAdapter>().Invoke(a1);
|
vtkm::worklet::DispatcherMapField<DoubleWorklet>().Invoke(a1);
|
||||||
virtualC.ReleaseResourcesExecution();
|
virtualC.ReleaseResourcesExecution();
|
||||||
VTKM_TEST_ASSERT(a1.GetNumberOfValues() == length,
|
VTKM_TEST_ASSERT(a1.GetNumberOfValues() == length,
|
||||||
"ReleaseResourcesExecution"
|
"ReleaseResourcesExecution"
|
||||||
@ -143,7 +141,11 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static int Run() { return vtkm::cont::testing::Testing::Run(TestAll); }
|
static int Run()
|
||||||
|
{
|
||||||
|
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(DeviceAdapter());
|
||||||
|
return vtkm::cont::testing::Testing::Run(TestAll);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <vtkm/TypeTraits.h>
|
#include <vtkm/TypeTraits.h>
|
||||||
#include <vtkm/cont/ArrayHandle.h>
|
#include <vtkm/cont/ArrayHandle.h>
|
||||||
|
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||||
|
|
||||||
#include <vtkm/worklet/DispatcherMapField.h>
|
#include <vtkm/worklet/DispatcherMapField.h>
|
||||||
#include <vtkm/worklet/WorkletMapField.h>
|
#include <vtkm/worklet/WorkletMapField.h>
|
||||||
@ -135,7 +136,7 @@ private:
|
|||||||
|
|
||||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>;
|
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>;
|
||||||
|
|
||||||
using DispatcherPassThrough = vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag>;
|
using DispatcherPassThrough = vtkm::worklet::DispatcherMapField<PassThrough>;
|
||||||
struct VerifyEmptyArrays
|
struct VerifyEmptyArrays
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -455,7 +456,11 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static VTKM_CONT int Run() { return vtkm::cont::testing::Testing::Run(TryArrayHandleType()); }
|
static VTKM_CONT int Run()
|
||||||
|
{
|
||||||
|
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(DeviceAdapterTag());
|
||||||
|
return vtkm::cont::testing::Testing::Run(TryArrayHandleType());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ vtkm::cont::DataSet MakeTestDataSet(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dims,
|
|||||||
cellset = vtkm::worklet::Triangulate().Run(uniformCs, device);
|
cellset = vtkm::worklet::Triangulate().Run(uniformCs, device);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
cellset = vtkm::worklet::Tetrahedralize().Run(uniformCs, device);
|
cellset = vtkm::worklet::Tetrahedralize().Run(uniformCs);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
VTKM_ASSERT(false);
|
VTKM_ASSERT(false);
|
||||||
@ -181,8 +181,9 @@ void GenerateRandomInput(const vtkm::cont::DataSet& ds,
|
|||||||
pcoords.GetPortalControl().Set(i, pc);
|
pcoords.GetPortalControl().Set(i, pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapTopology<ParametricToWorldCoordinates, DeviceAdapter> dispatcher(
|
vtkm::worklet::DispatcherMapTopology<ParametricToWorldCoordinates> dispatcher(
|
||||||
ParametricToWorldCoordinates::MakeScatter(cellIds));
|
ParametricToWorldCoordinates::MakeScatter(cellIds));
|
||||||
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
dispatcher.Invoke(ds.GetCellSet(), ds.GetCoordinateSystem().GetData(), pcoords, wcoords);
|
dispatcher.Invoke(ds.GetCellSet(), ds.GetCoordinateSystem().GetData(), pcoords, wcoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +134,9 @@ public:
|
|||||||
vtkm::cont::ArrayHandle<PointType> parametric;
|
vtkm::cont::ArrayHandle<PointType> parametric;
|
||||||
vtkm::cont::ArrayHandle<bool> match;
|
vtkm::cont::ArrayHandle<bool> match;
|
||||||
LocatorWorklet worklet(bounds, dims);
|
LocatorWorklet worklet(bounds, dims);
|
||||||
vtkm::worklet::DispatcherMapField<LocatorWorklet, DeviceAdapter> dispather(worklet);
|
vtkm::worklet::DispatcherMapField<LocatorWorklet> dispatcher(worklet);
|
||||||
dispather.Invoke(points, locator, cellIds, parametric, match);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
dispatcher.Invoke(points, locator, cellIds, parametric, match);
|
||||||
|
|
||||||
auto matchPortal = match.GetPortalConstControl();
|
auto matchPortal = match.GetPortalConstControl();
|
||||||
for (vtkm::Id index = 0; index < match.GetNumberOfValues(); index++)
|
for (vtkm::Id index = 0; index < match.GetNumberOfValues(); index++)
|
||||||
|
@ -461,7 +461,8 @@ public:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>> colors;
|
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>> colors;
|
||||||
TransferFunction transfer(table.PrepareForExecution(DeviceAdapterTag{}));
|
TransferFunction transfer(table.PrepareForExecution(DeviceAdapterTag{}));
|
||||||
vtkm::worklet::DispatcherMapField<TransferFunction, DeviceAdapterTag> dispatcher(transfer);
|
vtkm::worklet::DispatcherMapField<TransferFunction> dispatcher(transfer);
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
dispatcher.Invoke(samples, colors);
|
dispatcher.Invoke(samples, colors);
|
||||||
|
|
||||||
const vtkm::Vec<vtkm::UInt8, 4> correct_sampling_points[nvals] = { { 14, 28, 31, 255 },
|
const vtkm::Vec<vtkm::UInt8, 4> correct_sampling_points[nvals] = { { 14, 28, 31, 255 },
|
||||||
|
@ -139,7 +139,8 @@ private:
|
|||||||
|
|
||||||
//run a basic for-each topology algorithm on this
|
//run a basic for-each topology algorithm on this
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
vtkm::cont::ArrayHandle<vtkm::Float32> result;
|
||||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
dispatcher.Invoke(cellset, dataSet.GetField("pointvar"), result);
|
dispatcher.Invoke(cellset, dataSet.GetField("pointvar"), result);
|
||||||
|
|
||||||
vtkm::Float32 expected[3] = { 20.1333f, 30.1667f, 40.2333f };
|
vtkm::Float32 expected[3] = { 20.1333f, 30.1667f, 40.2333f };
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||||
#include <vtkm/cont/ArrayHandlePermutation.h>
|
#include <vtkm/cont/ArrayHandlePermutation.h>
|
||||||
#include <vtkm/cont/ArrayHandleTransform.h>
|
#include <vtkm/cont/ArrayHandleTransform.h>
|
||||||
|
#include <vtkm/cont/ArrayHandleView.h>
|
||||||
#include <vtkm/cont/ArrayHandleZip.h>
|
#include <vtkm/cont/ArrayHandleZip.h>
|
||||||
|
|
||||||
#include <vtkm/worklet/DispatcherMapField.h>
|
#include <vtkm/worklet/DispatcherMapField.h>
|
||||||
@ -167,7 +168,7 @@ private:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<ValueType, 3>> result;
|
vtkm::cont::ArrayHandle<vtkm::Vec<ValueType, 3>> result;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(composite, result);
|
dispatcher.Invoke(composite, result);
|
||||||
|
|
||||||
//verify that the control portal works
|
//verify that the control portal works
|
||||||
@ -195,7 +196,7 @@ private:
|
|||||||
vtkm::cont::make_ArrayHandleConstant(value, ARRAY_SIZE);
|
vtkm::cont::make_ArrayHandleConstant(value, ARRAY_SIZE);
|
||||||
vtkm::cont::ArrayHandle<ValueType> result;
|
vtkm::cont::ArrayHandle<ValueType> result;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(constant, result);
|
dispatcher.Invoke(constant, result);
|
||||||
|
|
||||||
vtkm::cont::printSummary_ArrayHandle(constant, std::cout);
|
vtkm::cont::printSummary_ArrayHandle(constant, std::cout);
|
||||||
@ -230,7 +231,7 @@ private:
|
|||||||
vtkm::cont::make_ArrayHandleCounting(start, ValueType(1), length);
|
vtkm::cont::make_ArrayHandleCounting(start, ValueType(1), length);
|
||||||
vtkm::cont::ArrayHandle<ValueType> result;
|
vtkm::cont::ArrayHandle<ValueType> result;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(counting, result);
|
dispatcher.Invoke(counting, result);
|
||||||
|
|
||||||
vtkm::cont::printSummary_ArrayHandle(counting, std::cout);
|
vtkm::cont::printSummary_ArrayHandle(counting, std::cout);
|
||||||
@ -266,7 +267,7 @@ private:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<ValueType> result;
|
vtkm::cont::ArrayHandle<ValueType> result;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(implicit, result);
|
dispatcher.Invoke(implicit, result);
|
||||||
|
|
||||||
//verify that the control portal works
|
//verify that the control portal works
|
||||||
@ -319,7 +320,7 @@ private:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<ValueType> result;
|
vtkm::cont::ArrayHandle<ValueType> result;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(concatenate, result);
|
dispatcher.Invoke(concatenate, result);
|
||||||
|
|
||||||
//verify that the control portal works
|
//verify that the control portal works
|
||||||
@ -373,7 +374,7 @@ private:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<ValueType> result;
|
vtkm::cont::ArrayHandle<ValueType> result;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(permutation, result);
|
dispatcher.Invoke(permutation, result);
|
||||||
|
|
||||||
//verify that the control portal works
|
//verify that the control portal works
|
||||||
@ -392,6 +393,52 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TestViewAsInput
|
||||||
|
{
|
||||||
|
template <typename ValueType>
|
||||||
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
||||||
|
{
|
||||||
|
const vtkm::Id length = ARRAY_SIZE;
|
||||||
|
|
||||||
|
using FunctorType = ::fancy_array_detail::IndexSquared<ValueType>;
|
||||||
|
|
||||||
|
using ValueHandleType = vtkm::cont::ArrayHandleImplicit<FunctorType>;
|
||||||
|
using ViewHandleType = vtkm::cont::ArrayHandleView<ValueHandleType>;
|
||||||
|
|
||||||
|
FunctorType functor;
|
||||||
|
for (vtkm::Id start_pos = 0; start_pos < length; start_pos += length / 4)
|
||||||
|
{
|
||||||
|
const vtkm::Id counting_length = length - start_pos;
|
||||||
|
|
||||||
|
ValueHandleType implicit = vtkm::cont::make_ArrayHandleImplicit(functor, length);
|
||||||
|
|
||||||
|
ViewHandleType view =
|
||||||
|
vtkm::cont::make_ArrayHandleView(implicit, start_pos, counting_length);
|
||||||
|
|
||||||
|
vtkm::cont::printSummary_ArrayHandle(view, std::cout);
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> result;
|
||||||
|
|
||||||
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
|
dispatcher.Invoke(view, result);
|
||||||
|
|
||||||
|
//verify that the control portal works
|
||||||
|
for (vtkm::Id i = 0; i < counting_length; ++i)
|
||||||
|
{
|
||||||
|
const vtkm::Id value_index = i;
|
||||||
|
const vtkm::Id key_index = start_pos + i;
|
||||||
|
|
||||||
|
const ValueType result_v = result.GetPortalConstControl().Get(value_index);
|
||||||
|
const ValueType correct_value = implicit.GetPortalConstControl().Get(key_index);
|
||||||
|
const ValueType control_value = view.GetPortalConstControl().Get(value_index);
|
||||||
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "Implicit Handle Failed");
|
||||||
|
VTKM_TEST_ASSERT(test_equal(result_v, control_value), "Implicit Handle Failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct TestTransformAsInput
|
struct TestTransformAsInput
|
||||||
{
|
{
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
@ -414,7 +461,7 @@ private:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<ValueType> result;
|
vtkm::cont::ArrayHandle<ValueType> result;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(transformed, result);
|
dispatcher.Invoke(transformed, result);
|
||||||
|
|
||||||
//verify that the control portal works
|
//verify that the control portal works
|
||||||
@ -456,7 +503,7 @@ private:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<OutputValueType> result;
|
vtkm::cont::ArrayHandle<OutputValueType> result;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(countingTransformed, result);
|
dispatcher.Invoke(countingTransformed, result);
|
||||||
|
|
||||||
//verify that the control portal works
|
//verify that the control portal works
|
||||||
@ -485,7 +532,7 @@ private:
|
|||||||
vtkm::cont::make_ArrayHandleCast(input, CastToType());
|
vtkm::cont::make_ArrayHandleCast(input, CastToType());
|
||||||
vtkm::cont::ArrayHandle<CastToType> result;
|
vtkm::cont::ArrayHandle<CastToType> result;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(castArray, result);
|
dispatcher.Invoke(castArray, result);
|
||||||
|
|
||||||
vtkm::cont::printSummary_ArrayHandle(castArray, std::cout);
|
vtkm::cont::printSummary_ArrayHandle(castArray, std::cout);
|
||||||
@ -529,7 +576,7 @@ private:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<ValueType> resultArray;
|
vtkm::cont::ArrayHandle<ValueType> resultArray;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(groupArray, resultArray);
|
dispatcher.Invoke(groupArray, resultArray);
|
||||||
|
|
||||||
VTKM_TEST_ASSERT(resultArray.GetNumberOfValues() == ARRAY_SIZE, "Got bad result array size.");
|
VTKM_TEST_ASSERT(resultArray.GetNumberOfValues() == ARRAY_SIZE, "Got bad result array size.");
|
||||||
@ -568,7 +615,7 @@ private:
|
|||||||
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<ComponentType>, NUM_COMPONENTS>
|
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<ComponentType>, NUM_COMPONENTS>
|
||||||
groupArray(resultArray);
|
groupArray(resultArray);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(baseArray, groupArray);
|
dispatcher.Invoke(baseArray, groupArray);
|
||||||
|
|
||||||
vtkm::cont::printSummary_ArrayHandle(groupArray, std::cout);
|
vtkm::cont::printSummary_ArrayHandle(groupArray, std::cout);
|
||||||
@ -649,7 +696,7 @@ private:
|
|||||||
vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray), std::cout);
|
vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray), std::cout);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<GroupVariableInputWorklet, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<GroupVariableInputWorklet> dispatcher;
|
||||||
dispatcher.Invoke(vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray));
|
dispatcher.Invoke(vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -695,7 +742,7 @@ private:
|
|||||||
vtkm::cont::ArrayHandle<ComponentType> sourceArray;
|
vtkm::cont::ArrayHandle<ComponentType> sourceArray;
|
||||||
sourceArray.Allocate(sourceArraySize);
|
sourceArray.Allocate(sourceArraySize);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<GroupVariableOutputWorklet, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<GroupVariableOutputWorklet> dispatcher;
|
||||||
dispatcher.Invoke(vtkm::cont::ArrayHandleIndex(ARRAY_SIZE),
|
dispatcher.Invoke(vtkm::cont::ArrayHandleIndex(ARRAY_SIZE),
|
||||||
vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray));
|
vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray));
|
||||||
|
|
||||||
@ -739,7 +786,7 @@ private:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<PairType> result;
|
vtkm::cont::ArrayHandle<PairType> result;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(zip, result);
|
dispatcher.Invoke(zip, result);
|
||||||
|
|
||||||
//verify that the control portal works
|
//verify that the control portal works
|
||||||
@ -776,7 +823,7 @@ private:
|
|||||||
DiscardHandleType discard;
|
DiscardHandleType discard;
|
||||||
discard.Allocate(length);
|
discard.Allocate(length);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(input, discard);
|
dispatcher.Invoke(input, discard);
|
||||||
|
|
||||||
// No output to verify since none is stored in memory. Just checking that
|
// No output to verify since none is stored in memory. Just checking that
|
||||||
@ -812,7 +859,7 @@ private:
|
|||||||
KeyHandleType counting = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(length, 1, length);
|
KeyHandleType counting = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(length, 1, length);
|
||||||
|
|
||||||
PermutationHandleType permutation = vtkm::cont::make_ArrayHandlePermutation(counting, values);
|
PermutationHandleType permutation = vtkm::cont::make_ArrayHandlePermutation(counting, values);
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(input, permutation);
|
dispatcher.Invoke(input, permutation);
|
||||||
|
|
||||||
vtkm::cont::printSummary_ArrayHandle(permutation, std::cout);
|
vtkm::cont::printSummary_ArrayHandle(permutation, std::cout);
|
||||||
@ -829,6 +876,47 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TestViewAsOutput
|
||||||
|
{
|
||||||
|
template <typename ValueType>
|
||||||
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
||||||
|
{
|
||||||
|
const vtkm::Id length = ARRAY_SIZE;
|
||||||
|
|
||||||
|
using ValueHandleType = vtkm::cont::ArrayHandle<ValueType>;
|
||||||
|
using ViewHandleType = vtkm::cont::ArrayHandleView<ValueHandleType>;
|
||||||
|
|
||||||
|
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
|
||||||
|
vtkm::cont::ArrayHandle<ValueType> input;
|
||||||
|
using Portal = typename vtkm::cont::ArrayHandle<ValueType>::PortalControl;
|
||||||
|
input.Allocate(length);
|
||||||
|
Portal inputPortal = input.GetPortalControl();
|
||||||
|
for (vtkm::Id i = 0; i < length; ++i)
|
||||||
|
{
|
||||||
|
inputPortal.Set(i, ValueType(ComponentType(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueHandleType values;
|
||||||
|
values.Allocate(length * 2);
|
||||||
|
|
||||||
|
ViewHandleType view = vtkm::cont::make_ArrayHandleView(values, length, length);
|
||||||
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
|
dispatcher.Invoke(input, view);
|
||||||
|
|
||||||
|
vtkm::cont::printSummary_ArrayHandle(view, std::cout);
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
//verify that the control portal works
|
||||||
|
for (vtkm::Id i = 0; i < length; ++i)
|
||||||
|
{
|
||||||
|
const ValueType result_v = view.GetPortalConstControl().Get(i);
|
||||||
|
const ValueType correct_value = ValueType(ComponentType(i));
|
||||||
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value),
|
||||||
|
"Permutation Handle Failed As Output");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct TestZipAsOutput
|
struct TestZipAsOutput
|
||||||
{
|
{
|
||||||
template <typename KeyType, typename ValueType>
|
template <typename KeyType, typename ValueType>
|
||||||
@ -853,7 +941,7 @@ private:
|
|||||||
vtkm::cont::ArrayHandle<ValueType>>
|
vtkm::cont::ArrayHandle<ValueType>>
|
||||||
result_zip = vtkm::cont::make_ArrayHandleZip(result_keys, result_values);
|
result_zip = vtkm::cont::make_ArrayHandleZip(result_keys, result_values);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
||||||
dispatcher.Invoke(input, result_zip);
|
dispatcher.Invoke(input, result_zip);
|
||||||
|
|
||||||
vtkm::cont::printSummary_ArrayHandle(result_zip, std::cout);
|
vtkm::cont::printSummary_ArrayHandle(result_zip, std::cout);
|
||||||
@ -886,7 +974,7 @@ private:
|
|||||||
vtkm::cont::ArrayHandle<ValueType> outputValues;
|
vtkm::cont::ArrayHandle<ValueType> outputValues;
|
||||||
outputValues.Allocate(ARRAY_SIZE);
|
outputValues.Allocate(ARRAY_SIZE);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<InplaceFunctorPair, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<InplaceFunctorPair> dispatcher;
|
||||||
dispatcher.Invoke(vtkm::cont::make_ArrayHandleZip(inputValues, outputValues));
|
dispatcher.Invoke(vtkm::cont::make_ArrayHandleZip(inputValues, outputValues));
|
||||||
|
|
||||||
vtkm::cont::printSummary_ArrayHandle(outputValues, std::cout);
|
vtkm::cont::printSummary_ArrayHandle(outputValues, std::cout);
|
||||||
@ -949,6 +1037,11 @@ private:
|
|||||||
vtkm::testing::Testing::TryTypes(
|
vtkm::testing::Testing::TryTypes(
|
||||||
TestingFancyArrayHandles<DeviceAdapterTag>::TestPermutationAsInput(), HandleTypesToTest());
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestPermutationAsInput(), HandleTypesToTest());
|
||||||
|
|
||||||
|
std::cout << "-------------------------------------------" << std::endl;
|
||||||
|
std::cout << "Testing ArrayHandleView as Input" << std::endl;
|
||||||
|
vtkm::testing::Testing::TryTypes(
|
||||||
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestViewAsInput(), HandleTypesToTest());
|
||||||
|
|
||||||
std::cout << "-------------------------------------------" << std::endl;
|
std::cout << "-------------------------------------------" << std::endl;
|
||||||
std::cout << "Testing ArrayHandleTransform as Input" << std::endl;
|
std::cout << "Testing ArrayHandleTransform as Input" << std::endl;
|
||||||
vtkm::testing::Testing::TryTypes(
|
vtkm::testing::Testing::TryTypes(
|
||||||
@ -1007,6 +1100,11 @@ private:
|
|||||||
vtkm::testing::Testing::TryTypes(
|
vtkm::testing::Testing::TryTypes(
|
||||||
TestingFancyArrayHandles<DeviceAdapterTag>::TestPermutationAsOutput(), HandleTypesToTest());
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestPermutationAsOutput(), HandleTypesToTest());
|
||||||
|
|
||||||
|
std::cout << "-------------------------------------------" << std::endl;
|
||||||
|
std::cout << "Testing ArrayHandleView as Output" << std::endl;
|
||||||
|
vtkm::testing::Testing::TryTypes(
|
||||||
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestViewAsOutput(), HandleTypesToTest());
|
||||||
|
|
||||||
std::cout << "-------------------------------------------" << std::endl;
|
std::cout << "-------------------------------------------" << std::endl;
|
||||||
std::cout << "Testing ArrayHandleDiscard as Output" << std::endl;
|
std::cout << "Testing ArrayHandleDiscard as Output" << std::endl;
|
||||||
vtkm::testing::Testing::TryTypes(
|
vtkm::testing::Testing::TryTypes(
|
||||||
@ -1034,7 +1132,11 @@ public:
|
|||||||
/// all the fancy array handles that vtkm supports. Returns an
|
/// all the fancy array handles that vtkm supports. Returns an
|
||||||
/// error code that can be returned from the main function of a test.
|
/// error code that can be returned from the main function of a test.
|
||||||
///
|
///
|
||||||
static VTKM_CONT int Run() { return vtkm::cont::testing::Testing::Run(TestAll()); }
|
static VTKM_CONT int Run()
|
||||||
|
{
|
||||||
|
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(DeviceAdapterTag());
|
||||||
|
return vtkm::cont::testing::Testing::Run(TestAll());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,10 +71,12 @@ void EvaluateOnCoordinates(vtkm::cont::CoordinateSystem points,
|
|||||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>& values,
|
vtkm::cont::ArrayHandle<vtkm::FloatDefault>& values,
|
||||||
DeviceAdapter device)
|
DeviceAdapter device)
|
||||||
{
|
{
|
||||||
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvaluateImplicitFunction, DeviceAdapter>;
|
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvaluateImplicitFunction>;
|
||||||
|
|
||||||
EvaluateImplicitFunction eval(function.PrepareForExecution(device));
|
EvaluateImplicitFunction eval(function.PrepareForExecution(device));
|
||||||
EvalDispatcher(eval).Invoke(points, values);
|
EvalDispatcher dispatcher(eval);
|
||||||
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
dispatcher.Invoke(points, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
|
@ -144,16 +144,18 @@ public:
|
|||||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> nnDis_Handle;
|
vtkm::cont::ArrayHandle<vtkm::FloatDefault> nnDis_Handle;
|
||||||
|
|
||||||
PointLocatorUniformGridWorklet pointLocatorUniformGridWorklet;
|
PointLocatorUniformGridWorklet pointLocatorUniformGridWorklet;
|
||||||
vtkm::worklet::DispatcherMapField<PointLocatorUniformGridWorklet, DeviceAdapter>
|
vtkm::worklet::DispatcherMapField<PointLocatorUniformGridWorklet> locatorDispatcher(
|
||||||
locatorDispatcher(pointLocatorUniformGridWorklet);
|
pointLocatorUniformGridWorklet);
|
||||||
|
locatorDispatcher.SetDevice(DeviceAdapter());
|
||||||
locatorDispatcher.Invoke(qc_Handle, locator, nnId_Handle, nnDis_Handle);
|
locatorDispatcher.Invoke(qc_Handle, locator, nnId_Handle, nnDis_Handle);
|
||||||
|
|
||||||
// brute force
|
// brute force
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> bfnnId_Handle;
|
vtkm::cont::ArrayHandle<vtkm::Id> bfnnId_Handle;
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> bfnnDis_Handle;
|
vtkm::cont::ArrayHandle<vtkm::Float32> bfnnDis_Handle;
|
||||||
NearestNeighborSearchBruteForce3DWorklet nnsbf3dWorklet;
|
NearestNeighborSearchBruteForce3DWorklet nnsbf3dWorklet;
|
||||||
vtkm::worklet::DispatcherMapField<NearestNeighborSearchBruteForce3DWorklet, DeviceAdapter>
|
vtkm::worklet::DispatcherMapField<NearestNeighborSearchBruteForce3DWorklet> nnsbf3DDispatcher(
|
||||||
nnsbf3DDispatcher(nnsbf3dWorklet);
|
nnsbf3dWorklet);
|
||||||
|
nnsbf3DDispatcher.SetDevice(DeviceAdapter());
|
||||||
nnsbf3DDispatcher.Invoke(
|
nnsbf3DDispatcher.Invoke(
|
||||||
qc_Handle, vtkm::cont::make_ArrayHandle(coordi), bfnnId_Handle, bfnnDis_Handle);
|
qc_Handle, vtkm::cont::make_ArrayHandle(coordi), bfnnId_Handle, bfnnDis_Handle);
|
||||||
|
|
||||||
|
88
vtkm/cont/testing/UnitTestRuntimeDeviceNames.cxx
Normal file
88
vtkm/cont/testing/UnitTestRuntimeDeviceNames.cxx
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
//============================================================================
|
||||||
|
// Copyright (c) Kitware, Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
// See LICENSE.txt for details.
|
||||||
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||||
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE. See the above copyright notice for more information.
|
||||||
|
//
|
||||||
|
// Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
||||||
|
// Copyright 2018 UT-Battelle, LLC.
|
||||||
|
// Copyright 2018 Los Alamos National Security.
|
||||||
|
//
|
||||||
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||||
|
// the U.S. Government retains certain rights in this software.
|
||||||
|
//
|
||||||
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||||
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||||
|
// this software.
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||||||
|
|
||||||
|
#include <vtkm/cont/cuda/DeviceAdapterCuda.h>
|
||||||
|
#include <vtkm/cont/internal/DeviceAdapterError.h>
|
||||||
|
#include <vtkm/cont/openmp/DeviceAdapterOpenMP.h>
|
||||||
|
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
||||||
|
#include <vtkm/cont/tbb/DeviceAdapterTBB.h>
|
||||||
|
|
||||||
|
#include <vtkm/cont/testing/Testing.h>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
// Invalid tag for testing. Returns the default "InvalidDeviceId" from
|
||||||
|
// vtkm::cont::RuntimeDeviceTracker::GetName.
|
||||||
|
struct VTKM_ALWAYS_EXPORT DeviceAdapterTagInvalidDeviceId : vtkm::cont::DeviceAdapterId
|
||||||
|
{
|
||||||
|
constexpr DeviceAdapterTagInvalidDeviceId()
|
||||||
|
: DeviceAdapterId(VTKM_MAX_DEVICE_ADAPTER_ID)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Tag>
|
||||||
|
void TestName(const std::string& name, Tag tag, vtkm::cont::DeviceAdapterId id)
|
||||||
|
{
|
||||||
|
auto tracker = vtkm::cont::GetGlobalRuntimeDeviceTracker();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
std::cerr << "Expected: " << name << "\n"
|
||||||
|
<< "\t" << id.GetName() << "\n"
|
||||||
|
<< "\t" << tag.GetName() << "\n"
|
||||||
|
<< "\t" << tracker.GetDeviceName(id) << "\n"
|
||||||
|
<< "\t" << tracker.GetDeviceName(tag) << "\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VTKM_TEST_ASSERT(id.GetName() == name, "Id::GetName() failed.");
|
||||||
|
VTKM_TEST_ASSERT(tag.GetName() == name, "Tag::GetName() failed.");
|
||||||
|
VTKM_TEST_ASSERT(tracker.GetDeviceName(id) == name, "RTDeviceTracker::GetDeviceName(Id) failed.");
|
||||||
|
VTKM_TEST_ASSERT(tracker.GetDeviceName(tag) == name,
|
||||||
|
"RTDeviceTracker::GetDeviceName(Tag) failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestNames()
|
||||||
|
{
|
||||||
|
DeviceAdapterTagInvalidDeviceId invalidTag;
|
||||||
|
vtkm::cont::DeviceAdapterTagError errorTag;
|
||||||
|
vtkm::cont::DeviceAdapterTagUndefined undefinedTag;
|
||||||
|
vtkm::cont::DeviceAdapterTagSerial serialTag;
|
||||||
|
vtkm::cont::DeviceAdapterTagTBB tbbTag;
|
||||||
|
vtkm::cont::DeviceAdapterTagOpenMP openmpTag;
|
||||||
|
vtkm::cont::DeviceAdapterTagCuda cudaTag;
|
||||||
|
|
||||||
|
TestName("InvalidDeviceId", invalidTag, invalidTag);
|
||||||
|
TestName("Error", errorTag, errorTag);
|
||||||
|
TestName("Undefined", undefinedTag, undefinedTag);
|
||||||
|
TestName("Serial", serialTag, serialTag);
|
||||||
|
TestName("TBB", tbbTag, tbbTag);
|
||||||
|
TestName("OpenMP", openmpTag, openmpTag);
|
||||||
|
TestName("Cuda", cudaTag, cudaTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end anon namespace
|
||||||
|
|
||||||
|
int UnitTestRuntimeDeviceNames(int, char* [])
|
||||||
|
{
|
||||||
|
return vtkm::cont::testing::Testing::Run(TestNames);
|
||||||
|
}
|
@ -43,7 +43,6 @@ class CellLocatorUniformGrid : public vtkm::exec::CellLocator
|
|||||||
public:
|
public:
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
CellLocatorUniformGrid(const vtkm::Bounds& bounds,
|
CellLocatorUniformGrid(const vtkm::Bounds& bounds,
|
||||||
const vtkm::Vec<vtkm::Id, 3>& dims,
|
|
||||||
const vtkm::Vec<vtkm::FloatDefault, 3> rangeTransform,
|
const vtkm::Vec<vtkm::FloatDefault, 3> rangeTransform,
|
||||||
const vtkm::Id planeSize,
|
const vtkm::Id planeSize,
|
||||||
const vtkm::Id rowSize,
|
const vtkm::Id rowSize,
|
||||||
@ -51,7 +50,6 @@ public:
|
|||||||
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
|
const vtkm::cont::ArrayHandleVirtualCoordinates& coords,
|
||||||
DeviceAdapter)
|
DeviceAdapter)
|
||||||
: Bounds(bounds)
|
: Bounds(bounds)
|
||||||
, Dims(dims)
|
|
||||||
, RangeTransform(rangeTransform)
|
, RangeTransform(rangeTransform)
|
||||||
, PlaneSize(planeSize)
|
, PlaneSize(planeSize)
|
||||||
, RowSize(rowSize)
|
, RowSize(rowSize)
|
||||||
@ -101,7 +99,6 @@ private:
|
|||||||
DeviceAdapter>::PortalConst;
|
DeviceAdapter>::PortalConst;
|
||||||
|
|
||||||
vtkm::Bounds Bounds;
|
vtkm::Bounds Bounds;
|
||||||
vtkm::Vec<vtkm::Id, 3> Dims;
|
|
||||||
vtkm::Vec<vtkm::FloatDefault, 3> RangeTransform;
|
vtkm::Vec<vtkm::FloatDefault, 3> RangeTransform;
|
||||||
vtkm::Id PlaneSize;
|
vtkm::Id PlaneSize;
|
||||||
vtkm::Id RowSize;
|
vtkm::Id RowSize;
|
||||||
|
@ -55,8 +55,8 @@ inline VTKM_CONT vtkm::cont::DataSet CellAverage::DoExecute(
|
|||||||
//If the input is implicit, we should know what to fall back to
|
//If the input is implicit, we should know what to fall back to
|
||||||
vtkm::cont::ArrayHandle<T> outArray;
|
vtkm::cont::ArrayHandle<T> outArray;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage, DeviceAdapter> dispatcher(
|
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher(this->Worklet);
|
||||||
this->Worklet);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cellSet, policy), inField, outArray);
|
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cellSet, policy), inField, outArray);
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ inline VTKM_CONT vtkm::cont::DataSet CellMeasures<IntegrationType>::DoExecute(
|
|||||||
const auto& cellset = input.GetCellSet(this->GetActiveCellSetIndex());
|
const auto& cellset = input.GetCellSet(this->GetActiveCellSetIndex());
|
||||||
vtkm::cont::ArrayHandle<T> outArray;
|
vtkm::cont::ArrayHandle<T> outArray;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellMeasure<IntegrationType>, DeviceAdapter>
|
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellMeasure<IntegrationType>> dispatcher;
|
||||||
dispatcher;
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cellset, policy), points, outArray);
|
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cellset, policy), points, outArray);
|
||||||
|
|
||||||
vtkm::cont::DataSet result;
|
vtkm::cont::DataSet result;
|
||||||
|
@ -38,7 +38,8 @@ struct CrossProductFunctor
|
|||||||
template <typename PrimaryFieldType, typename SecondaryFieldType>
|
template <typename PrimaryFieldType, typename SecondaryFieldType>
|
||||||
void operator()(const SecondaryFieldType& secondaryField, const PrimaryFieldType& primaryField)
|
void operator()(const SecondaryFieldType& secondaryField, const PrimaryFieldType& primaryField)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::CrossProduct, DeviceAdapter> dispatcher;
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::CrossProduct> dispatcher;
|
||||||
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
dispatcher.Invoke(primaryField,
|
dispatcher.Invoke(primaryField,
|
||||||
vtkm::cont::make_ArrayHandleCast<vtkm::Vec<T, 3>>(secondaryField),
|
vtkm::cont::make_ArrayHandleCast<vtkm::Vec<T, 3>>(secondaryField),
|
||||||
this->OutArray);
|
this->OutArray);
|
||||||
|
@ -39,7 +39,8 @@ struct DotProductFunctor
|
|||||||
template <typename PrimaryFieldType, typename SecondaryFieldType>
|
template <typename PrimaryFieldType, typename SecondaryFieldType>
|
||||||
void operator()(const SecondaryFieldType& secondaryField, const PrimaryFieldType& primaryField)
|
void operator()(const SecondaryFieldType& secondaryField, const PrimaryFieldType& primaryField)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::DotProduct, DeviceAdapter> dispatcher;
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::DotProduct> dispatcher;
|
||||||
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
dispatcher.Invoke(primaryField,
|
dispatcher.Invoke(primaryField,
|
||||||
vtkm::cont::make_ArrayHandleCast<vtkm::Vec<T, 3>>(secondaryField),
|
vtkm::cont::make_ArrayHandleCast<vtkm::Vec<T, 3>>(secondaryField),
|
||||||
this->OutArray);
|
this->OutArray);
|
||||||
|
@ -84,8 +84,8 @@ inline VTKM_CONT vtkm::cont::DataSet OscillatorSource::DoExecute(
|
|||||||
const DeviceAdapter&)
|
const DeviceAdapter&)
|
||||||
{
|
{
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float64> outArray;
|
vtkm::cont::ArrayHandle<vtkm::Float64> outArray;
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::OscillatorSource, DeviceAdapter> dispatcher(
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::OscillatorSource> dispatcher(this->Worklet);
|
||||||
this->Worklet);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
//todo, we need to use the policy to determine the valid conversions
|
//todo, we need to use the policy to determine the valid conversions
|
||||||
//that the dispatcher should do
|
//that the dispatcher should do
|
||||||
|
@ -55,8 +55,8 @@ inline VTKM_CONT vtkm::cont::DataSet PointAverage::DoExecute(
|
|||||||
//If the input is implicit, we should know what to fall back to
|
//If the input is implicit, we should know what to fall back to
|
||||||
vtkm::cont::ArrayHandle<T> outArray;
|
vtkm::cont::ArrayHandle<T> outArray;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::PointAverage, DeviceAdapter> dispatcher(
|
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::PointAverage> dispatcher(this->Worklet);
|
||||||
this->Worklet);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cellSet, policy), inField, outArray);
|
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cellSet, policy), inField, outArray);
|
||||||
|
|
||||||
|
@ -63,8 +63,8 @@ inline VTKM_CONT vtkm::cont::DataSet PointElevation::DoExecute(
|
|||||||
const DeviceAdapter&)
|
const DeviceAdapter&)
|
||||||
{
|
{
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float64> outArray;
|
vtkm::cont::ArrayHandle<vtkm::Float64> outArray;
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::PointElevation, DeviceAdapter> dispatcher(
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::PointElevation> dispatcher(this->Worklet);
|
||||||
this->Worklet);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
//todo, we need to use the policy to determine the valid conversions
|
//todo, we need to use the policy to determine the valid conversions
|
||||||
//that the dispatcher should do
|
//that the dispatcher should do
|
||||||
|
@ -127,8 +127,8 @@ inline VTKM_CONT vtkm::cont::DataSet PointTransform<S>::DoExecute(
|
|||||||
const DeviceAdapter&)
|
const DeviceAdapter&)
|
||||||
{
|
{
|
||||||
vtkm::cont::ArrayHandle<T> outArray;
|
vtkm::cont::ArrayHandle<T> outArray;
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::PointTransform<S>, DeviceAdapter> dispatcher(
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::PointTransform<S>> dispatcher(this->Worklet);
|
||||||
this->Worklet);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
dispatcher.Invoke(field, outArray);
|
dispatcher.Invoke(field, outArray);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
template <typename CellSetType>
|
template <typename CellSetType>
|
||||||
void operator()(const CellSetType& cellset) const
|
void operator()(const CellSetType& cellset) const
|
||||||
{
|
{
|
||||||
this->OutCellSet = Worklet.Run(cellset, DeviceAdapter());
|
this->OutCellSet = Worklet.Run(cellset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ inline VTKM_CONT vtkm::cont::DataSet VectorMagnitude::DoExecute(
|
|||||||
using ReturnType = typename ::vtkm::detail::FloatingPointReturnType<T>::Type;
|
using ReturnType = typename ::vtkm::detail::FloatingPointReturnType<T>::Type;
|
||||||
vtkm::cont::ArrayHandle<ReturnType> outArray;
|
vtkm::cont::ArrayHandle<ReturnType> outArray;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::Magnitude, DeviceAdapter> dispatcher(
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::Magnitude> dispatcher(this->Worklet);
|
||||||
this->Worklet);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
dispatcher.Invoke(field, outArray);
|
dispatcher.Invoke(field, outArray);
|
||||||
|
|
||||||
|
@ -61,33 +61,6 @@ struct ClearBuffers : public vtkm::worklet::WorkletMapField
|
|||||||
}
|
}
|
||||||
}; // struct ClearBuffers
|
}; // struct ClearBuffers
|
||||||
|
|
||||||
struct ClearBuffersExecutor
|
|
||||||
{
|
|
||||||
using ColorBufferType = vtkm::rendering::Canvas::ColorBufferType;
|
|
||||||
using DepthBufferType = vtkm::rendering::Canvas::DepthBufferType;
|
|
||||||
|
|
||||||
ColorBufferType ColorBuffer;
|
|
||||||
DepthBufferType DepthBuffer;
|
|
||||||
|
|
||||||
VTKM_CONT
|
|
||||||
ClearBuffersExecutor(const ColorBufferType& colorBuffer, const DepthBufferType& depthBuffer)
|
|
||||||
: ColorBuffer(colorBuffer)
|
|
||||||
, DepthBuffer(depthBuffer)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
VTKM_CONT bool operator()(Device) const
|
|
||||||
{
|
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
|
||||||
|
|
||||||
ClearBuffers worklet;
|
|
||||||
vtkm::worklet::DispatcherMapField<ClearBuffers, Device> dispatcher(worklet);
|
|
||||||
dispatcher.Invoke(this->ColorBuffer, this->DepthBuffer);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}; // struct ClearBuffersExecutor
|
|
||||||
|
|
||||||
struct BlendBackground : public vtkm::worklet::WorkletMapField
|
struct BlendBackground : public vtkm::worklet::WorkletMapField
|
||||||
{
|
{
|
||||||
vtkm::Vec<vtkm::Float32, 4> BackgroundColor;
|
vtkm::Vec<vtkm::Float32, 4> BackgroundColor;
|
||||||
@ -114,32 +87,6 @@ struct BlendBackground : public vtkm::worklet::WorkletMapField
|
|||||||
}
|
}
|
||||||
}; // struct BlendBackground
|
}; // struct BlendBackground
|
||||||
|
|
||||||
struct BlendBackgroundExecutor
|
|
||||||
{
|
|
||||||
using ColorBufferType = vtkm::rendering::Canvas::ColorBufferType;
|
|
||||||
|
|
||||||
ColorBufferType ColorBuffer;
|
|
||||||
BlendBackground Worklet;
|
|
||||||
|
|
||||||
VTKM_CONT
|
|
||||||
BlendBackgroundExecutor(const ColorBufferType& colorBuffer,
|
|
||||||
const vtkm::Vec<vtkm::Float32, 4>& backgroundColor)
|
|
||||||
: ColorBuffer(colorBuffer)
|
|
||||||
, Worklet(backgroundColor)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
VTKM_CONT bool operator()(Device) const
|
|
||||||
{
|
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<BlendBackground, Device> dispatcher(this->Worklet);
|
|
||||||
dispatcher.Invoke(this->ColorBuffer);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}; // struct BlendBackgroundExecutor
|
|
||||||
|
|
||||||
struct DrawColorSwatch : public vtkm::worklet::WorkletMapField
|
struct DrawColorSwatch : public vtkm::worklet::WorkletMapField
|
||||||
{
|
{
|
||||||
using ControlSignature = void(FieldIn<>, WholeArrayInOut<>);
|
using ControlSignature = void(FieldIn<>, WholeArrayInOut<>);
|
||||||
@ -257,81 +204,6 @@ struct DrawColorBar : public vtkm::worklet::WorkletMapField
|
|||||||
bool Horizontal;
|
bool Horizontal;
|
||||||
}; // struct DrawColorBar
|
}; // struct DrawColorBar
|
||||||
|
|
||||||
struct ColorSwatchExecutor
|
|
||||||
{
|
|
||||||
VTKM_CONT
|
|
||||||
ColorSwatchExecutor(vtkm::Id2 dims,
|
|
||||||
vtkm::Id2 xBounds,
|
|
||||||
vtkm::Id2 yBounds,
|
|
||||||
const vtkm::Vec<vtkm::Float32, 4>& color,
|
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& colorBuffer)
|
|
||||||
: Dims(dims)
|
|
||||||
, XBounds(xBounds)
|
|
||||||
, YBounds(yBounds)
|
|
||||||
, Color(color)
|
|
||||||
, ColorBuffer(colorBuffer)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
VTKM_CONT bool operator()(Device) const
|
|
||||||
{
|
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
|
||||||
|
|
||||||
vtkm::Id totalPixels = (XBounds[1] - XBounds[0]) * (YBounds[1] - YBounds[0]);
|
|
||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> iterator(0, 1, totalPixels);
|
|
||||||
vtkm::worklet::DispatcherMapField<DrawColorSwatch, Device> dispatcher(
|
|
||||||
DrawColorSwatch(this->Dims, this->XBounds, this->YBounds, Color));
|
|
||||||
dispatcher.Invoke(iterator, this->ColorBuffer);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
vtkm::Id2 Dims;
|
|
||||||
vtkm::Id2 XBounds;
|
|
||||||
vtkm::Id2 YBounds;
|
|
||||||
const vtkm::Vec<vtkm::Float32, 4>& Color;
|
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& ColorBuffer;
|
|
||||||
}; // struct ColorSwatchExecutor
|
|
||||||
|
|
||||||
struct ColorBarExecutor
|
|
||||||
{
|
|
||||||
VTKM_CONT
|
|
||||||
ColorBarExecutor(vtkm::Id2 dims,
|
|
||||||
vtkm::Id2 xBounds,
|
|
||||||
vtkm::Id2 yBounds,
|
|
||||||
bool horizontal,
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& colorMap,
|
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& colorBuffer)
|
|
||||||
: Dims(dims)
|
|
||||||
, XBounds(xBounds)
|
|
||||||
, YBounds(yBounds)
|
|
||||||
, Horizontal(horizontal)
|
|
||||||
, ColorMap(colorMap)
|
|
||||||
, ColorBuffer(colorBuffer)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
VTKM_CONT bool operator()(Device) const
|
|
||||||
{
|
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
|
||||||
|
|
||||||
vtkm::Id totalPixels = (XBounds[1] - XBounds[0]) * (YBounds[1] - YBounds[0]);
|
|
||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> iterator(0, 1, totalPixels);
|
|
||||||
vtkm::worklet::DispatcherMapField<DrawColorBar, Device> dispatcher(
|
|
||||||
DrawColorBar(this->Dims, this->XBounds, this->YBounds, this->Horizontal));
|
|
||||||
dispatcher.Invoke(iterator, this->ColorBuffer, this->ColorMap);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
vtkm::Id2 Dims;
|
|
||||||
vtkm::Id2 XBounds;
|
|
||||||
vtkm::Id2 YBounds;
|
|
||||||
bool Horizontal;
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& ColorMap;
|
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& ColorBuffer;
|
|
||||||
}; // struct ColorSwatchExecutor
|
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
struct Canvas::CanvasInternals
|
struct Canvas::CanvasInternals
|
||||||
@ -441,9 +313,8 @@ void Canvas::Activate()
|
|||||||
|
|
||||||
void Canvas::Clear()
|
void Canvas::Clear()
|
||||||
{
|
{
|
||||||
// TODO: Should the rendering library support policies or some other way to
|
vtkm::worklet::DispatcherMapField<internal::ClearBuffers>().Invoke(this->GetColorBuffer(),
|
||||||
// configure with custom devices?
|
this->GetDepthBuffer());
|
||||||
vtkm::cont::TryExecute(internal::ClearBuffersExecutor(GetColorBuffer(), GetDepthBuffer()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::Finish()
|
void Canvas::Finish()
|
||||||
@ -452,8 +323,9 @@ void Canvas::Finish()
|
|||||||
|
|
||||||
void Canvas::BlendBackground()
|
void Canvas::BlendBackground()
|
||||||
{
|
{
|
||||||
vtkm::cont::TryExecute(
|
vtkm::worklet::DispatcherMapField<internal::BlendBackground>(
|
||||||
internal::BlendBackgroundExecutor(GetColorBuffer(), GetBackgroundColor().Components));
|
this->GetBackgroundColor().Components)
|
||||||
|
.Invoke(this->GetColorBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::ResizeBuffers(vtkm::Id width, vtkm::Id height)
|
void Canvas::ResizeBuffers(vtkm::Id width, vtkm::Id height)
|
||||||
@ -491,8 +363,12 @@ void Canvas::AddColorSwatch(const vtkm::Vec<vtkm::Float64, 2>& point0,
|
|||||||
y[1] = static_cast<vtkm::Id>(((point2[1] + 1.) / 2.) * height + .5);
|
y[1] = static_cast<vtkm::Id>(((point2[1] + 1.) / 2.) * height + .5);
|
||||||
|
|
||||||
vtkm::Id2 dims(this->GetWidth(), this->GetHeight());
|
vtkm::Id2 dims(this->GetWidth(), this->GetHeight());
|
||||||
vtkm::cont::TryExecute(
|
|
||||||
internal::ColorSwatchExecutor(dims, x, y, color.Components, this->GetColorBuffer()));
|
vtkm::Id totalPixels = (x[1] - x[0]) * (y[1] - y[0]);
|
||||||
|
vtkm::cont::ArrayHandleCounting<vtkm::Id> iterator(0, 1, totalPixels);
|
||||||
|
vtkm::worklet::DispatcherMapField<internal::DrawColorSwatch> dispatcher(
|
||||||
|
internal::DrawColorSwatch(dims, x, y, color.Components));
|
||||||
|
dispatcher.Invoke(iterator, this->GetColorBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::AddColorSwatch(const vtkm::Float64 x0,
|
void Canvas::AddColorSwatch(const vtkm::Float64 x0,
|
||||||
@ -552,8 +428,12 @@ void Canvas::AddColorBar(const vtkm::Bounds& bounds,
|
|||||||
colorTable.Sample(static_cast<vtkm::Int32>(numSamples), colorMap);
|
colorTable.Sample(static_cast<vtkm::Int32>(numSamples), colorMap);
|
||||||
|
|
||||||
vtkm::Id2 dims(this->GetWidth(), this->GetHeight());
|
vtkm::Id2 dims(this->GetWidth(), this->GetHeight());
|
||||||
vtkm::cont::TryExecute(
|
|
||||||
internal::ColorBarExecutor(dims, x, y, horizontal, colorMap, this->GetColorBuffer()));
|
vtkm::Id totalPixels = (x[1] - x[0]) * (y[1] - y[0]);
|
||||||
|
vtkm::cont::ArrayHandleCounting<vtkm::Id> iterator(0, 1, totalPixels);
|
||||||
|
vtkm::worklet::DispatcherMapField<internal::DrawColorBar> dispatcher(
|
||||||
|
internal::DrawColorBar(dims, x, y, horizontal));
|
||||||
|
dispatcher.Invoke(iterator, this->GetColorBuffer(), colorMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::AddColorBar(vtkm::Float32 x,
|
void Canvas::AddColorBar(vtkm::Float32 x,
|
||||||
|
@ -110,57 +110,24 @@ public:
|
|||||||
}
|
}
|
||||||
}; //class SurfaceConverter
|
}; //class SurfaceConverter
|
||||||
|
|
||||||
template <typename Precision>
|
|
||||||
struct WriteFunctor
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
vtkm::rendering::CanvasRayTracer* Canvas;
|
|
||||||
const vtkm::rendering::raytracing::Ray<Precision>& Rays;
|
|
||||||
const vtkm::cont::ArrayHandle<Precision>& Colors;
|
|
||||||
const vtkm::rendering::Camera& CameraView;
|
|
||||||
vtkm::Matrix<vtkm::Float32, 4, 4> ViewProjMat;
|
|
||||||
|
|
||||||
public:
|
|
||||||
VTKM_CONT
|
|
||||||
WriteFunctor(vtkm::rendering::CanvasRayTracer* canvas,
|
|
||||||
const vtkm::rendering::raytracing::Ray<Precision>& rays,
|
|
||||||
const vtkm::cont::ArrayHandle<Precision>& colors,
|
|
||||||
const vtkm::rendering::Camera& camera)
|
|
||||||
: Canvas(canvas)
|
|
||||||
, Rays(rays)
|
|
||||||
, Colors(colors)
|
|
||||||
, CameraView(camera)
|
|
||||||
{
|
|
||||||
ViewProjMat = vtkm::MatrixMultiply(
|
|
||||||
CameraView.CreateProjectionMatrix(Canvas->GetWidth(), Canvas->GetHeight()),
|
|
||||||
CameraView.CreateViewMatrix());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
VTKM_CONT bool operator()(Device)
|
|
||||||
{
|
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
|
||||||
vtkm::worklet::DispatcherMapField<SurfaceConverter, Device>(SurfaceConverter(ViewProjMat))
|
|
||||||
.Invoke(Rays.PixelIdx,
|
|
||||||
Colors,
|
|
||||||
Rays.Distance,
|
|
||||||
Rays.Origin,
|
|
||||||
Rays.Dir,
|
|
||||||
Canvas->GetDepthBuffer(),
|
|
||||||
Canvas->GetColorBuffer());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Precision>
|
template <typename Precision>
|
||||||
VTKM_CONT void WriteToCanvas(const vtkm::rendering::raytracing::Ray<Precision>& rays,
|
VTKM_CONT void WriteToCanvas(const vtkm::rendering::raytracing::Ray<Precision>& rays,
|
||||||
const vtkm::cont::ArrayHandle<Precision>& colors,
|
const vtkm::cont::ArrayHandle<Precision>& colors,
|
||||||
const vtkm::rendering::Camera& camera,
|
const vtkm::rendering::Camera& camera,
|
||||||
vtkm::rendering::CanvasRayTracer* canvas)
|
vtkm::rendering::CanvasRayTracer* canvas)
|
||||||
{
|
{
|
||||||
WriteFunctor<Precision> functor(canvas, rays, colors, camera);
|
vtkm::Matrix<vtkm::Float32, 4, 4> viewProjMat =
|
||||||
|
vtkm::MatrixMultiply(camera.CreateProjectionMatrix(canvas->GetWidth(), canvas->GetHeight()),
|
||||||
|
camera.CreateViewMatrix());
|
||||||
|
|
||||||
vtkm::cont::TryExecute(functor);
|
vtkm::worklet::DispatcherMapField<SurfaceConverter>(SurfaceConverter(viewProjMat))
|
||||||
|
.Invoke(rays.PixelIdx,
|
||||||
|
colors,
|
||||||
|
rays.Distance,
|
||||||
|
rays.Origin,
|
||||||
|
rays.Dir,
|
||||||
|
canvas->GetDepthBuffer(),
|
||||||
|
canvas->GetColorBuffer());
|
||||||
|
|
||||||
//Force the transfer so the vectors contain data from device
|
//Force the transfer so the vectors contain data from device
|
||||||
canvas->GetColorBuffer().GetPortalControl().Get(0);
|
canvas->GetColorBuffer().GetPortalControl().Get(0);
|
||||||
|
@ -179,8 +179,9 @@ struct MapColorAndVerticesInvokeFunctor
|
|||||||
{
|
{
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||||
|
|
||||||
auto colorHandle = this->ColorTable.GetHandleForExecution();
|
|
||||||
MapColorAndVertices worklet(colorHandle->PrepareForExecution(device), this->SMin, this->SDiff);
|
MapColorAndVertices worklet(
|
||||||
|
this->ColorTable.PrepareForExecution(device), this->SMin, this->SDiff);
|
||||||
vtkm::worklet::DispatcherMapField<MapColorAndVertices, Device> dispatcher(worklet);
|
vtkm::worklet::DispatcherMapField<MapColorAndVertices, Device> dispatcher(worklet);
|
||||||
|
|
||||||
vtkm::cont::ArrayHandleIndex indexArray(this->TriangleIndices.GetNumberOfValues());
|
vtkm::cont::ArrayHandleIndex indexArray(this->TriangleIndices.GetNumberOfValues());
|
||||||
|
@ -59,21 +59,6 @@ public:
|
|||||||
}
|
}
|
||||||
}; // conn
|
}; // conn
|
||||||
|
|
||||||
struct ConnFunctor
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
VTKM_CONT bool operator()(Device,
|
|
||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id>& iter,
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id>& conn)
|
|
||||||
{
|
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
|
||||||
vtkm::worklet::DispatcherMapField<CreateConnectivity, Device>(CreateConnectivity())
|
|
||||||
.Invoke(iter, conn);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Convert1DCoordinates : public vtkm::worklet::WorkletMapField
|
class Convert1DCoordinates : public vtkm::worklet::WorkletMapField
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -123,26 +108,6 @@ public:
|
|||||||
}
|
}
|
||||||
}; // convert coords
|
}; // convert coords
|
||||||
|
|
||||||
struct ConvertFunctor
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename Device, typename CoordType, typename ScalarType>
|
|
||||||
VTKM_CONT bool operator()(Device,
|
|
||||||
CoordType coords,
|
|
||||||
ScalarType scalars,
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3>>& outCoords,
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32>& outScalars,
|
|
||||||
bool logY,
|
|
||||||
bool logX)
|
|
||||||
{
|
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
|
||||||
vtkm::worklet::DispatcherMapField<Convert1DCoordinates, Device>(
|
|
||||||
Convert1DCoordinates(logY, logX))
|
|
||||||
.Invoke(coords, scalars, outCoords, outScalars);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(VTKM_MSVC)
|
#if defined(VTKM_MSVC)
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4127) //conditional expression is constant
|
#pragma warning(disable : 4127) //conditional expression is constant
|
||||||
@ -176,10 +141,10 @@ struct EdgesExtracter : public vtkm::worklet::WorkletMapPointToCell
|
|||||||
using ScatterType = vtkm::worklet::ScatterCounting;
|
using ScatterType = vtkm::worklet::ScatterCounting;
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
template <typename CountArrayType, typename DeviceTag>
|
template <typename CountArrayType>
|
||||||
static ScatterType MakeScatter(const CountArrayType& counts, DeviceTag device)
|
static ScatterType MakeScatter(const CountArrayType& counts)
|
||||||
{
|
{
|
||||||
return ScatterType(counts, device);
|
return ScatterType(counts);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename CellShapeTag, typename PointIndexVecType, typename EdgeIndexVecType>
|
template <typename CellShapeTag, typename PointIndexVecType, typename EdgeIndexVecType>
|
||||||
@ -212,33 +177,6 @@ struct EdgesExtracter : public vtkm::worklet::WorkletMapPointToCell
|
|||||||
#if defined(VTKM_MSVC)
|
#if defined(VTKM_MSVC)
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ExtractUniqueEdges
|
|
||||||
{
|
|
||||||
vtkm::cont::DynamicCellSet CellSet;
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 2>> EdgeIndices;
|
|
||||||
|
|
||||||
VTKM_CONT
|
|
||||||
ExtractUniqueEdges(const vtkm::cont::DynamicCellSet& cellSet)
|
|
||||||
: CellSet(cellSet)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename DeviceTag>
|
|
||||||
VTKM_CONT bool operator()(DeviceTag)
|
|
||||||
{
|
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceTag);
|
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> counts;
|
|
||||||
vtkm::worklet::DispatcherMapTopology<EdgesCounter, DeviceTag>().Invoke(CellSet, counts);
|
|
||||||
vtkm::worklet::DispatcherMapTopology<EdgesExtracter, DeviceTag> extractDispatcher(
|
|
||||||
EdgesExtracter::MakeScatter(counts, DeviceTag()));
|
|
||||||
extractDispatcher.Invoke(CellSet, EdgeIndices);
|
|
||||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceTag>::template Sort<vtkm::Id2>(EdgeIndices);
|
|
||||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceTag>::template Unique<vtkm::Id2>(EdgeIndices);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}; // struct ExtractUniqueEdges
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
struct MapperWireframer::InternalsType
|
struct MapperWireframer::InternalsType
|
||||||
@ -340,13 +278,9 @@ void MapperWireframer::RenderCells(const vtkm::cont::DynamicCellSet& inCellSet,
|
|||||||
//
|
//
|
||||||
// Convert the cell set into something we can draw
|
// Convert the cell set into something we can draw
|
||||||
//
|
//
|
||||||
vtkm::cont::TryExecute(ConvertFunctor(),
|
vtkm::worklet::DispatcherMapField<Convert1DCoordinates>(
|
||||||
coords.GetData(),
|
Convert1DCoordinates(this->LogarithmY, this->LogarithmX))
|
||||||
inScalarField.GetData(),
|
.Invoke(coords.GetData(), inScalarField.GetData(), newCoords, newScalars);
|
||||||
newCoords,
|
|
||||||
newScalars,
|
|
||||||
this->LogarithmY,
|
|
||||||
this->LogarithmX);
|
|
||||||
|
|
||||||
actualCoords = vtkm::cont::CoordinateSystem("coords", newCoords);
|
actualCoords = vtkm::cont::CoordinateSystem("coords", newCoords);
|
||||||
actualField = vtkm::cont::Field(
|
actualField = vtkm::cont::Field(
|
||||||
@ -357,7 +291,7 @@ void MapperWireframer::RenderCells(const vtkm::cont::DynamicCellSet& inCellSet,
|
|||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> iter =
|
vtkm::cont::ArrayHandleCounting<vtkm::Id> iter =
|
||||||
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0), vtkm::Id(1), numCells);
|
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0), vtkm::Id(1), numCells);
|
||||||
conn.Allocate(numCells * 2);
|
conn.Allocate(numCells * 2);
|
||||||
vtkm::cont::TryExecute(ConnFunctor(), iter, conn);
|
vtkm::worklet::DispatcherMapField<CreateConnectivity>(CreateConnectivity()).Invoke(iter, conn);
|
||||||
|
|
||||||
vtkm::cont::CellSetSingleType<> newCellSet("cells");
|
vtkm::cont::CellSetSingleType<> newCellSet("cells");
|
||||||
newCellSet.Fill(newCoords.GetNumberOfValues(), vtkm::CELL_SHAPE_LINE, 2, conn);
|
newCellSet.Fill(newCoords.GetNumberOfValues(), vtkm::CELL_SHAPE_LINE, 2, conn);
|
||||||
@ -391,9 +325,14 @@ void MapperWireframer::RenderCells(const vtkm::cont::DynamicCellSet& inCellSet,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract unique edges from the cell set.
|
// Extract unique edges from the cell set.
|
||||||
ExtractUniqueEdges extracter(cellSet);
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> counts;
|
||||||
vtkm::cont::TryExecute(extracter);
|
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 2>> edgeIndices;
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 2>> edgeIndices = extracter.EdgeIndices;
|
vtkm::worklet::DispatcherMapTopology<EdgesCounter>().Invoke(cellSet, counts);
|
||||||
|
vtkm::worklet::DispatcherMapTopology<EdgesExtracter> extractDispatcher(
|
||||||
|
EdgesExtracter::MakeScatter(counts));
|
||||||
|
extractDispatcher.Invoke(cellSet, edgeIndices);
|
||||||
|
vtkm::cont::Algorithm::template Sort<vtkm::Id2>(edgeIndices);
|
||||||
|
vtkm::cont::Algorithm::template Unique<vtkm::Id2>(edgeIndices);
|
||||||
|
|
||||||
Wireframer renderer(
|
Wireframer renderer(
|
||||||
this->Internals->Canvas, this->Internals->ShowInternalZones, this->Internals->IsOverlay);
|
this->Internals->Canvas, this->Internals->ShowInternalZones, this->Internals->IsOverlay);
|
||||||
|
@ -165,7 +165,8 @@ struct RenderBitmapFontExecutor
|
|||||||
{
|
{
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<RenderBitmapFont, Device> dispatcher(Worklet);
|
vtkm::worklet::DispatcherMapField<RenderBitmapFont> dispatcher(Worklet);
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
dispatcher.Invoke(
|
dispatcher.Invoke(
|
||||||
ScreenCoords, TextureCoords, FontTexture.GetExecObjectFactory(), ColorBuffer, DepthBuffer);
|
ScreenCoords, TextureCoords, FontTexture.GetExecObjectFactory(), ColorBuffer, DepthBuffer);
|
||||||
return true;
|
return true;
|
||||||
|
@ -554,12 +554,14 @@ private:
|
|||||||
ColorMap,
|
ColorMap,
|
||||||
FrameBuffer,
|
FrameBuffer,
|
||||||
Camera.GetClippingRange());
|
Camera.GetClippingRange());
|
||||||
vtkm::worklet::DispatcherMapField<EdgePlotter<DeviceTag>, DeviceTag>(plotter).Invoke(
|
vtkm::worklet::DispatcherMapField<EdgePlotter<DeviceTag>> plotterDispatcher(plotter);
|
||||||
PointIndices, Coordinates, ScalarField.GetData());
|
plotterDispatcher.SetDevice(DeviceTag());
|
||||||
|
plotterDispatcher.Invoke(PointIndices, Coordinates, ScalarField.GetData());
|
||||||
|
|
||||||
BufferConverter converter;
|
BufferConverter converter;
|
||||||
vtkm::worklet::DispatcherMapField<BufferConverter, DeviceTag>(converter).Invoke(
|
vtkm::worklet::DispatcherMapField<BufferConverter> converterDispatcher(converter);
|
||||||
FrameBuffer, Canvas->GetDepthBuffer(), Canvas->GetColorBuffer());
|
converterDispatcher.SetDevice(DeviceTag());
|
||||||
|
converterDispatcher.Invoke(FrameBuffer, Canvas->GetDepthBuffer(), Canvas->GetColorBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
|
@ -608,7 +608,8 @@ VTKM_CONT void LinearBVHBuilder::SortAABBS(
|
|||||||
//create array of indexes to be sorted with morton codes
|
//create array of indexes to be sorted with morton codes
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> iterator;
|
vtkm::cont::ArrayHandle<vtkm::Id> iterator;
|
||||||
iterator.PrepareForOutput(bvh.GetNumberOfPrimitives(), Device());
|
iterator.PrepareForOutput(bvh.GetNumberOfPrimitives(), Device());
|
||||||
vtkm::worklet::DispatcherMapField<CountingIterator, Device> iteratorDispatcher;
|
vtkm::worklet::DispatcherMapField<CountingIterator> iteratorDispatcher;
|
||||||
|
iteratorDispatcher.SetDevice(Device());
|
||||||
iteratorDispatcher.Invoke(iterator);
|
iteratorDispatcher.Invoke(iterator);
|
||||||
|
|
||||||
//std::cout<<"\n\n\n";
|
//std::cout<<"\n\n\n";
|
||||||
@ -623,56 +624,77 @@ VTKM_CONT void LinearBVHBuilder::SortAABBS(
|
|||||||
|
|
||||||
tempStorage = new vtkm::cont::ArrayHandle<vtkm::Float32>();
|
tempStorage = new vtkm::cont::ArrayHandle<vtkm::Float32>();
|
||||||
//xmins
|
//xmins
|
||||||
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
|
{
|
||||||
GatherFloat32<Device>(*bvh.xmins, *tempStorage, arraySize))
|
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
|
||||||
.Invoke(iterator);
|
GatherFloat32<Device>(*bvh.xmins, *tempStorage, arraySize));
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(iterator);
|
||||||
|
}
|
||||||
|
|
||||||
tempPtr = bvh.xmins;
|
tempPtr = bvh.xmins;
|
||||||
bvh.xmins = tempStorage;
|
bvh.xmins = tempStorage;
|
||||||
tempStorage = tempPtr;
|
tempStorage = tempPtr;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
|
{
|
||||||
GatherFloat32<Device>(*bvh.ymins, *tempStorage, arraySize))
|
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
|
||||||
.Invoke(iterator);
|
GatherFloat32<Device>(*bvh.ymins, *tempStorage, arraySize));
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(iterator);
|
||||||
|
}
|
||||||
|
|
||||||
tempPtr = bvh.ymins;
|
tempPtr = bvh.ymins;
|
||||||
bvh.ymins = tempStorage;
|
bvh.ymins = tempStorage;
|
||||||
tempStorage = tempPtr;
|
tempStorage = tempPtr;
|
||||||
//zmins
|
//zmins
|
||||||
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
|
{
|
||||||
GatherFloat32<Device>(*bvh.zmins, *tempStorage, arraySize))
|
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
|
||||||
.Invoke(iterator);
|
GatherFloat32<Device>(*bvh.zmins, *tempStorage, arraySize));
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(iterator);
|
||||||
|
}
|
||||||
tempPtr = bvh.zmins;
|
tempPtr = bvh.zmins;
|
||||||
bvh.zmins = tempStorage;
|
bvh.zmins = tempStorage;
|
||||||
tempStorage = tempPtr;
|
tempStorage = tempPtr;
|
||||||
//xmaxs
|
//xmaxs
|
||||||
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
|
{
|
||||||
GatherFloat32<Device>(*bvh.xmaxs, *tempStorage, arraySize))
|
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
|
||||||
.Invoke(iterator);
|
GatherFloat32<Device>(*bvh.xmaxs, *tempStorage, arraySize));
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(iterator);
|
||||||
|
}
|
||||||
|
|
||||||
tempPtr = bvh.xmaxs;
|
tempPtr = bvh.xmaxs;
|
||||||
bvh.xmaxs = tempStorage;
|
bvh.xmaxs = tempStorage;
|
||||||
tempStorage = tempPtr;
|
tempStorage = tempPtr;
|
||||||
//ymaxs
|
//ymaxs
|
||||||
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
|
{
|
||||||
GatherFloat32<Device>(*bvh.ymaxs, *tempStorage, arraySize))
|
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
|
||||||
.Invoke(iterator);
|
GatherFloat32<Device>(*bvh.ymaxs, *tempStorage, arraySize));
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(iterator);
|
||||||
|
}
|
||||||
|
|
||||||
tempPtr = bvh.ymaxs;
|
tempPtr = bvh.ymaxs;
|
||||||
bvh.ymaxs = tempStorage;
|
bvh.ymaxs = tempStorage;
|
||||||
tempStorage = tempPtr;
|
tempStorage = tempPtr;
|
||||||
//zmaxs
|
//zmaxs
|
||||||
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
|
{
|
||||||
GatherFloat32<Device>(*bvh.zmaxs, *tempStorage, arraySize))
|
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
|
||||||
.Invoke(iterator);
|
GatherFloat32<Device>(*bvh.zmaxs, *tempStorage, arraySize));
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(iterator);
|
||||||
|
}
|
||||||
|
|
||||||
tempPtr = bvh.zmaxs;
|
tempPtr = bvh.zmaxs;
|
||||||
bvh.zmaxs = tempStorage;
|
bvh.zmaxs = tempStorage;
|
||||||
tempStorage = tempPtr;
|
tempStorage = tempPtr;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<GatherVecCast<Device>, Device>(
|
{
|
||||||
GatherVecCast<Device>(triangleIndices, outputTriangleIndices, arraySize))
|
vtkm::worklet::DispatcherMapField<GatherVecCast<Device>> dispatcher(
|
||||||
.Invoke(iterator);
|
GatherVecCast<Device>(triangleIndices, outputTriangleIndices, arraySize));
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(iterator);
|
||||||
|
}
|
||||||
delete tempStorage;
|
delete tempStorage;
|
||||||
|
|
||||||
} // method SortAABBs
|
} // method SortAABBs
|
||||||
@ -699,15 +721,16 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
|||||||
BVHData bvh(numBBoxes, device);
|
BVHData bvh(numBBoxes, device);
|
||||||
|
|
||||||
vtkm::cont::Timer<Device> timer;
|
vtkm::cont::Timer<Device> timer;
|
||||||
vtkm::worklet::DispatcherMapField<FindAABBs, Device>(FindAABBs())
|
vtkm::worklet::DispatcherMapField<FindAABBs> findAABBDispatcher{ (FindAABBs{}) };
|
||||||
.Invoke(triangleIndices,
|
findAABBDispatcher.SetDevice(Device());
|
||||||
*bvh.xmins,
|
findAABBDispatcher.Invoke(triangleIndices,
|
||||||
*bvh.ymins,
|
*bvh.xmins,
|
||||||
*bvh.zmins,
|
*bvh.ymins,
|
||||||
*bvh.xmaxs,
|
*bvh.zmins,
|
||||||
*bvh.ymaxs,
|
*bvh.xmaxs,
|
||||||
*bvh.zmaxs,
|
*bvh.ymaxs,
|
||||||
coordsHandle);
|
*bvh.zmaxs,
|
||||||
|
coordsHandle);
|
||||||
|
|
||||||
vtkm::Float64 time = timer.GetElapsedTime();
|
vtkm::Float64 time = timer.GetElapsedTime();
|
||||||
logger->AddLogData("find_aabb", time);
|
logger->AddLogData("find_aabb", time);
|
||||||
@ -742,10 +765,11 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Generate the morton codes
|
//Generate the morton codes
|
||||||
vtkm::worklet::DispatcherMapField<MortonCodeAABB, Device>(
|
vtkm::worklet::DispatcherMapField<MortonCodeAABB> mortonCodeAABBDispatcher(
|
||||||
MortonCodeAABB(inverseExtent, minExtent))
|
MortonCodeAABB(inverseExtent, minExtent));
|
||||||
.Invoke(
|
mortonCodeAABBDispatcher.SetDevice(Device());
|
||||||
*bvh.xmins, *bvh.ymins, *bvh.zmins, *bvh.xmaxs, *bvh.ymaxs, *bvh.zmaxs, bvh.mortonCodes);
|
mortonCodeAABBDispatcher.Invoke(
|
||||||
|
*bvh.xmins, *bvh.ymins, *bvh.zmins, *bvh.xmaxs, *bvh.ymaxs, *bvh.zmaxs, bvh.mortonCodes);
|
||||||
|
|
||||||
time = timer.GetElapsedTime();
|
time = timer.GetElapsedTime();
|
||||||
logger->AddLogData("morton_codes", time);
|
logger->AddLogData("morton_codes", time);
|
||||||
@ -759,9 +783,10 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
|||||||
logger->AddLogData("sort_aabbs", time);
|
logger->AddLogData("sort_aabbs", time);
|
||||||
timer.Reset();
|
timer.Reset();
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<TreeBuilder<Device>, Device>(
|
vtkm::worklet::DispatcherMapField<TreeBuilder<Device>> treeBuilderDispatcher(
|
||||||
TreeBuilder<Device>(bvh.mortonCodes, bvh.parent, bvh.GetNumberOfPrimitives()))
|
TreeBuilder<Device>(bvh.mortonCodes, bvh.parent, bvh.GetNumberOfPrimitives()));
|
||||||
.Invoke(bvh.leftChild, bvh.rightChild);
|
treeBuilderDispatcher.SetDevice(Device());
|
||||||
|
treeBuilderDispatcher.Invoke(bvh.leftChild, bvh.rightChild);
|
||||||
|
|
||||||
time = timer.GetElapsedTime();
|
time = timer.GetElapsedTime();
|
||||||
logger->AddLogData("build_tree", time);
|
logger->AddLogData("build_tree", time);
|
||||||
@ -772,15 +797,23 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
|||||||
vtkm::cont::ArrayHandle<vtkm::Int32> counters;
|
vtkm::cont::ArrayHandle<vtkm::Int32> counters;
|
||||||
counters.PrepareForOutput(bvh.GetNumberOfPrimitives() - 1, Device());
|
counters.PrepareForOutput(bvh.GetNumberOfPrimitives() - 1, Device());
|
||||||
vtkm::Int32 zero = 0;
|
vtkm::Int32 zero = 0;
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Int32>, Device>(MemSet<vtkm::Int32>(zero))
|
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Int32>> resetCountersDispatcher(
|
||||||
.Invoke(counters);
|
(MemSet<vtkm::Int32>(zero)));
|
||||||
|
resetCountersDispatcher.SetDevice(Device());
|
||||||
|
resetCountersDispatcher.Invoke(counters);
|
||||||
vtkm::cont::AtomicArray<vtkm::Int32> atomicCounters(counters);
|
vtkm::cont::AtomicArray<vtkm::Int32> atomicCounters(counters);
|
||||||
|
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<PropagateAABBs<Device>, Device>(
|
vtkm::worklet::DispatcherMapField<PropagateAABBs<Device>> propagateAABBDispatcher(
|
||||||
PropagateAABBs<Device>(
|
PropagateAABBs<Device>(bvh.parent,
|
||||||
bvh.parent, bvh.leftChild, bvh.rightChild, primitiveCount, linearBVH.FlatBVH, atomicCounters))
|
bvh.leftChild,
|
||||||
.Invoke(*bvh.xmins, *bvh.ymins, *bvh.zmins, *bvh.xmaxs, *bvh.ymaxs, *bvh.zmaxs);
|
bvh.rightChild,
|
||||||
|
primitiveCount,
|
||||||
|
linearBVH.FlatBVH,
|
||||||
|
atomicCounters));
|
||||||
|
propagateAABBDispatcher.SetDevice(Device());
|
||||||
|
propagateAABBDispatcher.Invoke(
|
||||||
|
*bvh.xmins, *bvh.ymins, *bvh.zmins, *bvh.xmaxs, *bvh.ymaxs, *bvh.zmaxs);
|
||||||
|
|
||||||
time = timer.GetElapsedTime();
|
time = timer.GetElapsedTime();
|
||||||
logger->AddLogData("propagate_aabbs", time);
|
logger->AddLogData("propagate_aabbs", time);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <vtkm/VectorAnalysis.h>
|
#include <vtkm/VectorAnalysis.h>
|
||||||
|
|
||||||
|
#include <vtkm/cont/Algorithm.h>
|
||||||
#include <vtkm/cont/ErrorBadValue.h>
|
#include <vtkm/cont/ErrorBadValue.h>
|
||||||
#include <vtkm/cont/Timer.h>
|
#include <vtkm/cont/Timer.h>
|
||||||
#include <vtkm/cont/TryExecute.h>
|
#include <vtkm/cont/TryExecute.h>
|
||||||
@ -659,69 +660,38 @@ struct Camera::CreateRaysFunctor
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Camera::PixelDataFunctor
|
|
||||||
{
|
|
||||||
vtkm::rendering::raytracing::Camera* Self;
|
|
||||||
const vtkm::cont::CoordinateSystem& Coords;
|
|
||||||
vtkm::Int32& ActivePixels;
|
|
||||||
vtkm::Float32& AveDistPerRay;
|
|
||||||
|
|
||||||
VTKM_CONT
|
|
||||||
PixelDataFunctor(vtkm::rendering::raytracing::Camera* self,
|
|
||||||
const vtkm::cont::CoordinateSystem& coords,
|
|
||||||
vtkm::Int32& activePixels,
|
|
||||||
vtkm::Float32& aveDistPerRay)
|
|
||||||
: Self(self)
|
|
||||||
, Coords(coords)
|
|
||||||
, ActivePixels(activePixels)
|
|
||||||
, AveDistPerRay(aveDistPerRay)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
VTKM_CONT bool operator()(Device)
|
|
||||||
{
|
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
|
||||||
|
|
||||||
vtkm::Bounds boundingBox = Coords.GetBounds();
|
|
||||||
Self->FindSubset(boundingBox);
|
|
||||||
//Reset the camera look vector
|
|
||||||
Self->Look = Self->LookAt - Self->Position;
|
|
||||||
vtkm::Normalize(Self->Look);
|
|
||||||
const int size = Self->SubsetWidth * Self->SubsetHeight;
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> dists;
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Int32> hits;
|
|
||||||
dists.PrepareForOutput(size, Device());
|
|
||||||
hits.PrepareForOutput(size, Device());
|
|
||||||
|
|
||||||
//Create the ray direction
|
|
||||||
vtkm::worklet::DispatcherMapField<PixelData, Device>(PixelData(Self->Width,
|
|
||||||
Self->Height,
|
|
||||||
Self->FovX,
|
|
||||||
Self->FovY,
|
|
||||||
Self->Look,
|
|
||||||
Self->Up,
|
|
||||||
Self->Zoom,
|
|
||||||
Self->SubsetWidth,
|
|
||||||
Self->SubsetMinX,
|
|
||||||
Self->SubsetMinY,
|
|
||||||
Self->Position,
|
|
||||||
boundingBox))
|
|
||||||
.Invoke(hits, dists); //X Y Z
|
|
||||||
ActivePixels = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(hits, vtkm::Int32(0));
|
|
||||||
AveDistPerRay = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(dists, vtkm::Float32(0)) /
|
|
||||||
vtkm::Float32(ActivePixels);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void Camera::GetPixelData(const vtkm::cont::CoordinateSystem& coords,
|
void Camera::GetPixelData(const vtkm::cont::CoordinateSystem& coords,
|
||||||
vtkm::Int32& activePixels,
|
vtkm::Int32& activePixels,
|
||||||
vtkm::Float32& aveRayDistance)
|
vtkm::Float32& aveRayDistance)
|
||||||
{
|
{
|
||||||
|
vtkm::Bounds boundingBox = coords.GetBounds();
|
||||||
|
this->FindSubset(boundingBox);
|
||||||
|
//Reset the camera look vector
|
||||||
|
this->Look = this->LookAt - this->Position;
|
||||||
|
vtkm::Normalize(this->Look);
|
||||||
|
const int size = this->SubsetWidth * this->SubsetHeight;
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Float32> dists;
|
||||||
|
vtkm::cont::ArrayHandle<vtkm::Int32> hits;
|
||||||
|
dists.Allocate(size);
|
||||||
|
hits.Allocate(size);
|
||||||
|
|
||||||
PixelDataFunctor functor(this, coords, activePixels, aveRayDistance);
|
//Create the ray direction
|
||||||
vtkm::cont::TryExecute(functor);
|
vtkm::worklet::DispatcherMapField<PixelData>(PixelData(this->Width,
|
||||||
|
this->Height,
|
||||||
|
this->FovX,
|
||||||
|
this->FovY,
|
||||||
|
this->Look,
|
||||||
|
this->Up,
|
||||||
|
this->Zoom,
|
||||||
|
this->SubsetWidth,
|
||||||
|
this->SubsetMinX,
|
||||||
|
this->SubsetMinY,
|
||||||
|
this->Position,
|
||||||
|
boundingBox))
|
||||||
|
.Invoke(hits, dists); //X Y Z
|
||||||
|
activePixels = vtkm::cont::Algorithm::Reduce(hits, vtkm::Int32(0));
|
||||||
|
aveRayDistance =
|
||||||
|
vtkm::cont::Algorithm::Reduce(dists, vtkm::Float32(0)) / vtkm::Float32(activePixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
@ -758,18 +728,20 @@ VTKM_CONT void Camera::CreateRaysOnDevice(Ray<Precision>& rays,
|
|||||||
Precision infinity;
|
Precision infinity;
|
||||||
GetInfinity(infinity);
|
GetInfinity(infinity);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(MemSet<Precision>(infinity))
|
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSetInfDispatcher(
|
||||||
.Invoke(rays.MaxDistance);
|
(MemSet<Precision>(infinity)));
|
||||||
|
memSetInfDispatcher.SetDevice(Device());
|
||||||
|
memSetInfDispatcher.Invoke(rays.MaxDistance);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(MemSet<Precision>(0.f))
|
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSet0Dispatcher((MemSet<Precision>(0.f)));
|
||||||
.Invoke(rays.MinDistance);
|
memSet0Dispatcher.SetDevice(Device());
|
||||||
|
memSet0Dispatcher.Invoke(rays.MinDistance);
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(MemSet<Precision>(0.f))
|
memSet0Dispatcher.Invoke(rays.Distance);
|
||||||
.Invoke(rays.Distance);
|
|
||||||
|
|
||||||
//Reset the Rays Hit Index to -2
|
//Reset the Rays Hit Index to -2
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Id>, Device>(MemSet<vtkm::Id>(-2))
|
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Id>> memSetM2Dispatcher((MemSet<vtkm::Id>(-2)));
|
||||||
.Invoke(rays.HitIdx);
|
memSetM2Dispatcher.SetDevice(Device());
|
||||||
|
memSetM2Dispatcher.Invoke(rays.HitIdx);
|
||||||
|
|
||||||
vtkm::Float64 time = timer.GetElapsedTime();
|
vtkm::Float64 time = timer.GetElapsedTime();
|
||||||
logger->AddLogData("camera_memset", time);
|
logger->AddLogData("camera_memset", time);
|
||||||
@ -781,25 +753,26 @@ VTKM_CONT void Camera::CreateRaysOnDevice(Ray<Precision>& rays,
|
|||||||
if (ortho)
|
if (ortho)
|
||||||
{
|
{
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<Ortho2DRayGen, Device>(Ortho2DRayGen(this->Width,
|
vtkm::worklet::DispatcherMapField<Ortho2DRayGen> dispatcher(Ortho2DRayGen(this->Width,
|
||||||
this->Height,
|
this->Height,
|
||||||
this->Zoom,
|
this->Zoom,
|
||||||
this->SubsetWidth,
|
this->SubsetWidth,
|
||||||
this->SubsetMinX,
|
this->SubsetMinX,
|
||||||
this->SubsetMinY,
|
this->SubsetMinY,
|
||||||
this->CameraView))
|
this->CameraView));
|
||||||
.Invoke(rays.DirX,
|
dispatcher.SetDevice(Device());
|
||||||
rays.DirY,
|
dispatcher.Invoke(rays.DirX,
|
||||||
rays.DirZ,
|
rays.DirY,
|
||||||
rays.OriginX,
|
rays.DirZ,
|
||||||
rays.OriginY,
|
rays.OriginX,
|
||||||
rays.OriginZ,
|
rays.OriginY,
|
||||||
rays.PixelIdx); //X Y Z
|
rays.OriginZ,
|
||||||
|
rays.PixelIdx); //X Y Z
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Create the ray direction
|
//Create the ray direction
|
||||||
vtkm::worklet::DispatcherMapField<PerspectiveRayGen, Device>(
|
vtkm::worklet::DispatcherMapField<PerspectiveRayGen> dispatcher(
|
||||||
PerspectiveRayGen(this->Width,
|
PerspectiveRayGen(this->Width,
|
||||||
this->Height,
|
this->Height,
|
||||||
this->FovX,
|
this->FovX,
|
||||||
@ -809,23 +782,24 @@ VTKM_CONT void Camera::CreateRaysOnDevice(Ray<Precision>& rays,
|
|||||||
this->Zoom,
|
this->Zoom,
|
||||||
this->SubsetWidth,
|
this->SubsetWidth,
|
||||||
this->SubsetMinX,
|
this->SubsetMinX,
|
||||||
this->SubsetMinY))
|
this->SubsetMinY));
|
||||||
.Invoke(rays.DirX,
|
dispatcher.SetDevice(Device());
|
||||||
rays.DirY,
|
dispatcher.Invoke(rays.DirX, rays.DirY, rays.DirZ, rays.PixelIdx); //X Y Z
|
||||||
rays.DirZ,
|
|
||||||
rays.PixelIdx); //X Y Z
|
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(
|
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSetPos0Dispatcher(
|
||||||
MemSet<Precision>(this->Position[0]))
|
MemSet<Precision>(this->Position[0]));
|
||||||
.Invoke(rays.OriginX);
|
memSetPos0Dispatcher.SetDevice(Device());
|
||||||
|
memSetPos0Dispatcher.Invoke(rays.OriginX);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(
|
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSetPos1Dispatcher(
|
||||||
MemSet<Precision>(this->Position[1]))
|
MemSet<Precision>(this->Position[1]));
|
||||||
.Invoke(rays.OriginY);
|
memSetPos1Dispatcher.SetDevice(Device());
|
||||||
|
memSetPos1Dispatcher.Invoke(rays.OriginY);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(
|
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSetPos2Dispatcher(
|
||||||
MemSet<Precision>(this->Position[2]))
|
MemSet<Precision>(this->Position[2]));
|
||||||
.Invoke(rays.OriginZ);
|
memSetPos2Dispatcher.SetDevice(Device());
|
||||||
|
memSetPos2Dispatcher.Invoke(rays.OriginZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
time = timer.GetElapsedTime();
|
time = timer.GetElapsedTime();
|
||||||
|
@ -39,26 +39,6 @@ namespace rendering
|
|||||||
namespace raytracing
|
namespace raytracing
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename Precision, typename OpWorklet>
|
|
||||||
struct BufferMathFunctor
|
|
||||||
{
|
|
||||||
ChannelBuffer<Precision>* Self;
|
|
||||||
const ChannelBuffer<Precision>* Other;
|
|
||||||
BufferMathFunctor(ChannelBuffer<Precision>* self, const ChannelBuffer<Precision>* other)
|
|
||||||
: Self(self)
|
|
||||||
, Other(other)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
bool operator()(Device vtkmNotUsed(device))
|
|
||||||
{
|
|
||||||
vtkm::worklet::DispatcherMapField<OpWorklet, Device>(OpWorklet())
|
|
||||||
.Invoke(Other->Buffer, Self->Buffer);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class BufferAddition : public vtkm::worklet::WorkletMapField
|
class BufferAddition : public vtkm::worklet::WorkletMapField
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -150,8 +130,7 @@ void ChannelBuffer<Precision>::AddBuffer(const ChannelBuffer<Precision>& other)
|
|||||||
if (this->Size != other.GetSize())
|
if (this->Size != other.GetSize())
|
||||||
throw vtkm::cont::ErrorBadValue("ChannelBuffer add: size must be equal");
|
throw vtkm::cont::ErrorBadValue("ChannelBuffer add: size must be equal");
|
||||||
|
|
||||||
BufferMathFunctor<Precision, BufferAddition> functor(this, &other);
|
vtkm::worklet::DispatcherMapField<BufferAddition>().Invoke(other.Buffer, this->Buffer);
|
||||||
vtkm::cont::TryExecute(functor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Precision>
|
template <typename Precision>
|
||||||
@ -162,8 +141,7 @@ void ChannelBuffer<Precision>::MultiplyBuffer(const ChannelBuffer<Precision>& ot
|
|||||||
if (this->Size != other.GetSize())
|
if (this->Size != other.GetSize())
|
||||||
throw vtkm::cont::ErrorBadValue("ChannelBuffer add: size must be equal");
|
throw vtkm::cont::ErrorBadValue("ChannelBuffer add: size must be equal");
|
||||||
|
|
||||||
BufferMathFunctor<Precision, BufferMultiply> functor(this, &other);
|
vtkm::worklet::DispatcherMapField<BufferMultiply>().Invoke(other.Buffer, this->Buffer);
|
||||||
vtkm::cont::TryExecute(functor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Precision>
|
template <typename Precision>
|
||||||
@ -221,9 +199,10 @@ struct ExtractChannelFunctor
|
|||||||
bool operator()(Device device)
|
bool operator()(Device device)
|
||||||
{
|
{
|
||||||
Output.PrepareForOutput(Self->GetSize(), device);
|
Output.PrepareForOutput(Self->GetSize(), device);
|
||||||
vtkm::worklet::DispatcherMapField<ExtractChannel, Device>(
|
vtkm::worklet::DispatcherMapField<ExtractChannel> dispatcher(
|
||||||
ExtractChannel(Self->GetNumChannels(), Channel))
|
ExtractChannel(Self->GetNumChannels(), Channel));
|
||||||
.Invoke(Output, Self->Buffer);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(Output, Self->Buffer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -307,8 +286,9 @@ struct ExpandFunctorSignature
|
|||||||
Output->Buffer.PrepareForOutput(totalSize, device);
|
Output->Buffer.PrepareForOutput(totalSize, device);
|
||||||
ChannelBufferOperations::InitChannels(*Output, Signature, device);
|
ChannelBufferOperations::InitChannels(*Output, Signature, device);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<Expand, Device>(Expand(NumChannels))
|
vtkm::worklet::DispatcherMapField<Expand> dispatcher((Expand(NumChannels)));
|
||||||
.Invoke(Input, SparseIndexes, Output->Buffer);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(Input, SparseIndexes, Output->Buffer);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -347,8 +327,9 @@ struct ExpandFunctor
|
|||||||
Output->Buffer.PrepareForOutput(totalSize, device);
|
Output->Buffer.PrepareForOutput(totalSize, device);
|
||||||
ChannelBufferOperations::InitConst(*Output, InitVal, device);
|
ChannelBufferOperations::InitConst(*Output, InitVal, device);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<Expand, Device>(Expand(NumChannels))
|
vtkm::worklet::DispatcherMapField<Expand> dispatcher((Expand(NumChannels)));
|
||||||
.Invoke(Input, SparseIndexes, Output->Buffer);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(Input, SparseIndexes, Output->Buffer);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -410,9 +391,10 @@ struct NormalizeFunctor
|
|||||||
asField.GetRange(&range);
|
asField.GetRange(&range);
|
||||||
Precision minScalar = static_cast<Precision>(range.Min);
|
Precision minScalar = static_cast<Precision>(range.Min);
|
||||||
Precision maxScalar = static_cast<Precision>(range.Max);
|
Precision maxScalar = static_cast<Precision>(range.Max);
|
||||||
vtkm::worklet::DispatcherMapField<NormalizeBuffer<Precision>, Device>(
|
vtkm::worklet::DispatcherMapField<NormalizeBuffer<Precision>> dispatcher(
|
||||||
NormalizeBuffer<Precision>(minScalar, maxScalar, Invert))
|
NormalizeBuffer<Precision>(minScalar, maxScalar, Invert));
|
||||||
.Invoke(Input);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(Input);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -116,9 +116,10 @@ public:
|
|||||||
vtkm::cont::ArrayHandle<Precision> compactedBuffer;
|
vtkm::cont::ArrayHandle<Precision> compactedBuffer;
|
||||||
compactedBuffer.PrepareForOutput(newSize * buffer.NumChannels, Device());
|
compactedBuffer.PrepareForOutput(newSize * buffer.NumChannels, Device());
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<detail::CompactBuffer, Device>(
|
vtkm::worklet::DispatcherMapField<detail::CompactBuffer> dispatcher(
|
||||||
detail::CompactBuffer(buffer.NumChannels))
|
detail::CompactBuffer(buffer.NumChannels));
|
||||||
.Invoke(masks, buffer.Buffer, offsets, compactedBuffer);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(masks, buffer.Buffer, offsets, compactedBuffer);
|
||||||
buffer.Buffer = compactedBuffer;
|
buffer.Buffer = compactedBuffer;
|
||||||
buffer.Size = newSize;
|
buffer.Size = newSize;
|
||||||
}
|
}
|
||||||
@ -133,16 +134,19 @@ public:
|
|||||||
std::string msg = "ChannelBuffer: number of bins in sourse signature must match NumChannels";
|
std::string msg = "ChannelBuffer: number of bins in sourse signature must match NumChannels";
|
||||||
throw vtkm::cont::ErrorBadValue(msg);
|
throw vtkm::cont::ErrorBadValue(msg);
|
||||||
}
|
}
|
||||||
vtkm::worklet::DispatcherMapField<detail::InitBuffer, Device>(
|
vtkm::worklet::DispatcherMapField<detail::InitBuffer> initBufferDispatcher(
|
||||||
detail::InitBuffer(buffer.NumChannels))
|
detail::InitBuffer(buffer.NumChannels));
|
||||||
.Invoke(buffer.Buffer, sourceSignature);
|
initBufferDispatcher.SetDevice(Device());
|
||||||
|
initBufferDispatcher.Invoke(buffer.Buffer, sourceSignature);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Device, typename Precision>
|
template <typename Device, typename Precision>
|
||||||
static void InitConst(ChannelBuffer<Precision>& buffer, const Precision value, Device)
|
static void InitConst(ChannelBuffer<Precision>& buffer, const Precision value, Device)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(MemSet<Precision>(value))
|
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSetDispatcher(
|
||||||
.Invoke(buffer.Buffer);
|
(MemSet<Precision>(value)));
|
||||||
|
memSetDispatcher.SetDevice(Device());
|
||||||
|
memSetDispatcher.Invoke(buffer.Buffer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -101,19 +101,24 @@ void RayTracking<FloatType>::Init(const vtkm::Id size,
|
|||||||
//
|
//
|
||||||
// Set the initial Distances
|
// Set the initial Distances
|
||||||
//
|
//
|
||||||
vtkm::worklet::DispatcherMapField<CopyAndOffset<FloatType>, Device>(
|
vtkm::worklet::DispatcherMapField<CopyAndOffset<FloatType>> resetDistancesDispatcher(
|
||||||
CopyAndOffset<FloatType>(0.0f))
|
CopyAndOffset<FloatType>(0.0f));
|
||||||
.Invoke(distances, *EnterDist);
|
resetDistancesDispatcher.SetDevice(Device());
|
||||||
|
resetDistancesDispatcher.Invoke(distances, *EnterDist);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Init the exit faces. This value is used to load the next cell
|
// Init the exit faces. This value is used to load the next cell
|
||||||
// base on the cell and face it left
|
// base on the cell and face it left
|
||||||
//
|
//
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Int32>, Device>(MemSet<vtkm::Int32>(-1))
|
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Int32>> initExitFaceDispatcher(
|
||||||
.Invoke(ExitFace);
|
MemSet<vtkm::Int32>(-1));
|
||||||
|
initExitFaceDispatcher.SetDevice(Device());
|
||||||
|
initExitFaceDispatcher.Invoke(ExitFace);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<FloatType>, Device>(MemSet<FloatType>(-1))
|
vtkm::worklet::DispatcherMapField<MemSet<FloatType>> initExitDistanceDispatcher(
|
||||||
.Invoke(*ExitDist);
|
MemSet<FloatType>(-1));
|
||||||
|
initExitDistanceDispatcher.SetDevice(Device());
|
||||||
|
initExitDistanceDispatcher.Invoke(*ExitDist);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FloatType>
|
template <typename FloatType>
|
||||||
@ -956,15 +961,16 @@ void ConnectivityTracer<CellType, ConnectivityType>::IntersectCell(
|
|||||||
{
|
{
|
||||||
using LocateC = LocateCell<CellType, FloatType, MeshConnExec<ConnectivityType, Device>>;
|
using LocateC = LocateCell<CellType, FloatType, MeshConnExec<ConnectivityType, Device>>;
|
||||||
vtkm::cont::Timer<Device> timer;
|
vtkm::cont::Timer<Device> timer;
|
||||||
vtkm::worklet::DispatcherMapField<LocateC, Device>(LocateC(MeshConn))
|
vtkm::worklet::DispatcherMapField<LocateC> dispatcher((LocateC(MeshConn)));
|
||||||
.Invoke(rays.HitIdx,
|
dispatcher.SetDevice(Device());
|
||||||
this->MeshConn.GetCoordinates(),
|
dispatcher.Invoke(rays.HitIdx,
|
||||||
rays.Dir,
|
this->MeshConn.GetCoordinates(),
|
||||||
*(tracker.EnterDist),
|
rays.Dir,
|
||||||
*(tracker.ExitDist),
|
*(tracker.EnterDist),
|
||||||
tracker.ExitFace,
|
*(tracker.ExitDist),
|
||||||
rays.Status,
|
tracker.ExitFace,
|
||||||
rays.Origin);
|
rays.Status,
|
||||||
|
rays.Origin);
|
||||||
|
|
||||||
if (this->CountRayStatus)
|
if (this->CountRayStatus)
|
||||||
RaysLost = RayOperations::GetStatusCount(rays, RAY_LOST, Device());
|
RaysLost = RayOperations::GetStatusCount(rays, RAY_LOST, Device());
|
||||||
@ -978,11 +984,11 @@ void ConnectivityTracer<CellType, ConnectivityType>::AccumulatePathLengths(
|
|||||||
detail::RayTracking<FloatType>& tracker,
|
detail::RayTracking<FloatType>& tracker,
|
||||||
Device)
|
Device)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<AddPathLengths<FloatType>, Device>(AddPathLengths<FloatType>())
|
vtkm::worklet::DispatcherMapField<AddPathLengths<FloatType>> dispatcher(
|
||||||
.Invoke(rays.Status,
|
(AddPathLengths<FloatType>()));
|
||||||
*(tracker.EnterDist),
|
dispatcher.SetDevice(Device());
|
||||||
*(tracker.ExitDist),
|
dispatcher.Invoke(
|
||||||
rays.GetBuffer("path_lengths").Buffer);
|
rays.Status, *(tracker.EnterDist), *(tracker.ExitDist), rays.GetBuffer("path_lengths").Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <vtkm::Int32 CellType, typename ConnectivityType>
|
template <vtkm::Int32 CellType, typename ConnectivityType>
|
||||||
@ -995,15 +1001,16 @@ void ConnectivityTracer<CellType, ConnectivityType>::FindLostRays(
|
|||||||
using RayB = RayBumper<CellType, FloatType, Device, MeshConnExec<ConnectivityType, Device>>;
|
using RayB = RayBumper<CellType, FloatType, Device, MeshConnExec<ConnectivityType, Device>>;
|
||||||
vtkm::cont::Timer<Device> timer;
|
vtkm::cont::Timer<Device> timer;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<RayB, Device>(
|
vtkm::worklet::DispatcherMapField<RayB> dispatcher(
|
||||||
RayB(rays.DirX, rays.DirY, rays.DirZ, this->MeshConn))
|
RayB(rays.DirX, rays.DirY, rays.DirZ, this->MeshConn));
|
||||||
.Invoke(rays.HitIdx,
|
dispatcher.SetDevice(Device());
|
||||||
this->MeshConn.GetCoordinates(),
|
dispatcher.Invoke(rays.HitIdx,
|
||||||
*(tracker.EnterDist),
|
this->MeshConn.GetCoordinates(),
|
||||||
*(tracker.ExitDist),
|
*(tracker.EnterDist),
|
||||||
tracker.ExitFace,
|
*(tracker.ExitDist),
|
||||||
rays.Status,
|
tracker.ExitFace,
|
||||||
rays.Origin);
|
rays.Status,
|
||||||
|
rays.Origin);
|
||||||
|
|
||||||
this->LostRayTime += timer.GetElapsedTime();
|
this->LostRayTime += timer.GetElapsedTime();
|
||||||
}
|
}
|
||||||
@ -1025,38 +1032,40 @@ void ConnectivityTracer<CellType, ConnectivityType>::SampleCells(
|
|||||||
|
|
||||||
if (FieldAssocPoints)
|
if (FieldAssocPoints)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<SampleP, Device>(
|
vtkm::worklet::DispatcherMapField<SampleP> dispatcher(
|
||||||
SampleP(this->SampleDistance,
|
SampleP(this->SampleDistance,
|
||||||
vtkm::Float32(this->ScalarBounds.Min),
|
vtkm::Float32(this->ScalarBounds.Min),
|
||||||
vtkm::Float32(this->ScalarBounds.Max),
|
vtkm::Float32(this->ScalarBounds.Max),
|
||||||
this->ColorMap,
|
this->ColorMap,
|
||||||
rays.Buffers.at(0).Buffer,
|
rays.Buffers.at(0).Buffer,
|
||||||
this->MeshConn))
|
this->MeshConn));
|
||||||
.Invoke(rays.HitIdx,
|
dispatcher.SetDevice(Device());
|
||||||
this->MeshConn.GetCoordinates(),
|
dispatcher.Invoke(rays.HitIdx,
|
||||||
this->ScalarField.GetData(),
|
this->MeshConn.GetCoordinates(),
|
||||||
*(tracker.EnterDist),
|
this->ScalarField.GetData(),
|
||||||
*(tracker.ExitDist),
|
*(tracker.EnterDist),
|
||||||
tracker.CurrentDistance,
|
*(tracker.ExitDist),
|
||||||
rays.Dir,
|
tracker.CurrentDistance,
|
||||||
rays.Status,
|
rays.Dir,
|
||||||
rays.Origin);
|
rays.Status,
|
||||||
|
rays.Origin);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<SampleC, Device>(
|
vtkm::worklet::DispatcherMapField<SampleC> dispatcher(
|
||||||
SampleC(this->SampleDistance,
|
SampleC(this->SampleDistance,
|
||||||
vtkm::Float32(this->ScalarBounds.Min),
|
vtkm::Float32(this->ScalarBounds.Min),
|
||||||
vtkm::Float32(this->ScalarBounds.Max),
|
vtkm::Float32(this->ScalarBounds.Max),
|
||||||
this->ColorMap,
|
this->ColorMap,
|
||||||
rays.Buffers.at(0).Buffer,
|
rays.Buffers.at(0).Buffer,
|
||||||
this->MeshConn))
|
this->MeshConn));
|
||||||
.Invoke(rays.HitIdx,
|
dispatcher.SetDevice(Device());
|
||||||
this->ScalarField.GetData(),
|
dispatcher.Invoke(rays.HitIdx,
|
||||||
*(tracker.EnterDist),
|
this->ScalarField.GetData(),
|
||||||
*(tracker.ExitDist),
|
*(tracker.EnterDist),
|
||||||
tracker.CurrentDistance,
|
*(tracker.ExitDist),
|
||||||
rays.Status);
|
tracker.CurrentDistance,
|
||||||
|
rays.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SampleTime += timer.GetElapsedTime();
|
this->SampleTime += timer.GetElapsedTime();
|
||||||
@ -1075,29 +1084,31 @@ void ConnectivityTracer<CellType, ConnectivityType>::IntegrateCells(
|
|||||||
bool divideEmisByAbsorp = false;
|
bool divideEmisByAbsorp = false;
|
||||||
vtkm::cont::ArrayHandle<FloatType> absorp = rays.Buffers.at(0).Buffer;
|
vtkm::cont::ArrayHandle<FloatType> absorp = rays.Buffers.at(0).Buffer;
|
||||||
vtkm::cont::ArrayHandle<FloatType> emission = rays.GetBuffer("emission").Buffer;
|
vtkm::cont::ArrayHandle<FloatType> emission = rays.GetBuffer("emission").Buffer;
|
||||||
vtkm::worklet::DispatcherMapField<IntegrateEmission<FloatType>, Device>(
|
vtkm::worklet::DispatcherMapField<IntegrateEmission<FloatType>> dispatcher(
|
||||||
IntegrateEmission<FloatType>(rays.Buffers.at(0).GetNumChannels(), divideEmisByAbsorp))
|
IntegrateEmission<FloatType>(rays.Buffers.at(0).GetNumChannels(), divideEmisByAbsorp));
|
||||||
.Invoke(rays.Status,
|
dispatcher.SetDevice(Device());
|
||||||
*(tracker.EnterDist),
|
dispatcher.Invoke(rays.Status,
|
||||||
*(tracker.ExitDist),
|
*(tracker.EnterDist),
|
||||||
rays.Distance,
|
*(tracker.ExitDist),
|
||||||
this->ScalarField.GetData(),
|
rays.Distance,
|
||||||
this->EmissionField.GetData(),
|
this->ScalarField.GetData(),
|
||||||
absorp,
|
this->EmissionField.GetData(),
|
||||||
emission,
|
absorp,
|
||||||
rays.HitIdx);
|
emission,
|
||||||
|
rays.HitIdx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<Integrate<FloatType>, Device>(
|
vtkm::worklet::DispatcherMapField<Integrate<FloatType>> dispatcher(
|
||||||
Integrate<FloatType>(rays.Buffers.at(0).GetNumChannels()))
|
Integrate<FloatType>(rays.Buffers.at(0).GetNumChannels()));
|
||||||
.Invoke(rays.Status,
|
dispatcher.SetDevice(Device());
|
||||||
*(tracker.EnterDist),
|
dispatcher.Invoke(rays.Status,
|
||||||
*(tracker.ExitDist),
|
*(tracker.EnterDist),
|
||||||
rays.Distance,
|
*(tracker.ExitDist),
|
||||||
this->ScalarField.GetData(),
|
rays.Distance,
|
||||||
rays.Buffers.at(0).Buffer,
|
this->ScalarField.GetData(),
|
||||||
rays.HitIdx);
|
rays.Buffers.at(0).Buffer,
|
||||||
|
rays.HitIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntegrateTime += timer.GetElapsedTime();
|
IntegrateTime += timer.GetElapsedTime();
|
||||||
@ -1136,9 +1147,10 @@ template <typename FloatType, typename Device>
|
|||||||
void ConnectivityTracer<CellType, ConnectivityType>::OffsetMinDistances(Ray<FloatType>& rays,
|
void ConnectivityTracer<CellType, ConnectivityType>::OffsetMinDistances(Ray<FloatType>& rays,
|
||||||
Device)
|
Device)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<AdvanceRay<FloatType>, Device>(
|
vtkm::worklet::DispatcherMapField<AdvanceRay<FloatType>> dispatcher(
|
||||||
AdvanceRay<FloatType>(FloatType(0.001)))
|
AdvanceRay<FloatType>(FloatType(0.001)));
|
||||||
.Invoke(rays.Status, rays.MinDistance);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(rays.Status, rays.MinDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <vtkm::Int32 CellType, typename ConnectivityType>
|
template <vtkm::Int32 CellType, typename ConnectivityType>
|
||||||
@ -1253,9 +1265,10 @@ void ConnectivityTracer<CellType, ConnectivityType>::RenderOnDevice(Ray<FloatTyp
|
|||||||
{
|
{
|
||||||
|
|
||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> pCounter(0, 1, rays.NumRays);
|
vtkm::cont::ArrayHandleCounting<vtkm::Id> pCounter(0, 1, rays.NumRays);
|
||||||
vtkm::worklet::DispatcherMapField<IdentifyMissedRay, Device>(
|
vtkm::worklet::DispatcherMapField<IdentifyMissedRay> dispatcher(
|
||||||
IdentifyMissedRay(rays.DebugWidth, rays.DebugHeight, this->BackgroundColor))
|
IdentifyMissedRay(rays.DebugWidth, rays.DebugHeight, this->BackgroundColor));
|
||||||
.Invoke(pCounter, rays.Buffers.at(0).Buffer);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(pCounter, rays.Buffers.at(0).Buffer);
|
||||||
}
|
}
|
||||||
vtkm::Float64 renderTime = renderTimer.GetElapsedTime();
|
vtkm::Float64 renderTime = renderTimer.GetElapsedTime();
|
||||||
this->LogTimers();
|
this->LogTimers();
|
||||||
|
@ -571,8 +571,9 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// scatter the coonectivity into the original order
|
// scatter the coonectivity into the original order
|
||||||
vtkm::worklet::DispatcherMapField<WriteFaceConn, DeviceAdapter>(WriteFaceConn())
|
vtkm::worklet::DispatcherMapField<WriteFaceConn> dispatcherWriteFaceConn;
|
||||||
.Invoke(cellFaceId, this->FaceOffsets, faceConnectivity);
|
dispatcherWriteFaceConn.SetDevice(DeviceAdapter());
|
||||||
|
dispatcherWriteFaceConn.Invoke(cellFaceId, this->FaceOffsets, faceConnectivity);
|
||||||
|
|
||||||
|
|
||||||
FaceConnectivity = faceConnectivity;
|
FaceConnectivity = faceConnectivity;
|
||||||
@ -628,8 +629,9 @@ public:
|
|||||||
this->ExtractExternalFaces(cellFaceId, faceConnectivity, shapes, conn, shapeOffsets);
|
this->ExtractExternalFaces(cellFaceId, faceConnectivity, shapes, conn, shapeOffsets);
|
||||||
|
|
||||||
// scatter the coonectivity into the original order
|
// scatter the coonectivity into the original order
|
||||||
vtkm::worklet::DispatcherMapField<WriteFaceConn, DeviceAdapter>(WriteFaceConn())
|
vtkm::worklet::DispatcherMapField<WriteFaceConn> dispatcher{ (WriteFaceConn{}) };
|
||||||
.Invoke(cellFaceId, this->FaceOffsets, faceConnectivity);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
dispatcher.Invoke(cellFaceId, this->FaceOffsets, faceConnectivity);
|
||||||
|
|
||||||
FaceConnectivity = faceConnectivity;
|
FaceConnectivity = faceConnectivity;
|
||||||
OutsideTriangles = externalTriangles;
|
OutsideTriangles = externalTriangles;
|
||||||
@ -653,10 +655,11 @@ public:
|
|||||||
triangles.PrepareForOutput(numFaces * 2, DeviceAdapter());
|
triangles.PrepareForOutput(numFaces * 2, DeviceAdapter());
|
||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> counting(0, 1, numFaces);
|
vtkm::cont::ArrayHandleCounting<vtkm::Id> counting(0, 1, numFaces);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<StructuredExternalTriangles, DeviceAdapter>(
|
vtkm::worklet::DispatcherMapField<StructuredExternalTriangles> dispatcher(
|
||||||
StructuredExternalTriangles(cellSetStructured.PrepareForInput(
|
StructuredExternalTriangles(cellSetStructured.PrepareForInput(
|
||||||
DeviceAdapter(), vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell())))
|
DeviceAdapter(), vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell())));
|
||||||
.Invoke(counting, triangles);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
dispatcher.Invoke(counting, triangles);
|
||||||
|
|
||||||
vtkm::Float64 time = timer.GetElapsedTime();
|
vtkm::Float64 time = timer.GetElapsedTime();
|
||||||
Logger::GetInstance()->AddLogData("structured_external_faces", time);
|
Logger::GetInstance()->AddLogData("structured_external_faces", time);
|
||||||
@ -701,8 +704,9 @@ protected:
|
|||||||
// Count the number of total faces in the cell set
|
// Count the number of total faces in the cell set
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> facesPerCell;
|
vtkm::cont::ArrayHandle<vtkm::Id> facesPerCell;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<CountFaces, DeviceAdapter>(CountFaces())
|
vtkm::worklet::DispatcherMapField<CountFaces> countFacesDispatcher{ (CountFaces{}) };
|
||||||
.Invoke(shapes, facesPerCell);
|
countFacesDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
countFacesDispatcher.Invoke(shapes, facesPerCell);
|
||||||
|
|
||||||
vtkm::Id totalFaces = 0;
|
vtkm::Id totalFaces = 0;
|
||||||
totalFaces =
|
totalFaces =
|
||||||
@ -744,9 +748,10 @@ protected:
|
|||||||
vtkm::cont::ArrayHandle<vtkm::UInt32> faceMortonCodes;
|
vtkm::cont::ArrayHandle<vtkm::UInt32> faceMortonCodes;
|
||||||
cellFaceId.PrepareForOutput(totalFaces, DeviceAdapter());
|
cellFaceId.PrepareForOutput(totalFaces, DeviceAdapter());
|
||||||
faceMortonCodes.PrepareForOutput(totalFaces, DeviceAdapter());
|
faceMortonCodes.PrepareForOutput(totalFaces, DeviceAdapter());
|
||||||
vtkm::worklet::DispatcherMapTopology<MortonCodeFace, DeviceAdapter>(
|
vtkm::worklet::DispatcherMapTopology<MortonCodeFace> mortonCodeFaceDispatcher(
|
||||||
MortonCodeFace(inverseExtent, minPoint))
|
MortonCodeFace(inverseExtent, minPoint));
|
||||||
.Invoke(cellSet, coordinates, cellOffsets, faceMortonCodes, cellFaceId);
|
mortonCodeFaceDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
mortonCodeFaceDispatcher.Invoke(cellSet, coordinates, cellOffsets, faceMortonCodes, cellFaceId);
|
||||||
|
|
||||||
// Sort the "faces" (i.e., morton codes)
|
// Sort the "faces" (i.e., morton codes)
|
||||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::SortByKey(faceMortonCodes, cellFaceId);
|
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::SortByKey(faceMortonCodes, cellFaceId);
|
||||||
@ -755,11 +760,15 @@ protected:
|
|||||||
faceConnectivity.PrepareForOutput(totalFaces, DeviceAdapter());
|
faceConnectivity.PrepareForOutput(totalFaces, DeviceAdapter());
|
||||||
|
|
||||||
// Initialize All connecting faces to -1 (connects to nothing)
|
// Initialize All connecting faces to -1 (connects to nothing)
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Id>, DeviceAdapter>(MemSet<vtkm::Id>(-1))
|
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Id>> memSetDispatcher(MemSet<vtkm::Id>(-1));
|
||||||
.Invoke(faceConnectivity);
|
memSetDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
memSetDispatcher.Invoke(faceConnectivity);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<MortonNeighbor, DeviceAdapter>(MortonNeighbor())
|
vtkm::worklet::DispatcherMapField<MortonNeighbor> mortonNeighborDispatcher{ (
|
||||||
.Invoke(faceMortonCodes, cellFaceId, conn, shapes, shapeOffsets, faceConnectivity);
|
MortonNeighbor{}) };
|
||||||
|
mortonNeighborDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
mortonNeighborDispatcher.Invoke(
|
||||||
|
faceMortonCodes, cellFaceId, conn, shapes, shapeOffsets, faceConnectivity);
|
||||||
|
|
||||||
vtkm::Float64 time = timer.GetElapsedTime();
|
vtkm::Float64 time = timer.GetElapsedTime();
|
||||||
Logger::GetInstance()->AddLogData("gen_face_conn", time);
|
Logger::GetInstance()->AddLogData("gen_face_conn", time);
|
||||||
@ -792,9 +801,10 @@ protected:
|
|||||||
trianglesPerExternalFace.PrepareForOutput(numExternalFaces, DeviceAdapter());
|
trianglesPerExternalFace.PrepareForOutput(numExternalFaces, DeviceAdapter());
|
||||||
|
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<CountExternalTriangles, DeviceAdapter>(
|
vtkm::worklet::DispatcherMapField<CountExternalTriangles> countExternalDispatcher{ (
|
||||||
CountExternalTriangles())
|
CountExternalTriangles{}) };
|
||||||
.Invoke(externalFacePairs, shapes, trianglesPerExternalFace);
|
countExternalDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
countExternalDispatcher.Invoke(externalFacePairs, shapes, trianglesPerExternalFace);
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> externalTriangleOffsets;
|
vtkm::cont::ArrayHandle<vtkm::Id> externalTriangleOffsets;
|
||||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::ScanExclusive(trianglesPerExternalFace,
|
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::ScanExclusive(trianglesPerExternalFace,
|
||||||
@ -807,9 +817,11 @@ protected:
|
|||||||
externalTriangles.PrepareForOutput(totalExternalTriangles, DeviceAdapter());
|
externalTriangles.PrepareForOutput(totalExternalTriangles, DeviceAdapter());
|
||||||
//count the number triangles in the external faces
|
//count the number triangles in the external faces
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<ExternalTriangles, DeviceAdapter>(ExternalTriangles())
|
vtkm::worklet::DispatcherMapField<ExternalTriangles> externalTriDispatcher{ (
|
||||||
.Invoke(
|
ExternalTriangles{}) };
|
||||||
externalFacePairs, shapes, shapeOffsets, conn, externalTriangles, externalTriangleOffsets);
|
externalTriDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
externalTriDispatcher.Invoke(
|
||||||
|
externalFacePairs, shapes, shapeOffsets, conn, externalTriangles, externalTriangleOffsets);
|
||||||
|
|
||||||
|
|
||||||
vtkm::Float64 time = timer.GetElapsedTime();
|
vtkm::Float64 time = timer.GetElapsedTime();
|
||||||
|
@ -27,41 +27,6 @@ namespace rendering
|
|||||||
namespace raytracing
|
namespace raytracing
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct MapCanvasFunctor
|
|
||||||
{
|
|
||||||
const vtkm::Matrix<vtkm::Float32, 4, 4> Inverse;
|
|
||||||
const vtkm::Id Width;
|
|
||||||
const vtkm::Id Height;
|
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Float32>& DepthBuffer;
|
|
||||||
Ray<T>& Rays;
|
|
||||||
vtkm::Vec<vtkm::Float32, 3> Origin;
|
|
||||||
|
|
||||||
MapCanvasFunctor(Ray<T>& rays,
|
|
||||||
const vtkm::Matrix<vtkm::Float32, 4, 4> inverse,
|
|
||||||
const vtkm::Id width,
|
|
||||||
const vtkm::Id height,
|
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Float32>& depthBuffer,
|
|
||||||
const vtkm::Vec<vtkm::Float32, 3>& origin)
|
|
||||||
: Inverse(inverse)
|
|
||||||
, Width(width)
|
|
||||||
, Height(height)
|
|
||||||
, DepthBuffer(depthBuffer)
|
|
||||||
, Rays(rays)
|
|
||||||
, Origin(origin)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Device>
|
|
||||||
bool operator()(Device)
|
|
||||||
{
|
|
||||||
vtkm::worklet::DispatcherMapField<detail::RayMapCanvas, Device>(
|
|
||||||
detail::RayMapCanvas(Inverse, Width, Height, Origin))
|
|
||||||
.Invoke(Rays.PixelIdx, Rays.MaxDistance, DepthBuffer);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void RayOperations::MapCanvasToRays(Ray<vtkm::Float32>& rays,
|
void RayOperations::MapCanvasToRays(Ray<vtkm::Float32>& rays,
|
||||||
const vtkm::rendering::Camera& camera,
|
const vtkm::rendering::Camera& camera,
|
||||||
const vtkm::rendering::CanvasRayTracer& canvas)
|
const vtkm::rendering::CanvasRayTracer& canvas)
|
||||||
@ -75,9 +40,9 @@ void RayOperations::MapCanvasToRays(Ray<vtkm::Float32>& rays,
|
|||||||
if (!valid)
|
if (!valid)
|
||||||
throw vtkm::cont::ErrorBadValue("Inverse Invalid");
|
throw vtkm::cont::ErrorBadValue("Inverse Invalid");
|
||||||
|
|
||||||
MapCanvasFunctor<vtkm::Float32> functor(
|
vtkm::worklet::DispatcherMapField<detail::RayMapCanvas>(
|
||||||
rays, inverse, width, height, canvas.GetDepthBuffer(), camera.GetPosition());
|
detail::RayMapCanvas(inverse, width, height, camera.GetPosition()))
|
||||||
vtkm::cont::TryExecute(functor);
|
.Invoke(rays.PixelIdx, rays.MaxDistance, canvas.GetDepthBuffer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,8 +117,10 @@ public:
|
|||||||
template <typename Device, typename T>
|
template <typename Device, typename T>
|
||||||
static void ResetStatus(Ray<T>& rays, vtkm::UInt8 status, Device)
|
static void ResetStatus(Ray<T>& rays, vtkm::UInt8 status, Device)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<MemSet<vtkm::UInt8>, Device>(MemSet<vtkm::UInt8>(status))
|
vtkm::worklet::DispatcherMapField<MemSet<vtkm::UInt8>> dispatcher(
|
||||||
.Invoke(rays.Status);
|
(MemSet<vtkm::UInt8>(status)));
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(rays.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -129,8 +131,10 @@ public:
|
|||||||
template <typename Device, typename T>
|
template <typename Device, typename T>
|
||||||
static void UpdateRayStatus(Ray<T>& rays, Device)
|
static void UpdateRayStatus(Ray<T>& rays, Device)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<detail::RayStatusFilter, Device>(detail::RayStatusFilter())
|
vtkm::worklet::DispatcherMapField<detail::RayStatusFilter> dispatcher{ (
|
||||||
.Invoke(rays.HitIdx, rays.Status);
|
detail::RayStatusFilter{}) };
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(rays.HitIdx, rays.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapCanvasToRays(Ray<vtkm::Float32>& rays,
|
static void MapCanvasToRays(Ray<vtkm::Float32>& rays,
|
||||||
@ -146,9 +150,10 @@ public:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
|
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<ManyMask<vtkm::UInt8, 2>, Device>(
|
vtkm::worklet::DispatcherMapField<ManyMask<vtkm::UInt8, 2>> dispatcher{ (
|
||||||
ManyMask<vtkm::UInt8, 2>(maskValues))
|
ManyMask<vtkm::UInt8, 2>{ maskValues }) };
|
||||||
.Invoke(rays.Status, masks);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(rays.Status, masks);
|
||||||
vtkm::cont::ArrayHandleCast<vtkm::Id, vtkm::cont::ArrayHandle<vtkm::UInt8>> castedMasks(masks);
|
vtkm::cont::ArrayHandleCast<vtkm::Id, vtkm::cont::ArrayHandle<vtkm::UInt8>> castedMasks(masks);
|
||||||
const vtkm::Id initVal = 0;
|
const vtkm::Id initVal = 0;
|
||||||
vtkm::Id count = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(castedMasks, initVal);
|
vtkm::Id count = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(castedMasks, initVal);
|
||||||
@ -168,8 +173,10 @@ public:
|
|||||||
statusUInt8 = static_cast<vtkm::UInt8>(status);
|
statusUInt8 = static_cast<vtkm::UInt8>(status);
|
||||||
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
|
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<Mask<vtkm::UInt8>, Device>(Mask<vtkm::UInt8>(statusUInt8))
|
vtkm::worklet::DispatcherMapField<Mask<vtkm::UInt8>> dispatcher{ (
|
||||||
.Invoke(rays.Status, masks);
|
Mask<vtkm::UInt8>{ statusUInt8 }) };
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(rays.Status, masks);
|
||||||
vtkm::cont::ArrayHandleCast<vtkm::Id, vtkm::cont::ArrayHandle<vtkm::UInt8>> castedMasks(masks);
|
vtkm::cont::ArrayHandleCast<vtkm::Id, vtkm::cont::ArrayHandle<vtkm::UInt8>> castedMasks(masks);
|
||||||
const vtkm::Id initVal = 0;
|
const vtkm::Id initVal = 0;
|
||||||
vtkm::Id count = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(castedMasks, initVal);
|
vtkm::Id count = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(castedMasks, initVal);
|
||||||
@ -187,9 +194,10 @@ public:
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
|
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<ManyMask<vtkm::UInt8, 3>, Device>(
|
vtkm::worklet::DispatcherMapField<ManyMask<vtkm::UInt8, 3>> dispatcher{ (
|
||||||
ManyMask<vtkm::UInt8, 3>(maskValues))
|
ManyMask<vtkm::UInt8, 3>{ maskValues }) };
|
||||||
.Invoke(rays.Status, masks);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(rays.Status, masks);
|
||||||
vtkm::cont::ArrayHandleCast<vtkm::Id, vtkm::cont::ArrayHandle<vtkm::UInt8>> castedMasks(masks);
|
vtkm::cont::ArrayHandleCast<vtkm::Id, vtkm::cont::ArrayHandle<vtkm::UInt8>> castedMasks(masks);
|
||||||
const vtkm::Id initVal = 0;
|
const vtkm::Id initVal = 0;
|
||||||
vtkm::Id count = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(castedMasks, initVal);
|
vtkm::Id count = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(castedMasks, initVal);
|
||||||
@ -205,8 +213,10 @@ public:
|
|||||||
vtkm::UInt8 statusUInt8 = static_cast<vtkm::UInt8>(RAY_ACTIVE);
|
vtkm::UInt8 statusUInt8 = static_cast<vtkm::UInt8>(RAY_ACTIVE);
|
||||||
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
|
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<Mask<vtkm::UInt8>, Device>(Mask<vtkm::UInt8>(statusUInt8))
|
vtkm::worklet::DispatcherMapField<Mask<vtkm::UInt8>> dispatcher{ (
|
||||||
.Invoke(rays.Status, masks);
|
Mask<vtkm::UInt8>{ statusUInt8 }) };
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(rays.Status, masks);
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<T> emptyHandle;
|
vtkm::cont::ArrayHandle<T> emptyHandle;
|
||||||
|
|
||||||
@ -328,9 +338,10 @@ public:
|
|||||||
template <typename Device, typename T>
|
template <typename Device, typename T>
|
||||||
static void CopyDistancesToMin(Ray<T> rays, Device, const T offset = 0.f)
|
static void CopyDistancesToMin(Ray<T> rays, Device, const T offset = 0.f)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<CopyAndOffsetMask<T>, Device>(
|
vtkm::worklet::DispatcherMapField<CopyAndOffsetMask<T>> dispatcher{ (
|
||||||
CopyAndOffsetMask<T>(offset, RAY_EXITED_MESH))
|
CopyAndOffsetMask<T>{ offset, RAY_EXITED_MESH }) };
|
||||||
.Invoke(rays.Distance, rays.MinDistance, rays.Status);
|
dispatcher.SetDevice(Device());
|
||||||
|
dispatcher.Invoke(rays.Distance, rays.MinDistance, rays.Status);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -237,22 +237,27 @@ public:
|
|||||||
throw vtkm::cont::ErrorBadValue("Field not accociated with cell set or points");
|
throw vtkm::cont::ErrorBadValue("Field not accociated with cell set or points");
|
||||||
bool isAssocPoints = scalarField.GetAssociation() == vtkm::cont::Field::Association::POINTS;
|
bool isAssocPoints = scalarField.GetAssociation() == vtkm::cont::Field::Association::POINTS;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<CalculateNormals, Device>(CalculateNormals(bvh.LeafNodes))
|
vtkm::worklet::DispatcherMapField<CalculateNormals> calcNormalsDispatcher(
|
||||||
.Invoke(rays.HitIdx, rays.Dir, rays.NormalX, rays.NormalY, rays.NormalZ, coordsHandle);
|
CalculateNormals(bvh.LeafNodes));
|
||||||
|
calcNormalsDispatcher.SetDevice(Device());
|
||||||
|
calcNormalsDispatcher.Invoke(
|
||||||
|
rays.HitIdx, rays.Dir, rays.NormalX, rays.NormalY, rays.NormalZ, coordsHandle);
|
||||||
|
|
||||||
if (isAssocPoints)
|
if (isAssocPoints)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<LerpScalar<Precision>, Device>(
|
vtkm::worklet::DispatcherMapField<LerpScalar<Precision>> lerpScalarDispatcher(
|
||||||
LerpScalar<Precision>(
|
LerpScalar<Precision>(
|
||||||
bvh.LeafNodes, vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max)))
|
bvh.LeafNodes, vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max)));
|
||||||
.Invoke(rays.HitIdx, rays.U, rays.V, rays.Scalar, scalarField);
|
lerpScalarDispatcher.SetDevice(Device());
|
||||||
|
lerpScalarDispatcher.Invoke(rays.HitIdx, rays.U, rays.V, rays.Scalar, scalarField);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<NodalScalar<Precision>, Device>(
|
vtkm::worklet::DispatcherMapField<NodalScalar<Precision>> nodalScalarDispatcher(
|
||||||
NodalScalar<Precision>(
|
NodalScalar<Precision>(
|
||||||
bvh.LeafNodes, vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max)))
|
bvh.LeafNodes, vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max)));
|
||||||
.Invoke(rays.HitIdx, rays.Scalar, scalarField);
|
nodalScalarDispatcher.SetDevice(Device());
|
||||||
|
nodalScalarDispatcher.Invoke(rays.HitIdx, rays.Scalar, scalarField);
|
||||||
}
|
}
|
||||||
} // Run
|
} // Run
|
||||||
|
|
||||||
@ -373,10 +378,11 @@ public:
|
|||||||
vtkm::Vec<vtkm::Float32, 3> scale(2, 2, 2);
|
vtkm::Vec<vtkm::Float32, 3> scale(2, 2, 2);
|
||||||
vtkm::Vec<vtkm::Float32, 3> lightPosition = camera.GetPosition() + scale * camera.GetUp();
|
vtkm::Vec<vtkm::Float32, 3> lightPosition = camera.GetPosition() + scale * camera.GetUp();
|
||||||
const vtkm::Int32 colorMapSize = vtkm::Int32(colorMap.GetNumberOfValues());
|
const vtkm::Int32 colorMapSize = vtkm::Int32(colorMap.GetNumberOfValues());
|
||||||
vtkm::worklet::DispatcherMapField<MapScalarToColor, Device>(
|
vtkm::worklet::DispatcherMapField<MapScalarToColor> dispatcher(MapScalarToColor(
|
||||||
MapScalarToColor(
|
colorMap, colorMapSize, lightPosition, camera.GetPosition(), camera.GetLookAt()));
|
||||||
colorMap, colorMapSize, lightPosition, camera.GetPosition(), camera.GetLookAt()))
|
dispatcher.SetDevice(Device());
|
||||||
.Invoke(rays.HitIdx, rays.Scalar, rays.Normal, rays.Intersection, rays.Buffers.at(0).Buffer);
|
dispatcher.Invoke(
|
||||||
|
rays.HitIdx, rays.Scalar, rays.Normal, rays.Intersection, rays.Buffers.at(0).Buffer);
|
||||||
}
|
}
|
||||||
}; // class SurfaceColor
|
}; // class SurfaceColor
|
||||||
|
|
||||||
@ -487,15 +493,16 @@ void RayTracer::RenderOnDevice(Ray<Precision>& rays, Device)
|
|||||||
timer.Reset();
|
timer.Reset();
|
||||||
|
|
||||||
// Find the intersection point from hit distance
|
// Find the intersection point from hit distance
|
||||||
vtkm::worklet::DispatcherMapField<detail::IntersectionPoint, Device>(
|
vtkm::worklet::DispatcherMapField<detail::IntersectionPoint> intersectionPointDispatcher{ (
|
||||||
detail::IntersectionPoint())
|
detail::IntersectionPoint{}) };
|
||||||
.Invoke(rays.HitIdx,
|
intersectionPointDispatcher.SetDevice(Device());
|
||||||
rays.Distance,
|
intersectionPointDispatcher.Invoke(rays.HitIdx,
|
||||||
rays.Dir,
|
rays.Distance,
|
||||||
rays.Origin,
|
rays.Dir,
|
||||||
rays.IntersectionX,
|
rays.Origin,
|
||||||
rays.IntersectionY,
|
rays.IntersectionX,
|
||||||
rays.IntersectionZ);
|
rays.IntersectionY,
|
||||||
|
rays.IntersectionZ);
|
||||||
|
|
||||||
time = timer.GetElapsedTime();
|
time = timer.GetElapsedTime();
|
||||||
logger->AddLogData("find_point", time);
|
logger->AddLogData("find_point", time);
|
||||||
|
@ -1049,16 +1049,17 @@ public:
|
|||||||
template <typename DynamicCoordType, typename Precision>
|
template <typename DynamicCoordType, typename Precision>
|
||||||
VTKM_CONT void run(Ray<Precision>& rays, LinearBVH& bvh, DynamicCoordType coordsHandle)
|
VTKM_CONT void run(Ray<Precision>& rays, LinearBVH& bvh, DynamicCoordType coordsHandle)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<Intersector, Device>(Intersector(false, bvh))
|
vtkm::worklet::DispatcherMapField<Intersector> dispatcher(Intersector(false, bvh));
|
||||||
.Invoke(rays.Dir,
|
dispatcher.SetDevice(Device());
|
||||||
rays.Origin,
|
dispatcher.Invoke(rays.Dir,
|
||||||
rays.Distance,
|
rays.Origin,
|
||||||
rays.MinDistance,
|
rays.Distance,
|
||||||
rays.MaxDistance,
|
rays.MinDistance,
|
||||||
rays.U,
|
rays.MaxDistance,
|
||||||
rays.V,
|
rays.U,
|
||||||
rays.HitIdx,
|
rays.V,
|
||||||
coordsHandle);
|
rays.HitIdx,
|
||||||
|
coordsHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename DynamicCoordType, typename Precision>
|
template <typename DynamicCoordType, typename Precision>
|
||||||
@ -1068,21 +1069,24 @@ public:
|
|||||||
bool returnCellIndex)
|
bool returnCellIndex)
|
||||||
{
|
{
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<IntersectorHitIndex<Precision>, Device>(
|
vtkm::worklet::DispatcherMapField<IntersectorHitIndex<Precision>> dispatcher(
|
||||||
IntersectorHitIndex<Precision>(false, bvh))
|
IntersectorHitIndex<Precision>(false, bvh));
|
||||||
.Invoke(rays.Dir,
|
dispatcher.SetDevice(Device());
|
||||||
rays.HitIdx,
|
dispatcher.Invoke(rays.Dir,
|
||||||
coordsHandle,
|
rays.HitIdx,
|
||||||
rays.Distance,
|
coordsHandle,
|
||||||
rays.MinDistance,
|
rays.Distance,
|
||||||
rays.MaxDistance,
|
rays.MinDistance,
|
||||||
rays.Origin);
|
rays.MaxDistance,
|
||||||
|
rays.Origin);
|
||||||
// Normally we return the index of the triangle hit,
|
// Normally we return the index of the triangle hit,
|
||||||
// but in some cases we are only interested in the cell
|
// but in some cases we are only interested in the cell
|
||||||
if (returnCellIndex)
|
if (returnCellIndex)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<CellIndexFilter, Device>(CellIndexFilter(bvh))
|
vtkm::worklet::DispatcherMapField<CellIndexFilter> cellIndexFilterDispatcher(
|
||||||
.Invoke(rays.HitIdx);
|
(CellIndexFilter(bvh)));
|
||||||
|
cellIndexFilterDispatcher.SetDevice(Device());
|
||||||
|
cellIndexFilterDispatcher.Invoke(rays.HitIdx);
|
||||||
}
|
}
|
||||||
// Update ray status
|
// Update ray status
|
||||||
RayOperations::UpdateRayStatus(rays, Device());
|
RayOperations::UpdateRayStatus(rays, Device());
|
||||||
|
@ -818,8 +818,11 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
|
|||||||
}
|
}
|
||||||
|
|
||||||
vtkm::cont::Timer<Device> timer;
|
vtkm::cont::Timer<Device> timer;
|
||||||
vtkm::worklet::DispatcherMapField<CalcRayStart, Device>(CalcRayStart(this->SpatialExtent))
|
vtkm::worklet::DispatcherMapField<CalcRayStart> calcRayStartDispatcher(
|
||||||
.Invoke(rays.Dir, rays.MinDistance, rays.Distance, rays.MaxDistance, rays.Origin);
|
CalcRayStart(this->SpatialExtent));
|
||||||
|
calcRayStartDispatcher.SetDevice(Device());
|
||||||
|
calcRayStartDispatcher.Invoke(
|
||||||
|
rays.Dir, rays.MinDistance, rays.Distance, rays.MaxDistance, rays.Origin);
|
||||||
|
|
||||||
vtkm::Float64 time = timer.GetElapsedTime();
|
vtkm::Float64 time = timer.GetElapsedTime();
|
||||||
logger->AddLogData("calc_ray_start", time);
|
logger->AddLogData("calc_ray_start", time);
|
||||||
@ -840,18 +843,19 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
|
|||||||
|
|
||||||
if (isAssocPoints)
|
if (isAssocPoints)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<Sampler<Device, UniformLocator<Device>>, Device>(
|
vtkm::worklet::DispatcherMapField<Sampler<Device, UniformLocator<Device>>> samplerDispatcher(
|
||||||
Sampler<Device, UniformLocator<Device>>(ColorMap,
|
Sampler<Device, UniformLocator<Device>>(ColorMap,
|
||||||
vtkm::Float32(ScalarRange.Min),
|
vtkm::Float32(ScalarRange.Min),
|
||||||
vtkm::Float32(ScalarRange.Max),
|
vtkm::Float32(ScalarRange.Max),
|
||||||
SampleDistance,
|
SampleDistance,
|
||||||
locator))
|
locator));
|
||||||
.Invoke(rays.Dir,
|
samplerDispatcher.SetDevice(Device());
|
||||||
rays.Origin,
|
samplerDispatcher.Invoke(rays.Dir,
|
||||||
rays.MinDistance,
|
rays.Origin,
|
||||||
rays.MaxDistance,
|
rays.MinDistance,
|
||||||
rays.Buffers.at(0).Buffer,
|
rays.MaxDistance,
|
||||||
*ScalarField);
|
rays.Buffers.at(0).Buffer,
|
||||||
|
*ScalarField);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -876,34 +880,37 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
|
|||||||
RectilinearLocator<Device> locator(vertices, Cellset);
|
RectilinearLocator<Device> locator(vertices, Cellset);
|
||||||
if (isAssocPoints)
|
if (isAssocPoints)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<Sampler<Device, RectilinearLocator<Device>>, Device>(
|
vtkm::worklet::DispatcherMapField<Sampler<Device, RectilinearLocator<Device>>>
|
||||||
Sampler<Device, RectilinearLocator<Device>>(ColorMap,
|
samplerDispatcher(
|
||||||
vtkm::Float32(ScalarRange.Min),
|
Sampler<Device, RectilinearLocator<Device>>(ColorMap,
|
||||||
vtkm::Float32(ScalarRange.Max),
|
vtkm::Float32(ScalarRange.Min),
|
||||||
SampleDistance,
|
vtkm::Float32(ScalarRange.Max),
|
||||||
locator))
|
SampleDistance,
|
||||||
.Invoke(rays.Dir,
|
locator));
|
||||||
rays.Origin,
|
samplerDispatcher.SetDevice(Device());
|
||||||
rays.MinDistance,
|
samplerDispatcher.Invoke(rays.Dir,
|
||||||
rays.MaxDistance,
|
rays.Origin,
|
||||||
rays.Buffers.at(0).Buffer,
|
rays.MinDistance,
|
||||||
*ScalarField);
|
rays.MaxDistance,
|
||||||
|
rays.Buffers.at(0).Buffer,
|
||||||
|
*ScalarField);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<SamplerCellAssoc<Device, RectilinearLocator<Device>>,
|
vtkm::worklet::DispatcherMapField<SamplerCellAssoc<Device, RectilinearLocator<Device>>>
|
||||||
Device>(
|
rectilinearLocatorDispatcher(
|
||||||
SamplerCellAssoc<Device, RectilinearLocator<Device>>(ColorMap,
|
SamplerCellAssoc<Device, RectilinearLocator<Device>>(ColorMap,
|
||||||
vtkm::Float32(ScalarRange.Min),
|
vtkm::Float32(ScalarRange.Min),
|
||||||
vtkm::Float32(ScalarRange.Max),
|
vtkm::Float32(ScalarRange.Max),
|
||||||
SampleDistance,
|
SampleDistance,
|
||||||
locator))
|
locator));
|
||||||
.Invoke(rays.Dir,
|
rectilinearLocatorDispatcher.SetDevice(Device());
|
||||||
rays.Origin,
|
rectilinearLocatorDispatcher.Invoke(rays.Dir,
|
||||||
rays.MinDistance,
|
rays.Origin,
|
||||||
rays.MaxDistance,
|
rays.MinDistance,
|
||||||
rays.Buffers.at(0).Buffer,
|
rays.MaxDistance,
|
||||||
*ScalarField);
|
rays.Buffers.at(0).Buffer,
|
||||||
|
*ScalarField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,8 @@ struct AverageByKey
|
|||||||
{
|
{
|
||||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherReduceByKey<AverageWorklet, Device> dispatcher;
|
vtkm::worklet::DispatcherReduceByKey<AverageWorklet> dispatcher;
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
dispatcher.Invoke(keys, inValues, outAverages);
|
dispatcher.Invoke(keys, inValues, outAverages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,8 +176,9 @@ struct AverageByKey
|
|||||||
keyArraySorted, inputZipHandle, outputKeyArray, outputZipHandle, vtkm::Add());
|
keyArraySorted, inputZipHandle, outputKeyArray, outputZipHandle, vtkm::Add());
|
||||||
|
|
||||||
// get average
|
// get average
|
||||||
DispatcherMapField<DivideWorklet, DeviceAdapter>().Invoke(
|
DispatcherMapField<DivideWorklet> dispatcher;
|
||||||
sumArray, countArray, outputValueArray);
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
dispatcher.Invoke(sumArray, countArray, outputValueArray);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,8 @@ struct CellDeepCopy
|
|||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorage> numIndices;
|
vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorage> numIndices;
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapTopology<CountCellPoints, Device> countDispatcher;
|
vtkm::worklet::DispatcherMapTopology<CountCellPoints> countDispatcher;
|
||||||
|
countDispatcher.SetDevice(Device());
|
||||||
countDispatcher.Invoke(inCellSet, numIndices);
|
countDispatcher.Invoke(inCellSet, numIndices);
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorage> shapes;
|
vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorage> shapes;
|
||||||
@ -100,7 +101,8 @@ struct CellDeepCopy
|
|||||||
vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
|
vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
|
||||||
connectivity.Allocate(connectivitySize);
|
connectivity.Allocate(connectivitySize);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapTopology<PassCellStructure, Device> passDispatcher;
|
vtkm::worklet::DispatcherMapTopology<PassCellStructure> passDispatcher;
|
||||||
|
passDispatcher.SetDevice(Device());
|
||||||
passDispatcher.Invoke(
|
passDispatcher.Invoke(
|
||||||
inCellSet, shapes, vtkm::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets));
|
inCellSet, shapes, vtkm::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets));
|
||||||
|
|
||||||
|
@ -496,8 +496,9 @@ public:
|
|||||||
vtkm::cont::ArrayHandle<ClipStats> stats;
|
vtkm::cont::ArrayHandle<ClipStats> stats;
|
||||||
|
|
||||||
ComputeStats<DeviceAdapter> computeStats(value, clipTablesDevicePortal, invert);
|
ComputeStats<DeviceAdapter> computeStats(value, clipTablesDevicePortal, invert);
|
||||||
DispatcherMapTopology<ComputeStats<DeviceAdapter>, DeviceAdapter>(computeStats)
|
DispatcherMapTopology<ComputeStats<DeviceAdapter>> computeStatsDispatcher(computeStats);
|
||||||
.Invoke(cellSet, scalars, clipTableIdxs, stats);
|
computeStatsDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
computeStatsDispatcher.Invoke(cellSet, scalars, clipTableIdxs, stats);
|
||||||
|
|
||||||
// compute offsets for each invocation
|
// compute offsets for each invocation
|
||||||
ClipStats zero;
|
ClipStats zero;
|
||||||
@ -522,15 +523,17 @@ public:
|
|||||||
this->CellIdMap.Allocate(total.NumberOfCells);
|
this->CellIdMap.Allocate(total.NumberOfCells);
|
||||||
|
|
||||||
GenerateCellSet<DeviceAdapter> generateCellSet(value, clipTablesDevicePortal);
|
GenerateCellSet<DeviceAdapter> generateCellSet(value, clipTablesDevicePortal);
|
||||||
DispatcherMapTopology<GenerateCellSet<DeviceAdapter>, DeviceAdapter>(generateCellSet)
|
DispatcherMapTopology<GenerateCellSet<DeviceAdapter>> generateCellSetDispatcher(
|
||||||
.Invoke(cellSet,
|
generateCellSet);
|
||||||
scalars,
|
generateCellSetDispatcher.SetDevice(DeviceAdapter());
|
||||||
clipTableIdxs,
|
generateCellSetDispatcher.Invoke(cellSet,
|
||||||
cellSetIndices,
|
scalars,
|
||||||
outConnectivity,
|
clipTableIdxs,
|
||||||
newPoints,
|
cellSetIndices,
|
||||||
newPointsConnectivityReverseMap,
|
outConnectivity,
|
||||||
this->CellIdMap);
|
newPoints,
|
||||||
|
newPointsConnectivityReverseMap,
|
||||||
|
this->CellIdMap);
|
||||||
cellSetIndices.ReleaseResources();
|
cellSetIndices.ReleaseResources();
|
||||||
|
|
||||||
// Step 3. remove duplicates from the list of new points
|
// Step 3. remove duplicates from the list of new points
|
||||||
|
@ -192,12 +192,14 @@ public:
|
|||||||
{
|
{
|
||||||
if (CartesianToSpherical)
|
if (CartesianToSpherical)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<detail::CarToSphere<T>, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<detail::CarToSphere<T>> dispatcher;
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
dispatcher.Invoke(inPoints, outPoints);
|
dispatcher.Invoke(inPoints, outPoints);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<detail::SphereToCar<T>, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<detail::SphereToCar<T>> dispatcher;
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
dispatcher.Invoke(inPoints, outPoints);
|
dispatcher.Invoke(inPoints, outPoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,12 +211,14 @@ public:
|
|||||||
{
|
{
|
||||||
if (CartesianToSpherical)
|
if (CartesianToSpherical)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<detail::CarToSphere<T>, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<detail::CarToSphere<T>> dispatcher;
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
dispatcher.Invoke(inPoints, outPoints);
|
dispatcher.Invoke(inPoints, outPoints);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapField<detail::SphereToCar<T>, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherMapField<detail::SphereToCar<T>> dispatcher;
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
dispatcher.Invoke(inPoints, outPoints);
|
dispatcher.Invoke(inPoints, outPoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#ifndef vtk_m_worklet_Dispatcher_MapField_h
|
#ifndef vtk_m_worklet_Dispatcher_MapField_h
|
||||||
#define vtk_m_worklet_Dispatcher_MapField_h
|
#define vtk_m_worklet_Dispatcher_MapField_h
|
||||||
|
|
||||||
#include <vtkm/cont/DeviceAdapter.h>
|
|
||||||
#include <vtkm/worklet/WorkletMapField.h>
|
#include <vtkm/worklet/WorkletMapField.h>
|
||||||
#include <vtkm/worklet/internal/DispatcherBase.h>
|
#include <vtkm/worklet/internal/DispatcherBase.h>
|
||||||
|
|
||||||
@ -31,16 +30,15 @@ namespace worklet
|
|||||||
|
|
||||||
/// \brief Dispatcher for worklets that inherit from \c WorkletMapField.
|
/// \brief Dispatcher for worklets that inherit from \c WorkletMapField.
|
||||||
///
|
///
|
||||||
template <typename WorkletType, typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
template <typename WorkletType>
|
||||||
class DispatcherMapField
|
class DispatcherMapField
|
||||||
: public vtkm::worklet::internal::DispatcherBase<DispatcherMapField<WorkletType, Device>,
|
: public vtkm::worklet::internal::DispatcherBase<DispatcherMapField<WorkletType>,
|
||||||
WorkletType,
|
WorkletType,
|
||||||
vtkm::worklet::WorkletMapField>
|
vtkm::worklet::WorkletMapField>
|
||||||
{
|
{
|
||||||
using Superclass =
|
using Superclass = vtkm::worklet::internal::DispatcherBase<DispatcherMapField<WorkletType>,
|
||||||
vtkm::worklet::internal::DispatcherBase<DispatcherMapField<WorkletType, Device>,
|
WorkletType,
|
||||||
WorkletType,
|
vtkm::worklet::WorkletMapField>;
|
||||||
vtkm::worklet::WorkletMapField>;
|
|
||||||
using ScatterType = typename Superclass::ScatterType;
|
using ScatterType = typename Superclass::ScatterType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -80,7 +78,7 @@ public:
|
|||||||
|
|
||||||
// A MapField is a pretty straightforward dispatch. Once we know the number
|
// A MapField is a pretty straightforward dispatch. Once we know the number
|
||||||
// of invocations, the superclass can take care of the rest.
|
// of invocations, the superclass can take care of the rest.
|
||||||
this->BasicInvoke(invocation, numInstances, Device());
|
this->BasicInvoke(invocation, numInstances);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -32,14 +32,14 @@ namespace worklet
|
|||||||
|
|
||||||
/// \brief Dispatcher for worklets that inherit from \c WorkletMapTopology.
|
/// \brief Dispatcher for worklets that inherit from \c WorkletMapTopology.
|
||||||
///
|
///
|
||||||
template <typename WorkletType, typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
template <typename WorkletType>
|
||||||
class DispatcherMapTopology
|
class DispatcherMapTopology
|
||||||
: public vtkm::worklet::internal::DispatcherBase<DispatcherMapTopology<WorkletType, Device>,
|
: public vtkm::worklet::internal::DispatcherBase<DispatcherMapTopology<WorkletType>,
|
||||||
WorkletType,
|
WorkletType,
|
||||||
vtkm::worklet::detail::WorkletMapTopologyBase>
|
vtkm::worklet::detail::WorkletMapTopologyBase>
|
||||||
{
|
{
|
||||||
using Superclass =
|
using Superclass =
|
||||||
vtkm::worklet::internal::DispatcherBase<DispatcherMapTopology<WorkletType, Device>,
|
vtkm::worklet::internal::DispatcherBase<DispatcherMapTopology<WorkletType>,
|
||||||
WorkletType,
|
WorkletType,
|
||||||
vtkm::worklet::detail::WorkletMapTopologyBase>;
|
vtkm::worklet::detail::WorkletMapTopologyBase>;
|
||||||
using ScatterType = typename Superclass::ScatterType;
|
using ScatterType = typename Superclass::ScatterType;
|
||||||
@ -81,8 +81,7 @@ public:
|
|||||||
|
|
||||||
// Now that we have the input domain, we can extract the range of the
|
// Now that we have the input domain, we can extract the range of the
|
||||||
// scheduling and call BadicInvoke.
|
// scheduling and call BadicInvoke.
|
||||||
this->BasicInvoke(
|
this->BasicInvoke(invocation, internal::scheduling_range(inputDomain, SchedulingRangeType{}));
|
||||||
invocation, internal::scheduling_range(inputDomain, SchedulingRangeType{}), Device());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,14 @@ namespace worklet
|
|||||||
|
|
||||||
/// \brief Dispatcher for worklets that inherit from \c WorkletPointNeighborhood.
|
/// \brief Dispatcher for worklets that inherit from \c WorkletPointNeighborhood.
|
||||||
///
|
///
|
||||||
template <typename WorkletType, typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
template <typename WorkletType>
|
||||||
class DispatcherPointNeighborhood
|
class DispatcherPointNeighborhood
|
||||||
: public vtkm::worklet::internal::DispatcherBase<DispatcherPointNeighborhood<WorkletType, Device>,
|
: public vtkm::worklet::internal::DispatcherBase<DispatcherPointNeighborhood<WorkletType>,
|
||||||
WorkletType,
|
WorkletType,
|
||||||
vtkm::worklet::WorkletPointNeighborhoodBase>
|
vtkm::worklet::WorkletPointNeighborhoodBase>
|
||||||
{
|
{
|
||||||
using Superclass =
|
using Superclass =
|
||||||
vtkm::worklet::internal::DispatcherBase<DispatcherPointNeighborhood<WorkletType, Device>,
|
vtkm::worklet::internal::DispatcherBase<DispatcherPointNeighborhood<WorkletType>,
|
||||||
WorkletType,
|
WorkletType,
|
||||||
vtkm::worklet::WorkletPointNeighborhoodBase>;
|
vtkm::worklet::WorkletPointNeighborhoodBase>;
|
||||||
using ScatterType = typename Superclass::ScatterType;
|
using ScatterType = typename Superclass::ScatterType;
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
|
|
||||||
// This is pretty straightforward dispatch. Once we know the number
|
// This is pretty straightforward dispatch. Once we know the number
|
||||||
// of invocations, the superclass can take care of the rest.
|
// of invocations, the superclass can take care of the rest.
|
||||||
this->BasicInvoke(invocation, inputRange, Device());
|
this->BasicInvoke(invocation, inputRange);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -33,16 +33,15 @@ namespace worklet
|
|||||||
|
|
||||||
/// \brief Dispatcher for worklets that inherit from \c WorkletReduceByKey.
|
/// \brief Dispatcher for worklets that inherit from \c WorkletReduceByKey.
|
||||||
///
|
///
|
||||||
template <typename WorkletType, typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
template <typename WorkletType>
|
||||||
class DispatcherReduceByKey
|
class DispatcherReduceByKey
|
||||||
: public vtkm::worklet::internal::DispatcherBase<DispatcherReduceByKey<WorkletType, Device>,
|
: public vtkm::worklet::internal::DispatcherBase<DispatcherReduceByKey<WorkletType>,
|
||||||
WorkletType,
|
WorkletType,
|
||||||
vtkm::worklet::WorkletReduceByKey>
|
vtkm::worklet::WorkletReduceByKey>
|
||||||
{
|
{
|
||||||
using Superclass =
|
using Superclass = vtkm::worklet::internal::DispatcherBase<DispatcherReduceByKey<WorkletType>,
|
||||||
vtkm::worklet::internal::DispatcherBase<DispatcherReduceByKey<WorkletType, Device>,
|
WorkletType,
|
||||||
WorkletType,
|
vtkm::worklet::WorkletReduceByKey>;
|
||||||
vtkm::worklet::WorkletReduceByKey>;
|
|
||||||
using ScatterType = typename Superclass::ScatterType;
|
using ScatterType = typename Superclass::ScatterType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -83,7 +82,7 @@ public:
|
|||||||
|
|
||||||
// Now that we have the input domain, we can extract the range of the
|
// Now that we have the input domain, we can extract the range of the
|
||||||
// scheduling and call BadicInvoke.
|
// scheduling and call BadicInvoke.
|
||||||
this->BasicInvoke(invocation, inputDomain.GetInputRange(), Device());
|
this->BasicInvoke(invocation, inputDomain.GetInputRange());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,22 @@ namespace worklet
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename ControlInterface, typename Device>
|
struct DispatcherStreamingTryExecuteFunctor
|
||||||
|
{
|
||||||
|
template <typename Device, typename DispatcherBaseType, typename Invocation, typename RangeType>
|
||||||
|
VTKM_CONT bool operator()(Device device,
|
||||||
|
const DispatcherBaseType* self,
|
||||||
|
Invocation& invocation,
|
||||||
|
const RangeType& dimensions,
|
||||||
|
const RangeType& globalIndexOffset)
|
||||||
|
{
|
||||||
|
self->InvokeTransportParameters(
|
||||||
|
invocation, dimensions, globalIndexOffset, self->Scatter.GetOutputRange(dimensions), device);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename ControlInterface>
|
||||||
struct DispatcherStreamingMapFieldTransformFunctor
|
struct DispatcherStreamingMapFieldTransformFunctor
|
||||||
{
|
{
|
||||||
vtkm::Id BlockIndex;
|
vtkm::Id BlockIndex;
|
||||||
@ -116,7 +131,7 @@ struct DispatcherStreamingMapFieldTransformFunctor
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ControlInterface, typename Device>
|
template <typename ControlInterface>
|
||||||
struct DispatcherStreamingMapFieldTransferFunctor
|
struct DispatcherStreamingMapFieldTransferFunctor
|
||||||
{
|
{
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
@ -163,14 +178,14 @@ struct DispatcherStreamingMapFieldTransferFunctor
|
|||||||
|
|
||||||
/// \brief Dispatcher for worklets that inherit from \c WorkletMapField.
|
/// \brief Dispatcher for worklets that inherit from \c WorkletMapField.
|
||||||
///
|
///
|
||||||
template <typename WorkletType, typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
template <typename WorkletType>
|
||||||
class DispatcherStreamingMapField
|
class DispatcherStreamingMapField
|
||||||
: public vtkm::worklet::internal::DispatcherBase<DispatcherStreamingMapField<WorkletType, Device>,
|
: public vtkm::worklet::internal::DispatcherBase<DispatcherStreamingMapField<WorkletType>,
|
||||||
WorkletType,
|
WorkletType,
|
||||||
vtkm::worklet::WorkletMapField>
|
vtkm::worklet::WorkletMapField>
|
||||||
{
|
{
|
||||||
using Superclass =
|
using Superclass =
|
||||||
vtkm::worklet::internal::DispatcherBase<DispatcherStreamingMapField<WorkletType, Device>,
|
vtkm::worklet::internal::DispatcherBase<DispatcherStreamingMapField<WorkletType>,
|
||||||
WorkletType,
|
WorkletType,
|
||||||
vtkm::worklet::WorkletMapField>;
|
vtkm::worklet::WorkletMapField>;
|
||||||
using ScatterType = typename Superclass::ScatterType;
|
using ScatterType = typename Superclass::ScatterType;
|
||||||
@ -199,17 +214,23 @@ public:
|
|||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
void SetNumberOfBlocks(vtkm::Id numberOfBlocks) { NumberOfBlocks = numberOfBlocks; }
|
void SetNumberOfBlocks(vtkm::Id numberOfBlocks) { NumberOfBlocks = numberOfBlocks; }
|
||||||
|
|
||||||
template <typename Invocation, typename DeviceAdapter>
|
friend struct detail::DispatcherStreamingTryExecuteFunctor;
|
||||||
|
|
||||||
|
template <typename Invocation>
|
||||||
VTKM_CONT void BasicInvoke(Invocation& invocation,
|
VTKM_CONT void BasicInvoke(Invocation& invocation,
|
||||||
vtkm::Id numInstances,
|
vtkm::Id numInstances,
|
||||||
vtkm::Id globalIndexOffset,
|
vtkm::Id globalIndexOffset) const
|
||||||
DeviceAdapter device) const
|
|
||||||
{
|
{
|
||||||
this->InvokeTransportParameters(invocation,
|
bool success = vtkm::cont::TryExecuteOnDevice(this->GetDevice(),
|
||||||
numInstances,
|
detail::DispatcherStreamingTryExecuteFunctor(),
|
||||||
globalIndexOffset,
|
this,
|
||||||
this->Scatter.GetOutputRange(numInstances),
|
invocation,
|
||||||
device);
|
numInstances,
|
||||||
|
globalIndexOffset);
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
throw vtkm::cont::ErrorExecution("Failed to execute worklet on any device.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Invocation>
|
template <typename Invocation>
|
||||||
@ -232,11 +253,9 @@ public:
|
|||||||
blockSize += 1;
|
blockSize += 1;
|
||||||
|
|
||||||
using TransformFunctorType =
|
using TransformFunctorType =
|
||||||
detail::DispatcherStreamingMapFieldTransformFunctor<typename Invocation::ControlInterface,
|
detail::DispatcherStreamingMapFieldTransformFunctor<typename Invocation::ControlInterface>;
|
||||||
Device>;
|
|
||||||
using TransferFunctorType =
|
using TransferFunctorType =
|
||||||
detail::DispatcherStreamingMapFieldTransferFunctor<typename Invocation::ControlInterface,
|
detail::DispatcherStreamingMapFieldTransferFunctor<typename Invocation::ControlInterface>;
|
||||||
Device>;
|
|
||||||
|
|
||||||
for (vtkm::Id block = 0; block < NumberOfBlocks; block++)
|
for (vtkm::Id block = 0; block < NumberOfBlocks; block++)
|
||||||
{
|
{
|
||||||
@ -255,7 +274,7 @@ public:
|
|||||||
using ChangedType = typename Invocation::template ChangeParametersType<ReportedType>::type;
|
using ChangedType = typename Invocation::template ChangeParametersType<ReportedType>::type;
|
||||||
ChangedType changedParams = invocation.ChangeParameters(newParams);
|
ChangedType changedParams = invocation.ChangeParameters(newParams);
|
||||||
|
|
||||||
this->BasicInvoke(changedParams, numberOfInstances, globalIndexOffset, Device());
|
this->BasicInvoke(changedParams, numberOfInstances, globalIndexOffset);
|
||||||
|
|
||||||
// Loop over parameters again to sync results for this block into control array
|
// Loop over parameters again to sync results for this block into control array
|
||||||
using ParameterInterfaceType2 = typename ChangedType::ParameterInterface;
|
using ParameterInterfaceType2 = typename ChangedType::ParameterInterface;
|
||||||
|
@ -737,8 +737,9 @@ public:
|
|||||||
|
|
||||||
// Create a worklet to count the number of external faces on each cell
|
// Create a worklet to count the number of external faces on each cell
|
||||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> numExternalFaces;
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> numExternalFaces;
|
||||||
vtkm::worklet::DispatcherMapTopology<NumExternalFacesPerStructuredCell, DeviceAdapter>
|
vtkm::worklet::DispatcherMapTopology<NumExternalFacesPerStructuredCell>
|
||||||
numExternalFacesDispatcher((NumExternalFacesPerStructuredCell(MinPoint, MaxPoint)));
|
numExternalFacesDispatcher((NumExternalFacesPerStructuredCell(MinPoint, MaxPoint)));
|
||||||
|
numExternalFacesDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
numExternalFacesDispatcher.Invoke(inCellSet, numExternalFaces, coordData);
|
numExternalFacesDispatcher.Invoke(inCellSet, numExternalFaces, coordData);
|
||||||
|
|
||||||
@ -761,9 +762,10 @@ public:
|
|||||||
// information to.
|
// information to.
|
||||||
faceConnectivity.Allocate(connectivitySize);
|
faceConnectivity.Allocate(connectivitySize);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapTopology<BuildConnectivityStructured, DeviceAdapter>
|
vtkm::worklet::DispatcherMapTopology<BuildConnectivityStructured>
|
||||||
buildConnectivityStructuredDispatcher(BuildConnectivityStructured(MinPoint, MaxPoint),
|
buildConnectivityStructuredDispatcher(BuildConnectivityStructured(MinPoint, MaxPoint),
|
||||||
scatterCellToExternalFace);
|
scatterCellToExternalFace);
|
||||||
|
buildConnectivityStructuredDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
buildConnectivityStructuredDispatcher.Invoke(
|
buildConnectivityStructuredDispatcher.Invoke(
|
||||||
inCellSet,
|
inCellSet,
|
||||||
@ -797,7 +799,8 @@ public:
|
|||||||
|
|
||||||
//Create a worklet to map the number of faces to each cell
|
//Create a worklet to map the number of faces to each cell
|
||||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> facesPerCell;
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> facesPerCell;
|
||||||
vtkm::worklet::DispatcherMapTopology<NumFacesPerCell, DeviceAdapter> numFacesDispatcher;
|
vtkm::worklet::DispatcherMapTopology<NumFacesPerCell> numFacesDispatcher;
|
||||||
|
numFacesDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
numFacesDispatcher.Invoke(inCellSet, facesPerCell);
|
numFacesDispatcher.Invoke(inCellSet, facesPerCell);
|
||||||
|
|
||||||
@ -813,7 +816,8 @@ public:
|
|||||||
if (this->PassPolyData)
|
if (this->PassPolyData)
|
||||||
{
|
{
|
||||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> isPolyDataCell;
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> isPolyDataCell;
|
||||||
vtkm::worklet::DispatcherMapTopology<IsPolyDataCell, DeviceAdapter> isPolyDataCellDispatcher;
|
vtkm::worklet::DispatcherMapTopology<IsPolyDataCell> isPolyDataCellDispatcher;
|
||||||
|
isPolyDataCellDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
isPolyDataCellDispatcher.Invoke(inCellSet, isPolyDataCell);
|
isPolyDataCellDispatcher.Invoke(inCellSet, isPolyDataCell);
|
||||||
|
|
||||||
@ -823,16 +827,18 @@ public:
|
|||||||
|
|
||||||
if (scatterPolyDataCells.GetOutputRange(inCellSet.GetNumberOfCells()) != 0)
|
if (scatterPolyDataCells.GetOutputRange(inCellSet.GetNumberOfCells()) != 0)
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapTopology<CountPolyDataCellPoints, DeviceAdapter>
|
vtkm::worklet::DispatcherMapTopology<CountPolyDataCellPoints>
|
||||||
countPolyDataCellPointsDispatcher(scatterPolyDataCells);
|
countPolyDataCellPointsDispatcher(scatterPolyDataCells);
|
||||||
|
countPolyDataCellPointsDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
countPolyDataCellPointsDispatcher.Invoke(inCellSet, polyDataPointCount);
|
countPolyDataCellPointsDispatcher.Invoke(inCellSet, polyDataPointCount);
|
||||||
|
|
||||||
vtkm::cont::ConvertNumComponentsToOffsets(
|
vtkm::cont::ConvertNumComponentsToOffsets(
|
||||||
polyDataPointCount, polyDataOffsets, polyDataConnectivitySize);
|
polyDataPointCount, polyDataOffsets, polyDataConnectivitySize);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapTopology<PassPolyDataCells, DeviceAdapter>
|
vtkm::worklet::DispatcherMapTopology<PassPolyDataCells> passPolyDataCellsDispatcher(
|
||||||
passPolyDataCellsDispatcher(scatterPolyDataCells);
|
scatterPolyDataCells);
|
||||||
|
passPolyDataCellsDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
polyDataConnectivity.Allocate(polyDataConnectivitySize);
|
polyDataConnectivity.Allocate(polyDataConnectivitySize);
|
||||||
|
|
||||||
@ -869,23 +875,25 @@ public:
|
|||||||
vtkm::cont::ArrayHandle<vtkm::HashType> faceHashes;
|
vtkm::cont::ArrayHandle<vtkm::HashType> faceHashes;
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> originCells;
|
vtkm::cont::ArrayHandle<vtkm::Id> originCells;
|
||||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> originFaces;
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> originFaces;
|
||||||
vtkm::worklet::DispatcherMapTopology<FaceHash, DeviceAdapter> faceHashDispatcher(
|
vtkm::worklet::DispatcherMapTopology<FaceHash> faceHashDispatcher(scatterCellToFace);
|
||||||
scatterCellToFace);
|
faceHashDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
faceHashDispatcher.Invoke(inCellSet, faceHashes, originCells, originFaces);
|
faceHashDispatcher.Invoke(inCellSet, faceHashes, originCells, originFaces);
|
||||||
|
|
||||||
vtkm::worklet::Keys<vtkm::HashType> faceKeys(faceHashes, DeviceAdapter());
|
vtkm::worklet::Keys<vtkm::HashType> faceKeys(faceHashes, DeviceAdapter());
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> faceOutputCount;
|
vtkm::cont::ArrayHandle<vtkm::IdComponent> faceOutputCount;
|
||||||
vtkm::worklet::DispatcherReduceByKey<FaceCounts, DeviceAdapter> faceCountDispatcher;
|
vtkm::worklet::DispatcherReduceByKey<FaceCounts> faceCountDispatcher;
|
||||||
|
faceCountDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
faceCountDispatcher.Invoke(faceKeys, inCellSet, originCells, originFaces, faceOutputCount);
|
faceCountDispatcher.Invoke(faceKeys, inCellSet, originCells, originFaces, faceOutputCount);
|
||||||
|
|
||||||
auto scatterCullInternalFaces = NumPointsPerFace::MakeScatter(faceOutputCount, DeviceAdapter());
|
auto scatterCullInternalFaces = NumPointsPerFace::MakeScatter(faceOutputCount, DeviceAdapter());
|
||||||
|
|
||||||
PointCountArrayType facePointCount;
|
PointCountArrayType facePointCount;
|
||||||
vtkm::worklet::DispatcherReduceByKey<NumPointsPerFace, DeviceAdapter> pointsPerFaceDispatcher(
|
vtkm::worklet::DispatcherReduceByKey<NumPointsPerFace> pointsPerFaceDispatcher(
|
||||||
scatterCullInternalFaces);
|
scatterCullInternalFaces);
|
||||||
|
pointsPerFaceDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
pointsPerFaceDispatcher.Invoke(faceKeys, inCellSet, originCells, originFaces, facePointCount);
|
pointsPerFaceDispatcher.Invoke(faceKeys, inCellSet, originCells, originFaces, facePointCount);
|
||||||
|
|
||||||
@ -900,8 +908,9 @@ public:
|
|||||||
// information to.
|
// information to.
|
||||||
faceConnectivity.Allocate(connectivitySize);
|
faceConnectivity.Allocate(connectivitySize);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherReduceByKey<BuildConnectivity, DeviceAdapter>
|
vtkm::worklet::DispatcherReduceByKey<BuildConnectivity> buildConnectivityDispatcher(
|
||||||
buildConnectivityDispatcher(scatterCullInternalFaces);
|
scatterCullInternalFaces);
|
||||||
|
buildConnectivityDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> faceToCellIdMap;
|
vtkm::cont::ArrayHandle<vtkm::Id> faceToCellIdMap;
|
||||||
|
|
||||||
|
@ -169,7 +169,8 @@ public:
|
|||||||
extractInside,
|
extractInside,
|
||||||
extractBoundaryCells,
|
extractBoundaryCells,
|
||||||
extractOnlyBoundaryCells);
|
extractOnlyBoundaryCells);
|
||||||
DispatcherMapTopology<ExtractCellsByVOI, DeviceAdapter> dispatcher(worklet);
|
DispatcherMapTopology<ExtractCellsByVOI> dispatcher(worklet);
|
||||||
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
dispatcher.Invoke(cellSet, coordinates, passFlags);
|
dispatcher.Invoke(cellSet, coordinates, passFlags);
|
||||||
|
|
||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> indices =
|
vtkm::cont::ArrayHandleCounting<vtkm::Id> indices =
|
||||||
|
@ -107,7 +107,8 @@ public:
|
|||||||
vtkm::cont::ArrayHandle<bool> passFlags;
|
vtkm::cont::ArrayHandle<bool> passFlags;
|
||||||
|
|
||||||
ExtractPointsByVOI worklet(implicitFunction.PrepareForExecution(device), extractInside);
|
ExtractPointsByVOI worklet(implicitFunction.PrepareForExecution(device), extractInside);
|
||||||
DispatcherMapTopology<ExtractPointsByVOI, DeviceAdapter> dispatcher(worklet);
|
DispatcherMapTopology<ExtractPointsByVOI> dispatcher(worklet);
|
||||||
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
dispatcher.Invoke(cellSet, coordinates, passFlags);
|
dispatcher.Invoke(cellSet, coordinates, passFlags);
|
||||||
|
|
||||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> indices =
|
vtkm::cont::ArrayHandleCounting<vtkm::Id> indices =
|
||||||
|
@ -91,8 +91,9 @@ public:
|
|||||||
///// calculate information content of each bin using self-define worklet /////
|
///// calculate information content of each bin using self-define worklet /////
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float64> informationContent;
|
vtkm::cont::ArrayHandle<vtkm::Float64> informationContent;
|
||||||
SetBinInformationContent binWorklet(static_cast<vtkm::Float64>(freqSum));
|
SetBinInformationContent binWorklet(static_cast<vtkm::Float64>(freqSum));
|
||||||
vtkm::worklet::DispatcherMapField<SetBinInformationContent, DeviceAdapter>
|
vtkm::worklet::DispatcherMapField<SetBinInformationContent> setBinInformationContentDispatcher(
|
||||||
setBinInformationContentDispatcher(binWorklet);
|
binWorklet);
|
||||||
|
setBinInformationContentDispatcher.SetDevice(DeviceAdapter());
|
||||||
setBinInformationContentDispatcher.Invoke(binArray, informationContent);
|
setBinInformationContentDispatcher.Invoke(binArray, informationContent);
|
||||||
|
|
||||||
///// calculate entropy by summing up information conetent of all bins /////
|
///// calculate entropy by summing up information conetent of all bins /////
|
||||||
|
@ -166,8 +166,9 @@ public:
|
|||||||
|
|
||||||
// Worklet to set the bin number for each data value
|
// Worklet to set the bin number for each data value
|
||||||
SetHistogramBin<FieldType> binWorklet(numberOfBins, fieldMinValue, fieldDelta);
|
SetHistogramBin<FieldType> binWorklet(numberOfBins, fieldMinValue, fieldDelta);
|
||||||
vtkm::worklet::DispatcherMapField<SetHistogramBin<FieldType>, DeviceAdapter>
|
vtkm::worklet::DispatcherMapField<SetHistogramBin<FieldType>> setHistogramBinDispatcher(
|
||||||
setHistogramBinDispatcher(binWorklet);
|
binWorklet);
|
||||||
|
setHistogramBinDispatcher.SetDevice(DeviceAdapter());
|
||||||
setHistogramBinDispatcher.Invoke(fieldArray, binIndex);
|
setHistogramBinDispatcher.Invoke(fieldArray, binIndex);
|
||||||
|
|
||||||
// Sort the resulting bin array for counting
|
// Sort the resulting bin array for counting
|
||||||
@ -179,7 +180,8 @@ public:
|
|||||||
DeviceAlgorithms::UpperBounds(binIndex, binCounter, totalCount);
|
DeviceAlgorithms::UpperBounds(binIndex, binCounter, totalCount);
|
||||||
|
|
||||||
// Difference between adjacent items is the bin count
|
// Difference between adjacent items is the bin count
|
||||||
vtkm::worklet::DispatcherMapField<AdjacentDifference, DeviceAdapter> dispatcher;
|
vtkm::worklet::DispatcherMapField<AdjacentDifference> dispatcher;
|
||||||
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
dispatcher.Invoke(binCounter, totalCount, binArray);
|
dispatcher.Invoke(binCounter, totalCount, binArray);
|
||||||
|
|
||||||
//update the users data
|
//update the users data
|
||||||
|
@ -152,8 +152,9 @@ public:
|
|||||||
pow4Array.Allocate(dataSize);
|
pow4Array.Allocate(dataSize);
|
||||||
|
|
||||||
// Raw moments via Worklet
|
// Raw moments via Worklet
|
||||||
vtkm::worklet::DispatcherMapField<CalculatePowers, DeviceAdapter> calculatePowersDispatcher(
|
vtkm::worklet::DispatcherMapField<CalculatePowers> calculatePowersDispatcher(
|
||||||
CalculatePowers(4));
|
CalculatePowers(4));
|
||||||
|
calculatePowersDispatcher.SetDevice(DeviceAdapter());
|
||||||
calculatePowersDispatcher.Invoke(fieldArray, pow1Array, pow2Array, pow3Array, pow4Array);
|
calculatePowersDispatcher.Invoke(fieldArray, pow1Array, pow2Array, pow3Array, pow4Array);
|
||||||
|
|
||||||
// Accumulate the results using ScanInclusive
|
// Accumulate the results using ScanInclusive
|
||||||
@ -163,8 +164,9 @@ public:
|
|||||||
statinfo.rawMoment[FOURTH] = DeviceAlgorithms::ScanInclusive(pow4Array, pow4Array) / numValues;
|
statinfo.rawMoment[FOURTH] = DeviceAlgorithms::ScanInclusive(pow4Array, pow4Array) / numValues;
|
||||||
|
|
||||||
// Subtract the mean from every value and leave in tempArray
|
// Subtract the mean from every value and leave in tempArray
|
||||||
vtkm::worklet::DispatcherMapField<SubtractConst, DeviceAdapter> subtractConstDispatcher(
|
vtkm::worklet::DispatcherMapField<SubtractConst> subtractConstDispatcher(
|
||||||
SubtractConst(statinfo.mean));
|
SubtractConst(statinfo.mean));
|
||||||
|
subtractConstDispatcher.SetDevice(DeviceAdapter());
|
||||||
subtractConstDispatcher.Invoke(fieldArray, tempArray);
|
subtractConstDispatcher.Invoke(fieldArray, tempArray);
|
||||||
|
|
||||||
// Calculate sums of powers on the (value - mean) array
|
// Calculate sums of powers on the (value - mean) array
|
||||||
|
@ -60,7 +60,8 @@ struct DeducedPointGrad
|
|||||||
template <typename CellSetType>
|
template <typename CellSetType>
|
||||||
void operator()(const CellSetType& cellset) const
|
void operator()(const CellSetType& cellset) const
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherMapTopology<PointGradient<T>, Device> dispatcher;
|
vtkm::worklet::DispatcherMapTopology<PointGradient<T>> dispatcher;
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
|
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
|
||||||
cellset, //whole cellset in
|
cellset, //whole cellset in
|
||||||
*this->Points,
|
*this->Points,
|
||||||
@ -70,7 +71,8 @@ struct DeducedPointGrad
|
|||||||
|
|
||||||
void operator()(const vtkm::cont::CellSetStructured<3>& cellset) const
|
void operator()(const vtkm::cont::CellSetStructured<3>& cellset) const
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>, Device> dispatcher;
|
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>> dispatcher;
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
|
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
|
||||||
*this->Points,
|
*this->Points,
|
||||||
*this->Field,
|
*this->Field,
|
||||||
@ -81,7 +83,8 @@ struct DeducedPointGrad
|
|||||||
void operator()(const vtkm::cont::CellSetPermutation<vtkm::cont::CellSetStructured<3>,
|
void operator()(const vtkm::cont::CellSetPermutation<vtkm::cont::CellSetStructured<3>,
|
||||||
PermIterType>& cellset) const
|
PermIterType>& cellset) const
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>, Device> dispatcher;
|
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>> dispatcher;
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
|
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
|
||||||
*this->Points,
|
*this->Points,
|
||||||
*this->Field,
|
*this->Field,
|
||||||
@ -90,7 +93,8 @@ struct DeducedPointGrad
|
|||||||
|
|
||||||
void operator()(const vtkm::cont::CellSetStructured<2>& cellset) const
|
void operator()(const vtkm::cont::CellSetStructured<2>& cellset) const
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>, Device> dispatcher;
|
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>> dispatcher;
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
|
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
|
||||||
*this->Points,
|
*this->Points,
|
||||||
*this->Field,
|
*this->Field,
|
||||||
@ -101,7 +105,8 @@ struct DeducedPointGrad
|
|||||||
void operator()(const vtkm::cont::CellSetPermutation<vtkm::cont::CellSetStructured<2>,
|
void operator()(const vtkm::cont::CellSetPermutation<vtkm::cont::CellSetStructured<2>,
|
||||||
PermIterType>& cellset) const
|
PermIterType>& cellset) const
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>, Device> dispatcher;
|
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>> dispatcher;
|
||||||
|
dispatcher.SetDevice(Device());
|
||||||
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
|
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
|
||||||
*this->Points,
|
*this->Points,
|
||||||
*this->Field,
|
*this->Field,
|
||||||
@ -273,11 +278,11 @@ public:
|
|||||||
DeviceAdapter)
|
DeviceAdapter)
|
||||||
{
|
{
|
||||||
using DispatcherType =
|
using DispatcherType =
|
||||||
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::gradient::CellGradient<T>, DeviceAdapter>;
|
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::gradient::CellGradient<T>>;
|
||||||
|
|
||||||
vtkm::worklet::gradient::CellGradient<T> worklet;
|
vtkm::worklet::gradient::CellGradient<T> worklet;
|
||||||
DispatcherType dispatcher(worklet);
|
DispatcherType dispatcher(worklet);
|
||||||
|
dispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
dispatcher.Invoke(cells, coords, field, extraOutput);
|
dispatcher.Invoke(cells, coords, field, extraOutput);
|
||||||
return extraOutput.Gradient;
|
return extraOutput.Gradient;
|
||||||
|
@ -431,8 +431,8 @@ struct KernelSplatterFilterUniformGrid
|
|||||||
IdHandleType localNeighborIds;
|
IdHandleType localNeighborIds;
|
||||||
|
|
||||||
GetFootprint footprint_worklet(origin_, spacing_, pointDimensions, kernel_);
|
GetFootprint footprint_worklet(origin_, spacing_, pointDimensions, kernel_);
|
||||||
vtkm::worklet::DispatcherMapField<GetFootprint, DeviceAdapter> footprintDispatcher(
|
vtkm::worklet::DispatcherMapField<GetFootprint> footprintDispatcher(footprint_worklet);
|
||||||
footprint_worklet);
|
footprintDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
START_TIMER_BLOCK(GetFootprint)
|
START_TIMER_BLOCK(GetFootprint)
|
||||||
footprintDispatcher.Invoke(
|
footprintDispatcher.Invoke(
|
||||||
@ -495,7 +495,8 @@ struct KernelSplatterFilterUniformGrid
|
|||||||
IdPermType offsets(neighbor2SplatId, numNeighborsExclusiveSum);
|
IdPermType offsets(neighbor2SplatId, numNeighborsExclusiveSum);
|
||||||
debug::OutputArrayDebug(offsets, "offsets");
|
debug::OutputArrayDebug(offsets, "offsets");
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapField<ComputeLocalNeighborId, DeviceAdapter> idDispatcher;
|
vtkm::worklet::DispatcherMapField<ComputeLocalNeighborId> idDispatcher;
|
||||||
|
idDispatcher.SetDevice(DeviceAdapter());
|
||||||
START_TIMER_BLOCK(idDispatcher)
|
START_TIMER_BLOCK(idDispatcher)
|
||||||
idDispatcher.Invoke(modulii, offsets, localNeighborIds);
|
idDispatcher.Invoke(modulii, offsets, localNeighborIds);
|
||||||
END_TIMER_BLOCK(idDispatcher)
|
END_TIMER_BLOCK(idDispatcher)
|
||||||
@ -528,8 +529,8 @@ struct KernelSplatterFilterUniformGrid
|
|||||||
FloatHandleType splatValues;
|
FloatHandleType splatValues;
|
||||||
|
|
||||||
GetSplatValue splatterDispatcher_worklet(origin_, spacing_, pointDimensions, kernel_);
|
GetSplatValue splatterDispatcher_worklet(origin_, spacing_, pointDimensions, kernel_);
|
||||||
vtkm::worklet::DispatcherMapField<GetSplatValue, DeviceAdapter> splatterDispatcher(
|
vtkm::worklet::DispatcherMapField<GetSplatValue> splatterDispatcher(splatterDispatcher_worklet);
|
||||||
splatterDispatcher_worklet);
|
splatterDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
START_TIMER_BLOCK(GetSplatValue)
|
START_TIMER_BLOCK(GetSplatValue)
|
||||||
splatterDispatcher.Invoke(ptSplatPoints,
|
splatterDispatcher.Invoke(ptSplatPoints,
|
||||||
@ -582,7 +583,8 @@ struct KernelSplatterFilterUniformGrid
|
|||||||
// initialize each field value to zero to begin with
|
// initialize each field value to zero to begin with
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
IdCountingType indexArray(vtkm::Id(0), 1, numVolumePoints);
|
IdCountingType indexArray(vtkm::Id(0), 1, numVolumePoints);
|
||||||
vtkm::worklet::DispatcherMapField<zero_voxel, DeviceAdapter> zeroDispatcher;
|
vtkm::worklet::DispatcherMapField<zero_voxel> zeroDispatcher;
|
||||||
|
zeroDispatcher.SetDevice(DeviceAdapter());
|
||||||
zeroDispatcher.Invoke(indexArray, scalarSplatOutput);
|
zeroDispatcher.Invoke(indexArray, scalarSplatOutput);
|
||||||
//
|
//
|
||||||
indexArray.ReleaseResources();
|
indexArray.ReleaseResources();
|
||||||
@ -591,7 +593,8 @@ struct KernelSplatterFilterUniformGrid
|
|||||||
// Scatter operation to write the previously-computed splat
|
// Scatter operation to write the previously-computed splat
|
||||||
// value sums into their corresponding entries in the output array
|
// value sums into their corresponding entries in the output array
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
vtkm::worklet::DispatcherMapField<UpdateVoxelSplats, DeviceAdapter> scatterDispatcher;
|
vtkm::worklet::DispatcherMapField<UpdateVoxelSplats> scatterDispatcher;
|
||||||
|
scatterDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
START_TIMER_BLOCK(UpdateVoxelSplats)
|
START_TIMER_BLOCK(UpdateVoxelSplats)
|
||||||
scatterDispatcher.Invoke(uniqueVoxelIds, voxelSplatSums, scalarSplatOutput);
|
scatterDispatcher.Invoke(uniqueVoxelIds, voxelSplatSums, scalarSplatOutput);
|
||||||
|
@ -469,7 +469,8 @@ void MergeDuplicates(const vtkm::cont::ArrayHandle<KeyType, KeyStorage>& origina
|
|||||||
input_keys.ReleaseResources();
|
input_keys.ReleaseResources();
|
||||||
|
|
||||||
{
|
{
|
||||||
vtkm::worklet::DispatcherReduceByKey<MergeDuplicateValues, DeviceAdapterTag> dispatcher;
|
vtkm::worklet::DispatcherReduceByKey<MergeDuplicateValues> dispatcher;
|
||||||
|
dispatcher.SetDevice(DeviceAdapterTag());
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> writeCells;
|
vtkm::cont::ArrayHandle<vtkm::Id> writeCells;
|
||||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> writeWeights;
|
vtkm::cont::ArrayHandle<vtkm::FloatDefault> writeWeights;
|
||||||
dispatcher.Invoke(keys, weights, cellids, writeWeights, writeCells);
|
dispatcher.Invoke(keys, weights, cellids, writeWeights, writeCells);
|
||||||
@ -483,7 +484,8 @@ void MergeDuplicates(const vtkm::cont::ArrayHandle<KeyType, KeyStorage>& origina
|
|||||||
uniqueKeys, original_keys, connectivity, marchingcubes::MultiContourLess());
|
uniqueKeys, original_keys, connectivity, marchingcubes::MultiContourLess());
|
||||||
|
|
||||||
//update the edge ids
|
//update the edge ids
|
||||||
vtkm::worklet::DispatcherMapField<CopyEdgeIds, DeviceAdapterTag> edgeDispatcher;
|
vtkm::worklet::DispatcherMapField<CopyEdgeIds> edgeDispatcher;
|
||||||
|
edgeDispatcher.SetDevice(DeviceAdapterTag());
|
||||||
edgeDispatcher.Invoke(uniqueKeys, edgeIds);
|
edgeDispatcher.Invoke(uniqueKeys, edgeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,13 +679,15 @@ struct GenerateNormalsDeduced
|
|||||||
// The final normal is interpolated from the two gradient values and stored
|
// The final normal is interpolated from the two gradient values and stored
|
||||||
// in the normals array.
|
// in the normals array.
|
||||||
//
|
//
|
||||||
vtkm::worklet::DispatcherMapTopology<NormalsWorkletPass1, DeviceAdapterTag>
|
vtkm::worklet::DispatcherMapTopology<NormalsWorkletPass1> dispatcherNormalsPass1(
|
||||||
dispatcherNormalsPass1(NormalsWorkletPass1::MakeScatter(*edges));
|
NormalsWorkletPass1::MakeScatter(*edges));
|
||||||
|
dispatcherNormalsPass1.SetDevice(DeviceAdapterTag());
|
||||||
dispatcherNormalsPass1.Invoke(
|
dispatcherNormalsPass1.Invoke(
|
||||||
*cellset, *cellset, coordinates, marchingcubes::make_ScalarField(*field), *normals);
|
*cellset, *cellset, coordinates, marchingcubes::make_ScalarField(*field), *normals);
|
||||||
|
|
||||||
vtkm::worklet::DispatcherMapTopology<NormalsWorkletPass2, DeviceAdapterTag>
|
vtkm::worklet::DispatcherMapTopology<NormalsWorkletPass2> dispatcherNormalsPass2(
|
||||||
dispatcherNormalsPass2(NormalsWorkletPass2::MakeScatter(*edges));
|
NormalsWorkletPass2::MakeScatter(*edges));
|
||||||
|
dispatcherNormalsPass2.SetDevice(DeviceAdapterTag());
|
||||||
dispatcherNormalsPass2.Invoke(
|
dispatcherNormalsPass2.Invoke(
|
||||||
*cellset, *cellset, coordinates, marchingcubes::make_ScalarField(*field), *weights, *normals);
|
*cellset, *cellset, coordinates, marchingcubes::make_ScalarField(*field), *weights, *normals);
|
||||||
}
|
}
|
||||||
@ -797,8 +801,8 @@ public:
|
|||||||
{
|
{
|
||||||
using vtkm::worklet::marchingcubes::MapPointField;
|
using vtkm::worklet::marchingcubes::MapPointField;
|
||||||
MapPointField applyToField;
|
MapPointField applyToField;
|
||||||
vtkm::worklet::DispatcherMapField<MapPointField, DeviceAdapter> applyFieldDispatcher(
|
vtkm::worklet::DispatcherMapField<MapPointField> applyFieldDispatcher(applyToField);
|
||||||
applyToField);
|
applyFieldDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<ValueType> output;
|
vtkm::cont::ArrayHandle<ValueType> output;
|
||||||
applyFieldDispatcher.Invoke(
|
applyFieldDispatcher.Invoke(
|
||||||
@ -940,12 +944,10 @@ private:
|
|||||||
using vtkm::worklet::marchingcubes::MapPointField;
|
using vtkm::worklet::marchingcubes::MapPointField;
|
||||||
|
|
||||||
// Setup the Dispatcher Typedefs
|
// Setup the Dispatcher Typedefs
|
||||||
using ClassifyDispatcher =
|
using ClassifyDispatcher = vtkm::worklet::DispatcherMapTopology<ClassifyCell<ValueType>>;
|
||||||
typename vtkm::worklet::DispatcherMapTopology<ClassifyCell<ValueType>, DeviceAdapter>;
|
|
||||||
|
|
||||||
using GenerateDispatcher =
|
using GenerateDispatcher =
|
||||||
typename vtkm::worklet::DispatcherMapTopology<EdgeWeightGenerate<ValueType, DeviceAdapter>,
|
vtkm::worklet::DispatcherMapTopology<EdgeWeightGenerate<ValueType, DeviceAdapter>>;
|
||||||
DeviceAdapter>;
|
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<ValueType> isoValuesHandle =
|
vtkm::cont::ArrayHandle<ValueType> isoValuesHandle =
|
||||||
vtkm::cont::make_ArrayHandle(isovalues, numIsoValues);
|
vtkm::cont::make_ArrayHandle(isovalues, numIsoValues);
|
||||||
@ -957,6 +959,7 @@ private:
|
|||||||
{
|
{
|
||||||
ClassifyCell<ValueType> classifyCell;
|
ClassifyCell<ValueType> classifyCell;
|
||||||
ClassifyDispatcher classifyCellDispatcher(classifyCell);
|
ClassifyDispatcher classifyCellDispatcher(classifyCell);
|
||||||
|
classifyCellDispatcher.SetDevice(DeviceAdapter());
|
||||||
classifyCellDispatcher.Invoke(
|
classifyCellDispatcher.Invoke(
|
||||||
isoValuesHandle, inputField, cells, numOutputTrisPerCell, this->NumTrianglesTable);
|
isoValuesHandle, inputField, cells, numOutputTrisPerCell, this->NumTrianglesTable);
|
||||||
}
|
}
|
||||||
@ -983,6 +986,7 @@ private:
|
|||||||
|
|
||||||
EdgeWeightGenerate<ValueType, DeviceAdapter> weightGenerate(metaData);
|
EdgeWeightGenerate<ValueType, DeviceAdapter> weightGenerate(metaData);
|
||||||
GenerateDispatcher edgeDispatcher(weightGenerate, scatter);
|
GenerateDispatcher edgeDispatcher(weightGenerate, scatter);
|
||||||
|
edgeDispatcher.SetDevice(DeviceAdapter());
|
||||||
edgeDispatcher.Invoke(
|
edgeDispatcher.Invoke(
|
||||||
cells,
|
cells,
|
||||||
//cast to a scalar field if not one, as cellderivative only works on those
|
//cast to a scalar field if not one, as cellderivative only works on those
|
||||||
@ -1034,8 +1038,8 @@ private:
|
|||||||
|
|
||||||
//generate the vertices's
|
//generate the vertices's
|
||||||
MapPointField applyToField;
|
MapPointField applyToField;
|
||||||
vtkm::worklet::DispatcherMapField<MapPointField, DeviceAdapter> applyFieldDispatcher(
|
vtkm::worklet::DispatcherMapField<MapPointField> applyFieldDispatcher(applyToField);
|
||||||
applyToField);
|
applyFieldDispatcher.SetDevice(DeviceAdapter());
|
||||||
|
|
||||||
applyFieldDispatcher.Invoke(
|
applyFieldDispatcher.Invoke(
|
||||||
this->InterpolationEdgeIds, this->InterpolationWeights, coordinateSystem, vertices);
|
this->InterpolationEdgeIds, this->InterpolationWeights, coordinateSystem, vertices);
|
||||||
|
@ -80,9 +80,9 @@ public:
|
|||||||
vtkm::cont::ArrayHandle<vtkm::Float64> informationContent;
|
vtkm::cont::ArrayHandle<vtkm::Float64> informationContent;
|
||||||
vtkm::worklet::histogram::SetBinInformationContent binWorklet(
|
vtkm::worklet::histogram::SetBinInformationContent binWorklet(
|
||||||
static_cast<vtkm::Float64>(freqSum));
|
static_cast<vtkm::Float64>(freqSum));
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::SetBinInformationContent,
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::SetBinInformationContent>
|
||||||
DeviceAdapter>
|
|
||||||
setBinInformationContentDispatcher(binWorklet);
|
setBinInformationContentDispatcher(binWorklet);
|
||||||
|
setBinInformationContentDispatcher.SetDevice(DeviceAdapter());
|
||||||
setBinInformationContentDispatcher.Invoke(freqs, informationContent);
|
setBinInformationContentDispatcher.Invoke(freqs, informationContent);
|
||||||
|
|
||||||
///// calculate entropy by summing up information conetent of all bins /////
|
///// calculate entropy by summing up information conetent of all bins /////
|
||||||
|
@ -94,8 +94,9 @@ public:
|
|||||||
numMarginalVariables++;
|
numMarginalVariables++;
|
||||||
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
|
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
|
||||||
vtkm::worklet::histogram::To1DIndex binWorklet(nFieldBins);
|
vtkm::worklet::histogram::To1DIndex binWorklet(nFieldBins);
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::To1DIndex, DeviceAdapter>
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::To1DIndex> to1DIndexDispatcher(
|
||||||
to1DIndexDispatcher(binWorklet);
|
binWorklet);
|
||||||
|
to1DIndexDispatcher.SetDevice(DeviceAdapter());
|
||||||
size_t vecIndex = static_cast<size_t>(i);
|
size_t vecIndex = static_cast<size_t>(i);
|
||||||
to1DIndexDispatcher.Invoke(binId[vecIndex], bin1DIndex, bin1DIndex);
|
to1DIndexDispatcher.Invoke(binId[vecIndex], bin1DIndex, bin1DIndex);
|
||||||
}
|
}
|
||||||
@ -107,9 +108,9 @@ public:
|
|||||||
conditionFunc
|
conditionFunc
|
||||||
};
|
};
|
||||||
conditionalFreqWorklet.setVar(i);
|
conditionalFreqWorklet.setVar(i);
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConditionalFreq<BinaryCompare>,
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConditionalFreq<BinaryCompare>>
|
||||||
DeviceAdapter>
|
|
||||||
cfDispatcher(conditionalFreqWorklet);
|
cfDispatcher(conditionalFreqWorklet);
|
||||||
|
cfDispatcher.SetDevice(DeviceAdapter());
|
||||||
size_t vecIndex = static_cast<size_t>(i);
|
size_t vecIndex = static_cast<size_t>(i);
|
||||||
cfDispatcher.Invoke(binId[vecIndex], freqs, freqs);
|
cfDispatcher.Invoke(binId[vecIndex], freqs, freqs);
|
||||||
}
|
}
|
||||||
@ -138,11 +139,11 @@ public:
|
|||||||
{
|
{
|
||||||
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
|
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
|
||||||
vtkm::worklet::histogram::ConvertHistBinToND binWorklet(nFieldBins);
|
vtkm::worklet::histogram::ConvertHistBinToND binWorklet(nFieldBins);
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND,
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND>
|
||||||
DeviceAdapter>
|
convertHistBinToNDDispatcher(binWorklet);
|
||||||
ConvertHistBinToNDDispatcher(binWorklet);
|
convertHistBinToNDDispatcher.SetDevice(DeviceAdapter());
|
||||||
size_t vecIndex = static_cast<size_t>(marginalVarIdx);
|
size_t vecIndex = static_cast<size_t>(marginalVarIdx);
|
||||||
ConvertHistBinToNDDispatcher.Invoke(
|
convertHistBinToNDDispatcher.Invoke(
|
||||||
sparseMarginal1DBinId, sparseMarginal1DBinId, marginalBinId[vecIndex]);
|
sparseMarginal1DBinId, sparseMarginal1DBinId, marginalBinId[vecIndex]);
|
||||||
marginalVarIdx--;
|
marginalVarIdx--;
|
||||||
}
|
}
|
||||||
@ -181,8 +182,9 @@ public:
|
|||||||
numMarginalVariables++;
|
numMarginalVariables++;
|
||||||
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
|
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
|
||||||
vtkm::worklet::histogram::To1DIndex binWorklet(nFieldBins);
|
vtkm::worklet::histogram::To1DIndex binWorklet(nFieldBins);
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::To1DIndex, DeviceAdapter>
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::To1DIndex> to1DIndexDispatcher(
|
||||||
to1DIndexDispatcher(binWorklet);
|
binWorklet);
|
||||||
|
to1DIndexDispatcher.SetDevice(DeviceAdapter());
|
||||||
size_t vecIndex = static_cast<size_t>(i);
|
size_t vecIndex = static_cast<size_t>(i);
|
||||||
to1DIndexDispatcher.Invoke(binId[vecIndex], bin1DIndex, bin1DIndex);
|
to1DIndexDispatcher.Invoke(binId[vecIndex], bin1DIndex, bin1DIndex);
|
||||||
}
|
}
|
||||||
@ -203,11 +205,11 @@ public:
|
|||||||
{
|
{
|
||||||
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
|
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
|
||||||
vtkm::worklet::histogram::ConvertHistBinToND binWorklet(nFieldBins);
|
vtkm::worklet::histogram::ConvertHistBinToND binWorklet(nFieldBins);
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND,
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND>
|
||||||
DeviceAdapter>
|
convertHistBinToNDDispatcher(binWorklet);
|
||||||
ConvertHistBinToNDDispatcher(binWorklet);
|
convertHistBinToNDDispatcher.SetDevice(DeviceAdapter());
|
||||||
size_t vecIndex = static_cast<size_t>(marginalVarIdx);
|
size_t vecIndex = static_cast<size_t>(marginalVarIdx);
|
||||||
ConvertHistBinToNDDispatcher.Invoke(bin1DIndex, bin1DIndex, marginalBinId[vecIndex]);
|
convertHistBinToNDDispatcher.Invoke(bin1DIndex, bin1DIndex, marginalBinId[vecIndex]);
|
||||||
marginalVarIdx--;
|
marginalVarIdx--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,10 +109,11 @@ public:
|
|||||||
{
|
{
|
||||||
const vtkm::Id nFieldBins = NumberOfBins[static_cast<size_t>(i)];
|
const vtkm::Id nFieldBins = NumberOfBins[static_cast<size_t>(i)];
|
||||||
vtkm::worklet::histogram::ConvertHistBinToND binWorklet(nFieldBins);
|
vtkm::worklet::histogram::ConvertHistBinToND binWorklet(nFieldBins);
|
||||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND, DeviceAdapter>
|
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND>
|
||||||
ConvertHistBinToNDDispatcher(binWorklet);
|
convertHistBinToNDDispatcher(binWorklet);
|
||||||
|
convertHistBinToNDDispatcher.SetDevice(DeviceAdapter());
|
||||||
size_t vectorId = static_cast<size_t>(i);
|
size_t vectorId = static_cast<size_t>(i);
|
||||||
ConvertHistBinToNDDispatcher.Invoke(Bin1DIndex, Bin1DIndex, binId[vectorId]);
|
convertHistBinToNDDispatcher.Invoke(Bin1DIndex, Bin1DIndex, binId[vectorId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user