Skip to content

Commit

Permalink
[SYCL2020] Migrate information descriptors to their respective namesp…
Browse files Browse the repository at this point in the history
…aces (#987)

* Migrate context information descriptors interface

* Migrate device information descriptors interface

* Migrate event information descriptors interface

* Migrate kernel information descriptors interface

* Migrate platform information descriptors interface

* Migrate program information descriptors interface

* Migrate queue information descriptors interface

* Migrate generic information descriptors helper templates

* Flip max_work_item_sizes queries for select backends

* Use the new macro to define the device-specific kernel info descriptors

* Fix return type for max_work_item_sizes
  • Loading branch information
nmnobre authored May 3, 2023
1 parent ed3dbd2 commit d2bd9fc
Show file tree
Hide file tree
Showing 21 changed files with 230 additions and 396 deletions.
1 change: 1 addition & 0 deletions include/hipSYCL/runtime/hardware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enum class device_uint_property {
max_global_size0,
max_global_size1,
max_global_size2,
needs_dimension_flip,
max_group_size0,
max_group_size1,
max_group_size2,
Expand Down
4 changes: 2 additions & 2 deletions include/hipSYCL/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ class context
return devs;
}

template <info::context param>
typename info::param_traits<info::context, param>::return_type get_info() const {
template <typename Param>
typename Param::return_type get_info() const {
throw unimplemented{"context::get_info() is unimplemented"};
}

Expand Down
35 changes: 29 additions & 6 deletions include/hipSYCL/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "backend.hpp"
#include "exception.hpp"
#include "version.hpp"
#include "hipSYCL/sycl/libkernel/id.hpp"
#include "hipSYCL/sycl/libkernel/range.hpp"

#include "hipSYCL/runtime/device_id.hpp"
#include "hipSYCL/runtime/application.hpp"
Expand Down Expand Up @@ -180,9 +180,8 @@ class device {
// Implemented in platform.hpp
platform get_platform() const;

template <info::device param>
typename info::param_traits<info::device, param>::return_type
get_info() const;
template <typename Param>
typename Param::return_type get_info() const;

bool has_extension(const string_class &extension) const
{
Expand Down Expand Up @@ -312,15 +311,39 @@ HIPSYCL_SPECIALIZE_GET_INFO(device, max_compute_units)
HIPSYCL_SPECIALIZE_GET_INFO(device, max_work_item_dimensions)
{ return 3; }

HIPSYCL_SPECIALIZE_GET_INFO(device, max_work_item_sizes)
HIPSYCL_SPECIALIZE_GET_INFO(device, max_work_item_sizes<1>)
{
std::size_t size0 = static_cast<std::size_t>(get_rt_device()->get_property(
rt::device_uint_property::max_group_size0));
return range<1>{size0};
}

HIPSYCL_SPECIALIZE_GET_INFO(device, max_work_item_sizes<2>)
{
std::size_t size0 = static_cast<std::size_t>(get_rt_device()->get_property(
rt::device_uint_property::max_group_size0));
std::size_t size1 = static_cast<std::size_t>(get_rt_device()->get_property(
rt::device_uint_property::max_group_size1));
if (get_rt_device()->get_property(
rt::device_uint_property::needs_dimension_flip))
return range<2>{size1, size0};
else
return range<2>{size0, size1};
}

HIPSYCL_SPECIALIZE_GET_INFO(device, max_work_item_sizes<3>)
{
std::size_t size0 = static_cast<std::size_t>(get_rt_device()->get_property(
rt::device_uint_property::max_group_size0));
std::size_t size1 = static_cast<std::size_t>(get_rt_device()->get_property(
rt::device_uint_property::max_group_size1));
std::size_t size2 = static_cast<std::size_t>(get_rt_device()->get_property(
rt::device_uint_property::max_group_size2));
return id<3>{size0, size1, size2};
if (get_rt_device()->get_property(
rt::device_uint_property::needs_dimension_flip))
return range<3>{size2, size1, size0};
else
return range<3>{size0, size1, size2};
}

HIPSYCL_SPECIALIZE_GET_INFO(device, max_work_group_size)
Expand Down
14 changes: 7 additions & 7 deletions include/hipSYCL/sycl/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ class event {
glue::throw_asynchronous_errors(eventList.front()._handler);
}

template <info::event param>
typename info::param_traits<info::event, param>::return_type get_info() const;
template <typename Param>
typename Param::return_type get_info() const;

// Wait for and retrieve profiling timestamps. Supports all handler operations except
// handler::require() and handler::update_host().
// Will throw sycl::invalid_object_error unless the queue was constructed with
// `property::queue::enable_profiling`.
// Timestamps are returned in std::chrono::system_clock nanoseconds-since-epoch.
template <info::event_profiling param>
typename info::param_traits<info::event_profiling, param>::return_type get_profiling_info() const
template <typename Param>
typename Param::return_type get_profiling_info() const
{
if(!_node) {
throw invalid_object_error{rt::make_error(
Expand Down Expand Up @@ -171,7 +171,7 @@ class event {
rt::error_type::invalid_object_error})};
}

if (param == info::event_profiling::command_submit) {
if (std::is_same_v<Param, info::event_profiling::command_submit>) {
auto submission =
_node->get_operation()
->get_instrumentations()
Expand All @@ -182,7 +182,7 @@ class event {
"Operation not profiled: No submission timestamp available");

return rt::profiler_clock::ns_ticks(submission->get_time_point());
} else if (param == info::event_profiling::command_start) {
} else if (std::is_same_v<Param, info::event_profiling::command_start>) {
auto start =
_node->get_operation()
->get_instrumentations()
Expand All @@ -193,7 +193,7 @@ class event {
"Operation not profiled: No execution start timestamp available");

return rt::profiler_clock::ns_ticks(start->get_time_point());
} else if (param == info::event_profiling::command_end) {
} else if (std::is_same_v<Param, info::event_profiling::command_end>) {
auto finish =
_node->get_operation()
->get_instrumentations()
Expand Down
22 changes: 5 additions & 17 deletions include/hipSYCL/sycl/info/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#ifndef HIPSYCL_INFO_CONTEXT_HPP
#define HIPSYCL_INFO_CONTEXT_HPP

#include "info.hpp"
#include "../types.hpp"
#include "param_traits.hpp"

namespace hipsycl {
namespace sycl {
Expand All @@ -40,24 +40,12 @@ class device;

namespace info {

enum class context : int {
reference_count,
platform,
devices
namespace context {
HIPSYCL_DEFINE_INFO_DESCRIPTOR(reference_count, detail::u_int);
HIPSYCL_DEFINE_INFO_DESCRIPTOR(platform, sycl::platform);
HIPSYCL_DEFINE_INFO_DESCRIPTOR(devices, vector_class<sycl::device>);
};

HIPSYCL_PARAM_TRAIT_RETURN_VALUE(context,
context::reference_count,
detail::u_int);

HIPSYCL_PARAM_TRAIT_RETURN_VALUE(context,
context::platform,
sycl::platform);

HIPSYCL_PARAM_TRAIT_RETURN_VALUE(context,
context::devices,
vector_class<sycl::device>);

}
}
}
Expand Down
Loading

0 comments on commit d2bd9fc

Please sign in to comment.