Skip to content

Commit f910c93

Browse files
committed
[SYCL][PI] Equality operator for PI plugins
Implemented a comparison operator for the plugin class in SYCL RT: Two plugins are equal if the pointer to their string is the same. plugin constructor marked explicit to avoid accidental implicit conversions. Signed-off-by: Ruyman Reyes <[email protected]>
1 parent aa384ae commit f910c93

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sycl/source/detail/plugin.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class plugin {
2323
public:
2424
plugin() = delete;
2525

26-
plugin(RT::PiPlugin Plugin) : MPlugin(Plugin) {
26+
explicit plugin(RT::PiPlugin Plugin) : MPlugin(Plugin) {
2727
MPiEnableTrace = (std::getenv("SYCL_PI_TRACE") != nullptr);
2828
}
2929

@@ -79,6 +79,17 @@ class plugin {
7979
bool MPiEnableTrace;
8080

8181
}; // class plugin
82+
83+
/// Two plugins are the same if their string is the same.
84+
/// There is no need to check the actual string, just the pointer, since
85+
/// there is only one instance of the PiPlugin struct per backend.
86+
///
87+
/// \ingroup sycl_pi
88+
///
89+
inline bool operator==(const plugin &lhs, const plugin &rhs) {
90+
return (lhs.getPiPlugin().PluginVersion == rhs.getPiPlugin().PluginVersion);
91+
}
92+
8293
} // namespace detail
8394
} // namespace sycl
8495
} // __SYCL_INLINE_NAMESPACE(cl)

0 commit comments

Comments
 (0)