-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][ABI-break] Remove <iostream> headers from "sycl/sycl.hpp" and related files #6337
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
Changes from all commits
3fe426b
58ebf67
f2b5f89
1ba59dd
780cb9c
60cb520
06f3856
96ff86e
1f63594
de8792b
d64275a
3a66ee4
8ce2fe9
63e2155
6c85afe
3104b5f
786b793
8c49996
672176e
8513d2b
6d1e9b2
6b787df
3e16843
e13331b
7ec4559
f49ef6c
995bfa4
e137e4e
603791e
e241fc0
030acda
4152ca5
3d5aaef
00f14e6
49a7d63
d3af226
cdd4a54
9f7e3be
67d6459
8be9589
be34f48
949ec50
5e94fcf
0081330
f514b07
56d8eab
d141036
424b6b0
7119d2a
4a85979
71ea7ed
52a45da
1f6df1b
4deaffd
8657632
d890d56
31cf873
171094b
dc561f7
76cfc00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -12,7 +12,6 @@ | |||||||
#include <sycl/detail/defines.hpp> | ||||||||
#include <sycl/info/info_desc.hpp> | ||||||||
|
||||||||
#include <iostream> | ||||||||
#include <string> | ||||||||
|
||||||||
__SYCL_INLINE_NAMESPACE(cl) { | ||||||||
|
@@ -30,8 +29,7 @@ struct device_filter { | |||||||
|
||||||||
device_filter(){}; | ||||||||
device_filter(const std::string &FilterString); | ||||||||
friend std::ostream &operator<<(std::ostream &Out, | ||||||||
const device_filter &Filter); | ||||||||
inline operator std::string() const; | ||||||||
}; | ||||||||
|
||||||||
class device_filter_list { | ||||||||
|
@@ -47,37 +45,45 @@ class device_filter_list { | |||||||
bool deviceTypeCompatible(info::device_type DeviceType); | ||||||||
bool deviceNumberCompatible(int DeviceNum); | ||||||||
bool containsHost(); | ||||||||
friend std::ostream &operator<<(std::ostream &Out, | ||||||||
const device_filter_list &List); | ||||||||
inline operator std::string() const; | ||||||||
}; | ||||||||
|
||||||||
inline std::ostream &operator<<(std::ostream &Out, | ||||||||
const device_filter &Filter) { | ||||||||
Out << Filter.Backend << ":"; | ||||||||
if (Filter.DeviceType == info::device_type::host) { | ||||||||
Out << "host"; | ||||||||
} else if (Filter.DeviceType == info::device_type::cpu) { | ||||||||
Out << "cpu"; | ||||||||
} else if (Filter.DeviceType == info::device_type::gpu) { | ||||||||
Out << "gpu"; | ||||||||
} else if (Filter.DeviceType == info::device_type::accelerator) { | ||||||||
Out << "accelerator"; | ||||||||
} else if (Filter.DeviceType == info::device_type::all) { | ||||||||
Out << "*"; | ||||||||
} else { | ||||||||
Out << "unknown"; | ||||||||
inline device_filter::operator std::string() const { | ||||||||
std::string Out{}; | ||||||||
Out += backend_to_string(this->Backend); | ||||||||
Comment on lines
+52
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
Out += ":"; | ||||||||
switch (this->DeviceType) { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just out of curiosity: is |
||||||||
case info::device_type::host: | ||||||||
Out += "host"; | ||||||||
break; | ||||||||
case info::device_type::cpu: | ||||||||
Out += "cpu"; | ||||||||
break; | ||||||||
case info::device_type::gpu: | ||||||||
Out += "gpu"; | ||||||||
break; | ||||||||
case info::device_type::accelerator: | ||||||||
Out += "accelerator"; | ||||||||
break; | ||||||||
case info::device_type::all: | ||||||||
Out += "*"; | ||||||||
break; | ||||||||
default: | ||||||||
Out += "unknown"; | ||||||||
break; | ||||||||
} | ||||||||
if (Filter.HasDeviceNum) { | ||||||||
Out << ":" << Filter.DeviceNum; | ||||||||
|
||||||||
if (this->HasDeviceNum) { | ||||||||
Out += ":" + std::to_string(this->DeviceNum); | ||||||||
} | ||||||||
return Out; | ||||||||
} | ||||||||
|
||||||||
inline std::ostream &operator<<(std::ostream &Out, | ||||||||
const device_filter_list &List) { | ||||||||
for (const device_filter &Filter : List.FilterList) { | ||||||||
Out << Filter; | ||||||||
Out << ","; | ||||||||
inline device_filter_list::operator std::string() const { | ||||||||
std::string Out; | ||||||||
for (const device_filter &Filter : this->FilterList) { | ||||||||
Out += Filter; | ||||||||
Out += ","; | ||||||||
} | ||||||||
return Out; | ||||||||
} | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
#include <sycl/ext/oneapi/experimental/invoke_simd.hpp> | ||
|
||
#ifndef __SYCL_DEVICE_ONLY__ | ||
#include <iostream> | ||
#include <cstdio> | ||
#endif // __SYCL_DEVICE_ONLY__ | ||
|
||
__SYCL_INLINE_NAMESPACE(cl) { | ||
|
@@ -125,9 +125,30 @@ class simd : public detail::simd_obj_impl< | |
return sycl::ext::oneapi::experimental::simd<Ty, N1>(base_type::data()); | ||
} | ||
|
||
/// @ingroup sycl_esimd_misc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is wrong doc group. just drop it |
||
/// Prints a \c simd object to an output stream. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not what the code is doing now, it rather converts the object to std::string |
||
/// TODO: implemented for host code only. | ||
operator std::string() const | ||
#ifdef __SYCL_DEVICE_ONLY__ | ||
{} | ||
#else | ||
{ | ||
std::string OS; | ||
OS += "{"; | ||
for (int I = 0; I < N; I++) { | ||
OS += (*this)[I]; | ||
if (I < N - 1) | ||
OS += ","; | ||
} | ||
OS += "}"; | ||
return OS; | ||
} | ||
#endif // __SYCL_DEVICE_ONLY__ | ||
|
||
/// Prefix increment, increments elements of this object. | ||
/// @return Reference to this object. | ||
simd &operator++() { | ||
simd & | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please drop this change |
||
operator++() { | ||
*this += 1; | ||
return *this; | ||
} | ||
|
@@ -200,23 +221,3 @@ template <int N> using simd_mask = detail::simd_mask_type<N>; | |
|
||
} // namespace __ESIMD_NS | ||
} // __SYCL_INLINE_NAMESPACE(cl) | ||
|
||
/// @ingroup sycl_esimd_misc | ||
/// Prints a \c simd object to an output stream. | ||
/// TODO: implemented for host code only. | ||
template <typename Ty, int N> | ||
std::ostream &operator<<(std::ostream &OS, const __ESIMD_NS::simd<Ty, N> &V) | ||
#ifdef __SYCL_DEVICE_ONLY__ | ||
{} | ||
#else | ||
{ | ||
OS << "{"; | ||
for (int I = 0; I < N; I++) { | ||
OS << V[I]; | ||
if (I < N - 1) | ||
OS << ","; | ||
} | ||
OS << "}"; | ||
return OS; | ||
} | ||
#endif // __SYCL_DEVICE_ONLY__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raaiq1, please, add motivation for this change to the PR description. Right now it just describes what PR does, but doesn't explain why do we need this change.
I guess performance has something to do with it. Am I right?
FYI: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#slio3-prefer-iostreams-for-io
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main motivation behind it to abide by llvm coding standards, in this case it's avoid including <iostream> in library files: https://llvm.org/docs/CodingStandards.html#include-iostream-is-forbidden
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add such information to the pull request description. It's important context information for doing code review.