Skip to content

Commit

Permalink
Initial pass at guarding all Umpire code
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbeckingsale committed Feb 20, 2020
1 parent a31dcfe commit 85c9443
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 15 deletions.
14 changes: 11 additions & 3 deletions source/SAMRAI/geom/CartesianCellConservativeLinearRefine.C
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,15 @@ void CartesianCellConservativeLinearRefine<T>::refine(
SAMRAI::hier::Box diff_box = coarse_box;
diff_box.growUpper(SAMRAI::hier::IntVector::getOne(dim));

#ifdef HAVE_UMPIRE
tbox::AllocatorDatabase *alloc_db = tbox::AllocatorDatabase::getDatabase();

// change to alloc_db->getDevicePool or other generic pool allocator for gpu policies
//pdat::ArrayData<T> slope(cgbox, dim.getValue(), alloc_db->getTagAllocator());
pdat::ArrayData<T> slope(cgbox, dim.getValue(), alloc_db->getDevicePool());
#else
pdat::ArrayData<T> slope(cgbox, dim.getValue());
#endif


for (int d = 0; d < fdata->getDepth(); ++d) {
Expand Down Expand Up @@ -402,11 +406,15 @@ void CartesianCellConservativeLinearRefine<dcomplex>::refine(
SAMRAI::hier::Box diff_box = coarse_box;
diff_box.growUpper(SAMRAI::hier::IntVector::getOne(dim));

#ifdef HAVE_UMPIRE
tbox::AllocatorDatabase *alloc_db = tbox::AllocatorDatabase::getDatabase();

// change to alloc_db->getDevicePool or other generic pool allocator for gpu policies
//pdat::ArrayData<T> slope(cgbox, dim.getValue(), alloc_db->getTagAllocator());
pdat::ArrayData<dcomplex> slope(cgbox, dim.getValue(), alloc_db->getDevicePool());
#else
pdat::ArrayData<dcomplex> slope(cgbox, dim.getValue());
#endif


for (int d = 0; d < fdata->getDepth(); ++d) {
Expand Down Expand Up @@ -770,9 +778,9 @@ void CartesianCellConservativeLinearRefine<dcomplex>::refine(

#else // Fortran dim 3

std::vector<T> diff0_f(cgbox.numberCells(0) + 1);
std::vector<T> diff1_f(cgbox.numberCells(1) + 1);
std::vector<T> diff2_f(cgbox.numberCells(2) + 1);
std::vector<dcomplex> diff0_f(cgbox.numberCells(0) + 1);
std::vector<dcomplex> diff1_f(cgbox.numberCells(1) + 1);
std::vector<dcomplex> diff2_f(cgbox.numberCells(2) + 1);
Call3dFortranCellLinearRefine(
ifirstc(0),
ifirstc(1), ifirstc(2),
Expand Down
5 changes: 0 additions & 5 deletions source/SAMRAI/hier/VariableDatabase.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#include "SAMRAI/tbox/MathUtilities.h"
#include "SAMRAI/tbox/Utilities.h"

#include "SAMRAI/tbox/AllocatorDatabase.h"


namespace SAMRAI {
namespace hier {

Expand Down Expand Up @@ -77,8 +74,6 @@ VariableDatabase::VariableDatabase():
d_num_registered_patch_data_ids = 0;

d_internal_SAMRAI_context = getContext("Internal_SAMRAI_Variable");

auto allocator_db = tbox::AllocatorDatabase::getDatabase();
}

VariableDatabase::~VariableDatabase()
Expand Down
8 changes: 3 additions & 5 deletions source/SAMRAI/pdat/ArrayData.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "SAMRAI/pdat/CopyOperation.h"
#include "SAMRAI/pdat/SumOperation.h"

#if defined(HAVE_UMPIRE)
#ifdef HAVE_UMPIRE
#include "umpire/ResourceManager.hpp"
#endif

Expand Down Expand Up @@ -99,6 +99,7 @@ ArrayData<TYPE>::ArrayData(
#endif
}

#ifdef HAVE_UMPIRE
template<class TYPE>
ArrayData<TYPE>::ArrayData(
const hier::Box& box,
Expand All @@ -107,19 +108,16 @@ ArrayData<TYPE>::ArrayData(
d_depth(depth),
d_offset(box.size()),
d_box(box)
#if defined(HAVE_UMPIRE)
, d_allocator(allocator)
, d_array(d_allocator.allocate(d_depth * d_offset * sizeof(TYPE)))
#else
, d_array(d_depth * d_offset)
#endif
{
TBOX_ASSERT(depth > 0);

#ifdef DEBUG_INITIALIZE_UNDEFINED
undefineData();
#endif
}
#endif

template<class TYPE>
ArrayData<TYPE>::~ArrayData()
Expand Down
2 changes: 1 addition & 1 deletion source/SAMRAI/pdat/ArrayData.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ArrayData
const hier::Box& box,
unsigned int depth);

#if defined(HAVE_UMPIRE)
#ifdef HAVE_UMPIRE
/*!
* Construct an array data object using an Umpire allocator.
*
Expand Down
2 changes: 2 additions & 0 deletions source/SAMRAI/pdat/CellData.C
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ CellData<TYPE>::CellData(
d_data.reset(new ArrayData<TYPE>(getGhostBox(), depth));
}

#ifdef HAVE_UMPIRE
template<class TYPE>
CellData<TYPE>::CellData(
const hier::Box& box,
Expand All @@ -105,6 +106,7 @@ CellData<TYPE>::CellData(

d_data.reset(new ArrayData<TYPE>(getGhostBox(), depth, allocator));
}
#endif

template<class TYPE>
CellData<TYPE>::~CellData()
Expand Down
2 changes: 2 additions & 0 deletions source/SAMRAI/pdat/EdgeData.C
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ EdgeData<TYPE>::EdgeData(
}
}

#if defined(HAVE_UMPIRE)
template<class TYPE>
EdgeData<TYPE>::EdgeData(
const hier::Box& box,
Expand All @@ -74,6 +75,7 @@ EdgeData<TYPE>::EdgeData(
d_data[d].reset(new ArrayData<TYPE>(edge_box, depth, allocator));
}
}
#endif

template<class TYPE>
EdgeData<TYPE>::~EdgeData()
Expand Down
2 changes: 2 additions & 0 deletions source/SAMRAI/pdat/FaceData.C
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ FaceData<TYPE>::FaceData(
}
}

#if defined(HAVE_UMPIRE)
template <class TYPE>
FaceData<TYPE>::FaceData(const hier::Box& box,
int depth,
Expand All @@ -70,6 +71,7 @@ FaceData<TYPE>::FaceData(const hier::Box& box,
d_data[d].reset(new ArrayData<TYPE>(face, depth, allocator));
}
}
#endif

template<class TYPE>
FaceData<TYPE>::~FaceData()
Expand Down
2 changes: 1 addition & 1 deletion source/SAMRAI/pdat/FaceData.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class FaceData:public hier::PatchData
int depth,
const hier::IntVector& ghosts);

#if defined(HAVE_UMPIRE)
#ifdef HAVE_UMPIRE
FaceData(const hier::Box& box, int depth, const hier::IntVector& ghosts,umpire::Allocator allocator);
#endif

Expand Down
3 changes: 3 additions & 0 deletions source/SAMRAI/pdat/OuterfaceData.C
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ OuterfaceData<TYPE>::OuterfaceData(
}
}

#ifdef HAVE_UMPIRE
template<class TYPE>
OuterfaceData<TYPE>::OuterfaceData(
const hier::Box& box,
Expand All @@ -81,6 +82,8 @@ OuterfaceData<TYPE>::OuterfaceData(
d_data[d][1].reset(new ArrayData<TYPE>(outerfacebox, depth,allocator));
}
}
#endif

template<class TYPE>
OuterfaceData<TYPE>::~OuterfaceData()
{
Expand Down
2 changes: 2 additions & 0 deletions source/SAMRAI/pdat/SideData.C
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ SideData<TYPE>::SideData(
}
}

#ifdef HAVE_UMPIRE
template<class TYPE>
SideData<TYPE>::SideData(
const hier::Box& box,
Expand Down Expand Up @@ -109,6 +110,7 @@ SideData<TYPE>::SideData(
d_data[d].reset(new ArrayData<TYPE>(side, depth, allocator));
}
}
#endif

template<class TYPE>
SideData<TYPE>::SideData(
Expand Down
4 changes: 4 additions & 0 deletions source/SAMRAI/tbox/AllocatorDatabase.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "SAMRAI/tbox/AllocatorDatabase.h"

#ifdef HAVE_UMPIRE

#include "umpire/strategy/DynamicPool.hpp"
#include "umpire/ResourceManager.hpp"

Expand Down Expand Up @@ -136,3 +138,5 @@ AllocatorDatabase::getTagAllocator()

}
}

#endif
3 changes: 3 additions & 0 deletions source/SAMRAI/tbox/AllocatorDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include "SAMRAI/SAMRAI_config.h"

#ifdef HAVE_UMPIRE

#include "SAMRAI/tbox/StartupShutdownManager.h"

#include "umpire/Allocator.hpp"
Expand Down Expand Up @@ -56,3 +58,4 @@ class AllocatorDatabase
}

#endif
#endif
8 changes: 8 additions & 0 deletions source/SAMRAI/tbox/MessageStream.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ MessageStream::MessageStream(
const void* data_to_read,
bool deep_copy):
d_mode(mode),
#ifdef HAVE_UMPIRE
d_write_buffer(AllocatorDatabase::getDatabase()->getStreamAllocator()),
#else
d_write_buffer(),
#endif
d_read_buffer(0),
d_buffer_size(0),
d_buffer_index(0),
Expand Down Expand Up @@ -57,7 +61,11 @@ MessageStream::MessageStream(

MessageStream::MessageStream():
d_mode(Write),
#ifdef HAVE_UMPIRE
d_write_buffer(AllocatorDatabase::getDatabase()->getStreamAllocator()),
#else
d_write_buffer(),
#endif
d_read_buffer(0),
d_buffer_size(0),
d_buffer_index(0),
Expand Down
6 changes: 6 additions & 0 deletions source/SAMRAI/tbox/MessageStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
#include "SAMRAI/tbox/Complex.h"
#include "SAMRAI/tbox/Utilities.h"

#ifdef HAVE_UMPIRE
#include "umpire/TypedAllocator.hpp"
#endif

#include <cstring>
#include <iostream>
Expand Down Expand Up @@ -416,7 +418,11 @@ class MessageStream
/*!
* The buffer for the streamed data to be written.
*/
#ifdef HAVE_UMPIRE
std::vector<char, umpire::TypedAllocator<char> > d_write_buffer;
#else
std::vector<char> d_write_buffer;
#endif

/*!
* @brief Pointer to the externally supplied memory to read from in
Expand Down

0 comments on commit 85c9443

Please sign in to comment.