-
Notifications
You must be signed in to change notification settings - Fork 407
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
Derived View type and allocation #566
Comments
What is the difference of this with Arithmetic Traits which exists in KokkosKernels? |
@kyungjoo-kim @mperego @ndellingwood @etphipp ViewX x ;
ViewY y ;
ViewZ z ;
using value_type = typename decltype( deduce_view_specialization( x , y , z ) )::value_type ;
View< value_type ** , Space > w( view_alloc( "w" , deduce_view_specialization( x , y , z ) ) , n0 , n1 ); Same discussion as issue #253 |
I guess it all depends on what deduce_view_specialization returns, and how complicated it is to use. What would you propose for that? Note that at some point, derived views need to be created manually (e.g., one of x, y, or z in your example), so whatever object is created by deduce_view_specialization needs to be easy to work with. |
@ndellingwood asked me to provide a code snippet from Albany to see how views are created there. `// ScalarT can be a Fad type or a double. … // dof is allocated // create unmanaged view for buffer using information from dof ... // create dofSide view using buffer. This could be on device. |
@etphipp re: struct ViewSacadoSpecialization {
using value_type = // deduced with specializations meta function
unsigned embedded_dimension ;
}; specific name of function is t.b.d. |
I think I would have to see it in action to really know for sure. Are you thinking this would replace the existing approach completely, e.g.,
or would that still be available? I would like to preserve that as an option, I guess, since it seems to me to be the most convenient way to create specialized views by hand (which is the majority of the use cases). |
Add corresponding routines to Sacado to implement the desired functionality in issue kokkos#566
Parially addresses Github issue kokkos#566 Add a property to ViewCtorProp, metafunctions, and user API to store embedded dimension within a ViewCtorProp instance, and retrieve/append to layout when this is present during construction of the view. TODO: * Finalize names of newly introduced items * Cleanup following name finalize * Move sandbox tests into Kokkos unit test framework and Sacados * Extensive testing WARNING: Corresponding changes were made to Sacado's KokkosExp_View_Fad.hpp and Kokkos_ViewFactory.hpp files and must be applied via patch prior to next snapshot of Kokkos into Trilinos and testing
Unit test to check functionality added for issue kokkos#566 TODO: Test Cuda
@hcedwar I have implemented functionality for this enhancement, based on your design suggestion, available from branch of my fork Let me know the best way to review, particularly name choices of functions, meta-functions, types etc. introduced. Following finalization of names and full testing I'll test issue PR following successful testing. Corresponding Sacado changes are stored in a patch that I'll attach after naming is final. The patch will need to be applied to Trilinos and committed synchronously with next Kokkos snapshot and integration testing. |
With a discussion with Eric P., I leave a comment for a robust way to construct workspace in the functor. Inside of a functor, I sometimes need to use stack memory and wrap the memory with a view to use API interfaced via Kokkos view (I do not want to use shared memory as it limits parallel for with a team policy only). My use case is
The third one is correct but it is still impl dependent and not insulated from fad specific data layout. Can we have a more robust and systematic way to create static workspace ? Best |
namespace Impl {
template< class ... Views >
struct CommonViewSpecialize ; // Recursively determine the one common non-void ViewTraits<...>::specialize among the view types
template< class SpecializationTag , class ... Views >
struct CommonViewTraits ; // specialized for ViewTraits<...>::specialize
template < class ... Views >
struct CommonViewTraits< void , Views ... > {
using value_type = typename std::common_type< typename Views::value_type ... >::type ;
};
// appears only in Sacado
template< class ... Views >
struct CommonViewTraits< ViewSpecializeSacadoFad , Views ... > {
using value_type = ... ;
unsigned fad_dimension ;
};
template< class ... Views >
using DeduceCommonViewTraits =
CommonViewTraits< typename CommonViewSpecialize< Views ... >::specialize , Views ... > ;
}
template< class ... Views >
Impl::DeduceCommonViewTraits< Views ... >
common_view_traits( Views const & ... args )
{ return Impl::DeduceCommonViewTraits< Views ... >( args... ); } |
@hcedwar Have a functional second impl based on your design suggestion above. It helped clean up some of the metafunctions and moved the Sacado-specific implementation details to Sacado. A couple comments:
Kokkos impl is on this branch of my fork: ndellingwood@5d2fde7 Sacado impl is stored locally and in a patch, will attach or email prior to review. |
Addresses issue kokkos#566 to provide functionality in Kokkos to replace ViewFactory in Sacado
Addresses issue kokkos#566 to provide functionality in Kokkos to replace ViewFactory in Sacado
Issue #566: Add metafunctions and prop to deduce common value_type
View value_type deduction:
View allocation with the deduced value_type
The current Sacado view factory provides both deducers and wrapper to View allocation
https://github.com/trilinos/Trilinos/blob/master/packages/sacado/example/view_factory_example.cpp
We need an extensible way to provide this functionality in order to remove the dependency of Intrepid2 on Sacado
The text was updated successfully, but these errors were encountered: