48 #include "Sacado_mpl_range_c.hpp"
49 #include "Sacado_mpl_for_each.hpp"
50 #include "Sacado_mpl_integral_c.hpp"
53 #include <Kokkos_UnorderedMap.hpp>
54 #include <Kokkos_StaticCrsGraph.hpp>
55 #include <impl/Kokkos_Timer.hpp>
99 template <
typename Scalar,
typename Device,
103 const int use_print ,
104 const int use_trials ,
105 const int use_nodes[] ,
107 Kokkos::View< Scalar* , Kokkos::LayoutLeft, Device >& nodal_residual)
111 using Teuchos::rcpFromRef;
112 using Teuchos::arrayView;
119 typedef typename LocalMatrixType::StaticCrsGraphType LocalGraphType ;
127 ElementComputationType ;
132 typedef typename ElementComputationType::vector_type VectorType ;
135 typename FixtureType::comm_list_type ,
136 typename FixtureType::send_nodeid_type ,
137 VectorType > ImportType ;
141 const int print_flag = use_print && Kokkos::Impl::is_same< Kokkos::HostSpace , typename Device::memory_space >::value ;
143 const int comm_rank = comm->getRank();
144 const int comm_size = comm->getSize();
148 const double bubble_x = 1.0 ;
149 const double bubble_y = 1.0 ;
150 const double bubble_z = 1.0 ;
153 comm_size , comm_rank ,
154 use_nodes[0] , use_nodes[1] , use_nodes[2] ,
155 bubble_x , bubble_y , bubble_z );
159 const ImportType comm_nodal_import(
161 fixture.recv_node() ,
162 fixture.send_node() ,
163 fixture.send_nodeid() ,
164 fixture.node_count_owned() ,
165 fixture.node_count() - fixture.node_count_owned() );
172 CoeffFunctionType diffusion_coefficient( 1.0, 0.1, 1.0, 5 );
178 std::cout <<
"ElemNode {" << std::endl ;
179 for (
unsigned ielem = 0 ; ielem < fixture.elem_count() ; ++ielem ) {
180 std::cout <<
" elem[" << ielem <<
"]{" ;
181 for (
unsigned inode = 0 ; inode < FixtureType::ElemNode ; ++inode ) {
182 std::cout <<
" " << fixture.elem_node(ielem,inode);
184 std::cout <<
" }" << std::endl ;
186 std::cout <<
"}" << std::endl ;
191 Kokkos::Impl::Timer wall_clock ;
195 for (
int itrial = 0 ; itrial < use_trials ; ++itrial ) {
207 typename NodeNodeGraphType::Times graph_times;
208 const NodeNodeGraphType
209 mesh_to_graph( fixture.elem_node() , fixture.node_count_owned(),
213 LocalMatrixType jacobian( mesh_to_graph.graph );
218 VectorType nodal_solution(
"nodal_solution" , fixture.node_count() );
219 nodal_residual = VectorType(
"nodal_residual" , fixture.node_count_owned() );
227 const ElementComputationType elemcomp( fixture , diffusion_coefficient ,
229 mesh_to_graph.elem_graph ,
230 jacobian , nodal_residual ,
247 comm_nodal_import( nodal_solution );
279 template <
typename ScalarViewType,
typename EnsembleViewType>
281 const EnsembleViewType& ensemble_residual)
283 const double tol = 1e-14;
286 Teuchos::VerboseObjectBase::getDefaultOStream();
287 std::stringstream buf;
290 typename ScalarViewType::HostMirror host_scalar_residual =
292 typename EnsembleViewType::HostMirror host_ensemble_residual =
298 host_ensemble_residual.extent(0), fbuf, success );
300 const size_t num_node = host_scalar_residual.extent(0);
302 for (
size_t i=0; i<num_node; ++i) {
303 for (
size_t j=0;
j<num_ensemble; ++
j) {
306 tol, fbuf, success );
330 const int use_print_ ,
331 const int use_trials_ ,
332 const int use_nodes_[] ,
342 template <
typename ArgT>
344 const int ensemble = ArgT::value;
345 typedef typename Storage::template apply_N<ensemble> NewStorageApply;
349 typedef Kokkos::View< Scalar* , Kokkos::LayoutLeft, Device > scalar_vector_type ;
350 typedef Kokkos::View< mp_vector_type* , Kokkos::LayoutLeft, Device > ensemble_vector_type ;
352 scalar_vector_type scalar_residual;
355 fenl_assembly<Scalar,Device,Method>(
357 scalar_dev_config, scalar_residual );
359 ensemble_vector_type ensemble_residual;
361 #if defined( KOKKOS_ENABLE_CUDA )
362 const bool is_cuda = Kokkos::Impl::is_same<Device,Kokkos::Cuda>::value;
364 const bool is_cuda = false ;
369 ensemble_dev_config.
block_dim.
y = block_size/ensemble;
372 fenl_assembly<mp_vector_type,Device,Method>(
374 ensemble_dev_config, ensemble_residual);
381 perf_scalar.
scale(s);
382 perf_ensemble.
scale(s);
384 if (comm->getRank() == 0) {
385 std::cout.precision(3);
386 std::cout << use_nodes[0] <<
" , "
388 << std::setw(2) << ensemble <<
" , "
392 << std::fixed << std::setw(6)
397 << std::fixed << std::setw(6)
404 template <
class Storage,
int entry_min,
int entry_max,
int entry_step,
407 const int use_print ,
408 const int use_trials ,
409 const int use_nodes[] ,
413 if (comm->getRank() == 0) {
414 std::cout.precision(8);
415 std::cout << std::endl
416 <<
"\"Grid Size\" , "
418 <<
"\"Ensemble Size\" , "
419 <<
"\"Scalar Import Time\" , "
420 <<
"\"Ensemble Import Time\" , "
421 <<
"\"Ensemble Import Speedup\" , "
422 <<
"\"Scalar Fill Time\" , "
423 <<
"\"Ensemble Fill Time\" , "
424 <<
"\"Ensemble Fill Speedup\" , "
429 typedef Sacado::mpl::range_c< int, entry_min, entry_max+1, entry_step > Range;
431 use_nodes, check, dev_config);
432 Sacado::mpl::for_each_no_kokkos<Range>
f(op);
Perf fenl_assembly(const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const int use_print, const int use_trials, const int use_nodes[], Kokkos::Example::FENL::DeviceConfig dev_config, Kokkos::View< Scalar *, Kokkos::LayoutLeft, Device > &nodal_residual)
bool check_residuals(const ScalarViewType &scalar_residual, const EnsembleViewType &ensemble_residual)
Stokhos::StandardStorage< int, double > storage_type
Stokhos::StandardStorage< int, double > Storage
static void eval(Kokkos::Example::FENL::DeviceConfig &dev_config_elem, Kokkos::Example::FENL::DeviceConfig &dev_config_bc)
#define TEUCHOS_TEST_FLOATING_EQUALITY(v1, v2, tol, out, success)
Kokkos::DefaultExecutionSpace execution_space
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< View< T, P...> >::value, unsigned >::type dimension_scalar(const View< T, P...> &view)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void increment(const Perf &p)
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
void deep_copy(const Stokhos::CrsMatrix< ValueType, DstDevice, Layout > &dst, const Stokhos::CrsMatrix< ValueType, SrcDevice, Layout > &src)
expr1 expr1 expr1 expr2 expr1 expr1 c expr2 expr1 c fastAccessCoeff(j)-expr2.val(j)
void performance_test_driver(const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const int use_print, const int use_trials, const int use_nodes[], const bool check, Kokkos::Example::FENL::DeviceConfig dev_config)
#define TEUCHOS_TEST_EQUALITY(v1, v2, out, success)
double maximum(const Teuchos::RCP< const Teuchos::Comm< int > > &comm, double local)
ScalarType f(const Teuchos::Array< ScalarType > &x, double a, double b)
Generate a distributed unstructured finite element mesh from a partitioned NX*NY*NZ box of elements...
Stokhos::CrsMatrix< ValueType, Device, Layout >::HostMirror create_mirror_view(const Stokhos::CrsMatrix< ValueType, Device, Layout > &A)