Skip to content

Commit

Permalink
Merge pull request #1423 from LLNL/feature/yang39/warnings-cleanup
Browse files Browse the repository at this point in the history
Cleanup a bunch of GPU warnings
  • Loading branch information
publixsubfan authored Sep 25, 2024
2 parents e80b31a + dcd22e2 commit 24751dd
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 77 deletions.
2 changes: 1 addition & 1 deletion src/axom/core/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ class Array : public ArrayBase<T, DIM, Array<T, DIM, SPACE>>
/*!
* \brief Get the ID for the umpire allocator
*/
int getAllocatorID() const { return m_allocator_id; }
AXOM_HOST_DEVICE int getAllocatorID() const { return m_allocator_id; }

/*!
* \brief Sets the preferred space where operations on this array should be
Expand Down
14 changes: 9 additions & 5 deletions src/axom/core/ArrayBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class ArrayBase
* memory spaces
*/
template <typename OtherArrayType>
ArrayBase(
AXOM_HOST_DEVICE ArrayBase(
const ArrayBase<typename std::remove_const<T>::type, DIM, OtherArrayType>& other)
: m_shape(other.shape())
, m_mapping(other.mapping())
Expand All @@ -230,7 +230,7 @@ class ArrayBase

/// \overload
template <typename OtherArrayType>
ArrayBase(
AXOM_HOST_DEVICE ArrayBase(
const ArrayBase<const typename std::remove_const<T>::type, DIM, OtherArrayType>& other)
: m_shape(other.shape())
, m_mapping(other.mapping())
Expand Down Expand Up @@ -618,12 +618,13 @@ class ArrayBase<T, 1, ArrayType>

// Empty implementation because no member data
template <typename OtherArrayType>
ArrayBase(const ArrayBase<typename std::remove_const<T>::type, 1, OtherArrayType>&)
AXOM_HOST_DEVICE ArrayBase(
const ArrayBase<typename std::remove_const<T>::type, 1, OtherArrayType>&)
{ }

// Empty implementation because no member data
template <typename OtherArrayType>
ArrayBase(
AXOM_HOST_DEVICE ArrayBase(
const ArrayBase<const typename std::remove_const<T>::type, 1, OtherArrayType>&)
{ }

Expand Down Expand Up @@ -1812,7 +1813,10 @@ class ArraySubslice
/*!
* \brief Get the ID for the umpire allocator
*/
int getAllocatorID() const { return m_array->getAllocatorID(); }
AXOM_HOST_DEVICE int getAllocatorID() const
{
return m_array->getAllocatorID();
}

protected:
friend BaseClass;
Expand Down
15 changes: 8 additions & 7 deletions src/axom/core/ArrayView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ class ArrayView : public ArrayBase<T, DIM, ArrayView<T, DIM, SPACE>>
* space.
*/
template <typename OtherArrayType>
ArrayView(ArrayBase<T, DIM, OtherArrayType>& other);
AXOM_HOST_DEVICE ArrayView(ArrayBase<T, DIM, OtherArrayType>& other);
/// \overload
template <typename OtherArrayType>
ArrayView(
AXOM_HOST_DEVICE ArrayView(
const ArrayBase<typename std::remove_const<T>::type, DIM, OtherArrayType>& other);

/*!
Expand Down Expand Up @@ -156,7 +156,7 @@ class ArrayView : public ArrayBase<T, DIM, ArrayView<T, DIM, SPACE>>
/*!
* \brief Get the ID for the umpire allocator
*/
int getAllocatorID() const { return m_allocator_id; }
AXOM_HOST_DEVICE int getAllocatorID() const { return m_allocator_id; }

/*!
* \brief Returns an ArrayView that is a subspan of the original range of
Expand Down Expand Up @@ -341,13 +341,14 @@ AXOM_HOST_DEVICE ArrayView<T, DIM, SPACE>::ArrayView(
//------------------------------------------------------------------------------
template <typename T, int DIM, MemorySpace SPACE>
template <typename OtherArrayType>
ArrayView<T, DIM, SPACE>::ArrayView(ArrayBase<T, DIM, OtherArrayType>& other)
AXOM_HOST_DEVICE ArrayView<T, DIM, SPACE>::ArrayView(
ArrayBase<T, DIM, OtherArrayType>& other)
: ArrayBase<T, DIM, ArrayView<T, DIM, SPACE>>(other)
, m_data(static_cast<OtherArrayType&>(other).data())
, m_num_elements(static_cast<OtherArrayType&>(other).size())
, m_allocator_id(static_cast<OtherArrayType&>(other).getAllocatorID())
{
#ifdef AXOM_DEBUG
#if !defined(AXOM_DEVICE_CODE) && defined(AXOM_DEBUG)
// If it's not dynamic, the allocator ID from the argument array has to match the template param.
// If that's not the case then things have gone horribly wrong somewhere.
if(SPACE != MemorySpace::Dynamic &&
Expand All @@ -363,7 +364,7 @@ ArrayView<T, DIM, SPACE>::ArrayView(ArrayBase<T, DIM, OtherArrayType>& other)
//------------------------------------------------------------------------------
template <typename T, int DIM, MemorySpace SPACE>
template <typename OtherArrayType>
ArrayView<T, DIM, SPACE>::ArrayView(
AXOM_HOST_DEVICE ArrayView<T, DIM, SPACE>::ArrayView(
const ArrayBase<typename std::remove_const<T>::type, DIM, OtherArrayType>& other)
: ArrayBase<T, DIM, ArrayView<T, DIM, SPACE>>(other)
, m_data(static_cast<const OtherArrayType&>(other).data())
Expand All @@ -373,7 +374,7 @@ ArrayView<T, DIM, SPACE>::ArrayView(
static_assert(
std::is_const<T>::value || detail::ArrayTraits<OtherArrayType>::is_view,
"Cannot create an ArrayView of non-const type from a const Array");
#ifdef AXOM_DEBUG
#if !defined(AXOM_DEVICE_CODE) && defined(AXOM_DEBUG)
// If it's not dynamic, the allocator ID from the argument array has to match the template param.
// If that's not the case then things have gone horribly wrong somewhere.
if(SPACE != MemorySpace::Dynamic &&
Expand Down
4 changes: 4 additions & 0 deletions src/axom/core/IteratorBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ class IteratorBase
}

/// Addition-assignment operator
AXOM_SUPPRESS_HD_WARN
AXOM_HOST_DEVICE
IterType& operator+=(PosType n)
{
adv(getIter(), n);
Expand All @@ -169,6 +171,8 @@ class IteratorBase
}

/// Addition operator with iterator on left and position on right
AXOM_SUPPRESS_HD_WARN
AXOM_HOST_DEVICE
friend IterType operator+(const IterType& it, PosType n)
{
IterType ret(it);
Expand Down
1 change: 0 additions & 1 deletion src/axom/core/detail/FlatTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ struct SequentialLookupPolicy : ProbePolicy
{
// Stop probing if the "overflow" bit is not set.
keep_going = false;
curr_group = NO_MATCH;
}

if(!keep_going)
Expand Down
26 changes: 11 additions & 15 deletions src/axom/slam/BivariateMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ template <typename T,
typename IndPol =
policies::STLVectorIndirection<typename BSet::PositionType, T>,
typename StrPol = policies::StrideOne<typename BSet::PositionType>,
typename IfacePol = policies::VirtualInterface>
typename IfacePol = policies::ConcreteInterface>
class BivariateMap
: public policies::MapInterface<IfacePol, typename BSet::PositionType>,
public StrPol
Expand Down Expand Up @@ -481,10 +481,8 @@ class BivariateMap

public:
/** BivariateMap iterator functions */
AXOM_SUPPRESS_HD_WARN
AXOM_HOST_DEVICE iterator begin() { return iterator(this, 0); }

AXOM_SUPPRESS_HD_WARN
AXOM_HOST_DEVICE iterator end()
{
return iterator(this, totalSize() * numComp());
Expand All @@ -500,25 +498,21 @@ class BivariateMap
return const_iterator(this, totalSize() * numComp());
}

AXOM_SUPPRESS_HD_WARN
AXOM_HOST_DEVICE range_iterator set_begin()
{
return range_iterator(this, 0);
}

AXOM_SUPPRESS_HD_WARN
AXOM_HOST_DEVICE range_iterator set_end()
{
return range_iterator(this, totalSize());
}

AXOM_SUPPRESS_HD_WARN
AXOM_HOST_DEVICE const_range_iterator set_begin() const
{
return const_range_iterator(this, 0);
}

AXOM_SUPPRESS_HD_WARN
AXOM_HOST_DEVICE const_range_iterator set_end() const
{
return const_range_iterator(this, totalSize());
Expand Down Expand Up @@ -562,9 +556,9 @@ class BivariateMap
public:
AXOM_HOST_DEVICE const BivariateSetType* set() const { return m_bset.get(); }

const MapType* getMap() const { return &m_map; }
AXOM_HOST_DEVICE const MapType* getMap() const { return &m_map; }

MapType* getMap() { return &m_map; }
AXOM_HOST_DEVICE MapType* getMap() { return &m_map; }

bool isValid(bool verboseOutput = false) const
{
Expand All @@ -576,11 +570,10 @@ class BivariateMap
///

/** \brief Returns the BivariateSet size. */
AXOM_SUPPRESS_HD_WARN
AXOM_HOST_DEVICE SetPosition size() const { return set()->size(); }

/** \brief Returns the BivariateSet size. */
SetPosition totalSize() const { return set()->size(); }
AXOM_HOST_DEVICE SetPosition totalSize() const { return set()->size(); }

SetPosition firstSetSize() const { return set()->firstSetSize(); }

Expand All @@ -594,7 +587,7 @@ class BivariateMap
SetPosition size(SetPosition s) const { return set()->size(s); }

/** \brief Return the number of components of the map */
SetPosition numComp() const { return StrPol::stride(); }
AXOM_HOST_DEVICE SetPosition numComp() const { return StrPol::stride(); }

/// @}

Expand Down Expand Up @@ -682,7 +675,7 @@ class BivariateMap<T, BSet, IndPol, StrPol, IfacePol>::FlatIterator
/**
* \brief Construct a new BivariateMap Iterator given an ElementFlatIndex
*/
FlatIterator(BivariateMapPtr sMap, PositionType pos)
AXOM_HOST_DEVICE FlatIterator(BivariateMapPtr sMap, PositionType pos)
: IterBase(pos)
, m_map(sMap)
, m_bsetIterator(m_map->set(), pos / m_map->numComp())
Expand Down Expand Up @@ -771,7 +764,7 @@ class BivariateMap<T, BSet, IndPol, StrPol, IfacePol>::RangeIterator
/*!
* \brief Construct a new BivariateMap Iterator given an ElementFlatIndex
*/
RangeIterator(BivariateMapPtr sMap, PositionType pos)
AXOM_HOST_DEVICE RangeIterator(BivariateMapPtr sMap, PositionType pos)
: IterBase(pos)
, m_map(sMap)
, m_mapIterator(m_map->getMap()->set_begin() + pos)
Expand Down Expand Up @@ -828,7 +821,10 @@ class BivariateMap<T, BSet, IndPol, StrPol, IfacePol>::RangeIterator
/**
* \brief Return the current iterator's flat bivariate index.
*/
PositionType flatIndex() const { return m_mapIterator.flatIndex(); }
AXOM_HOST_DEVICE PositionType flatIndex() const
{
return m_mapIterator.flatIndex();
}

/** \brief Returns the number of components per element in the map. */
PositionType numComp() const { return m_map->numComp(); }
Expand Down
3 changes: 2 additions & 1 deletion src/axom/slam/BivariateSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ struct BivariateSetIterator
using pointer = value_type*;
using iterator_category = std::forward_iterator_tag;

BivariateSetIterator(const BivariateSetType* bset, IndexType flatPos = 0)
AXOM_HOST_DEVICE BivariateSetIterator(const BivariateSetType* bset,
IndexType flatPos = 0)
: BaseType(flatPos)
, m_bset(bset)
{ }
Expand Down
Loading

0 comments on commit 24751dd

Please sign in to comment.