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_Timer.hpp>
67 template <
typename Scalar,
typename Device,
72 const int use_trials ,
73 const int use_nodes[] ,
75 Kokkos::View< Scalar* , Kokkos::LayoutLeft, Device >& nodal_residual)
79 using Teuchos::rcpFromRef;
80 using Teuchos::arrayView;
87 typedef typename LocalMatrixType::StaticCrsGraphType LocalGraphType ;
95 ElementComputationType ;
100 typedef typename ElementComputationType::vector_type VectorType ;
103 typename FixtureType::comm_list_type ,
104 typename FixtureType::send_nodeid_type ,
105 VectorType > ImportType ;
109 const int print_flag = use_print && std::is_same< Kokkos::HostSpace , typename Device::memory_space >::value ;
111 const int comm_rank = comm->getRank();
112 const int comm_size = comm->getSize();
116 const double bubble_x = 1.0 ;
117 const double bubble_y = 1.0 ;
118 const double bubble_z = 1.0 ;
121 comm_size , comm_rank ,
122 use_nodes[0] , use_nodes[1] , use_nodes[2] ,
123 bubble_x , bubble_y , bubble_z );
127 const ImportType comm_nodal_import(
129 fixture.recv_node() ,
130 fixture.send_node() ,
131 fixture.send_nodeid() ,
132 fixture.node_count_owned() ,
133 fixture.node_count() - fixture.node_count_owned() );
140 CoeffFunctionType diffusion_coefficient( 1.0, 0.1, 1.0, 5 );
146 std::cout <<
"ElemNode {" << std::endl ;
147 for (
unsigned ielem = 0 ; ielem < fixture.elem_count() ; ++ielem ) {
148 std::cout <<
" elem[" << ielem <<
"]{" ;
149 for (
unsigned inode = 0 ; inode < FixtureType::ElemNode ; ++inode ) {
150 std::cout <<
" " << fixture.elem_node(ielem,inode);
152 std::cout <<
" }" << std::endl ;
154 std::cout <<
"}" << std::endl ;
159 Kokkos::Timer wall_clock ;
163 for (
int itrial = 0 ; itrial < use_trials ; ++itrial ) {
175 typename NodeNodeGraphType::Times graph_times;
176 const NodeNodeGraphType
177 mesh_to_graph( fixture.elem_node() , fixture.node_count_owned(),
181 LocalMatrixType jacobian( mesh_to_graph.graph );
186 VectorType nodal_solution(
"nodal_solution" , fixture.node_count() );
187 nodal_residual = VectorType(
"nodal_residual" , fixture.node_count_owned() );
195 const ElementComputationType elemcomp( fixture , diffusion_coefficient ,
197 mesh_to_graph.elem_graph ,
198 jacobian , nodal_residual ,
215 comm_nodal_import( nodal_solution );
247 template <
typename ScalarViewType,
typename EnsembleViewType>
249 const EnsembleViewType& ensemble_residual)
251 const double tol = 1e-14;
254 Teuchos::VerboseObjectBase::getDefaultOStream();
255 std::stringstream buf;
258 typename ScalarViewType::HostMirror host_scalar_residual =
260 typename EnsembleViewType::HostMirror host_ensemble_residual =
266 host_ensemble_residual.extent(0), fbuf, success );
268 const size_t num_node = host_scalar_residual.extent(0);
270 for (
size_t i=0; i<num_node; ++i) {
271 for (
size_t j=0;
j<num_ensemble; ++
j) {
274 tol, fbuf, success );
298 const int use_print_ ,
299 const int use_trials_ ,
300 const int use_nodes_[] ,
310 template <
typename ArgT>
312 const int ensemble = ArgT::value;
313 typedef typename Storage::template apply_N<ensemble> NewStorageApply;
317 typedef Kokkos::View< Scalar* , Kokkos::LayoutLeft, Device > scalar_vector_type ;
318 typedef Kokkos::View< mp_vector_type* , Kokkos::LayoutLeft, Device > ensemble_vector_type ;
320 scalar_vector_type scalar_residual;
323 fenl_assembly<Scalar,Device,Method>(
325 scalar_dev_config, scalar_residual );
327 ensemble_vector_type ensemble_residual;
329 #if defined( KOKKOS_ENABLE_CUDA )
330 const bool is_cuda = std::is_same<Device,Kokkos::Cuda>::value;
332 const bool is_cuda = false ;
337 ensemble_dev_config.
block_dim.
y = block_size/ensemble;
340 fenl_assembly<mp_vector_type,Device,Method>(
342 ensemble_dev_config, ensemble_residual);
349 perf_scalar.
scale(s);
350 perf_ensemble.
scale(s);
352 if (comm->getRank() == 0) {
353 std::cout.precision(3);
354 std::cout << use_nodes[0] <<
" , "
356 << std::setw(2) << ensemble <<
" , "
360 << std::fixed << std::setw(6)
365 << std::fixed << std::setw(6)
372 template <
class Storage,
int entry_min,
int entry_max,
int entry_step,
375 const int use_print ,
376 const int use_trials ,
377 const int use_nodes[] ,
381 if (comm->getRank() == 0) {
382 std::cout.precision(8);
383 std::cout << std::endl
384 <<
"\"Grid Size\" , "
386 <<
"\"Ensemble Size\" , "
387 <<
"\"Scalar Import Time\" , "
388 <<
"\"Ensemble Import Time\" , "
389 <<
"\"Ensemble Import Speedup\" , "
390 <<
"\"Scalar Fill Time\" , "
391 <<
"\"Ensemble Fill Time\" , "
392 <<
"\"Ensemble Fill Speedup\" , "
397 typedef Sacado::mpl::range_c< int, entry_min, entry_max+1, entry_step > Range;
399 use_nodes, check, dev_config);
400 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)