Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dynamic Selection] Adding sycl profiling for auto tune policy #1464

Merged
merged 31 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9417ddb
Added static assert for keyArgs==Args
AnuyaWelling2801 Jan 9, 2024
7e54e28
WIP for jit compilation
AnuyaWelling2801 Jan 10, 2024
268f0d5
Fixing Autotune bug
AnuyaWelling2801 Jan 17, 2024
0dda712
Added sycl profiling without host task
AnuyaWelling2801 Mar 21, 2024
a38327a
Corrections in dynamic traits
AnuyaWelling2801 Mar 22, 2024
70f993c
Remove comments in dynamic_selection_traits
AnuyaWelling2801 Mar 22, 2024
59fa9a8
Merged main
AnuyaWelling2801 Mar 22, 2024
69f5014
Adding back jit compolation restrictions
AnuyaWelling2801 Mar 22, 2024
757c470
Adressing comments to add thread safety, better traits
AnuyaWelling2801 Mar 27, 2024
37a895a
Added backend trait to check if profiling is enabled
AnuyaWelling2801 Mar 27, 2024
d9fe635
Backend traits, renaming and adding a lock to lazy report
AnuyaWelling2801 Apr 4, 2024
95ee3ac
Fixed memory leaks
AnuyaWelling2801 Apr 9, 2024
cd5b318
No nullptr for selection handle in async waiter constructor
AnuyaWelling2801 Apr 15, 2024
e58f264
Added an erase and remove_if
AnuyaWelling2801 Apr 15, 2024
e134770
Adressing comments for profiling report, Adding profiling to default …
AnuyaWelling2801 Apr 24, 2024
6ce3b5e
Changes to std::chrono::duration
AnuyaWelling2801 Apr 25, 2024
a8ad96b
Addressed comments for sycl backend
AnuyaWelling2801 Apr 25, 2024
b70aeec
Addressed comments to sycl backend
AnuyaWelling2801 Apr 26, 2024
60710e2
Fix USM memory leaks and create unique task names (#1537)
SergeyKopienko Apr 26, 2024
1e76278
Fix the format of report method - using `report_duration` in second p…
SergeyKopienko Apr 26, 2024
c217e1a
Fixing clang format
AnuyaWelling2801 Apr 26, 2024
75dd226
Adding header file for backend_traits
AnuyaWelling2801 Apr 26, 2024
bc95cd2
Changed structure for sycl_backend submit
AnuyaWelling2801 Apr 26, 2024
19e78e7
Fixed clang format
AnuyaWelling2801 Apr 26, 2024
3d3dab2
Changes to make variables is_profiling_enabled and aliases for report…
AnuyaWelling2801 Apr 29, 2024
8009669
Moved is_profiling_enabled outside the async_waiter class
AnuyaWelling2801 Apr 29, 2024
ae46b12
Making sycl backend submit function more readable
AnuyaWelling2801 Apr 29, 2024
0cf0daa
Fixed clang format
AnuyaWelling2801 Apr 29, 2024
5028e63
Simplify sycl_backend::submit(SelectionHandle s, Function&& f, Args&&…
SergeyKopienko Apr 30, 2024
aa07b29
Minor changes to auto_tune_policy.h and sycl_backend.h
AnuyaWelling2801 Apr 30, 2024
797ea84
Improving readability
AnuyaWelling2801 Apr 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
#include <mutex>
#include <utility>
#include <chrono>
#include <ratio>
#include <limits>
#include <vector>
#include <type_traits>
#include <tuple>
#include <unordered_map>
#include "oneapi/dpl/internal/dynamic_selection_traits.h"
#include "oneapi/dpl/internal/dynamic_selection_impl/backend_traits.h"
#if _DS_BACKEND_SYCL != 0
# include "oneapi/dpl/internal/dynamic_selection_impl/sycl_backend.h"
#endif
Expand All @@ -47,13 +49,16 @@ class auto_tune_policy
using size_type = typename std::vector<typename Backend::resource_type>::size_type;
using timing_t = uint64_t;

using report_clock_type = std::chrono::steady_clock;
using report_duration = std::chrono::milliseconds;

SergeyKopienko marked this conversation as resolved.
Show resolved Hide resolved
static constexpr timing_t never_resample = 0;
static constexpr size_type use_best_resource = ~size_type(0);

struct resource_with_index_t
{
wrapped_resource_t r_;
size_type index_;
size_type index_ = 0;
};

struct time_data_t
Expand All @@ -66,7 +71,7 @@ class auto_tune_policy
{
std::mutex m_;

std::chrono::steady_clock::time_point t0_;
report_clock_type::time_point t0_;

timing_t best_timing_ = std::numeric_limits<timing_t>::max();
resource_with_index_t best_resource_;
Expand All @@ -80,7 +85,7 @@ class auto_tune_policy
timing_t resample_time_ = 0.0;

tuner_t(resource_with_index_t br, size_type resources_size, timing_t rt)
: t0_(std::chrono::steady_clock::now()), best_resource_(br), max_resource_to_profile_(resources_size),
: t0_(report_clock_type::now()), best_resource_(br), max_resource_to_profile_(resources_size),
resample_time_(rt)
{
}
Expand All @@ -100,8 +105,8 @@ class auto_tune_policy
}
else
{
auto now = std::chrono::steady_clock::now();
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(now - t0_).count();
const auto now = report_clock_type::now();
const auto ms = std::chrono::duration_cast<report_duration>(now - t0_).count();
if (ms < resample_time_)
{
return use_best_resource;
Expand Down Expand Up @@ -169,9 +174,9 @@ class auto_tune_policy
};

void
report(const execution_info::task_time_t&, const typename execution_info::task_time_t::value_type& v) const
report(const execution_info::task_time_t&, report_duration v) const
{
tuner_->add_new_timing(resource_, v);
tuner_->add_new_timing(resource_, v.count());
}
};

Expand Down Expand Up @@ -217,6 +222,10 @@ class auto_tune_policy
select(Function&& f, Args&&... args)
{
static_assert(sizeof...(KeyArgs) == sizeof...(Args));
if constexpr (backend_traits::lazy_report_v<Backend>)
{
backend_->lazy_report();
}
if (state_)
{
std::lock_guard<std::mutex> l(state_->m_);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Copyright (C) 2023 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _ONEDPL_INTERNAL_BACKEND_TRAITS_H
#define _ONEDPL_INTERNAL_BACKEND_TRAITS_H

#include <utility>
#include <type_traits>

namespace oneapi
{
namespace dpl
{
namespace experimental
{
namespace internal
{
template <typename Backend>
auto
has_lazy_report_impl(...) -> std::false_type;

template <typename Backend>
auto
has_lazy_report_impl(int) -> decltype(std::declval<Backend>().lazy_report(), std::true_type{});

template <typename Backend>
struct has_lazy_report : decltype(has_lazy_report_impl<Backend>(0))
{
};

} //namespace internal

namespace backend_traits
{
template <typename S>
struct lazy_report_value
{
static constexpr bool value = ::oneapi::dpl::experimental::internal::has_lazy_report<S>::value;
};
template <typename S>
inline constexpr bool lazy_report_v = lazy_report_value<S>::value;

} //namespace backend_traits

} // namespace experimental
} // namespace dpl
} // namespace oneapi

#endif /*_ONEDPL_INTERNAL_BACKEND_TRAITS_H*/
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <type_traits>
#include <utility>
#include "oneapi/dpl/internal/dynamic_selection_traits.h"
#include "oneapi/dpl/internal/dynamic_selection_impl/backend_traits.h"
#if _DS_BACKEND_SYCL != 0
# include "oneapi/dpl/internal/dynamic_selection_impl/sycl_backend.h"
#endif
Expand Down Expand Up @@ -150,6 +151,10 @@ struct dynamic_load_policy
selection_type
select(Args&&...)
{
if constexpr (backend_traits::lazy_report_v<Backend>)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnuyaWelling2801 Shouldn't this file need to include the backend_traits.h? Is it somehow including indirectly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend_traits.h file is being included indirectly since the tests include the file oneapi/dpl/dynamic_selection. This file includes auto_tune_policy,h (which contains the file backend_traits.h) before the file dynamic_load_policy.h

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

{
backend_->lazy_report();
}
if (state_)
{
std::lock_guard<std::mutex> l(state_->m_);
Expand Down
Loading
Loading