mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Change the namespacing of atomic array
moved the execution object to vtkm::exec and AtomicArray to vtkm::cont
This commit is contained in:
parent
6b9cb536a8
commit
db1c9bfeee
@ -17,17 +17,18 @@
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_exec_AtomicArray_h
|
||||
#define vtk_m_exec_AtomicArray_h
|
||||
#ifndef vtk_m_cont_AtomicArray_h
|
||||
#define vtk_m_cont_AtomicArray_h
|
||||
|
||||
#include <vtkm/ListTag.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/ExecutionObjectBase.h>
|
||||
#include <vtkm/exec/AtomicArrayExecutionObject.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
namespace cont
|
||||
{
|
||||
|
||||
/// \brief A type list containing types that can be used with an AtomicArray.
|
||||
@ -36,46 +37,6 @@ struct AtomicArrayTypeListTag : vtkm::ListTagBase<vtkm::Int32, vtkm::Int64>
|
||||
{
|
||||
};
|
||||
|
||||
template <typename T, typename Device>
|
||||
class AtomicArrayExecutionObject
|
||||
{
|
||||
public:
|
||||
using ValueType = T;
|
||||
|
||||
VTKM_CONT
|
||||
AtomicArrayExecutionObject()
|
||||
: AtomicImplementation((vtkm::cont::ArrayHandle<T>()))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename StorageType>
|
||||
VTKM_CONT AtomicArrayExecutionObject(vtkm::cont::ArrayHandle<T, StorageType> handle)
|
||||
: AtomicImplementation(handle)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC
|
||||
T Add(vtkm::Id index, const T& value) const
|
||||
{
|
||||
return this->AtomicImplementation.Add(index, value);
|
||||
}
|
||||
|
||||
//
|
||||
// Compare and Swap is an atomic exchange operation. If the value at
|
||||
// the index is equal to oldValue, then newValue is written to the index.
|
||||
// The operation was successful if return value is equal to oldValue
|
||||
//
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC
|
||||
T CompareAndSwap(vtkm::Id index, const T& newValue, const T& oldValue) const
|
||||
{
|
||||
return this->AtomicImplementation.CompareAndSwap(index, newValue, oldValue);
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::cont::DeviceAdapterAtomicArrayImplementation<T, Device> AtomicImplementation;
|
||||
};
|
||||
|
||||
/// A class that can be used to atomically operate on an array of values safely
|
||||
/// across multiple instances of the same worklet. This is useful when you have
|
||||
@ -98,16 +59,16 @@ public:
|
||||
using ValueType = T;
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT AtomicArrayExecutionObject<T, Device> PrepareForExecution(Device) const
|
||||
VTKM_CONT vtkm::exec::AtomicArrayExecutionObject<T, Device> PrepareForExecution(Device) const
|
||||
{
|
||||
AtomicArrayExecutionObject<T, Device> execObject;
|
||||
vtkm::exec::AtomicArrayExecutionObject<T, Device> execObject;
|
||||
if (isHandle)
|
||||
{
|
||||
execObject = AtomicArrayExecutionObject<T, Device>(this->Handle);
|
||||
execObject = vtkm::exec::AtomicArrayExecutionObject<T, Device>(this->Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
execObject = AtomicArrayExecutionObject<T, Device>();
|
||||
execObject = vtkm::exec::AtomicArrayExecutionObject<T, Device>();
|
||||
}
|
||||
return execObject;
|
||||
}
|
||||
@ -131,4 +92,4 @@ private:
|
||||
}
|
||||
} // namespace vtkm::exec
|
||||
|
||||
#endif //vtk_m_exec_AtomicArray_h
|
||||
#endif //vtk_m_cont_AtomicArray_h
|
@ -46,6 +46,7 @@ set(headers
|
||||
ArrayHandleConcatenate.h
|
||||
ArrayRangeCompute.h
|
||||
AssignerMultiBlock.h
|
||||
AtomicArray.h
|
||||
BoundingIntervalHierarchyNode.h
|
||||
BoundingIntervalHierarchy.h
|
||||
BoundsCompute.h
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include <vtkm/cont/arg/Transport.h>
|
||||
|
||||
#include <vtkm/exec/AtomicArray.h>
|
||||
#include <vtkm/cont/AtomicArray.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -54,7 +54,7 @@ struct Transport<vtkm::cont::arg::TransportTagAtomicArray,
|
||||
Device>
|
||||
{
|
||||
using ExecObjectType = vtkm::exec::AtomicArrayExecutionObject<T, Device>;
|
||||
using ExecType = vtkm::exec::AtomicArray<T>;
|
||||
using ExecType = vtkm::cont::AtomicArray<T>;
|
||||
|
||||
template <typename InputDomainType>
|
||||
VTKM_CONT ExecObjectType operator()(vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic> array,
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
|
||||
#include <vtkm/exec/AtomicArray.h>
|
||||
#include <vtkm/cont/AtomicArray.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -40,7 +40,7 @@ namespace arg
|
||||
/// that is valid for atomic access. There are many restrictions on the
|
||||
/// type of data that can be used for an atomic array.
|
||||
///
|
||||
template <typename TypeList = vtkm::exec::AtomicArrayTypeListTag>
|
||||
template <typename TypeList = vtkm::cont::AtomicArrayTypeListTag>
|
||||
struct TypeCheckTagAtomicArray
|
||||
{
|
||||
VTKM_IS_LIST_TAG(TypeList);
|
||||
@ -57,7 +57,7 @@ struct TypeCheck<TypeCheckTagAtomicArray<TypeList>,
|
||||
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>>
|
||||
{
|
||||
static constexpr bool value = (vtkm::ListContains<TypeList, T>::value &&
|
||||
vtkm::ListContains<vtkm::exec::AtomicArrayTypeListTag, T>::value);
|
||||
vtkm::ListContains<vtkm::cont::AtomicArrayTypeListTag, T>::value);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ void TryArrayOutTransport(Device)
|
||||
{
|
||||
vtkm::testing::Testing::TryTypes(TryWholeArrayType<Device>(), vtkm::TypeListTagCommon());
|
||||
vtkm::testing::Testing::TryTypes(TryAtomicArrayType<Device>(),
|
||||
vtkm::exec::AtomicArrayTypeListTag());
|
||||
vtkm::cont::AtomicArrayTypeListTag());
|
||||
}
|
||||
|
||||
void TestWholeArrayTransport()
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
#include <vtkm/exec/AtomicArray.h>
|
||||
#include <vtkm/cont/AtomicArray.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
@ -270,7 +270,7 @@ public:
|
||||
struct AtomicKernel
|
||||
{
|
||||
VTKM_CONT
|
||||
AtomicKernel(const vtkm::exec::AtomicArray<T>& array)
|
||||
AtomicKernel(const vtkm::cont::AtomicArray<T>& array)
|
||||
: AArray(array.PrepareForExecution(DeviceAdapterTag()))
|
||||
{
|
||||
}
|
||||
@ -290,7 +290,7 @@ public:
|
||||
struct AtomicCASKernel
|
||||
{
|
||||
VTKM_CONT
|
||||
AtomicCASKernel(const vtkm::exec::AtomicArray<T>& array)
|
||||
AtomicCASKernel(const vtkm::cont::AtomicArray<T>& array)
|
||||
: AArray(array.PrepareForExecution(DeviceAdapterTag()))
|
||||
{
|
||||
}
|
||||
@ -2094,7 +2094,7 @@ private:
|
||||
vtkm::cont::ArrayHandle<vtkm::Int32> atomicElement =
|
||||
vtkm::cont::make_ArrayHandle(singleElement);
|
||||
|
||||
vtkm::exec::AtomicArray<vtkm::Int32> atomic(atomicElement);
|
||||
vtkm::cont::AtomicArray<vtkm::Int32> atomic(atomicElement);
|
||||
Algorithm::Schedule(AtomicKernel<vtkm::Int32>(atomic), SHORT_ARRAY_SIZE);
|
||||
vtkm::Int32 expected = vtkm::Int32(atomicCount);
|
||||
vtkm::Int32 actual = atomicElement.GetPortalControl().Get(0);
|
||||
@ -2108,7 +2108,7 @@ private:
|
||||
vtkm::cont::ArrayHandle<vtkm::Int64> atomicElement =
|
||||
vtkm::cont::make_ArrayHandle(singleElement);
|
||||
|
||||
vtkm::exec::AtomicArray<vtkm::Int64> atomic(atomicElement);
|
||||
vtkm::cont::AtomicArray<vtkm::Int64> atomic(atomicElement);
|
||||
Algorithm::Schedule(AtomicKernel<vtkm::Int64>(atomic), SHORT_ARRAY_SIZE);
|
||||
vtkm::Int64 expected = vtkm::Int64(atomicCount);
|
||||
vtkm::Int64 actual = atomicElement.GetPortalControl().Get(0);
|
||||
@ -2122,7 +2122,7 @@ private:
|
||||
vtkm::cont::ArrayHandle<vtkm::Int32> atomicElement =
|
||||
vtkm::cont::make_ArrayHandle(singleElement);
|
||||
|
||||
vtkm::exec::AtomicArray<vtkm::Int32> atomic(atomicElement);
|
||||
vtkm::cont::AtomicArray<vtkm::Int32> atomic(atomicElement);
|
||||
Algorithm::Schedule(AtomicCASKernel<vtkm::Int32>(atomic), SHORT_ARRAY_SIZE);
|
||||
vtkm::Int32 expected = vtkm::Int32(atomicCount);
|
||||
vtkm::Int32 actual = atomicElement.GetPortalControl().Get(0);
|
||||
@ -2136,7 +2136,7 @@ private:
|
||||
vtkm::cont::ArrayHandle<vtkm::Int64> atomicElement =
|
||||
vtkm::cont::make_ArrayHandle(singleElement);
|
||||
|
||||
vtkm::exec::AtomicArray<vtkm::Int64> atomic(atomicElement);
|
||||
vtkm::cont::AtomicArray<vtkm::Int64> atomic(atomicElement);
|
||||
Algorithm::Schedule(AtomicCASKernel<vtkm::Int64>(atomic), SHORT_ARRAY_SIZE);
|
||||
vtkm::Int64 expected = vtkm::Int64(atomicCount);
|
||||
vtkm::Int64 actual = atomicElement.GetPortalControl().Get(0);
|
||||
|
75
vtkm/exec/AtomicArrayExecutionObject.h
Normal file
75
vtkm/exec/AtomicArrayExecutionObject.h
Normal file
@ -0,0 +1,75 @@
|
||||
//============================================================================
|
||||
// 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 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
||||
// Copyright 2015 UT-Battelle, LLC.
|
||||
// Copyright 2015 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_exec_AtomicArrayExecutionObject_h
|
||||
#define vtk_m_exec_AtomicArrayExecutionObject_h
|
||||
|
||||
#include <vtkm/ListTag.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace exec
|
||||
{
|
||||
|
||||
template <typename T, typename Device>
|
||||
class AtomicArrayExecutionObject
|
||||
{
|
||||
public:
|
||||
using ValueType = T;
|
||||
|
||||
VTKM_CONT
|
||||
AtomicArrayExecutionObject()
|
||||
: AtomicImplementation((vtkm::cont::ArrayHandle<T>()))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename StorageType>
|
||||
VTKM_CONT AtomicArrayExecutionObject(vtkm::cont::ArrayHandle<T, StorageType> handle)
|
||||
: AtomicImplementation(handle)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC
|
||||
T Add(vtkm::Id index, const T& value) const
|
||||
{
|
||||
return this->AtomicImplementation.Add(index, value);
|
||||
}
|
||||
|
||||
//
|
||||
// Compare and Swap is an atomic exchange operation. If the value at
|
||||
// the index is equal to oldValue, then newValue is written to the index.
|
||||
// The operation was successful if return value is equal to oldValue
|
||||
//
|
||||
VTKM_SUPPRESS_EXEC_WARNINGS
|
||||
VTKM_EXEC
|
||||
T CompareAndSwap(vtkm::Id index, const T& newValue, const T& oldValue) const
|
||||
{
|
||||
return this->AtomicImplementation.CompareAndSwap(index, newValue, oldValue);
|
||||
}
|
||||
|
||||
private:
|
||||
vtkm::cont::DeviceAdapterAtomicArrayImplementation<T, Device> AtomicImplementation;
|
||||
};
|
||||
}
|
||||
} // namespace vtkm::exec
|
||||
|
||||
#endif //vtk_m_exec_AtomicArrayExecutionObject_h
|
@ -19,8 +19,8 @@
|
||||
##============================================================================
|
||||
|
||||
set(headers
|
||||
AtomicArray.h
|
||||
BoundingIntervalHierarchyExec.h
|
||||
AtomicArrayExecutionObject.h
|
||||
CellDerivative.h
|
||||
CellEdge.h
|
||||
CellFace.h
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/VectorAnalysis.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/AtomicArray.h>
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
#include <vtkm/exec/AtomicArray.h>
|
||||
#include <vtkm/rendering/MatrixHelpers.h>
|
||||
#include <vtkm/rendering/Triangulator.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
@ -159,7 +159,7 @@ class EdgePlotter : public vtkm::worklet::WorkletMapField
|
||||
public:
|
||||
using AtomicPackedFrameBufferHandle =
|
||||
vtkm::exec::AtomicArrayExecutionObject<vtkm::Int64, DeviceTag>;
|
||||
using AtomicPackedFrameBuffer = vtkm::exec::AtomicArray<vtkm::Int64>;
|
||||
using AtomicPackedFrameBuffer = vtkm::cont::AtomicArray<vtkm::Int64>;
|
||||
|
||||
using ControlSignature = void(FieldIn<Id2Type>, WholeArrayIn<Vec3>, WholeArrayIn<Scalar>);
|
||||
using ExecutionSignature = void(_1, _2, _3);
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <vtkm/cont/Timer.h>
|
||||
#include <vtkm/cont/TryExecute.h>
|
||||
|
||||
#include <vtkm/exec/AtomicArray.h>
|
||||
#include <vtkm/cont/AtomicArray.h>
|
||||
|
||||
#include <vtkm/rendering/raytracing/BoundingVolumeHierarchy.h>
|
||||
#include <vtkm/rendering/raytracing/Logger.h>
|
||||
@ -306,7 +306,7 @@ public:
|
||||
IdArrayHandle& rightChildren,
|
||||
vtkm::Int32 leafCount,
|
||||
Float4ArrayHandle flatBVH,
|
||||
const vtkm::exec::AtomicArray<vtkm::Int32>& counters)
|
||||
const vtkm::cont::AtomicArray<vtkm::Int32>& counters)
|
||||
: Parents(parents.PrepareForInput(Device()))
|
||||
, LeftChildren(leftChildren.PrepareForInput(Device()))
|
||||
, RightChildren(rightChildren.PrepareForInput(Device()))
|
||||
@ -774,7 +774,7 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
|
||||
vtkm::Int32 zero = 0;
|
||||
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Int32>, Device>(MemSet<vtkm::Int32>(zero))
|
||||
.Invoke(counters);
|
||||
vtkm::exec::AtomicArray<vtkm::Int32> atomicCounters(counters);
|
||||
vtkm::cont::AtomicArray<vtkm::Int32> atomicCounters(counters);
|
||||
|
||||
|
||||
vtkm::worklet::DispatcherMapField<PropagateAABBs<Device>, Device>(
|
||||
|
@ -163,7 +163,7 @@ void TestWorkletMapFieldExecArg()
|
||||
|
||||
std::cout << "--- Worklet accepting atomics." << std::endl;
|
||||
vtkm::testing::Testing::TryTypes(map_whole_array::DoTestAtomicArrayWorklet(),
|
||||
vtkm::exec::AtomicArrayTypeListTag());
|
||||
vtkm::cont::AtomicArrayTypeListTag());
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
Loading…
Reference in New Issue
Block a user