Skip to content

Commit

Permalink
Remove sleep and wake functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Rombur committed Oct 25, 2023
1 parent cf5a859 commit 9158785
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 92 deletions.
20 changes: 0 additions & 20 deletions core/src/Cuda/Kokkos_Cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,6 @@ class Cuda {
#endif
}

/** \brief Set the device in a "sleep" state.
*
* This function sets the device in a "sleep" state in which it is
* not ready for work. This may consume less resources than if the
* device were in an "awake" state, but it may also take time to
* bring the device from a sleep state to be ready for work.
*
* \return True if the device is in the "sleep" state, else false if
* the device is actively working and could not enter the "sleep"
* state.
*/
static bool sleep();

/// \brief Wake the device from the 'sleep' state so it is ready for work.
///
/// \return True if the device is in the "ready" state, else "false"
/// if the device is actively working (which also means that it's
/// awake).
static bool wake();

/// \brief Wait until all dispatched functors complete.
///
/// The parallel_for or parallel_reduce dispatch of a functor may
Expand Down
6 changes: 0 additions & 6 deletions core/src/SYCL/Kokkos_SYCL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ class SYCL {
#endif
}

/** \brief Set the device in a "sleep" state. */
static bool sleep();

/** \brief Wake the device from the 'sleep' state. A noop for OpenMP. */
static bool wake();

/** \brief Wait until all dispatched functors complete. A noop for OpenMP. */
static void impl_static_fence(const std::string& name);

Expand Down
63 changes: 0 additions & 63 deletions core/src/Threads/Kokkos_Threads_Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
namespace Kokkos {
namespace Impl {
namespace {
std::mutex host_internal_cppthread_mutex;

// std::thread compatible driver.
// Recovery from an exception would require constant intra-thread health
Expand Down Expand Up @@ -125,12 +124,6 @@ bool ThreadsInternal::is_process() {
return master_pid == std::this_thread::get_id();
}

void ThreadsInternal::global_lock() { host_internal_cppthread_mutex.lock(); }

void ThreadsInternal::global_unlock() {
host_internal_cppthread_mutex.unlock();
}

//----------------------------------------------------------------------------

void ThreadsInternal::wait_yield(volatile ThreadState &flag,
Expand Down Expand Up @@ -269,24 +262,6 @@ ThreadsInternal *ThreadsInternal::get_thread(const int init_thread_rank) {
return th;
}

//----------------------------------------------------------------------------

void ThreadsInternal::execute_sleep(ThreadsInternal &exec, const void *) {
ThreadsInternal::global_lock();
ThreadsInternal::global_unlock();

const int n = exec.m_pool_fan_size;
const int rank_rev = exec.m_pool_size - (exec.m_pool_rank + 1);

for (int i = 0; i < n; ++i) {
Impl::spinwait_while_equal(
exec.m_pool_base[rank_rev + (1 << i)]->m_pool_state,
ThreadState::Active);
}

exec.m_pool_state = ThreadState::Inactive;
}

} // namespace Impl
} // namespace Kokkos

Expand Down Expand Up @@ -391,44 +366,6 @@ void ThreadsInternal::start(void (*func)(ThreadsInternal &, const void *),

//----------------------------------------------------------------------------

bool ThreadsInternal::sleep() {
verify_is_process("ThreadsInternal::sleep", true);

if (&execute_sleep == s_current_function) return false;

fence();

ThreadsInternal::global_lock();

s_current_function = &execute_sleep;

// Activate threads:
for (unsigned i = s_thread_pool_size[0]; 0 < i;) {
s_threads_exec[--i]->m_pool_state = ThreadState::Active;
}

return true;
}

bool ThreadsInternal::wake() {
verify_is_process("ThreadsInternal::wake", true);

if (&execute_sleep != s_current_function) return false;

ThreadsInternal::global_unlock();

if (s_threads_process.m_pool_base) {
execute_sleep(s_threads_process, nullptr);
s_threads_process.m_pool_state = ThreadState::Inactive;
}

fence();

return true;
}

//----------------------------------------------------------------------------

void ThreadsInternal::execute_resize_scratch_in_serial() {
const unsigned begin = s_threads_process.m_pool_base ? 1 : 0;

Expand Down
3 changes: 0 additions & 3 deletions core/src/Threads/Kokkos_Threads_Instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class ThreadsInternal {

static void first_touch_allocate_thread_private_scratch(ThreadsInternal &,
const void *);
static void execute_sleep(ThreadsInternal &, const void *);

ThreadsInternal(const ThreadsInternal &);
ThreadsInternal &operator=(const ThreadsInternal &);
Expand Down Expand Up @@ -424,8 +423,6 @@ class ThreadsInternal {
static void internal_fence(
const std::string &,
Impl::fence_is_static is_static = Impl::fence_is_static::yes);
static bool sleep();
static bool wake();

/* Dynamic Scheduling related functionality */
// Initialize the work range for this thread
Expand Down

0 comments on commit 9158785

Please sign in to comment.