Skip to content

Commit

Permalink
[SYCL] ABI-Neutralize graph API (#15694)
Browse files Browse the repository at this point in the history
print_graph should use sycl::string_view instead of std::string which is
not ABI-neutral.
  • Loading branch information
bso-intel authored Oct 21, 2024
1 parent 3c291ef commit b87d2a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
17 changes: 14 additions & 3 deletions sycl/include/sycl/ext/oneapi/experimental/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
#include <sycl/detail/kernel_desc.hpp> // for kernel_param_kind_t
#include <sycl/detail/property_helper.hpp> // for DataLessPropKind, PropWith...
#include <sycl/device.hpp> // for device
#include <sycl/nd_range.hpp> // for range, nd_range
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
#include <sycl/detail/string_view.hpp>
#endif
#include <sycl/device.hpp> // for device
#include <sycl/nd_range.hpp> // for range, nd_range
#include <sycl/properties/property_traits.hpp> // for is_property, is_property_of
#include <sycl/property_list.hpp> // for property_list

Expand Down Expand Up @@ -314,7 +317,13 @@ class __SYCL_EXPORT modifiable_command_graph {
/// @param path The path to write the DOT file to.
/// @param verbose If true, print additional information about the nodes such
/// as kernel args or memory access where applicable.
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
void print_graph(const std::string path, bool verbose = false) const {
print_graph(sycl::detail::string_view{path}, verbose);
}
#else
void print_graph(const std::string path, bool verbose = false) const;
#endif

/// Get a list of all nodes contained in this graph.
std::vector<node> get_nodes() const;
Expand Down Expand Up @@ -350,7 +359,9 @@ class __SYCL_EXPORT modifiable_command_graph {
sycl::detail::getSyclObjImpl(const Obj &SyclObject);
template <class T>
friend T sycl::detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
void print_graph(sycl::detail::string_view path, bool verbose = false) const;
#endif
std::shared_ptr<detail::graph_impl> impl;
};

Expand Down
10 changes: 10 additions & 0 deletions sycl/source/detail/graph_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include <detail/scheduler/commands.hpp>
#include <detail/sycl_mem_obj_t.hpp>
#include <sycl/detail/common.hpp>
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
#include <sycl/detail/string_view.hpp>
#endif
#include <sycl/feature_test.hpp>
#include <sycl/queue.hpp>

Expand Down Expand Up @@ -1680,8 +1683,15 @@ void modifiable_command_graph::end_recording(
}
}

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
void modifiable_command_graph::print_graph(sycl::detail::string_view pathstr,
#else
void modifiable_command_graph::print_graph(std::string path,
#endif
bool verbose) const {
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
std::string path{pathstr.data()};
#endif
graph_impl::ReadLock Lock(impl->MMutex);
if (path.substr(path.find_last_of(".") + 1) == "dot") {
impl->printGraphAsDot(path, verbose);
Expand Down

0 comments on commit b87d2a3

Please sign in to comment.