Skip to content

Commit 3fe426b

Browse files
committed
replaced cout|cin|clog with respective c counterparts to remove <iostream> in headers
1 parent d1f1698 commit 3fe426b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+712
-576
lines changed

sycl/include/CL/sycl/backend_types.hpp

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum class backend : char {
3131
esimd_cpu __SYCL2020_DEPRECATED("use 'ext_oneapi_esimd_emulator' instead") =
3232
ext_intel_esimd_emulator,
3333
ext_oneapi_hip = 6,
34-
hip __SYCL2020_DEPRECATED("use 'ext_oneapi_hip' instead") = ext_oneapi_hip,
34+
hip __SYCL2020_DEPRECATED("use 'ext_oneapi_hip' instead") = ext_oneapi_hip
3535
};
3636

3737
template <backend Backend> class backend_traits;
@@ -42,32 +42,59 @@ using backend_input_t =
4242
template <backend Backend, typename SYCLObjectT>
4343
using backend_return_t =
4444
typename backend_traits<Backend>::template return_type<SYCLObjectT>;
45+
46+
inline std::string backend_to_string(const backend& be) {
4547

46-
inline std::ostream &operator<<(std::ostream &Out, backend be) {
47-
switch (be) {
48+
std::string Out="";
49+
switch (be) {
4850
case backend::host:
49-
Out << "host";
51+
Out+= "host";
5052
break;
5153
case backend::opencl:
52-
Out << "opencl";
54+
Out+= "opencl";
5355
break;
5456
case backend::ext_oneapi_level_zero:
55-
Out << "ext_oneapi_level_zero";
57+
Out+= "ext_oneapi_level_zero";
5658
break;
5759
case backend::ext_oneapi_cuda:
58-
Out << "ext_oneapi_cuda";
60+
Out+= "ext_oneapi_cuda";
5961
break;
6062
case backend::ext_intel_esimd_emulator:
61-
Out << "ext_intel_esimd_emulator";
63+
Out+= "ext_intel_esimd_emulator";
6264
break;
6365
case backend::ext_oneapi_hip:
64-
Out << "ext_oneapi_hip";
66+
Out+= "ext_oneapi_hip";
6567
break;
6668
case backend::all:
67-
Out << "all";
69+
Out+= "all";
6870
}
6971
return Out;
7072
}
73+
// inline std::ostream &operator<<(std::ostream &Out, backend be) {
74+
// switch (be) {
75+
// case backend::host:
76+
// Out << "host";
77+
// break;
78+
// case backend::opencl:
79+
// Out << "opencl";
80+
// break;
81+
// case backend::ext_oneapi_level_zero:
82+
// Out << "ext_oneapi_level_zero";
83+
// break;
84+
// case backend::ext_oneapi_cuda:
85+
// Out << "ext_oneapi_cuda";
86+
// break;
87+
// case backend::ext_intel_esimd_emulator:
88+
// Out << "ext_intel_esimd_emulator";
89+
// break;
90+
// case backend::ext_oneapi_hip:
91+
// Out << "ext_oneapi_hip";
92+
// break;
93+
// case backend::all:
94+
// Out << "all";
95+
// }
96+
// return Out;
97+
// }
7198

7299
} // namespace sycl
73100
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/CL/sycl/detail/common.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,13 @@ static inline std::string codeToString(cl_int code) {
116116
"Native API returns: "
117117

118118
#ifndef __SYCL_SUPPRESS_OCL_ERROR_REPORT
119-
#include <iostream>
120119
// TODO: rename all names with direct use of OCL/OPENCL to be backend agnostic.
121120
#define __SYCL_REPORT_OCL_ERR_TO_STREAM(expr) \
122121
{ \
123122
auto code = expr; \
124123
if (code != CL_SUCCESS) { \
125-
std::cerr << __SYCL_OCL_ERROR_REPORT \
126-
<< cl::sycl::detail::codeToString(code) << std::endl; \
124+
fprintf(stderr,"%s%s\n",__SYCL_OCL_ERROR_REPORT \
125+
, cl::sycl::detail::codeToString(code).c_str()); \
127126
} \
128127
}
129128
#endif

sycl/include/CL/sycl/detail/device_binary_image.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class RTDeviceBinaryImage : public pi::DeviceBinaryImage {
4343

4444
void print() const override {
4545
pi::DeviceBinaryImage::print();
46-
std::cerr << " OSModuleHandle=" << ModuleHandle << "\n";
46+
fprintf(stderr," OSModuleHandle=%ld\n",ModuleHandle);
4747
}
4848

4949
protected:
@@ -60,7 +60,7 @@ class DynRTDeviceBinaryImage : public RTDeviceBinaryImage {
6060

6161
void print() const override {
6262
RTDeviceBinaryImage::print();
63-
std::cerr << " DYNAMICALLY CREATED\n";
63+
fprintf(stderr," DYNAMICALLY CREATED\n");
6464
}
6565

6666
protected:

sycl/include/CL/sycl/detail/device_filter.hpp

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
10+
//Todo: Have iostream replacements
911
#pragma once
1012

1113
#include <CL/sycl/backend_types.hpp>
1214
#include <CL/sycl/detail/defines.hpp>
1315
#include <CL/sycl/info/info_desc.hpp>
1416

15-
#include <iostream>
17+
//#include <iostream>
1618
#include <string>
1719

1820
__SYCL_INLINE_NAMESPACE(cl) {
@@ -30,8 +32,10 @@ struct device_filter {
3032

3133
device_filter(){};
3234
device_filter(const std::string &FilterString);
33-
friend std::ostream &operator<<(std::ostream &Out,
34-
const device_filter &Filter);
35+
// friend std::ostream &operator<<(std::ostream &Out,
36+
// const device_filter &Filter);
37+
inline operator std::string()const;
38+
3539
};
3640

3741
class device_filter_list {
@@ -47,41 +51,75 @@ class device_filter_list {
4751
bool deviceTypeCompatible(info::device_type DeviceType);
4852
bool deviceNumberCompatible(int DeviceNum);
4953
bool containsHost();
50-
friend std::ostream &operator<<(std::ostream &Out,
51-
const device_filter_list &List);
54+
// friend std::ostream &operator<<(std::ostream &Out,
55+
// const device_filter_list &List);
56+
inline operator std::string()const;
5257
};
5358

54-
inline std::ostream &operator<<(std::ostream &Out,
55-
const device_filter &Filter) {
56-
Out << Filter.Backend << ":";
57-
if (Filter.DeviceType == info::device_type::host) {
58-
Out << "host";
59-
} else if (Filter.DeviceType == info::device_type::cpu) {
60-
Out << "cpu";
61-
} else if (Filter.DeviceType == info::device_type::gpu) {
62-
Out << "gpu";
63-
} else if (Filter.DeviceType == info::device_type::accelerator) {
64-
Out << "accelerator";
65-
} else if (Filter.DeviceType == info::device_type::all) {
66-
Out << "*";
67-
} else {
68-
Out << "unknown";
69-
}
70-
if (Filter.HasDeviceNum) {
71-
Out << ":" << Filter.DeviceNum;
72-
}
73-
return Out;
59+
inline device_filter::operator std::string() const {
60+
std::string Out{};
61+
Out+= backend_to_string(this->Backend);
62+
Out+= ":";
63+
if (this->DeviceType == info::device_type::host) {
64+
Out += "host";
65+
} else if (this->DeviceType == info::device_type::cpu) {
66+
Out += "cpu";
67+
} else if (this->DeviceType == info::device_type::gpu) {
68+
Out += "gpu";
69+
} else if (this->DeviceType == info::device_type::accelerator) {
70+
Out += "accelerator";
71+
} else if (this->DeviceType == info::device_type::all) {
72+
Out += "*";
73+
} else {
74+
Out += "unknown";
75+
}
76+
if (this->HasDeviceNum) {
77+
Out += ":";
78+
Out += this->DeviceNum;
79+
}
80+
return Out;
7481
}
7582

76-
inline std::ostream &operator<<(std::ostream &Out,
77-
const device_filter_list &List) {
78-
for (const device_filter &Filter : List.FilterList) {
79-
Out << Filter;
80-
Out << ",";
81-
}
83+
// inline std::ostream &operator<<(std::ostream &Out,
84+
// const device_filter &Filter) {
85+
// Out << Filter.Backend << ":";
86+
// if (Filter.DeviceType == info::device_type::host) {
87+
// Out << "host";
88+
// } else if (Filter.DeviceType == info::device_type::cpu) {
89+
// Out << "cpu";
90+
// } else if (Filter.DeviceType == info::device_type::gpu) {
91+
// Out << "gpu";
92+
// } else if (Filter.DeviceType == info::device_type::accelerator) {
93+
// Out << "accelerator";
94+
// } else if (Filter.DeviceType == info::device_type::all) {
95+
// Out << "*";
96+
// } else {
97+
// Out << "unknown";
98+
// }
99+
// if (Filter.HasDeviceNum) {
100+
// Out << ":" << Filter.DeviceNum;
101+
// }
102+
// return Out;
103+
// }
104+
105+
inline device_filter_list::operator std::string()const{
106+
std::string Out;
107+
for (const device_filter &Filter : this->FilterList) {
108+
Out += Filter;
109+
Out += ",";
110+
}
82111
return Out;
83112
}
84113

114+
// inline std::ostream &operator<<(std::ostream &Out,
115+
// const device_filter_list &List) {
116+
// for (const device_filter &Filter : List.FilterList) {
117+
// Out << Filter;
118+
// Out << ",";
119+
// }
120+
// return Out;
121+
// }
122+
85123
} // namespace detail
86124
} // namespace sycl
87125
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/CL/sycl/detail/image_accessor_util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <CL/sycl/types.hpp>
2121

2222
#include <cmath>
23-
#include <iostream>
23+
//#include <iostream>
2424

2525
__SYCL_INLINE_NAMESPACE(cl) {
2626
namespace sycl {

sycl/include/CL/sycl/detail/pi.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,15 @@ class DeviceBinaryProperty {
232232
pi_uint32 asUint32() const;
233233
ByteArray asByteArray() const;
234234
const char *asCString() const;
235+
operator std::string()const;
235236

236237
protected:
237-
friend std::ostream &operator<<(std::ostream &Out,
238-
const DeviceBinaryProperty &P);
238+
// friend std::ostream &operator<<(std::ostream &Out,
239+
// const DeviceBinaryProperty &P);
239240
const _pi_device_binary_property_struct *Prop;
240241
};
241242

242-
std::ostream &operator<<(std::ostream &Out, const DeviceBinaryProperty &P);
243+
//std::ostream &operator<<(std::ostream &Out, const DeviceBinaryProperty &P);
243244

244245
// C++ convenience wrapper over the pi_device_binary_struct structure.
245246
class DeviceBinaryImage {
@@ -298,7 +299,7 @@ class DeviceBinaryImage {
298299
DeviceBinaryImage() : Bin(nullptr){};
299300

300301
virtual void print() const;
301-
virtual void dump(std::ostream &Out) const;
302+
virtual void dump(FILE* file) const;
302303

303304
size_t getSize() const {
304305
assert(Bin && "binary image data not set");

sycl/include/CL/sycl/half_type.hpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <CL/sycl/detail/type_traits.hpp>
1414

1515
#include <functional>
16-
#include <iostream>
16+
// #include <iostream>
1717
#include <limits>
1818

1919
#if !__has_builtin(__builtin_expect)
@@ -143,7 +143,8 @@ class __SYCL_EXPORT half {
143143
half(const float &rhs);
144144

145145
half &operator=(const half &rhs) = default;
146-
146+
// string operator
147+
inline operator std::string()const;
147148
// Operator +=, -=, *=, /=
148149
half &operator+=(const half &rhs);
149150

@@ -693,18 +694,28 @@ template <> struct numeric_limits<cl::sycl::half> {
693694
};
694695

695696
} // namespace std
696-
697-
inline std::ostream &operator<<(std::ostream &O, cl::sycl::half const &rhs) {
698-
O << static_cast<float>(rhs);
699-
return O;
697+
inline FILE* operator<<(FILE* file,cl::sycl::half const &rhs){
698+
fprintf(file,"%lf",static_cast<float>(rhs));
699+
return file;
700700
}
701701

702-
inline std::istream &operator>>(std::istream &I, cl::sycl::half &rhs) {
702+
// inline std::ostream &operator<<(std::ostream &O, cl::sycl::half const &rhs) {
703+
// O << static_cast<float>(rhs);
704+
// return O;
705+
// }
706+
707+
inline FILE* operator>>(FILE* file,cl::sycl::half &rhs){
703708
float ValFloat = 0.0f;
704-
I >> ValFloat;
705-
rhs = ValFloat;
706-
return I;
709+
fscanf(file,"%f",&ValFloat);
710+
rhs=ValFloat;
711+
return file;
707712
}
713+
// inline std::istream &operator>>(std::istream &I, cl::sycl::half &rhs) {
714+
// float ValFloat = 0.0f;
715+
// I >> ValFloat;
716+
// rhs = ValFloat;
717+
// return I;
718+
// }
708719

709720
#undef __SYCL_CONSTEXPR_HALF
710721
#undef _CPP14_CONSTEXPR

sycl/include/CL/sycl/handler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,8 @@ class __SYCL_EXPORT handler {
10141014
size_t NewValX =
10151015
((NumWorkItems[0] + GoodFactorX - 1) / GoodFactorX) * GoodFactorX;
10161016
if (this->RangeRoundingTrace())
1017-
std::cout << "parallel_for range adjusted from " << NumWorkItems[0]
1018-
<< " to " << NewValX << std::endl;
1017+
printf("parallel_for range adjusted from %lu%s%lu\n",NumWorkItems[0]
1018+
," to ",NewValX);
10191019

10201020
using NameWT = typename detail::get_kernel_wrapper_name_t<NameT>::name;
10211021
auto Wrapper =

sycl/include/CL/sycl/types.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,9 +826,9 @@ template <typename Type, int NumElements> class vec {
826826
void dump() {
827827
#ifndef __SYCL_DEVICE_ONLY__
828828
for (int I = 0; I < NumElements; ++I) {
829-
std::cout << " " << I << ": " << getValue(I) << std::endl;
829+
printf(" %d: %d\n",I,getValue(I));
830830
}
831-
std::cout << std::endl;
831+
printf("\n");
832832
#endif // __SYCL_DEVICE_ONLY__
833833
}
834834

sycl/include/sycl/ext/intel/esimd/detail/elem_type_traits.hpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -714,17 +714,18 @@ template <>
714714
struct is_esimd_arithmetic_type<__raw_t<sycl::half>, void> : std::true_type {};
715715

716716
// Misc
717-
inline std::ostream &operator<<(std::ostream &O, sycl::half const &rhs) {
718-
O << static_cast<float>(rhs);
719-
return O;
720-
}
721-
722-
inline std::istream &operator>>(std::istream &I, sycl::half &rhs) {
723-
float ValFloat = 0.0f;
724-
I >> ValFloat;
725-
rhs = ValFloat;
726-
return I;
727-
}
717+
//TODO: Delete definitions duplicate from half_type.hpp
718+
// inline std::ostream &operator<<(std::ostream &O, sycl::half const &rhs) {
719+
// O << static_cast<float>(rhs);
720+
// return O;
721+
// }
722+
723+
// inline std::istream &operator>>(std::istream &I, sycl::half &rhs) {
724+
// float ValFloat = 0.0f;
725+
// I >> ValFloat;
726+
// rhs = ValFloat;
727+
// return I;
728+
// }
728729

729730
// The only other place which needs to be updated to support a new type is
730731
// the is_wrapper_elem_type_v meta function.

0 commit comments

Comments
 (0)