Add additional control logic for CopyInto function

Clean up comments and align code to 80 character width
This commit is contained in:
hschroot 2015-08-13 17:51:50 -07:00 committed by Sujin Philip
parent 20c1a04894
commit 2c55b15c3f
5 changed files with 20 additions and 41 deletions

@ -225,21 +225,20 @@ public:
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapterTag);
if (!this->Internals->ControlArrayValid
&& !this->Internals->ExecutionArrayValid)
if (!this->Internals->ControlArrayValid &&
!this->Internals->ExecutionArrayValid)
{
throw vtkm::cont::ErrorControlBadValue(
"ArrayHandle has no data to copy into Iterator.");
}
if (this->Internals->ExecutionArrayValid)
if (!this->Internals->ControlArrayValid &&
this->Internals->ExecutionArray->IsDeviceAdapter(DeviceAdapterTag()))
{
//This will ensure we have a concrete instance of the
//ArrayHandleExecutionManager
this->PrepareForDevice(DeviceAdapterTag());
//Next, do a dynamic cast to convert the ArrayHandleExecutionManager
//into a concrete class to call CopyInto
/// Dynamically cast ArrayHandleExecutionManagerBase into a concrete
/// class and call CopyInto. The dynamic conversion will be sucessful
/// becuase the check to ensure the ExecutionArray is of the type
/// DeviceAdapterTag has already passed
typedef vtkm::cont::internal::ArrayHandleExecutionManager<
T, StorageTag, DeviceAdapterTag> ConcreteType;
ConcreteType *ConcreteExecutionArray =

@ -63,9 +63,8 @@ public:
VTKM_EXEC_CONT_EXPORT
ValueType Get(vtkm::Id index) const { return this->Functor(index); }
typedef vtkm::cont::internal::IteratorFromArrayPortal < ArrayPortalImplicit
< ValueType, FunctorType > >
IteratorType;
typedef vtkm::cont::internal::IteratorFromArrayPortal<
ArrayPortalImplicit<ValueType,FunctorType> > IteratorType;
VTKM_CONT_EXPORT
IteratorType GetIteratorBegin() const

@ -159,13 +159,11 @@ public:
VTKM_CONT_EXPORT void CopyInto(IteratorTypeControl dest) const
{
typedef typename StorageType::PortalConstType::IteratorType IteratorType;
IteratorType BeginIterator = this->Storage->GetPortalConst().GetIteratorBegin();
//It might be unsafe to take the begin iterator and just add the number of
//values, but I can't think of a better/safer way to do this
std::copy(BeginIterator, BeginIterator+this->Storage->GetNumberOfValues(), dest);
// std::copy(this->Portal.GetIteratorBegin(),
// this->Portal.GetIteratorEnd(),
// dest);
IteratorType beginIterator =
this->Storage->GetPortalConst().GetIteratorBegin();
std::copy(beginIterator,
beginIterator + this->Storage->GetNumberOfValues(), dest);
}
VTKM_CONT_EXPORT

@ -134,18 +134,6 @@ public:
this->RetrieveOutputDataImpl(storage);
}
/// Similar to RetrieveOutputData except that instead of writing to the
/// controlArray itself, it writes to the given control environment
/// iterator. This allows the user to retrieve data without necessarily
/// allocating an array in the ArrayContainerControl (assuming that control
/// and exeuction have seperate memory spaces).
///
// template<class IteratorTypeControl>
// VTKM_CONT_EXPORT
// void CopyInto(IteratorTypeControl dest) const {
// this->CopyIntoImpl(&dest);
// }
/// \brief Reduces the size of the array without changing its values.
///
/// This method allows you to resize the array without reallocating it. The
@ -278,12 +266,6 @@ protected:
this->Transfer.RetrieveOutputData(storage);
}
// template<class IteratorTypeControl>
// VTKM_CONT_EXPORT void CopyInto(IteratorTypeControl dest) const
// {
// this->Transfer.CopyInto(dest);
// }
VTKM_CONT_EXPORT
void ShrinkImpl(Id numberOfValues)
{

@ -100,10 +100,11 @@ public:
VTKM_CONT_EXPORT void CopyInto(IteratorTypeControl dest) const
{
typedef typename StorageType::PortalConstType::IteratorType IteratorType;
IteratorType BeginIterator = this->Storage->GetPortalConst().GetIteratorBegin();
//It might be unsafe to take the begin iterator and just add the number of
//values, but I can't think of a better/safer way to do this
std::copy(BeginIterator, BeginIterator+this->Storage->GetNumberOfValues(), dest);
IteratorType beginIterator =
this->Storage->GetPortalConst().GetIteratorBegin();
std::copy(beginIterator,
beginIterator + this->Storage->GetNumberOfValues(), dest);
}
/// Shrinks the storage.