ParallelReduce( const FunctorType & arg_functor
               , const Policy      & arg_policy
               , const ViewType    & arg_result )
   : m_functor( arg_functor )
   , m_policy( arg_policy )
   , m_result_ptr( arg_result.ptr_on_device() )
   , m_shared( arg_policy.scratch_size() + FunctorTeamShmemSize< FunctorType >::value( arg_functor , arg_policy.team_size() ) )
   { }
 Teuchos::ArrayRCP<typename ViewType::value_type>
 persistingView(
   const ViewType& view,
   typename Teuchos::ArrayRCP<typename ViewType::value_type>::size_type offset,
   typename Teuchos::ArrayRCP<typename ViewType::value_type>::size_type size) {
   return Teuchos::arcp(view.ptr_on_device()+offset, 0, size,
                        deallocator(view), false);
 }
예제 #3
0
  ParallelReduce( const FunctorType & functor
                , const Policy      & policy
                , const ViewType    & result )
    : m_func( functor )
    , m_policy( policy )
    {
      ThreadsExec::resize_shared_scratch( FunctorShmemSize< FunctorType >::value( functor ) );
      ThreadsExec::resize_reduce_scratch( Reduce::value_size( m_func ) );

      ThreadsExec::start( & ParallelReduce::execute , this , policy.league_size() , policy.team_size() );

      const pointer_type data = (pointer_type) ThreadsExec::root_reduce_scratch();

      ThreadsExec::fence();

      const unsigned n = Reduce::value_count( m_func );
      for ( unsigned i = 0 ; i < n ; ++i ) { result.ptr_on_device()[i] = data[i]; }
    }
 Teuchos::ArrayRCP<typename ViewType::value_type>
 persistingView(const ViewType& view) {
   // mfh (05 Sep 2013) We use a custom deallocator that keeps the
   // view, but otherwise does nothing.  It doesn't deallocate the
   // view; it just maintains the reference count for the lifetime
   // of the deallocator object (and therefore, for the lifetime of
   // the ArrayRCP).  It seems weird that this is a nonowning
   // ArrayRCP (the last argument is false).  However, that's OK,
   // because (a) the ArrayRCP (actually, the underlying
   // RCPNodeTmpl; see Teuchos_RCPNode.hpp) keeps the deallocator
   // object regardless of whether the ArrayRCP is owning, and (b)
   // if we make this an owning ArrayRCP, the RCPNode tracking
   // system (in a debug build: Teuchos_ENABLE_DEBUG:BOOL=ON) will
   // report problems, because multiple owning ArrayRCPs have the
   // same raw pointer but not the same underlying RCPNode.  That
   // would be a problem if those ArrayRCPs shared memory that was
   // allocated (e.g.,) using new or malloc, but it's not a problem
   // here, because the custom deallocator does not free anything.
   // Nevertheless, it's better not to trouble the tracking system.
   return Teuchos::arcp(view.ptr_on_device(), 0, view.capacity(),
                        deallocator(view), false);
 }
 Teuchos::ArrayView<const typename ViewType::value_type>
 getConstArrayView(const ViewType& a) {
   return Teuchos::ArrayView<const typename ViewType::value_type>(
     a.ptr_on_device(), a.size());
 }