Skip to content

[SYCL] Remove <iostream> from header and source files #6469

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

Merged
merged 19 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sycl/include/sycl/backend_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#pragma once

#include <sycl/detail/defines.hpp>
#include <sycl/detail/iostream_proxy.hpp>

#include <fstream>
#include <iostream>
#include <istream>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static inline std::string codeToString(pi_int32 code) {
"Native API returns: "

#ifndef __SYCL_SUPPRESS_PI_ERROR_REPORT
#include <iostream>
#include <sycl/detail/iostream_proxy.hpp>
// TODO: rename all names with direct use of OCL/OPENCL to be backend agnostic.
#define __SYCL_REPORT_PI_ERR_TO_STREAM(expr) \
{ \
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/detail/device_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include <sycl/backend_types.hpp>
#include <sycl/detail/defines.hpp>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/info/info_desc.hpp>

#include <iostream>
#include <string>

__SYCL_INLINE_NAMESPACE(cl) {
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/detail/image_accessor_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#include <sycl/builtins.hpp>
#include <sycl/detail/export.hpp>
#include <sycl/detail/generic_type_traits.hpp>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/image.hpp>
#include <sycl/sampler.hpp>
#include <sycl/types.hpp>

#include <cmath>
#include <iostream>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
Expand Down
10 changes: 10 additions & 0 deletions sycl/include/sycl/detail/iostream_proxy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once
#include <istream>
#include <ostream>

namespace std {
extern istream cin; /// Linked to standard input
extern ostream cout; /// Linked to standard output
extern ostream cerr; /// Linked to standard error (unbuffered)
extern ostream clog; /// Linked to standard error (buffered)
} // namespace std
2 changes: 1 addition & 1 deletion sycl/include/sycl/ext/intel/esimd/simd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <sycl/ext/oneapi/experimental/invoke_simd.hpp>

#ifndef __SYCL_DEVICE_ONLY__
#include <iostream>
#include <sycl/detail/iostream_proxy.hpp>
#endif // __SYCL_DEVICE_ONLY__

__SYCL_INLINE_NAMESPACE(cl) {
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/half_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

#include <sycl/detail/defines.hpp>
#include <sycl/detail/export.hpp>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/detail/type_traits.hpp>

#include <functional>
#include <iostream>
#include <limits>

#if !__has_builtin(__builtin_expect)
Expand Down
1 change: 1 addition & 0 deletions sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <string>
Expand Down
5 changes: 3 additions & 2 deletions sycl/plugins/esimd_emulator/pi_esimd_emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

#pragma once

#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/detail/pi.h>

#include <atomic>
#include <cassert>
#include <iostream>
#include <mutex>
#include <sycl/detail/pi.h>
#include <unordered_map>

#include <malloc.h>
Expand Down
2 changes: 1 addition & 1 deletion sycl/plugins/level_zero/pi_level_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <cassert>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
Expand All @@ -43,6 +42,7 @@

#include <level_zero/ze_api.h>
#include <level_zero/zes_api.h>
#include <sycl/detail/iostream_proxy.hpp>

#include "usm_allocator.hpp"

Expand Down
2 changes: 1 addition & 1 deletion sycl/plugins/level_zero/tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <level_zero/ze_api.h>
#include <xpti/xpti_trace_framework.h>

#include <iostream>
#include <sycl/detail/iostream_proxy.hpp>

constexpr auto ZE_CALL_STREAM_NAME = "sycl.experimental.level_zero.call";
constexpr auto ZE_DEBUG_STREAM_NAME = "sycl.experimental.level_zero.debug";
Expand Down
3 changes: 1 addition & 2 deletions sycl/plugins/level_zero/usm_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <cassert>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <list>
#include <memory>
#include <mutex>
Expand All @@ -23,7 +22,7 @@
#include <vector>

#include "usm_allocator.hpp"
#include <iostream>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/detail/spinlock.hpp>

// USM allocations are a minimum of 4KB/64KB/2MB even when a smaller size is
Expand Down
2 changes: 1 addition & 1 deletion sycl/plugins/opencl/pi_opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

#include <pi_opencl.hpp>
#include <sycl/detail/cl.h>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/detail/pi.h>

#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <sstream>
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include <detail/config.hpp>
#include <sycl/detail/common.hpp>
#include <sycl/detail/defines_elementary.hpp>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/detail/os_util.hpp>

#include <cstring>
#include <fstream>
#include <iostream>
#include <limits>

__SYCL_INLINE_NAMESPACE(cl) {
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/spec_constant_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include <detail/spec_constant_impl.hpp>

#include <sycl/detail/defines.hpp>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/detail/pi.h>
#include <sycl/detail/util.hpp>
#include <sycl/exception.hpp>

#include <cstring>
#include <iostream>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/spec_constant_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#pragma once

#include <sycl/detail/defines.hpp>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/detail/util.hpp>
#include <sycl/stl.hpp>

#include <iostream>
#include <map>
#include <vector>

Expand Down
5 changes: 5 additions & 0 deletions sycl/test/basic_tests/iostream_clean_compile_1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: %clangxx -Wno-unused-command-line-argument -Werror -fsycl %s -c

#include <iostream>
#include <sycl/sycl.hpp>
void foo() { std::cout << 42; }
7 changes: 7 additions & 0 deletions sycl/test/basic_tests/iostream_clean_compile_2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: %clangxx -Wno-unused-command-line-argument -Werror -fsycl %s -c

// clang-format off
#include <sycl/sycl.hpp>
#include <iostream>
// clang-format on
void foo() { std::cout << 42; }
6 changes: 6 additions & 0 deletions sycl/test/basic_tests/no_iostream.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %clangxx -fsycl %s -S -emit-llvm -o- | FileCheck %s
// CHECK-NOT: {{^@}}
//
// Tests if <sycl/sycl.hpp> headers include any <iostream> headers

#include <sycl/sycl.hpp>