8 #ifndef UNITTESTKOKKOSME_H 9 #define UNITTESTKOKKOSME_H 11 #include "gtest/gtest.h" 23 template<
typename AlgTraits>
28 :
comm_(MPI_COMM_WORLD),
29 meta_(AlgTraits::nDim_),
55 meta_.coordinate_field());
73 double scs_data[AlgTraits::numScsIp_*AlgTraits::nodesPerElement_];
76 for (
int i=0; i < (AlgTraits::numScsIp_*AlgTraits::nodesPerElement_); ++i) {
77 v_scs_data[i] = scs_data[i];
80 double scv_data[AlgTraits::numScvIp_*AlgTraits::nodesPerElement_];
83 for (
int i=0; i < (AlgTraits::numScvIp_*AlgTraits::nodesPerElement_); ++i) {
84 v_scv_data[i] = scv_data[i];
88 template<
typename LambdaFunction>
91 constexpr
int simdLen = stk::simd::ndoubles;
93 const bool alsoProcessMEViews =
false;
95 stk::mesh::Selector sel = (
96 meta_.locally_owned_part() & stk::mesh::selectUnion(
partVec_));
98 const int bytes_per_team = 0;
99 int bytes_per_thread = sierra::nalu::get_num_bytes_pre_req_data<double>(
101 bytes_per_thread *= 3 * stk::simd::ndoubles;
103 const auto& buckets =
bulk_.get_buckets(stk::topology::ELEM_RANK, sel);
106 buckets.size(), bytes_per_team, bytes_per_thread);
109 auto& b = *buckets[team.league_rank()];
110 const auto length = b.size();
112 std::vector<sierra::nalu::ScratchViews<double>*> prereqData(simdLen,
nullptr);
114 for (
int simdIndex=0; simdIndex < simdLen; ++simdIndex) {
119 team,
bulk_, AlgTraits::topo_, dataNeeded_);
121 const stk::mesh::Entity* elemNodes[simdLen];
122 stk::mesh::Bucket::size_type simdBucketLen = length / simdLen;
123 const stk::mesh::Bucket::size_type remainder = length % simdLen;
124 if (remainder > 0) simdBucketLen++;
126 Kokkos::parallel_for(Kokkos::TeamThreadRange(team, simdBucketLen), [&](
const size_t& bktIndex){
127 int simdElems = simdLen;
128 if (length - bktIndex*simdLen < simdLen) {
129 simdElems = length - bktIndex*simdLen;
132 stk::mesh::Entity element;
133 for (
int simdIndex=0; simdIndex < simdElems; ++simdIndex) {
134 element = b[bktIndex*simdLen + simdIndex];
135 elemNodes[simdIndex] =
bulk_.begin_nodes(element);
137 *prereqData[simdIndex], alsoProcessMEViews);
143 element, simdPrereqData);
145 func(simdPrereqData);
160 Kokkos::View<DoubleType[AlgTraits::numScvIp_][AlgTraits::nodesPerElement_]>
scv_shape_fcn_ {
"scv_shape_function"};
161 Kokkos::View<DoubleType[AlgTraits::numScsIp_][AlgTraits::nodesPerElement_]>
scs_shape_fcn_ {
"scs_shape_function"};
std::vector< Part * > PartVector
Definition: Algorithm.h:16
Definition: MasterElement.h:53
sierra::nalu::DoubleType DoubleType
Definition: SimdInterface.h:37
void add_coordinates_field(const stk::mesh::FieldBase &field, unsigned scalarsPerNode, COORDS_TYPES cType)
Definition: ElemDataRequests.C:69
void fill_master_element_views(ElemDataRequests &dataNeeded, const stk::mesh::BulkData &bulkData, stk::topology topo, stk::mesh::Entity elem, ScratchViews< DoubleType > &prereqData)
Definition: ScratchViews.C:257
static MasterElement * get_surface_master_element(const stk::topology &theTopo, int dimension=0, std::string quadType="GaussLegendre")
Definition: MasterElementFactory.C:208
void add_cvfem_volume_me(MasterElement *meSCV)
Definition: ElemDataRequests.h:103
Definition: ElemDataRequests.h:66
virtual void shape_fcn(SharedMemView< DoubleType ** > &shpfc)
Definition: MasterElement.h:60
void copy_and_interleave(const std::vector< ScratchViews< double > * > &data, int simdElems, ScratchViews< DoubleType > &simdData, bool copyMEViews=true)
Definition: CopyAndInterleave.h:152
stk::mesh::MetaData meta_
Definition: UnitTestKokkosME.h:151
Definition: UnitTestKokkosME.h:24
void add_cvfem_surface_me(MasterElement *meSCS)
Definition: ElemDataRequests.h:108
Definition: UnitTestFieldUtils.C:10
sierra::nalu::MasterElement * meSCV_
Definition: UnitTestKokkosME.h:157
sierra::nalu::ElemDataRequests dataNeeded_
Definition: UnitTestKokkosME.h:156
Definition: ElemDataRequests.h:35
stk::ParallelMachine comm_
Definition: UnitTestKokkosME.h:150
KokkosMEViews(bool doInit=true)
Definition: UnitTestKokkosME.h:27
stk::mesh::Entity create_one_reference_element(stk::mesh::BulkData &bulk, stk::topology topo)
Definition: UnitTestUtils.C:295
virtual ~KokkosMEViews()
Definition: UnitTestKokkosME.h:36
void fill_mesh_and_init_data(bool doPerturb=false)
Create a 1-element STK mesh and initialize MasterElement data structures.
Definition: UnitTestKokkosME.h:40
DeviceTeamPolicy get_team_policy(const size_t sz, const size_t bytes_per_team, const size_t bytes_per_thread)
Definition: KokkosInterface.h:30
sierra::nalu::MasterElement * meSCS_
Definition: UnitTestKokkosME.h:158
stk::mesh::Entity create_one_perturbed_element(stk::mesh::BulkData &bulk, stk::topology topo)
Definition: UnitTestUtils.C:330
Kokkos::View< DoubleType[AlgTraits::numScsIp_][AlgTraits::nodesPerElement_]> scs_shape_fcn_
Definition: UnitTestKokkosME.h:161
void execute(LambdaFunction func)
Definition: UnitTestKokkosME.h:89
void fill_mesh(bool doPerturb=false)
Definition: UnitTestKokkosME.h:46
Kokkos::View< DoubleType[AlgTraits::numScvIp_][AlgTraits::nodesPerElement_]> scv_shape_fcn_
Definition: UnitTestKokkosME.h:160
void init_me_data()
Definition: UnitTestKokkosME.h:62
stk::mesh::PartVector partVec_
Definition: UnitTestKokkosME.h:153
Kokkos::TeamPolicy< DeviceSpace, DynamicScheduleType >::member_type TeamHandleType
Definition: KokkosInterface.h:22
static MasterElement * get_volume_master_element(const stk::topology &theTopo, int dimension=0, std::string quadType="GaussLegendre")
Definition: MasterElementFactory.C:228
const VectorFieldType * coordinates_
Definition: UnitTestKokkosME.h:154
void fill_pre_req_data(ElemDataRequests &dataNeeded, const stk::mesh::BulkData &bulkData, stk::topology topo, stk::mesh::Entity elem, ScratchViews< double > &prereqData, bool fillMEViews)
Definition: ScratchViews.C:180
Definition: ScratchViews.h:82
stk::mesh::BulkData bulk_
Definition: UnitTestKokkosME.h:152