DPC++ Runtime
Runtime libraries for oneAPI DPC++
sycl::_V1::detail::tls_code_loc_t Class Reference

Data type that manages the code_location information in TLS. More...

#include <sycl/detail/common.hpp>

Public Member Functions

 tls_code_loc_t ()
 Consructor that checks to see if a TLS entry already exists. More...
 
 tls_code_loc_t (const detail::code_location &CodeLoc)
 Iniitializes TLS with CodeLoc if a TLS entry not present. More...
 
 ~tls_code_loc_t ()
 If the code location is set up by this instance, reset it. More...
 
const detail::code_locationquery ()
 Query the information in the TLS slot. More...
 

Detailed Description

Data type that manages the code_location information in TLS.

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()); }

Definition at line 129 of file common.hpp.

Constructor & Destructor Documentation

◆ tls_code_loc_t() [1/2]

sycl::_V1::detail::tls_code_loc_t::tls_code_loc_t ( )

Consructor that checks to see if a TLS entry already exists.

Default constructor to use in lower levels of the calling stack to check and see if code location object is available.

If a previous populated TLS entry exists, this constructor will capture the informationa and allow you to query the information later.

If not, continue with instrumentation as needed

Definition at line 25 of file common.cpp.

References sycl::_V1::detail::code_location::fileName(), sycl::_V1::detail::code_location::functionName(), and sycl::_V1::detail::GCodeLocTLS.

◆ tls_code_loc_t() [2/2]

sycl::_V1::detail::tls_code_loc_t::tls_code_loc_t ( const detail::code_location CodeLoc)

Iniitializes TLS with CodeLoc if a TLS entry not present.

Constructor to use at the top level of the calling stack.

Parameters
CodeLocThe code location information to set up the TLS slot with.

This is usually a SYCL entry point used by the end user in their application code. In this case, we still check to see if another code location has been stashed in the TLS at a higher level. If not, we have the code location information that must be active for the current calling scope.

Definition at line 36 of file common.cpp.

References sycl::_V1::detail::code_location::fileName(), sycl::_V1::detail::code_location::functionName(), and sycl::_V1::detail::GCodeLocTLS.

◆ ~tls_code_loc_t()

sycl::_V1::detail::tls_code_loc_t::~tls_code_loc_t ( )

If the code location is set up by this instance, reset it.

If we are the top lovel scope, reset the code location info.

Definition at line 48 of file common.cpp.

References sycl::_V1::detail::GCodeLocTLS.

Member Function Documentation

◆ query()

const detail::code_location & sycl::_V1::detail::tls_code_loc_t::query ( )

Query the information in the TLS slot.

Returns
The code location information saved in the TLS slot. If not TLS entry has been set up, a default coe location is returned.

Definition at line 55 of file common.cpp.

References sycl::_V1::detail::GCodeLocTLS.

Referenced by sycl::_V1::detail::Command::copySubmissionCodeLocation(), sycl::_V1::detail::pi::emitFunctionWithArgsBeginTrace(), and sycl::_V1::detail::GlobalHandler::TraceEventXPTI().


The documentation for this class was generated from the following files: