Commit e0ae06ab authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Make ArrayPortalVirtual GetAs/SetAs methods inline where possible

There can be issues with methods that are used in different translation
units that are defined inline but not marked as inline. You could see
random failrues in downstream VTK-m with CUDA due to ODR violations.

See MR !1680, vtk/vtk-m!1680
parent 839f9527
Pipeline #140459 failed with stage
in 0 seconds
......@@ -165,7 +165,7 @@ public:
};
template <typename T>
VTKM_EXEC void GetAs(vtkm::Id index, T& value) const
VTKM_EXEC inline void GetAs(vtkm::Id index, T& value) const
{
using Query = detail::ArrayPortalVirtualValueTypeQuery<T>;
VTKM_STATIC_ASSERT(Query::Valid::value);
......@@ -175,7 +175,7 @@ public:
}
template <typename ComponentType>
VTKM_EXEC void GetAs(vtkm::Id index, vtkm::VecC<ComponentType> value) const
VTKM_EXEC inline void GetAs(vtkm::Id index, vtkm::VecC<ComponentType> value) const
{
using Query = detail::ArrayPortalVirtualValueTypeQuery<ComponentType>;
VTKM_STATIC_ASSERT(Query::Valid::value);
......@@ -186,7 +186,7 @@ public:
}
template <typename T>
VTKM_EXEC void SetAs(vtkm::Id index, const T& value) const
VTKM_EXEC inline void SetAs(vtkm::Id index, const T& value) const
{
using Query = detail::ArrayPortalVirtualValueTypeQuery<T>;
VTKM_STATIC_ASSERT(Query::Valid::value);
......@@ -197,7 +197,7 @@ public:
}
template <typename ComponentType>
VTKM_EXEC void SetAs(vtkm::Id index, vtkm::VecC<ComponentType> value) const
VTKM_EXEC inline void SetAs(vtkm::Id index, vtkm::VecC<ComponentType> value) const
{
using Query = detail::ArrayPortalVirtualValueTypeQuery<ComponentType>;
VTKM_STATIC_ASSERT(Query::Valid::value);
......@@ -208,7 +208,7 @@ public:
}
template <typename ComponentType>
VTKM_EXEC void SetAs(vtkm::Id index, vtkm::VecCConst<ComponentType> value) const
VTKM_EXEC inline void SetAs(vtkm::Id index, vtkm::VecCConst<ComponentType> value) const
{
using Query = detail::ArrayPortalVirtualValueTypeQuery<ComponentType>;
VTKM_STATIC_ASSERT(Query::Valid::value);
......@@ -248,125 +248,144 @@ protected:
private:
VTKM_EXEC
void DoGetAs(vtkm::Id index, char* buffer, vtkm::IdComponent numComponents) const noexcept
inline void DoGetAs(vtkm::Id index, char* buffer, vtkm::IdComponent numComponents) const noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::CHAR);
}
VTKM_EXEC
void DoGetAs(vtkm::Id index, vtkm::Int8* buffer, vtkm::IdComponent numComponents) const noexcept
inline void DoGetAs(vtkm::Id index, vtkm::Int8* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::INT8);
}
VTKM_EXEC
void DoGetAs(vtkm::Id index, vtkm::UInt8* buffer, vtkm::IdComponent numComponents) const noexcept
inline void DoGetAs(vtkm::Id index, vtkm::UInt8* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::UINT8);
}
VTKM_EXEC
void DoGetAs(vtkm::Id index, vtkm::Int16* buffer, vtkm::IdComponent numComponents) const noexcept
inline void DoGetAs(vtkm::Id index, vtkm::Int16* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::INT16);
}
VTKM_EXEC
void DoGetAs(vtkm::Id index, vtkm::UInt16* buffer, vtkm::IdComponent numComponents) const noexcept
inline void DoGetAs(vtkm::Id index, vtkm::UInt16* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::UINT16);
}
VTKM_EXEC
void DoGetAs(vtkm::Id index, vtkm::Int32* buffer, vtkm::IdComponent numComponents) const noexcept
inline void DoGetAs(vtkm::Id index, vtkm::Int32* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::INT32);
}
VTKM_EXEC
void DoGetAs(vtkm::Id index, vtkm::UInt32* buffer, vtkm::IdComponent numComponents) const noexcept
inline void DoGetAs(vtkm::Id index, vtkm::UInt32* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::UINT32);
}
VTKM_EXEC
void DoGetAs(vtkm::Id index, vtkm::Int64* buffer, vtkm::IdComponent numComponents) const noexcept
inline void DoGetAs(vtkm::Id index, vtkm::Int64* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::INT64);
}
VTKM_EXEC
void DoGetAs(vtkm::Id index, vtkm::UInt64* buffer, vtkm::IdComponent numComponents) const noexcept
inline void DoGetAs(vtkm::Id index, vtkm::UInt64* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::UINT64);
}
VTKM_EXEC
void DoGetAs(vtkm::Id index, vtkm::Float32* buffer, vtkm::IdComponent numComponents) const
inline void DoGetAs(vtkm::Id index, vtkm::Float32* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::FLOAT32);
}
VTKM_EXEC
void DoGetAs(vtkm::Id index, vtkm::Float64* buffer, vtkm::IdComponent numComponents) const
inline void DoGetAs(vtkm::Id index, vtkm::Float64* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->GetAsImpl(index, buffer, numComponents, BasicType::FLOAT64);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const char* buffer, vtkm::IdComponent numComponents) const noexcept
inline void DoSetAs(vtkm::Id index, const char* buffer, vtkm::IdComponent numComponents) const
noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::CHAR);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const vtkm::Int8* buffer, vtkm::IdComponent numComponents) const
noexcept
inline void DoSetAs(vtkm::Id index,
const vtkm::Int8* buffer,
vtkm::IdComponent numComponents) const noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::INT8);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const vtkm::UInt8* buffer, vtkm::IdComponent numComponents) const
noexcept
inline void DoSetAs(vtkm::Id index,
const vtkm::UInt8* buffer,
vtkm::IdComponent numComponents) const noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::UINT8);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const vtkm::Int16* buffer, vtkm::IdComponent numComponents) const
noexcept
inline void DoSetAs(vtkm::Id index,
const vtkm::Int16* buffer,
vtkm::IdComponent numComponents) const noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::INT16);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const vtkm::UInt16* buffer, vtkm::IdComponent numComponents) const
noexcept
inline void DoSetAs(vtkm::Id index,
const vtkm::UInt16* buffer,
vtkm::IdComponent numComponents) const noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::UINT16);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const vtkm::Int32* buffer, vtkm::IdComponent numComponents) const
noexcept
inline void DoSetAs(vtkm::Id index,
const vtkm::Int32* buffer,
vtkm::IdComponent numComponents) const noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::INT32);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const vtkm::UInt32* buffer, vtkm::IdComponent numComponents) const
noexcept
inline void DoSetAs(vtkm::Id index,
const vtkm::UInt32* buffer,
vtkm::IdComponent numComponents) const noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::UINT32);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const vtkm::Int64* buffer, vtkm::IdComponent numComponents) const
noexcept
inline void DoSetAs(vtkm::Id index,
const vtkm::Int64* buffer,
vtkm::IdComponent numComponents) const noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::INT64);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const vtkm::UInt64* buffer, vtkm::IdComponent numComponents) const
noexcept
inline void DoSetAs(vtkm::Id index,
const vtkm::UInt64* buffer,
vtkm::IdComponent numComponents) const noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::UINT64);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const vtkm::Float32* buffer, vtkm::IdComponent numComponents) const
noexcept
inline void DoSetAs(vtkm::Id index,
const vtkm::Float32* buffer,
vtkm::IdComponent numComponents) const noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::FLOAT32);
}
VTKM_EXEC
void DoSetAs(vtkm::Id index, const vtkm::Float64* buffer, vtkm::IdComponent numComponents) const
noexcept
inline void DoSetAs(vtkm::Id index,
const vtkm::Float64* buffer,
vtkm::IdComponent numComponents) const noexcept
{
this->SetAsImpl(index, buffer, numComponents, BasicType::FLOAT64);
}
......@@ -440,22 +459,22 @@ private:
VTKM_EXEC inline void Set(std::false_type, vtkm::Id, const T&) const noexcept {}
// clang-format on
VTKM_EXEC void GetAsImplIsValid(std::false_type,
vtkm::Id,
void*,
vtkm::IdComponent,
internal::PortalVirtualBase::BasicType) const noexcept
VTKM_EXEC inline void GetAsImplIsValid(std::false_type,
vtkm::Id,
void*,
vtkm::IdComponent,
internal::PortalVirtualBase::BasicType) const noexcept
{
// Cannot get-as this type. The type is either something weird or the portal is just a
// placeholder because it is invalid.
}
VTKM_EXEC
void GetAsImplIsValid(std::true_type,
vtkm::Id index,
void* buffer,
vtkm::IdComponent numComponents,
internal::PortalVirtualBase::BasicType type) const noexcept
void inline GetAsImplIsValid(std::true_type,
vtkm::Id index,
void* buffer,
vtkm::IdComponent numComponents,
internal::PortalVirtualBase::BasicType type) const noexcept
{
switch (type)
{
......@@ -496,9 +515,9 @@ private:
}
template <typename CastToType>
VTKM_EXEC void GetAsImpl(vtkm::Id index,
CastToType* destBuffer,
vtkm::IdComponent numComponents) const noexcept
VTKM_EXEC inline void GetAsImpl(vtkm::Id index,
CastToType* destBuffer,
vtkm::IdComponent numComponents) const noexcept
{
using Query = internal::detail::ArrayPortalVirtualValueTypeQuery<T>;
......@@ -517,22 +536,22 @@ private:
}
}
VTKM_EXEC void SetAsImplIsValid(std::false_type,
vtkm::Id,
const void*,
vtkm::IdComponent,
internal::PortalVirtualBase::BasicType) const noexcept
VTKM_EXEC inline void SetAsImplIsValid(std::false_type,
vtkm::Id,
const void*,
vtkm::IdComponent,
internal::PortalVirtualBase::BasicType) const noexcept
{
// Cannot get-as this type. The type is either something weird or the portal is just a
// placeholder because it is invalid.
}
VTKM_EXEC
void SetAsImplIsValid(std::true_type,
vtkm::Id index,
const void* buffer,
vtkm::IdComponent numComponents,
internal::PortalVirtualBase::BasicType type) const noexcept
inline void SetAsImplIsValid(std::true_type,
vtkm::Id index,
const void* buffer,
vtkm::IdComponent numComponents,
internal::PortalVirtualBase::BasicType type) const noexcept
{
switch (type)
{
......@@ -573,9 +592,9 @@ private:
}
template <typename SourceType>
VTKM_EXEC void SetAsImpl(vtkm::Id index,
const SourceType* srcBuffer,
vtkm::IdComponent numComponents) const noexcept
VTKM_EXEC inline void SetAsImpl(vtkm::Id index,
const SourceType* srcBuffer,
vtkm::IdComponent numComponents) const noexcept
{
using Query = internal::detail::ArrayPortalVirtualValueTypeQuery<T>;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment