static void run( int n ) { typedef typename sched_type::memory_space memory_space; // enum { MemoryCapacity = 4000 }; // Triggers infinite loop in memory pool. enum { MemoryCapacity = 16000 }; enum { MinBlockSize = 64 }; enum { MaxBlockSize = 1024 }; enum { SuperBlockSize = 1u << 12 }; sched_type sched( memory_space() , MemoryCapacity , MinBlockSize , MaxBlockSize , SuperBlockSize ); accum_type accum( "accum" ); typename accum_type::HostMirror host_accum = Kokkos::create_mirror_view( accum ); Kokkos::host_spawn( Kokkos::TaskSingle( sched ), TestTaskDependence( n, sched, accum ) ); Kokkos::wait( sched ); Kokkos::deep_copy( host_accum, accum ); ASSERT_EQ( host_accum(), n ); }
KOKKOS_INLINE_FUNCTION void operator()( typename sched_type::member_type & ) { enum { CHUNK = 8 }; const int n = CHUNK < m_count ? CHUNK : m_count; if ( 1 < m_count ) { const int increment = ( m_count + n - 1 ) / n; future_type f = m_sched.when_all( n , [this,increment]( int i ) { const long inc = increment ; const long begin = i * inc ; const long count = begin + inc < m_count ? inc : m_count - begin ; return Kokkos::task_spawn ( Kokkos::TaskSingle( m_sched ) , TestTaskDependence( count, m_sched, m_accum ) ); }); m_count = 0; Kokkos::respawn( this, f ); } else if ( 1 == m_count ) { Kokkos::atomic_increment( & m_accum() ); } }
KOKKOS_INLINE_FUNCTION void operator()( typename policy_type::member_type & ) { enum { CHUNK = 8 }; const int n = CHUNK < m_count ? CHUNK : m_count ; if ( 1 < m_count ) { future_type f[ CHUNK ] ; const int inc = ( m_count + n - 1 ) / n ; for ( int i = 0 ; i < n ; ++i ) { long begin = i * inc ; long count = begin + inc < m_count ? inc : m_count - begin ; f[i] = m_policy.task_spawn( TestTaskDependence(count,m_policy,m_accum) , Kokkos::TaskSingle ); } m_count = 0 ; m_policy.respawn( this , m_policy.when_all( n , f ) ); } else if ( 1 == m_count ) { Kokkos::atomic_increment( & m_accum() ); } }
static void run( int n ) { typedef typename policy_type::memory_space memory_space ; // enum { MemoryCapacity = 4000 }; // Triggers infinite loop in memory pool enum { MemoryCapacity = 16000 }; enum { Log2_SuperBlockSize = 12 }; policy_type policy( memory_space() , MemoryCapacity , Log2_SuperBlockSize ); accum_type accum("accum"); typename accum_type::HostMirror host_accum = Kokkos::create_mirror_view( accum ); policy.host_spawn( TestTaskDependence(n,policy,accum) , Kokkos::TaskSingle ); Kokkos::wait( policy ); Kokkos::deep_copy( host_accum , accum ); ASSERT_EQ( host_accum() , n ); }