Clause getBoxCoverageRequirement(ViewType& view, size_t boxSize, CellType reqCellType) { Clause req; for (int row = view.height()-boxSize; row < view.height(); row++) { for (int col = view.width()-boxSize; col < view.width(); col++) { req |= view[row][col] == reqCellType; } } return req; }
KOKKOS_INLINE_FUNCTION void operator() (const typename ViewType::size_type i) const { // On CPUs this loop could be vectorized so j should do stride 1 // access on a for optimal performance. I.e. a should be LayoutRight. // On GPUs threads should do coalesced loads and stores. That means // that i should be the stride one access for optimal performance. for (typename ViewType::size_type j = 0; j < a.dimension_1 (); ++j) { a(i,j) = 1.0*a.dimension_0()*i + 1.0*j; } }
string UserInterface::getTaskString(Task* task, int viewType) { ViewType *taskListType; switch(viewType) { case -1: taskListType = new ViewType(); break; case 0: taskListType = new ViewType0(); break; default: break; } return taskListType->getTaskString(task); }
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() ) ) { }
void UserInterface::printSearchList(string searchTerm, int viewType) { printNotificationSearchTerm(searchTerm); ViewType *taskListType; switch(viewType) { case -1: taskListType = new ViewType(_taskList); break; case 0: taskListType = new ViewType0(_taskList); break; default: break; } printDisplayList(createDisplayBox(taskListType->createDisplayList())); delete taskListType; }
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); }
void UserInterface::printTaskList(int currentDate ,int viewType) { ViewType *taskListType; switch(viewType) { case -1: taskListType = new ViewType(_taskList , currentDate); break; case 0: taskListType = new ViewType0(_taskList , currentDate); break; case 1: taskListType = new ViewType1(_taskList , currentDate); break; default: break; } printDisplayList(createDisplayBox(taskListType->createDisplayList())); delete taskListType; }
void draw_v_disparity_line(ViewType &view, PixelType &color, const GroundPlaneEstimator::line_t &v_disparity_line) { const int x1 = 0, y1 = v_disparity_line.origin()(0); const int x2 = view.width(), y2 = v_disparity_line.origin()(0) + x2*v_disparity_line.direction()(0); draw_line(view, color, x1, y1, x2, y2); // printf("draw_v_disparity_line (origin, direction) == (%.2f, %.2f) -> (x2, y2) == (%i, %i)\n", // v_disparity_line.origin()(0), v_disparity_line.direction()(0), // x2, y2); return; }
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); }
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]; } }
MPVectorAtomicFunctor( const ViewType & v , const scalar_type & s ) : m_v( v ), m_s( s ) { Kokkos::parallel_for( m_v.dimension_0() , *this ); }
// Kernel launch static void apply(const ViewType& v, const ScalarType& s) { const size_type nrow = v.dimension_0(); Kokkos::parallel_for( nrow, ScalarAssignKernel(v,s) ); }
GetMeanValsFunc(const ViewType& vals) { mean_vals = ViewType("mean-values", vals.dimension_0()); Kokkos::deep_copy( mean_vals, vals ); }
size_t getStride2DView (ViewType A) { size_t stride[8]; A.stride (stride); return A.dimension_1 () > 1 ? stride[1] : A.dimension_0 (); }
inline bool isInside(const ViewType& v, const CoordType i, const CoordType j) { return i>=0 && j>=0 && i<v.width() && j<v.height(); }
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()); }