-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow multiple receivers in an element. #425
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,26 @@ struct chunk_index_type<false, DimensionType> { | |
const specfem::point::index<dimension> index) | ||
: ielement(ielement), index(index){}; | ||
}; | ||
|
||
/** | ||
* @brief Struct to store the index of a quadrature point generated by chunk | ||
* policy. | ||
* | ||
* @tparam UseSIMD Indicates whether SIMD is used or not. | ||
* @tparam DimensionType Dimension type of the elements within this iterator. | ||
*/ | ||
template <bool UseSIMD, specfem::dimension::type DimensionType> | ||
struct mapped_chunk_index_type | ||
: public chunk_index_type<UseSIMD, DimensionType> { | ||
using Base = chunk_index_type<UseSIMD, DimensionType>; | ||
int imap; ///< Index of the mapped element | ||
|
||
mapped_chunk_index_type(const int ielement, | ||
const specfem::point::index<DimensionType> index, | ||
const int imap) | ||
: Base(ielement, index), imap(imap) {} | ||
}; | ||
|
||
} // namespace impl | ||
|
||
/** | ||
|
@@ -93,7 +113,7 @@ class chunk<ViewType, specfem::dimension::type::dim2, SIMD> { | |
///< type | ||
///@} | ||
|
||
private: | ||
protected: | ||
constexpr static bool using_simd = simd::using_simd; | ||
constexpr static int simd_size = simd::size(); | ||
|
||
|
@@ -223,6 +243,35 @@ class chunk<ViewType, specfem::dimension::type::dim2, SIMD> { | |
return Kokkos::make_pair(indices(0), indices(num_elements - 1) + 1); | ||
} | ||
}; | ||
|
||
template <typename ViewType, specfem::dimension::type DimensionType, | ||
typename SIMD> | ||
class mapped_chunk; | ||
|
||
template <typename ViewType, typename SIMD> | ||
class mapped_chunk<ViewType, specfem::dimension::type::dim2, SIMD> | ||
: public chunk<ViewType, specfem::dimension::type::dim2, SIMD> { | ||
using Base = chunk<ViewType, specfem::dimension::type::dim2, SIMD>; | ||
using mapped_index_type = | ||
typename impl::mapped_chunk_index_type<Base::using_simd, | ||
Base::dimension>; ///< Index | ||
|
||
public: | ||
mapped_chunk(const ViewType &indices, const ViewType &mapping, | ||
const int ngllz, const int ngllx) | ||
: Base(indices, ngllz, ngllx), mapping(mapping) {} | ||
|
||
KOKKOS_INLINE_FUNCTION | ||
mapped_index_type operator()(const int i) const { | ||
const auto base_index = Base::operator()(i); | ||
return mapped_index_type(base_index.ielement, base_index.index, | ||
mapping(base_index.ielement)); | ||
} | ||
|
||
private: | ||
ViewType mapping; | ||
}; | ||
|
||
} // namespace iterator | ||
|
||
namespace policy { | ||
|
@@ -237,7 +286,7 @@ template <typename ParallelConfig> | |
struct element_chunk | ||
: public Kokkos::TeamPolicy<typename ParallelConfig::execution_space> { | ||
|
||
private: | ||
protected: | ||
using IndexViewType = Kokkos::View< | ||
int *, | ||
typename ParallelConfig::execution_space::memory_space>; ///< View | ||
|
@@ -289,7 +338,7 @@ struct element_chunk | |
true; ///< Indicates that this is a Kokkos team policy | ||
///@} | ||
|
||
private: | ||
protected: | ||
constexpr static int simd_size = simd::size(); | ||
constexpr static bool using_simd = simd::using_simd; | ||
|
||
|
@@ -345,10 +394,44 @@ struct element_chunk | |
return iterator_type(my_indices, ngllz, ngllx); | ||
} | ||
|
||
private: | ||
protected: | ||
IndexViewType elements; ///< View of elements | ||
int ngllz; ///< Number of GLL points in the z-direction | ||
int ngllx; ///< Number of GLL points in the x-direction | ||
}; | ||
|
||
template <typename ParallelConfig> | ||
struct mapped_element_chunk : public element_chunk<ParallelConfig> { | ||
using simd = typename ParallelConfig::simd; | ||
using Base = element_chunk<ParallelConfig>; | ||
using IndexViewType = typename Base::IndexViewType; | ||
|
||
using mapped_iterator_type = | ||
specfem::iterator::mapped_chunk<IndexViewType, ParallelConfig::dimension, | ||
simd>; ///< Iterator | ||
|
||
mapped_element_chunk(const IndexViewType &view, const IndexViewType &mapping, | ||
int ngllz, int ngllx) | ||
: Base(view, ngllz, ngllx), mapping(mapping) {} | ||
|
||
KOKKOS_INLINE_FUNCTION | ||
mapped_iterator_type mapped_league_iterator(const int start_index) const { | ||
const int start = start_index; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got the error |
||
const int end = | ||
(start + Base::chunk_size * Base::simd_size > Base::elements.extent(0)) | ||
? Base::elements.extent(0) | ||
: start + Base::chunk_size * Base::simd_size; | ||
const auto elem_indices = | ||
Kokkos::subview(Base::elements, Kokkos::make_pair(start, end)); | ||
const auto map_indices = | ||
Kokkos::subview(mapping, Kokkos::make_pair(start, end)); | ||
return mapped_iterator_type(elem_indices, map_indices, Base::ngllz, | ||
Base::ngllx); | ||
} | ||
|
||
protected: | ||
IndexViewType mapping; ///< View of elements | ||
}; | ||
|
||
} // namespace policy | ||
} // namespace specfem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up updating the naming of the policy, index, iterator etc. for more clarity:
But it is fine the way it is here