Skip to content

Commit

Permalink
SimSYCL is now thread-safe; remove workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
fknorr committed Dec 9, 2024
1 parent f2a0a76 commit 539b74b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
22 changes: 4 additions & 18 deletions src/backend/sycl_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,6 @@ struct sycl_backend::impl {
}
}

template <typename F>
async_event submit_alloc(F&& f) {
#if CELERITY_WORKAROUND(SIMSYCL)
// SimSYCL is not thread safe => skip alloc_queue and complete allocations in executor thread.
if constexpr(std::is_void_v<std::invoke_result_t<F>>) {
return f(), make_complete_event();
} else {
return make_complete_event(f());
}
#else
return host.alloc_queue.submit(std::forward<F>(f));
#endif
}

thread_queue& get_host_queue(const size_t lane) {
assert(lane <= host.queues.size());
if(lane == host.queues.size()) { host.queues.emplace_back(named_threads::task_type_host_queue(lane), config.profiling); }
Expand Down Expand Up @@ -233,7 +219,7 @@ void* sycl_backend::debug_alloc(const size_t size) {
void sycl_backend::debug_free(void* const ptr) { sycl::free(ptr, m_impl->host.sycl_context); }

async_event sycl_backend::enqueue_host_alloc(const size_t size, const size_t alignment) {
return m_impl->submit_alloc([this, size, alignment] {
return m_impl->host.alloc_queue.submit([this, size, alignment] {
const auto ptr = sycl::aligned_alloc_host(alignment, size, m_impl->host.sycl_context);
#if CELERITY_DETAIL_ENABLE_DEBUG
memset(ptr, static_cast<int>(sycl_backend_detail::uninitialized_memory_pattern), size);
Expand All @@ -243,7 +229,7 @@ async_event sycl_backend::enqueue_host_alloc(const size_t size, const size_t ali
}

async_event sycl_backend::enqueue_device_alloc(const device_id device, const size_t size, const size_t alignment) {
return m_impl->submit_alloc([this, device, size, alignment] {
return m_impl->host.alloc_queue.submit([this, device, size, alignment] {
auto& d = m_impl->devices[device];
const auto ptr = sycl::aligned_alloc_device(alignment, size, d.sycl_device, d.sycl_context);
#if CELERITY_DETAIL_ENABLE_DEBUG
Expand All @@ -256,11 +242,11 @@ async_event sycl_backend::enqueue_device_alloc(const device_id device, const siz
}

async_event sycl_backend::enqueue_host_free(void* const ptr) {
return m_impl->submit_alloc([this, ptr] { sycl::free(ptr, m_impl->host.sycl_context); });
return m_impl->host.alloc_queue.submit([this, ptr] { sycl::free(ptr, m_impl->host.sycl_context); });
}

async_event sycl_backend::enqueue_device_free(const device_id device, void* const ptr) {
return m_impl->submit_alloc([this, device, ptr] { sycl::free(ptr, m_impl->devices[device].sycl_context); });
return m_impl->host.alloc_queue.submit([this, device, ptr] { sycl::free(ptr, m_impl->devices[device].sycl_context); });
}

async_event sycl_backend::enqueue_host_task(size_t host_lane, const host_task_launcher& launcher, std::vector<closure_hydrator::accessor_info> accessor_infos,
Expand Down
8 changes: 0 additions & 8 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ namespace detail {
if(has_profile_kernel) { m_enable_device_profiling = *has_profile_kernel; }

m_enable_backend_device_submission_threads = parsed_and_validated_envs.get_or(env_backend_device_submission_threads, true);
#if CELERITY_WORKAROUND(SIMSYCL)
// SimSYCL is not thread safe
if(m_enable_backend_device_submission_threads) {
CELERITY_WARN("CELERITY_BACKEND_DEVICE_SUBMISSION_THREADS=on is not supported with SimSYCL. Disabling worker threads.");
m_enable_backend_device_submission_threads = false;
}
#endif // CELERITY_WORKAROUND(SIMSYCL)

m_thread_pinning_config = parsed_and_validated_envs.get_or(env_thread_pinning, {});

const auto dry_run_num_nodes = parsed_and_validated_envs.get(env_dry_run_num_nodes);
Expand Down
3 changes: 1 addition & 2 deletions test/test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ const char* const expected_runtime_init_warnings_regex =
"Celerity has detected that only .* logical cores are available to this process.*|"
"Celerity detected more than one node \\(MPI rank\\) on this host, which is not recommended.*|"
"Instrumentation for profiling with Tracy is enabled\\. Performance may be negatively impacted\\.|"
"\\[executor\\] no progress for .* seconds, potentially stuck.*|"
"CELERITY_BACKEND_DEVICE_SUBMISSION_THREADS=on is not supported with SimSYCL\\. Disabling worker threads\\.";
"\\[executor\\] no progress for .* seconds, potentially stuck.*";

const char* const expected_device_enumeration_warnings_regex = "Found fewer devices .* than local nodes .*, multiple nodes will use the same device.*";

Expand Down

0 comments on commit 539b74b

Please sign in to comment.