Skip to content
Open
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
3 changes: 2 additions & 1 deletion sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

#include <sycl/access/access.hpp> // for target, mode
#include <sycl/detail/accessor_iterator.hpp> // for accessor_iterator
#include <sycl/detail/common.hpp> // for code_location
#include <sycl/detail/code_location.hpp> // for code_location
#include <sycl/detail/common.hpp>
#include <sycl/detail/defines.hpp> // for __SYCL_SPECIAL...
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEP...
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
Expand Down
1 change: 1 addition & 0 deletions sycl/include/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <sycl/access/access.hpp>
#include <sycl/backend_types.hpp>
#include <sycl/detail/array.hpp>
#include <sycl/detail/code_location.hpp>
#include <sycl/detail/common.hpp>
#include <sycl/detail/defines_elementary.hpp>
#include <sycl/detail/export.hpp>
Expand Down
19 changes: 2 additions & 17 deletions sycl/include/sycl/detail/cg_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,11 @@

#pragma once

#include <sycl/detail/array.hpp> // for array
#include <sycl/detail/helpers.hpp> // for Builder
#include <sycl/detail/host_profiling_info.hpp> // for HostProfilingInfo
#include <sycl/detail/item_base.hpp> // for id
#include <sycl/detail/kernel_desc.hpp> // for kernel_param_kind_t
#include <sycl/detail/nd_loop.hpp> // for InitializedVal, NDLoop
#include <sycl/exception.hpp>
#include <sycl/group.hpp> // for group
#include <sycl/h_item.hpp> // for h_item
#include <sycl/id.hpp> // for id
#include <sycl/item.hpp> // for item
#include <sycl/kernel_handler.hpp> // for kernel_handler
#include <sycl/nd_item.hpp> // for nd_item
#include <sycl/nd_range.hpp> // for nd_range
#include <sycl/range.hpp> // for range, operator*

#include <functional> // for function
#include <stddef.h> // for size_t
#include <memory> // for unique_ptr
#include <type_traits> // for enable_if_t, false_type
#include <utility> // for declval
#include <utility> // for declval, move

