Skip to content

Commit f5bb713

Browse files
committed
Fix nightly GPU failures after kokkos 4.5.0
- remove create_copy() and create temp workspace - add Helmholtz back in
1 parent 238f75f commit f5bb713

8 files changed

+27
-41
lines changed

src/PHAL_Utilities_Def.hpp

-31
Original file line numberDiff line numberDiff line change
@@ -260,35 +260,4 @@ void scale (ArrayT& a, const T& val) {
260260
loop(sl, a);
261261
}
262262

263-
template< class T , class ... P >
264-
inline
265-
typename std::enable_if<
266-
!Kokkos::is_dynrankview_fad<Kokkos::DynRankView<T,P...>>::value,
267-
typename Kokkos::DynRankView<T,P...>::non_const_type >::type
268-
create_copy( const std::string& name,
269-
const Kokkos::DynRankView<T,P...> & src )
270-
{
271-
using dst_type = typename Kokkos::DynRankView<T,P...>::non_const_type;
272-
auto layout = Kokkos::Impl::reconstructLayout(src.layout(), src.rank());
273-
return dst_type( name , layout );
274-
}
275-
276-
template< class T , class ... P >
277-
inline
278-
typename std::enable_if<
279-
Kokkos::is_dynrankview_fad<Kokkos::DynRankView<T,P...>>::value,
280-
typename Kokkos::DynRankView<T,P...>::non_const_type >::type
281-
create_copy( const std::string& /* name */,
282-
const Kokkos::DynRankView<T,P...> & src )
283-
{
284-
using Dst = typename Kokkos::DynRankView<T,P...>::non_const_type;
285-
auto sm = src.impl_map();
286-
auto sl = sm.layout();
287-
auto fad_rank = src.rank();
288-
sl.dimension[fad_rank] = sm.dimension_scalar();
289-
auto real_rank = fad_rank + 1;
290-
auto ml = Kokkos::Impl::reconstructLayout(sl, real_rank);
291-
return Dst ( src.label(), ml );
292-
}
293-
294263
} // namespace PHAL

src/corePDEs/evaluators/PHAL_HeatEqResid.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class HeatEqResid : public PHX::EvaluatorWithBaseImpl<Traits>,
6060
bool haverhoCp;
6161
unsigned int numQPs, numDims, numNodes, worksetSize;
6262
Kokkos::DynRankView<ScalarT, PHX::Device> flux;
63+
Kokkos::DynRankView<ScalarT, PHX::Device> neg_source;
6364
Kokkos::DynRankView<ScalarT, PHX::Device> aterm;
6465
Kokkos::DynRankView<ScalarT, PHX::Device> convection;
6566
};

src/corePDEs/evaluators/PHAL_HeatEqResid_Def.hpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ postRegistrationSetup(typename Traits::SetupData /* d */,
107107
this->utils.setFieldData(TResidual,fm);
108108

109109
// Allocate workspace
110-
flux = Kokkos::createDynRankView(Temperature.get_view(), "XXX", worksetSize, numQPs, numDims);
111-
if (haveAbsorption) aterm = Kokkos::createDynRankView(Temperature.get_view(), "XXX", worksetSize, numQPs);
112-
if (haveConvection) convection = Kokkos::createDynRankView(Temperature.get_view(), "XXX", worksetSize, numQPs);
110+
flux = Kokkos::createDynRankView(Temperature.get_view(), "flux", worksetSize, numQPs, numDims);
111+
if (haveSource) neg_source = Kokkos::createDynRankView(Temperature.get_view(), "neg_source", worksetSize, numQPs);
112+
if (haveAbsorption) aterm = Kokkos::createDynRankView(Temperature.get_view(), "aterm", worksetSize, numQPs);
113+
if (haveConvection) convection = Kokkos::createDynRankView(Temperature.get_view(), "convection", worksetSize, numQPs);
113114
}
114115

115116
//**********************************************************************
@@ -124,8 +125,6 @@ evaluateFields(typename Traits::EvalData workset)
124125
FST::integrate(TResidual.get_view(), flux, wGradBF.get_view(), false); // "false" overwrites
125126

