Skip to content

[SYCL][NFC] Refactor __SYCL_INLINE macro #1121

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
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
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
}
O << "\n";

O << "__SYCL_INLINE namespace cl {\n";
O << "__SYCL_INLINE_NAMESPACE(cl) {\n";
O << "namespace sycl {\n";
O << "namespace detail {\n";

Expand Down Expand Up @@ -1765,7 +1765,7 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {
O << "\n";
O << "} // namespace detail\n";
O << "} // namespace sycl\n";
O << "} // namespace cl\n";
O << "} // __SYCL_INLINE_NAMESPACE(cl)\n";
O << "\n";
}

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenSYCL/wrapped-accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// CHECK: class wrapped_access;

// CHECK: namespace cl {
// CHECK: __SYCL_INLINE_NAMESPACE(cl) {
// CHECK-NEXT: namespace sycl {
// CHECK-NEXT: namespace detail {

Expand Down
1 change: 1 addition & 0 deletions sycl/.clang-format
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
BasedOnStyle: LLVM
TypenameMacros: ['PI_CALL' ,'PI_CALL_THROW', 'PI_CALL_NOCHECK']
NamespaceMacros: ['__SYCL_INLINE_NAMESPACE']
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/access/access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace access {

Expand Down Expand Up @@ -180,4 +180,4 @@ struct remove_AS<__OPENCL_CONSTANT_AS__ T> {
} // namespace detail

} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
// accessor_common contains several helpers common for both accessor(1) and
// accessor(3)

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

template <typename DataT, int Dimensions, access::mode AccessMode,
Expand Down Expand Up @@ -1264,7 +1264,7 @@ class accessor<DataT, Dimensions, AccessMode, access::target::image_array,
};

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

namespace std {
template <typename DataT, int Dimensions, cl::sycl::access::mode AccessMode,
Expand Down
8 changes: 4 additions & 4 deletions sycl/include/CL/sycl/aliases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <cstdint>

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
template <typename T, int N> class vec;
namespace detail {
Expand All @@ -22,7 +22,7 @@ class half;
} // namespace half_impl
} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)

// FIXME: line below exports 'half' into global namespace, which seems incorrect
// However, SYCL 1.2.1 spec considers 'half' to be a fundamental C++ data type
Expand Down Expand Up @@ -69,7 +69,7 @@ using half = cl::sycl::detail::half_impl::half;
MAKE_VECTOR_ALIASES_FOR_OPENCL_TYPES(N) \
MAKE_VECTOR_ALIASES_FOR_SIGNED_AND_UNSIGNED_TYPES(N)

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
using byte = std::uint8_t;
using schar = signed char;
Expand Down Expand Up @@ -101,7 +101,7 @@ MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(4)
MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(8)
MAKE_VECTOR_ALIASES_FOR_VECTOR_LENGTH(16)
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)

#undef MAKE_VECTOR_ALIAS
#undef MAKE_VECTOR_ALIASES_FOR_ARITHMETIC_TYPES
Expand Down
12 changes: 6 additions & 6 deletions sycl/include/CL/sycl/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
static_assert(!std::is_same<T, float>::value, \
"SYCL atomic function not available for float type")

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

enum class memory_order : int { relaxed };
Expand Down Expand Up @@ -62,11 +62,11 @@ template <> struct GetSpirvMemoryScope<access::address_space::local_space> {

} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)

#ifndef __SYCL_DEVICE_ONLY__
// host implementation of SYCL atomics
__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {
// Translate cl::sycl::memory_order or __spv::MemorySemanticsMask
Expand All @@ -81,7 +81,7 @@ static inline std::memory_order getStdMemoryOrder(::cl::sycl::memory_order MS) {
}
} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)

// std::atomic version of atomic SPIR-V builtins