namespace sycl {
inline namespace _V1 {
Expand Down
147 changes: 147 additions & 0 deletions sycl/include/sycl/detail/code_location.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
//==---------- code_location.hpp ----- code_location utilities ------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#pragma once

#include <sycl/detail/export.hpp> // for __SYCL_EXPORT

#include <cstdint>

namespace sycl {
inline namespace _V1 {
namespace detail {

#if !defined(NDEBUG) && (_MSC_VER > 1929 || __has_builtin(__builtin_FILE))
#define __CODELOC_FILE_NAME __builtin_FILE()
#else
#define __CODELOC_FILE_NAME nullptr
#endif

#if _MSC_VER > 1929 || __has_builtin(__builtin_FUNCTION)
#define __CODELOC_FUNCTION __builtin_FUNCTION()
#else
#define __CODELOC_FUNCTION nullptr
#endif

#if _MSC_VER > 1929 || __has_builtin(__builtin_LINE)
#define __CODELOC_LINE __builtin_LINE()
#else
#define __CODELOC_LINE 0
#endif

#if _MSC_VER > 1929 || __has_builtin(__builtin_COLUMN)
#define __CODELOC_COLUMN __builtin_COLUMN()
#else
#define __CODELOC_COLUMN 0
#endif

// Data structure that captures the user code location information using the
// builtin capabilities of the compiler
struct code_location {
static constexpr code_location
current(const char *fileName = __CODELOC_FILE_NAME,
const char *funcName = __CODELOC_FUNCTION,
uint32_t lineNo = __CODELOC_LINE,
uint32_t columnNo = __CODELOC_COLUMN) noexcept {
return code_location(fileName, funcName, lineNo, columnNo);
}

#undef __CODELOC_FILE_NAME
#undef __CODELOC_FUNCTION
#undef __CODELOC_LINE
#undef __CODELOC_COLUMN

constexpr code_location(const char *file, const char *func, uint32_t line,
uint32_t col) noexcept
: MFileName(file), MFunctionName(func), MLineNo(line), MColumnNo(col) {}

constexpr code_location() noexcept
: MFileName(nullptr), MFunctionName(nullptr), MLineNo(0u), MColumnNo(0u) {
}

constexpr uint32_t lineNumber() const noexcept {
return static_cast<uint32_t>(MLineNo);
}
constexpr uint32_t columnNumber() const noexcept {
return static_cast<uint32_t>(MColumnNo);
}
constexpr const char *fileName() const noexcept { return MFileName; }
constexpr const char *functionName() const noexcept { return MFunctionName; }

private:
const char *MFileName;
const char *MFunctionName;
uint32_t MLineNo;
uint32_t MColumnNo;
};

/// @brief Data type that manages the code_location information in TLS
/// @details As new SYCL features are added, they all enable the propagation of
/// the code location information where the SYCL API was called by the
/// application layer. In order to facilitate this, the tls_code_loc_t object
/// assists in managing the data in TLS :
/// (1) Populate the information when you at the top level function in the
/// call chain. This is usually the end-user entry point function into SYCL.
/// (2) Remove the information when the object goes out of scope in the top
/// level function.
///
/// Usage:-
/// void bar() {
/// tls_code_loc_t p;
/// // Print the source information of where foo() was called in main()
/// std::cout << p.query().fileName() << ":" << p.query().lineNumber() <<
/// std::endl;
/// }
/// // Will work for arbitrary call chain lengths.
/// void bar1() {bar();}
///
/// // Foo() is equivalent to a SYCL end user entry point such as
/// // queue.memcpy() or queue.copy()
/// void foo(const code_location &loc) {
/// tls_code_loc_t tp(loc);
/// bar1();
/// }
///
/// void main() {
/// foo(const code_location &loc = code_location::current());
/// }
class __SYCL_EXPORT tls_code_loc_t {
public:
/// @brief Consructor that checks to see if a TLS entry already exists
/// @details If a previous populated TLS entry exists, this constructor will
/// capture the informationa and allow you to query the information later.
tls_code_loc_t();
/// @brief Iniitializes TLS with CodeLoc if a TLS entry not present
/// @param CodeLoc The code location information to set up the TLS slot with.
tls_code_loc_t(const detail::code_location &CodeLoc);

// Used to maintain global state (GCodeLocTLS), so we do not want to copy
tls_code_loc_t(const tls_code_loc_t &) = delete;
tls_code_loc_t &operator=(const tls_code_loc_t &) = delete;

/// If the code location is set up by this instance, reset it.
~tls_code_loc_t();
/// @brief Query the information in the TLS slot
/// @return The code location information saved in the TLS slot. If not TLS
/// entry has been set up, a default coe location is returned.
const detail::code_location &query();
/// @brief Returns true if the TLS slot was cleared when this object was
/// constructed.
bool isToplevel() const { return !MLocalScope; }

private:
// Cache the TLS location to decrease amount of TLS accesses.
detail::code_location &CodeLocTLSRef;
// The flag that is used to determine if the object is in a local scope or in
// the top level scope.
bool MLocalScope = true;
};

} // namespace detail
} // namespace _V1
} // namespace sycl
139 changes: 1 addition & 138 deletions sycl/include/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
#pragma once

#include <sycl/detail/assert.hpp>
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
#include <sycl/detail/nd_loop.hpp>

#include <array> // for array
#include <cstddef> // for size_t
#include <cstdint>
#include <type_traits> // for enable_if_t
#include <utility> // for index_sequence, make_i...

// Default signature enables the passing of user code location information to
// public methods as a default argument.
namespace sycl {
inline namespace _V1 {
namespace detail {
Expand All @@ -36,140 +33,6 @@ template <typename DataT>
using EnableIfOutputIteratorT = std::enable_if_t<
/*is_output_iterator<DataT>::value &&*/ !std::is_pointer_v<DataT>>;

#if !defined(NDEBUG) && (_MSC_VER > 1929 || __has_builtin(__builtin_FILE))
#define __CODELOC_FILE_NAME __builtin_FILE()
#else
#define __CODELOC_FILE_NAME nullptr
#endif

#if _MSC_VER > 1929 || __has_builtin(__builtin_FUNCTION)
#define __CODELOC_FUNCTION __builtin_FUNCTION()
#else
#define __CODELOC_FUNCTION nullptr
#endif

#if _MSC_VER > 1929 || __has_builtin(__builtin_LINE)
#define __CODELOC_LINE __builtin_LINE()
#else
#define __CODELOC_LINE 0
#endif

#if _MSC_VER > 1929 || __has_builtin(__builtin_COLUMN)
#define __CODELOC_COLUMN __builtin_COLUMN()
#else
#define __CODELOC_COLUMN 0
#endif

// Data structure that captures the user code location information using the
// builtin capabilities of the compiler
struct code_location {
static constexpr code_location
current(const char *fileName = __CODELOC_FILE_NAME,
const char *funcName = __CODELOC_FUNCTION,
uint32_t lineNo = __CODELOC_LINE,
uint32_t columnNo = __CODELOC_COLUMN) noexcept {
return code_location(fileName, funcName, lineNo, columnNo);
}

#undef __CODELOC_FILE_NAME
#undef __CODELOC_FUNCTION
#undef __CODELOC_LINE
#undef __CODELOC_COLUMN

constexpr code_location(const char *file, const char *func, uint32_t line,
uint32_t col) noexcept
: MFileName(file), MFunctionName(func), MLineNo(line), MColumnNo(col) {}

constexpr code_location() noexcept
: MFileName(nullptr), MFunctionName(nullptr), MLineNo(0u), MColumnNo(0u) {
}

constexpr uint32_t lineNumber() const noexcept {
return static_cast<uint32_t>(MLineNo);
}
constexpr uint32_t columnNumber() const noexcept {
return static_cast<uint32_t>(MColumnNo);
}
constexpr const char *fileName() const noexcept { return MFileName; }
constexpr const char *functionName() const noexcept { return MFunctionName; }

private:
const char *MFileName;
const char *MFunctionName;
uint32_t MLineNo;
uint32_t MColumnNo;
};

/// @brief Data type that manages the code_location information in TLS
/// @details As new SYCL features are added, they all enable the propagation of
/// the code location information where the SYCL API was called by the
/// application layer. In order to facilitate this, the tls_code_loc_t object
/// assists in managing the data in TLS :
/// (1) Populate the information when you at the top level function in the
/// call chain. This is usually the end-user entry point function into SYCL.
/// (2) Remove the information when the object goes out of scope in the top
/// level function.
///
/// Usage:-
/// void bar() {
/// tls_code_loc_t p;
/// // Print the source information of where foo() was called in main()
/// std::cout << p.query().fileName() << ":" << p.query().lineNumber() <<
/// std::endl;
/// }
/// // Will work for arbitrary call chain lengths.
/// void bar1() {bar();}
///
/// // Foo() is equivalent to a SYCL end user entry point such as
/// // queue.memcpy() or queue.copy()
/// void foo(const code_location &loc) {
/// tls_code_loc_t tp(loc);
/// bar1();
/// }
///
/// void main() {
/// foo(const code_location &loc = code_location::current());
/// }
class __SYCL_EXPORT tls_code_loc_t {
public:
/// @brief Consructor that checks to see if a TLS entry already exists
/// @details If a previous populated TLS entry exists, this constructor will
/// capture the informationa and allow you to query the information later.
tls_code_loc_t();
/// @brief Iniitializes TLS with CodeLoc if a TLS entry not present
/// @param CodeLoc The code location information to set up the TLS slot with.
tls_code_loc_t(const detail::code_location &CodeLoc);

// Used to maintain global state (GCodeLocTLS), so we do not want to copy
tls_code_loc_t(const tls_code_loc_t &) = delete;
tls_code_loc_t &operator=(const tls_code_loc_t &) = delete;

/// If the code location is set up by this instance, reset it.
~tls_code_loc_t();
/// @brief Query the information in the TLS slot
/// @return The code location information saved in the TLS slot. If not TLS
/// entry has been set up, a default coe location is returned.
const detail::code_location &query();
/// @brief Returns true if the TLS slot was cleared when this object was
/// constructed.
bool isToplevel() const { return !MLocalScope; }

private:
// Cache the TLS location to decrease amount of TLS accesses.
detail::code_location &CodeLocTLSRef;
// The flag that is used to determine if the object is in a local scope or in
// the top level scope.
bool MLocalScope = true;
};

} // namespace detail
} // namespace _V1
} // namespace sycl

namespace sycl {
inline namespace _V1 {
namespace detail {

constexpr size_t getNextPowerOfTwoHelper(size_t Var, size_t Offset) {
return Offset != 64
? getNextPowerOfTwoHelper(Var | (Var >> Offset), Offset * 2)
Expand Down
2 changes: 0 additions & 2 deletions sycl/include/sycl/detail/kernel_launch_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
#pragma once

#include <sycl/detail/cg_types.hpp>
#include <sycl/detail/compile_time_kernel_info.hpp>
#include <sycl/detail/helpers.hpp>
#include <sycl/detail/is_device_copyable.hpp>
#include <sycl/detail/type_traits.hpp>
#include <sycl/ext/intel/experimental/fp_control_kernel_properties.hpp>
#include <sycl/ext/intel/experimental/kernel_execution_properties.hpp>
#include <sycl/ext/oneapi/experimental/cluster_group_prop.hpp>
#include <sycl/ext/oneapi/experimental/graph.hpp>
#include <sycl/ext/oneapi/experimental/use_root_sync_prop.hpp>
#include <sycl/ext/oneapi/experimental/virtual_functions.hpp>
#include <sycl/ext/oneapi/kernel_properties.hpp>
Expand Down
3 changes: 2 additions & 1 deletion sycl/include/sycl/detail/range_rounding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@
#include <sycl/detail/export.hpp>
#include <sycl/detail/helpers.hpp>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/device.hpp>
#include <sycl/ext/oneapi/kernel_properties.hpp>
#include <sycl/id.hpp>
#include <sycl/item.hpp>
#include <sycl/kernel_handler.hpp>
#include <sycl/range.hpp>

#include <limits>
#include <tuple>
#include <type_traits>

#include <stddef.h>

namespace sycl {
inline namespace _V1 {
class device;

namespace detail {

Expand Down
Loading
Loading