126127
if (haveSource) {
127-
auto neg_source = PHAL::create_copy("neg_source", Source.get_view());
128-
129128
for (size_t i =0; i< Source.extent(0); i++)
130129
for (size_t j =0; j< Source.extent(1); j++)
131130
neg_source(i,j) = Source(i,j) * -1.0;

src/demoPDEs/evaluators/PHAL_HelmholtzResid.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ class HelmholtzResid : public PHX::EvaluatorWithBaseImpl<Traits>,
5454

5555
bool haveSource;
5656

57+
unsigned int worksetSize, numQPs;
5758
ScalarT ksqr;
59+
Kokkos::DynRankView<ScalarT, PHX::Device> U_ksqr;
60+
Kokkos::DynRankView<ScalarT, PHX::Device> V_ksqr;
5861

5962
// Output:
6063
PHX::MDField<ScalarT,Cell,Node> UResidual;

src/demoPDEs/evaluators/PHAL_HelmholtzResid_Def.hpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ HelmholtzResid(const Teuchos::ParameterList& p) :
6161
p.get< Teuchos::RCP<ParamLib> >("Parameter Library");
6262
this->registerSacadoParameter("Ksqr", paramLib);
6363

64+
Teuchos::RCP<PHX::DataLayout> qp_scalar_dl =
65+
p.get< Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout");
66+
std::vector<PHX::DataLayout::size_type> dims;
67+
qp_scalar_dl->dimensions(dims);
68+
worksetSize = dims[0];
69+
numQPs = dims[1];
6470
}
6571

6672
//**********************************************************************
@@ -81,6 +87,10 @@ postRegistrationSetup(typename Traits::SetupData /* d */,
8187
}
8288
this->utils.setFieldData(UResidual,fm);
8389
this->utils.setFieldData(VResidual,fm);
90+
91+
// Allocate workspace
92+
U_ksqr = Kokkos::createDynRankView(U.get_view(), "U_ksqr", worksetSize, numQPs);
93+
V_ksqr = Kokkos::createDynRankView(U.get_view(), "V_ksqr", worksetSize, numQPs);
8494
}
8595

8696
//**********************************************************************
@@ -102,9 +112,6 @@ evaluateFields(typename Traits::EvalData /* workset */)
102112
FST::integrate(VResidual.get_view(), VSource.get_view(), wBF.get_view(), true);
103113
}
104114

105-
auto U_ksqr = create_copy("U_ksqr", U.get_view());
106-
auto V_ksqr = create_copy("V_ksqr", V.get_view());
107-
108115
RST::scale(U_ksqr, U.get_view(), ksqr);
109116
RST::scale(V_ksqr, V.get_view(), ksqr);
110117

src/demoPDEs/evaluators/PHAL_PoissonResid.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class PoissonResid : public PHX::EvaluatorWithBaseImpl<Traits>,
4444
PHX::MDField<const ScalarT> Source;
4545

4646
bool haveSource;
47+
unsigned int worksetSize, numQPs;
48+
Kokkos::DynRankView<ScalarT, PHX::Device> neg_source;
4749

4850
// Output:
4951
PHX::MDField<ScalarT> PhiResidual;

src/demoPDEs/evaluators/PHAL_PoissonResid_Def.hpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ PoissonResid(const Teuchos::ParameterList& p,
2323
Source (p.get<std::string> ("Source Name"), dl->qp_scalar ),
2424
haveSource (p.get<bool>("Have Source")),
2525
PhiResidual (p.get<std::string> ("Residual Name"), dl->node_scalar ),
26-
PhiFlux (p.get<std::string> ("Flux QP Variable Name"), dl->qp_gradient)
26+
PhiFlux (p.get<std::string> ("Flux QP Variable Name"), dl->qp_gradient),
27+
worksetSize (dl->qp_scalar->extent(0)),
28+
numQPs (dl->qp_scalar->extent(1))
2729
{
2830
this->addDependentField(wBF);
2931
//this->addDependentField(Potential);
@@ -53,6 +55,9 @@ postRegistrationSetup(typename Traits::SetupData /* d */,
5355
if (haveSource) this->utils.setFieldData(Source,fm);
5456

5557
this->utils.setFieldData(PhiResidual,fm);
58+
59+
// Allocate workspace
60+
if (haveSource) neg_source = Kokkos::createDynRankView(Source.get_view(), "neg_source", worksetSize, numQPs);
5661
}
5762

5863
//**********************************************************************
@@ -67,7 +72,6 @@ evaluateFields(typename Traits::EvalData /* workset */)
6772

6873
FST::integrate(PhiResidual.get_view(), PhiFlux.get_view(), wGradBF.get_view(), false); // "false" overwrites
6974

70-
auto neg_source = PHAL::create_copy("neg_Source", Source.get_view());
7175
if (haveSource) {
7276
for (unsigned int i=0; i<Source.extent(0); i++)
7377
for (unsigned int j=0; j<Source.extent(1); j++)

tests/demoPDEs/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
## in the file "license.txt" in the top-level Albany directory //
55
##*****************************************************************//
66

7+
add_subdirectory(Helmholtz2D)
78
add_subdirectory(AdvDiff)
89
add_subdirectory(ReactDiffSystem)
910
add_subdirectory(ODE)

0 commit comments

Comments
 (0)