Expand Down Expand Up @@ -161,7 +161,7 @@ extern T __spirv_AtomicMax(std::atomic<T> *Ptr, __spv::Scope S,

#endif // !defined(__SYCL_DEVICE_ONLY__)

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

template <typename T, access::address_space addressSpace =
Expand Down Expand Up @@ -369,6 +369,6 @@ T atomic_fetch_max(atomic<T, addressSpace> Object, T Operand,
}

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

#undef STATIC_ASSERT_NOT_FLOAT
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// TODO: 4.3.4 Properties

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
class handler;
class queue;
Expand Down Expand Up @@ -396,7 +396,7 @@ buffer(const T *, const range<dimensions> &, const property_list & = {})
#endif // __cpp_deduction_guides

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

namespace std {
template <typename T, int dimensions, typename AllocatorT>
Expand Down
8 changes: 4 additions & 4 deletions sycl/include/CL/sycl/builtins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
// TODO Decide whether to mark functions with this attribute.
#define __NOEXC /*noexcept*/

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
#ifdef __SYCL_DEVICE_ONLY__
#define __sycl_std
#else
namespace __sycl_std = __host_std;
#endif
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
/* ----------------- 4.13.3 Math functions. ---------------------------------*/
// genfloat acos (genfloat x)
Expand Down Expand Up @@ -1546,6 +1546,6 @@ detail::enable_if_t<detail::is_genfloatf<T>::value, T> tan(T x) __NOEXC {

} // namespace half_precision
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)

#undef __NOEXC
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <type_traits>
// 4.6.2 Context class

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
// Forward declarations
class device;
Expand Down Expand Up @@ -139,7 +139,7 @@ class context {
};

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

namespace std {
template <> struct hash<cl::sycl::context> {
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/accessor_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <CL/sycl/range.hpp>
#include <CL/sycl/stl.hpp>

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

Expand Down Expand Up @@ -187,4 +187,4 @@ using Requirement = AccessorImplHost;

} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/aligned_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <memory>
#include <vector>

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {
template <typename T> class aligned_allocator {
Expand Down Expand Up @@ -80,4 +80,4 @@ template <typename T> class aligned_allocator {
};
} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <functional>
#include <stdexcept>

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
template <int dimensions> class id;
template <int dimensions> class range;
Expand Down Expand Up @@ -119,4 +119,4 @@ template <int dimensions = 1> class array {

} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/boolean.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <initializer_list>
#include <type_traits>

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

Expand Down Expand Up @@ -140,4 +140,4 @@ template <> struct Boolean<1> {

} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/buffer_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <memory>
#include <type_traits>

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
// Forward declarations
template <typename DataT, int Dimensions, access::mode AccessMode,
Expand Down Expand Up @@ -118,4 +118,4 @@ class buffer_impl final : public SYCLMemObjT {

} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/builtins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}

#ifndef __SYCL_DEVICE_ONLY__
__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace __host_std {
#endif // __SYCL_DEVICE_ONLY__
/* ----------------- 4.13.3 Math functions. ---------------------------------*/
Expand Down Expand Up @@ -242,7 +242,7 @@ MAKE_CALL_ARG3(bitselect, __FUNC_PREFIX_OCL)
MAKE_CALL_ARG3(select, __FUNC_PREFIX_OCL) // select
#ifndef __SYCL_DEVICE_ONLY__
} // namespace __host_std
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
#endif

#undef __NOEXC
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/cg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <type_traits>
#include <vector>

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

Expand Down Expand Up @@ -520,4 +520,4 @@ class CGPrefetchUSM : public CG {

} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/circular_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <deque>
#include <utility>

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

Expand Down Expand Up @@ -96,4 +96,4 @@ template <typename T> class CircularBuffer {

} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/clusm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <mutex>
#include <vector>

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {
namespace usm {
Expand Down Expand Up @@ -97,4 +97,4 @@ class CLUSM {
} // namespace usm
} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
8 changes: 4 additions & 4 deletions sycl/include/CL/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define STRINGIFY_LINE_HELP(s) #s
#define STRINGIFY_LINE(s) STRINGIFY_LINE_HELP(s)

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

Expand All @@ -33,7 +33,7 @@ static inline std::string codeToString(cl_int code){
stringifyErrorCode(code) + ")");
}

}}} // namespace cl::sycl::detail
}}} // __SYCL_INLINE_NAMESPACE(cl)::sycl::detail

#ifdef __SYCL_DEVICE_ONLY__
// TODO remove this when 'assert' is supported in device code
Expand Down Expand Up @@ -87,7 +87,7 @@ static inline std::string codeToString(cl_int code){
#define CHECK_OCL_CODE_NO_EXC(X) REPORT_OCL_ERR_TO_STREAM(X)
#endif

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

Expand Down Expand Up @@ -252,4 +252,4 @@ constexpr KernelSetId LastKSId = SpvFileKSId;

} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/common_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once
#include <CL/sycl/stl.hpp>

__SYCL_INLINE namespace cl {
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace detail {

Expand All @@ -18,4 +18,4 @@ vector_class<string_class> split_string(const string_class &str,

} // namespace detail
} // namespace sycl
} // namespace cl
} // __SYCL_INLINE_NAMESPACE(cl)
Loading