17 #include "Sacado_mpl_range_c.hpp"
18 #include "Sacado_mpl_for_each.hpp"
19 #include "Sacado_mpl_integral_c.hpp"
22 #include <Kokkos_UnorderedMap.hpp>
23 #include <Kokkos_StaticCrsGraph.hpp>
24 #include <Kokkos_Timer.hpp>
68 template <
typename Scalar,
typename Device,
73 const int use_trials ,
74 const int use_nodes[] ,
76 Kokkos::View< Scalar* , Kokkos::LayoutLeft, Device >& nodal_residual)
80 using Teuchos::rcpFromRef;
81 using Teuchos::arrayView;
88 typedef typename LocalMatrixType::StaticCrsGraphType LocalGraphType ;
96 ElementComputationType ;
101 typedef typename ElementComputationType::vector_type VectorType ;
104 typename FixtureType::comm_list_type ,
105 typename FixtureType::send_nodeid_type ,
106 VectorType > ImportType ;
110 const int print_flag = use_print && std::is_same< Kokkos::HostSpace , typename Device::memory_space >::value ;
112 const int comm_rank = comm->getRank();
113 const int comm_size = comm->getSize();
117 const double bubble_x = 1.0 ;
118 const double bubble_y = 1.0 ;
119 const double bubble_z = 1.0 ;
122 comm_size , comm_rank ,
123 use_nodes[0] , use_nodes[1] , use_nodes[2] ,
124 bubble_x , bubble_y , bubble_z );
128 const ImportType comm_nodal_import(
130 fixture.recv_node() ,
131 fixture.send_node() ,
132 fixture.send_nodeid() ,
133 fixture.node_count_owned() ,
134 fixture.node_count() - fixture.node_count_owned() );
141 CoeffFunctionType diffusion_coefficient( 1.0, 0.1, 1.0, 5 );
147 std::cout <<
"ElemNode {" << std::endl ;
148 for (
unsigned ielem = 0 ; ielem < fixture.elem_count() ; ++ielem ) {
149 std::cout <<
" elem[" << ielem <<
"]{" ;
150 for (
unsigned inode = 0 ; inode < FixtureType::ElemNode ; ++inode ) {
151 std::cout <<
" " << fixture.elem_node(ielem,inode);
153 std::cout <<
" }" << std::endl ;
155 std::cout <<
"}" << std::endl ;
160 Kokkos::Timer wall_clock ;
164 for (
int itrial = 0 ; itrial < use_trials ; ++itrial ) {
176 typename NodeNodeGraphType::Times graph_times;
177 const NodeNodeGraphType
178 mesh_to_graph( fixture.elem_node() , fixture.node_count_owned(),
182 LocalMatrixType jacobian( mesh_to_graph.graph );
187 VectorType nodal_solution(
"nodal_solution" , fixture.node_count() );
188 nodal_residual = VectorType(
"nodal_residual" , fixture.node_count_owned() );
196 const ElementComputationType elemcomp( fixture , diffusion_coefficient ,
198 mesh_to_graph.elem_graph ,
199 jacobian , nodal_residual ,
216 comm_nodal_import( nodal_solution );
248 template <
typename ScalarViewType,
typename EnsembleViewType>
250 const EnsembleViewType& ensemble_residual)
252 const double tol = 1e-14;
255 Teuchos::VerboseObjectBase::getDefaultOStream();
256 std::stringstream buf;
259 typename ScalarViewType::HostMirror host_scalar_residual =
261 typename EnsembleViewType::HostMirror host_ensemble_residual =
267 host_ensemble_residual.extent(0), fbuf, success );
269 const size_t num_node = host_scalar_residual.extent(0);
271 for (
size_t i=0; i<num_node; ++i) {
272 for (
size_t j=0;
j<num_ensemble; ++
j) {
275 tol, fbuf, success );
299 const int use_print_ ,
300 const int use_trials_ ,
301 const int use_nodes_[] ,
311 template <
typename ArgT>
313 const int ensemble = ArgT::value;
314 typedef typename Storage::template apply_N<ensemble> NewStorageApply;
318 typedef Kokkos::View< Scalar* , Kokkos::LayoutLeft, Device > scalar_vector_type ;
319 typedef Kokkos::View< mp_vector_type* , Kokkos::LayoutLeft, Device > ensemble_vector_type ;
321 scalar_vector_type scalar_residual;
324 fenl_assembly<Scalar,Device,Method>(
326 scalar_dev_config, scalar_residual );
328 ensemble_vector_type ensemble_residual;
330 #if defined( KOKKOS_ENABLE_CUDA )
331 const bool is_cuda = std::is_same<Device,Kokkos::Cuda>::value;
333 const bool is_cuda = false ;
338 ensemble_dev_config.
block_dim.
y = block_size/ensemble;
341 fenl_assembly<mp_vector_type,Device,Method>(
343 ensemble_dev_config, ensemble_residual);
350 perf_scalar.
scale(s);
351 perf_ensemble.
scale(s);
353 if (comm->getRank() == 0) {
354 std::cout.precision(3);
355 std::cout << use_nodes[0] <<
" , "
357 << std::setw(2) << ensemble <<
" , "
361 << std::fixed << std::setw(6)
366 << std::fixed << std::setw(6)
373 template <
class Storage,
int entry_min,
int entry_max,
int entry_step,
376 const int use_print ,
377 const int use_trials ,
378 const int use_nodes[] ,
382 if (comm->getRank() == 0) {
383 std::cout.precision(8);
384 std::cout << std::endl
385 <<
"\"Grid Size\" , "
387 <<
"\"Ensemble Size\" , "
388 <<
"\"Scalar Import Time\" , "
389 <<
"\"Ensemble Import Time\" , "
390 <<
"\"Ensemble Import Speedup\" , "
391 <<
"\"Scalar Fill Time\" , "
392 <<
"\"Ensemble Fill Time\" , "
393 <<
"\"Ensemble Fill Speedup\" , "
398 typedef Sacado::mpl::range_c< int, entry_min, entry_max+1, entry_step > Range;
400 use_nodes, check, dev_config);
401 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)
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)