Skip to content

Commit c0483d7

Browse files
authored
[SYCL][NFC] Update includes in DPC++ headers. (#10648)
These changes were done in semi-automatic mode by [include what you use](https://github.com/include-what-you-use/include-what-you-use/) tool. The caveat is that this tool doesn't support SYCL compilation mode, so it analyses only host code and I had to manually adjust includes for the device compilation. The tool annotated each include with the symbols declared in the included header and used in the code. I tired to apply following structure to includes where it's possible: ```c++ // <copyright header> #pragma once #include "local/includes" #include <sycl/includes> #ifdef .. #include <conditional/includes> #endif #include <standard_library> ``` Removed sycl/include/sycl/detail/sycl_fe_intrins.hpp and sycl/include/sycl/detail/service_kernel_names.hpp - declarations from these headers are used only once, so there is sense in moving them to a separate headers. I've put a few comments for follow-up actions: 1. sycl/include/sycl/handler.hpp includes 57 headers, which seems to much. 2. sycl/include/sycl/info/info_desc.hpp and sycl/include/sycl/detail/info_desc_helpers.hpp - includes .def files, which depend on previous includes, doesn't sound like a good idea. 3. sycl/include/sycl/detail/kernel_desc.hpp - uses __SYCL_EXPORT, which doesn't sounds right to me, but I might be missing something.
1 parent 4fa03a8 commit c0483d7

File tree

168 files changed

+1632
-946
lines changed

Some content is hidden

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

168 files changed

+1632
-946
lines changed

sycl/include/CL/__spirv/spirv_ops.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88

99
#pragma once
1010

11-
#include <CL/__spirv/spirv_types.hpp>
12-
#include <sycl/detail/defines_elementary.hpp>
13-
#include <sycl/detail/export.hpp>
11+
#include <CL/__spirv/spirv_types.hpp> // for Scope, __ocl_event_t
12+
#include <sycl/detail/defines_elementary.hpp> // for __DPCPP_SYCL_EXTERNAL
13+
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
14+
15+
#include <stddef.h> // for size_t
16+
#include <stdint.h> // for uint32_t
1417

1518
// Convergent attribute
1619
#ifdef __SYCL_DEVICE_ONLY__

sycl/include/CL/__spirv/spirv_types.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
#pragma once
1010

11-
#include <sycl/detail/defines_elementary.hpp>
12-
#include <sycl/half_type.hpp>
11+
#include <sycl/detail/defines.hpp> // for SYCL_EXT_ONEAPI_MATRIX_VERSION
12+
#include <sycl/half_type.hpp> // for half
1313

14-
#include <complex>
15-
#include <cstddef>
16-
#include <cstdint>
14+
#include <complex> // for complex
15+
#include <cstddef> // for size_t
16+
#include <cstdint> // for uint32_t
1717

1818
// TODO: include the header file with SPIR-V declarations from SPIRV-Headers
1919
// project.

sycl/include/CL/__spirv/spirv_vars.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
#pragma once
1010

11-
#include <cstddef>
12-
#include <cstdint>
13-
1411
#ifdef __SYCL_DEVICE_ONLY__
1512

13+
#include <sycl/detail/defines_elementary.hpp> // for __DPCPP_SYCL_EXTERNAL
14+
15+
#include <cstddef> // for size_t
16+
#include <cstdint> // for uint8_t
17+
1618
#define __SPIRV_VAR_QUALIFIERS extern "C" const
1719

1820
#if defined(__NVPTX__) || defined(__AMDGCN__)

sycl/include/sycl/access/access.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8+
89
#pragma once
910

11+
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
12+
13+
#ifdef __SYCL_DEVICE_ONLY__
1014
#include <CL/__spirv/spirv_ops.hpp>
11-
#include <sycl/detail/common.hpp>
12-
#include <sycl/detail/defines.hpp>
15+
#include <type_traits>
16+
#endif
1317

1418
namespace sycl {
1519
inline namespace _V1 {

sycl/include/sycl/accessor.hpp

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,56 @@
88

99
#pragma once
1010

11-
#include <CL/__spirv/spirv_types.hpp>
12-
#include <sycl/atomic.hpp>
13-
#include <sycl/buffer.hpp>
14-
#include <sycl/detail/accessor_iterator.hpp>
15-
#include <sycl/detail/cl.h>
16-
#include <sycl/detail/common.hpp>
17-
#include <sycl/detail/export.hpp>
18-
#include <sycl/detail/generic_type_traits.hpp>
19-
#include <sycl/detail/handler_proxy.hpp>
20-
#include <sycl/detail/image_accessor_util.hpp>
11+
#include <sycl/access/access.hpp> // for target, mode
12+
#include <sycl/aliases.hpp> // for float4, int4
13+
#include <sycl/aspects.hpp> // for aspect
14+
#include <sycl/atomic.hpp> // for atomic
15+
#include <sycl/buffer.hpp> // for range
16+
#include <sycl/detail/accessor_iterator.hpp> // for accessor_iterator
17+
#include <sycl/detail/common.hpp> // for code_location
18+
#include <sycl/detail/defines.hpp> // for __SYCL_SPECIAL...
19+
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEP...
20+
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
21+
#include <sycl/detail/generic_type_traits.hpp> // for is_genint, Try...
22+
#include <sycl/detail/handler_proxy.hpp> // for associateWithH...
23+
#include <sycl/detail/helpers.hpp> // for loop
24+
#include <sycl/detail/image_accessor_util.hpp> // for imageReadSampl...
25+
#include <sycl/detail/owner_less_base.hpp> // for OwnerLessBase
26+
#include <sycl/detail/pi.h> // for PI_ERROR_INVAL...
27+
#include <sycl/detail/property_helper.hpp> // for PropWithDataKind
28+
#include <sycl/detail/property_list_base.hpp> // for PropertyListBase
29+
#include <sycl/detail/type_list.hpp> // for is_contained
30+
#include <sycl/detail/type_traits.hpp> // for const_if_const_AS
31+
#include <sycl/device.hpp> // for device
32+
#include <sycl/exception.hpp> // for make_error_code
33+
#include <sycl/ext/oneapi/accessor_property_list.hpp> // for accessor_prope...
34+
#include <sycl/ext/oneapi/weak_object_base.hpp> // for getSyclWeakObj...
35+
#include <sycl/id.hpp> // for id
36+
#include <sycl/image.hpp> // for image, image_c...
37+
#include <sycl/multi_ptr.hpp> // for multi_ptr
38+
#include <sycl/pointers.hpp> // for local_ptr, glo...
39+
#include <sycl/properties/accessor_properties.hpp> // for buffer_location
40+
#include <sycl/properties/buffer_properties.hpp> // for buffer, buffer...
41+
#include <sycl/property_list.hpp> // for property_list
42+
#include <sycl/range.hpp> // for range
43+
#include <sycl/sampler.hpp> // for addressing_mode
44+
#include <sycl/types.hpp> // for vec
45+
46+
#ifdef __SYCL_DEVICE_ONLY__
2147
#include <sycl/detail/image_ocl_types.hpp>
22-
#include <sycl/detail/owner_less_base.hpp>
23-
#include <sycl/device.hpp>
24-
#include <sycl/exception.hpp>
25-
#include <sycl/ext/oneapi/accessor_property_list.hpp>
26-
#include <sycl/ext/oneapi/weak_object_base.hpp>
27-
#include <sycl/id.hpp>
28-
#include <sycl/image.hpp>
29-
#include <sycl/pointers.hpp>
30-
#include <sycl/properties/accessor_properties.hpp>
31-
#include <sycl/properties/buffer_properties.hpp>
32-
#include <sycl/property_list.hpp>
33-
#include <sycl/property_list_conversion.hpp>
34-
#include <sycl/sampler.hpp>
35-
36-
#include <iterator>
37-
#include <optional>
38-
#include <type_traits>
39-
40-
#include <utility>
48+
#endif
49+
50+
#include <cstddef> // for size_t
51+
#include <functional> // for hash
52+
#include <iterator> // for reverse_iterator
53+
#include <limits> // for numeric_limits
54+
#include <memory> // for shared_ptr
55+
#include <optional> // for nullopt, optional
56+
#include <stdint.h> // for uint32_t
57+
#include <tuple> // for _Swallow_assign
58+
#include <type_traits> // for enable_if_t
59+
#include <typeinfo> // for type_info
60+
#include <variant> // for hash
4161

4262
/// \file accessor.hpp
4363
/// The file contains implementations of accessor class.

sycl/include/sycl/aliases.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88

99
#pragma once
1010

11-
#include <sycl/detail/cl.h>
12-
#include <sycl/detail/common.hpp>
13-
#include <sycl/detail/defines_elementary.hpp>
11+
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
12+
#include <sycl/half_type.hpp> // for half
1413

15-
#include <cstddef>
16-
#include <cstdint>
14+
#include <cstdint> // for uint8_t, int16_t, int32_t
1715

1816
namespace sycl {
1917
inline namespace _V1 {

sycl/include/sycl/aspects.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
// ===--------------------------------------------------------------------=== //
88
#pragma once
99

10-
#include <sycl/detail/defines.hpp>
10+
#include <sycl/detail/defines.hpp> // for __SYCL_TYPE
11+
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
1112

1213
namespace sycl {
1314
inline namespace _V1 {

sycl/include/sycl/async_handler.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
#pragma once
1010

11-
#include <sycl/detail/defines_elementary.hpp>
12-
13-
#include <functional>
11+
#include <functional> // for function
1412

1513
namespace sycl {
1614
inline namespace _V1 {

sycl/include/sycl/atomic.hpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88

99
#pragma once
1010

11-
#include <CL/__spirv/spirv_ops.hpp>
12-
#include <sycl/access/access.hpp>
13-
#include <sycl/detail/cl.h>
14-
#include <sycl/detail/helpers.hpp>
15-
#include <sycl/memory_enums.hpp>
11+
#include <CL/__spirv/spirv_types.hpp> // for Scope, MemorySemanticsMask
12+
#include <sycl/access/access.hpp> // for address_space, decorated
13+
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
14+
#include <sycl/detail/helpers.hpp> // for getSPIRVMemorySemanticsMask
15+
#include <sycl/memory_enums.hpp> // for memory_order, getStdMemoryO...
16+
#include <sycl/multi_ptr.hpp> // for multi_ptr
1617

17-
#ifndef __SYCL_DEVICE_ONLY__
18-
#include <atomic>
19-
#else
18+
#include <type_traits> // for is_same
19+
20+
#ifdef __SYCL_DEVICE_ONLY__
2021
#include <cstring>
22+
#else
23+
#include <atomic> // for atomic, memory_order
2124
#endif
22-
#include <type_traits>
2325

2426
#define __SYCL_STATIC_ASSERT_NOT_FLOAT(T) \
2527
static_assert(!std::is_same<T, float>::value, \

sycl/include/sycl/atomic_fence.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
#pragma once
1010

11-
#include <CL/__spirv/spirv_ops.hpp>
12-
#include <sycl/detail/spirv.hpp>
13-
#include <sycl/memory_enums.hpp>
11+
#include <sycl/memory_enums.hpp> // for getStdMemoryOrder, memory_order
1412

15-
#ifndef __SYCL_DEVICE_ONLY__
16-
#include <atomic>
13+
#ifdef __SYCL_DEVICE_ONLY__
14+
#include <sycl/detail/spirv.hpp>
15+
#else
16+
#include <atomic> // for atomic_thread_fence
1717
#endif
1818

1919
namespace sycl {

sycl/include/sycl/atomic_ref.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88

99
#pragma once
1010

11-
#include <sycl/access/access.hpp>
12-
#include <sycl/aspects.hpp>
13-
#include <sycl/atomic.hpp>
14-
#include <sycl/detail/defines.hpp>
15-
#include <sycl/memory_enums.hpp>
11+
#include <sycl/access/access.hpp> // for address_space
12+
#include <sycl/bit_cast.hpp> // for bit_cast
13+
#include <sycl/memory_enums.hpp> // for getStdMemoryOrder, memory_order
14+
1615
#ifdef __SYCL_DEVICE_ONLY__
1716
#include <sycl/detail/spirv.hpp>
1817
#include <sycl/multi_ptr.hpp>
18+
#else
19+
#include <atomic> // for atomic
1920
#endif
2021

21-
#ifndef __SYCL_DEVICE_ONLY__
22-
#include <atomic>
23-
#endif
24-
#include <type_traits>
22+
#include <stddef.h> // for size_t, ptrdiff_t
23+
#include <stdint.h> // for uintptr_t, uint32_t, uint64_t
24+
#include <type_traits> // for enable_if_t, bool_constant
2525

2626
namespace sycl {
2727
inline namespace _V1 {

sycl/include/sycl/backend.hpp

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,33 @@
88

99
#pragma once
1010

11-
#include <sycl/accessor.hpp>
12-
#include <sycl/backend_types.hpp>
13-
#include <sycl/buffer.hpp>
14-
#include <sycl/context.hpp>
15-
#include <sycl/detail/backend_traits.hpp>
16-
#include <sycl/feature_test.hpp>
17-
#include <sycl/image.hpp>
11+
#include <sycl/access/access.hpp> // for mode, placeholder
12+
#include <sycl/accessor.hpp> // for accessor
13+
#include <sycl/async_handler.hpp> // for async_handler
14+
#include <sycl/backend_types.hpp> // for backend
15+
#include <sycl/buffer.hpp> // for buffer_allocator
16+
#include <sycl/context.hpp> // for context, get_na...
17+
#include <sycl/detail/backend_traits.hpp> // for InteropFeatureS...
18+
#include <sycl/detail/cl.h> // for _cl_event
19+
#include <sycl/detail/defines_elementary.hpp> // for __SYCL_DEPRECATED
20+
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
21+
#include <sycl/detail/impl_utils.hpp> // for createSyclObjFr...
22+
#include <sycl/detail/pi.h> // for pi_native_handle
23+
#include <sycl/device.hpp> // for device, get_native
24+
#include <sycl/event.hpp> // for event, get_native
25+
#include <sycl/exception.hpp> // for make_error_code
26+
#include <sycl/feature_test.hpp> // for SYCL_BACKEND_OP...
27+
#include <sycl/handler.hpp> // for buffer
28+
#include <sycl/image.hpp> // for image, image_al...
29+
#include <sycl/kernel.hpp> // for kernel, get_native
30+
#include <sycl/kernel_bundle.hpp> // for kernel_bundle
31+
#include <sycl/kernel_bundle_enums.hpp> // for bundle_state
32+
#include <sycl/platform.hpp> // for platform, get_n...
33+
#include <sycl/property_list.hpp> // for property_list
34+
#include <sycl/queue.hpp> // for queue, get_native
35+
1836
#if SYCL_BACKEND_OPENCL
19-
#include <sycl/detail/backend_traits_opencl.hpp>
37+
#include <sycl/detail/backend_traits_opencl.hpp> // for interop
2038
#endif
2139
#if SYCL_EXT_ONEAPI_BACKEND_CUDA
2240
#ifdef SYCL_EXT_ONEAPI_BACKEND_CUDA_EXPERIMENTAL
@@ -29,20 +47,13 @@
2947
#include <sycl/detail/backend_traits_hip.hpp>
3048
#endif
3149
#if SYCL_EXT_ONEAPI_BACKEND_LEVEL_ZERO
32-
#include <sycl/detail/backend_traits_level_zero.hpp>
50+
#include <sycl/detail/backend_traits_level_zero.hpp> // for _ze_command_lis...
3351
#endif
34-
#include <sycl/detail/common.hpp>
35-
#include <sycl/detail/export.hpp>
36-
#include <sycl/detail/pi.h>
37-
#include <sycl/detail/pi.hpp>
38-
#include <sycl/device.hpp>
39-
#include <sycl/event.hpp>
40-
#include <sycl/exception.hpp>
41-
#include <sycl/kernel_bundle.hpp>
42-
#include <sycl/platform.hpp>
43-
#include <sycl/queue.hpp>
44-
45-
#include <type_traits>
52+
53+
#include <memory> // for shared_ptr
54+
#include <stdint.h> // for int32_t
55+
#include <type_traits> // for enable_if_t
56+
#include <vector> // for vector
4657

4758
namespace sycl {
4859
inline namespace _V1 {

sycl/include/sycl/backend/opencl.hpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
//==---------------- opencl.hpp - SYCL OpenCL backend ----------------------==//
32
//
43
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -9,9 +8,18 @@
98

109
#pragma once
1110

12-
#include <sycl/backend.hpp>
11+
#include <sycl/backend_types.hpp> // for backend
12+
#include <sycl/context.hpp> // for context
13+
#include <sycl/detail/backend_traits.hpp> // for interop
14+
#include <sycl/detail/defines_elementary.hpp> // for __SYCL_DEPRECATED
15+
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
16+
#include <sycl/detail/pi.h> // for pi_native_handle
17+
#include <sycl/device.hpp> // for device
18+
#include <sycl/platform.hpp> // for platform
19+
#include <sycl/queue.hpp> // for queue
1320

14-
#include <string>
21+
#include <string> // for string
22+
#include <type_traits> // for enable_if_t
1523

1624
namespace sycl {
1725
inline namespace _V1 {

sycl/include/sycl/backend_types.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
#pragma once
1010

11-
#include <sycl/detail/defines_elementary.hpp>
11+
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
1212

13-
#include <ostream>
13+
#include <ostream> // for operator<<, ostream
1414

1515
namespace sycl {
1616
inline namespace _V1 {

0 commit comments

Comments
 (0)