diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index cdc84bc122b57..243868f2bc4cf 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -31,6 +31,7 @@ endif() # materialization possible. option(SYCL_ENABLE_EXTENSION_JIT "Enable extension to JIT kernels" ON) +# TODO-UPSTREAM temp workaround to fix cuda adapter build if (NOT XPTI_INCLUDES) set(XPTI_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../xpti/include) endif() @@ -122,10 +123,6 @@ if(SYCL_ENABLE_WERROR) endif() endif() -# Create a soft option for enabling or disabling the instrumentation -# of the SYCL runtime and expect enabling -option(SYCL_ENABLE_XPTI_TRACING "Enable tracing of SYCL constructs" OFF) - # Get clang's version include(VersionFromVCS) set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") @@ -354,14 +351,6 @@ if (NOT WIN32) COMPONENT sycl-headers-extras) endif() -if (SYCL_ENABLE_XPTI_TRACING) - if (MSVC) - set(XPTIFW_LIBS xpti xptid xptifw xptifwd) - else() - set(XPTIFW_LIBS xpti xptifw) - endif() -endif() - # SYCL toolchain builds all components: compiler, libraries, headers, etc. add_custom_target(sycl-compiler DEPENDS append-file @@ -392,7 +381,6 @@ add_custom_target( sycl-toolchain ALL DEPENDS sycl-runtime-libraries sycl-compiler sycl-ls - ${XPTIFW_LIBS} COMMENT "Building SYCL compiler toolchain..." ) @@ -470,7 +458,6 @@ set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS libsycldevice unified-memory-framework unified-runtime-loader - ${XPTIFW_LIBS} ${SYCL_TOOLCHAIN_DEPS} ) @@ -478,16 +465,6 @@ if (WIN32) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS ur_win_proxy_loader) endif() -if (TARGET sycl-prof) - list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS sycl-prof) -endif() -if (TARGET sycl-sanitize) - list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS sycl-sanitize) -endif() -if (TARGET sycl-trace) - list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS sycl-trace) -endif() - if(OpenCL_INSTALL_KHRONOS_ICD_LOADER AND TARGET OpenCL-ICD) list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS OpenCL-ICD) endif() diff --git a/sycl/doc/EnvironmentVariables.md b/sycl/doc/EnvironmentVariables.md index df624323bf453..7893e07c3145f 100644 --- a/sycl/doc/EnvironmentVariables.md +++ b/sycl/doc/EnvironmentVariables.md @@ -180,12 +180,8 @@ For a description of parallel for range rounding in DPC++ see | Environment variable | Values | Description | | -------------------- | ------ | ----------- | | `INTEL_ENABLE_OFFLOAD_ANNOTATIONS` | Any(\*) | Enables ITT Annotations support for SYCL runtime. This variable should only be used by tools, that support ITT Annotations. | -| `XPTI_FRAMEWORK_DISPATCHER`(\*\*) | Path to dispatcher library | Loads XPTI instrumentation dispatcher framework library. See [XPTI Framework documentation][xpti] for more info | -| `XPTI_TRACE_ENABLE`(\*\*) | `1`, `true`, `0`, `false` | Enables XPTI instrumentation. See [XPTI Framework documentation][xpti] for more info | -| `XPTI_SUBSCRIBERS`(\*\*) | Comma separated list of subscriber libraries | Loads XPTI subscribers. See [XPTI Framework documentation][xpti] for more info | `(*) Note: Any means this environment variable is effective when set to any non-null value.` -`(**) Note: These variables come from XPTI framework` ## Debugging variables for DPC++ Runtime @@ -298,5 +294,4 @@ variables in production code. `(*) Note: Any means this environment variable is effective when set to any non-null value.` -[xpti]: https://github.com/intel/llvm/blob/sycl/xptifw/doc/XPTI_Framework.md [range-rounding]: https://github.com/intel/llvm/blob/sycl/sycl/doc/design/ParallelForRangeRounding.md diff --git a/sycl/doc/design/SYCLInstrumentationUsingXPTI.md b/sycl/doc/design/SYCLInstrumentationUsingXPTI.md deleted file mode 100644 index a019ba515fc4d..0000000000000 --- a/sycl/doc/design/SYCLInstrumentationUsingXPTI.md +++ /dev/null @@ -1,353 +0,0 @@ -# SYCL Instrumentation - -Any language or programming paradigm must provide mechanisms to correlate a -developer's use of the language to the debug and performance traces for that -use. A lightweight tracing framework (XPTI) was developed to enable this for -SYCL and is the primary mechanism that is employed to enable debug and -performance traces. - -> **NOTE:** For additional information on the XPTI framework, please refer to ->the [Framework Documentation](https://github.com/intel/llvm/tree/sycl/xptifw/doc/XPTI_Framework.md) for API use ->and framework performance data. - -This document outlines the use of this framework API in the SYCL runtime -library. The primary concept enable by this framework is the generation of a -unique 64-bit ID, referred to as the Universal ID (UID), for every public -language entry point into the library. This allows tools and other helps in the -software stack to correlate debug and performance data by tagging it with the -64-bit UID. The framework also provides the ability to propagate this UID all -the way to the driver layers for the target device so data from lower layers and -hardware can be correlated easily. - -The XPTI concepts in use here are: - -1. Tracepoints - define all the points in a software layer we want to -instrument or trace. The trace point is used to generate the UID. -2. Notification - allows the software layer to communicate the trace -information to listeners/subscribers -3. Callback - implemented by subscribers to specific events to capture the -trace information - -The SYCL runtime layer defines the tracepoints and notifies the information -about any given tracepoint to a registered subscriber. These tracepoints are -enabled in meaningful locations of the runtime to provide semantic information -about the developer's use of the language. This would include information such -as relationships that form asynchronous task graphs or other constructs such -as barriers that are introduced while waiting on events. - -## Instrumentation Trace Points - -This section will document all the places in the SYCL runtime that have been -instrumented to capture the asynchronous task graphs created by the runtime. -The task graphs are captured as graph, nodes and edges: - -> - The graph encapsulates all of the disjoint task graphs generated by the application. -> - The nodes capture operations that are performed, such as kernel -executions or memory transfers -> - The edges represent dependence relationships, the representation of -which mimics control flow as opposed to a dependence graph. The source node -in an edge must complete before the target node can begin execution. - - All code changes to enable this have been guarded by - `XPTI_ENABLE_INSTRUMENTATION` macro and the CMake files have been updated to - have this as an option which is enabled by default and this change is under - `llvm/sycl/CMakeLists.txt`. - -```cmake -... -# Create a soft option for enabling or disabling the instrumentation -# of the SYCL runtime -option(SYCL_ENABLE_XPTI_TRACING "Enable tracing of SYCL constructs" ON) -``` - -### The Graph - -Any SYCL application can submit command groups to any active queue -during the lifetime of the application. Each submission is handled by the -runtime and the asynchronous task graphs are updated to reflect the new -submission. This may be as simple as adding a new node to the task-graph or -adding multiple nodes to the graph, where one of the nodes represents the -computation and the others dependent memory transfers. - -To model this, we create a global graph for every application instantiation -and all kernel executions in the applications are added as nodes in this -global graph. In the SYCL runtime, there is no obvious location where the -creation of the global graph can be inserted as many objects are -instantiated statically. Currently, graph creation happens alongside UR -initialization in `initializePlugins` ([here](https://github.com/intel/llvm/blob/2137ff0e2ae0b478d341c12466bed0ac4402f516/sycl/source/detail/ur.cpp#L96)). -In this call, we will perform two operations: - -1. Initialize all listeners and create a trace event to represent the graph. -2. Send a `graph_create` event to all subscribers. This notification -will only be sent once. - -### The Nodes - -The command group lambdas are captured and encapsulated in a `Command` -object. This object is evaluated for dependencies on data/memory or external -OpenCL events and an asynchronous task graph is built by mapping all these -dependencies, before it is enqueued on the device. In order to capture the -command groups (nodes) and the dependencies (edges), the base class -`Command` and any derived classes that are of interest are instrumented. - -In this section, we discuss the instrumentation of the Command object in two -parts: (1) The changes made to capture end-user source code details for -language constructs (2) The instrumentation that handles capturing the -relevant metadata. - -1. In order to capture end-user source code information, we have implemented -`sycl::detail::code_location` class that uses the builtin functions -in the compiler. However, equivalent implementations are unavailable on -Windows and separate cross-platform implementation might be used in the -future. To mitigate this, the Windows implementation will always report -`unknown_file`, `unknown_func` and a line number of 0 for source -file, function name and line number. We handle this case while processing -this information. - - The source information of a language construct, such as source file, - function name, line number and column number allow us to determine if a - Command that was previously created for a construct is being created - again. In such cases, we will not emit a `node_create` event, but we - will bump up the instance count recording the number of instances - created. Secondly, the source information allows us to associate a unique - ID with the source location and propagate it all the way to the driver, - if possible. This will allow us to associate a Kernel event with a source - location at all times. All instrumentation that identifies a command - object of a given type and emits the `node_create` event is located - in the `emitInstrumentationData()` and must be implemented by all - derived classes. - - To enable this source location information, we start with enabling the - public methods in the queue class, such as `queue.submit()`, - `queue.parallel_for()`, `queue.wait()`, etc to include a default - argument that captures the source location information. The location of - the line in the caller that makes the call to `queue.submit()`, - `queue.parallel_for()`, etc is represented in this default argument. - These changes are present in `queue.hpp` and `ordered_queue.hpp`. - The default arguments for all public functions are guarded by - `#ifdef SYCL_INSTRUMENTATION_METADATA` that is currently enabled by - default. - - The location information, when captured, is propagated all the way to the - `CommandGroup` object. So, for every `CommandGroup` object, we - will have the corresponding source location in end-user code where the - command group is submitted to the queue. This metadata is propagated by - the instrumentation to the subscribers of the stream. - -2. The base `Command class` and all derived classes are instrumented to capture - the relevant information for each command object and a `node_create` event is - generated. - -### The Node instance - -Once a command object is created, it is enqueued on the device for -execution. To capture the execution of this node instance, we instrument the -`enqueue()` method to determine the cost of this computation or memory -related kernel. As the commands are enqueued, the enqueue method emits a -pair of events indicating the `task_begin` and `task_end`events that -capture the duration of the enqueued command. For commands that are -asynchronous, the pair of events capture just the kernel submission and the -actual execution of the command on the device is tracked through the -`cl_event` returned by the enqueue operation. In the case of host kernel -execution or commands that are synchronous, the cost is measured directly. - -In the case of the command being submitted to an OpenCL device, we capture -the event of the submitted kernel and propagate it to the subscriber tool. -It is up to the tool to register a callback for this event completion and -close the task opened for the command object. - -### The Edges - -As discussed in the previous section, the command groups submitted to the -device queues form nodes in the asynchronous tasks graphs created by -the SYCL runtime. In addition to these nodes, based on the memory references -(through accessors or USM pointers), additional nodes to `allocate`, -`copy` and `release` are created and they are necessary for the -computation kernels to run. The computation kernel has dependencies on the -memory objects and these dependencies are recorded as `event`s and in -our model we represent them as edges between the dependent nodes. - -Tools monitoring the event stream then can start capturing the asynchronous -task graph as it is being built. As dependencies are added to a command -object, the instrumentation emits these dependencies as `edge_create` -events. Each of these `edge_create`events encapsulate the two command -objects that have a dependency through this edge. The source object of this -edge event must complete execution first before the target object of the -edge can begin execution. - -To instrument this part of the code, the `Command::addDep` methods of -the Command object are instrumented to create the trace points and notify -all subscribers. - -The `Release` command, as implemented in the SYCL runtime, has a -reference to the memory object, but no explicit dependencies are created. To -model the edges correctly, we instrument the `waitForRecordToFinish` method in -the `Scheduler` where the release operation waits on all the -dependent operations to complete to capture the edges. - -This concludes all the changes that were made to the SYCL runtime to support -tracing. The next section talks about the XPTI framework that allows -applications and runtimes to efficiently capture, record and emit trace -notifications for important events during the run. - -## Documentation of SYCL tracepoints -### XPTI Stream Domain - -Traces belong to a named stream and this constitutes a domain of data. The XPTI -framework allows the instrumentation logic to define a stream and associate the -traces to the stream. A stream also defines the protocol to be observed to -decipher the data at the receiving end. The XPTI API defines the notion of a -trace point that includes an event, a trace point type and a notification. - -- The **event** consists a payload that describes the event (`source file`, - `function name`, `line number` and/or a `code pointer`), a `unique_id` that - is used to identify the event, a `global user data field` and a mechanism to - record `metadata` associated with the event. The `unique_id` is generated - from the payload, so if the trace point is visited multiple times, it - represents the same `unique_id` and this allows us to determine the number of - instances of a trace point. - -- The **trace point type** defines the type of notification that is being - emitted for the trace point. There are many commonly occurring trace point - types that are predefined by the framework, but a stream can extend this - set by the extension APIs provided. A subscriber must explicitly register a - callback for each trace point type that is of interest to the subscriber. If - no subscribers are registered for a stream or a trace point type, then - traces will not be emitted. A given trace point event may be used to emit - multiple traces to different trace point types. - -- The **notification** emits the trace to all subscribers of the stream domain - that have a callback registered to the given trace point type. The stream - can attached a per-instance user data during this notification call that - *must* be guaranteed to be valid for the duration of the notification call. - -This document will outline the protocol for the streams of data being generated -by the SYCL runtime. - -## SYCL Stream `"ur.call"` Notification Signatures - -| Trace Point Type | Parameter Description | Metadata | -| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | -| `function_begin` |
  • **trace_type**: `xpti::trace_point_type_t::function_begin` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `function_begin` event with the `function_end` event.
  • **user_data**: Name of the function being called sent in as `const char *`
  • | None | -| `function_end` |
  • **trace_type**: `xpti::trace_point_type_t::function_end` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `function_begin` event with the `function_end` event. This value is guaranteed to be the same value received by the trace event for the corresponding `function_begin`
  • **user_data**: Name of the function being called sent in as `const char *`
  • | None | - -## SYCL Stream `"ur.call.debug"` Notification Signatures - -| Trace Point Type | Parameter Description | Metadata | -| :------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | -| `function_with_args_begin` |
  • **trace_type**: `xpti::trace_point_type_t::function_with_args_begin` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call.debug` layer.
  • **event**: `nullptr` if code location is not available or event ID with code location data.
  • **instance**: Unique ID to allow the correlation of the `function_with_args_begin` event with the `function_with_args_end` event.
  • **user_data**: A pointer to `function_with_args_t` object, that includes function ID, name, and arguments.
  • | None | -| `function_with_args_end` |
  • **trace_type**: `xpti::trace_point_type_t::function_with_args_end` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call.debug` layer.
  • **event**: `nullptr` if code location is not available or event ID with code location data.
  • **instance**: Unique ID to allow the correlation of the `function_with_args_begin` event with the `function_with_args_end` event. This value is guaranteed to be the same value received by the trace event for the corresponding `function_with_args_begin`
  • **user_data**: A pointer to `function_with_args_t` object, that includes function ID, name, arguments, and return value.
  • | None | - -## SYCL Stream `"sycl"` Notification Signatures - -All trace point types in bold provide semantic information about the graph, nodes and edges and the topology of the asynchronous task graphs created by the runtime. -| Trace Point Type | Parameter Description | Metadata | -| :----------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **`graph_create`** |
  • **trace_type**: `xpti::trace_point_type_t::graph_create` that marks the creation of an asynchronous graph.
  • **parent**: `nullptr`
  • **event**: The global asynchronous graph object ID. All other graph related events such as node and edge creation will always this ID as the parent ID.
  • **instance**: Unique ID related to the event, but not a correlation ID as there are other events to correlate to.
  • **user_data**: `nullptr`
  • SYCL runtime will always have one instance of a graph object with many disjoint subgraphs that get created during the execution of an application.
    | None | -| **`node_create`** |
  • **trace_type**: `xpti::trace_point_type_t::node_create` that marks the creation of a node in the graph, which could be a computational kernel or memory operation.
  • **parent**: The global graph event that is created during the `graph_create` event.
  • **event**: The unique ID that identifies the data parallel compute operation or memory operation.
  • **instance**: Unique ID related to the event, but not a correlation ID as there are other events to correlate to.
  • **user_data**: Command type that has been submitted through the command group handler, which could be one of: `command_group_node`, `memory_transfer_node`, `memory_allocation_node`, `sub_buffer_creation_node`, `memory_deallocation_node`, `host_acc_create_buffer_lock_node`, `host_acc_destroy_buffer_release_node` combined with the address of the command group object and represented as a string [`const char *`]
  • SYCL runtime will always have one instance of a graph object with many disjoint subgraphs that get created during the execution of an application.
    |
  • Computational Kernels
  • `sycl_device`, `sycl_device_type`, `sycl_device_name`, `kernel_name`, `from_source`, `sym_function_name`, `sym_source_file_name`, `sym_line_no`. The per-queue unique ID can be obtained by using `xptiGetStashedTuple` API call. See `queue_create` documentation for usage information.
  • Memory operations
  • `memory_object`, `offset`, `access_range`, `allocation_type`, `copy_from`, `copy_to`,`device_id`, `device_name`, `memory_size`, `src_memory_ptr`, `dest_memory_ptr`, `memory_ptr`, `value_set`. The per-queue unique ID can be obtained by using `xptiGetSTashedTuple` API call. See `queue_create` documentation for usage information. | -| **`edge_create`** |
  • **trace_type**: `xpti::trace_point_type_t::graph_create` that marks the creation of an asynchronous graph.
  • **parent**: The global graph event that is created during the `graph_create` event.
  • **event**: The unique ID that identifies the dependence relationship between two operations.
  • **instance**: Unique ID related to the event, but not a correlation ID as there are other events to correlate to.
  • **user_data**: `nullptr`
  • Edges capture dependence relationships between computations or computations and memory operations.
    | `access_mode`, `memory_object`, `event` | -| `task_begin` |
  • **trace_type**: `xpti::trace_point_type_t::task_begin` that marks the beginning of a task belonging to one of the nodes in the graph. When the trace event is for a kernel executing on a device other than the the CPU, this `task_begin` and corresponding `task_end` mark the submit call. To track the execution of the kernel on the device, the `trace_signal` event must be monitored to get the kernel event handle from which the execution statistics can be gathered.
  • **parent**: The global graph event that is created during the `graph_create` event.
  • **event**: The event ID will reflect the ID of the computation or memory operation kernel, which would be one of the nodes in the graph.
  • **instance**: Instance ID for the task that can be used to correlate it with the corresponding `task_end` trace event.
  • **user_data**: `nullptr`
  • | Same metadata defined for the node the trace task belongs to. | -| `task_end` |
  • **trace_type**: `xpti::trace_point_type_t::task_end` that marks the end of a task belonging to one of the nodes in the graph. The specific task instance can be tacked through the instance ID parameter which helps correlate the `task_end` with the corresponding `task_begin`.
  • **parent**: The global graph event that is created during the `graph_create` event.
  • **event**: The event ID will reflect the ID of the computation or memory operation kernel, which would be one of the nodes in the graph.
  • **instance**: Instance ID for the task that can be used to correlate it with the corresponding `task_begin` trace event.
  • **user_data**: `nullptr`
  • | Same metadata defined for the node the trace task belongs to. | -| `signal` |
  • **trace_type**: `xpti::trace_point_type_t::signal` that marks the an event that contains the `event` handle of an executing kernel on a device.
  • **parent**: The global graph event that is created during the `graph_create` event.
  • **event**: The event ID will reflect the ID of the computation or memory operation kernel, which would be one of the nodes in the graph.
  • **instance**: Instance ID for the task for which the signal has been generated.
  • **user_data**: Address of the kernel event that is returned by the device so the progress of the execution can be tracked.
  • | Same metadata defined for the node the trace task belongs to. | -| `wait_begin` |
  • **trace_type**: `xpti::trace_point_type_t::wait_begin` that marks the beginning of the wait on an `event`
  • **parent**: `nullptr`
  • **event**: The event ID will reflect the ID of the command group object submission that created this event, the queue or a new event based on the combination of the string "queue.wait" and the address of the event.
  • **instance**: Unique ID to allow the correlation of the `wait_begin` event with the `wait_end` event.
  • **user_data**: String indicating `queue.wait` and the address of the event sent in as `const char *`
  • Tracing the `queue.wait()` or `queue.wait_and_throw()` will capture the waiting on the action represented by the event object, which could be the execution of a kernel, completion of a memory operation, etc that is embedded in the command group handler. All wait events contain metadata that indicates the SYCL device on which the corresponding operation has been submitted. If the event is from a command group handler, then the source location information is available as well.
    | `sycl_device`, `sycl_device_type`, `sycl_device_name`, `sym_function_name`, `sym_source_file_name`, `sym_line_no`, `sym_column_no` | -| `wait_end` |
  • **trace_type**: `xpti::trace_point_type_t::wait_end` that marks the beginning of the wait on an `event`
  • **parent**: `nullptr`
  • **event**: The event ID will reflect the ID of the command group object submission that created this event, the queue or a new event based on the combination of the string "queue.wait" and the address of the event.
  • **instance**: Unique ID to allow the correlation of the `wait_begin` event with the `wait_end` event.
  • **user_data**: String indicating `queue.wait` and the address of the event as `const char *`
  • | `sycl_device`, `sycl_device_type`, `sycl_device_name`, `sym_function_name`, `sym_source_file_name`, `sym_line_no`, `sym_column_no` | -| `barrier_begin` |
  • **trace_type**: `xpti::trace_point_type_t::barrier_begin` that marks the beginning of a barrier while enqueuing a command group object
  • **parent**: The global graph event that is created during the `graph_create` event.
  • **event**: The event ID will reflect the ID of the command group object that has encountered a barrier during the enqueue operation.
  • **instance**: Unique ID to allow the correlation of the `barrier_begin` event with the `barrier_end` event.
  • **user_data**: String indicating `enqueue.barrier` and the reason for the barrier as a `const char *`
  • The reason for the barrier could be one of `Buffer locked by host accessor`, `Blocked by host task` or `Unknown reason`.
    |
  • Computational Kernels
  • `sycl_device`, `sycl_device_type`, `sycl_device_name`, `kernel_name`, `from_source`, `sym_function_name`, `sym_source_file_name`, `sym_line_no`, `sym_column_no`
  • Memory operations
  • `memory_object`, `offset`, `access_range_start`, `access_range_end`, `allocation_type`, `copy_from`, `copy_to` | -| `barrier_end` |
  • **trace_type**: `xpti::trace_point_type_t::barrier_end` that marks the end of the barrier that is encountered during enqueue.
  • **parent**: The global graph event that is created during the `graph_create` event.
  • **event**: The event ID will reflect the ID of the command group object that has encountered a barrier during the enqueue operation.
  • **instance**: Unique ID to allow the correlation of the `barrier_begin` event with the `barrier_end` event.
  • **user_data**: String indicating `enqueue.barrier` and the reason for the barrier as a `const char *`
  • The reason for the barrier could be one of `Buffer locked by host accessor`, `Blocked by host task` or `Unknown reason`.
    |
  • Computational Kernels
  • `sycl_device`, `sycl_device_type`, `sycl_device_name`, `kernel_name`, `from_source`, `sym_function_name`, `sym_source_file_name`, `sym_line_no`, `sym_column_no`
  • Memory operations
  • `memory_object`, `offset`, `access_range_start`, `access_range_end`, `allocation_type`, `copy_from`, `copy_to` | -| `diagnostics` |
  • **trace_type**: `xpti::trace_point_type_t::diagnostics` that represents general purpose notifications. For example, it is emitted when an exception is thrown in SYCL runtime.
  • **parent**: Set to NULL.
  • **event**: The event ID will reflect the code location of notification origin, if available.
  • **instance**: An instance ID that records the number of times this code location has been seen.
  • **user_data**: String with diagnostic message as a `const char *`
  • | `sym_function_name`, `sym_source_file_name`, `sym_line_no`, `sym_column_no` | -| `queue_create` |
  • **trace_type**: `xpti::trace_point_type_t::queue_create` that marks the creation of a queue, which could be a device or host queue.
  • **parent**: Set to NULL.
  • **event**: The event ID will reflect the code location of notification origin, if available.
  • **instance**: Will contain the instance ID of the queue, which is a per-queue unique identifier. For example, if the queue is created in a loop, the **event** will be the same as it happens at the same code location, but the **instance** will help differentiate between the different queues being created and used.
  • **user_data**: Not meaningful for this trace type. Could contain string with 'queue_create' or nullptr.
  • This signal is emitted only once for every queue object, notifies about successful queue creation (the signal is not emitted if any exception happens during queue creation).
    | `sycl_context`, `sycl_device_name`, `sycl_device`, `is_inorder`, `queue_handle`

    `queue_id` field has been deprecated and replaced with the **instance** information and supporting XPTI API calls (`xptiGetStashedTuple`). Using the **instance** information is the recommended approach.

    `char *key = 0;`

    `uint64_t value;`

    `if (xptiGetStashedTuple(&key, value) ==xpti::result_t::XPTI_RESULT_SUCCESS) {`

    `// key will contain "queue_id"`

    `// value will contain the per-queue unique ID`

    `}`

    `queue_handle` is absent for host queue since no backend object is used.

    | -| `queue_destroy` |
  • **trace_type**: `xpti::trace_point_type_t::queue_destroy` that marks the destruction of a queue, which could be a device or host queue.
  • **parent**: Set to NULL.
  • **event**: The event ID will reflect the code location of notification origin, if available.
  • **instance**: Will contain the instance ID of the queue, which is a per-queue unique identifier.
  • **user_data**: Not meaningful for this trace type. Could contain string with 'queue_destroy' or nullptr.
  • This signal is emitted only once for every queue object, notifies about queue destruction. Contains the same metadata set for corresponding 'queue_create' signal. **event** and corresponding metadata will be destroyed right after notification.
    | `sycl_context`, `sycl_device_name`, `sycl_device`, `is_inorder`, `queue_id`, `queue_handle`

    `queue_id` field has been deprecated and replaced with the **instance** information and supporting XPTI API calls (`xptiGetStashedTuple`). Using the **instance** information is the recommended approach. `queue_handle` is absent for host queue since no backend object is used. | - -### Metadata description - -| Metadata | Type | Description | -| :--------------------: | :-------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `access_mode` | `int` | Value of `sycl::access::mode` enum | -| `access_range_start` | `size_t` | Start of accessor range | -| `access_range_end` | `size_t` | End of accessor range | -| `allocation_type` | C-style string | Allocation type | -| `copy_from` | `size_t` | ID of source device | -| `copy_to` | `size_t` | ID of target device | -| `event` | `size_t` | Unique identifier of event | -| `from_source` | `bool` | `true` if kernel comes from user source | -| `kernel_name` | C-style string | Kernel name | -| `memory_object` | `size_t` | Unique identifier of memory object | -| `offset` | `size_t` | Accessor offset size in bytes | -| `sycl_device` | `size_t` | Unique identifier of SYCL device | -| `sycl_device_type` | C-style string | `CPU`, `GPU`, `ACC`, or `HOST` | -| `sycl_device_name` | C-style string | Result of `sycl::device::get_info()` | -| `sym_function_name` | C-style string | Function name | -| `sym_source_file_name` | C-style string | Source file name | -| `sym_line_no` | `int32_t` | File line number | -| `sym_column_no` | `int32_t` | File column number | -| `enqueue_kernel_data` | `xpti::offload_kernel_arg_data_t` | Includes kernel execution parameters (global size, local size, offset) and number of kernel arguments | -| `argN` | `xpti::offload_kernel_arg_data_t` | Description for the Nth kernel argument. It includes argument kind (sycl::detail::kernel_param_kind_t), pointer to the value, size and index in the argument list. | - -## Buffer management stream `"sycl.experimental.buffer"` Notification Signatures - -| Trace Point Type | Parameter Description | Metadata | -| :-------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | -| `offload_alloc_memory_object_construct` |
  • **trace_type**: `xpti::trace_point_type_t::offload_memory_object_data_t` that marks offload buffer creation point
  • **parent**: Event ID created for all functions in the `oneapi.experimental.buffer` layer.
  • **event**: `xpti::trace_event_data_t` - contains information about source location.
  • **instance**: `nullptr` since no begin-end event alignment is needed.
  • **user_data**: A pointer to `offload_memory_object_data_t` object, that includes buffer object ID, host pointer used to create/initialize buffer, buffer element information (type name, size), number of buffer dimensions and buffer size for each dimension.
  • | None | -| `offload_alloc_memory_object_associate` |
  • **trace_type**: `xpti::trace_point_type_t::offload_association_data_t` that provides association between user level buffer object and platform specific memory object
  • **parent**: Event ID created for all functions in the `oneapi.experimental.buffer` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: `nullptr` since no begin-end event alignment is needed.
  • **user_data**: A pointer to `offload_association_data_t` object, that includes user object ID and platform-specific representation for offload buffer.
  • | None | -| `offload_alloc_memory_object_destruct` |
  • **trace_type**: `xpti::trace_point_type_t::offload_memory_object_data_t` that marks offload buffer destruction point
  • **parent**: Event ID created for all functions in the `oneapi.experimental.buffer` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: `nullptr` since no begin-end event alignment is needed.
  • **user_data**: A pointer to `offload_memory_object_data_t` object, that includes buffer object ID.
  • | None | -| `offload_alloc_memory_object_release` |
  • **trace_type**: `xpti::trace_point_type_t::offload_memory_object_release_data_t` that provides information about release of platform specific memory object
  • **parent**: `nullptr` - since the stream of data just captures functions being called.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: `nullptr` since no begin-end event alignment is needed.
  • **user_data**: A pointer to `offload_association_data_t` object, that includes user object ID and platform-specific representation for offload buffer.
  • | None | -| `offload_alloc_accessor` |
  • **trace_type**: `xpti::trace_point_type_t::offload_accessor_data_t` that marks offload accessor creation point
  • **parent**: Event ID created for all functions in the `oneapi.experimental.buffer` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: `nullptr` since no begin-end event alignment is needed.
  • **user_data**: A pointer to `offload_accessor_data_t` object, that includes buffer object ID, accessor handle created from specific buffer, accessor information (access target and mode).
  • | None | - -## Image management stream `"sycl.experimental.image"` Notification Signatures - -| Trace Point Type | Parameter Description | Metadata | -| :-------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | -| `offload_alloc_memory_object_construct` |
  • **trace_type**: `xpti::trace_point_type_t::offload_image_data_t` that marks offload image creation point
  • **parent**: Event ID created for all functions in the `oneapi.experimental.image` layer.
  • **event**: `xpti::trace_event_data_t` - contains information about source location.
  • **instance**: `nullptr` since no begin-end event alignment is needed.
  • **user_data**: A pointer to `offload_image_data_t` object, that includes image object ID, host pointer used to create/initialize image, number of image dimensions, the image format and sampler information (addressing mode, coordinate normalization mode, filtering mode).
  • | None | -| `offload_alloc_memory_object_associate` |
  • **trace_type**: `xpti::trace_point_type_t::offload_association_data_t` that provides association between user level image object and platform specific memory object
  • **parent**: Event ID created for all functions in the `oneapi.experimental.image` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: `nullptr` since no begin-end event alignment is needed.
  • **user_data**: A pointer to `offload_association_data_t` object, that includes user object ID and platform-specific representation for offload image.
  • | None | -| `offload_alloc_memory_object_destruct` |
  • **trace_type**: `xpti::trace_point_type_t::offload_image_data_t` that marks offload image destruction point
  • **parent**: Event ID created for all functions in the `oneapi.experimental.image` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: `nullptr` since no begin-end event alignment is needed.
  • **user_data**: A pointer to `offload_image_data_t` object, that includes image object ID.
  • | None | -| `offload_alloc_memory_object_release` |
  • **trace_type**: `xpti::trace_point_type_t::offload_association_data_t` that provides information about release of platform specific memory object
  • **parent**: `nullptr` - since the stream of data just captures functions being called.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: `nullptr` since no begin-end event alignment is needed.
  • **user_data**: A pointer to `offload_association_data_t` object, that includes user object ID and platform-specific representation for offload image.
  • | None | -| `offload_alloc_accessor` |
  • **trace_type**: `xpti::trace_point_type_t::offload_image_accessor_data_t` that marks offload image accessor creation point
  • **parent**: Event ID created for all functions in the `oneapi.experimental.image` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: `nullptr` since no begin-end event alignment is needed.
  • **user_data**: A pointer to `offload_image_accessor_data_t` object, that includes image object ID, accessor handle created from specific image, access target (if the accessor is not a host accessor), access mode (if the accessor is to an unsampled image) and element information (type name, size).
  • | None | - -## SYCL Memory Allocations Stream `"sycl.experimental.mem_alloc"` Notification Signatures - -| Trace Point Type | Parameter Description | Metadata | -| :-----------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | -| `mem_alloc_begin` |
  • **trace_type**: `xpti::trace_point_type_t::mem_alloc_begin` that marks the beginning of memory allocation process
  • **parent**: Event ID created for all functions in the `oneapi.level_zero.experimental.mem_alloc` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `mem_alloc_begin` event with the `mem_alloc_end` event.
  • **user_data**: A pointer to `mem_alloc_data_t` object, that includes memory object ID (if any), allocation size, and guard zone size (if any).
  • | None | -| `mem_alloc_end` |
  • **trace_type**: `xpti::trace_point_type_t::mem_alloc_end` that marks the end of memory allocation process
  • **parent**: Event ID created for all functions in the `oneapi.level_zero.experimental.mem_alloc` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `mem_alloc_begin` event with the `mem_alloc_end` event. This value is guaranteed to be the same value received by the trace event for the corresponding `mem_alloc_begin`.
  • **user_data**: A pointer to `mem_alloc_data_t` object, that includes memory object ID (if any), allocated pointer, allocation size, and guard zone size (if any).
  • | None | -| `mem_release_begin` |
  • **trace_type**: `xpti::trace_point_type_t::mem_release_begin` that marks the beginning of memory allocation process
  • **parent**: Event ID created for all functions in the `oneapi.level_zero.experimental.mem_alloc` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `mem_release_begin` event with the `mem_release_end` event.
  • **user_data**: A pointer to `mem_alloc_data_t` object, that includes memory object ID (if any) and released pointer.
  • | None | -| `mem_release_end` |
  • **trace_type**: `xpti::trace_point_type_t::mem_release_end` that marks the end of memory allocation process
  • **parent**: Event ID created for all functions in the `oneapi.level_zero.experimental.mem_alloc` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `mem_release_begin` event with the `mem_release_end` event. This value is guaranteed to be the same value received by the trace event for the corresponding `mem_release_begin`.
  • **user_data**: A pointer to `mem_alloc_data_t` object, that includes memory object ID (if any) and released pointer.
  • | None | - -## SYCL Stream `"sycl.experimental.level_zero.call"` Notification Signatures - -This stream transfers events about Level Zero API calls made by SYCL -application. - -| Trace Point Type | Parameter Description | Metadata | -| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | -| `function_begin` |
  • **trace_type**: `xpti::trace_point_type_t::function_begin` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `function_begin` event with the `function_end` event.
  • **user_data**: Name of the function being called sent in as `const char *`
  • | None | -| `function_end` |
  • **trace_type**: `xpti::trace_point_type_t::function_end` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `function_begin` event with the `function_end` event. This value is guaranteed to be the same value received by the trace event for the corresponding `function_begin`
  • **user_data**: Name of the function being called sent in as `const char *`
  • | None | - -## SYCL Stream `"sycl.experimental.level_zero.debug"` Notification Signatures - -This stream transfers events about Level Zero API calls and their function -arguments made by SYCL application. - -| Trace Point Type | Parameter Description | Metadata | -| :------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | -| `function_with_args_begin` |
  • **trace_type**: `xpti::trace_point_type_t::function_with_args_begin` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call.debug` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `function_with_args_begin` event with the `function_with_args_end` event.
  • **user_data**: A pointer to `function_with_args_t` object, that includes function ID, name, and arguments.
  • | None | -| `function_with_args_end` |
  • **trace_type**: `xpti::trace_point_type_t::function_with_args_end` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call.debug` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `function_with_args_begin` event with the `function_with_args_end` event. This value is guaranteed to be the same value received by the trace event for the corresponding `function_with_args_begin`
  • **user_data**: A pointer to `function_with_args_t` object, that includes function ID, name, arguments, and return value.
  • | None | - -## SYCL Stream `"sycl.experimental.cuda.call"` Notification Signatures - -This stream transfers events about CUDA Driver API calls made by SYCL -application. - -| Trace Point Type | Parameter Description | Metadata | -| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | -| `function_begin` |
  • **trace_type**: `xpti::trace_point_type_t::function_begin` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `function_begin` event with the `function_end` event.
  • **user_data**: Name of the function being called sent in as `const char *`
  • | None | -| `function_end` |
  • **trace_type**: `xpti::trace_point_type_t::function_end` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `function_begin` event with the `function_end` event. This value is guaranteed to be the same value received by the trace event for the corresponding `function_begin`
  • **user_data**: Name of the function being called sent in as `const char *`
  • | None | - -## SYCL Stream `"sycl.experimental.cuda.debug"` Notification Signatures - -This stream transfers events about CUDA Driver API calls and their function -arguments made by SYCL application. - -| Trace Point Type | Parameter Description | Metadata | -| :------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | -| `function_with_args_begin` |
  • **trace_type**: `xpti::trace_point_type_t::function_with_args_begin` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call.debug` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `function_with_args_begin` event with the `function_with_args_end` event.
  • **user_data**: A pointer to `function_with_args_t` object, that includes function ID, name, and arguments.
  • | None | -| `function_with_args_end` |
  • **trace_type**: `xpti::trace_point_type_t::function_with_args_end` that marks the beginning of a function
  • **parent**: Event ID created for all functions in the `ur.call.debug` layer.
  • **event**: `nullptr` - since the stream of data just captures functions being called.
  • **instance**: Unique ID to allow the correlation of the `function_with_args_begin` event with the `function_with_args_end` event. This value is guaranteed to be the same value received by the trace event for the corresponding `function_with_args_begin`
  • **user_data**: A pointer to `function_with_args_t` object, that includes function ID, name, arguments, and return value.
  • | None | - diff --git a/sycl/doc/index.rst b/sycl/doc/index.rst index cc4961dd7f438..f8aa11a864175 100644 --- a/sycl/doc/index.rst +++ b/sycl/doc/index.rst @@ -37,7 +37,6 @@ Design Documents for the oneAPI DPC++ Compiler design/SharedLibraries design/OptionalDeviceFeatures design/ParallelForRangeRounding - design/SYCLInstrumentationUsingXPTI design/ITTAnnotations design/DeviceGlobal design/CompileTimeProperties diff --git a/sycl/include/sycl/accessor.hpp b/sycl/include/sycl/accessor.hpp index e8034f77c5e9a..3d9945520c5a5 100644 --- a/sycl/include/sycl/accessor.hpp +++ b/sycl/include/sycl/accessor.hpp @@ -244,11 +244,6 @@ struct AccHostDataT { void *Reserved = nullptr; }; -void __SYCL_EXPORT constructorNotification(void *BufferObj, void *AccessorObj, - access::target Target, - access::mode Mode, - const code_location &CodeLoc); - template using IsPropertyListT = typename std::is_base_of; @@ -956,14 +951,12 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : detail::getSyclObjImpl(BufferRef).get(), AdjustedDim, sizeof(DataT), IsPlaceH, BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); if (!AccessorBaseHost::isPlaceholder()) addHostAccessorAndWait(AccessorBaseHost::impl.get()); initHostAcc(); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); #endif } @@ -997,14 +990,12 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : detail::getSyclObjImpl(BufferRef).get(), AdjustedDim, sizeof(DataT), IsPlaceH, BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); if (!AccessorBaseHost::isPlaceholder()) addHostAccessorAndWait(AccessorBaseHost::impl.get()); initHostAcc(); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); #endif } @@ -1034,13 +1025,11 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : getAdjustedMode(PropertyList), detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT), BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); detail::associateWithHandler(CommandGroupHandler, this, AccessTarget); initHostAcc(); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); } #endif @@ -1072,13 +1061,11 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : getAdjustedMode(PropertyList), detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT), BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); detail::associateWithHandler(CommandGroupHandler, this, AccessTarget); initHostAcc(); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); } #endif @@ -1106,14 +1093,12 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT), IsPlaceH, BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); if (!AccessorBaseHost::isPlaceholder()) addHostAccessorAndWait(AccessorBaseHost::impl.get()); initHostAcc(); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); } #endif @@ -1143,14 +1128,12 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT), IsPlaceH, BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); if (!AccessorBaseHost::isPlaceholder()) addHostAccessorAndWait(AccessorBaseHost::impl.get()); initHostAcc(); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); } #endif @@ -1207,13 +1190,11 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : getAdjustedMode(PropertyList), detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT), BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); detail::associateWithHandler(CommandGroupHandler, this, AccessTarget); initHostAcc(); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); } #endif @@ -1243,13 +1224,11 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : getAdjustedMode(PropertyList), detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT), BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); initHostAcc(); detail::associateWithHandler(CommandGroupHandler, this, AccessTarget); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); } #endif @@ -1420,6 +1399,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT), IsPlaceH, BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); if (!AccessorBaseHost::isPlaceholder()) @@ -1431,9 +1411,6 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : "exceed the bounds of the buffer"); initHostAcc(); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); } #endif @@ -1463,6 +1440,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT), IsPlaceH, BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); if (!AccessorBaseHost::isPlaceholder()) @@ -1474,9 +1452,6 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : "exceed the bounds of the buffer"); initHostAcc(); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); } #endif @@ -1535,6 +1510,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT), BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); if (BufferRef.isOutOfBounds(AccessOffset, AccessRange, @@ -1545,9 +1521,6 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : initHostAcc(); detail::associateWithHandler(CommandGroupHandler, this, AccessTarget); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); } #endif @@ -1578,6 +1551,7 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT), BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) { + std::ignore = CodeLoc; throwIfUsedByGraph(); preScreenAccessor(PropertyList); if (BufferRef.isOutOfBounds(AccessOffset, AccessRange, @@ -1588,9 +1562,6 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : initHostAcc(); detail::associateWithHandler(CommandGroupHandler, this, AccessTarget); - detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), - detail::AccessorBaseHost::impl.get(), - AccessTarget, AccessMode, CodeLoc); GDBMethodsAnchor(); } #endif @@ -1645,10 +1616,6 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : PropertyListT::template areSameCompileTimeProperties(), "Compile-time-constant properties must be the same"); (void)CodeLoc; -#ifndef __SYCL_DEVICE_ONLY__ - detail::constructorNotification(getMemoryObject(), impl.get(), AccessTarget, - AccessMode, CodeLoc); -#endif } void swap(accessor &other) { @@ -2250,8 +2217,7 @@ class __SYCL_SPECIAL_CLASS local_accessor_base : } #else : LocalAccessorBaseHost(range<3>{1, 1, 1}, AdjustedDim, sizeof(DataT)) { - detail::constructorNotification(nullptr, LocalAccessorBaseHost::impl.get(), - access::target::local, AccessMode, CodeLoc); + std::ignore = CodeLoc; GDBMethodsAnchor(); } #endif @@ -2268,9 +2234,8 @@ class __SYCL_SPECIAL_CLASS local_accessor_base : #else : LocalAccessorBaseHost(range<3>{1, 1, 1}, AdjustedDim, sizeof(DataT), propList) { - detail::constructorNotification(nullptr, LocalAccessorBaseHost::impl.get(), - access::target::local, AccessMode, CodeLoc); - GDBMethodsAnchor(); + std::ignore = CodeLoc; + GDBMethodsAnchor(); } #endif @@ -2285,8 +2250,7 @@ class __SYCL_SPECIAL_CLASS local_accessor_base : #else : LocalAccessorBaseHost(detail::convertToArrayOfN<3, 1>(AllocationSize), AdjustedDim, sizeof(DataT)) { - detail::constructorNotification(nullptr, LocalAccessorBaseHost::impl.get(), - access::target::local, AccessMode, CodeLoc); + std::ignore = CodeLoc; GDBMethodsAnchor(); } #endif @@ -2305,9 +2269,8 @@ class __SYCL_SPECIAL_CLASS local_accessor_base : #else : LocalAccessorBaseHost(detail::convertToArrayOfN<3, 1>(AllocationSize), AdjustedDim, sizeof(DataT), propList) { - detail::constructorNotification(nullptr, LocalAccessorBaseHost::impl.get(), - access::target::local, AccessMode, CodeLoc); - GDBMethodsAnchor(); + std::ignore = CodeLoc; + GDBMethodsAnchor(); } #endif diff --git a/sycl/include/sycl/accessor_image.hpp b/sycl/include/sycl/accessor_image.hpp index f784561bafd95..c0fa764407c0f 100644 --- a/sycl/include/sycl/accessor_image.hpp +++ b/sycl/include/sycl/accessor_image.hpp @@ -51,16 +51,6 @@ template struct IsValidSampledCoord2020DataT<3, T> { constexpr static bool value = std::is_same_v; }; -void __SYCL_EXPORT unsampledImageConstructorNotification( - void *ImageObj, void *AccessorObj, - const std::optional &Target, access::mode Mode, - const void *Type, uint32_t ElemSize, const code_location &CodeLoc); - -void __SYCL_EXPORT sampledImageConstructorNotification( - void *ImageObj, void *AccessorObj, - const std::optional &Target, const void *Type, - uint32_t ElemSize, const code_location &CodeLoc); - class UnsampledImageAccessorImplHost; class SampledImageAccessorImplHost; using UnsampledImageAccessorImplPtr = @@ -819,6 +809,7 @@ class __SYCL_EBO unsampled_image_accessor : {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0}, ImageRef.getChannelType(), ImageRef.getChannelOrder(), PropList) { + std::ignore = CodeLoc; device Device = detail::getDeviceFromHandler(CommandGroupHandlerRef); // Avoid aspect::image warning. aspect ImageAspect = aspect::image; @@ -828,9 +819,6 @@ class __SYCL_EBO unsampled_image_accessor : "Device associated with command group handler does not have " "aspect::image."); - detail::unsampledImageConstructorNotification( - detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), AccessTarget, - AccessMode, (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc); detail::associateWithHandler(CommandGroupHandlerRef, this, AccessTarget); GDBMethodsAnchor(); } @@ -972,11 +960,8 @@ class __SYCL_EBO host_unsampled_image_accessor {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0}, ImageRef.getChannelType(), ImageRef.getChannelOrder(), PropList) { + std::ignore = CodeLoc; addHostUnsampledImageAccessorAndWait(base_class::impl.get()); - - detail::unsampledImageConstructorNotification( - detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), std::nullopt, - AccessMode, (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc); } /* -- common interface members -- */ @@ -1120,6 +1105,7 @@ class __SYCL_EBO sampled_image_accessor : {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0}, ImageRef.getChannelType(), ImageRef.getChannelOrder(), ImageRef.getSampler(), PropList) { + std::ignore = CodeLoc; device Device = detail::getDeviceFromHandler(CommandGroupHandlerRef); // Avoid aspect::image warning. aspect ImageAspect = aspect::image; @@ -1129,9 +1115,6 @@ class __SYCL_EBO sampled_image_accessor : "Device associated with command group handler does not have " "aspect::image."); - detail::sampledImageConstructorNotification( - detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), AccessTarget, - (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc); detail::associateWithHandler(CommandGroupHandlerRef, this, AccessTarget); GDBMethodsAnchor(); } @@ -1249,11 +1232,8 @@ class __SYCL_EBO host_sampled_image_accessor {ImageRef.getRowPitch(), ImageRef.getSlicePitch(), 0}, ImageRef.getChannelType(), ImageRef.getChannelOrder(), ImageRef.getSampler(), PropList) { + std::ignore = CodeLoc; addHostSampledImageAccessorAndWait(base_class::impl.get()); - - detail::sampledImageConstructorNotification( - detail::getSyclObjImpl(ImageRef).get(), this->impl.get(), std::nullopt, - (const void *)typeid(DataT).name(), sizeof(DataT), CodeLoc); } /* -- common interface members -- */ diff --git a/sycl/include/sycl/buffer.hpp b/sycl/include/sycl/buffer.hpp index 8b3a14af607f2..5f7c1bcad5c94 100644 --- a/sycl/include/sycl/buffer.hpp +++ b/sycl/include/sycl/buffer.hpp @@ -125,11 +125,6 @@ class __SYCL_EXPORT buffer_plain { void set_write_back(bool NeedWriteBack); - void constructorNotification(const detail::code_location &CodeLoc, - void *UserObj, const void *HostObj, - const void *Type, uint32_t Dim, - uint32_t ElemType, size_t Range[3]); - template bool has_property() const noexcept { return getPropList().template has_property(); } @@ -204,9 +199,7 @@ class buffer : public detail::buffer_plain, std::make_unique< detail::SYCLMemObjAllocatorHolder>()), Range(bufferRange) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), nullptr, (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } buffer(const range &bufferRange, AllocatorT allocator, @@ -217,9 +210,7 @@ class buffer : public detail::buffer_plain, std::make_unique>( allocator)), Range(bufferRange) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), nullptr, (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } buffer(T *hostData, const range &bufferRange, @@ -230,9 +221,7 @@ class buffer : public detail::buffer_plain, std::make_unique< detail::SYCLMemObjAllocatorHolder>()), Range(bufferRange) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), hostData, (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } buffer(T *hostData, const range &bufferRange, @@ -243,9 +232,7 @@ class buffer : public detail::buffer_plain, std::make_unique>( allocator)), Range(bufferRange) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), hostData, (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } template @@ -258,9 +245,7 @@ class buffer : public detail::buffer_plain, std::make_unique< detail::SYCLMemObjAllocatorHolder>()), Range(bufferRange) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), hostData, (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } template @@ -273,9 +258,7 @@ class buffer : public detail::buffer_plain, std::make_unique>( allocator)), Range(bufferRange) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), hostData, (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } buffer(const std::shared_ptr &hostData, @@ -288,10 +271,7 @@ class buffer : public detail::buffer_plain, allocator), std::is_const::value), Range(bufferRange) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), (void *)hostData.get(), - (const void *)typeid(T).name(), dimensions, sizeof(T), - detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } buffer(const std::shared_ptr &hostData, @@ -304,10 +284,7 @@ class buffer : public detail::buffer_plain, allocator), std::is_const::value), Range(bufferRange) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), (void *)hostData.get(), - (const void *)typeid(T).name(), dimensions, sizeof(T), - detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } buffer(const std::shared_ptr &hostData, @@ -320,10 +297,7 @@ class buffer : public detail::buffer_plain, detail::SYCLMemObjAllocatorHolder>(), std::is_const::value), Range(bufferRange) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), (void *)hostData.get(), - (const void *)typeid(T).name(), dimensions, sizeof(T), - detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } buffer(const std::shared_ptr &hostData, @@ -336,10 +310,7 @@ class buffer : public detail::buffer_plain, detail::SYCLMemObjAllocatorHolder>(), std::is_const::value), Range(bufferRange) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), (void *)hostData.get(), - (const void *)typeid(T).name(), dimensions, sizeof(T), - detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } template ::value), Range(range<1>(std::distance(first, last))) { - size_t r[3] = {Range[0], 0, 0}; - buffer_plain::constructorNotification(CodeLoc, (void *)impl.get(), &first, - (const void *)typeid(T).name(), - dimensions, sizeof(T), r); + std::ignore = CodeLoc; } template >(), detail::iterator_to_const_type_t::value), Range(range<1>(std::distance(first, last))) { - size_t r[3] = {Range[0], 0, 0}; - buffer_plain::constructorNotification(CodeLoc, (void *)impl.get(), &first, - (const void *)typeid(T).name(), - dimensions, sizeof(T), r); + std::ignore = CodeLoc; } // This constructor is a prototype for a future SYCL specification @@ -419,10 +384,7 @@ class buffer : public detail::buffer_plain, std::make_unique>( allocator)), Range(range<1>(container.size())) { - size_t r[3] = {Range[0], 0, 0}; - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), container.data(), - (const void *)typeid(T).name(), dimensions, sizeof(T), r); + std::ignore = CodeLoc; } // This constructor is a prototype for a future SYCL specification @@ -439,9 +401,7 @@ class buffer : public detail::buffer_plain, : buffer_plain(b.impl), Range(subRange), OffsetInBytes(getOffsetInBytes(baseIndex, b.Range)), IsSubBuffer(true) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), impl.get(), (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; if (b.is_sub_buffer()) throw sycl::exception(make_error_code(errc::invalid), @@ -458,18 +418,14 @@ class buffer : public detail::buffer_plain, const detail::code_location CodeLoc = detail::code_location::current()) : buffer_plain(rhs.impl), Range(rhs.Range), OffsetInBytes(rhs.OffsetInBytes), IsSubBuffer(rhs.IsSubBuffer) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), impl.get(), (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } buffer(buffer &&rhs, const detail::code_location CodeLoc = detail::code_location::current()) : buffer_plain(std::move(rhs.impl)), Range(rhs.Range), OffsetInBytes(rhs.OffsetInBytes), IsSubBuffer(rhs.IsSubBuffer) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), impl.get(), (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } buffer &operator=(const buffer &rhs) = default; @@ -757,9 +713,7 @@ class buffer : public detail::buffer_plain, Range{0} { Range[0] = buffer_plain::getSize() / sizeof(T); - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), &MemObject, (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } void addOrReplaceAccessorProperties(const property_list &PropertyList) { @@ -777,9 +731,7 @@ class buffer : public detail::buffer_plain, const detail::code_location CodeLoc = detail::code_location::current()) : buffer_plain(Impl), Range(reinterpretRange), OffsetInBytes(reinterpretOffset), IsSubBuffer(isSubBuffer) { - buffer_plain::constructorNotification( - CodeLoc, (void *)impl.get(), Impl.get(), (const void *)typeid(T).name(), - dimensions, sizeof(T), detail::rangeToArray(Range).data()); + std::ignore = CodeLoc; } template diff --git a/sycl/include/sycl/detail/ur.hpp b/sycl/include/sycl/detail/ur.hpp index 1ed65046c0c1b..38b613026ed91 100644 --- a/sycl/include/sycl/detail/ur.hpp +++ b/sycl/include/sycl/detail/ur.hpp @@ -31,13 +31,6 @@ typedef void (*pi_context_extended_deleter)(void *user_data); struct _sycl_device_binary_property_struct; using sycl_device_binary_property = _sycl_device_binary_property_struct*; -#ifdef XPTI_ENABLE_INSTRUMENTATION -// Forward declarations -namespace xpti { -struct trace_event_data_t; -} -#endif - namespace sycl { inline namespace _V1 { diff --git a/sycl/include/sycl/ext/intel/experimental/pipes.hpp b/sycl/include/sycl/ext/intel/experimental/pipes.hpp index b7f912183439c..5e36f1700fcb0 100644 --- a/sycl/include/sycl/ext/intel/experimental/pipes.hpp +++ b/sycl/include/sycl/ext/intel/experimental/pipes.hpp @@ -24,11 +24,6 @@ #include #endif -#ifdef XPTI_ENABLE_INSTRUMENTATION -#include -#include -#endif - #include // for int32_t #include // for string #include // for _Swallow_... diff --git a/sycl/include/sycl/image.hpp b/sycl/include/sycl/image.hpp index 9a2c5fe1dedb9..245356dbec59e 100644 --- a/sycl/include/sycl/image.hpp +++ b/sycl/include/sycl/image.hpp @@ -288,18 +288,6 @@ class __SYCL_EXPORT image_plain { image_channel_type getChannelType() const; - void sampledImageConstructorNotification(const detail::code_location &CodeLoc, - void *UserObj, const void *HostObj, - uint32_t Dim, size_t Range[3], - image_format Format, - const image_sampler &Sampler); - void sampledImageDestructorNotification(void *UserObj); - - void unsampledImageConstructorNotification( - const detail::code_location &CodeLoc, void *UserObj, const void *HostObj, - uint32_t Dim, size_t Range[3], image_format Format); - void unsampledImageDestructorNotification(void *UserObj); - std::shared_ptr impl; const property_list &getPropList() const; @@ -747,9 +735,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(), Dimensions, PropList) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), nullptr, Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } unsampled_image( @@ -763,9 +749,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(Allocator), Dimensions, PropList) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), nullptr, Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } template 1), @@ -781,9 +765,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(), Dimensions, PropList) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), nullptr, Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } template 1), @@ -801,9 +783,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(Allocator), Dimensions, PropList) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), nullptr, Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } unsampled_image( @@ -816,9 +796,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(), Dimensions, PropList) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer, Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } unsampled_image( @@ -832,9 +810,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(Allocator), Dimensions, PropList) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer, Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } template 1), @@ -850,9 +826,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(), Dimensions, PropList) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer, Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } template 1), @@ -870,9 +844,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(Allocator), Dimensions, PropList) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer, Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } unsampled_image( @@ -885,9 +857,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(), Dimensions, PropList, /*IsConstPtr*/ false) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } unsampled_image( @@ -902,9 +872,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(Allocator), Dimensions, PropList, /*IsConstPtr*/ false) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } template 1), @@ -921,9 +889,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(), Dimensions, PropList, /*IsConstPtr*/ false) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } template 1), @@ -941,9 +907,7 @@ class unsampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(Allocator), Dimensions, PropList, /*IsConstPtr*/ false) { - common_base::unsampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions, - detail::rangeToArray(Range).data(), Format); + std::ignore = CodeLoc; } /* -- common interface members -- */ @@ -956,14 +920,7 @@ class unsampled_image unsampled_image &operator=(unsampled_image &&rhs) = default; - ~unsampled_image() { - try { - common_base::unsampledImageDestructorNotification( - (void *)this->impl.get()); - } catch (std::exception &e) { - __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~unsampled_image", e); - } - } + ~unsampled_image() {} bool operator==(const unsampled_image &rhs) const { return this->impl == rhs.impl; @@ -1034,9 +991,7 @@ class sampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(), Dimensions, PropList) { - common_base::sampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), nullptr, Dimensions, - detail::rangeToArray(Range).data(), Format, Sampler); + std::ignore = CodeLoc; } template 1), @@ -1053,9 +1008,7 @@ class sampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(), Dimensions, PropList) { - common_base::sampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer, Dimensions, - detail::rangeToArray(Range).data(), Format, Sampler); + std::ignore = CodeLoc; } sampled_image( @@ -1069,9 +1022,7 @@ class sampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(), Dimensions, PropList) { - common_base::sampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions, - detail::rangeToArray(Range).data(), Format, Sampler); + std::ignore = CodeLoc; } template 1), @@ -1088,9 +1039,7 @@ class sampled_image std::make_unique< detail::SYCLMemObjAllocatorHolder>(), Dimensions, PropList) { - common_base::sampledImageConstructorNotification( - CodeLoc, (void *)this->impl.get(), HostPointer.get(), Dimensions, - detail::rangeToArray(Range).data(), Format, Sampler); + std::ignore = CodeLoc; } /* -- common interface members -- */ @@ -1103,13 +1052,7 @@ class sampled_image sampled_image &operator=(sampled_image &&rhs) = default; - ~sampled_image() { - try { - common_base::sampledImageDestructorNotification((void *)this->impl.get()); - } catch (std::exception &e) { - __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~sampled_image", e); - } - } + ~sampled_image() {} bool operator==(const sampled_image &rhs) const { return this->impl == rhs.impl; diff --git a/sycl/include/sycl/range.hpp b/sycl/include/sycl/range.hpp index 7d3249235a5ca..43f0b7efc731a 100644 --- a/sycl/include/sycl/range.hpp +++ b/sycl/include/sycl/range.hpp @@ -229,18 +229,5 @@ range(size_t, size_t)->range<2>; range(size_t, size_t, size_t)->range<3>; #endif -namespace detail { -// XPTI helpers for creating array from a range. -inline std::array rangeToArray(const range<3> &r) { - return {r[0], r[1], r[2]}; -} -inline std::array rangeToArray(const range<2> &r) { - return {r[0], r[1], 0}; -} -inline std::array rangeToArray(const range<1> &r) { - return {r[0], 0, 0}; -} -} // namespace detail - } // namespace _V1 } // namespace sycl diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index d9f8801d45ba5..b971947e1770a 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -8,17 +8,10 @@ configure_file( ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY) -if (SYCL_ENABLE_XPTI_TRACING) - if (NOT DEFINED LLVM_EXTERNAL_XPTI_SOURCE_DIR) - message (FATAL_ERROR "Undefined LLVM_EXTERNAL_XPTI_SOURCE_DIR variable: Must be set when XPTI tracing is set to ON") - endif() - include_directories(${LLVM_EXTERNAL_XPTI_SOURCE_DIR}/include) -endif() - function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) # Add an optional argument so we can get the library name to # link with for Windows Debug version - cmake_parse_arguments(ARG "" "XPTI_LIB;IMPLIB_NAME" "COMPILE_OPTIONS;SOURCES" ${ARGN}) + cmake_parse_arguments(ARG "" "IMPLIB_NAME" "COMPILE_OPTIONS;SOURCES" ${ARGN}) add_library(${LIB_OBJ_NAME} OBJECT ${ARG_SOURCES}) add_library(${LIB_NAME} SHARED @@ -64,11 +57,6 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) set_target_properties(${LIB_NAME} PROPERTIES LINKER_LANGUAGE CXX) - if (SYCL_ENABLE_XPTI_TRACING) - target_compile_definitions(${LIB_OBJ_NAME} PRIVATE XPTI_ENABLE_INSTRUMENTATION XPTI_STATIC_LIBRARY) - target_link_libraries(${LIB_NAME} PRIVATE ${ARG_XPTI_LIB}) - endif() - if (NOT LLVM_ENABLE_ZSTD) target_compile_definitions(${LIB_OBJ_NAME} PRIVATE SYCL_RT_ZSTD_NOT_AVAIABLE) else() @@ -129,9 +117,6 @@ function(add_sycl_rt_library LIB_NAME LIB_OBJ_NAME) ${LIB_NAME} PRIVATE "-Wl,--version-script=${linker_script}") set_target_properties(${LIB_NAME} PROPERTIES LINK_DEPENDS ${linker_script}) endif() - if (SYCL_ENABLE_XPTI_TRACING) - target_link_libraries(${LIB_NAME} PRIVATE ${CMAKE_DL_LIBS}) - endif() endif() target_compile_definitions(${LIB_OBJ_NAME} PRIVATE SYCL2020_DISABLE_DEPRECATION_WARNINGS) @@ -300,7 +285,6 @@ set(SYCL_COMMON_SOURCES "detail/usm/usm_impl.cpp" "detail/ur.cpp" "detail/util.cpp" - "detail/xpti_registry.cpp" "accessor.cpp" "buffer.cpp" "context.cpp" @@ -347,16 +331,9 @@ if (MSVC) endforeach() set(WIN_DUPE "1") - if (SYCL_ENABLE_XPTI_TRACING) - add_sycl_rt_library(sycl${SYCL_MAJOR_VERSION}d sycld_object XPTI_LIB xptid COMPILE_OPTIONS "/MDd" SOURCES ${SYCL_NON_PREVIEW_SOURCES} IMPLIB_NAME sycld) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) - add_sycl_rt_library(sycl${SYCL_MAJOR_VERSION}-previewd sycl-previewd_object XPTI_LIB xptid COMPILE_OPTIONS "/MDd" "/D__INTEL_PREVIEW_BREAKING_CHANGES" SOURCES ${SYCL_PREVIEW_SOURCES} IMPLIB_NAME sycl-previewd) - endif() - else() - add_sycl_rt_library(sycl${SYCL_MAJOR_VERSION}d sycld_object COMPILE_OPTIONS "/MDd" SOURCES ${SYCL_NON_PREVIEW_SOURCES} IMPLIB_NAME sycld) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) - add_sycl_rt_library(sycl${SYCL_MAJOR_VERSION}-previewd sycl-previewd_object COMPILE_OPTIONS "/MDd" "/D__INTEL_PREVIEW_BREAKING_CHANGES" SOURCES ${SYCL_PREVIEW_SOURCES} IMPLIB_NAME sycl-previewd) - endif() + add_sycl_rt_library(sycl${SYCL_MAJOR_VERSION}d sycld_object COMPILE_OPTIONS "/MDd" SOURCES ${SYCL_NON_PREVIEW_SOURCES} IMPLIB_NAME sycld) + if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) + add_sycl_rt_library(sycl${SYCL_MAJOR_VERSION}-previewd sycl-previewd_object COMPILE_OPTIONS "/MDd" "/D__INTEL_PREVIEW_BREAKING_CHANGES" SOURCES ${SYCL_PREVIEW_SOURCES} IMPLIB_NAME sycl-previewd) endif() unset(WIN_DUPE) add_library(sycld ALIAS sycl${SYCL_MAJOR_VERSION}d) @@ -381,16 +358,9 @@ endif() # Version-agnostic name of the import library, has effect on Windows only. set(IMPLIB_NAME "sycl") -if (SYCL_ENABLE_XPTI_TRACING) - add_sycl_rt_library(${LIB_NAME} sycl_object XPTI_LIB xpti COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} SOURCES ${SYCL_NON_PREVIEW_SOURCES} IMPLIB_NAME ${IMPLIB_NAME}) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) - add_sycl_rt_library(${LIB_NAME}-preview sycl-preview_object XPTI_LIB xpti COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} "-D__INTEL_PREVIEW_BREAKING_CHANGES" SOURCES ${SYCL_PREVIEW_SOURCES} IMPLIB_NAME ${IMPLIB_NAME}-preview) - endif() -else() - add_sycl_rt_library(${LIB_NAME} sycl_object COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} SOURCES ${SYCL_NON_PREVIEW_SOURCES} IMPLIB_NAME ${IMPLIB_NAME}) - if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) - add_sycl_rt_library(${LIB_NAME}-preview sycl-preview_object COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} "-D__INTEL_PREVIEW_BREAKING_CHANGES" SOURCES ${SYCL_PREVIEW_SOURCES} IMPLIB_NAME ${IMPLIB_NAME}-preview) - endif() +add_sycl_rt_library(${LIB_NAME} sycl_object COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} SOURCES ${SYCL_NON_PREVIEW_SOURCES} IMPLIB_NAME ${IMPLIB_NAME}) +if(SYCL_ENABLE_MAJOR_RELEASE_PREVIEW_LIB) + add_sycl_rt_library(${LIB_NAME}-preview sycl-preview_object COMPILE_OPTIONS ${SYCL_EXTRA_OPTS} "-D__INTEL_PREVIEW_BREAKING_CHANGES" SOURCES ${SYCL_PREVIEW_SOURCES} IMPLIB_NAME ${IMPLIB_NAME}-preview) endif() if (WIN32) diff --git a/sycl/source/buffer.cpp b/sycl/source/buffer.cpp index f62da9f968ccb..07e6ea8b39376 100644 --- a/sycl/source/buffer.cpp +++ b/sycl/source/buffer.cpp @@ -70,14 +70,6 @@ void buffer_plain::set_final_data_internal( impl->set_final_data(FinalDataFunc); } -void buffer_plain::constructorNotification(const detail::code_location &CodeLoc, - void *UserObj, const void *HostObj, - const void *Type, uint32_t Dim, - uint32_t ElemType, size_t Range[3]) { - impl->constructorNotification(CodeLoc, UserObj, HostObj, Type, Dim, ElemType, - Range); -} - void buffer_plain::set_write_back(bool NeedWriteBack) { impl->set_write_back(NeedWriteBack); } diff --git a/sycl/source/detail/accessor_impl.cpp b/sycl/source/detail/accessor_impl.cpp index 1d349627e64e7..995d31d65df83 100644 --- a/sycl/source/detail/accessor_impl.cpp +++ b/sycl/source/detail/accessor_impl.cpp @@ -10,7 +10,6 @@ #include #include #include -#include namespace sycl { inline namespace _V1 { @@ -47,39 +46,6 @@ void addHostSampledImageAccessorAndWait(SampledImageAccessorImplHost *Req) { addHostAccessorAndWait(Req); } -void constructorNotification(void *BufferObj, void *AccessorObj, - sycl::access::target Target, - sycl::access::mode Mode, - const detail::code_location &CodeLoc) { - XPTIRegistry::bufferAccessorNotification( - BufferObj, AccessorObj, (uint32_t)Target, (uint32_t)Mode, CodeLoc); -} - -void unsampledImageConstructorNotification( - void *ImageObj, void *AccessorObj, - const std::optional &Target, access::mode Mode, - const void *Type, uint32_t ElemSize, const code_location &CodeLoc) { - if (Target) - XPTIRegistry::unsampledImageAccessorNotification( - ImageObj, AccessorObj, (uint32_t)*Target, (uint32_t)Mode, Type, - ElemSize, CodeLoc); - else - XPTIRegistry::unsampledImageHostAccessorNotification( - ImageObj, AccessorObj, (uint32_t)Mode, Type, ElemSize, CodeLoc); -} - -void sampledImageConstructorNotification( - void *ImageObj, void *AccessorObj, - const std::optional &Target, const void *Type, - uint32_t ElemSize, const code_location &CodeLoc) { - if (Target) - XPTIRegistry::sampledImageAccessorNotification( - ImageObj, AccessorObj, (uint32_t)*Target, Type, ElemSize, CodeLoc); - else - XPTIRegistry::sampledImageHostAccessorNotification(ImageObj, AccessorObj, - Type, ElemSize, CodeLoc); -} - } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/adapter.hpp b/sycl/source/detail/adapter.hpp index d78743ac6159e..5c6a9c5771ff2 100644 --- a/sycl/source/detail/adapter.hpp +++ b/sycl/source/detail/adapter.hpp @@ -15,10 +15,6 @@ #include #include -#ifdef XPTI_ENABLE_INSTRUMENTATION -// Include the headers necessary for emitting traces using the trace framework -#include "xpti/xpti_trace_framework.h" -#endif #include #include diff --git a/sycl/source/detail/allowlist.cpp b/sycl/source/detail/allowlist.cpp index 96b9577aca975..495e89db98723 100644 --- a/sycl/source/detail/allowlist.cpp +++ b/sycl/source/detail/allowlist.cpp @@ -190,7 +190,7 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) { Key) != SupportedKeyNamesRequireRegexValue.end()) { const std::string Prefix("{{"); // TODO: can be changed to string_view::starts_with after switching - // DPC++ RT to C++20 + // the runtime to C++20 if (Prefix != AllowListRaw.substr(ValueStart, Prefix.length())) { throw sycl::exception( sycl::make_error_code(sycl::errc::runtime), @@ -302,7 +302,7 @@ bool deviceIsAllowed(const DeviceDescT &DeviceDesc, "SYCL_DEVICE_ALLOWLIST."); auto EqualityComp = [&](const std::string &KeyName, const DeviceDescT &AllowListDeviceDesc) { - // change to map::contains after switching DPC++ RT to C++20 + // change to map::contains after switching the runtime to C++20 if (AllowListDeviceDesc.find(KeyName) != AllowListDeviceDesc.end()) if (AllowListDeviceDesc.at(KeyName) != DeviceDesc.at(KeyName)) return false; diff --git a/sycl/source/detail/buffer_impl.cpp b/sycl/source/detail/buffer_impl.cpp index 777091f6be572..d868173feb478 100644 --- a/sycl/source/detail/buffer_impl.cpp +++ b/sycl/source/detail/buffer_impl.cpp @@ -11,16 +11,12 @@ #include #include #include -#include #include #include namespace sycl { inline namespace _V1 { namespace detail { -#ifdef XPTI_ENABLE_INSTRUMENTATION -uint8_t GBufferStreamID; -#endif void *buffer_impl::allocateMem(ContextImplPtr Context, bool InitFromUserData, void *HostPtr, ur_event_handle_t &OutEventToWait) { @@ -34,17 +30,6 @@ void *buffer_impl::allocateMem(ContextImplPtr Context, bool InitFromUserData, BaseT::getSizeInBytes(), BaseT::MInteropEvent, BaseT::MInteropContext, MProps, OutEventToWait); } -void buffer_impl::constructorNotification(const detail::code_location &CodeLoc, - void *UserObj, const void *HostObj, - const void *Type, uint32_t Dim, - uint32_t ElemSize, size_t Range[3]) { - XPTIRegistry::bufferConstructorNotification(UserObj, CodeLoc, HostObj, Type, - Dim, ElemSize, Range); -} - -void buffer_impl::destructorNotification(void *UserObj) { - XPTIRegistry::bufferDestructorNotification(UserObj); -} void buffer_impl::addInteropObject( std::vector &Handles) const { diff --git a/sycl/source/detail/buffer_impl.hpp b/sycl/source/detail/buffer_impl.hpp index be3a529f17718..ff5ff868508a9 100644 --- a/sycl/source/detail/buffer_impl.hpp +++ b/sycl/source/detail/buffer_impl.hpp @@ -131,11 +131,6 @@ class buffer_impl final : public SYCLMemObjT { void *allocateMem(ContextImplPtr Context, bool InitFromUserData, void *HostPtr, ur_event_handle_t &OutEventToWait) override; - void constructorNotification(const detail::code_location &CodeLoc, - void *UserObj, const void *HostObj, - const void *Type, uint32_t Dim, - uint32_t ElemType, size_t Range[3]); - void destructorNotification(void *UserObj); MemObjType getType() const override { return MemObjType::Buffer; } @@ -144,7 +139,6 @@ class buffer_impl final : public SYCLMemObjT { BaseT::updateHostMemory(); } catch (...) { } - destructorNotification(this); } void resize(size_t size) { BaseT::MSizeInBytes = size; } diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index f6e5edfc92e74..977df8576c8e0 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -18,19 +18,9 @@ #include -#ifdef XPTI_ENABLE_INSTRUMENTATION -#include "xpti/xpti_trace_framework.hpp" -#include -#include -#include -#endif - namespace sycl { inline namespace _V1 { namespace detail { -#ifdef XPTI_ENABLE_INSTRUMENTATION -extern xpti::trace_event_data_t *GSYCLGraphEvent; -#endif // If we do not yet have a context, use the default one. void event_impl::initContextIfNeeded() { @@ -178,64 +168,6 @@ event_impl::event_impl(const QueueImplPtr &Queue) MState.store(HES_Complete); } -void *event_impl::instrumentationProlog(std::string &Name, int32_t StreamID, - uint64_t &IId) const { - void *TraceEvent = nullptr; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_wait_begin; - if (!xptiCheckTraceEnabled(StreamID, NotificationTraceType)) - return TraceEvent; - xpti::trace_event_data_t *WaitEvent = nullptr; - - // Create a string with the event address so it - // can be associated with other debug data - xpti::utils::StringHelper SH; - Name = SH.nameWithAddress("event.wait", this->getHandle()); - - // We can emit the wait associated with the graph if the - // event does not have a command object or associated with - // the command object, if it exists - if (MCommand) { - Command *Cmd = (Command *)MCommand; - WaitEvent = Cmd->MTraceEvent ? static_cast(Cmd->MTraceEvent) - : GSYCLGraphEvent; - } else { - // If queue.wait() is used, we want to make sure the information about the - // queue is available with the wait events. We check to see if the - // TraceEvent is available in the Queue object. - void *TraceEvent = nullptr; - if (QueueImplPtr Queue = MQueue.lock()) { - TraceEvent = Queue->getTraceEvent(); - WaitEvent = - (TraceEvent ? static_cast(TraceEvent) : GSYCLGraphEvent); - } else - WaitEvent = GSYCLGraphEvent; - } - // Record the current instance ID for use by Epilog - IId = xptiGetUniqueId(); - xptiNotifySubscribers(StreamID, NotificationTraceType, nullptr, WaitEvent, - IId, static_cast(Name.c_str())); - TraceEvent = (void *)WaitEvent; -#endif - return TraceEvent; -} - -void event_impl::instrumentationEpilog(void *TelemetryEvent, - const std::string &Name, - int32_t StreamID, uint64_t IId) const { -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_wait_end; - if (!(xptiCheckTraceEnabled(StreamID, NotificationTraceType) && - TelemetryEvent)) - return; - // Close the wait() scope - xpti::trace_event_data_t *TraceEvent = - (xpti::trace_event_data_t *)TelemetryEvent; - xptiNotifySubscribers(StreamID, NotificationTraceType, nullptr, TraceEvent, - IId, static_cast(Name.c_str())); -#endif -} - void event_impl::wait(std::shared_ptr Self, bool *Success) { if (MState == HES_Discarded) @@ -248,14 +180,6 @@ void event_impl::wait(std::shared_ptr Self, "with a command graph."); } -#ifdef XPTI_ENABLE_INSTRUMENTATION - void *TelemetryEvent = nullptr; - uint64_t IId = 0; - std::string Name; - int32_t StreamID = xptiRegisterStream(SYCL_STREAM_NAME); - TelemetryEvent = instrumentationProlog(Name, StreamID, IId); -#endif - auto EventHandle = getHandle(); if (EventHandle) // presence of the native handle means the command has been enqueued, so no @@ -263,10 +187,6 @@ void event_impl::wait(std::shared_ptr Self, waitInternal(Success); else if (MCommand) detail::Scheduler::getInstance().waitForEvent(Self, Success); - -#ifdef XPTI_ENABLE_INSTRUMENTATION - instrumentationEpilog(TelemetryEvent, Name, StreamID, IId); -#endif } void event_impl::wait_and_throw( diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index 768de70826624..2bd42c3e0060d 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -340,13 +340,6 @@ class event_impl { } protected: - // When instrumentation is enabled emits trace event for event wait begin and - // returns the telemetry event generated for the wait - void *instrumentationProlog(std::string &Name, int32_t StreamID, - uint64_t &instance_id) const; - // Uses events generated by the Prolog and emits event wait done event - void instrumentationEpilog(void *TelementryEvent, const std::string &Name, - int32_t StreamID, uint64_t IId) const; void checkProfilingPreconditions() const; std::atomic MEvent = nullptr; diff --git a/sycl/source/detail/global_handler.cpp b/sycl/source/detail/global_handler.cpp index 5669fbdaacc50..2dcfda8e2b24c 100644 --- a/sycl/source/detail/global_handler.cpp +++ b/sycl/source/detail/global_handler.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -78,52 +77,6 @@ std::atomic_uint ObjectUsageCounter::MCounter{0}; GlobalHandler::GlobalHandler() = default; GlobalHandler::~GlobalHandler() = default; -void GlobalHandler::InitXPTI() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Let subscribers know a new stream is being initialized - getXPTIRegistry().initializeStream(SYCL_STREAM_NAME, GMajVer, GMinVer, - GVerStr); - xpti::payload_t SYCLPayload("SYCL Runtime Exceptions"); - uint64_t SYCLInstanceNo; - GSYCLCallEvent = xptiMakeEvent("SYCL Try-catch Exceptions", &SYCLPayload, - xpti::trace_algorithm_event, xpti_at::active, - &SYCLInstanceNo); -#endif -} - -void GlobalHandler::TraceEventXPTI(const char *Message) { - if (!Message) - return; -#ifdef XPTI_ENABLE_INSTRUMENTATION - static std::once_flag InitXPTIFlag; - if (xptiTraceEnabled()) { - std::call_once(InitXPTIFlag, [&]() { InitXPTI(); }); - - // We have to handle the cases where: (1) we may have just the code location - // set and not UID and (2) UID set - detail::tls_code_loc_t Tls; - auto CodeLocation = Tls.query(); - - // Creating a tracepoint will convert a CodeLocation to UID, if not set - xpti::framework::tracepoint_t TP( - CodeLocation.fileName(), CodeLocation.functionName(), - CodeLocation.lineNumber(), CodeLocation.columnNumber(), nullptr); - - // The call to notify will have the signature of: - // (1) the stream defined in .stream() - // (2) The trace type equal to what is set by .trace_type() - // (3) Parent event set to NULL - // (4) Current event set to one created from CodeLocation and UID - // (5) An instance ID that records the number of times this code location - // has been seen (6) The message generated by the exception handler - TP.stream(SYCL_STREAM_NAME) - .trace_type(xpti::trace_point_type_t::diagnostics) - .notify(static_cast(Message)); - } - -#endif -} - GlobalHandler *&GlobalHandler::getInstancePtr() { static GlobalHandler *RTGlobalObjHandler = new GlobalHandler(); return RTGlobalObjHandler; @@ -218,10 +171,6 @@ GlobalHandler::getOneapiDeviceSelectorTargets(const std::string &InitValue) { return getOrCreate(MOneapiDeviceSelectorTargets, InitValue); } -XPTIRegistry &GlobalHandler::getXPTIRegistry() { - return getOrCreate(MXPTIRegistry); -} - ThreadPool &GlobalHandler::getHostTaskThreadPool() { int Size = SYCLConfig::get(); ThreadPool &TP = getOrCreate(MHostTaskThreadPool, Size); @@ -347,8 +296,6 @@ void shutdown_late() { if (Handler->MAdapters.Inst) Handler->MAdapters.Inst.reset(nullptr); - Handler->MXPTIRegistry.Inst.reset(nullptr); - // Release the rest of global resources. delete Handler; Handler = nullptr; @@ -374,13 +321,6 @@ extern "C" __SYCL_EXPORT BOOL WINAPI DllMain(HINSTANCE hinstDLL, if (PrintUrTrace) std::cout << "---> DLL_PROCESS_DETACH syclx.dll\n" << std::endl; -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (xptiTraceEnabled()) - return TRUE; // When doing xpti tracing, we can't safely call shutdown. - // TODO: figure out what XPTI is doing that prevents - // release. -#endif - try { shutdown_win(); } catch (std::exception &e) { diff --git a/sycl/source/detail/global_handler.hpp b/sycl/source/detail/global_handler.hpp index 4b834927e3832..e4a38316aa3c5 100644 --- a/sycl/source/detail/global_handler.hpp +++ b/sycl/source/detail/global_handler.hpp @@ -24,7 +24,6 @@ class ProgramManager; class Sync; class Adapter; class ods_target_list; -class XPTIRegistry; class ThreadPool; using PlatformImplPtr = std::shared_ptr; @@ -70,7 +69,6 @@ class GlobalHandler { std::mutex &getFilterMutex(); std::vector &getAdapters(); ods_target_list &getOneapiDeviceSelectorTargets(const std::string &InitValue); - XPTIRegistry &getXPTIRegistry(); ThreadPool &getHostTaskThreadPool(); static void registerEarlyShutdownHandler(); @@ -82,17 +80,10 @@ class GlobalHandler { void drainThreadPool(); void prepareSchedulerToRelease(bool Blocking); - void InitXPTI(); - void TraceEventXPTI(const char *Message); - // For testing purposes only void attachScheduler(Scheduler *Scheduler); private: -#ifdef XPTI_ENABLE_INSTRUMENTATION - void *GSYCLCallEvent = nullptr; -#endif - bool OkToDefer = true; friend void shutdown_win(); @@ -126,7 +117,6 @@ class GlobalHandler { InstWithLock MFilterMutex; InstWithLock> MAdapters; InstWithLock MOneapiDeviceSelectorTargets; - InstWithLock MXPTIRegistry; // Thread pool for host task and event callbacks execution InstWithLock MHostTaskThreadPool; }; diff --git a/sycl/source/detail/graph_impl.cpp b/sycl/source/detail/graph_impl.cpp index e6181a559d8e6..87a6c0745ea9c 100644 --- a/sycl/source/detail/graph_impl.cpp +++ b/sycl/source/detail/graph_impl.cpp @@ -779,22 +779,6 @@ exec_graph_impl::enqueueNodeDirect(sycl::context Ctx, ur_exp_command_buffer_sync_point_t NewSyncPoint; ur_exp_command_buffer_command_handle_t NewCommand = 0; -#ifdef XPTI_ENABLE_INSTRUMENTATION - int32_t StreamID = xptiRegisterStream(sycl::detail::SYCL_STREAM_NAME); - sycl::detail::CGExecKernel *CGExec = - static_cast(Node->MCommandGroup.get()); - sycl::detail::code_location CodeLoc(CGExec->MFileName.c_str(), - CGExec->MFunctionName.c_str(), - CGExec->MLine, CGExec->MColumn); - auto [CmdTraceEvent, InstanceID] = emitKernelInstrumentationData( - StreamID, CGExec->MSyclKernel, CodeLoc, CGExec->MIsTopCodeLoc, - CGExec->MKernelName.c_str(), nullptr, CGExec->MNDRDesc, - CGExec->MKernelBundle, CGExec->MArgs); - if (CmdTraceEvent) - sycl::detail::emitInstrumentationGeneral( - StreamID, InstanceID, CmdTraceEvent, xpti::trace_task_begin, nullptr); -#endif - ur_result_t Res = sycl::detail::enqueueImpCommandBufferKernel( Ctx, DeviceImpl, CommandBuffer, *static_cast((Node->MCommandGroup.get())), @@ -809,12 +793,6 @@ exec_graph_impl::enqueueNodeDirect(sycl::context Ctx, "Failed to add kernel to UR command-buffer"); } -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (CmdTraceEvent) - sycl::detail::emitInstrumentationGeneral( - StreamID, InstanceID, CmdTraceEvent, xpti::trace_task_end, nullptr); -#endif - return NewSyncPoint; } diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index a8582a2893943..a222d14ac1eb9 100644 --- a/sycl/source/detail/image_impl.cpp +++ b/sycl/source/detail/image_impl.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -18,9 +17,6 @@ namespace sycl { inline namespace _V1 { namespace detail { -#ifdef XPTI_ENABLE_INSTRUMENTATION -uint8_t GImageStreamID; -#endif template static bool checkImageValueRange(const std::vector &Devices, @@ -457,31 +453,6 @@ std::vector image_impl::getDevices(const ContextImplPtr Context) { return Context->get_info(); } -void image_impl::sampledImageConstructorNotification( - const detail::code_location &CodeLoc, void *UserObj, const void *HostObj, - uint32_t Dim, size_t Range[3], image_format Format, - const image_sampler &Sampler) { - XPTIRegistry::sampledImageConstructorNotification( - UserObj, CodeLoc, HostObj, Dim, Range, (uint32_t)Format, - (uint32_t)Sampler.addressing, (uint32_t)Sampler.coordinate, - (uint32_t)Sampler.filtering); -} - -void image_impl::sampledImageDestructorNotification(void *UserObj) { - XPTIRegistry::sampledImageDestructorNotification(UserObj); -} - -void image_impl::unsampledImageConstructorNotification( - const detail::code_location &CodeLoc, void *UserObj, const void *HostObj, - uint32_t Dim, size_t Range[3], image_format Format) { - XPTIRegistry::unsampledImageConstructorNotification( - UserObj, CodeLoc, HostObj, Dim, Range, (uint32_t)Format); -} - -void image_impl::unsampledImageDestructorNotification(void *UserObj) { - XPTIRegistry::unsampledImageDestructorNotification(UserObj); -} - void image_impl::verifyProps(const property_list &Props) const { auto CheckDataLessProperties = [](int PropertyKind) { #define __SYCL_DATA_LESS_PROP(NS_QUALIFIER, PROP_NAME, ENUM_VAL) \ diff --git a/sycl/source/detail/image_impl.hpp b/sycl/source/detail/image_impl.hpp index 7b4c7508effaf..d8e2c9f5441fa 100644 --- a/sycl/source/detail/image_impl.hpp +++ b/sycl/source/detail/image_impl.hpp @@ -285,18 +285,6 @@ class image_impl final : public SYCLMemObjT { } } - void sampledImageConstructorNotification(const detail::code_location &CodeLoc, - void *UserObj, const void *HostObj, - uint32_t Dim, size_t Range[3], - image_format Format, - const image_sampler &Sampler); - void sampledImageDestructorNotification(void *UserObj); - - void unsampledImageConstructorNotification( - const detail::code_location &CodeLoc, void *UserObj, const void *HostObj, - uint32_t Dim, size_t Range[3], image_format Format); - void unsampledImageDestructorNotification(void *UserObj); - private: std::vector getDevices(const ContextImplPtr Context); diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 3069595d2b6d8..ca92f2f4ce70d 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -26,98 +25,10 @@ #include #include -#ifdef XPTI_ENABLE_INSTRUMENTATION -#include -#include -#endif - namespace sycl { inline namespace _V1 { namespace detail { -#ifdef XPTI_ENABLE_INSTRUMENTATION -uint8_t GMemAllocStreamID; -xpti::trace_event_data_t *GMemAllocEvent; -#endif - -uint64_t emitMemAllocBeginTrace(uintptr_t ObjHandle, size_t AllocSize, - size_t GuardZone) { - (void)ObjHandle; - (void)AllocSize; - (void)GuardZone; - uint64_t CorrelationID = 0; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = - static_cast(xpti::trace_point_type_t::mem_alloc_begin); - if (xptiCheckTraceEnabled(GMemAllocStreamID, NotificationTraceType)) { - xpti::mem_alloc_data_t MemAlloc{ObjHandle, 0 /* alloc ptr */, AllocSize, - GuardZone}; - - CorrelationID = xptiGetUniqueId(); - xptiNotifySubscribers(GMemAllocStreamID, NotificationTraceType, - GMemAllocEvent, nullptr, CorrelationID, &MemAlloc); - } -#endif - return CorrelationID; -} - -void emitMemAllocEndTrace(uintptr_t ObjHandle, uintptr_t AllocPtr, - size_t AllocSize, size_t GuardZone, - uint64_t CorrelationID) { - (void)ObjHandle; - (void)AllocPtr; - (void)AllocSize; - (void)GuardZone; - (void)CorrelationID; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = - static_cast(xpti::trace_point_type_t::mem_alloc_end); - if (xptiCheckTraceEnabled(GMemAllocStreamID, NotificationTraceType)) { - xpti::mem_alloc_data_t MemAlloc{ObjHandle, AllocPtr, AllocSize, GuardZone}; - - xptiNotifySubscribers(GMemAllocStreamID, NotificationTraceType, - GMemAllocEvent, nullptr, CorrelationID, &MemAlloc); - } -#endif -} - -uint64_t emitMemReleaseBeginTrace(uintptr_t ObjHandle, uintptr_t AllocPtr) { - (void)ObjHandle; - (void)AllocPtr; - uint64_t CorrelationID = 0; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = - static_cast(xpti::trace_point_type_t::mem_release_begin); - if (xptiCheckTraceEnabled(GMemAllocStreamID, NotificationTraceType)) { - xpti::mem_alloc_data_t MemAlloc{ObjHandle, AllocPtr, 0 /* alloc size */, - 0 /* guard zone */}; - - CorrelationID = xptiGetUniqueId(); - xptiNotifySubscribers(GMemAllocStreamID, NotificationTraceType, - GMemAllocEvent, nullptr, CorrelationID, &MemAlloc); - } -#endif - return CorrelationID; -} - -void emitMemReleaseEndTrace(uintptr_t ObjHandle, uintptr_t AllocPtr, - uint64_t CorrelationID) { - (void)ObjHandle; - (void)AllocPtr; - (void)CorrelationID; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = - static_cast(xpti::trace_point_type_t::mem_release_end); - if (xptiCheckTraceEnabled(GMemAllocStreamID, NotificationTraceType)) { - xpti::mem_alloc_data_t MemAlloc{ObjHandle, AllocPtr, 0 /* alloc size */, - 0 /* guard zone */}; - - xptiNotifySubscribers(GMemAllocStreamID, NotificationTraceType, - GMemAllocEvent, nullptr, CorrelationID, &MemAlloc); - } -#endif -} - static void waitForEvents(const std::vector &Events) { // Assuming all events will be on the same device or // devices associated with the same Backend. @@ -137,65 +48,16 @@ void memBufferCreateHelper(const AdapterPtr &Adapter, ur_context_handle_t Ctx, ur_mem_flags_t Flags, size_t Size, ur_mem_handle_t *RetMem, const ur_buffer_properties_t *Props) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - uint64_t CorrID = 0; -#endif - // We only want to instrument urMemBufferCreate - { -#ifdef XPTI_ENABLE_INSTRUMENTATION - CorrID = - emitMemAllocBeginTrace(0 /* mem object */, Size, 0 /* guard zone */); - xpti::utils::finally _{[&] { - // C-style cast is required for MSVC - uintptr_t MemObjID = (uintptr_t)(*RetMem); - ur_native_handle_t Ptr = 0; - // Always use call_nocheck here, because call may throw an exception, - // and this lambda will be called from destructor, which in combination - // rewards us with UB. - // When doing buffer interop we don't know what device the memory should - // be resident on, so pass nullptr for Device param. Buffer interop may - // not be supported by all backends. - Adapter->call_nocheck( - *RetMem, /*Dev*/ nullptr, &Ptr); - emitMemAllocEndTrace(MemObjID, (uintptr_t)(Ptr), Size, 0 /* guard zone */, - CorrID); - }}; -#endif - if (Size) - Adapter->call(Ctx, Flags, Size, Props, - RetMem); - } + if (Size) + Adapter->call(Ctx, Flags, Size, Props, + RetMem); } void memReleaseHelper(const AdapterPtr &Adapter, ur_mem_handle_t Mem) { // FIXME urMemRelease does not guarante memory release. It is only true if // reference counter is 1. However, SYCL runtime currently only calls // urMemRetain only for OpenCL interop -#ifdef XPTI_ENABLE_INSTRUMENTATION - uint64_t CorrID = 0; - // C-style cast is required for MSVC - uintptr_t MemObjID = (uintptr_t)(Mem); - uintptr_t Ptr = 0; - // Do not make unnecessary UR calls without instrumentation enabled - if (xptiTraceEnabled()) { - ur_native_handle_t PtrHandle = 0; - // When doing buffer interop we don't know what device the memory should be - // resident on, so pass nullptr for Device param. Buffer interop may not be - // supported by all backends. - Adapter->call_nocheck(Mem, /*Dev*/ nullptr, - &PtrHandle); - Ptr = (uintptr_t)(PtrHandle); - } -#endif - // We only want to instrument urMemRelease - { -#ifdef XPTI_ENABLE_INSTRUMENTATION - CorrID = emitMemReleaseBeginTrace(MemObjID, Ptr); - xpti::utils::finally _{ - [&] { emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); }}; -#endif - Adapter->call(Mem); - } + Adapter->call(Mem); } void memBufferMapHelper(const AdapterPtr &Adapter, ur_queue_handle_t Queue, @@ -203,19 +65,8 @@ void memBufferMapHelper(const AdapterPtr &Adapter, ur_queue_handle_t Queue, ur_map_flags_t Flags, size_t Offset, size_t Size, uint32_t NumEvents, const ur_event_handle_t *WaitList, ur_event_handle_t *Event, void **RetMap) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - uint64_t CorrID = 0; - uintptr_t MemObjID = (uintptr_t)(Buffer); -#endif // We only want to instrument urEnqueueMemBufferMap -#ifdef XPTI_ENABLE_INSTRUMENTATION - CorrID = emitMemAllocBeginTrace(MemObjID, Size, 0 /* guard zone */); - xpti::utils::finally _{[&] { - emitMemAllocEndTrace(MemObjID, (uintptr_t)(*RetMap), Size, - 0 /* guard zone */, CorrID); - }}; -#endif Adapter->call( Queue, Buffer, Blocking, Flags, Offset, Size, NumEvents, WaitList, Event, RetMap); @@ -225,29 +76,9 @@ void memUnmapHelper(const AdapterPtr &Adapter, ur_queue_handle_t Queue, ur_mem_handle_t Mem, void *MappedPtr, uint32_t NumEvents, const ur_event_handle_t *WaitList, ur_event_handle_t *Event) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - uint64_t CorrID = 0; - uintptr_t MemObjID = (uintptr_t)(Mem); - uintptr_t Ptr = (uintptr_t)(MappedPtr); -#endif // We only want to instrument urEnqueueMemUnmap - { -#ifdef XPTI_ENABLE_INSTRUMENTATION - CorrID = emitMemReleaseBeginTrace(MemObjID, Ptr); - xpti::utils::finally _{[&] { - // There's no way for SYCL to know, when the pointer is freed, so we have - // to explicitly wait for the end of data transfers here in order to - // report correct events. - // Always use call_nocheck here, because call may throw an exception, - // and this lambda will be called from destructor, which in combination - // rewards us with UB. - Adapter->call_nocheck(1, Event); - emitMemReleaseEndTrace(MemObjID, Ptr, CorrID); - }}; -#endif - Adapter->call(Queue, Mem, MappedPtr, - NumEvents, WaitList, Event); - } + Adapter->call(Queue, Mem, MappedPtr, NumEvents, + WaitList, Event); } void MemoryManager::release(ContextImplPtr TargetContext, SYCLMemObjI *MemObj, @@ -258,7 +89,6 @@ void MemoryManager::release(ContextImplPtr TargetContext, SYCLMemObjI *MemObj, // dependency events and return empty event. waitForEvents(DepEvents); OutEvent = nullptr; - XPTIRegistry::bufferReleaseNotification(MemObj, MemAllocation); MemObj->releaseMem(TargetContext, MemAllocation); } @@ -409,7 +239,6 @@ void *MemoryManager::allocateMemBuffer(ContextImplPtr TargetContext, else MemPtr = allocateBufferObject(TargetContext, UserPtr, HostPtrReadOnly, Size, PropsList); - XPTIRegistry::bufferAssociateNotification(MemObj, MemPtr); return MemPtr; } diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index 88374d3289c20..984e8e82b7e10 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -17,12 +17,6 @@ #include #include -#ifdef XPTI_ENABLE_INSTRUMENTATION -#include "xpti/xpti_trace_framework.hpp" -#include -#include -#endif - namespace sycl { inline namespace _V1 { namespace detail { @@ -150,29 +144,6 @@ event queue_impl::memset(const std::shared_ptr &Self, void *Ptr, int Value, size_t Count, const std::vector &DepEvents, bool CallerNeedsEvent) { -#if XPTI_ENABLE_INSTRUMENTATION - // We need a code pointer value and we use the object ptr; if code location - // information is available, we will have function name and source file - // information - XPTIScope PrepareNotify((void *)this, - (uint16_t)xpti::trace_point_type_t::node_create, - SYCL_STREAM_NAME, "memory_transfer_node::memset"); - PrepareNotify.addMetadata([&](auto TEvent) { - xpti::addMetadata(TEvent, "sycl_device", - reinterpret_cast(MDevice->getHandleRef())); - xpti::addMetadata(TEvent, "memory_ptr", reinterpret_cast(Ptr)); - xpti::addMetadata(TEvent, "value_set", Value); - xpti::addMetadata(TEvent, "memory_size", Count); - xpti::addMetadata(TEvent, "queue_id", MQueueID); - }); - // Before we notifiy the subscribers, we broadcast the 'queue_id', which was a - // metadata entry to TLS for use by callback handlers - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, MQueueID); - // Notify XPTI about the memset submission - PrepareNotify.notify(); - // Emit a begin/end scope for this call - PrepareNotify.scopedNotify((uint16_t)xpti::trace_point_type_t::task_begin); -#endif const std::vector Pattern{static_cast(Value)}; return submitMemOpHelper( Self, DepEvents, CallerNeedsEvent, @@ -198,28 +169,6 @@ event queue_impl::memcpy(const std::shared_ptr &Self, void *Dest, const void *Src, size_t Count, const std::vector &DepEvents, bool CallerNeedsEvent, const code_location &CodeLoc) { -#if XPTI_ENABLE_INSTRUMENTATION - // We need a code pointer value and we duse the object ptr; If code location - // is available, we use the source file information along with the object - // pointer. - XPTIScope PrepareNotify((void *)this, - (uint16_t)xpti::trace_point_type_t::node_create, - SYCL_STREAM_NAME, "memory_transfer_node::memcpy"); - PrepareNotify.addMetadata([&](auto TEvent) { - xpti::addMetadata(TEvent, "sycl_device", - reinterpret_cast(MDevice->getHandleRef())); - xpti::addMetadata(TEvent, "src_memory_ptr", reinterpret_cast(Src)); - xpti::addMetadata(TEvent, "dest_memory_ptr", - reinterpret_cast(Dest)); - xpti::addMetadata(TEvent, "memory_size", Count); - xpti::addMetadata(TEvent, "queue_id", MQueueID); - }); - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, MQueueID); - // Notify XPTI about the memcpy submission - PrepareNotify.notify(); - // Emit a begin/end scope for this call - PrepareNotify.scopedNotify((uint16_t)xpti::trace_point_type_t::task_begin); -#endif if ((!Src || !Dest) && Count != 0) { report(CodeLoc); @@ -498,91 +447,8 @@ event queue_impl::submitMemOpHelper(const std::shared_ptr &Self, return submitWithHandler(Self, DepEvents, CallerNeedsEvent, HandlerFunc); } -void *queue_impl::instrumentationProlog(const detail::code_location &CodeLoc, - std::string &Name, int32_t StreamID, - uint64_t &IId) { - void *TraceEvent = nullptr; - (void)CodeLoc; - (void)Name; - (void)StreamID; - (void)IId; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_wait_begin; - if (!xptiCheckTraceEnabled(StreamID, NotificationTraceType)) - return TraceEvent; - - xpti::payload_t Payload; - bool HasSourceInfo = false; - // We try to create a unique string for the wait() call by combining it with - // the queue address - xpti::utils::StringHelper NG; - Name = NG.nameWithAddress("queue.wait", this); - - if (CodeLoc.fileName()) { - // We have source code location information - Payload = - xpti::payload_t(Name.c_str(), CodeLoc.fileName(), CodeLoc.lineNumber(), - CodeLoc.columnNumber(), (void *)this); - HasSourceInfo = true; - } else { - // We have no location information, so we'll use the address of the queue - Payload = xpti::payload_t(Name.c_str(), (void *)this); - } - // wait() calls could be at different user-code locations; We create a new - // event based on the code location info and if this has been seen before, a - // previously created event will be returned. - uint64_t QWaitInstanceNo = 0; - xpti::trace_event_data_t *WaitEvent = - xptiMakeEvent(Name.c_str(), &Payload, xpti::trace_graph_event, - xpti_at::active, &QWaitInstanceNo); - IId = QWaitInstanceNo; - if (WaitEvent) { - xpti::addMetadata(WaitEvent, "sycl_device_type", queueDeviceToString(this)); - if (HasSourceInfo) { - xpti::addMetadata(WaitEvent, "sym_function_name", CodeLoc.functionName()); - xpti::addMetadata(WaitEvent, "sym_source_file_name", CodeLoc.fileName()); - xpti::addMetadata(WaitEvent, "sym_line_no", - static_cast((CodeLoc.lineNumber()))); - xpti::addMetadata(WaitEvent, "sym_column_no", - static_cast((CodeLoc.columnNumber()))); - } - xptiNotifySubscribers(StreamID, xpti::trace_wait_begin, nullptr, WaitEvent, - QWaitInstanceNo, - static_cast(Name.c_str())); - TraceEvent = (void *)WaitEvent; - } -#endif - return TraceEvent; -} - -void queue_impl::instrumentationEpilog(void *TelemetryEvent, std::string &Name, - int32_t StreamID, uint64_t IId) { - (void)TelemetryEvent; - (void)Name; - (void)StreamID; - (void)IId; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_wait_end; - if (!(xptiCheckTraceEnabled(StreamID, NotificationTraceType) && - TelemetryEvent)) - return; - // Close the wait() scope - xpti::trace_event_data_t *TraceEvent = - (xpti::trace_event_data_t *)TelemetryEvent; - xptiNotifySubscribers(StreamID, NotificationTraceType, nullptr, TraceEvent, - IId, static_cast(Name.c_str())); -#endif -} - void queue_impl::wait(const detail::code_location &CodeLoc) { (void)CodeLoc; -#ifdef XPTI_ENABLE_INSTRUMENTATION - void *TelemetryEvent = nullptr; - uint64_t IId; - std::string Name; - int32_t StreamID = xptiRegisterStream(SYCL_STREAM_NAME); - TelemetryEvent = instrumentationProlog(CodeLoc, Name, StreamID, IId); -#endif if (MGraph.lock()) { throw sycl::exception(make_error_code(errc::invalid), @@ -658,68 +524,6 @@ void queue_impl::wait(const detail::code_location &CodeLoc) { } for (const EventImplPtr &Event : StreamsServiceEvents) Event->wait(Event); - -#ifdef XPTI_ENABLE_INSTRUMENTATION - instrumentationEpilog(TelemetryEvent, Name, StreamID, IId); -#endif -} - -void queue_impl::constructorNotification() { -#if XPTI_ENABLE_INSTRUMENTATION - if (xptiTraceEnabled()) { - MStreamID = xptiRegisterStream(SYCL_STREAM_NAME); - constexpr uint16_t NotificationTraceType = - static_cast(xpti::trace_point_type_t::queue_create); - if (xptiCheckTraceEnabled(MStreamID, NotificationTraceType)) { - xpti::utils::StringHelper SH; - std::string AddrStr = SH.addressAsString(MQueueID); - std::string QueueName = SH.nameWithAddressString("queue", AddrStr); - // Create a payload for the queue create event as we do not get code - // location for the queue create event - xpti::payload_t QPayload(QueueName.c_str()); - MInstanceID = xptiGetUniqueId(); - uint64_t RetInstanceNo; - xpti_td *TEvent = - xptiMakeEvent("queue_create", &QPayload, - (uint16_t)xpti::trace_event_type_t::algorithm, - xpti_at::active, &RetInstanceNo); - // Cache the trace event, stream id and instance IDs for the destructor - MTraceEvent = (void *)TEvent; - - xpti::addMetadata(TEvent, "sycl_context", - reinterpret_cast(MContext->getHandleRef())); - if (MDevice) { - xpti::addMetadata(TEvent, "sycl_device_name", MDevice->getDeviceName()); - xpti::addMetadata(TEvent, "sycl_device", - reinterpret_cast(MDevice->getHandleRef())); - } - xpti::addMetadata(TEvent, "is_inorder", MIsInorder); - xpti::addMetadata(TEvent, "queue_id", MQueueID); - xpti::addMetadata(TEvent, "queue_handle", - reinterpret_cast(getHandleRef())); - // Also publish to TLS before notification - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, MQueueID); - xptiNotifySubscribers( - MStreamID, (uint16_t)xpti::trace_point_type_t::queue_create, nullptr, - TEvent, MInstanceID, static_cast("queue_create")); - } - } -#endif -} - -void queue_impl::destructorNotification() { -#if XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = - static_cast(xpti::trace_point_type_t::queue_destroy); - if (xptiCheckTraceEnabled(MStreamID, NotificationTraceType)) { - // Use the cached trace event, stream id and instance IDs for the - // destructor - xptiNotifySubscribers(MStreamID, NotificationTraceType, nullptr, - (xpti::trace_event_data_t *)MTraceEvent, MInstanceID, - static_cast("queue_destroy")); - xptiReleaseEvent((xpti::trace_event_data_t *)MTraceEvent); - } -#endif } ur_native_handle_t queue_impl::getNative(int32_t &NativeHandleDesc) const { diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 0f99f49d1257d..50fb4261c25bf 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -36,11 +36,6 @@ #include -#ifdef XPTI_ENABLE_INSTRUMENTATION -#include "xpti/xpti_trace_framework.hpp" -#include -#endif - namespace sycl { inline namespace _V1 { @@ -167,17 +162,6 @@ class queue_impl { const QueueOrder QOrder = MIsInorder ? QueueOrder::Ordered : QueueOrder::OOO; MQueues.push_back(createQueue(QOrder)); - // This section is the second part of the instrumentation that uses the - // tracepoint information and notifies - - // We enable XPTI tracing events using the TLS mechanism; if the code - // location data is available, then the tracing data will be rich. -#if XPTI_ENABLE_INSTRUMENTATION - // Emit a trace event for queue creation; we currently do not get code - // location information, so all queueus will have the same UID with a - // different instance ID until this gets added. - constructorNotification(); -#endif } event getLastEvent(); @@ -204,16 +188,6 @@ class queue_impl { make_error_code(errc::invalid), "Device provided by native Queue not found in Context."); } - // The following commented section provides a guideline on how to use the - // TLS enabled mechanism to create a tracepoint and notify using XPTI. This - // is the prolog section and the epilog section will initiate the - // notification. -#if XPTI_ENABLE_INSTRUMENTATION - // Emit a trace event for queue creation; we currently do not get code - // location information, so all queueus will have the same UID with a - // different instance ID until this gets added. - constructorNotification(); -#endif } public: @@ -257,12 +231,6 @@ class queue_impl { ~queue_impl() { try { -#if XPTI_ENABLE_INSTRUMENTATION - // The trace event created in the constructor should be active through the - // lifetime of the queue object as member variable. We will send a - // notification and destroy the trace event for this queue. - destructorNotification(); -#endif throw_asynchronous(); getAdapter()->call(MQueues[0]); } catch (std::exception &e) { @@ -705,8 +673,6 @@ class queue_impl { unsigned long long getQueueID() { return MQueueID; } - void *getTraceEvent() { return MTraceEvent; } - void setExternalEvent(const event &Event) { std::lock_guard Lock(MInOrderExternalEventMtx); MInOrderExternalEvent = Event; @@ -894,22 +860,6 @@ class queue_impl { bool CallerNeedsEvent, HandlerFuncT HandlerFunc, MemMngrFuncT MemMngrFunc, MemMngrArgTs... MemOpArgs); - // When instrumentation is enabled emits trace event for wait begin and - // returns the telemetry event generated for the wait - void *instrumentationProlog(const detail::code_location &CodeLoc, - std::string &Name, int32_t StreamID, - uint64_t &iid); - // Uses events generated by the Prolog and emits wait done event - void instrumentationEpilog(void *TelementryEvent, std::string &Name, - int32_t StreamID, uint64_t IId); - - // We need to emit a queue_create notification when a queue object is created - void constructorNotification(); - - // We need to emit a queue_destroy notification when a queue object is - // destroyed - void destructorNotification(); - /// queue_impl.addEvent tracks events with weak pointers /// but some events have no other owners. addSharedEvent() /// follows events with a shared pointer. @@ -970,16 +920,6 @@ class queue_impl { std::vector MStreamsServiceEvents; std::mutex MStreamsServiceEventsMutex; - // All member variable defined here are needed for the SYCL instrumentation - // layer. Do not guard these variables below with XPTI_ENABLE_INSTRUMENTATION - // to ensure we have the same object layout when the macro in the library and - // SYCL app are not the same. - void *MTraceEvent = nullptr; - /// The stream under which the traces are emitted from the queue object - uint8_t MStreamID = 0; - /// The instance ID of the trace event for queue object - uint64_t MInstanceID = 0; - // the fallback implementation of profiling info bool MFallbackProfiling = false; diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index ac00313e670de..b5fa26de49861 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -44,11 +43,6 @@ #endif #endif -#ifdef XPTI_ENABLE_INSTRUMENTATION -#include "xpti/xpti_trace_framework.hpp" -#include -#endif - namespace sycl { inline namespace _V1 { namespace detail { @@ -77,49 +71,6 @@ ur_result_t callMemOpHelperRet(MemOpRet &MemOpResult, MemOpFuncT &MemOpFunc, return UR_RESULT_SUCCESS; } -#ifdef XPTI_ENABLE_INSTRUMENTATION -// Global graph for the application -extern xpti::trace_event_data_t *GSYCLGraphEvent; - -static bool CurrentCodeLocationValid() { - detail::tls_code_loc_t Tls; - auto CodeLoc = Tls.query(); - auto FileName = CodeLoc.fileName(); - auto FunctionName = CodeLoc.functionName(); - return (FileName && FileName[0] != '\0') || - (FunctionName && FunctionName[0] != '\0'); -} - -void emitInstrumentationGeneral(uint32_t StreamID, uint64_t InstanceID, - xpti_td *TraceEvent, uint16_t Type, - const void *Addr) { - if (!(xptiCheckTraceEnabled(StreamID, Type) && TraceEvent)) - return; - // Trace event notifier that emits a Type event - xptiNotifySubscribers(StreamID, Type, detail::GSYCLGraphEvent, - static_cast(TraceEvent), InstanceID, Addr); -} - -static size_t deviceToID(const device &Device) { - return reinterpret_cast(getSyclObjImpl(Device)->getHandleRef()); -} - -static void addDeviceMetadata(xpti_td *TraceEvent, const QueueImplPtr &Queue) { - xpti::addMetadata(TraceEvent, "sycl_device_type", - queueDeviceToString(Queue.get())); - if (Queue) { - xpti::addMetadata(TraceEvent, "sycl_device", - deviceToID(Queue->get_device())); - xpti::addMetadata(TraceEvent, "sycl_device_name", - getSyclObjImpl(Queue->get_device())->getDeviceName()); - } -} - -static unsigned long long getQueueID(const QueueImplPtr &Queue) { - return Queue ? Queue->getQueueID() : 0; -} -#endif - static ContextImplPtr getContext(const QueueImplPtr &Queue) { if (Queue) return Queue->getContextImplPtr(); @@ -196,63 +147,6 @@ static std::string accessModeToString(access::mode Mode) { } } -#ifdef XPTI_ENABLE_INSTRUMENTATION -// Using the command group type to create node types for the asynchronous task -// graph modeling -static std::string commandToNodeType(Command::CommandType Type) { - switch (Type) { - case Command::CommandType::RUN_CG: - return "command_group_node"; - case Command::CommandType::COPY_MEMORY: - return "memory_transfer_node"; - case Command::CommandType::ALLOCA: - return "memory_allocation_node"; - case Command::CommandType::ALLOCA_SUB_BUF: - return "sub_buffer_creation_node"; - case Command::CommandType::RELEASE: - return "memory_deallocation_node"; - case Command::CommandType::MAP_MEM_OBJ: - return "memory_transfer_node"; - case Command::CommandType::UNMAP_MEM_OBJ: - return "memory_transfer_node"; - case Command::CommandType::UPDATE_REQUIREMENT: - return "host_acc_create_buffer_lock_node"; - case Command::CommandType::EMPTY_TASK: - return "host_acc_destroy_buffer_release_node"; - default: - return "unknown_node"; - } -} - -// Using the names being generated and the string are subject to change to -// something more meaningful to end-users as this will be visible in analysis -// tools that subscribe to this data -static std::string commandToName(Command::CommandType Type) { - switch (Type) { - case Command::CommandType::RUN_CG: - return "Command Group Action"; - case Command::CommandType::COPY_MEMORY: - return "Memory Transfer (Copy)"; - case Command::CommandType::ALLOCA: - return "Memory Allocation"; - case Command::CommandType::ALLOCA_SUB_BUF: - return "Sub Buffer Creation"; - case Command::CommandType::RELEASE: - return "Memory Deallocation"; - case Command::CommandType::MAP_MEM_OBJ: - return "Memory Transfer (Map)"; - case Command::CommandType::UNMAP_MEM_OBJ: - return "Memory Transfer (Unmap)"; - case Command::CommandType::UPDATE_REQUIREMENT: - return "Host Accessor Creation/Buffer Lock"; - case Command::CommandType::EMPTY_TASK: - return "Host Accessor Destruction/Buffer Lock Release"; - default: - return "Unknown Action"; - } -} -#endif - std::vector Command::getUrEvents(const std::vector &EventImpls, const QueueImplPtr &CommandQueue, bool IsHostTaskCommand) { @@ -423,18 +317,6 @@ class DispatchHostTask { CGHostTask &HostTask = static_cast(MThisCmd->getCG()); -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Host task is executed async and in a separate thread that do not allow to - // use code location data stored in TLS. So we keep submission code location - // as Command field and put it here to TLS so that thrown exception could - // query and report it. - std::unique_ptr AsyncCodeLocationPtr; - if (xptiTraceEnabled() && !CurrentCodeLocationValid()) { - AsyncCodeLocationPtr.reset( - new detail::tls_code_loc_t(MThisCmd->MSubmissionCodeLocation)); - } -#endif - if (!waitForEvents()) { std::exception_ptr EPtr = std::make_exception_ptr(sycl::exception( make_error_code(errc::runtime), @@ -485,35 +367,12 @@ class DispatchHostTask { HostTask.MHostTask->call(MThisCmd->MEvent->getHostProfilingInfo()); } catch (...) { auto CurrentException = std::current_exception(); -#ifdef XPTI_ENABLE_INSTRUMENTATION - // sycl::exception emit tracing of message with code location if - // available. For other types of exception we need to explicitly trigger - // tracing by calling TraceEventXPTI. - if (xptiTraceEnabled()) { - try { - rethrow_exception(CurrentException); - } catch (const sycl::exception &) { - // it is already traced, nothing to care about - } catch (const std::exception &StdException) { - GlobalHandler::instance().TraceEventXPTI(StdException.what()); - } catch (...) { - GlobalHandler::instance().TraceEventXPTI( - "Host task lambda thrown non standard exception"); - } - } -#endif MThisCmd->MEvent->getSubmittedQueue()->reportAsyncException( CurrentException); } HostTask.MHostTask.reset(); -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Host Task is done, clear its submittion location to not interfere with - // following dependent kernels submission. - AsyncCodeLocationPtr.reset(); -#endif - try { // If we enqueue blocked users - ur level could throw exception that // should be treated as async now. @@ -605,184 +464,6 @@ Command::Command( MEvent->setContextImpl(MQueue->getContextImplPtr()); MEvent->setStateIncomplete(); MEnqueueStatus = EnqueueResultT::SyclEnqueueReady; - -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiTraceEnabled()) - return; - // Obtain the stream ID so all commands can emit traces to that stream - MStreamID = xptiRegisterStream(SYCL_STREAM_NAME); -#endif -} - -void Command::emitInstrumentationDataProxy() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - emitInstrumentationData(); -#endif -} - -/// Method takes in void * for the address as adding a template function to -/// the command group object maybe undesirable. -/// @param Cmd The command object of the source of the edge -/// @param ObjAddr The address that defines the edge dependency; it is the -/// event address when the edge is for an event and a memory object address if -/// it is due to an accessor -/// @param Prefix Contains "event" if the dependency is an edge and contains -/// the access mode to the buffer if it is due to an accessor -/// @param IsCommand True if the dependency has a command object as the -/// source, false otherwise -void Command::emitEdgeEventForCommandDependence( - Command *Cmd, void *ObjAddr, bool IsCommand, - std::optional AccMode) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Bail early if either the source or the target node for the given - // dependency is undefined or NULL - constexpr uint16_t NotificationTraceType = xpti::trace_edge_create; - if (!(xptiCheckTraceEnabled(MStreamID, NotificationTraceType) && - MTraceEvent && Cmd && Cmd->MTraceEvent)) - return; - - // If all the information we need for creating an edge event is available, - // then go ahead with creating it; if not, bail early! - xpti::utils::StringHelper SH; - std::string AddressStr = SH.addressAsString(ObjAddr); - std::string Prefix = AccMode ? accessModeToString(AccMode.value()) : "Event"; - std::string TypeString = SH.nameWithAddressString(Prefix, AddressStr); - // Create an edge with the dependent buffer address for which a command - // object has been created as one of the properties of the edge - xpti::payload_t Payload(TypeString.c_str(), MAddress); - uint64_t EdgeInstanceNo; - xpti_td *EdgeEvent = - xptiMakeEvent(TypeString.c_str(), &Payload, xpti::trace_graph_event, - xpti_at::active, &EdgeInstanceNo); - if (EdgeEvent) { - xpti_td *SrcEvent = static_cast(Cmd->MTraceEvent); - xpti_td *TgtEvent = static_cast(MTraceEvent); - EdgeEvent->source_id = SrcEvent->unique_id; - EdgeEvent->target_id = TgtEvent->unique_id; - if (IsCommand) { - xpti::addMetadata(EdgeEvent, "access_mode", - static_cast(AccMode.value())); - xpti::addMetadata(EdgeEvent, "memory_object", - reinterpret_cast(ObjAddr)); - } else { - xpti::addMetadata(EdgeEvent, "event", reinterpret_cast(ObjAddr)); - } - xptiNotifySubscribers(MStreamID, NotificationTraceType, - detail::GSYCLGraphEvent, EdgeEvent, EdgeInstanceNo, - nullptr); - } - // General comment - None of these are serious errors as the instrumentation - // layer MUST be tolerant of errors. If we need to let the end user know, we - // throw exceptions in the future -#endif -} - -/// Creates an edge when the dependency is due to an event. -/// @param Cmd The command object of the source of the edge -/// @param UrEventAddr The address that defines the edge dependency, which in -/// this case is an event -void Command::emitEdgeEventForEventDependence(Command *Cmd, - ur_event_handle_t &UrEventAddr) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - // If we have failed to create an event to represent the Command, then we - // cannot emit an edge event. Bail early! - if (!(xptiCheckTraceEnabled(MStreamID) && MTraceEvent)) - return; - - if (Cmd && Cmd->MTraceEvent) { - // If the event is associated with a command, we use this command's trace - // event as the source of edge, hence modeling the control flow - emitEdgeEventForCommandDependence(Cmd, (void *)UrEventAddr, false); - return; - } - if (UrEventAddr) { - xpti::utils::StringHelper SH; - std::string AddressStr = SH.addressAsString(UrEventAddr); - // This is the case when it is a OCL event enqueued by the user or another - // event is registered by the runtime as a dependency The dependency on - // this occasion is an OCL event; so we build a virtual node in the graph - // with the event as the metadata for the node - std::string NodeName = SH.nameWithAddressString("virtual_node", AddressStr); - - // Node name is "virtual_node[]" - xpti::payload_t VNPayload(NodeName.c_str(), MAddress); - uint64_t VNodeInstanceNo; - xpti_td *NodeEvent = - xptiMakeEvent(NodeName.c_str(), &VNPayload, xpti::trace_graph_event, - xpti_at::active, &VNodeInstanceNo); - // Emit the virtual node first - xpti::addMetadata(NodeEvent, "kernel_name", NodeName); - xptiNotifySubscribers(MStreamID, xpti::trace_node_create, - detail::GSYCLGraphEvent, NodeEvent, VNodeInstanceNo, - nullptr); - // Create a new event for the edge - std::string EdgeName = SH.nameWithAddressString("Event", AddressStr); - xpti::payload_t EdgePayload(EdgeName.c_str(), MAddress); - uint64_t EdgeInstanceNo; - xpti_td *EdgeEvent = - xptiMakeEvent(EdgeName.c_str(), &EdgePayload, xpti::trace_graph_event, - xpti_at::active, &EdgeInstanceNo); - if (EdgeEvent && NodeEvent) { - // Source node represents the event and this event needs to be completed - // before target node can execute - xpti_td *TgtEvent = static_cast(MTraceEvent); - EdgeEvent->source_id = NodeEvent->unique_id; - EdgeEvent->target_id = TgtEvent->unique_id; - xpti::addMetadata(EdgeEvent, "event", - reinterpret_cast(UrEventAddr)); - xptiNotifySubscribers(MStreamID, xpti::trace_edge_create, - detail::GSYCLGraphEvent, EdgeEvent, EdgeInstanceNo, - nullptr); - } - return; - } -#endif -} - -uint64_t Command::makeTraceEventProlog(void *MAddress) { - uint64_t CommandInstanceNo = 0; -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return CommandInstanceNo; - - MTraceEventPrologComplete = true; - // Setup the member variables with information needed for event notification - MCommandNodeType = commandToNodeType(MType); - MCommandName = commandToName(MType); - xpti::utils::StringHelper SH; - MAddressString = SH.addressAsString(MAddress); - std::string CommandString = - SH.nameWithAddressString(MCommandName, MAddressString); - - xpti::payload_t p(CommandString.c_str(), MAddress); - xpti_td *CmdTraceEvent = - xptiMakeEvent(CommandString.c_str(), &p, xpti::trace_graph_event, - xpti_at::active, &CommandInstanceNo); - MInstanceID = CommandInstanceNo; - if (CmdTraceEvent) { - MTraceEvent = (void *)CmdTraceEvent; - // If we are seeing this event again, then the instance ID will be greater - // than 1; in the previous implementation, we would skip sending a - // notifications for subsequent instances. With the new implementation, we - // will send a notification for each instance as this allows for mutable - // metadata entries for multiple visits to the same code location and - // maintaining data integrity. - } -#endif - return CommandInstanceNo; -} - -void Command::makeTraceEventEpilog() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_node_create; - if (!(xptiCheckTraceEnabled(MStreamID, NotificationTraceType) && MTraceEvent)) - return; - assert(MTraceEventPrologComplete); - xptiNotifySubscribers(MStreamID, NotificationTraceType, - detail::GSYCLGraphEvent, - static_cast(MTraceEvent), MInstanceID, - static_cast(MCommandNodeType.c_str())); -#endif } Command *Command::processDepEvent(EventImplPtr DepEvent, const DepDesc &Dep, @@ -849,62 +530,17 @@ Command *Command::addDep(DepDesc NewDep, std::vector &ToCleanUp) { NewDep.MDepCommand->addUser(this); } -#ifdef XPTI_ENABLE_INSTRUMENTATION - emitEdgeEventForCommandDependence(NewDep.MDepCommand, - (void *)NewDep.MDepRequirement->MSYCLMemObj, - true, NewDep.MDepRequirement->MAccessMode); -#endif - return ConnectionCmd; } Command *Command::addDep(EventImplPtr Event, std::vector &ToCleanUp) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - // We need this for just the instrumentation, so guarding it will prevent - // unused variable warnings when instrumentation is turned off - Command *Cmd = (Command *)Event->getCommand(); - ur_event_handle_t UrEventAddr = Event->getHandle(); - // Now make an edge for the dependent event - emitEdgeEventForEventDependence(Cmd, UrEventAddr); -#endif - return processDepEvent(std::move(Event), DepDesc{nullptr, nullptr, nullptr}, ToCleanUp); } -void Command::emitEnqueuedEventSignal(const ur_event_handle_t UrEventAddr) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - emitInstrumentationGeneral( - MStreamID, MInstanceID, static_cast(MTraceEvent), - xpti::trace_signal, static_cast(UrEventAddr)); -#endif - std::ignore = UrEventAddr; -} - -void Command::emitInstrumentation(uint16_t Type, const char *Txt) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - return emitInstrumentationGeneral(MStreamID, MInstanceID, - static_cast(MTraceEvent), Type, - static_cast(Txt)); -#else - std::ignore = Type; - std::ignore = Txt; -#endif -} - bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking, std::vector &ToCleanUp) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - // If command is enqueued from host task thread - it will not have valid - // submission code location set. So we set it manually to properly trace - // failures if ur level report any. - std::unique_ptr AsyncCodeLocationPtr; - if (xptiTraceEnabled() && !CurrentCodeLocationValid()) { - AsyncCodeLocationPtr.reset( - new detail::tls_code_loc_t(MSubmissionCodeLocation)); - } -#endif // Exit if already enqueued if (MEnqueueStatus == EnqueueResultT::SyclEnqueueSuccess) return true; @@ -917,21 +553,9 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking, return false; } -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Scoped trace event notifier that emits a barrier begin and barrier end - // event, which models the barrier while enqueuing along with the blocked - // reason, as determined by the scheduler - std::string Info = "enqueue.barrier["; - Info += std::string(getBlockReason()) + "]"; - emitInstrumentation(xpti::trace_barrier_begin, Info.c_str()); -#endif - // Wait if blocking while (MEnqueueStatus == EnqueueResultT::SyclEnqueueBlocked) ; -#ifdef XPTI_ENABLE_INSTRUMENTATION - emitInstrumentation(xpti::trace_barrier_end, Info.c_str()); -#endif } std::lock_guard Lock(MEnqueueMtx); @@ -940,10 +564,6 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking, if (MEnqueueStatus == EnqueueResultT::SyclEnqueueSuccess) return true; -#ifdef XPTI_ENABLE_INSTRUMENTATION - emitInstrumentation(xpti::trace_task_begin, nullptr); -#endif - if (MEnqueueStatus == EnqueueResultT::SyclEnqueueFailed) { EnqueueResult = EnqueueResultT(EnqueueResultT::SyclEnqueueFailed, this); return false; @@ -977,56 +597,9 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking, } } - // Emit this correlation signal before the task end - emitEnqueuedEventSignal(MEvent->getHandle()); -#ifdef XPTI_ENABLE_INSTRUMENTATION - emitInstrumentation(xpti::trace_task_end, nullptr); -#endif return MEnqueueStatus == EnqueueResultT::SyclEnqueueSuccess; } -void Command::resolveReleaseDependencies(std::set &DepList) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - assert(MType == CommandType::RELEASE && "Expected release command"); - if (!MTraceEvent) - return; - // The current command is the target node for all dependencies as the source - // nodes have to be completed first before the current node can begin to - // execute; these edges model control flow - xpti_td *TgtTraceEvent = static_cast(MTraceEvent); - // We have all the Commands that must be completed before the release - // command can be enqueued; here we'll find the command that is an Alloca - // with the same SYCLMemObject address and create a dependency line (edge) - // between them in our sematic modeling - for (auto &Item : DepList) { - if (Item->MTraceEvent && Item->MAddress == MAddress) { - xpti::utils::StringHelper SH; - std::string AddressStr = SH.addressAsString(MAddress); - std::string TypeString = - "Edge:" + SH.nameWithAddressString(commandToName(MType), AddressStr); - - // Create an edge with the dependent buffer address being one of the - // properties of the edge - xpti::payload_t p(TypeString.c_str(), MAddress); - uint64_t EdgeInstanceNo; - xpti_td *EdgeEvent = - xptiMakeEvent(TypeString.c_str(), &p, xpti::trace_graph_event, - xpti_at::active, &EdgeInstanceNo); - if (EdgeEvent) { - xpti_td *SrcTraceEvent = static_cast(Item->MTraceEvent); - EdgeEvent->target_id = TgtTraceEvent->unique_id; - EdgeEvent->source_id = SrcTraceEvent->unique_id; - xpti::addMetadata(EdgeEvent, "memory_object", - reinterpret_cast(MAddress)); - xptiNotifySubscribers(MStreamID, xpti::trace_edge_create, - detail::GSYCLGraphEvent, EdgeEvent, - EdgeInstanceNo, nullptr); - } - } - } -#endif -} - const char *Command::getBlockReason() const { switch (MBlockReason) { case BlockReason::HostAccessor: @@ -1038,24 +611,6 @@ const char *Command::getBlockReason() const { } } -void Command::copySubmissionCodeLocation() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiTraceEnabled()) - return; - - detail::tls_code_loc_t Tls; - auto TData = Tls.query(); - if (TData.fileName()) - MSubmissionFileName = TData.fileName(); - if (TData.functionName()) - MSubmissionFunctionName = TData.functionName(); - if (MSubmissionFileName.size() || MSubmissionFunctionName.size()) - MSubmissionCodeLocation = { - MSubmissionFileName.c_str(), MSubmissionFunctionName.c_str(), - (int)TData.lineNumber(), (int)TData.columnNumber()}; -#endif -} - AllocaCommandBase::AllocaCommandBase(CommandType Type, QueueImplPtr Queue, Requirement Req, AllocaCommandBase *LinkedAllocaCmd, @@ -1064,33 +619,6 @@ AllocaCommandBase::AllocaCommandBase(CommandType Type, QueueImplPtr Queue, MIsLeaderAlloca(nullptr == LinkedAllocaCmd), MIsConst(IsConst), MRequirement(std::move(Req)), MReleaseCmd(Queue, this) { MRequirement.MAccessMode = access::mode::read_write; - emitInstrumentationDataProxy(); -} - -void AllocaCommandBase::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return; - // Create a payload with the command name and an event using this payload to - // emit a node_create - MAddress = MRequirement.MSYCLMemObj; - makeTraceEventProlog(MAddress); - // Set the relevant meta data properties for this command; in the 64-bit key - // based implementation, we would notify the graph events only for the first - // instance as the trace event structure was invariant across all instances. - // Due to mutable metadata requirements, we now create and notify them for all - // instances. In addition to this, we have moved to 128-bit keys in the XPTI - // internal infrastructure to guarantee collision free universal IDs. - if (MTraceEvent) { - xpti_td *TE = static_cast(MTraceEvent); - addDeviceMetadata(TE, MQueue); - xpti::addMetadata(TE, "memory_object", reinterpret_cast(MAddress)); - // Since we do NOT add queue_id value to metadata, we are stashing it to TLS - // as this data is mutable and the metadata is supposed to be invariant - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, - getQueueID(MQueue)); - } -#endif } bool AllocaCommandBase::producesPiEvent() const { return false; } @@ -1105,9 +633,6 @@ AllocaCommand::AllocaCommand(QueueImplPtr Queue, Requirement Req, : AllocaCommandBase(CommandType::ALLOCA, std::move(Queue), std::move(Req), LinkedAllocaCmd, IsConst), MInitFromUserData(InitFromUserData) { - // Node event must be created before the dependent edge is added to this - // node, so this call must be before the addDep() call. - emitInstrumentationDataProxy(); // "Nothing to depend on" std::vector ToCleanUp; Command *ConnectionCmd = @@ -1117,15 +642,6 @@ AllocaCommand::AllocaCommand(QueueImplPtr Queue, Requirement Req, (void)ConnectionCmd; } -void AllocaCommand::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return; - - makeTraceEventEpilog(); -#endif -} - ur_result_t AllocaCommand::enqueueImp() { waitForPreparedHostEvents(); std::vector EventImpls = MPreparedDepsEvents; @@ -1157,6 +673,20 @@ ur_result_t AllocaCommand::enqueueImp() { return UR_RESULT_SUCCESS; } +static std::string queueDeviceToString(const queue_impl *const &Queue) { + if (!Queue) + return "HOST"; + auto Device = Queue->get_device(); + if (Device.is_cpu()) + return "CPU"; + else if (Device.is_gpu()) + return "GPU"; + else if (Device.is_accelerator()) + return "ACCELERATOR"; + else + return "UNKNOWN"; +} + void AllocaCommand::printDot(std::ostream &Stream) const { Stream << "\"" << this << "\" [style=filled, fillcolor=\"#FFD28A\", label=\""; @@ -1185,31 +715,12 @@ AllocaSubBufCommand::AllocaSubBufCommand(QueueImplPtr Queue, Requirement Req, std::move(Req), /*LinkedAllocaCmd*/ nullptr, /*IsConst*/ false), MParentAlloca(ParentAlloca) { - // Node event must be created before the dependent edge - // is added to this node, so this call must be before - // the addDep() call. - emitInstrumentationDataProxy(); Command *ConnectionCmd = addDep( DepDesc(MParentAlloca, getRequirement(), MParentAlloca), ToCleanUp); if (ConnectionCmd) ToEnqueue.push_back(ConnectionCmd); } -void AllocaSubBufCommand::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return; - - xpti_td *TE = static_cast(MTraceEvent); - xpti::addMetadata(TE, "offset", this->MRequirement.MOffsetInBytes); - xpti::addMetadata(TE, "access_range_start", - this->MRequirement.MAccessRange[0]); - xpti::addMetadata(TE, "access_range_end", this->MRequirement.MAccessRange[1]); - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, getQueueID(MQueue)); - makeTraceEventEpilog(); -#endif -} - void *AllocaSubBufCommand::getMemAllocation() const { // In some cases parent`s memory allocation might change (e.g., after // map/unmap operations). If parent`s memory allocation changes, sub-buffer @@ -1237,8 +748,6 @@ ur_result_t AllocaSubBufCommand::enqueueImp() { MEvent->setHandle(UREvent); - XPTIRegistry::bufferAssociateNotification(MParentAlloca->getSYCLMemObj(), - MMemAllocation); return UR_RESULT_SUCCESS; } @@ -1264,29 +773,7 @@ void AllocaSubBufCommand::printDot(std::ostream &Stream) const { } ReleaseCommand::ReleaseCommand(QueueImplPtr Queue, AllocaCommandBase *AllocaCmd) - : Command(CommandType::RELEASE, std::move(Queue)), MAllocaCmd(AllocaCmd) { - emitInstrumentationDataProxy(); -} - -void ReleaseCommand::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return; - // Create a payload with the command name and an event using this payload to - // emit a node_create - MAddress = MAllocaCmd->getSYCLMemObj(); - makeTraceEventProlog(MAddress); - - xpti_td *TE = static_cast(MTraceEvent); - addDeviceMetadata(TE, MQueue); - xpti::addMetadata(TE, "allocation_type", - commandToName(MAllocaCmd->getType())); - // Since we do NOT add queue_id value to metadata, we are stashing it to TLS - // as this data is mutable and the metadata is supposed to be invariant - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, getQueueID(MQueue)); - makeTraceEventEpilog(); -#endif -} + : Command(CommandType::RELEASE, std::move(Queue)), MAllocaCmd(AllocaCmd) {} ur_result_t ReleaseCommand::enqueueImp() { waitForPreparedHostEvents(); @@ -1389,28 +876,7 @@ MapMemObject::MapMemObject(AllocaCommandBase *SrcAllocaCmd, Requirement Req, access::mode MapMode) : Command(CommandType::MAP_MEM_OBJ, std::move(Queue)), MSrcAllocaCmd(SrcAllocaCmd), MSrcReq(std::move(Req)), MDstPtr(DstPtr), - MMapMode(MapMode) { - emitInstrumentationDataProxy(); -} - -void MapMemObject::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return; - // Create a payload with the command name and an event using this payload to - // emit a node_create - MAddress = MSrcAllocaCmd->getSYCLMemObj(); - makeTraceEventProlog(MAddress); - - xpti_td *TE = static_cast(MTraceEvent); - addDeviceMetadata(TE, MQueue); - xpti::addMetadata(TE, "memory_object", reinterpret_cast(MAddress)); - // Since we do NOT add queue_id value to metadata, we are stashing it to TLS - // as this data is mutable and the metadata is supposed to be invariant - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, getQueueID(MQueue)); - makeTraceEventEpilog(); -#endif -} + MMapMode(MapMode) {} ur_result_t MapMemObject::enqueueImp() { waitForPreparedHostEvents(); @@ -1451,28 +917,7 @@ void MapMemObject::printDot(std::ostream &Stream) const { UnMapMemObject::UnMapMemObject(AllocaCommandBase *DstAllocaCmd, Requirement Req, void **SrcPtr, QueueImplPtr Queue) : Command(CommandType::UNMAP_MEM_OBJ, std::move(Queue)), - MDstAllocaCmd(DstAllocaCmd), MDstReq(std::move(Req)), MSrcPtr(SrcPtr) { - emitInstrumentationDataProxy(); -} - -void UnMapMemObject::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return; - // Create a payload with the command name and an event using this payload to - // emit a node_create - MAddress = MDstAllocaCmd->getSYCLMemObj(); - makeTraceEventProlog(MAddress); - - xpti_td *TE = static_cast(MTraceEvent); - addDeviceMetadata(TE, MQueue); - xpti::addMetadata(TE, "memory_object", reinterpret_cast(MAddress)); - // Since we do NOT add queue_id value to metadata, we are stashing it to TLS - // as this data is mutable and the metadata is supposed to be invariant - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, getQueueID(MQueue)); - makeTraceEventEpilog(); -#endif -} + MDstAllocaCmd(DstAllocaCmd), MDstReq(std::move(Req)), MSrcPtr(SrcPtr) {} bool UnMapMemObject::producesPiEvent() const { // TODO remove this workaround once the batching issue is addressed in Level @@ -1546,32 +991,6 @@ MemCpyCommand::MemCpyCommand(Requirement SrcReq, MWorkerQueue = !MQueue ? MSrcQueue : MQueue; MEvent->setWorkerQueue(MWorkerQueue); - - emitInstrumentationDataProxy(); -} - -void MemCpyCommand::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return; - // Create a payload with the command name and an event using this payload to - // emit a node_create - MAddress = MSrcAllocaCmd->getSYCLMemObj(); - makeTraceEventProlog(MAddress); - - xpti_td *CmdTraceEvent = static_cast(MTraceEvent); - addDeviceMetadata(CmdTraceEvent, MQueue); - xpti::addMetadata(CmdTraceEvent, "memory_object", - reinterpret_cast(MAddress)); - xpti::addMetadata(CmdTraceEvent, "copy_from", - MSrcQueue ? deviceToID(MSrcQueue->get_device()) : 0); - xpti::addMetadata(CmdTraceEvent, "copy_to", - MQueue ? deviceToID(MQueue->get_device()) : 0); - // Since we do NOT add queue_id value to metadata, we are stashing it to TLS - // as this data is mutable and the metadata is supposed to be invariant - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, getQueueID(MQueue)); - makeTraceEventEpilog(); -#endif } ContextImplPtr MemCpyCommand::getWorkerContext() const { @@ -1720,32 +1139,6 @@ MemCpyCommandHost::MemCpyCommandHost(Requirement SrcReq, MWorkerQueue = !MQueue ? MSrcQueue : MQueue; MEvent->setWorkerQueue(MWorkerQueue); - - emitInstrumentationDataProxy(); -} - -void MemCpyCommandHost::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return; - // Create a payload with the command name and an event using this payload to - // emit a node_create - MAddress = MSrcAllocaCmd->getSYCLMemObj(); - makeTraceEventProlog(MAddress); - - xpti_td *CmdTraceEvent = static_cast(MTraceEvent); - addDeviceMetadata(CmdTraceEvent, MQueue); - xpti::addMetadata(CmdTraceEvent, "memory_object", - reinterpret_cast(MAddress)); - xpti::addMetadata(CmdTraceEvent, "copy_from", - MSrcQueue ? deviceToID(MSrcQueue->get_device()) : 0); - xpti::addMetadata(CmdTraceEvent, "copy_to", - MQueue ? deviceToID(MQueue->get_device()) : 0); - // Since we do NOT add queue_id value to metadata, we are stashing it to TLS - // as this data is mutable and the metadata is supposed to be invariant - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, getQueueID(MQueue)); - makeTraceEventEpilog(); -#endif } ContextImplPtr MemCpyCommandHost::getWorkerContext() const { @@ -1787,9 +1180,7 @@ ur_result_t MemCpyCommandHost::enqueueImp() { return UR_RESULT_SUCCESS; } -EmptyCommand::EmptyCommand() : Command(CommandType::EMPTY_TASK, nullptr) { - emitInstrumentationDataProxy(); -} +EmptyCommand::EmptyCommand() : Command(CommandType::EMPTY_TASK, nullptr) {} ur_result_t EmptyCommand::enqueueImp() { waitForPreparedHostEvents(); @@ -1815,31 +1206,6 @@ void EmptyCommand::addRequirement(Command *DepCmd, AllocaCommandBase *AllocaCmd, (void)Cmd; } -void EmptyCommand::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return; - // Create a payload with the command name and an event using this payload to - // emit a node_create - if (MRequirements.empty()) - return; - - Requirement &Req = *MRequirements.begin(); - - MAddress = Req.MSYCLMemObj; - makeTraceEventProlog(MAddress); - - xpti_td *CmdTraceEvent = static_cast(MTraceEvent); - addDeviceMetadata(CmdTraceEvent, MQueue); - xpti::addMetadata(CmdTraceEvent, "memory_object", - reinterpret_cast(MAddress)); - // Since we do NOT add queue_id value to metadata, we are stashing it to TLS - // as this data is mutable and the metadata is supposed to be invariant - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, getQueueID(MQueue)); - makeTraceEventEpilog(); -#endif -} - void EmptyCommand::printDot(std::ostream &Stream) const { Stream << "\"" << this << "\" [style=filled, fillcolor=\"#8d8f29\", label=\""; @@ -1881,30 +1247,7 @@ UpdateHostRequirementCommand::UpdateHostRequirementCommand( QueueImplPtr Queue, Requirement Req, AllocaCommandBase *SrcAllocaCmd, void **DstPtr) : Command(CommandType::UPDATE_REQUIREMENT, std::move(Queue)), - MSrcAllocaCmd(SrcAllocaCmd), MDstReq(std::move(Req)), MDstPtr(DstPtr) { - - emitInstrumentationDataProxy(); -} - -void UpdateHostRequirementCommand::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - if (!xptiCheckTraceEnabled(MStreamID)) - return; - // Create a payload with the command name and an event using this payload to - // emit a node_create - MAddress = MSrcAllocaCmd->getSYCLMemObj(); - makeTraceEventProlog(MAddress); - - xpti_td *CmdTraceEvent = static_cast(MTraceEvent); - addDeviceMetadata(CmdTraceEvent, MQueue); - xpti::addMetadata(CmdTraceEvent, "memory_object", - reinterpret_cast(MAddress)); - // Since we do NOT add queue_id value to metadata, we are stashing it to TLS - // as this data is mutable and the metadata is supposed to be invariant - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, getQueueID(MQueue)); - makeTraceEventEpilog(); -#endif -} + MSrcAllocaCmd(SrcAllocaCmd), MDstReq(std::move(Req)), MDstPtr(DstPtr) {} static std::string_view cgTypeToString(detail::CGType Type) { switch (Type) { @@ -1988,266 +1331,6 @@ ExecCGCommand::ExecCGCommand( } if (MCommandGroup->getType() == detail::CGType::ProfilingTag) MEvent->markAsProfilingTagEvent(); - - emitInstrumentationDataProxy(); -} - -#ifdef XPTI_ENABLE_INSTRUMENTATION -std::string instrumentationGetKernelName( - const std::shared_ptr &SyclKernel, - const std::string &FunctionName, const std::string &SyclKernelName, - void *&Address, std::optional &FromSource) { - std::string KernelName; - if (SyclKernel && SyclKernel->isCreatedFromSource()) { - FromSource = true; - ur_kernel_handle_t KernelHandle = SyclKernel->getHandleRef(); - Address = KernelHandle; - KernelName = FunctionName; - } else { - FromSource = false; - KernelName = demangleKernelName(SyclKernelName); - } - return KernelName; -} - -void instrumentationAddExtraKernelMetadata( - xpti_td *&CmdTraceEvent, const NDRDescT &NDRDesc, - const std::shared_ptr &KernelBundleImplPtr, - const std::string &KernelName, - const std::shared_ptr &SyclKernel, - const QueueImplPtr &Queue, - std::vector &CGArgs) // CGArgs are not const since they could be - // sorted in this function -{ - std::vector Args; - - auto FilterArgs = [&Args](detail::ArgDesc &Arg, int NextTrueIndex) { - Args.push_back({Arg.MType, Arg.MPtr, Arg.MSize, NextTrueIndex}); - }; - ur_program_handle_t Program = nullptr; - ur_kernel_handle_t Kernel = nullptr; - std::mutex *KernelMutex = nullptr; - const KernelArgMask *EliminatedArgMask = nullptr; - - std::shared_ptr SyclKernelImpl; - std::shared_ptr DeviceImageImpl; - - // Use kernel_bundle if available unless it is interop. - // Interop bundles can't be used in the first branch, because the - // kernels in interop kernel bundles (if any) do not have kernel_id and - // can therefore not be looked up, but since they are self-contained - // they can simply be launched directly. - if (KernelBundleImplPtr && !KernelBundleImplPtr->isInterop()) { - kernel_id KernelID = - detail::ProgramManager::getInstance().getSYCLKernelID(KernelName); - kernel SyclKernel = - KernelBundleImplPtr->get_kernel(KernelID, KernelBundleImplPtr); - std::shared_ptr KernelImpl = - detail::getSyclObjImpl(SyclKernel); - - EliminatedArgMask = KernelImpl->getKernelArgMask(); - Program = KernelImpl->getDeviceImage()->get_ur_program_ref(); - } else if (nullptr != SyclKernel) { - Program = SyclKernel->getProgramRef(); - if (!SyclKernel->isCreatedFromSource()) - EliminatedArgMask = SyclKernel->getKernelArgMask(); - } else if (Queue) { - // NOTE: Queue can be null when kernel is directly enqueued to a command - // buffer - // by graph API, when a modifiable graph is finalized. - std::tie(Kernel, KernelMutex, EliminatedArgMask, Program) = - detail::ProgramManager::getInstance().getOrCreateKernel( - Queue->getContextImplPtr(), Queue->getDeviceImplPtr(), KernelName); - } - - applyFuncOnFilteredArgs(EliminatedArgMask, CGArgs, FilterArgs); - - xpti::offload_kernel_enqueue_data_t KernelData{ - {NDRDesc.GlobalSize[0], NDRDesc.GlobalSize[1], NDRDesc.GlobalSize[2]}, - {NDRDesc.LocalSize[0], NDRDesc.LocalSize[1], NDRDesc.LocalSize[2]}, - {NDRDesc.GlobalOffset[0], NDRDesc.GlobalOffset[1], - NDRDesc.GlobalOffset[2]}, - Args.size()}; - xpti::addMetadata(CmdTraceEvent, "enqueue_kernel_data", KernelData); - for (size_t i = 0; i < Args.size(); i++) { - std::string Prefix("arg"); - xpti::offload_kernel_arg_data_t arg{(int)Args[i].MType, Args[i].MPtr, - Args[i].MSize, Args[i].MIndex}; - xpti::addMetadata(CmdTraceEvent, Prefix + std::to_string(i), arg); - } -} - -void instrumentationFillCommonData(const std::string &KernelName, - const std::string &FuncName, - const std::string &FileName, uint64_t Line, - uint64_t Column, const void *const Address, - const QueueImplPtr &Queue, - std::optional &FromSource, - uint64_t &OutInstanceID, - xpti_td *&OutTraceEvent) { - // Get source file, line number information from the CommandGroup object - // and create payload using name, address, and source info - // - // On Windows, since the support for builtin functions is not available in - // MSVC, the MFileName, MLine will be set to nullptr and "0" respectively. - // Handle this condition explicitly here. - bool HasSourceInfo = false; - xpti::payload_t Payload; - if (!FileName.empty()) { - // File name has a valid string - Payload = xpti::payload_t(FuncName.empty() ? KernelName.c_str() - : FuncName.c_str(), - FileName.c_str(), Line, Column, Address); - HasSourceInfo = true; - } else if (Address) { - // We have a valid function name and an address - Payload = xpti::payload_t(KernelName.c_str(), Address); - } else { - // In any case, we will have a valid function name and we'll use that to - // create the hash - Payload = xpti::payload_t(KernelName.c_str()); - } - - uint64_t CGKernelInstanceNo; - // Create event using the payload - xpti_td *CmdTraceEvent = - xptiMakeEvent("ExecCG", &Payload, xpti::trace_graph_event, - xpti::trace_activity_type_t::active, &CGKernelInstanceNo); - if (CmdTraceEvent) { - OutInstanceID = CGKernelInstanceNo; - OutTraceEvent = CmdTraceEvent; - - addDeviceMetadata(CmdTraceEvent, Queue); - if (!KernelName.empty()) { - xpti::addMetadata(CmdTraceEvent, "kernel_name", KernelName); - } - if (FromSource.has_value()) { - xpti::addMetadata(CmdTraceEvent, "from_source", FromSource.value()); - } - if (HasSourceInfo) { - xpti::addMetadata(CmdTraceEvent, "sym_function_name", KernelName); - xpti::addMetadata(CmdTraceEvent, "sym_source_file_name", FileName); - xpti::addMetadata(CmdTraceEvent, "sym_line_no", static_cast(Line)); - xpti::addMetadata(CmdTraceEvent, "sym_column_no", - static_cast(Column)); - } - // We no longer set the 'queue_id' in the metadata structure as it is a - // mutable value and multiple threads using the same queue created at the - // same location will overwrite the metadata values creating inconsistencies - } -} -#endif - -#ifdef XPTI_ENABLE_INSTRUMENTATION -std::pair emitKernelInstrumentationData( - int32_t StreamID, const std::shared_ptr &SyclKernel, - const detail::code_location &CodeLoc, bool IsTopCodeLoc, - const std::string &SyclKernelName, const QueueImplPtr &Queue, - const NDRDescT &NDRDesc, - const std::shared_ptr &KernelBundleImplPtr, - std::vector &CGArgs) { - - auto XptiObjects = std::make_pair(nullptr, -1); - constexpr uint16_t NotificationTraceType = xpti::trace_node_create; - if (!xptiCheckTraceEnabled(StreamID)) - return XptiObjects; - - void *Address = nullptr; - std::optional FromSource; - std::string KernelName = instrumentationGetKernelName( - SyclKernel, std::string(CodeLoc.functionName()), SyclKernelName, Address, - FromSource); - - auto &[CmdTraceEvent, InstanceID] = XptiObjects; - - std::string FileName = - CodeLoc.fileName() ? CodeLoc.fileName() : std::string(); - - // If code location is above sycl layer, use function name from code - // location instead of kernel name in event payload - std::string FuncName = (!IsTopCodeLoc && CodeLoc.functionName()) - ? CodeLoc.functionName() - : std::string(); - - instrumentationFillCommonData(KernelName, FuncName, FileName, - CodeLoc.lineNumber(), CodeLoc.columnNumber(), - Address, Queue, FromSource, InstanceID, - CmdTraceEvent); - - if (CmdTraceEvent) { - // Stash the queue_id mutable metadata in TLS - // NOTE: Queue can be null when kernel is directly enqueued to a command - // buffer by graph API, when a modifiable graph is finalized. - if (Queue.get()) - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, - getQueueID(Queue)); - instrumentationAddExtraKernelMetadata(CmdTraceEvent, NDRDesc, - KernelBundleImplPtr, SyclKernelName, - SyclKernel, Queue, CGArgs); - - xptiNotifySubscribers( - StreamID, NotificationTraceType, detail::GSYCLGraphEvent, CmdTraceEvent, - InstanceID, - static_cast( - commandToNodeType(Command::CommandType::RUN_CG).c_str())); - } - - return XptiObjects; -} -#endif - -void ExecCGCommand::emitInstrumentationData() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_node_create; - if (!xptiCheckTraceEnabled(MStreamID)) - return; - - std::string KernelName; - std::optional FromSource; - switch (MCommandGroup->getType()) { - case detail::CGType::Kernel: { - auto KernelCG = - reinterpret_cast(MCommandGroup.get()); - KernelName = instrumentationGetKernelName( - KernelCG->MSyclKernel, MCommandGroup->MFunctionName, - KernelCG->getKernelName(), MAddress, FromSource); - } break; - default: - KernelName = getTypeString(); - break; - } - - // If code location is above sycl layer, use function name from code - // location instead of kernel name in event payload - std::string FuncName; - if (!MCommandGroup->MIsTopCodeLoc) - FuncName = MCommandGroup->MFunctionName; - - xpti_td *CmdTraceEvent = nullptr; - instrumentationFillCommonData(KernelName, FuncName, MCommandGroup->MFileName, - MCommandGroup->MLine, MCommandGroup->MColumn, - MAddress, MQueue, FromSource, MInstanceID, - CmdTraceEvent); - - if (CmdTraceEvent) { - xpti::framework::stash_tuple(XPTI_QUEUE_INSTANCE_ID_KEY, - getQueueID(MQueue)); - MTraceEvent = static_cast(CmdTraceEvent); - if (MCommandGroup->getType() == detail::CGType::Kernel) { - auto KernelCG = - reinterpret_cast(MCommandGroup.get()); - instrumentationAddExtraKernelMetadata( - CmdTraceEvent, KernelCG->MNDRDesc, KernelCG->getKernelBundle(), - KernelCG->MKernelName, KernelCG->MSyclKernel, MQueue, - KernelCG->MArgs); - } - - xptiNotifySubscribers( - MStreamID, NotificationTraceType, detail::GSYCLGraphEvent, - CmdTraceEvent, MInstanceID, - static_cast(commandToNodeType(MType).c_str())); - } -#endif } void ExecCGCommand::printDot(std::ostream &Stream) const { @@ -3348,10 +2431,6 @@ ur_result_t ExecCGCommand::enqueueImpQueue() { std::sort(std::begin(ReqToMem), std::end(ReqToMem)); } - // Host task is executed asynchronously so we should record where it was - // submitted to report exception origin properly. - copySubmissionCodeLocation(); - queue_impl::getThreadPool().submit( DispatchHostTask(this, std::move(ReqToMem), std::move(ReqUrMem))); @@ -3730,7 +2809,6 @@ void UpdateCommandBufferCommand::printDot(std::ostream &Stream) const { } } -void UpdateCommandBufferCommand::emitInstrumentationData() {} bool UpdateCommandBufferCommand::producesPiEvent() const { return false; } } // namespace detail diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index 239cebf521767..650a0b1a2b3f8 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -32,11 +32,6 @@ class node_impl; } // namespace ext::oneapi::experimental::detail namespace detail { -#ifdef XPTI_ENABLE_INSTRUMENTATION -void emitInstrumentationGeneral(uint32_t StreamID, uint64_t InstanceID, - xpti_td *TraceEvent, uint16_t Type, - const void *Addr); -#endif RTDeviceBinaryImage * retrieveAMDGCNOrNVPTXKernelBinary(const DeviceImplPtr DeviceImpl, const std::string &KernelName); @@ -181,37 +176,6 @@ class Command { const EventImplPtr &getEvent() const { return MEvent; } - // Methods needed to support SYCL instrumentation - - /// Proxy method which calls emitInstrumentationData. - void emitInstrumentationDataProxy(); - /// Instrumentation method which emits telemetry data. - virtual void emitInstrumentationData() = 0; - /// Looks at all the dependencies for the release command and enables - /// instrumentation to report these dependencies as edges. - void resolveReleaseDependencies(std::set &list); - /// Creates an edge event when the dependency is a command. - void emitEdgeEventForCommandDependence( - Command *Cmd, void *ObjAddr, bool IsCommand, - std::optional AccMode = std::nullopt); - /// Creates an edge event when the dependency is an event. - void emitEdgeEventForEventDependence(Command *Cmd, - ur_event_handle_t &EventAddr); - /// Creates a signal event with the enqueued kernel event handle. - void emitEnqueuedEventSignal(const ur_event_handle_t UrEventAddr); - /// Create a trace event of node_create type; this must be guarded by a - /// check for xptiTraceEnabled(). - /// Post Condition: MTraceEvent will be set to the event created. - /// \param MAddress The address to use to create the payload. - uint64_t makeTraceEventProlog(void *MAddress); - /// If prolog has been run, run epilog; this must be guarded by a check for - /// xptiTraceEnabled(). - void makeTraceEventEpilog(); - /// Emits an event of Type. - void emitInstrumentation(uint16_t Type, const char *Txt = nullptr); - - // End Methods needed to support SYCL instrumentation - virtual void printDot(std::ostream &Stream) const = 0; virtual const Requirement *getRequirement() const { @@ -304,10 +268,6 @@ class Command { return MPreparedDepsEvents; } - // XPTI instrumentation. Copy code location details to the internal struct. - // Memory is allocated in this method and released in destructor. - void copySubmissionCodeLocation(); - /// Contains list of dependencies(edges) std::vector MDeps; /// Contains list of commands that depend on the command. @@ -334,39 +294,6 @@ class Command { /// Describes the status of the command. std::atomic MEnqueueStatus; - // All member variables defined here are needed for the SYCL instrumentation - // layer. Do not guard these variables below with XPTI_ENABLE_INSTRUMENTATION - // to ensure we have the same object layout when the macro in the library and - // SYCL app are not the same. - - /// The event for node_create and task_begin. - void *MTraceEvent = nullptr; - /// The stream under which the traces are emitted. - /// - /// Stream ids are positive integers and we set it to an invalid value. - int32_t MStreamID = -1; - /// Reserved for storing the object address such as SPIR-V or memory object - /// address. - void *MAddress = nullptr; - /// Buffer to build the address string. - std::string MAddressString; - /// Buffer to build the command node type. - std::string MCommandNodeType; - /// Buffer to build the command end-user understandable name. - std::string MCommandName; - /// Flag to indicate if makeTraceEventProlog() has been run. - bool MTraceEventPrologComplete = false; - /// Instance ID tracked for the command. - uint64_t MInstanceID = 0; - /// Represents code location of command submission to SYCL API, assigned with - /// the valid value only if command execution is async (host task) or delayed - /// (blocked by host task). - code_location MSubmissionCodeLocation; - /// Introduces string to handle memory management since code_location struct - /// works with raw char arrays. - std::string MSubmissionFileName; - std::string MSubmissionFunctionName; - // This flag allows to control whether event should be set complete // after successfull enqueue of command. Event is considered as "host" event // if there is no backend representation of event (i.e. getHandleRef() return @@ -412,8 +339,6 @@ class EmptyCommand : public Command { void addRequirement(Command *DepCmd, AllocaCommandBase *AllocaCmd, const Requirement *Req); - void emitInstrumentationData() override; - bool producesPiEvent() const final; private: @@ -432,7 +357,6 @@ class ReleaseCommand : public Command { ReleaseCommand(QueueImplPtr Queue, AllocaCommandBase *AllocaCmd); void printDot(std::ostream &Stream) const final; - void emitInstrumentationData() override; bool producesPiEvent() const final; bool supportsPostEnqueueCleanup() const final; bool readyForCleanup() const final; @@ -458,8 +382,6 @@ class AllocaCommandBase : public Command { const Requirement *getRequirement() const final { return &MRequirement; } - void emitInstrumentationData() override; - bool producesPiEvent() const final; bool supportsPostEnqueueCleanup() const final; @@ -499,7 +421,6 @@ class AllocaCommand : public AllocaCommandBase { void *getMemAllocation() const final { return MMemAllocation; } void printDot(std::ostream &Stream) const final; - void emitInstrumentationData() override; private: ur_result_t enqueueImp() final; @@ -520,7 +441,6 @@ class AllocaSubBufCommand : public AllocaCommandBase { void *getMemAllocation() const final; void printDot(std::ostream &Stream) const final; AllocaCommandBase *getParentAlloca() { return MParentAlloca; } - void emitInstrumentationData() override; private: ur_result_t enqueueImp() final; @@ -536,7 +456,6 @@ class MapMemObject : public Command { void printDot(std::ostream &Stream) const final; const Requirement *getRequirement() const final { return &MSrcReq; } - void emitInstrumentationData() override; private: ur_result_t enqueueImp() final; @@ -555,7 +474,6 @@ class UnMapMemObject : public Command { void printDot(std::ostream &Stream) const final; const Requirement *getRequirement() const final { return &MDstReq; } - void emitInstrumentationData() override; bool producesPiEvent() const final; private: @@ -576,7 +494,6 @@ class MemCpyCommand : public Command { void printDot(std::ostream &Stream) const final; const Requirement *getRequirement() const final { return &MDstReq; } - void emitInstrumentationData() final; ContextImplPtr getWorkerContext() const final; bool producesPiEvent() const final; @@ -600,7 +517,6 @@ class MemCpyCommandHost : public Command { void printDot(std::ostream &Stream) const final; const Requirement *getRequirement() const final { return &MDstReq; } - void emitInstrumentationData() final; ContextImplPtr getWorkerContext() const final; private: @@ -645,7 +561,6 @@ class ExecCGCommand : public Command { void clearAuxiliaryResources(); void printDot(std::ostream &Stream) const final; - void emitInstrumentationData() final; std::string_view getTypeString() const; detail::CG &getCG() const { return *MCommandGroup; } @@ -679,19 +594,6 @@ class ExecCGCommand : public Command { friend class Command; }; -// For XPTI instrumentation only. -// Method used to emit data in cases when we do not create node in graph. -// Very close to ExecCGCommand::emitInstrumentationData content. -#ifdef XPTI_ENABLE_INSTRUMENTATION -std::pair emitKernelInstrumentationData( - int32_t StreamID, const std::shared_ptr &SyclKernel, - const detail::code_location &CodeLoc, bool IsTopCodeLoc, - const std::string &SyclKernelName, const QueueImplPtr &Queue, - const NDRDescT &NDRDesc, - const std::shared_ptr &KernelBundleImplPtr, - std::vector &CGArgs); -#endif - class UpdateHostRequirementCommand : public Command { public: UpdateHostRequirementCommand(QueueImplPtr Queue, Requirement Req, @@ -699,7 +601,6 @@ class UpdateHostRequirementCommand : public Command { void printDot(std::ostream &Stream) const final; const Requirement *getRequirement() const final { return &MDstReq; } - void emitInstrumentationData() final; private: ur_result_t enqueueImp() final; @@ -718,7 +619,6 @@ class UpdateCommandBufferCommand : public Command { Nodes); void printDot(std::ostream &Stream) const final; - void emitInstrumentationData() final; bool producesPiEvent() const final; private: diff --git a/sycl/source/detail/scheduler/graph_processor.cpp b/sycl/source/detail/scheduler/graph_processor.cpp index 14396d8790968..3ef60f52e01a2 100644 --- a/sycl/source/detail/scheduler/graph_processor.cpp +++ b/sycl/source/detail/scheduler/graph_processor.cpp @@ -60,9 +60,6 @@ bool Scheduler::GraphProcessor::handleBlockingCmd(Command *Cmd, Cmd->addBlockedUserUnique(RootCmdEvent); EnqueueResult = EnqueueResultT(EnqueueResultT::SyclEnqueueBlocked, Cmd); - // Blocked command will be enqueued asynchronously from submission so we - // need to keep current root code location to report failure properly. - RootCommand->copySubmissionCodeLocation(); return false; } } diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index efbbb52acab73..b5a7daf3393a0 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -46,10 +46,6 @@ bool Scheduler::checkLeavesCompletion(MemObjRecord *Record) { void Scheduler::waitForRecordToFinish(MemObjRecord *Record, ReadLockT &GraphReadLock) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Will contain the list of dependencies for the Release Command - std::set DepCommands; -#endif std::vector ToCleanUp; for (Command *Cmd : Record->MReadLeaves) { EnqueueResultT Res; @@ -58,10 +54,6 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record, if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw exception(make_error_code(errc::runtime), "Enqueue process failed."); -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Capture the dependencies - DepCommands.insert(Cmd); -#endif GraphProcessor::waitForEvent(Cmd->getEvent(), GraphReadLock, ToCleanUp); } for (Command *Cmd : Record->MWriteLeaves) { @@ -71,9 +63,6 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record, if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw exception(make_error_code(errc::runtime), "Enqueue process failed."); -#ifdef XPTI_ENABLE_INSTRUMENTATION - DepCommands.insert(Cmd); -#endif GraphProcessor::waitForEvent(Cmd->getEvent(), GraphReadLock, ToCleanUp); } for (AllocaCommandBase *AllocaCmd : Record->MAllocaCommands) { @@ -84,11 +73,6 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record, if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw exception(make_error_code(errc::runtime), "Enqueue process failed."); -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Report these dependencies to the Command so these dependencies can be - // reported as edges - ReleaseCmd->resolveReleaseDependencies(DepCommands); -#endif GraphProcessor::waitForEvent(ReleaseCmd->getEvent(), GraphReadLock, ToCleanUp); } diff --git a/sycl/source/detail/ur.cpp b/sycl/source/detail/ur.cpp index 33249576265bb..de2f3e0c703c0 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -36,12 +35,6 @@ #include #include -#ifdef XPTI_ENABLE_INSTRUMENTATION -// Include the headers necessary for emitting -// traces using the trace framework -#include "xpti/xpti_trace_framework.h" -#endif - namespace sycl { inline namespace _V1 { namespace detail { @@ -57,13 +50,6 @@ void contextSetExtendedDeleter(const sycl::context &context, } } // namespace pi -#ifdef XPTI_ENABLE_INSTRUMENTATION -// Global (to the SYCL runtime) graph handle that all command groups are a -// child of -/// Event to be used by graph related activities -xpti_td *GSYCLGraphEvent = nullptr; -#endif // XPTI_ENABLE_INSTRUMENTATION - template void *getAdapterOpaqueData([[maybe_unused]] void *OpaqueDataParam) { // This was formerly a call to piextAdapterGetOpaqueData, a deprecated PI @@ -86,8 +72,6 @@ bool trace(TraceLevel Level) { static void initializeAdapters(std::vector &Adapters, ur_loader_config_handle_t LoaderConfig); -bool XPTIInitDone = false; - // Initializes all available Adapters. std::vector &initializeUr(ur_loader_config_handle_t LoaderConfig) { // This uses static variable initialization to work around a gcc bug with @@ -221,39 +205,6 @@ static void initializeAdapters(std::vector &Adapters, Adapters.emplace_back(std::make_shared(UrAdapter, syclBackend)); } -#ifdef XPTI_ENABLE_INSTRUMENTATION - GlobalHandler::instance().getXPTIRegistry().initializeFrameworkOnce(); - - if (!(xptiTraceEnabled() && !XPTIInitDone)) - return; - // Not sure this is the best place to initialize the framework; SYCL runtime - // team needs to advise on the right place, until then we piggy-back on the - // initialization of the UR layer. - - // Initialize the global events just once, in the case ur::initialize() is - // called multiple times - XPTIInitDone = true; - // Registers a new stream for 'sycl' and any application that wants to listen - // to this stream will register itself using this string or stream ID for - // this string. - uint8_t StreamID = xptiRegisterStream(SYCL_STREAM_NAME); - // Let all tool applications know that a stream by the name of 'sycl' has - // been initialized and will be generating the trace stream. - GlobalHandler::instance().getXPTIRegistry().initializeStream( - SYCL_STREAM_NAME, GMajVer, GMinVer, GVerStr); - // Create a tracepoint to indicate the graph creation - xpti::payload_t GraphPayload("application_graph"); - uint64_t GraphInstanceNo; - GSYCLGraphEvent = - xptiMakeEvent("application_graph", &GraphPayload, xpti::trace_graph_event, - xpti_at::active, &GraphInstanceNo); - if (GSYCLGraphEvent) { - // The graph event is a global event and will be used as the parent for - // all nodes (command groups) - xptiNotifySubscribers(StreamID, xpti::trace_graph_create, nullptr, - GSYCLGraphEvent, GraphInstanceNo, nullptr); - } -#endif #undef CHECK_UR_SUCCESS } diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index 08e08000e9ae2..ddfdd299904fb 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -22,34 +22,11 @@ #include #include -#ifdef XPTI_ENABLE_INSTRUMENTATION -// Include the headers necessary for emitting -// traces using the trace framework -#include "xpti/xpti_trace_framework.hpp" -#include -#endif - namespace { void *alignedAllocHost(size_t Alignment, size_t Size, const sycl::context &Ctxt, const sycl::property_list &PropList, const sycl::detail::code_location &CodeLoc) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Stash the code location information and propagate - sycl::detail::tls_code_loc_t CL(CodeLoc); - sycl::detail::XPTIScope PrepareNotify( - (void *)alignedAllocHost, (uint16_t)xpti::trace_point_type_t::node_create, - sycl::detail::SYCL_MEM_ALLOC_STREAM_NAME, "malloc_host"); - PrepareNotify.addMetadata([&](auto TEvent) { - xpti::addMetadata(TEvent, "sycl_device_name", std::string("Host")); - xpti::addMetadata(TEvent, "sycl_device", 0); - xpti::addMetadata(TEvent, "memory_size", Size); - }); - // Notify XPTI about the memset submission - PrepareNotify.notify(); - // Emit a begin/end scope for this call - PrepareNotify.scopedNotify( - (uint16_t)xpti::trace_point_type_t::mem_alloc_begin); -#endif + std::ignore = CodeLoc; const auto &devices = Ctxt.get_devices(); if (!std::any_of(devices.begin(), devices.end(), [&](const auto &device) { return device.has(sycl::aspect::usm_host_allocations); @@ -94,10 +71,6 @@ void *alignedAllocHost(size_t Alignment, size_t Size, const sycl::context &Ctxt, // The spec wants a nullptr returned, not an exception. if (Error != UR_RESULT_SUCCESS) return nullptr; -#ifdef XPTI_ENABLE_INSTRUMENTATION - xpti::addMetadata(PrepareNotify.traceEvent(), "memory_ptr", - reinterpret_cast(RetVal)); -#endif return RetVal; } } // namespace @@ -108,9 +81,6 @@ inline namespace _V1 { using alloc = sycl::usm::alloc; namespace detail { -#ifdef XPTI_ENABLE_INSTRUMENTATION -extern xpti::trace_event_data_t *GSYCLGraphEvent; -#endif namespace usm { void *alignedAllocInternal(size_t Alignment, size_t Size, @@ -219,32 +189,10 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, void *alignedAlloc(size_t Alignment, size_t Size, const context &Ctxt, const device &Dev, alloc Kind, const property_list &PropList, const detail::code_location &CodeLoc) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Stash the code location information and propagate - detail::tls_code_loc_t CL(CodeLoc); - XPTIScope PrepareNotify((void *)alignedAlloc, - (uint16_t)xpti::trace_point_type_t::node_create, - SYCL_MEM_ALLOC_STREAM_NAME, "usm::alignedAlloc"); - PrepareNotify.addMetadata([&](auto TEvent) { - xpti::addMetadata(TEvent, "sycl_device_name", - Dev.get_info()); - // Need to determine how to get the device handle reference - // xpti::addMetadata(TEvent, "sycl_device", Dev.getHandleRef())); - xpti::addMetadata(TEvent, "memory_size", Size); - }); - // Notify XPTI about the memset submission - PrepareNotify.notify(); - // Emit a begin/end scope for this call - PrepareNotify.scopedNotify( - (uint16_t)xpti::trace_point_type_t::mem_alloc_begin); -#endif + std::ignore = CodeLoc; void *RetVal = alignedAllocInternal(Alignment, Size, getSyclObjImpl(Ctxt).get(), getSyclObjImpl(Dev).get(), Kind, PropList); -#ifdef XPTI_ENABLE_INSTRUMENTATION - xpti::addMetadata(PrepareNotify.traceEvent(), "memory_ptr", - reinterpret_cast(RetVal)); -#endif return RetVal; } @@ -258,21 +206,7 @@ void freeInternal(void *Ptr, const context_impl *CtxImpl) { void free(void *Ptr, const context &Ctxt, const detail::code_location &CodeLoc) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Stash the code location information and propagate - detail::tls_code_loc_t CL(CodeLoc); - XPTIScope PrepareNotify((void *)free, - (uint16_t)xpti::trace_point_type_t::node_create, - SYCL_MEM_ALLOC_STREAM_NAME, "usm::free"); - PrepareNotify.addMetadata([&](auto TEvent) { - xpti::addMetadata(TEvent, "memory_ptr", reinterpret_cast(Ptr)); - }); - // Notify XPTI about the memset submission - PrepareNotify.notify(); - // Emit a begin/end scope for this call - PrepareNotify.scopedNotify( - (uint16_t)xpti::trace_point_type_t::mem_release_begin); -#endif + std::ignore = CodeLoc; freeInternal(Ptr, detail::getSyclObjImpl(Ctxt).get()); } diff --git a/sycl/source/detail/xpti_registry.cpp b/sycl/source/detail/xpti_registry.cpp deleted file mode 100644 index 78a1c66cb346d..0000000000000 --- a/sycl/source/detail/xpti_registry.cpp +++ /dev/null @@ -1,382 +0,0 @@ -//==---------- xpti_registry.cpp ----- XPTI Stream Registry ----------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include -#include -#include - -#ifdef XPTI_ENABLE_INSTRUMENTATION -#include "xpti/xpti_trace_framework.hpp" -#include -#endif -namespace sycl { -inline namespace _V1 { -namespace detail { -#ifdef XPTI_ENABLE_INSTRUMENTATION -xpti::trace_event_data_t *XPTIRegistry::createTraceEvent( - const void *Obj, const void *FuncPtr, uint64_t &IId, - const detail::code_location &CodeLoc, uint16_t TraceEventType) { - xpti::utils::StringHelper NG; - auto Name = NG.nameWithAddress(CodeLoc.functionName(), - const_cast(FuncPtr)); - xpti::payload_t Payload(Name.c_str(), - (CodeLoc.fileName() ? CodeLoc.fileName() : ""), - CodeLoc.lineNumber(), CodeLoc.columnNumber(), Obj); - - // Calls could be at different user-code locations; We create a new event - // based on the code location info and if this has been seen before, a - // previously created event will be returned. - return xptiMakeEvent(Name.c_str(), &Payload, TraceEventType, xpti_at::active, - &IId); -} -#endif // XPTI_ENABLE_INSTRUMENTATION - -void XPTIRegistry::bufferConstructorNotification( - const void *UserObj, const detail::code_location &CodeLoc, - const void *HostObj, const void *Type, uint32_t Dim, uint32_t ElemSize, - size_t Range[3]) { - (void)UserObj; - (void)CodeLoc; - (void)HostObj; - (void)Type; - (void)Dim; - (void)ElemSize; - (void)Range; -#ifdef XPTI_ENABLE_INSTRUMENTATION - GlobalHandler::instance().getXPTIRegistry().initializeFrameworkOnce(); - constexpr uint16_t NotificationTraceType = - xpti::trace_offload_alloc_memory_object_construct; - if (!xptiCheckTraceEnabled(GBufferStreamID, NotificationTraceType)) - return; - - uint64_t IId; - xpti::offload_buffer_data_t BufConstr{(uintptr_t)UserObj, - (uintptr_t)HostObj, - (const char *)Type, - ElemSize, - Dim, - {Range[0], Range[1], Range[2]}}; - - xpti::trace_event_data_t *TraceEvent = createTraceEvent( - UserObj, "buffer", IId, CodeLoc, xpti::trace_offload_memory_object_event); - xptiNotifySubscribers(GBufferStreamID, NotificationTraceType, nullptr, - TraceEvent, IId, &BufConstr); -#endif -} - -void XPTIRegistry::bufferAssociateNotification(const void *UserObj, - const void *MemObj) { - (void)UserObj; - (void)MemObj; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = - xpti::trace_offload_alloc_memory_object_associate; - if (!xptiCheckTraceEnabled(GBufferStreamID, NotificationTraceType)) - return; - uint64_t IId = xptiGetUniqueId(); - xpti::offload_association_data_t BufAssoc{(uintptr_t)UserObj, - (uintptr_t)MemObj}; - - // Add association between user level and UR level memory object - xptiNotifySubscribers(GBufferStreamID, NotificationTraceType, nullptr, - nullptr, IId, &BufAssoc); -#endif -} - -void XPTIRegistry::bufferReleaseNotification(const void *UserObj, - const void *MemObj) { - (void)UserObj; - (void)MemObj; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = - xpti::trace_offload_alloc_memory_object_release; - if (!xptiCheckTraceEnabled(GBufferStreamID, NotificationTraceType)) - return; - uint64_t IId = xptiGetUniqueId(); - xpti::offload_association_data_t BufRelease{(uintptr_t)UserObj, - (uintptr_t)MemObj}; - - // Release UR level memory object - xptiNotifySubscribers(GBufferStreamID, NotificationTraceType, nullptr, - nullptr, IId, &BufRelease); -#endif -} - -void XPTIRegistry::bufferDestructorNotification(const void *UserObj) { - (void)UserObj; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = - xpti::trace_offload_alloc_memory_object_destruct; - if (!xptiCheckTraceEnabled(GBufferStreamID, NotificationTraceType)) - return; - uint64_t IId = xptiGetUniqueId(); - xpti::offload_buffer_data_t BufDestr{(uintptr_t)UserObj}; - // Destruction of user level memory object - xptiNotifySubscribers(GBufferStreamID, NotificationTraceType, nullptr, - nullptr, IId, &BufDestr); -#endif -} - -void XPTIRegistry::bufferAccessorNotification( - const void *UserObj, const void *AccessorObj, uint32_t Target, - uint32_t Mode, const detail::code_location &CodeLoc) { - (void)UserObj; - (void)AccessorObj; - (void)CodeLoc; - (void)Target; - (void)Mode; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_offload_alloc_accessor; - if (!xptiCheckTraceEnabled(GBufferStreamID, NotificationTraceType)) - return; - - uint64_t IId; - xpti::offload_accessor_data_t AccessorConstr{ - (uintptr_t)UserObj, (uintptr_t)AccessorObj, Target, Mode}; - - xpti::trace_event_data_t *TraceEvent = createTraceEvent( - UserObj, "accessor", IId, CodeLoc, xpti::trace_offload_accessor_event); - xptiNotifySubscribers(GBufferStreamID, NotificationTraceType, nullptr, - TraceEvent, IId, &AccessorConstr); -#endif -} - -void XPTIRegistry::sampledImageConstructorNotification( - const void *UserObj, const detail::code_location &CodeLoc, - const void *HostObj, uint32_t Dim, size_t Range[3], uint32_t ImageFormat, - uint32_t SamplerAddressingMode, uint32_t SamplerCoordinateNormalizationMode, - uint32_t SamplerFilteringMode) { - (void)UserObj; - (void)CodeLoc; - (void)HostObj; - (void)Dim; - (void)Range; - (void)ImageFormat; - (void)SamplerAddressingMode; - (void)SamplerCoordinateNormalizationMode; - (void)SamplerFilteringMode; -#ifdef XPTI_ENABLE_INSTRUMENTATION - GlobalHandler::instance().getXPTIRegistry().initializeFrameworkOnce(); - constexpr uint16_t NotificationTraceType = - xpti::trace_offload_alloc_memory_object_construct; - if (!xptiCheckTraceEnabled(GImageStreamID, NotificationTraceType)) - return; - - uint64_t IId; - xpti::offload_image_data_t ImgConstr{(uintptr_t)UserObj, - (uintptr_t)HostObj, - Dim, - {Range[0], Range[1], Range[2]}, - ImageFormat, - SamplerAddressingMode, - SamplerCoordinateNormalizationMode, - SamplerFilteringMode}; - - xpti::trace_event_data_t *TraceEvent = - createTraceEvent(UserObj, "sampled_image", IId, CodeLoc, - xpti::trace_offload_memory_object_event); - xptiNotifySubscribers(GImageStreamID, NotificationTraceType, nullptr, - TraceEvent, IId, &ImgConstr); -#endif -} - -void XPTIRegistry::sampledImageDestructorNotification(const void *UserObj) { - (void)UserObj; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = - xpti::trace_offload_alloc_memory_object_destruct; - if (!xptiCheckTraceEnabled(GImageStreamID, NotificationTraceType)) - return; - uint64_t IId = xptiGetUniqueId(); - xpti::offload_image_data_t ImgDestr{(uintptr_t)UserObj}; - // Destruction of user level memory object - xptiNotifySubscribers(GImageStreamID, NotificationTraceType, nullptr, nullptr, - IId, &ImgDestr); -#endif -} - -void XPTIRegistry::unsampledImageConstructorNotification( - const void *UserObj, const detail::code_location &CodeLoc, - const void *HostObj, uint32_t Dim, size_t Range[3], uint32_t ImageFormat) { - (void)UserObj; - (void)CodeLoc; - (void)HostObj; - (void)Dim; - (void)Range; - (void)ImageFormat; -#ifdef XPTI_ENABLE_INSTRUMENTATION - GlobalHandler::instance().getXPTIRegistry().initializeFrameworkOnce(); - constexpr uint16_t NotificationTraceType = - xpti::trace_offload_alloc_memory_object_construct; - if (!xptiCheckTraceEnabled(GImageStreamID, NotificationTraceType)) - return; - - uint64_t IId; - xpti::offload_image_data_t ImgConstr{(uintptr_t)UserObj, - (uintptr_t)HostObj, - Dim, - {Range[0], Range[1], Range[2]}, - ImageFormat, - // No sampler information - std::nullopt, - std::nullopt, - std::nullopt}; - - xpti::trace_event_data_t *TraceEvent = - createTraceEvent(UserObj, "unsampled_image", IId, CodeLoc, - xpti::trace_offload_memory_object_event); - xptiNotifySubscribers(GImageStreamID, NotificationTraceType, nullptr, - TraceEvent, IId, &ImgConstr); -#endif -} - -void XPTIRegistry::unsampledImageDestructorNotification(const void *UserObj) { - (void)UserObj; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = - xpti::trace_offload_alloc_memory_object_destruct; - if (!xptiCheckTraceEnabled(GImageStreamID, NotificationTraceType)) - return; - uint64_t IId = xptiGetUniqueId(); - xpti::offload_image_data_t ImgDestr{(uintptr_t)UserObj}; - // Destruction of user level memory object - xptiNotifySubscribers(GImageStreamID, NotificationTraceType, nullptr, nullptr, - IId, &ImgDestr); -#endif -} - -void XPTIRegistry::unsampledImageAccessorNotification( - const void *UserObj, const void *AccessorObj, uint32_t Target, - uint32_t Mode, const void *Type, uint32_t ElemSize, - const detail::code_location &CodeLoc) { - (void)UserObj; - (void)AccessorObj; - (void)CodeLoc; - (void)Target; - (void)Mode; - (void)Type; - (void)ElemSize; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_offload_alloc_accessor; - if (!xptiCheckTraceEnabled(GImageStreamID, NotificationTraceType)) - return; - - uint64_t IId; - xpti::offload_image_accessor_data_t AccessorConstr{(uintptr_t)UserObj, - (uintptr_t)AccessorObj, - Target, - Mode, - (const char *)Type, - ElemSize}; - - xpti::trace_event_data_t *TraceEvent = - createTraceEvent(UserObj, "unsampled_image_accessor", IId, CodeLoc, - xpti::trace_offload_accessor_event); - xptiNotifySubscribers(GImageStreamID, NotificationTraceType, nullptr, - TraceEvent, IId, &AccessorConstr); -#endif -} - -void XPTIRegistry::unsampledImageHostAccessorNotification( - const void *UserObj, const void *AccessorObj, uint32_t Mode, - const void *Type, uint32_t ElemSize, const detail::code_location &CodeLoc) { - (void)UserObj; - (void)AccessorObj; - (void)CodeLoc; - (void)Mode; - (void)Type; - (void)ElemSize; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_offload_alloc_accessor; - if (!xptiCheckTraceEnabled(GImageStreamID, NotificationTraceType)) - return; - - uint64_t IId; - xpti::offload_image_accessor_data_t AccessorConstr{ - (uintptr_t)UserObj, (uintptr_t)AccessorObj, - std::nullopt, Mode, - (const char *)Type, ElemSize}; - - xpti::trace_event_data_t *TraceEvent = - createTraceEvent(UserObj, "host_unsampled_image_accessor", IId, CodeLoc, - xpti::trace_offload_accessor_event); - xptiNotifySubscribers(GImageStreamID, NotificationTraceType, nullptr, - TraceEvent, IId, &AccessorConstr); -#endif -} - -void XPTIRegistry::sampledImageAccessorNotification( - const void *UserObj, const void *AccessorObj, uint32_t Target, - const void *Type, uint32_t ElemSize, const detail::code_location &CodeLoc) { - (void)UserObj; - (void)AccessorObj; - (void)CodeLoc; - (void)Target; - (void)Type; - (void)ElemSize; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_offload_alloc_accessor; - if (!xptiCheckTraceEnabled(GImageStreamID, NotificationTraceType)) - return; - - uint64_t IId; - xpti::offload_image_accessor_data_t AccessorConstr{ - (uintptr_t)UserObj, (uintptr_t)AccessorObj, Target, - std::nullopt, (const char *)Type, ElemSize}; - - xpti::trace_event_data_t *TraceEvent = - createTraceEvent(UserObj, "sampled_image_accessor", IId, CodeLoc, - xpti::trace_offload_accessor_event); - xptiNotifySubscribers(GImageStreamID, NotificationTraceType, nullptr, - TraceEvent, IId, &AccessorConstr); -#endif -} - -void XPTIRegistry::sampledImageHostAccessorNotification( - const void *UserObj, const void *AccessorObj, const void *Type, - uint32_t ElemSize, const detail::code_location &CodeLoc) { - (void)UserObj; - (void)AccessorObj; - (void)CodeLoc; - (void)Type; - (void)ElemSize; -#ifdef XPTI_ENABLE_INSTRUMENTATION - constexpr uint16_t NotificationTraceType = xpti::trace_offload_alloc_accessor; - if (!xptiCheckTraceEnabled(GImageStreamID, NotificationTraceType)) - return; - - uint64_t IId; - xpti::offload_image_accessor_data_t AccessorConstr{ - (uintptr_t)UserObj, (uintptr_t)AccessorObj, std::nullopt, - std::nullopt, (const char *)Type, ElemSize}; - - xpti::trace_event_data_t *TraceEvent = - createTraceEvent(UserObj, "host_sampled_image_accessor", IId, CodeLoc, - xpti::trace_offload_accessor_event); - xptiNotifySubscribers(GImageStreamID, NotificationTraceType, nullptr, - TraceEvent, IId, &AccessorConstr); -#endif -} - -std::string queueDeviceToString(const queue_impl *const &Queue) { - if (!Queue) - return "HOST"; - auto Device = Queue->get_device(); - if (Device.is_cpu()) - return "CPU"; - else if (Device.is_gpu()) - return "GPU"; - else if (Device.is_accelerator()) - return "ACCELERATOR"; - else - return "UNKNOWN"; -} - -} // namespace detail -} // namespace _V1 -} // namespace sycl diff --git a/sycl/source/detail/xpti_registry.hpp b/sycl/source/detail/xpti_registry.hpp deleted file mode 100644 index c9b72a22ed626..0000000000000 --- a/sycl/source/detail/xpti_registry.hpp +++ /dev/null @@ -1,322 +0,0 @@ -//==---------- xpti_registry.hpp ----- XPTI Stream Registry ----------------==// -// -// 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 -#include -#include - -#include -#include - -#ifdef XPTI_ENABLE_INSTRUMENTATION -// Include the headers necessary for emitting -// traces using the trace framework -#include "xpti/xpti_trace_framework.hpp" -#endif - -namespace sycl { -inline namespace _V1 { -namespace detail { -// We define a sycl stream name and this will be used by the instrumentation -// framework -inline constexpr const char *SYCL_STREAM_NAME = "sycl"; -inline constexpr auto SYCL_MEM_ALLOC_STREAM_NAME = - "sycl.experimental.mem_alloc"; - -#ifdef XPTI_ENABLE_INSTRUMENTATION -extern uint8_t GBufferStreamID; -extern uint8_t GImageStreamID; -extern uint8_t GMemAllocStreamID; -extern xpti::trace_event_data_t *GMemAllocEvent; -extern xpti::trace_event_data_t *GSYCLGraphEvent; - -// We will pick a global constant so that the pointer in TLS never goes stale -inline constexpr auto XPTI_QUEUE_INSTANCE_ID_KEY = "queue_id"; - -#define STR(x) #x -#define SYCL_VERSION_STR \ - "sycl " STR(__LIBSYCL_MAJOR_VERSION) "." STR(__LIBSYCL_MINOR_VERSION) - -/// Constants being used as placeholder until one is able to reliably get the -/// version of the SYCL runtime -constexpr uint32_t GMajVer = __LIBSYCL_MAJOR_VERSION; -constexpr uint32_t GMinVer = __LIBSYCL_MINOR_VERSION; -constexpr const char *GVerStr = SYCL_VERSION_STR; -#endif - -// Stream name being used to notify about buffer objects. -inline constexpr const char *SYCL_BUFFER_STREAM_NAME = - "sycl.experimental.buffer"; - -// Stream name being used to notify about image objects. -inline constexpr const char *SYCL_IMAGE_STREAM_NAME = "sycl.experimental.image"; - -class XPTIRegistry { -public: - void initializeFrameworkOnce() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - std::call_once(MInitialized, [this] { - xptiFrameworkInitialize(); - // SYCL buffer events - GBufferStreamID = xptiRegisterStream(SYCL_BUFFER_STREAM_NAME); - this->initializeStream(SYCL_BUFFER_STREAM_NAME, 0, 1, "0.1"); - // SYCL image events - GImageStreamID = xptiRegisterStream(SYCL_IMAGE_STREAM_NAME); - this->initializeStream(SYCL_IMAGE_STREAM_NAME, 0, 1, "0.1"); - - // Memory allocation events - GMemAllocStreamID = xptiRegisterStream(SYCL_MEM_ALLOC_STREAM_NAME); - this->initializeStream(SYCL_MEM_ALLOC_STREAM_NAME, 0, 1, "0.1"); - xpti::payload_t MAPayload("SYCL Memory Allocations Layer"); - uint64_t MAInstanceNo = 0; - GMemAllocEvent = xptiMakeEvent("SYCL Memory Allocations", &MAPayload, - xpti::trace_algorithm_event, - xpti_at::active, &MAInstanceNo); - }); -#endif - } - - /// Notifies XPTI subscribers about new stream. - /// - /// \param StreamName is a name of newly initialized stream. - /// \param MajVer is a stream major version. - /// \param MinVer is a stream minor version. - /// \param VerStr is a string of "MajVer.MinVer" format. - void initializeStream(const std::string &StreamName, uint32_t MajVer, - uint32_t MinVer, const std::string &VerStr) { -#ifdef XPTI_ENABLE_INSTRUMENTATION - MActiveStreams.insert(StreamName); - xptiInitialize(StreamName.c_str(), MajVer, MinVer, VerStr.c_str()); -#endif // XPTI_ENABLE_INSTRUMENTATION - } - - ~XPTIRegistry() { -#ifdef XPTI_ENABLE_INSTRUMENTATION - for (const auto &StreamName : MActiveStreams) { - xptiFinalize(StreamName.c_str()); - } - xptiFrameworkFinalize(); -#endif // XPTI_ENABLE_INSTRUMENTATION - } - - static void bufferConstructorNotification(const void *, - const detail::code_location &, - const void *, const void *, - uint32_t, uint32_t, size_t[3]); - static void bufferAssociateNotification(const void *, const void *); - static void bufferReleaseNotification(const void *, const void *); - static void bufferDestructorNotification(const void *); - static void bufferAccessorNotification(const void *, const void *, uint32_t, - uint32_t, - const detail::code_location &); - - static void sampledImageConstructorNotification(const void *, - const detail::code_location &, - const void *, uint32_t, - size_t[3], uint32_t, uint32_t, - uint32_t, uint32_t); - static void sampledImageDestructorNotification(const void *); - - static void unsampledImageConstructorNotification( - const void *, const detail::code_location &, const void *, uint32_t, - size_t[3], uint32_t); - static void unsampledImageDestructorNotification(const void *); - - static void unsampledImageAccessorNotification(const void *, const void *, - uint32_t, uint32_t, - const void *, uint32_t, - const detail::code_location &); - static void - unsampledImageHostAccessorNotification(const void *, const void *, uint32_t, - const void *, uint32_t, - const detail::code_location &); - static void sampledImageAccessorNotification(const void *, const void *, - uint32_t, const void *, uint32_t, - const detail::code_location &); - static void - sampledImageHostAccessorNotification(const void *, const void *, const void *, - uint32_t, const detail::code_location &); - -private: - std::unordered_set MActiveStreams; - std::once_flag MInitialized; - -#ifdef XPTI_ENABLE_INSTRUMENTATION - static xpti::trace_event_data_t * - createTraceEvent(const void *Obj, const void *ObjName, uint64_t &IId, - const detail::code_location &CodeLoc, - uint16_t TraceEventType); -#endif // XPTI_ENABLE_INSTRUMENTATION -}; - -/// @brief Helper class to enable XPTI implementation -/// @details This class simplifies the instrumentation and encapsulates the -/// verbose call sequences -#if XPTI_ENABLE_INSTRUMENTATION -class XPTIScope { -public: - using TracePoint = xpti::framework::tracepoint_t; - /// @brief Scoped class for XPTI instrumentation using TLS data - /// @param CodePtr The address of the class/function to help differentiate - /// actions in case the code location information is not available - /// @param TraceType The type of trace event being created - /// @param StreamName The stream which will emit these notifications - /// @param InstanceID The instance ID associated with an object, otherwise 0 - /// will auto-generate - /// @param UserData String value that provides metadata about the - /// instrumentation - XPTIScope(void *CodePtr, uint16_t TraceType, const char *StreamName, - uint64_t InstanceID, const char *UserData) - : MUserData(UserData), MStreamID(0), MInstanceID(InstanceID), - MScopedNotify(false), MTraceType(0) { - detail::tls_code_loc_t Tls; - auto TData = Tls.query(); - // If TLS is not set, we can still genertate universal IDs with user data - // and CodePtr information - const char *FuncName = TData.functionName(); - if (!TData.functionName() && !TData.fileName()) - FuncName = UserData; - // Create a tracepoint object that has a lifetime of this class - MTP = new TracePoint(TData.fileName(), FuncName, TData.lineNumber(), - TData.columnNumber(), CodePtr); - if (TraceType == (uint16_t)xpti::trace_point_type_t::graph_create || - TraceType == (uint16_t)xpti::trace_point_type_t::node_create || - TraceType == (uint16_t)xpti::trace_point_type_t::edge_create || - TraceType == (uint16_t)xpti::trace_point_type_t::queue_create) - MTP->parent_event(GSYCLGraphEvent); - // Now if tracing is enabled, create trace events and notify - if (xptiTraceEnabled() && MTP) { - MTP->stream(StreamName).trace_type((xpti::trace_point_type_t)TraceType); - MTraceEvent = const_cast(MTP->trace_event()); - MStreamID = MTP->stream_id(); - // This constructor uses a manual override for the instance ID as some - // objects such as queues keep track of instance IDs - MTP->override_instance_id(MInstanceID); - } - } - - /// @brief Scoped class for XPTI instrumentation using TLS data - /// @param CodePtr The address of the class/function to help differentiate - /// actions in case the code location information is not available - /// @param TraceType The type of trace event being created - /// @param StreamName The stream which will emit these notifications - /// @param UserData String value that provides metadata about the - /// instrumentation - XPTIScope(void *CodePtr, uint16_t TraceType, const char *StreamName, - const char *UserData) - : MUserData(UserData), MStreamID(0), MInstanceID(0), MScopedNotify(false), - MTraceType(0) { - detail::tls_code_loc_t Tls; - auto TData = Tls.query(); - // If TLS is not set, we can still genertate universal IDs with user data - // and CodePtr information - const char *FuncName = TData.functionName(); - if (!TData.functionName() && !TData.fileName()) - FuncName = UserData; - // Create a tracepoint object that has a lifetime of this class - MTP = new TracePoint(TData.fileName(), FuncName, TData.lineNumber(), - TData.columnNumber(), CodePtr); - if (TraceType == (uint16_t)xpti::trace_point_type_t::graph_create || - TraceType == (uint16_t)xpti::trace_point_type_t::node_create || - TraceType == (uint16_t)xpti::trace_point_type_t::edge_create || - TraceType == (uint16_t)xpti::trace_point_type_t::queue_create) - MTP->parent_event(GSYCLGraphEvent); - // Now if tracing is enabled, create trace events and notify - if (xptiTraceEnabled() && MTP) { - MTP->stream(StreamName).trace_type((xpti::trace_point_type_t)TraceType); - MTraceEvent = const_cast(MTP->trace_event()); - MStreamID = MTP->stream_id(); - MInstanceID = MTP->instance_id(); - } - } - - XPTIScope(const XPTIScope &rhs) = delete; - - XPTIScope &operator=(const XPTIScope &rhs) = delete; - - xpti::trace_event_data_t *traceEvent() { return MTraceEvent; } - - uint8_t streamID() { return MStreamID; } - - uint64_t instanceID() { return MTP ? MTP->instance_id() : 0; } - - XPTIScope & - addMetadata(const std::function &Callback) { - if (xptiTraceEnabled() && MTP) { - auto TEvent = const_cast(MTP->trace_event()); - Callback(TEvent); - } - return *this; - } - - XPTIScope ¬ify() { - MTP->notify(static_cast(MUserData)); - return *this; - } - - /// @brief Method that emits begin/end trace notifications - /// @return Current class - XPTIScope &scopedNotify(uint16_t TraceType) { - // Keep this data even if no subscribers are for this TraceType (begin). - // Someone could still use (end) emitted from destructor. - MTraceType = TraceType & 0xfffe; - MScopedNotify = true; - if (xptiCheckTraceEnabled(MStreamID, TraceType) && MTP) { - xptiNotifySubscribers(MStreamID, MTraceType, nullptr, MTraceEvent, - MInstanceID, static_cast(MUserData)); - } - return *this; - } - ~XPTIScope() { - MTraceType = MTraceType | 1; - if (xptiCheckTraceEnabled(MStreamID, MTraceType) && MTP && MScopedNotify) { - if (MTraceType == (uint16_t)xpti::trace_point_type_t::signal || - MTraceType == (uint16_t)xpti::trace_point_type_t::graph_create || - MTraceType == (uint16_t)xpti::trace_point_type_t::node_create || - MTraceType == (uint16_t)xpti::trace_point_type_t::edge_create || - MTraceType == (uint16_t)xpti::trace_point_type_t::queue_create || - MTraceType == (uint16_t)xpti::trace_point_type_t::queue_destroy || - MTraceType == (uint16_t)xpti::trace_point_type_t::diagnostics) - return; - - // Only notify for a trace type that has a begin/end - xptiNotifySubscribers(MStreamID, MTraceType, nullptr, MTraceEvent, - MInstanceID, static_cast(MUserData)); - } - // Delete the tracepoint object which will clear TLS if it is the top of - // the scope - delete MTP; - } - -private: - // Tracepoint_t object who's lifetime is that of the class - TracePoint *MTP = nullptr; - // Trace event created from the TLS data, if it exists - xpti::trace_event_data_t *MTraceEvent = nullptr; - // The const string that indicates the operation - const char *MUserData = nullptr; - // The stream on which the notifications occur - uint8_t MStreamID; - // The instance ID for the trace event; if it is called in a loop, then the - // trace event ID will remain the same, but the instance ID will increment - uint64_t MInstanceID; - // If scoped notifcation is requested, this tracks the request - bool MScopedNotify; - // The trace type information for scoped notifications - uint16_t MTraceType; -}; // class XPTIScope -#endif - -class queue_impl; -std::string queueDeviceToString(const detail::queue_impl *const &Queue); - -} // namespace detail -} // namespace _V1 -} // namespace sycl diff --git a/sycl/source/exception.cpp b/sycl/source/exception.cpp index 06d1d30ffad14..6f76bb0004220 100644 --- a/sycl/source/exception.cpp +++ b/sycl/source/exception.cpp @@ -34,9 +34,7 @@ exception::exception(int EV, const std::error_category &ECat) exception::exception(std::error_code EC, std::shared_ptr SharedPtrCtx, const char *WhatArg) : MMsg(std::make_shared(WhatArg)), - MErr(UR_RESULT_ERROR_INVALID_VALUE), MContext(SharedPtrCtx), MErrC(EC) { - detail::GlobalHandler::instance().TraceEventXPTI(MMsg->c_str()); -} + MErr(UR_RESULT_ERROR_INVALID_VALUE), MContext(SharedPtrCtx), MErrC(EC) {} exception::~exception() {} diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 19d0fe95706cf..f83df87f8f96b 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -265,21 +265,7 @@ event handler::finalize() { detail::Command::getUrEvents(impl->CGData.MEvents, MQueue, false); detail::EventImplPtr NewEvent; -#ifdef XPTI_ENABLE_INSTRUMENTATION - // uint32_t StreamID, uint64_t InstanceID, xpti_td* TraceEvent, - int32_t StreamID = xptiRegisterStream(detail::SYCL_STREAM_NAME); - auto [CmdTraceEvent, InstanceID] = emitKernelInstrumentationData( - StreamID, MKernel, MCodeLoc, impl->MIsTopCodeLoc, MKernelName.c_str(), - MQueue, impl->MNDRDesc, KernelBundleImpPtr, impl->MArgs); - auto EnqueueKernel = [&, CmdTraceEvent = CmdTraceEvent, - InstanceID = InstanceID]() { -#else auto EnqueueKernel = [&]() { -#endif -#ifdef XPTI_ENABLE_INSTRUMENTATION - detail::emitInstrumentationGeneral(StreamID, InstanceID, CmdTraceEvent, - xpti::trace_task_begin, nullptr); -#endif const detail::RTDeviceBinaryImage *BinImage = nullptr; if (detail::SYCLConfig::get()) { std::tie(BinImage, std::ignore) = @@ -292,16 +278,6 @@ event handler::finalize() { impl->MKernelIsCooperative, impl->MKernelUsesClusterLaunch, impl->MKernelWorkGroupMemorySize, BinImage); -#ifdef XPTI_ENABLE_INSTRUMENTATION - // Emit signal only when event is created - if (NewEvent != nullptr) { - detail::emitInstrumentationGeneral( - StreamID, InstanceID, CmdTraceEvent, xpti::trace_signal, - static_cast(NewEvent->getHandle())); - } - detail::emitInstrumentationGeneral(StreamID, InstanceID, CmdTraceEvent, - xpti::trace_task_end, nullptr); -#endif }; bool DiscardEvent = (MQueue->MDiscardEvents || !impl->MEventNeeded) && @@ -508,7 +484,6 @@ event handler::finalize() { "Internal Error. Command group cannot be constructed."); // Propagate MIsTopCodeLoc state to CommandGroup. - // Will be used for XPTI payload generation for CG's related events. CommandGroup->MIsTopCodeLoc = impl->MIsTopCodeLoc; // If there is a graph associated with the handler we are in the explicit diff --git a/sycl/source/image.cpp b/sycl/source/image.cpp index 511d816e5d31f..7fbd166345f50 100644 --- a/sycl/source/image.cpp +++ b/sycl/source/image.cpp @@ -184,29 +184,6 @@ image_channel_type image_plain::getChannelType() const { return impl->getChannelType(); } -void image_plain::sampledImageConstructorNotification( - const detail::code_location &CodeLoc, void *UserObj, const void *HostObj, - uint32_t Dim, size_t Range[3], image_format Format, - const image_sampler &Sampler) { - impl->sampledImageConstructorNotification(CodeLoc, UserObj, HostObj, Dim, - Range, Format, Sampler); -} - -void image_plain::sampledImageDestructorNotification(void *UserObj) { - impl->sampledImageDestructorNotification(UserObj); -} - -void image_plain::unsampledImageConstructorNotification( - const detail::code_location &CodeLoc, void *UserObj, const void *HostObj, - uint32_t Dim, size_t Range[3], image_format Format) { - impl->unsampledImageConstructorNotification(CodeLoc, UserObj, HostObj, Dim, - Range, Format); -} - -void image_plain::unsampledImageDestructorNotification(void *UserObj) { - impl->unsampledImageDestructorNotification(UserObj); -} - const property_list &image_plain::getPropList() const { return impl->getPropList(); } diff --git a/sycl/test-e2e/Tracing/code_location_queue_copy.cpp b/sycl/test-e2e/Tracing/code_location_queue_copy.cpp deleted file mode 100644 index ffc9964dc18d6..0000000000000 --- a/sycl/test-e2e/Tracing/code_location_queue_copy.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// REQUIRES: cpu -// UNSUPPORTED: windows -// RUN: %{build} -o %t.out -// RUN: %{run} sycl-trace --sycl %t.out | FileCheck %s - -// Test tracing of the code location data for queue.copy in case of failure -// (exception generation) - -#include -#include - -int main() { - sycl::queue Q; - bool ExceptionCaught = false; - unsigned char *HostAllocSrc = (unsigned char *)sycl::malloc_host(1, Q); - unsigned char *HostAllocDst = NULL; - try { -// CHECK: code_location_queue_copy.cpp:[[# @LINE + 1 ]] main - Q.copy(HostAllocDst, HostAllocSrc, 1); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - sycl::free(HostAllocSrc, Q); - - return !ExceptionCaught; -} diff --git a/sycl/test-e2e/Tracing/code_location_queue_parallel_for.cpp b/sycl/test-e2e/Tracing/code_location_queue_parallel_for.cpp deleted file mode 100644 index 17921cb2cf378..0000000000000 --- a/sycl/test-e2e/Tracing/code_location_queue_parallel_for.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// REQUIRES: cpu -// UNSUPPORTED: windows -// RUN: %{build} -o %t.out -// RUN: %{run} sycl-trace --sycl %t.out | FileCheck %s - -// Test tracing of the code location data for queue.parallel_for in case of -// failure (exception generation) - -#include - -int main() { - sycl::queue Queue; - sycl::device Dev = Queue.get_device(); - sycl::range<1> MaxWISizes = - Dev.get_info>(); - bool ExceptionCaught = false; - try { - // CHECK: code_location_queue_parallel_for.cpp:[[# @LINE + 3 ]] E2ETestKernel - Queue.parallel_for( - sycl::nd_range<1>{MaxWISizes.get(0), 2 * MaxWISizes.get(0)}, - [](sycl::nd_item<1>) {}); - } catch (...) { - ExceptionCaught = true; - } - Queue.wait(); - return !ExceptionCaught; -} diff --git a/sycl/test-e2e/Tracing/code_location_queue_submit.cpp b/sycl/test-e2e/Tracing/code_location_queue_submit.cpp deleted file mode 100644 index eeb7a270ecf54..0000000000000 --- a/sycl/test-e2e/Tracing/code_location_queue_submit.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// REQUIRES: cpu -// UNSUPPORTED: windows -// RUN: %{build} -o %t.out -// RUN: %{run} sycl-trace --sycl --print-format=verbose %t.out | FileCheck %s - -// Test tracing of the code location data for queue.submit in case of failure -// (exception generation) -// First queue creation (id = 0) is queue created on line 17. - -#include -#include - -int main() { - bool ExceptionCaught = false; - { - sycl::queue Q; - unsigned char *HostAllocSrc = (unsigned char *)sycl::malloc_host(1, Q); - unsigned char *HostAllocDst = NULL; - // CHECK: [SYCL] Queue create: - // CHECK-DAG: queue_handle : {{.*}} - // CHECK-DAG: queue_id : 1 - // CHECK-DAG: is_inorder : false - // CHECK-DAG: sycl_device : {{.*}} - // CHECK-DAG: sycl_device_name : {{.*}} - // CHECK-DAG: sycl_context : {{.*}} - // CHECK: [SYCL] Runtime reports: - // CHECK-NEXT: what: NULL pointer argument in memory copy operation. - // CHECK-NEXT: where:{{.*}}code_location_queue_submit.cpp:[[# @LINE + 2 ]] main - try { - Q.submit( - [&](sycl::handler &cgh) { cgh.copy(HostAllocDst, HostAllocSrc, 1); }); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - sycl::free(HostAllocSrc, Q); - } - // CHECK: [SYCL] Queue destroy: - // CHECK-DAG: queue_id : 1 - return !ExceptionCaught; -} diff --git a/sycl/test-e2e/Tracing/task_execution.cpp b/sycl/test-e2e/Tracing/task_execution.cpp deleted file mode 100644 index b4932df0eda55..0000000000000 --- a/sycl/test-e2e/Tracing/task_execution.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// REQUIRES: cpu -// UNSUPPORTED: windows -// RUN: %{build} -o %t.out -// RUN: %{run} sycl-trace --sycl --print-format=verbose %t.out | FileCheck %s - -#include -#include - -int main() { - { - sycl::queue Q; - unsigned char *AllocSrc = (unsigned char *)sycl::malloc_device(1, Q); - unsigned char *AllocDst = (unsigned char *)sycl::malloc_device(1, Q); - Q.memset(AllocSrc, 0, 1).wait(); - Q.copy(AllocDst, AllocSrc, 1).wait(); - // CHECK: [SYCL] Queue create: - // CHECK-DAG: queue_handle : {{.*}} - // CHECK-DAG: queue_id : 1 - // CHECK-DAG: is_inorder : false - // CHECK-DAG: sycl_device : {{.*}} - // CHECK-DAG: sycl_device_name : {{.*}} - // CHECK-DAG: sycl_context : {{.*}} - // CHECK-NEXT: [SYCL] Task begin (event={{.*}},instanceID={{.*}}) - // CHECK-DAG: queue_id : 1 - // CHECK-DAG: memory_size : 1 - // CHECK-DAG: value_set : 0 - // CHECK-DAG: memory_ptr : {{.*}} - // CHECK-DAG: sycl_device : {{.*}} - // CHECK-NEXT: [SYCL] Task end (event={{.*}},instanceID={{.*}}) - // CHECK-NEXT: [SYCL] Task begin (event={{.*}},instanceID={{.*}}) - // CHECK-DAG: queue_id : 1 - // CHECK-DAG: memory_size : 1 - // CHECK-DAG: dest_memory_ptr : {{.*}} - // CHECK-DAG: src_memory_ptr : {{.*}} - // CHECK-DAG: sycl_device : {{.*}} - // CHECK-NEXT: [SYCL] Task end (event={{.*}},instanceID={{.*}}) - Q.single_task([]() {}).wait(); - // CHECK-NEXT: [SYCL] Task begin (event={{.*}},instanceID={{.*}}) - // CHECK-DAG: enqueue_kernel_data : {{.*}} - // CHECK-DAG: sym_column_no : {{.*}} - // CHECK-DAG: sym_line_no : 37 - // CHECK-DAG: sym_source_file_name : {{.*}}task_execution.cpp - // CHECK-DAG: queue_id : 1 - // CHECK-DAG: sym_function_name : typeinfo name for main::E2ETestKernel - // CHECK-DAG: from_source : {{.*}} - // CHECK-DAG: sycl_device_name : {{.*}} - // CHECK-DAG: sycl_device_type : {{.*}} - // CHECK-DAG: kernel_name : typeinfo name for main::E2ETestKernel - // CHECK-DAG: sycl_device : {{.*}} - // CHECK-NEXT: [SYCL] Task end (event={{.*}},instanceID={{.*}}) - // CHECK-NEXT: [SYCL] Queue destroy: - // CHECK-DAG: queue_id : 1 - sycl::free(AllocSrc, Q); - sycl::free(AllocDst, Q); - } - return 0; -} diff --git a/sycl/test-e2e/Tracing/task_execution_handler.cpp b/sycl/test-e2e/Tracing/task_execution_handler.cpp deleted file mode 100644 index a208fe6655bda..0000000000000 --- a/sycl/test-e2e/Tracing/task_execution_handler.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// REQUIRES: cpu -// UNSUPPORTED: windows -// RUN: %{build} -o %t.out -// RUN: %{run} sycl-trace --sycl --print-format=verbose %t.out | FileCheck %s - -#include -#include - -int main() { - { - sycl::queue Q; - unsigned char *AllocSrc = (unsigned char *)sycl::malloc_device(1, Q); - unsigned char *AllocDst = (unsigned char *)sycl::malloc_device(1, Q); - Q.submit([&](sycl::handler &cgh) - - { cgh.memset(AllocSrc, 0, 1); }) - .wait(); - // CHECK: [SYCL] Task begin (event={{.*}},instanceID={{.*}}) - // CHECK-DAG: queue_id : 1 - // CHECK-DAG: sym_column_no : {{.*}} - // CHECK-DAG: sym_function_name : {{.*}} - // CHECK-DAG: kernel_name : {{.*}} - // CHECK-DAG: sym_source_file_name : {{.*}}task_execution_handler.cpp - // CHECK-DAG: sycl_device_name : {{.*}} - // CHECK-DAG: sycl_device_type : {{.*}} - // CHECK-DAG: sym_line_no : {{.*}} - // CHECK-DAG: sycl_device : {{.*}} - // CHECK-NEXT: [SYCL] Task end (event={{.*}},instanceID={{.*}}) - // CHECK-NEXT: [SYCL] Task begin (event={{.*}},instanceID={{.*}}) - // CHECK-DAG: queue_id : 1 - // CHECK-DAG: sym_column_no : {{.*}} - // CHECK-DAG: sym_function_name : {{.*}} - // CHECK-DAG: kernel_name : {{.*}} - // CHECK-DAG: sym_source_file_name : {{.*}}task_execution_handler.cpp - // CHECK-DAG: sycl_device_name : {{.*}} - // CHECK-DAG: sycl_device_type : {{.*}} - // CHECK-DAG: sym_line_no : {{.*}} - // CHECK-DAG: sycl_device : {{.*}} - // CHECK-NEXT: [SYCL] Task end (event={{.*}},instanceID={{.*}}) - Q.submit([&](sycl::handler &cgh) - - { cgh.memcpy(AllocDst, AllocSrc, 1); }) - .wait(); - sycl::free(AllocSrc, Q); - sycl::free(AllocDst, Q); - } - return 0; -} diff --git a/sycl/test-e2e/XPTI/Inputs/memory_info_collector.cpp b/sycl/test-e2e/XPTI/Inputs/memory_info_collector.cpp deleted file mode 100644 index a2dd139d112a6..0000000000000 --- a/sycl/test-e2e/XPTI/Inputs/memory_info_collector.cpp +++ /dev/null @@ -1,333 +0,0 @@ -#include "xpti/xpti_trace_framework.hpp" - -#include -#include -#include -#include - -std::mutex GMutex; - -XPTI_CALLBACK_API void syclCallback(uint16_t, xpti::trace_event_data_t *, - xpti::trace_event_data_t *, uint64_t, - const void *); - -XPTI_CALLBACK_API void memCallback(uint16_t, xpti::trace_event_data_t *, - xpti::trace_event_data_t *, uint64_t, - const void *); - -XPTI_CALLBACK_API void syclBufferCallback(uint16_t, xpti::trace_event_data_t *, - xpti::trace_event_data_t *, uint64_t, - const void *); - -XPTI_CALLBACK_API void syclImageCallback(uint16_t, xpti::trace_event_data_t *, - xpti::trace_event_data_t *, uint64_t, - const void *); - -XPTI_CALLBACK_API void xptiTraceInit(unsigned int MajorVersion, - unsigned int MinorVersion, - const char *VersionStr, - const char *StreamName) { - std::cout << "xptiTraceInit: Stream Name = " << StreamName << "\n"; - std::string_view NameView{StreamName}; - - using type = xpti::trace_point_type_t; - if (NameView == "sycl.experimental.mem_alloc") { - uint8_t StreamID = xptiRegisterStream(StreamName); - for (type t : std::initializer_list{ - type::mem_alloc_begin, type::mem_alloc_end, - type::mem_release_begin, type::mem_release_end}) - xptiRegisterCallback(StreamID, static_cast(t), memCallback); - } - - auto buffer_image_traces = std::initializer_list{ - type::offload_alloc_memory_object_construct, - type::offload_alloc_memory_object_associate, - type::offload_alloc_memory_object_release, - type::offload_alloc_memory_object_destruct, type::offload_alloc_accessor}; - if (NameView == "sycl.experimental.buffer") { - uint8_t StreamID = xptiRegisterStream(StreamName); - for (type t : buffer_image_traces) - xptiRegisterCallback(StreamID, static_cast(t), - syclBufferCallback); - } - if (NameView == "sycl.experimental.image") { - uint8_t StreamID = xptiRegisterStream(StreamName); - for (type t : buffer_image_traces) - xptiRegisterCallback(StreamID, static_cast(t), - syclImageCallback); - } - if (NameView == "sycl") { - uint8_t StreamID = xptiRegisterStream(StreamName); - for (type t : std::initializer_list{ - type::graph_create, type::node_create, type::edge_create, - type::task_begin, type::task_end, type::signal, type::wait_begin, - type::wait_end, type::barrier_begin, type::barrier_end, - type::diagnostics}) - xptiRegisterCallback(StreamID, static_cast(t), syclCallback); - } -} - -XPTI_CALLBACK_API void xptiTraceFinish(const char *streamName) { - std::cout << "xptiTraceFinish: Stream Name = " << streamName << "\n"; -} - -XPTI_CALLBACK_API void memCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *, uint64_t, - const void *UserData) { - std::lock_guard Lock{GMutex}; - auto Type = static_cast(TraceType); - auto *Data = static_cast(UserData); - if (Type == xpti::trace_point_type_t::mem_alloc_begin) { - std::cout << "Mem Alloc Begin : "; - } else if (Type == xpti::trace_point_type_t::mem_alloc_end) { - std::cout << "Mem Alloc End : "; - } else if (Type == xpti::trace_point_type_t::mem_release_begin) { - std::cout << "Mem Release Begin : "; - } else if (Type == xpti::trace_point_type_t::mem_release_end) { - std::cout << "Mem Release End : "; - } - std::cout << "mem_obj_handle:0x" << std::hex << Data->mem_object_handle; - std::cout << "|alloc_pointer:0x" << Data->alloc_pointer; - std::cout << "|alloc_size:" << std::dec << Data->alloc_size << std::endl; -} - -XPTI_CALLBACK_API void syclBufferCallback(uint16_t TraceType, - xpti::trace_event_data_t *Parent, - xpti::trace_event_data_t *Event, - uint64_t IId, const void *UserData) { - std::lock_guard Lock{GMutex}; - auto Type = static_cast(TraceType); - switch (Type) { - case xpti::trace_point_type_t::offload_alloc_memory_object_construct: { - auto BufConstr = (xpti::offload_buffer_data_t *)UserData; - std::cout << IId << "|Create buffer|0x" << std::hex - << BufConstr->user_object_handle << "|0x" - << BufConstr->host_object_handle << "|" << std::dec - << BufConstr->element_type << "|" << BufConstr->element_size - << "|" << BufConstr->dim << "|" - << "{" << BufConstr->range[0] << "," << BufConstr->range[1] << "," - << BufConstr->range[2] << "}|" - << Event->reserved.payload->source_file << ":" - << Event->reserved.payload->line_no << ":" - << Event->reserved.payload->column_no << "\n"; - - break; - } - case xpti::trace_point_type_t::offload_alloc_memory_object_associate: { - auto BufAssoc = (xpti::offload_association_data_t *)UserData; - std::cout << IId << "|Associate buffer|0x" << std::hex - << BufAssoc->user_object_handle << "|0x" - << BufAssoc->mem_object_handle << std::dec << std::endl; - break; - } - case xpti::trace_point_type_t::offload_alloc_memory_object_release: { - auto BufRelease = (xpti::offload_association_data_t *)UserData; - std::cout << IId << "|Release buffer|0x" << std::hex - << BufRelease->user_object_handle << "|0x" - << BufRelease->mem_object_handle << std::dec << std::endl; - break; - } - case xpti::trace_point_type_t::offload_alloc_memory_object_destruct: { - auto BufDestr = (xpti::offload_buffer_data_t *)UserData; - std::cout << IId << "|Destruct buffer|0x" << std::hex - << BufDestr->user_object_handle << std::dec << std::endl; - break; - } - case xpti::trace_point_type_t::offload_alloc_accessor: { - auto BufAccessor = (xpti::offload_accessor_data_t *)UserData; - std::cout << IId << "|Construct accessor|0x" << std::hex - << BufAccessor->buffer_handle << "|0x" - << BufAccessor->accessor_handle << std::dec << "|" - << BufAccessor->target << "|" << BufAccessor->mode << "|" - << Event->reserved.payload->source_file << ":" - << Event->reserved.payload->line_no << ":" - << Event->reserved.payload->column_no << "\n"; - break; - } - default: - std::cout << "Unknown tracepoint\n"; - } -} - -XPTI_CALLBACK_API void syclImageCallback(uint16_t TraceType, - xpti::trace_event_data_t *Parent, - xpti::trace_event_data_t *Event, - uint64_t IId, const void *UserData) { - std::lock_guard Lock{GMutex}; - auto Type = static_cast(TraceType); - switch (Type) { - case xpti::trace_point_type_t::offload_alloc_memory_object_construct: { - auto ImgConstr = (xpti::offload_image_data_t *)UserData; - bool IsSampledImage = ImgConstr->addressing && - ImgConstr->coordinate_normalization && - ImgConstr->filtering; - std::cout << IId << "|Create "; - if (!IsSampledImage) - std::cout << "un"; - std::cout << "sampled image|0x" << std::hex << ImgConstr->user_object_handle - << "|0x" << ImgConstr->host_object_handle << "|" << std::dec - << ImgConstr->dim << "|" - << "{" << ImgConstr->range[0] << "," << ImgConstr->range[1] << "," - << ImgConstr->range[2] << "}|" << ImgConstr->format << "|"; - if (IsSampledImage) - std::cout << *ImgConstr->addressing << "|" - << *ImgConstr->coordinate_normalization << "|" - << *ImgConstr->filtering << "|"; - std::cout << Event->reserved.payload->source_file << ":" - << Event->reserved.payload->line_no << ":" - << Event->reserved.payload->column_no << "\n"; - - break; - } - case xpti::trace_point_type_t::offload_alloc_memory_object_associate: { - auto ImgAssoc = (xpti::offload_association_data_t *)UserData; - std::cout << IId << "|Associate image|0x" << std::hex - << ImgAssoc->user_object_handle << "|0x" - << ImgAssoc->mem_object_handle << std::dec << std::endl; - break; - } - case xpti::trace_point_type_t::offload_alloc_memory_object_release: { - auto ImgRelease = (xpti::offload_association_data_t *)UserData; - std::cout << IId << "|Release image|0x" << std::hex - << ImgRelease->user_object_handle << "|0x" - << ImgRelease->mem_object_handle << std::dec << std::endl; - break; - } - case xpti::trace_point_type_t::offload_alloc_memory_object_destruct: { - auto ImgDestr = (xpti::offload_image_data_t *)UserData; - std::cout << IId << "|Destruct image|0x" << std::hex - << ImgDestr->user_object_handle << std::dec << std::endl; - break; - } - case xpti::trace_point_type_t::offload_alloc_accessor: { - auto ImgAccessor = (xpti::offload_image_accessor_data_t *)UserData; - // Host accessors do not have a target. - bool IsHostAccessor = !ImgAccessor->target; - // Only unsampled image accessors have a mode. - bool IsUnsampledAccessor = bool(ImgAccessor->mode); - std::cout << IId << "|Construct "; - if (IsHostAccessor) - std::cout << "host "; - if (IsUnsampledAccessor) - std::cout << "un"; - std::cout << "sampled image accessor|0x" << std::hex - << ImgAccessor->image_handle << "|0x" - << ImgAccessor->accessor_handle << std::dec << "|"; - if (!IsHostAccessor) - std::cout << *ImgAccessor->target << "|"; - if (IsUnsampledAccessor) - std::cout << *ImgAccessor->mode << "|"; - std::cout << ImgAccessor->element_type << "|" << ImgAccessor->element_size - << "|" << Event->reserved.payload->source_file << ":" - << Event->reserved.payload->line_no << ":" - << Event->reserved.payload->column_no << "\n"; - break; - } - default: - std::cout << "Unknown tracepoint\n"; - } -} - -template -T getMetadataByKey(xpti::metadata_t *Metadata, const char *key) { - for (auto &Item : *Metadata) { - if (std::string(xptiLookupString(Item.first)) == key) { - return xpti::getMetadata(Item).second; - } - } - return {}; -} - -bool isMetadataPresent(xpti::metadata_t *Metadata, const char *key) { - for (auto &Item : *Metadata) { - if (std::string(xptiLookupString(Item.first)) == key) { - return true; - } - } - return false; -} -void parseMetadata(xpti::trace_event_data_t *Event) { - xpti::metadata_t *Metadata = xptiQueryMetadata(Event); - if (isMetadataPresent(Metadata, "kernel_name")) { - std::cout << getMetadataByKey(Metadata, "kernel_name") << "|"; - } - if (isMetadataPresent(Metadata, "sym_source_file_name") && - isMetadataPresent(Metadata, "sym_line_no") && - isMetadataPresent(Metadata, "sym_column_no")) { - std::cout << getMetadataByKey(Metadata, "sym_source_file_name") - << ":" << getMetadataByKey(Metadata, "sym_line_no") << ":" - << getMetadataByKey(Metadata, "sym_column_no") << "|"; - } - if (isMetadataPresent(Metadata, "enqueue_kernel_data")) { - auto KernelEnqueueData = - getMetadataByKey( - Metadata, "enqueue_kernel_data"); - - std::cout << "{" << KernelEnqueueData.global_size[0] << ", " - << KernelEnqueueData.global_size[1] << ", " - << KernelEnqueueData.global_size[2] << "}, {" - << KernelEnqueueData.local_size[0] << ", " - << KernelEnqueueData.local_size[1] << ", " - << KernelEnqueueData.local_size[2] << "}, {" - << KernelEnqueueData.offset[0] << ", " - << KernelEnqueueData.offset[1] << ", " - << KernelEnqueueData.offset[2] << "}, " - << KernelEnqueueData.args_num << "|\n"; - - for (int i = 0; i < KernelEnqueueData.args_num; i++) { - std::string Name("arg" + std::to_string(i)); - - auto arg = getMetadataByKey( - Metadata, Name.c_str()); - std::cout << " " << Name << " : {" << arg.type << ", " << std::hex - << "0x" << (uintptr_t)arg.pointer << std::dec << ", " - << arg.size << ", " << arg.index << "} " - << "\n"; - } - } else { - std::cout << "\n"; - } -} -XPTI_CALLBACK_API void syclCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *Event, uint64_t, - const void *UserData) { - std::lock_guard Lock{GMutex}; - auto Type = static_cast(TraceType); - switch (Type) { - case xpti::trace_point_type_t::graph_create: - std::cout << "Graph create|"; - break; - case xpti::trace_point_type_t::node_create: - std::cout << "Node create|"; - break; - case xpti::trace_point_type_t::edge_create: - std::cout << "Edge create|"; - break; - case xpti::trace_point_type_t::task_begin: - std::cout << "Task begin|"; - break; - case xpti::trace_point_type_t::task_end: - std::cout << "Task end|"; - break; - case xpti::trace_point_type_t::signal: - std::cout << "Signal|"; - break; - case xpti::trace_point_type_t::wait_begin: - std::cout << "Wait begin|"; - break; - case xpti::trace_point_type_t::wait_end: - std::cout << "Wait end|"; - break; - case xpti::trace_point_type_t::barrier_begin: - std::cout << "Barrier begin|"; - break; - case xpti::trace_point_type_t::barrier_end: - std::cout << "Barrier end|"; - break; - default: - std::cout << "Unknown tracepoint|"; - } - parseMetadata(Event); -} diff --git a/sycl/test-e2e/XPTI/Inputs/test_collector.cpp b/sycl/test-e2e/XPTI/Inputs/test_collector.cpp deleted file mode 100644 index 86e126714fc07..0000000000000 --- a/sycl/test-e2e/XPTI/Inputs/test_collector.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "xpti/xpti_trace_framework.hpp" - -#include -#include -#include - -std::mutex GMutex; - -XPTI_CALLBACK_API void syclCallback(uint16_t, xpti::trace_event_data_t *, - xpti::trace_event_data_t *, uint64_t, - const void *); -XPTI_CALLBACK_API void syclUrCallback(uint16_t, xpti::trace_event_data_t *, - xpti::trace_event_data_t *, uint64_t, - const void *); - -XPTI_CALLBACK_API void xptiTraceInit(unsigned int MajorVersion, - unsigned int MinorVersion, - const char *VersionStr, - const char *StreamName) { - std::cout << "xptiTraceInit: Stream Name = " << StreamName << "\n"; - std::string_view NameView{StreamName}; - using type = xpti::trace_point_type_t; - - if (NameView == "ur.call") { - uint8_t StreamID = xptiRegisterStream(StreamName); - for (type t : std::initializer_list{type::function_with_args_begin}) - xptiRegisterCallback(StreamID, static_cast(t), syclUrCallback); - } - if (NameView == "sycl") { - uint8_t StreamID = xptiRegisterStream(StreamName); - - for (type t : std::initializer_list{ - type::graph_create, type::node_create, type::edge_create, - type::task_begin, type::task_end, type::signal, - type::barrier_begin, type::barrier_end, type::wait_begin, - type::wait_end}) - xptiRegisterCallback(StreamID, static_cast(t), syclCallback); - } -} - -XPTI_CALLBACK_API void xptiTraceFinish(const char *streamName) { - std::cout << "xptiTraceFinish: Stream Name = " << streamName << "\n"; -} - -XPTI_CALLBACK_API void syclUrCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *, uint64_t, - const void *UserData) { - std::lock_guard Lock{GMutex}; - auto Type = static_cast(TraceType); - auto *args = static_cast(UserData); - if (Type == xpti::trace_point_type_t::function_with_args_begin) { - std::cout << "UR Call Begin : "; - } else if (Type == xpti::trace_point_type_t::function_with_args_end) { - std::cout << "UR Call End : "; - } - std::cout << args->function_name << "\n"; -} - -XPTI_CALLBACK_API void syclCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *Event, uint64_t, - const void *UserData) { - char *Key = 0; - uint64_t Value; - bool HaveKeyValue = - (xptiGetStashedTuple(&Key, Value) == xpti::result_t::XPTI_RESULT_SUCCESS); - std::lock_guard Lock{GMutex}; - auto Type = static_cast(TraceType); - switch (Type) { - case xpti::trace_point_type_t::graph_create: - std::cout << "Graph create\n"; - break; - case xpti::trace_point_type_t::node_create: - std::cout << "Node create\n"; - break; - case xpti::trace_point_type_t::edge_create: - std::cout << "Edge create\n"; - break; - case xpti::trace_point_type_t::task_begin: - std::cout << "Task begin\n"; - break; - case xpti::trace_point_type_t::task_end: - std::cout << "Task end\n"; - break; - case xpti::trace_point_type_t::signal: - std::cout << "Signal\n"; - break; - case xpti::trace_point_type_t::wait_begin: - std::cout << "Wait begin\n"; - break; - case xpti::trace_point_type_t::wait_end: - std::cout << "Wait end\n"; - break; - case xpti::trace_point_type_t::barrier_begin: - std::cout << "Barrier begin\n"; - break; - case xpti::trace_point_type_t::barrier_end: - std::cout << "Barrier end\n"; - break; - default: - std::cout << "Unknown tracepoint\n"; - } - - if (HaveKeyValue) { - std::cout << " " << Key << " : " << Value << "\n"; - } - xpti::metadata_t *Metadata = xptiQueryMetadata(Event); - for (auto &Item : *Metadata) { - std::cout << " " << xptiLookupString(Item.first) << " : " - << xpti::readMetadata(Item) << "\n"; - } -} diff --git a/sycl/test-e2e/XPTI/basic_event_collection.inc b/sycl/test-e2e/XPTI/basic_event_collection.inc deleted file mode 100644 index c8db44c579bf0..0000000000000 --- a/sycl/test-e2e/XPTI/basic_event_collection.inc +++ /dev/null @@ -1,33 +0,0 @@ -#ifdef XPTI_COLLECTOR - -#include "Inputs/test_collector.cpp" - -#else - -#include -#include - -int main() { - sycl::queue Q{sycl::default_selector_v}; - - auto Ptr = sycl::malloc_device(1, Q); - - auto Evt1 = Q.single_task([=]() { Ptr[0] = 1; }); - - auto Evt2 = Q.submit([&](sycl::handler &CGH) { - CGH.depends_on(Evt1); - CGH.single_task([=]() { Ptr[0]++; }); - }); - - Evt2.wait(); - - int Res = 0; - Q.memcpy(&Res, Ptr, 1); - Q.wait(); - - assert(Res == 2); - - return 0; -} - -#endif diff --git a/sycl/test-e2e/XPTI/basic_event_collection_linux.cpp b/sycl/test-e2e/XPTI/basic_event_collection_linux.cpp deleted file mode 100644 index ef6142d392e09..0000000000000 --- a/sycl/test-e2e/XPTI/basic_event_collection_linux.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// REQUIRES: xptifw, opencl, cpu, linux -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib -shared -fPIC -std=c++17 -o %t_collector.so -// RUN: %{build} -o %t.out -// RUN: env UR_ENABLE_LAYERS=UR_LAYER_TRACING env XPTI_TRACE_ENABLE=1 env XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher env XPTI_SUBSCRIBERS=%t_collector.so %{run} %t.out | FileCheck %s - -#include "basic_event_collection.inc" -// -// CHECK: xptiTraceInit: Stream Name = ur.call -// CHECK: xptiTraceInit: Stream Name = sycl.experimental.mem_alloc -// CHECK: xptiTraceInit: Stream Name = sycl -// CHECK-NEXT: Graph create -// CHECK: UR Call Begin : urPlatformGet -// CHECK: UR Call Begin : urContextCreate -// CHECK: UR Call Begin : urQueueCreate -// CHECK: UR Call Begin : urDeviceSelectBinary -// CHECK: UR Call Begin : urKernelCreate -// CHECK-NEXT: UR Call Begin : urPlatformGetInfo -// CHECK-NEXT: UR Call Begin : urPlatformGetInfo -// CHECK-NEXT: UR Call Begin : urKernelSetExecInfo -// CHECK: UR Call Begin : urKernelSetArgPointer -// CHECK-NEXT: UR Call Begin : urKernelGetGroupInfo -// CHECK-NEXT: UR Call Begin : urEnqueueKernelLaunch -// CHECK: UR Call Begin : urKernelCreate -// CHECK-NEXT: UR Call Begin : urPlatformGetInfo -// CHECK-NEXT: UR Call Begin : urPlatformGetInfo -// CHECK-NEXT: UR Call Begin : urKernelSetExecInfo -// CHECK: Node create -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: sym_line_no : {{.*}} -// CHECK-DAG: sym_source_file_name : {{.*}} -// CHECK-DAG: sym_function_name : typeinfo name for main::{lambda(sycl::_V1::handler&)#1}::operator()(sycl::_V1::handler&) const::{lambda()#1} -// CHECK-DAG: from_source : false -// CHECK-DAG: kernel_name : typeinfo name for main::{lambda(sycl::_V1::handler&)#1}::operator()(sycl::_V1::handler&) const::{lambda()#1} -// CHECK-DAG: sycl_device : {{.*}} -// CHECK: Node create -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: kernel_name : virtual_node[{{.*}}] -// CHECK-NEXT: Edge create -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: event : {{.*}} -// CHECK: Task begin -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: sym_line_no : {{.*}} -// CHECK-DAG: sym_source_file_name : {{.*}} -// CHECK-DAG: sym_function_name : typeinfo name for main::{lambda(sycl::_V1::handler&)#1}::operator()(sycl::_V1::handler&) const::{lambda()#1} -// CHECK-DAG: from_source : false -// CHECK-DAG: kernel_name : typeinfo name for main::{lambda(sycl::_V1::handler&)#1}::operator()(sycl::_V1::handler&) const::{lambda()#1} -// CHECK-DAG: sycl_device : {{.*}} -// CHECK: UR Call Begin : urKernelSetArgPointer -// CHECK-NEXT: UR Call Begin : urKernelGetGroupInfo -// CHECK-NEXT: UR Call Begin : urEnqueueKernelLaunch -// CHECK-NEXT: UR Call Begin : urKernelRelease -// CHECK-NEXT: UR Call Begin : urProgramRelease -// CHECK-NEXT: Signal -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: sym_line_no : {{.*}} -// CHECK-DAG: sym_source_file_name : {{.*}} -// CHECK-DAG: sym_function_name : typeinfo name for main::{lambda(sycl::_V1::handler&)#1}::operator()(sycl::_V1::handler&) const::{lambda()#1} -// CHECK-DAG: from_source : false -// CHECK-DAG: kernel_name : typeinfo name for main::{lambda(sycl::_V1::handler&)#1}::operator()(sycl::_V1::handler&) const::{lambda()#1} -// CHECK-DAG: sycl_device : {{.*}} -// CHECK: Task end -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: sym_line_no : {{.*}} -// CHECK-DAG: sym_source_file_name : {{.*}} -// CHECK-DAG: sym_function_name : typeinfo name for main::{lambda(sycl::_V1::handler&)#1}::operator()(sycl::_V1::handler&) const::{lambda()#1} -// CHECK-DAG: from_source : false -// CHECK-DAG: kernel_name : typeinfo name for main::{lambda(sycl::_V1::handler&)#1}::operator()(sycl::_V1::handler&) const::{lambda()#1} -// CHECK-DAG: sycl_device : {{.*}} -// CHECK: Wait begin -// CHECK-DAG: queue_id : {{.*}} -// CHECK-NEXT: UR Call Begin : urEventWait -// CHECK-NEXT: Wait end -// CHECK-DAG: queue_id : {{.*}} -// CHECK-NEXT: Node create -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: memory_size : {{.*}} -// CHECK-DAG: dest_memory_ptr : {{.*}} -// CHECK-DAG: src_memory_ptr : {{.*}} -// CHECK-DAG: sycl_device : {{.*}} -// CHECK: Task begin -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: memory_size : {{.*}} -// CHECK-DAG: dest_memory_ptr : {{.*}} -// CHECK-DAG: src_memory_ptr : {{.*}} -// CHECK-DAG: sycl_device : {{.*}} -// CHECK: UR Call Begin : urEnqueueUSMMemcpy -// CHECK-NEXT: Task end -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: memory_size : {{.*}} -// CHECK-DAG: dest_memory_ptr : {{.*}} -// CHECK-DAG: src_memory_ptr : {{.*}} -// CHECK-DAG: sycl_device : {{.*}} -// CHECK: UR Call Begin : urEventRelease -// CHECK-NEXT: Wait begin -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: sycl_device_type : {{.*}} -// CHECK: UR Call Begin : urQueueFinish -// CHECK-NEXT: Wait end -// CHECK-DAG: queue_id : {{.*}} -// CHECK-DAG: sycl_device_type : {{.*}} diff --git a/sycl/test-e2e/XPTI/buffer/accessors.cpp b/sycl/test-e2e/XPTI/buffer/accessors.cpp deleted file mode 100644 index f7412c0744cdd..0000000000000 --- a/sycl/test-e2e/XPTI/buffer/accessors.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// REQUIRES: xptifw, opencl -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -Wno-error=deprecated-declarations -o %t.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.out | FileCheck %s - -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else - -#include - -using namespace sycl::access; - -int main() { - bool MismatchFound = false; - sycl::queue Queue{}; - - // CHECK:{{[0-9]+}}|Create buffer|[[BUFFERID:[0-9,a-f,x]+]]|0x0|{{i(nt)*}}|4|1|{3,0,0}|{{.*}}accessors.cpp:[[# @LINE + 1]]:24 - sycl::buffer Buf(3); - - sycl::range<1> Range{Buf.size()}; - sycl::nd_range<1> NDRange(Buf.size(), Buf.size()); - - Queue.submit([&](sycl::handler &cgh) { - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID1:.+]]|2015|1024|{{.*}}accessors.cpp:[[# @LINE + 1]]:19 - auto A1 = Buf.get_access(cgh); - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID2:.*]]|2014|1025|{{.*}}accessors.cpp:[[# @LINE + 1]]:19 - auto A2 = Buf.get_access(cgh); - // CHECK: {{[0-9]+}}|Construct accessor|0x0|[[ACCID3:.*]]|2016|1026|{{.*}}accessors.cpp:[[# @LINE + 1]]:34 - sycl::local_accessor A3(Range, cgh); - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID4:.*]]|2014|1027|{{.*}}accessors.cpp:[[# @LINE + 1]]:19 - auto A4 = Buf.get_access(cgh); - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID5:.*]]|2014|1028|{{.*}}accessors.cpp:[[# @LINE + 1]]:19 - auto A5 = Buf.get_access(cgh); - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID6:.*]]|2014|1029|{{.*}}accessors.cpp:[[# @LINE + 1]]:19 - auto A6 = Buf.get_access(cgh); - cgh.parallel_for(NDRange, [=](sycl::nd_item<1>) { - (void)A1; - (void)A2; - (void)A3; - (void)A4; - (void)A5; - (void)A6; - }); - }); - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID7:.*]]|2018|1024|{{.*}}accessors.cpp:[[# @LINE + 1]]:25 - { sycl::host_accessor HA(Buf, sycl::read_only); } - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID8:.*]]|2018|1025|{{.*}}accessors.cpp:[[# @LINE + 1]]:25 - { sycl::host_accessor HA(Buf, sycl::write_only); } - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID9:.*]]|2018|1026|{{.*}}accessors.cpp:[[# @LINE + 1]]:25 - { sycl::host_accessor HA(Buf, sycl::read_write); } - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID10:.*]]|2018|1027|{{.*}}accessors.cpp:[[# @LINE + 1]]:19 - { auto HA = Buf.get_access(); } - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID11:.*]]|2018|1028|{{.*}}accessors.cpp:[[# @LINE + 1]]:19 - { auto HA = Buf.get_access(); } - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID12:.*]]|2018|1029|{{.*}}accessors.cpp:[[# @LINE + 1]]:19 - { auto HA = Buf.get_access(); } - - return 0; -} -// CHECK:{{[0-9]+}}|Destruct buffer|[[BUFFERID]] -#endif diff --git a/sycl/test-e2e/XPTI/buffer/host_array.cpp b/sycl/test-e2e/XPTI/buffer/host_array.cpp deleted file mode 100644 index 2574f93ae53f6..0000000000000 --- a/sycl/test-e2e/XPTI/buffer/host_array.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// REQUIRES: xptifw, opencl -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -o %t.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.out | FileCheck %s - -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else -#include -#include - -int main() { - bool MismatchFound = false; - sycl::queue Queue{}; - - int Array[4]; - { - sycl::range<1> NumOfWorkItems{4}; - // CHECK:{{[0-9]+}}|Create buffer|[[USERID1:[0-9,a-f,x]+]]|0x{{.*}}|{{i(nt)*}}|4|1|{4,0,0}|{{.*}}host_array.cpp:[[# @LINE + 1]]:26 - sycl::buffer Buffer1(Array, NumOfWorkItems); - - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID1]]|[[BEID1:.*]] - Queue.submit([&](sycl::handler &cgh) { - // Get write only access to the buffer on a device. - auto Accessor1 = Buffer1.get_access(cgh); - // Execute kernel. - cgh.parallel_for(NumOfWorkItems, [=](sycl::id<1> WIid) { - Accessor1[WIid] = static_cast(WIid.get(0)); - }); - }); - } - - // Check the results. - for (size_t I = 0; I < 4; ++I) { - if (Array[I] != I) { - std::cout << "The result is incorrect for element: " << I - << " , expected: " << I << " , got: " << Array[I] << std::endl; - MismatchFound = true; - } - } - - return MismatchFound; -} -// CHECK:{{[0-9]+}}|Release buffer|[[USERID1]]|[[BEID1]] -// CHECK:{{[0-9]+}}|Destruct buffer|[[USERID1]] -#endif diff --git a/sycl/test-e2e/XPTI/buffer/in_cycle.cpp b/sycl/test-e2e/XPTI/buffer/in_cycle.cpp deleted file mode 100644 index 7dbd84d336289..0000000000000 --- a/sycl/test-e2e/XPTI/buffer/in_cycle.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// REQUIRES: xptifw, opencl -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -o %t.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.out | FileCheck %s - -// It looks like order of events diffres on Windows -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else -#include -#include -bool func(sycl::queue &Queue, int depth = 0) { - bool MismatchFound = false; - // Create a buffer of 4 ints to be used inside the kernel code. - sycl::buffer Buffer(4); - - // Size of index space for kernel. - sycl::range<1> NumOfWorkItems{Buffer.size()}; - - // Submit command group(work) to queue. - Queue.submit([&](sycl::handler &cgh) { - // Get write only access to the buffer on a device. - auto Accessor = Buffer.get_access(cgh); - // Execute kernel. - cgh.parallel_for(NumOfWorkItems, [=](sycl::id<1> WIid) { - Accessor[WIid] = static_cast(WIid.get(0)); - }); - }); - - // Get read only access to the buffer on the host. - // This introduces an implicit barrier which blocks execution until the - // command group above completes. - const sycl::host_accessor HostAccessor(Buffer, sycl::read_only); - - // Check the results. - for (size_t I = 0; I < Buffer.size(); ++I) { - if (HostAccessor[I] != I) { - std::cout << "The result is incorrect for element: " << I - << " , expected: " << I << " , got: " << HostAccessor[I] - << std::endl; - MismatchFound = true; - } - } - - if (depth > 0) - MismatchFound &= func(Queue, depth - 1); - return MismatchFound; -} -int main() { - bool MismatchFound = false; - // Create a SYCL queue. - sycl::queue Queue{}; - - // CHECK:{{[0-9]+}}|Create buffer|[[USERID1:[0-9,a-f,x]*]]|0x0|{{i(nt)*}}|4|1|{4,0,0}|{{.*}}in_cycle.cpp:17:24 - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID1]]|[[BEID1:.*]] - // CHECK:{{[0-9]+}}|Release buffer|[[USERID1]]|[[BEID1]] - // CHECK:{{[0-9]+}}|Destruct buffer|[[USERID1]] - // CHECK:{{[0-9]+}}|Create buffer|[[USERID2:[0-9,a-f,x]*]]|0x0|{{i(nt)*}}|4|1|{4,0,0}|{{.*}}in_cycle.cpp:17:24 - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID2]]|[[BEID2:.*]] - // CHECK:{{[0-9]+}}|Release buffer|[[USERID2]]|[[BEID2]] - // CHECK:{{[0-9]+}}|Destruct buffer|[[USERID2]] - // CHECK:{{[0-9]+}}|Create buffer|[[USERID3:[0-9,a-f,x]*]]|0x0|{{i(nt)*}}|4|1|{4,0,0}|{{.*}}in_cycle.cpp:17:24 - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID3]]|[[BEID3:.*]] - // CHECK:{{[0-9]+}}|Release buffer|[[USERID3]]|[[BEID3]] - // CHECK:{{[0-9]+}}|Destruct buffer|[[USERID3]] - for (int i = 0; i < 3; i++) - MismatchFound &= func(Queue); - return MismatchFound; -} - -#endif diff --git a/sycl/test-e2e/XPTI/buffer/multiple_buffers.cpp b/sycl/test-e2e/XPTI/buffer/multiple_buffers.cpp deleted file mode 100644 index 247a5182413c8..0000000000000 --- a/sycl/test-e2e/XPTI/buffer/multiple_buffers.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// REQUIRES: xptifw, opencl -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -o %t.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.out | FileCheck %s - -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else -#include -#include - -int main() { - bool MismatchFound = false; - sycl::queue Queue{}; - - // CHECK:{{[0-9]+}}|Create buffer|[[USERID1:[0-9,a-f,x]+]]|0x0|{{s(hort)*}}|2|1|{4,0,0}|{{.*}}multiple_buffers.cpp:[[# @LINE + 1]]:26 - sycl::buffer Buffer1(4); - // CHECK:{{[0-9]+}}|Create buffer|[[USERID2:[0-9,a-f,x]+]]|0x0|{{c(har)*}}|1|3|{5,4,3}|{{.*}}multiple_buffers.cpp:[[# @LINE + 1]]:25 - sycl::buffer Buffer2({5, 4, 3}); - - sycl::range<1> NumOfWorkItems{Buffer1.size()}; - - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID1]]|[[BEID1:.*]] - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID2]]|[[BEID2:.*]] - Queue.submit([&](sycl::handler &cgh) { - // Get write only access to the buffer on a device. - auto Accessor1 = Buffer1.get_access(cgh); - auto Accessor2 = Buffer2.get_access(cgh); - // Execute kernel. - cgh.parallel_for(NumOfWorkItems, [=](sycl::id<1> WIid) { - Accessor1[WIid] = static_cast(WIid.get(0)); - Accessor2[WIid][0][0] = static_cast(WIid.get(0)); - }); - }); - - const sycl::host_accessor HostAccessor1(Buffer1, sycl::read_only); - const sycl::host_accessor HostAccessor2(Buffer2, sycl::read_only); - - // Check the results. - for (size_t I = 0; I < Buffer1.size(); ++I) { - if (HostAccessor1[I] != I || HostAccessor2[I][0][0] != I) { - std::cout << "The result is incorrect for element: " << I - << " , expected: " << I << " , got: " << HostAccessor1[I] - << ", " << HostAccessor2[I][0][0] << std::endl; - MismatchFound = true; - } - } - - return MismatchFound; -} -// CHECK:{{[0-9]+}}|Release buffer|[[USERID2]]|[[BEID2]] -// CHECK:{{[0-9]+}}|Destruct buffer|[[USERID2]] -// CHECK:{{[0-9]+}}|Release buffer|[[USERID1]]|[[BEID1]] -// CHECK:{{[0-9]+}}|Destruct buffer|[[USERID1]] -#endif diff --git a/sycl/test-e2e/XPTI/buffer/multiple_queues.cpp b/sycl/test-e2e/XPTI/buffer/multiple_queues.cpp deleted file mode 100644 index 3085c0b621cb0..0000000000000 --- a/sycl/test-e2e/XPTI/buffer/multiple_queues.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// REQUIRES: xptifw, opencl, (cpu || accelerator) -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -o %t.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.out | FileCheck %s - -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else -#include -#include -#include - -int main() { - bool MismatchFound = false; - - auto selector_v = [](const sycl::device &d) { - return std::max(cpu_selector_v(d), accelerator_selector_v(d)); - }; - sycl::device Device{selector_v}; - auto Devices = Device.create_sub_devices< - sycl::info::partition_property::partition_equally>(2); - - int Array[4] = {0}; - { - sycl::queue Queue1{Devices[0]}; - sycl::queue Queue2{Devices[1]}; - sycl::range<1> NumOfWorkItems{4}; - // CHECK:{{[0-9]+}}|Create buffer|[[USERID1:0x[0-9,a-f,x]+]]|0x{{.*}}|{{i(nt)*}}|4|1|{4,0,0}|{{.*}}multiple_queues.cpp:[[# @LINE + 1]]:26 - sycl::buffer Buffer1(Array, NumOfWorkItems); - - Queue1.submit([&](sycl::handler &cgh) { - // CHECK: {{[0-9]+}}|Construct accessor|[[USERID1]]|[[ACCID1:.*]]|2014|1025|{{.*}}multiple_queues.cpp:[[# @LINE + 1]]:32 - auto Accessor1 = Buffer1.get_access(cgh); - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID1]]|[[BEID1:.*]] - cgh.parallel_for(NumOfWorkItems, [=](sycl::id<1> WIid) { - Accessor1[WIid] = static_cast(WIid.get(0)); - }); - }); - Queue1.wait(); - - Queue2.submit([&](sycl::handler &cgh) { - // CHECK: {{[0-9]+}}|Construct accessor|[[USERID1]]|[[ACCID2:.*]]|2014|1025|{{.*}}multiple_queues.cpp:[[# @LINE + 1]]:32 - auto Accessor1 = Buffer1.get_access(cgh); - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID1]]|[[BEID2:.*]] - cgh.parallel_for(NumOfWorkItems, [=](sycl::id<1> WIid) { - Accessor1[WIid] *= static_cast(WIid.get(0)); - }); - }); - } - // CHECK:{{[0-9]+}}|Release buffer|[[USERID1]]|[[BEID1]] - // CHECK:{{[0-9]+}}|Release buffer|[[USERID1]]|[[BEID2]] - // CHECK:{{[0-9]+}}|Destruct buffer|[[USERID1]] - - // Check the results. - for (size_t I = 0; I < 4; ++I) { - if (Array[I] != I * I) { - std::cout << "The result is incorrect for element: " << I - << " , expected: " << I * I << " , got: " << Array[I] - << std::endl; - MismatchFound = true; - } - } - - return MismatchFound; -} -#endif diff --git a/sycl/test-e2e/XPTI/buffer/recursion.cpp b/sycl/test-e2e/XPTI/buffer/recursion.cpp deleted file mode 100644 index 00d90390311a1..0000000000000 --- a/sycl/test-e2e/XPTI/buffer/recursion.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// REQUIRES: xptifw, opencl -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -o %t.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.out | FileCheck %s - -// It looks like order of events diffres on Windows -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else -#include -#include -bool func(sycl::queue &Queue, int depth = 0) { - bool MismatchFound = false; - // Create a buffer of 4 ints to be used inside the kernel code. - sycl::buffer Buffer(4); - - // Size of index space for kernel. - sycl::range<1> NumOfWorkItems{Buffer.size()}; - - // Submit command group(work) to queue. - Queue.submit([&](sycl::handler &cgh) { - // Get write only access to the buffer on a device. - auto Accessor = Buffer.get_access(cgh); - // Execute kernel. - cgh.parallel_for(NumOfWorkItems, [=](sycl::id<1> WIid) { - Accessor[WIid] = static_cast(WIid.get(0)); - }); - }); - - // Get read only access to the buffer on the host. - // This introduces an implicit barrier which blocks execution until the - // command group above completes. - const sycl::host_accessor HostAccessor(Buffer, sycl::read_only); - - // Check the results. - for (size_t I = 0; I < Buffer.size(); ++I) { - if (HostAccessor[I] != I) { - std::cout << "The result is incorrect for element: " << I - << " , expected: " << I << " , got: " << HostAccessor[I] - << std::endl; - MismatchFound = true; - } - } - - if (depth > 0) - MismatchFound &= func(Queue, depth - 1); - return MismatchFound; -} -int main() { - bool MismatchFound = false; - // Create a SYCL queue. - sycl::queue Queue{}; - - // CHECK:{{[0-9]+}}|Create buffer|[[USERID1:0x[0-9,a-f,x]+]]|0x0|{{i(nt)*}}|4|1|{4,0,0}|{{.*}}recursion.cpp:17:24 - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID1]]|[[BEID1:.*]] - // CHECK:{{[0-9]+}}|Create buffer|[[USERID2:0x[0-9,a-f,x]+]]|0x0|{{i(nt)*}}|4|1|{4,0,0}|{{.*}}recursion.cpp:17:24 - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID2]]|[[BEID2:.*]] - // CHECK:{{[0-9]+}}|Create buffer|[[USERID3:0x[0-9,a-f,x]+]]|0x0|{{i(nt)*}}|4|1|{4,0,0}|{{.*}}recursion.cpp:17:24 - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID3]]|[[BEID3:.*]] - // CHECK:{{[0-9]+}}|Release buffer|[[USERID3]]|[[BEID3]] - // CHECK:{{[0-9]+}}|Destruct buffer|[[USERID3]] - // CHECK:{{[0-9]+}}|Release buffer|[[USERID2]]|[[BEID2]] - // CHECK:{{[0-9]+}}|Destruct buffer|[[USERID2]] - // CHECK:{{[0-9]+}}|Release buffer|[[USERID1]]|[[BEID1]] - // CHECK:{{[0-9]+}}|Destruct buffer|[[USERID1]] - MismatchFound &= func(Queue, 2); - - return MismatchFound; -} - -#endif diff --git a/sycl/test-e2e/XPTI/buffer/sub_buffer.cpp b/sycl/test-e2e/XPTI/buffer/sub_buffer.cpp deleted file mode 100644 index f660ef7b17456..0000000000000 --- a/sycl/test-e2e/XPTI/buffer/sub_buffer.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// REQUIRES: xptifw, opencl -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -o %t.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.out | FileCheck %s - -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else -#include -#include - -int main() { - bool MismatchFound = false; - sycl::queue Queue{}; - - { - sycl::range<1> NumOfWorkItems{128}; - // CHECK:{{[0-9]+}}|Create buffer|[[USERID1:0x[0-9,a-f,x]+]]|0x0|{{i(nt)*}}|4|1|{128,0,0}|{{.*}}sub_buffer.cpp:[[# @LINE + 1]]:26 - sycl::buffer Buffer1(NumOfWorkItems); - // CHECK:{{[0-9]+}}|Create buffer|[[USERID1:0x[0-9,a-f,x]+]]|[[USERID1]]|{{i(nt)*}}|4|1|{32,0,0}|{{.*}}sub_buffer.cpp:[[# @LINE + 1]]:26 - sycl::buffer SubBuffer{Buffer1, sycl::range<1>{32}, - sycl::range<1>{32}}; - - Queue.submit([&](sycl::handler &cgh) { - // CHECK: {{[0-9]+}}|Construct accessor|[[USERID1]]|[[ACCID1:.*]]|2014|1025|{{.*}}sub_buffer.cpp:[[# @LINE + 1]]:34 - auto Accessor1 = SubBuffer.get_access(cgh); - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID1]]|[[BEID1:.*]] - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID1]]|[[BEID2:.*]] - cgh.parallel_for( - sycl::range<1>{32}, [=](sycl::id<1> WIid) { - Accessor1[WIid] = static_cast(WIid.get(0)); - }); - }); - // CHECK: {{[0-9]+}}|Construct accessor|[[USERID1]]|[[ACCID2:.*]]|2018|1024|{{.*}}sub_buffer.cpp:[[# @LINE + 1]]:25 - sycl::host_accessor Accessor1(Buffer1, sycl::read_only); - for (size_t I = 32; I < 64; ++I) { - if (Accessor1[I] != I - 32) { - std::cout << "The result is incorrect for element: " << I - << " , expected: " << I - 32 << " , got: " << Accessor1[I] - << std::endl; - MismatchFound = true; - } - } - } - - return MismatchFound; -} -// CHECK:{{[0-9]+}}|Release buffer|[[USERID1]]|[[BEID1]] -// CHECK:{{[0-9]+}}|Release buffer|[[USERID1]]|[[BEID2]] -// CHECK:{{[0-9]+}}|Destruct buffer|[[USERID1]] -#endif diff --git a/sycl/test-e2e/XPTI/buffer/use_host_ptr.cpp b/sycl/test-e2e/XPTI/buffer/use_host_ptr.cpp deleted file mode 100644 index 23e0f2e44ff80..0000000000000 --- a/sycl/test-e2e/XPTI/buffer/use_host_ptr.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// REQUIRES: xptifw, opencl -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -o %t.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.out | FileCheck %s - -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else - -#include -#include -int main() { - bool MismatchFound = false; - sycl::queue Queue{}; - - int Array[4]; - { - sycl::range<1> NumOfWorkItems{4}; - // CHECK:{{[0-9]+}}|Create buffer|[[USERID1:0x[0-9,a-f,x]+]]|0x{{.*}}|{{i(nt)*}}|4|1|{4,0,0}|{{.*}}use_host_ptr.cpp:[[# @LINE + 1]]:26 - sycl::buffer Buffer1(Array, NumOfWorkItems, - {sycl::property::buffer::use_host_ptr()}); - - // CHECK:{{[0-9]+}}|Associate buffer|[[USERID1]]|[[BEID1:.*]] - Queue.submit([&](sycl::handler &cgh) { - // Get write only access to the buffer on a device. - auto Accessor1 = Buffer1.get_access(cgh); - // Execute kernel. - cgh.parallel_for(NumOfWorkItems, [=](sycl::id<1> WIid) { - Accessor1[WIid] = static_cast(WIid.get(0)); - }); - }); - } - - // Check the results. - for (size_t I = 0; I < 4; ++I) { - if (Array[I] != I) { - std::cout << "The result is incorrect for element: " << I - << " , expected: " << I << " , got: " << Array[I] << std::endl; - MismatchFound = true; - } - } - - return MismatchFound; -} -// CHECK:{{[0-9]+}}|Release buffer|[[USERID1]]|[[BEID1]] -// CHECK:{{[0-9]+}}|Destruct buffer|[[USERID1]] -#endif diff --git a/sycl/test-e2e/XPTI/image/accessors.cpp b/sycl/test-e2e/XPTI/image/accessors.cpp deleted file mode 100644 index 80caefa175cd6..0000000000000 --- a/sycl/test-e2e/XPTI/image/accessors.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// REQUIRES: xptifw, opencl -// REQUIRES: aspect-ext_intel_legacy_image -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -o %t.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.out | FileCheck %s - -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else - -#include -#include - -using namespace sycl::access; - -int main() { - sycl::queue Q{}; - - /* Unsampled images */ - { - // CHECK:{{[0-9]+}}|Create unsampled image|[[UIMGID:[0-9,a-f,x]+]]|0x{{[0-9,a-f]+}}|1|{3,0,0}|7|{{.*}}accessors.cpp:[[# @LINE + 1]]:30 - sycl::unsampled_image<1> UImg(sycl::image_format::r32b32g32a32_uint, 3); - - Q.submit([&](sycl::handler &CGH) { - // CHECK:{{[0-9]+}}|Construct unsampled image accessor|[[UIMGID]]|0x{{[0-9,a-f]+}}|1|1024|{{.*}}vec{{.*}}|16|{{.*}}accessors.cpp:[[# @LINE + 1]]:22 - auto A1 = UImg.get_access(CGH); - }); - - Q.submit([&](sycl::handler &CGH) { - // CHECK:{{[0-9]+}}|Construct unsampled image accessor|[[UIMGID]]|0x{{[0-9,a-f]+}}|1|1025|{{.*}}vec{{.*}}|16|{{.*}}accessors.cpp:[[# @LINE + 1]]:22 - auto A1 = UImg.get_access(CGH); - }); - - // CHECK:{{[0-9]+}}|Construct host unsampled image accessor|[[UIMGID]]|0x{{[0-9,a-f]+}}|1024|{{.*}}vec{{.*}}|16|{{.*}}accessors.cpp:[[# @LINE + 1]]:22 - { auto HA = UImg.get_host_access(); } - // CHECK:{{[0-9]+}}|Construct host unsampled image accessor|[[UIMGID]]|0x{{[0-9,a-f]+}}|1025|{{.*}}vec{{.*}}|16|{{.*}}accessors.cpp:[[# @LINE + 1]]:22 - { auto HA = UImg.get_host_access(); } - // CHECK:{{[0-9]+}}|Construct host unsampled image accessor|[[UIMGID]]|0x{{[0-9,a-f]+}}|1026|{{.*}}vec{{.*}}|8|{{.*}}accessors.cpp:[[# @LINE + 1]]:22 - { auto HA = UImg.get_host_access(); } - } - // CHECK:{{[0-9]+}}|Destruct image|[[UIMGID]] - - /* Sampled images */ - { - constexpr size_t SampledImgElemCount = 3; - int16_t SampledImgData[4 * SampledImgElemCount] = {0}; - sycl::image_sampler Sampler{sycl::addressing_mode::repeat, - sycl::coordinate_normalization_mode::normalized, - sycl::filtering_mode::linear}; - - // CHECK:{{[0-9]+}}|Create sampled image|[[SIMGID:[0-9,a-f,x]+]]|0x{{[0-9,a-f]+}}|1|{3,0,0}|3|4403|1|4417|{{.*}}accessors.cpp:[[# @LINE + 1]]:28 - sycl::sampled_image<1> SImg(SampledImgData, - sycl::image_format::r16g16b16a16_sint, Sampler, - SampledImgElemCount); - - Q.submit([&](sycl::handler &CGH) { - // CHECK:{{[0-9]+}}|Construct sampled image accessor|[[SIMGID]]|0x{{[0-9,a-f]+}}|1|{{.*}}vec{{.*}}|16|{{.*}}accessors.cpp:[[# @LINE + 2]]:16 - auto A1 = - SImg.get_access(CGH); - }); - - // CHECK:{{[0-9]+}}|Construct host sampled image accessor|[[SIMGID]]|0x{{[0-9,a-f]+}}|{{.*}}vec{{.*}}|16|{{.*}}accessors.cpp:[[# @LINE + 1]]:22 - { auto HA = SImg.get_host_access(); } - // CHECK:{{[0-9]+}}|Construct host sampled image accessor|[[SIMGID]]|0x{{[0-9,a-f]+}}|{{.*}}vec{{.*}}|8|{{.*}}accessors.cpp:[[# @LINE + 1]]:22 - { auto HA = SImg.get_host_access(); } - } - // CHECK:{{[0-9]+}}|Destruct image|[[SIMGID]] - - return 0; -} -#endif diff --git a/sycl/test-e2e/XPTI/kernel/basic.cpp b/sycl/test-e2e/XPTI/kernel/basic.cpp deleted file mode 100644 index 9075d2c2f52c8..0000000000000 --- a/sycl/test-e2e/XPTI/kernel/basic.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// REQUIRES: xptifw, opencl -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -O2 -o %t.opt.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.opt.out | FileCheck %s --check-prefixes=CHECK,CHECK-OPT -// RUN: %{build} -fno-sycl-dead-args-optimization -o %t.noopt.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.noopt.out | FileCheck %s --check-prefixes=CHECK,CHECK-NOOPT - -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else - -#include -#include -#include - -using namespace sycl::access; -constexpr sycl::specialization_id int_id(42); - -class Functor1 { -public: - Functor1(short X_, - sycl::accessor &Acc_) - : X(X_), Acc(Acc_) {} - - void operator()() const { Acc[0] += X; } - -private: - short X; - sycl::accessor Acc; -}; - -class Functor2 { -public: - Functor2(short X_, - sycl::accessor &Acc_) - : X(X_), Acc(Acc_) {} - - void operator()(sycl::id<1> id = 0) const { Acc[id] += X; } - -private: - short X; - sycl::accessor Acc; -}; - -int main() { - bool MismatchFound = false; - sycl::queue Queue{}; - - // CHECK:{{[0-9]+}}|Create buffer|[[BUFFERID:[0-9,a-f,x]+]]|0x0|{{i(nt)*}}|4|1|{5,0,0}|{{.*}}.cpp:[[# @LINE + 1]]:24 - sycl::buffer Buf(5); - sycl::range<1> Range{Buf.size()}; - sycl::nd_range<1> NDRange{Buf.size(), Buf.size()}; - short Val = Buf.size(); - auto PtrDevice = sycl::malloc_device(7, Queue); - auto PtrShared = sycl::malloc_shared(8, Queue); - Queue - .submit([&](sycl::handler &cgh) { - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID1:.+]]|2014|1026|{{.*}}.cpp:[[# @LINE + 1]]:23 - auto A1 = Buf.get_access(cgh); - // CHECK: {{[0-9]+}}|Construct accessor|0x0|[[ACCID2:.*]]|2016|1026|{{.*}}.cpp:[[# @LINE + 1]]:38 - sycl::local_accessor A2(Range, cgh); - cgh.parallel_for(NDRange, [=](sycl::nd_item<1> ndi) { - auto gid = ndi.get_global_id(0); - // CHECK-OPT: arg0 : {1, {{[0-9,a-f,x]+}}, 2, 0} - int h = Val; - // CHECK-OPT: arg1 : {1, {{.*}}0, 20, 1} - A2[gid] = h; - // CHECK-OPT: arg2 : {0, [[ACCID1]], 4062, 2} - // CHECK-OPT: arg3 : {1, [[ACCID1]], 8, 3} - A1[gid] = A2[gid]; - // CHECK-OPT: arg4 : {3, {{.*}}, 8, 4} - PtrDevice[gid] = gid; - // CHECK-OPT: arg5 : {3, {{.*}}, 8, 5} - PtrShared[gid] = PtrDevice[gid]; - }); - }) - .wait(); - - // CHECK: Wait begin|{{.*}}.cpp:[[# @LINE + 2]]:9 - // CHECK: Wait end|{{.*}}.cpp:[[# @LINE + 1]]:9 - Queue.wait(); - - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID3:.*]]|2018|1024|{{.*}}.cpp:[[# @LINE + 1]]:25 - { sycl::host_accessor HA(Buf, sycl::read_only); } - - Queue.submit([&](sycl::handler &cgh) { - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID4:.+]]|2014|1026|{{.*}}.cpp:[[# @LINE + 1]]:20 - auto Acc = Buf.get_access(cgh); - Functor1 F(Val, Acc); - // CHECK-OPT: Node create|{{.*}}Functor1|{{.*}}.cpp:[[# @LINE - 4 ]]:9|{1, 1, 1}, {0, 0, 0}, {0, 0, 0}, 3 - // CHECK-NOOPT: Node create|{{.*}}Functor1|{{.*}}.cpp:[[# @LINE - 5 ]]:9|{1, 1, 1}, {0, 0, 0}, {0, 0, 0}, 5 - cgh.single_task(F); - // CHECK-OPT: arg0 : {1, {{[0-9,a-f,x]+}}, 2, 0} - // CHECK-OPT: arg1 : {0, [[ACCID4]], 4062, 1} - // CHECK-OPT: arg2 : {1, [[ACCID4]], 8, 2} - }); - - Queue.submit([&](sycl::handler &cgh) { - // CHECK: {{[0-9]+}}|Construct accessor|[[BUFFERID]]|[[ACCID5:.+]]|2014|1026|{{.*}}.cpp:[[# @LINE + 1]]:20 - auto Acc = Buf.get_access(cgh); - Functor2 F(Val, Acc); - // CHECK-OPT: Node create|{{.*}}Functor2|{{.*}}.cpp:[[# @LINE - 4 ]]:9|{5, 1, 1}, {0, 0, 0}, {0, 0, 0}, 3 - // CHECK-NOOPT: Node create|{{.*}}Functor2|{{.*}}.cpp:[[# @LINE - 5 ]]:9|{5, 1, 1}, {0, 0, 0}, {0, 0, 0}, 5 - cgh.parallel_for(Range, F); - // CHECK-OPT: arg0 : {1, {{[0-9,a-f,x]+}}, 2, 0} - // CHECK-OPT: arg1 : {0, [[ACCID5]], 4062, 1} - // CHECK-OPT: arg2 : {1, [[ACCID5]], 8, 2} - }); - - return 0; -} -#endif diff --git a/sycl/test-e2e/XPTI/kernel/content.cpp b/sycl/test-e2e/XPTI/kernel/content.cpp deleted file mode 100644 index 67b9f48846455..0000000000000 --- a/sycl/test-e2e/XPTI/kernel/content.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// REQUIRES: xptifw, opencl -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib %shared_lib %fPIC %cxx_std_optionc++17 -o %t_collector.dll -// RUN: %{build} -Wno-error=deprecated-declarations -O2 -o %t.opt.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.opt.out | FileCheck %s --check-prefix=CHECK-OPT -// RUN: %{build} -Wno-error=deprecated-declarations -fno-sycl-dead-args-optimization -o %t.noopt.out -// RUN: env XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher XPTI_SUBSCRIBERS=%t_collector.dll %{run} %t.noopt.out | FileCheck %s --check-prefix=CHECK-NOOPT - -#ifdef XPTI_COLLECTOR - -#include "../Inputs/memory_info_collector.cpp" - -#else -#include -#include -#include -#include -#include - -using namespace sycl; -int main() { - std::array input; - std::iota(input.begin(), input.end(), 0); - buffer valuesBuf{input}; - - // Buffers with just 1 element to get the reduction results - int sumResult = 0; - buffer sumBuf{&sumResult, 1}; - queue myQueue; - myQueue.submit([&](handler &cgh) { - auto inputValues = valuesBuf.get_access(cgh); - - auto sumR = reduction(sumBuf, cgh, plus<>()); - // Reduction kernel is used, strategy and hence number of kernel arguments - // is hw-dependent. - // CHECK-OPT:Node create|{{.*}}reduction{{.*}}test1{{.*}}|{{.*}}.cpp:[[# @LINE - 6 ]]:11|{{{.*}}, 1, 1}, {{{.*}}, 1, 1}, {0, 0, 0}, {{1.*}} - // CHECK-NOOPT:Node create|{{.*}}reduction{{.*}}test1{{.*}}|{{.*}}.cpp:[[# @LINE - 7 ]]:11|{{{.*}}, 1, 1}, {{{.*}}, 1, 1}, {0, 0, 0}, {{2.*}} - cgh.parallel_for( - range<1>{1024}, sumR, - [=](id<1> idx, auto &sum) { sum += inputValues[idx]; }); - }); - - // sumBuf contains the reduction results once the kernel completes - assert(sumBuf.get_host_access()[0] == 523776); - - { - buffer in_buf(input.data(), input.size()); - buffer out_buf(input.size()); - myQueue.submit([&](handler &cgh) { - auto in = in_buf.template get_access(cgh); - auto out = out_buf.template get_access(cgh); - // CHECK-OPT:Node create|{{.*}}test2{{.*}}|{{.*}}.cpp:[[# @LINE - 3 ]]:13|{128, 4, 2}, {32, 2, 1}, {16, 1, 0}, 2 - // CHECK-NOOPT:Node create|{{.*}}test2{{.*}}|{{.*}}.cpp:[[# @LINE - 4 ]]:13|{128, 4, 2}, {32, 2, 1}, {16, 1, 0}, 8 - cgh.parallel_for( - nd_range<3>({128, 4, 2}, {32, 2, 1}, {16, 1, 0}), [=](nd_item<3> it) { - auto sg = it.get_sub_group(); - joint_exclusive_scan( - sg, in.template get_multi_ptr(), - in.template get_multi_ptr() + - sg.get_local_id(), - out.template get_multi_ptr(), - std::plus<>{}); - }); - }); - } -} -#endif diff --git a/sycl/test-e2e/XPTI/mem_alloc_events.inc b/sycl/test-e2e/XPTI/mem_alloc_events.inc deleted file mode 100644 index 16acbf078a50f..0000000000000 --- a/sycl/test-e2e/XPTI/mem_alloc_events.inc +++ /dev/null @@ -1,37 +0,0 @@ -#ifdef XPTI_COLLECTOR - -#include "Inputs/memory_info_collector.cpp" - -#else - -#include -#include -#include - -int main() { - sycl::queue Q{sycl::default_selector_v}; - - sycl::buffer Buf{sycl::range{100}}; - std::vector Vec; - Vec.resize(100); - std::iota(Vec.begin(), Vec.end(), 0); - - Q.submit([&](sycl::handler &CGH) { - sycl::accessor Acc{Buf, CGH, sycl::write_only}; - CGH.copy(Vec.data(), Acc); - }); - - Q.submit([&](sycl::handler &CGH) { - sycl::accessor Acc{Buf, CGH, sycl::write_only}; - CGH.single_task([=]() { Acc[0] = 42; }); - }); - - Q.wait(); - - sycl::host_accessor Acc{Buf}; - assert(Acc[0] == 42); - - return 0; -} - -#endif diff --git a/sycl/test-e2e/XPTI/mem_alloc_events_linux.cpp b/sycl/test-e2e/XPTI/mem_alloc_events_linux.cpp deleted file mode 100644 index 82a878acd0551..0000000000000 --- a/sycl/test-e2e/XPTI/mem_alloc_events_linux.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// REQUIRES: xptifw, level_zero, gpu, linux -// RUN: %clangxx %s -DXPTI_COLLECTOR -DXPTI_CALLBACK_API_EXPORTS %xptifw_lib -shared -fPIC -std=c++17 -o %t_collector.so -// RUN: %{build} -o %t.out -// RUN: env XPTI_TRACE_ENABLE=1 env XPTI_FRAMEWORK_DISPATCHER=%xptifw_dispatcher env XPTI_SUBSCRIBERS=%t_collector.so %{run} %t.out | FileCheck %s - -#include "mem_alloc_events.inc" - -// CHECK: xptiTraceInit: Stream Name = sycl.experimental.mem_alloc -// CHECK: Mem Alloc Begin : mem_obj_handle:{{.*}}|alloc_pointer:0x0|alloc_size:400 -// CHECK: Mem Alloc End : mem_obj_handle:{{.*}}|alloc_pointer:{{.*}}|alloc_size:400 -// CHECK: Mem Release Begin : mem_obj_handle:{{.*}}|alloc_pointer:{{.*}}|alloc_size:0 -// CHECK: Mem Release End : mem_obj_handle:{{.*}}|alloc_pointer:{{.*}}|alloc_size:0 diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index 23a1ec5692afd..aabb93f6124cb 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -76,10 +76,6 @@ "LIBCLANG_CODE_COMPLETION_LOGGING", ] -# Names of the Release and Debug versions of the XPTIFW library -XPTIFW_RELEASE = "xptifw" -XPTIFW_DEBUG = "xptifwd" - # Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it. if platform.system() != "Windows": possibly_dangerous_env_vars.append("INCLUDE") @@ -591,45 +587,6 @@ def open_check_file(file_name): if config.run_launcher: config.substitutions.append(("%e2e_tests_root", config.test_source_root)) -# TODO properly set XPTIFW include and runtime dirs -xptifw_lib_dir = os.path.join(config.dpcpp_root_dir, "lib") -xptifw_dispatcher = "" -if platform.system() == "Linux": - xptifw_dispatcher = os.path.join(xptifw_lib_dir, "libxptifw.so") -elif platform.system() == "Windows": - # Use debug version of xptifw library if tests are built with \MDd. - xptifw_dispatcher_name = ( - XPTIFW_DEBUG if "/MDd" in config.cxx_flags else XPTIFW_RELEASE - ) - xptifw_dispatcher = os.path.join( - config.dpcpp_root_dir, "bin", xptifw_dispatcher_name + ".dll" - ) -xptifw_includes = os.path.join(config.dpcpp_root_dir, "include") -if os.path.exists(xptifw_lib_dir) and os.path.exists( - os.path.join(xptifw_includes, "xpti", "xpti_trace_framework.h") -): - config.available_features.add("xptifw") - config.substitutions.append(("%xptifw_dispatcher", xptifw_dispatcher)) - if cl_options: - # Use debug version of xptifw library if tests are built with \MDd. - xptifw_lib_name = XPTIFW_DEBUG if "/MDd" in config.cxx_flags else XPTIFW_RELEASE - xptifw_lib = os.path.normpath( - os.path.join(xptifw_lib_dir, xptifw_lib_name + ".lib") - ) - config.substitutions.append( - ( - "%xptifw_lib", - f" {xptifw_lib} /I{xptifw_includes} ", - ) - ) - else: - config.substitutions.append( - ( - "%xptifw_lib", - " -L{} -lxptifw -I{} ".format(xptifw_lib_dir, xptifw_includes), - ) - ) - # Tools for which we add a corresponding feature when available. feature_tools = [ ToolSubst("llvm-spirv", unresolved="ignore"), diff --git a/sycl/test/abi/layout_accessors_device.cpp b/sycl/test/abi/layout_accessors_device.cpp index 49f4817de8a91..92667bfe1ce11 100644 --- a/sycl/test/abi/layout_accessors_device.cpp +++ b/sycl/test/abi/layout_accessors_device.cpp @@ -20,7 +20,7 @@ SYCL_EXTERNAL void hostAcc(accessor (base) (empty) // CHECK-NEXT: 0 | class sycl::detail::OwnerLessBase > (base) (empty) // CHECK-NEXT: 0 | class sycl::detail::AccessorImplDevice<1> impl -// CHECK-NEXT: 0 | class sycl::id<1> Offset +// CHECK-NEXT: 0 | class sycl::id<> Offset // CHECK-NEXT: 0 | class sycl::detail::array<> (base) // CHECK-NEXT: 0 | size_t[1] common_array // CHECK-NEXT: 8 | class sycl::range<> AccessRange @@ -52,7 +52,7 @@ SYCL_EXTERNAL void hostAcc(accessor MemRange // CHECK-NEXT: 8 | class sycl::detail::array<> (base) // CHECK-NEXT: 8 | size_t[1] common_array -// CHECK-NEXT: 16 | class sycl::id<1> Offset +// CHECK-NEXT: 16 | class sycl::id<> Offset // CHECK-NEXT: 16 | class sycl::detail::array<> (base) // CHECK-NEXT: 16 | size_t[1] common_array // CHECK-NEXT: 24 | ConcreteASPtrType MData @@ -74,7 +74,7 @@ SYCL_EXTERNAL void hostAcc(local_accessor Acc) { // CHECK-NEXT: 8 | class sycl::range<> MemRange // CHECK-NEXT: 8 | class sycl::detail::array<> (base) // CHECK-NEXT: 8 | size_t[1] common_array -// CHECK-NEXT: 16 | class sycl::id<1> Offset +// CHECK-NEXT: 16 | class sycl::id<> Offset // CHECK-NEXT: 16 | class sycl::detail::array<> (base) // CHECK-NEXT: 16 | size_t[1] common_array // CHECK-NEXT: 24 | ConcreteASPtrType MData diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 26a129e33ef85..447590ef7799e 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3179,10 +3179,6 @@ _ZN4sycl3_V16detail10waitEventsESt6vectorINS0_5eventESaIS3_EE _ZN4sycl3_V16detail11image_plain14set_write_backEb _ZN4sycl3_V16detail11image_plain23set_final_data_internalERKSt8functionIFvRKS3_IFvPvEEEE _ZN4sycl3_V16detail11image_plain23set_final_data_internalEv -_ZN4sycl3_V16detail11image_plain34sampledImageDestructorNotificationEPv -_ZN4sycl3_V16detail11image_plain35sampledImageConstructorNotificationERKNS1_13code_locationEPvPKvjPmNS0_12image_formatERKNS0_13image_samplerE -_ZN4sycl3_V16detail11image_plain36unsampledImageDestructorNotificationEPv -_ZN4sycl3_V16detail11image_plain37unsampledImageConstructorNotificationERKNS1_13code_locationEPvPKvjPmNS0_12image_formatE _ZN4sycl3_V16detail11image_plainC1ENS0_19image_channel_orderENS0_18image_channel_typeERKNS0_5rangeILi3EEERKNS5_ILi2EEESt10unique_ptrINS1_19SYCLMemObjAllocatorESt14default_deleteISD_EEhRKNS0_13property_listE _ZN4sycl3_V16detail11image_plainC1ENS0_19image_channel_orderENS0_18image_channel_typeERKNS0_5rangeILi3EEESt10unique_ptrINS1_19SYCLMemObjAllocatorESt14default_deleteISA_EEhRKNS0_13property_listE _ZN4sycl3_V16detail11image_plainC1EP7_cl_memRKNS0_7contextENS0_5eventESt10unique_ptrINS1_19SYCLMemObjAllocatorESt14default_deleteISA_EEh @@ -3220,7 +3216,6 @@ _ZN4sycl3_V16detail11sincos_implEdPd _ZN4sycl3_V16detail11sincos_implEfPf _ZN4sycl3_V16detail12buffer_plain14deleteAccPropsERKNS1_16PropWithDataKindE _ZN4sycl3_V16detail12buffer_plain14set_write_backEb -_ZN4sycl3_V16detail12buffer_plain23constructorNotificationERKNS1_13code_locationEPvPKvS8_jjPm _ZN4sycl3_V16detail12buffer_plain23set_final_data_internalERKSt8functionIFvRKS3_IFvPvEEEE _ZN4sycl3_V16detail12buffer_plain23set_final_data_internalEv _ZN4sycl3_V16detail12buffer_plain30addOrReplaceAccessorPropertiesERKNS0_13property_listE @@ -3301,7 +3296,6 @@ _ZN4sycl3_V16detail22has_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6devi _ZN4sycl3_V16detail22has_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EERKS5_INS0_9kernel_idESaISB_EENS0_12bundle_stateE _ZN4sycl3_V16detail22reduGetPreferredWGSizeERSt10shared_ptrINS1_10queue_implEEm _ZN4sycl3_V16detail22removeDuplicateDevicesERKSt6vectorINS0_6deviceESaIS3_EE -_ZN4sycl3_V16detail23constructorNotificationEPvS2_NS0_6access6targetENS3_4modeERKNS1_13code_locationE _ZN4sycl3_V16detail24find_device_intersectionERKSt6vectorINS0_13kernel_bundleILNS0_12bundle_stateE1EEESaIS5_EE _ZN4sycl3_V16detail26isDeviceGlobalUsedInKernelEPKv _ZN4sycl3_V16detail27getPixelCoordLinearFiltModeENS0_3vecIfLi4EEENS0_15addressing_modeENS0_5rangeILi3EEERS3_ @@ -3319,10 +3313,8 @@ _ZN4sycl3_V16detail30UnsampledImageAccessorBaseHostC2ENS0_5rangeILi3EEENS0_6acce _ZN4sycl3_V16detail33enable_ext_oneapi_default_contextEb _ZN4sycl3_V16detail33reduGetMaxNumConcurrentWorkGroupsESt10shared_ptrINS1_10queue_implEE _ZN4sycl3_V16detail34addHostSampledImageAccessorAndWaitEPNS1_28SampledImageAccessorImplHostE -_ZN4sycl3_V16detail35sampledImageConstructorNotificationEPvS2_RKSt8optionalINS0_12image_targetEEPKvjRKNS1_13code_locationE _ZN4sycl3_V16detail36addHostUnsampledImageAccessorAndWaitEPNS1_30UnsampledImageAccessorImplHostE _ZN4sycl3_V16detail36get_empty_interop_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EE -_ZN4sycl3_V16detail37unsampledImageConstructorNotificationEPvS2_RKSt8optionalINS0_12image_targetEENS0_6access4modeEPKvjRKNS1_13code_locationE _ZN4sycl3_V16detail6OSUtil10getDirNameB5cxx11EPKc _ZN4sycl3_V16detail6OSUtil11alignedFreeEPv _ZN4sycl3_V16detail6OSUtil12alignedAllocEmm diff --git a/sycl/test/gdb/accessors-device.cpp b/sycl/test/gdb/accessors-device.cpp index d0ac41b0d2934..303ee80b4b364 100644 --- a/sycl/test/gdb/accessors-device.cpp +++ b/sycl/test/gdb/accessors-device.cpp @@ -17,7 +17,7 @@ int main() { // AccessorImplDevice must have MemRange and Offset fields // CHECK: 0 | class sycl::detail::AccessorImplDevice<1> -// CHECK-NEXT: 0 | class sycl::id<1> Offset +// CHECK-NEXT: 0 | class sycl::id<> Offset // CHECK-NEXT: 0 | class sycl::detail::array<> (base) // CHECK-NEXT: 0 | size_t[1] common_array // CHECK-NEXT: 8 | class sycl::range<> AccessRange @@ -35,7 +35,7 @@ int main() { // CHECK-NEXT: 0 | class sycl::detail::accessor_common (base) (empty) // CHECK-NEXT: 0 | class sycl::detail::OwnerLessBase > (base) (empty) // CHECK-NEXT: 0 | class sycl::detail::AccessorImplDevice<1> impl -// CHECK-NEXT: 0 | class sycl::id<1> Offset +// CHECK-NEXT: 0 | class sycl::id<> Offset // CHECK-NEXT: 0 | class sycl::detail::array<> (base) // CHECK-NEXT: 0 | size_t[1] common_array // CHECK-NEXT: 8 | class sycl::range<> AccessRange diff --git a/sycl/test/gdb/printers.cpp b/sycl/test/gdb/printers.cpp index 5d31ae98e87a2..b09e23cc00fb2 100644 --- a/sycl/test/gdb/printers.cpp +++ b/sycl/test/gdb/printers.cpp @@ -68,7 +68,7 @@ sycl::range<1> r(3); // CHECK: 24 | element_type * _M_ptr // DEVICE: 0 | class sycl::detail::AccessorImplDevice<1> -// DEVICE: 0 | class sycl::id<1> Offset +// DEVICE: 0 | class sycl::id<> Offset // DEVICE: 8 | class sycl::range<> AccessRange // DEVICE: 16 | class sycl::range<> MemRange diff --git a/sycl/tools/CMakeLists.txt b/sycl/tools/CMakeLists.txt index ed11e98b1f9c8..ac3f7b4d41ea7 100644 --- a/sycl/tools/CMakeLists.txt +++ b/sycl/tools/CMakeLists.txt @@ -6,12 +6,3 @@ function(link_llvm_libs target) endfunction() add_subdirectory(sycl-ls) - -if (SYCL_ENABLE_XPTI_TRACING) - if (UNIX) - add_subdirectory(sycl-prof) - add_subdirectory(sycl-trace) - add_subdirectory(sycl-sanitize) - endif() -endif() - diff --git a/sycl/tools/sycl-prof/CMakeLists.txt b/sycl/tools/sycl-prof/CMakeLists.txt deleted file mode 100644 index 09586c1b857ca..0000000000000 --- a/sycl/tools/sycl-prof/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -add_executable(sycl-prof - main.cpp -) - -target_include_directories(sycl-prof PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../xpti_helpers/" -) - -link_llvm_libs(sycl-prof - LLVMSupport -) - -target_compile_options(sycl-prof PRIVATE -fno-exceptions -fno-rtti) - -add_library(sycl_profiler_collector SHARED collector.cpp) -target_compile_definitions(sycl_profiler_collector PRIVATE XPTI_CALLBACK_API_EXPORTS) -target_link_libraries(sycl_profiler_collector PRIVATE xptifw) -if (TARGET OpenCL-Headers) - target_link_libraries(sycl_profiler_collector PRIVATE OpenCL-Headers) -endif() -target_include_directories(sycl_profiler_collector PRIVATE - "${sycl_inc_dir}" - "${sycl_src_dir}" -) - -add_dependencies(sycl-prof sycl_profiler_collector) -add_dependencies(sycl-toolchain sycl-prof) - -include(GNUInstallDirs) -install(TARGETS sycl-prof sycl_profiler_collector - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sycl-prof - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-prof - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-prof -) diff --git a/sycl/tools/sycl-prof/collector.cpp b/sycl/tools/sycl-prof/collector.cpp deleted file mode 100644 index 7afca930b9194..0000000000000 --- a/sycl/tools/sycl-prof/collector.cpp +++ /dev/null @@ -1,181 +0,0 @@ -//==-------------- collector.cpp -------------------------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include "writer.hpp" -#include "xpti/xpti_data_types.h" - -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace chrono = std::chrono; - -Writer *GWriter = nullptr; - -struct Measurements { - size_t TID; - size_t PID; - size_t TimeStamp; -}; - -unsigned long process_id() { return static_cast(getpid()); } - -static Measurements measure() { - size_t TID = std::hash{}(std::this_thread::get_id()); - size_t PID = process_id(); - auto Now = chrono::high_resolution_clock::now(); - size_t TS = chrono::time_point_cast(Now) - .time_since_epoch() - .count(); - - return Measurements{TID, PID, TS}; -} - -XPTI_CALLBACK_API void apiBeginEndCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *, - uint64_t /*Instance*/, - const void *UserData); -XPTI_CALLBACK_API void urBeginEndCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *, - uint64_t /*Instance*/, - const void *UserData); -XPTI_CALLBACK_API void taskBeginEndCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *, - uint64_t /*Instance*/, - const void *UserData); -XPTI_CALLBACK_API void waitBeginEndCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *, - uint64_t /*Instance*/, - const void *UserData); - -XPTI_CALLBACK_API void xptiTraceInit(unsigned int /*major_version*/, - unsigned int /*minor_version*/, - const char * /*version_str*/, - const char *StreamName) { - if (GWriter == nullptr) { - const char *ProfOutFile = std::getenv("SYCL_PROF_OUT_FILE"); - if (!ProfOutFile) - throw std::runtime_error( - "SYCL_PROF_OUT_FILE environment variable is not specified"); - GWriter = new JSONWriter(ProfOutFile); - GWriter->init(); - } - - std::string_view NameView{StreamName}; - if (NameView == "ur.call") { - uint8_t StreamID = xptiRegisterStream(StreamName); - xptiRegisterCallback(StreamID, xpti::trace_function_with_args_begin, - urBeginEndCallback); - xptiRegisterCallback(StreamID, xpti::trace_function_with_args_end, - urBeginEndCallback); - } else if (NameView == "sycl") { - uint8_t StreamID = xptiRegisterStream(StreamName); - xptiRegisterCallback(StreamID, xpti::trace_task_begin, - taskBeginEndCallback); - xptiRegisterCallback(StreamID, xpti::trace_task_end, taskBeginEndCallback); - xptiRegisterCallback(StreamID, xpti::trace_wait_begin, - waitBeginEndCallback); - xptiRegisterCallback(StreamID, xpti::trace_wait_end, waitBeginEndCallback); - xptiRegisterCallback(StreamID, xpti::trace_barrier_begin, - waitBeginEndCallback); - xptiRegisterCallback(StreamID, xpti::trace_barrier_end, - waitBeginEndCallback); - } else if (NameView == "sycl.experimental.level_zero.call") { - uint8_t StreamID = xptiRegisterStream(StreamName); - xptiRegisterCallback(StreamID, xpti::trace_function_begin, - apiBeginEndCallback); - xptiRegisterCallback(StreamID, xpti::trace_function_end, - apiBeginEndCallback); - } else if (NameView == "sycl.experimental.cuda.call") { - uint8_t StreamID = xptiRegisterStream(StreamName); - xptiRegisterCallback(StreamID, xpti::trace_function_begin, - apiBeginEndCallback); - xptiRegisterCallback(StreamID, xpti::trace_function_end, - apiBeginEndCallback); - } -} - -XPTI_CALLBACK_API void xptiTraceFinish(const char *) { GWriter->finalize(); } - -XPTI_CALLBACK_API void apiBeginEndCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *, - uint64_t /*Instance*/, - const void *UserData) { - auto [TID, PID, TS] = measure(); - if (TraceType == xpti::trace_function_begin) { - GWriter->writeBegin(static_cast(UserData), "API", PID, TID, - TS); - } else { - GWriter->writeEnd(static_cast(UserData), "API", PID, TID, TS); - } -} - -XPTI_CALLBACK_API void urBeginEndCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *, - uint64_t /*Instance*/, - const void *UserData) { - auto [TID, PID, TS] = measure(); - auto *Name = - static_cast(UserData)->function_name; - if (TraceType == xpti::trace_function_with_args_begin) { - GWriter->writeBegin(Name, "API", PID, TID, TS); - } else { - GWriter->writeEnd(Name, "API", PID, TID, TS); - } -} - -XPTI_CALLBACK_API void taskBeginEndCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *Event, - uint64_t /*Instance*/, - const void *) { - std::string_view Name = "unknown"; - - xpti::metadata_t *Metadata = xptiQueryMetadata(Event); - for (auto &Item : *Metadata) { - std::string_view Key{xptiLookupString(Item.first)}; - if (Key == "kernel_name" || Key == "memory_object") { - Name = xptiLookupString(Item.second); - } - } - - auto [TID, PID, TS] = measure(); - if (TraceType == xpti::trace_task_begin) { - GWriter->writeBegin(Name, "SYCL", PID, TID, TS); - } else { - GWriter->writeEnd(Name, "SYCL", PID, TID, TS); - } -} - -XPTI_CALLBACK_API void waitBeginEndCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *, - uint64_t /*Instance*/, - const void *UserData) { - auto [TID, PID, TS] = measure(); - if (TraceType == xpti::trace_wait_begin || - TraceType == xpti::trace_barrier_begin) { - GWriter->writeBegin(static_cast(UserData), "SYCL", PID, TID, - TS); - } else { - GWriter->writeEnd(static_cast(UserData), "SYCL", PID, TID, - TS); - } -} diff --git a/sycl/tools/sycl-prof/main.cpp b/sycl/tools/sycl-prof/main.cpp deleted file mode 100644 index ac511676332f6..0000000000000 --- a/sycl/tools/sycl-prof/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -//==------------ main.cpp - SYCL Profiler Tool -----------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include "launch.hpp" -#include "llvm/Support/CommandLine.h" - -#include -#include - -using namespace llvm; - -enum OutputFormatKind { JSON }; - -int main(int argc, char **argv, char *env[]) { - cl::opt OutputFormat( - "format", cl::desc("Set profiler output format:"), - cl::values( - // TODO performance summary - clEnumValN(JSON, "json", - "JSON file, compatible with chrome://tracing"))); - cl::opt OutputFilename("o", cl::desc("Specify output filename"), - cl::value_desc("filename"), cl::Required); - cl::opt TargetExecutable( - cl::Positional, cl::desc(""), cl::Required); - cl::list Argv(cl::ConsumeAfter, - cl::desc("...")); - - cl::ParseCommandLineOptions(argc, argv); - - std::vector NewEnv; - - { - size_t I = 0; - while (env[I] != nullptr) - NewEnv.emplace_back(env[I++]); - } - - std::string ProfOutFile = "SYCL_PROF_OUT_FILE=" + OutputFilename; - NewEnv.push_back(ProfOutFile); - NewEnv.push_back("XPTI_FRAMEWORK_DISPATCHER=libxptifw.so"); - NewEnv.push_back("XPTI_SUBSCRIBERS=libsycl_profiler_collector.so"); - NewEnv.push_back("XPTI_TRACE_ENABLE=1"); - NewEnv.push_back("ZE_ENABLE_TRACING_LAYER=1"); - NewEnv.push_back("UR_ENABLE_LAYERS=UR_LAYER_TRACING"); - - std::vector Args; - - Args.push_back(TargetExecutable); - std::copy(Argv.begin(), Argv.end(), std::back_inserter(Args)); - - int Err = launch(TargetExecutable, Args, NewEnv); - - if (Err) { - std::cerr << "Failed to launch target application. Error code " << Err - << "\n"; - return Err; - } - - return 0; -} diff --git a/sycl/tools/sycl-prof/writer.hpp b/sycl/tools/sycl-prof/writer.hpp deleted file mode 100644 index 070632c75567e..0000000000000 --- a/sycl/tools/sycl-prof/writer.hpp +++ /dev/null @@ -1,89 +0,0 @@ -//==----------------- writer.hpp -------------------------------------------==// -// -// 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 -#include -#include - -class Writer { -public: - virtual void init() = 0; - virtual void finalize() = 0; - virtual void writeBegin(std::string_view Name, std::string_view Category, - size_t PID, size_t TID, size_t TimeStamp) = 0; - virtual void writeEnd(std::string_view Name, std::string_view Category, - size_t PID, size_t TID, size_t TimeStamp) = 0; - virtual ~Writer() = default; -}; - -class JSONWriter : public Writer { -public: - explicit JSONWriter(const std::string &OutPath) : MOutFile(OutPath) {} - - void init() final { - std::lock_guard _{MWriteMutex}; - - MOutFile << "{\n"; - MOutFile << " \"traceEvents\": [\n"; - } - - void writeBegin(std::string_view Name, std::string_view Category, size_t PID, - size_t TID, size_t TimeStamp) override { - std::lock_guard _{MWriteMutex}; - - if (!MOutFile.is_open()) - return; - - MOutFile << "{\"name\": \"" << Name << "\", "; - MOutFile << "\"cat\": \"" << Category << "\", "; - MOutFile << "\"ph\": \"B\", "; - MOutFile << "\"pid\": \"" << PID << "\", "; - MOutFile << "\"tid\": \"" << TID << "\", "; - MOutFile << "\"ts\": \"" << TimeStamp << "\"},"; - MOutFile << std::endl; - } - - void writeEnd(std::string_view Name, std::string_view Category, size_t PID, - size_t TID, size_t TimeStamp) override { - std::lock_guard _{MWriteMutex}; - - if (!MOutFile.is_open()) - return; - - MOutFile << "{\"name\": \"" << Name << "\", "; - MOutFile << "\"cat\": \"" << Category << "\", "; - MOutFile << "\"ph\": \"E\", "; - MOutFile << "\"pid\": \"" << PID << "\", "; - MOutFile << "\"tid\": \"" << TID << "\", "; - MOutFile << "\"ts\": \"" << TimeStamp << "\"},"; - MOutFile << std::endl; - } - - void finalize() final { - std::lock_guard _{MWriteMutex}; - - if (!MOutFile.is_open()) - return; - - // add an empty element for not ending with '}, ]' - MOutFile << "{\"name\": \"\", \"cat\": \"\", \"ph\": \"\", \"pid\": \"\", " - "\"tid\": \"\", \"ts\": \"\"}\n"; - - MOutFile << "],\n"; - MOutFile << "\"displayTimeUnit\":\"ns\"\n}\n"; - MOutFile.close(); - } - - ~JSONWriter() { finalize(); } - -private: - std::mutex MWriteMutex; - std::ofstream MOutFile; -}; diff --git a/sycl/tools/sycl-sanitize/CMakeLists.txt b/sycl/tools/sycl-sanitize/CMakeLists.txt deleted file mode 100644 index 280b4760e302f..0000000000000 --- a/sycl/tools/sycl-sanitize/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -add_executable(sycl-sanitize main.cpp) - -target_include_directories(sycl-sanitize PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../xpti_helpers/" -) - -link_llvm_libs(sycl-sanitize - LLVMSupport -) - -target_compile_options(sycl-sanitize PRIVATE -fno-exceptions -fno-rtti) - -add_library(sycl_sanitizer_collector SHARED collector.cpp) -target_compile_definitions(sycl_sanitizer_collector PRIVATE XPTI_CALLBACK_API_EXPORTS) -target_link_libraries(sycl_sanitizer_collector PRIVATE xptifw) -target_link_libraries(sycl_sanitizer_collector PRIVATE UnifiedRuntime-Headers) -if (TARGET OpenCL-Headers) - target_link_libraries(sycl_sanitizer_collector PRIVATE OpenCL-Headers) -endif() - -target_include_directories(sycl_sanitizer_collector PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../xpti_helpers/" - "${sycl_inc_dir}" - "${sycl_src_dir}" -) - -add_dependencies(sycl-sanitize sycl_sanitizer_collector) -add_dependencies(sycl-toolchain sycl-sanitize) - -include(GNUInstallDirs) -install(TARGETS sycl-sanitize sycl_sanitizer_collector - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sycl-sanitize - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-sanitize - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-sanitize -) diff --git a/sycl/tools/sycl-sanitize/collector.cpp b/sycl/tools/sycl-sanitize/collector.cpp deleted file mode 100644 index 9ce6f1a58d79b..0000000000000 --- a/sycl/tools/sycl-sanitize/collector.cpp +++ /dev/null @@ -1,84 +0,0 @@ -//==-------------- collector.cpp -------------------------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -/// \file collector.cpp -/// The SYCL sanitizer collector intercepts PI calls to find memory leaks in -/// usages of USM pointers. - -#include "xpti/xpti_trace_framework.h" - -#include "usm_analyzer.hpp" - -#include -#include -#include -#include -#include -#include - -std::mutex IOMutex; - -XPTI_CALLBACK_API void tpCallback(uint16_t trace_type, - xpti::trace_event_data_t *parent, - xpti::trace_event_data_t *event, - uint64_t instance, const void *user_data); - -XPTI_CALLBACK_API void xptiTraceInit(unsigned int /*major_version*/, - unsigned int /*minor_version*/, - const char * /*version_str*/, - const char *StreamName) { - if (std::string_view(StreamName) == "ur.call") { - uint8_t StreamID = xptiRegisterStream(StreamName); - xptiRegisterCallback(StreamID, xpti::trace_function_with_args_begin, - tpCallback); - xptiRegisterCallback(StreamID, xpti::trace_function_with_args_end, - tpCallback); - auto &GS = USMAnalyzer::getInstance(); - GS.changeTerminationOnErrorState(true); - GS.printToErrorStream(); - } -} - -XPTI_CALLBACK_API void xptiTraceFinish(const char *StreamName) { - if (std::string_view(StreamName) == "ur.call") { - bool hadLeak = false; - auto &GS = USMAnalyzer::getInstance(); - if (GS.ActivePointers.size() > 0) { - hadLeak = true; - std::cerr << "Found " << GS.ActivePointers.size() - << " leaked memory allocations\n"; - for (const auto &Ptr : GS.ActivePointers) { - std::cerr << "Leaked pointer: " << std::hex << Ptr.first << "\n"; - std::cerr << " Location: " - << "function " << Ptr.second.Location.Function << " at " - << Ptr.second.Location.Source << ":" << std::dec - << Ptr.second.Location.Line << "\n"; - } - } - if (hadLeak) - exit(-1); - } -} - -XPTI_CALLBACK_API void tpCallback(uint16_t TraceType, - xpti::trace_event_data_t *, - xpti::trace_event_data_t *ObjectEvent, - uint64_t /*Instance*/, const void *UserData) { - auto &GS = USMAnalyzer::getInstance(); - GS.fillLastTracepointData(ObjectEvent); - - // Lock while we capture information - std::lock_guard Lock(IOMutex); - - const auto *Data = static_cast(UserData); - if (TraceType == xpti::trace_function_with_args_begin) { - GS.handlePreCall(Data); - } else if (TraceType == xpti::trace_function_with_args_end) { - GS.handlePostCall(Data); - } -} diff --git a/sycl/tools/sycl-sanitize/main.cpp b/sycl/tools/sycl-sanitize/main.cpp deleted file mode 100644 index 19e53f4c869e9..0000000000000 --- a/sycl/tools/sycl-sanitize/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -//==------------ main.cpp - SYCL Sanitizer Tool ----------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include "launch.hpp" -#include "llvm/Support/CommandLine.h" - -#include -#include - -using namespace llvm; - -int main(int argc, char **argv, char *env[]) { - cl::opt TargetExecutable( - cl::Positional, cl::desc(""), cl::Required); - cl::list Argv(cl::ConsumeAfter, - cl::desc("...")); - - cl::ParseCommandLineOptions(argc, argv); - - std::vector NewEnv; - - { - size_t I = 0; - while (env[I] != nullptr) - NewEnv.push_back(env[I++]); - } - - NewEnv.push_back("XPTI_FRAMEWORK_DISPATCHER=libxptifw.so"); - NewEnv.push_back("XPTI_SUBSCRIBERS=libsycl_sanitizer_collector.so"); - NewEnv.push_back("XPTI_TRACE_ENABLE=1"); - NewEnv.push_back("UR_ENABLE_LAYERS=UR_LAYER_TRACING"); - - std::vector Args; - - Args.push_back(TargetExecutable); - std::copy(Argv.begin(), Argv.end(), std::back_inserter(Args)); - - int Err = launch(TargetExecutable, Args, NewEnv); - - if (Err) { - std::cerr << "Failed to launch target application. Error code " << Err - << "\n"; - return Err; - } - - return 0; -} diff --git a/sycl/tools/sycl-trace/CMakeLists.txt b/sycl/tools/sycl-trace/CMakeLists.txt deleted file mode 100644 index ed1987f8137c9..0000000000000 --- a/sycl/tools/sycl-trace/CMakeLists.txt +++ /dev/null @@ -1,157 +0,0 @@ -add_executable(sycl-trace main.cpp) - -target_include_directories(sycl-trace PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../xpti_helpers/" -) - -target_compile_options(sycl-trace PRIVATE -fno-exceptions -fno-rtti) - -link_llvm_libs(sycl-trace - LLVMSupport -) - -if ("level_zero" IN_LIST SYCL_ENABLE_BACKENDS) - add_library(ze_trace_collector SHARED - ze_trace_collector.cpp - ) - set(EXTRA_TARGETS_TO_INSTALL - ze_trace_collector - ) - add_dependencies(sycl-trace ze_trace_collector) -endif() - -if ("cuda" IN_LIST SYCL_ENABLE_BACKENDS) - add_library(cuda_trace_collector SHARED - cuda_trace_collector.cpp - ) - set(EXTRA_TARGETS_TO_INSTALL - ${EXTRA_TARGETS_TO_INSTALL} - cuda_trace_collector - ) - add_dependencies(sycl-trace cuda_trace_collector) -endif() - -add_library(sycl_ur_trace_collector SHARED - collector.cpp - sycl_trace_collector.cpp - ur_trace_collector.cpp - verification_collector.cpp -) - -find_package(Python3 REQUIRED) - -# To get L0 loader -if ("level_zero" IN_LIST SYCL_ENABLE_BACKENDS) - target_link_libraries(ze_trace_collector PRIVATE LevelZeroLoader-Headers) - target_compile_definitions(ze_trace_collector PRIVATE SYCL_HAS_LEVEL_ZERO) - target_link_libraries(ze_trace_collector PRIVATE xptifw) - - add_custom_target(ze-pretty-printers - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ze_printers.def - ) - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/ze_printers.def - COMMAND ${Python3_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/generate_ze_pretty_printers.py - ${LEVEL_ZERO_INCLUDE_DIR}/ze_api.h - DEPENDS - ${LEVEL_ZERO_INCLUDE_DIR}/ze_api.h - ) - - add_custom_target(ze-api DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ze_api.def) - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/ze_api.def - COMMAND ${Python3_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/ze_api_generator.py - ${LEVEL_ZERO_INCLUDE_DIR}/ze_api.h - DEPENDS - ${LEVEL_ZERO_INCLUDE_DIR}/ze_api.h - ) - - add_dependencies(ze_trace_collector ze-api ze-pretty-printers) - target_compile_definitions(sycl_ur_trace_collector PRIVATE SYCL_HAS_LEVEL_ZERO) -endif() - -target_compile_definitions(sycl_ur_trace_collector PRIVATE XPTI_CALLBACK_API_EXPORTS) -target_link_libraries(sycl_ur_trace_collector PRIVATE xptifw) -if (TARGET OpenCL-Headers) - target_link_libraries(sycl_ur_trace_collector PRIVATE OpenCL-Headers) -endif() -target_link_libraries(sycl_ur_trace_collector PRIVATE UnifiedRuntime-Headers) - -target_include_directories(sycl_ur_trace_collector PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../xpti_helpers/" - "${sycl_inc_dir}" - "${sycl_src_dir}" - "${CMAKE_CURRENT_BINARY_DIR}" -) - -if(SYCL_BUILD_BACKEND_CUDA) - - find_package(CUDA 10.1 REQUIRED) - - target_compile_definitions(cuda_trace_collector PRIVATE USE_UR_CUDA) - - # The following two if's can be removed when FindCUDA -> FindCUDAToolkit. - # CUDA_CUPTI_INCLUDE_DIR -> CUDAToolkit_CUPTI_INCLUDE_DIR - include(FindCUDACupti) - if(NOT CUDA_CUPTI_INCLUDE_DIR) - find_cuda_cupti_include_dir() - endif() - # CUDA_cupti_LIBRARY -> CUDAToolkit_cupti_LIBRARY - if(NOT CUDA_cupti_LIBRARY) - find_cuda_cupti_library() - endif() - - target_include_directories(cuda_trace_collector - PRIVATE - ${CUDA_CUPTI_INCLUDE_DIR} - ) - - target_link_libraries(cuda_trace_collector - PRIVATE - cudadrv - ${CUDA_cupti_LIBRARY} - ) - - find_path(GEN_CUDA_META_H_DIR generated_cuda_meta.h PATHS - "${CUDA_TOOLKIT_ROOT_DIR}/extras/CUPTI/include" - "${CUDA_INCLUDE_DIRS}/../extras/CUPTI/include" - "${CUDA_INCLUDE_DIRS}" - NO_DEFAULT_PATH) - - if( EXISTS "${GEN_CUDA_META_H_DIR}/generated_cuda_meta.h" ) - add_custom_target(cuda-pretty-printers - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/cuda_printers.def) - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cuda_printers.def - COMMAND ${Python3_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/generate_cuda_pretty_printers.py - ${GEN_CUDA_META_H_DIR}/generated_cuda_meta.h - DEPENDS - ${GEN_CUDA_META_H_DIR}/generated_cuda_meta.h - ) - else() - message(WARNING "generated_cuda_meta.h not FOUND!") - message(WARNING "CUDA printer definitions cannot be generated.") - file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/cuda_printers.def") - add_custom_target(cuda-pretty-printers) - endif() - - add_dependencies(cuda_trace_collector cuda-pretty-printers) - target_link_libraries(cuda_trace_collector PRIVATE xptifw) - target_compile_definitions(sycl_ur_trace_collector PRIVATE USE_UR_CUDA) -endif() - -add_dependencies(sycl-trace sycl_ur_trace_collector) -add_dependencies(sycl-toolchain sycl-trace) - -include(GNUInstallDirs) -install(TARGETS sycl-trace sycl_ur_trace_collector ${EXTRA_TARGETS_TO_INSTALL} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sycl-trace - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-trace - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-trace -) - diff --git a/sycl/tools/sycl-trace/cuda_trace_collector.cpp b/sycl/tools/sycl-trace/cuda_trace_collector.cpp deleted file mode 100644 index 38851cf41a7a0..0000000000000 --- a/sycl/tools/sycl-trace/cuda_trace_collector.cpp +++ /dev/null @@ -1,124 +0,0 @@ -//==----------- cuda_trace_collector.cpp -----------------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -/// \file cuda_trace_collector.cpp -/// Routines to collect and print CUDA Driver API calls. - -#include "xpti/xpti_trace_framework.h" - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#define COLLECTOR_EXPORT_API __attribute__((__visibility__("default"))) - -int IndentationLevel = 0; - -static bool PrintVerbose = false; - -static std::string getResult(CUresult Res) { - const char *Err; - cuGetErrorName(Res, &Err); - - std::string ResultStr{Err}; - - if (PrintVerbose) { - const char *Desc; - cuGetErrorString(Res, &Desc); - ResultStr += " (" + std::string{Desc} + ")"; - } - - return ResultStr; -} - -extern "C" { -COLLECTOR_EXPORT_API void callback(uint16_t TraceType, - xpti::trace_event_data_t * /*Parent*/, - xpti::trace_event_data_t * /*Event*/, - uint64_t /*Instance*/, - const void *UserData) { - const auto *Data = static_cast(UserData); - const auto PrintPrefix = [] { - if (IndentationLevel) - std::cout << "* "; - }; - if (TraceType == xpti::trace_function_with_args_begin) { - - const auto PrintOffset = [PrintPrefix]() { - PrintPrefix(); - std::cout << " "; - }; - - PrintPrefix(); - if (PrintVerbose) { - std::string Source = ""; - size_t Line = 0; - - auto *Payload = xptiQueryPayloadByUID(xptiGetUniversalId()); - - if (Payload) { - if (Payload->source_file != nullptr) { - Source = Payload->source_file; - Line = Payload->line_no; - } - } - - auto TID = std::this_thread::get_id(); - std::cout << "[CU:TID " << TID << ":"; - std::cout << Source << ":" << Line << "]\n"; - PrintPrefix(); - } else { - std::cout << "[CU] "; - } - - std::cout << Data->function_name << "(\n"; - - switch (Data->function_id) { -#include "cuda_printers.def" - default: - break; // unknown API - } - - if (IndentationLevel) { - std::cout << "* "; - } - std::cout << std::flush; - } else if (TraceType == xpti::trace_function_with_args_end) { - std::cout << ") ---> " - << getResult(*static_cast(Data->ret_data)) - << std::endl; - PrintPrefix(); - std::cout << std::endl; - } -} - -COLLECTOR_EXPORT_API void init() { - std::string_view PrinterType(std::getenv("SYCL_TRACE_PRINT_FORMAT")); - if (PrinterType == "classic") { - std::cerr << "Classic output is unsupported for CUDA\n"; - } else if (PrinterType == "verbose") { - PrintVerbose = true; - } else if (PrinterType == "compact") { - PrintVerbose = false; - } -} - -// For unification purpose -COLLECTOR_EXPORT_API void finish() {} - -COLLECTOR_EXPORT_API void setIndentationLevel(int NewLevel) { - IndentationLevel = NewLevel; -} -} diff --git a/sycl/tools/sycl-trace/generate_cuda_pretty_printers.py b/sycl/tools/sycl-trace/generate_cuda_pretty_printers.py deleted file mode 100644 index a7992def23216..0000000000000 --- a/sycl/tools/sycl-trace/generate_cuda_pretty_printers.py +++ /dev/null @@ -1,55 +0,0 @@ -import re -import sys - - -def generate_ze_pretty_printers(header): - printers = open("cuda_printers.def", "w") - - matches = re.finditer( - r"typedef struct (cu[a-zA-Z_]+)_params_st {\n([a-zA-Z\s\n;\*0-9]+)}", header - ) - - for match in matches: - api_name = match.group(1) - args = match.group(2).replace("\n", "").strip().split(";")[:-1] - - printers.write( - "case static_cast(CUPTI_DRIVER_TRACE_CBID_{}): {{\n".format( - api_name - ) - ) - printers.write( - "const auto *Args = reinterpret_cast(Data->args_data);\n".format( - api_name - ) - ) - printers.write("(void)Args;\n") - for arg in args: - arg_name = arg.split(" ")[-1].replace("*", "") - arg_types = [x.strip() for x in arg.strip().split(" ")[:-1]] - printers.write("PrintOffset();\n") - printable = ["size_t", "void", "int", "char"] - if any(item in printable for item in arg_types): - printers.write( - 'std::cout << "{}: " << Args->{} << "\\n";\n'.format( - arg_name, arg_name - ) - ) - else: - printers.write( - 'std::cout << "{}: " << "\\n";\n'.format(arg_name) - ) - - printers.write("break;\n") - printers.write("}\n") - - printers.close() - - -if __name__ == "__main__": - """ - Usage: python generate_cuda_pretty_printers.py path/to/generated_cuda_meta.h - """ - with open(sys.argv[1], "r") as f: - header = f.read() - generate_ze_pretty_printers(header) diff --git a/sycl/tools/sycl-trace/generate_ze_pretty_printers.py b/sycl/tools/sycl-trace/generate_ze_pretty_printers.py deleted file mode 100644 index 6b7b93a02ac6c..0000000000000 --- a/sycl/tools/sycl-trace/generate_ze_pretty_printers.py +++ /dev/null @@ -1,80 +0,0 @@ -import re -import sys - - -def camel_to_snake(src): - return re.sub(r"(?(ZEApiKind::{}): {{\n".format(api_name) - ) - printers.write( - "const auto *Args = reinterpret_cast<{}*>(Data->args_data);\n".format( - param_type - ) - ) - for arg in args: - arg_name = arg.strip().split(" ")[-1].replace("*", "") - arg_types = [x.strip() for x in arg.strip().split(" ")[:-1]] - printers.write("PrintOffset();\n") - scalar = ["size_t*", "void**", "uint32_t*", "uint64_t*"] - if any(item in scalar for item in arg_types): - printers.write( - 'std::cout << "{}: " << *(Args->{}) << "\\n";\n'.format( - arg_name[1:], arg_name - ) - ) - else: - printers.write( - ' std::cout << "{}: " << Args->{} << "\\n";\n'.format( - arg_name, arg_name - ) - ) - printers.write("break;\n") - printers.write("}\n") - - printers.close() - - -if __name__ == "__main__": - """ - Usage: python generate_pi_pretty_printers.py path/to/ze_api.h - """ - with open(sys.argv[1], "r") as f: - header = f.read() - generate_ze_pretty_printers(header) diff --git a/sycl/tools/sycl-trace/main.cpp b/sycl/tools/sycl-trace/main.cpp deleted file mode 100644 index 456342aa344ef..0000000000000 --- a/sycl/tools/sycl-trace/main.cpp +++ /dev/null @@ -1,133 +0,0 @@ -//==------------ main.cpp - SYCL Tracing Tool ------------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include "launch.hpp" -#include "llvm/Support/CommandLine.h" - -#include -#include - -using namespace llvm; - -enum ModeKind { UR, ZE, CU, SYCL, VERIFY }; -enum PrintFormatKind { PRETTY_COMPACT, PRETTY_VERBOSE, CLASSIC }; - -int main(int argc, char **argv, char *env[]) { - cl::list Modes( - cl::desc("Available tracing modes:"), - cl::values( - // TODO graph dot - clEnumValN(UR, "ur.call", "Trace Unified Runtime calls"), - clEnumValN(ZE, "level_zero", "Trace Level Zero calls"), - clEnumValN(CU, "cuda", "Trace CUDA Driver API calls"), - clEnumValN(SYCL, "sycl", "Trace SYCL API calls"), - clEnumValN(VERIFY, "verify", - "Experimental. Verify PI API call parameters"))); - cl::opt PrintFormat( - "print-format", cl::desc("Print format"), - cl::values( - clEnumValN(PRETTY_COMPACT, "compact", "Human readable compact"), - clEnumValN(PRETTY_VERBOSE, "verbose", "Human readable verbose"), - clEnumValN( - CLASSIC, "classic", - "Similar to SYCL_PI_TRACE, only compatible with PI layer"))); - cl::opt TargetExecutable( - cl::Positional, cl::desc(""), cl::Required); - cl::list Argv(cl::ConsumeAfter, - cl::desc("...")); - - cl::ParseCommandLineOptions(argc, argv); - - std::vector NewEnv; - - { - size_t I = 0; - while (env[I] != nullptr) - NewEnv.emplace_back(env[I++]); - } - -#ifdef __linux__ - NewEnv.push_back("XPTI_FRAMEWORK_DISPATCHER=libxptifw.so"); - NewEnv.push_back("XPTI_SUBSCRIBERS=libsycl_ur_trace_collector.so"); -#elif defined(__APPLE__) - NewEnv.push_back("XPTI_FRAMEWORK_DISPATCHER=libxptifw.dylib"); - NewEnv.push_back("XPTI_SUBSCRIBERS=libsycl_ur_trace_collector.dylib"); -#endif - NewEnv.push_back("XPTI_TRACE_ENABLE=1"); - - const auto EnableURTrace = [&]() { - NewEnv.push_back("SYCL_TRACE_UR_ENABLE=1"); - NewEnv.push_back("UR_ENABLE_LAYERS=UR_LAYER_TRACING"); - }; - const auto EnableZETrace = [&]() { - NewEnv.push_back("SYCL_TRACE_ZE_ENABLE=1"); - NewEnv.push_back("ZE_ENABLE_TRACING_LAYER=1"); - }; - const auto EnableCUTrace = [&]() { - NewEnv.push_back("SYCL_TRACE_CU_ENABLE=1"); - }; - const auto EnableSYCLTrace = [&]() { - NewEnv.push_back("SYCL_TRACE_API_ENABLE=1"); - }; - const auto EnableVerificationTrace = [&]() { - NewEnv.push_back("SYCL_TRACE_VERIFICATION_ENABLE=1"); - NewEnv.push_back("UR_ENABLE_LAYERS=UR_LAYER_TRACING"); - }; - - for (auto Mode : Modes) { - switch (Mode) { - case UR: - EnableURTrace(); - break; - case ZE: - EnableZETrace(); - break; - case CU: - EnableCUTrace(); - break; - case SYCL: - EnableSYCLTrace(); - break; - case VERIFY: - EnableVerificationTrace(); - break; - } - } - - if (PrintFormat == CLASSIC) { - NewEnv.push_back("SYCL_TRACE_PRINT_FORMAT=classic"); - } else if (PrintFormat == PRETTY_VERBOSE) { - NewEnv.push_back("SYCL_TRACE_PRINT_FORMAT=verbose"); - } else { - NewEnv.push_back("SYCL_TRACE_PRINT_FORMAT=compact"); - } - - if (Modes.size() == 0) { - EnableURTrace(); - EnableZETrace(); - EnableCUTrace(); - // Intentionally do not enable SYCL API traces -> to not break existing - // tests. - // EnableSYTrace(); - } - - std::vector Args; - - Args.push_back(TargetExecutable); - std::copy(Argv.begin(), Argv.end(), std::back_inserter(Args)); - - int Err = launch(TargetExecutable.c_str(), Args, NewEnv); - - if (Err) { - std::cerr << "Failed to launch target application. Error code " << Err - << "\n"; - return Err; - } - - return 0; -} diff --git a/sycl/tools/sycl-trace/sycl_trace_collector.cpp b/sycl/tools/sycl-trace/sycl_trace_collector.cpp deleted file mode 100644 index 5cf5b3bc5f5b9..0000000000000 --- a/sycl/tools/sycl-trace/sycl_trace_collector.cpp +++ /dev/null @@ -1,149 +0,0 @@ -//==----------- sycl_trace_collector.cpp -----------------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -/// \file sycl_trace_collector.cpp -/// Routines to collect and print SYCL API calls. - -#include "xpti/xpti_trace_framework.hpp" - -#include - -#include -#include -#include -#include -#include - -extern sycl::detail::SpinLock GlobalLock; - -bool PrintSyclVerbose = false; - -void TraceDiagnosticsMessage(xpti::trace_event_data_t * /*Parent*/, - xpti::trace_event_data_t *CurrentObject, - const char *Message) { - if (!Message) - return; - - std::cout << "[SYCL] Runtime reports: " << std::endl; - std::cout << "what: " << Message << std::endl; - if (!CurrentObject) - return; - std::cout << "where: "; - if (auto Payload = CurrentObject->reserved.payload) { - bool HasData = false; - if (Payload->flags & (uint64_t)xpti::payload_flag_t::SourceFileAvailable) { - HasData = true; - std::cout << Payload->source_file << ":" << Payload->line_no << "\t"; - } - if (Payload->flags & (uint64_t)xpti::payload_flag_t::NameAvailable) { - HasData = true; - std::cout << Payload->name; - } - if (!HasData) - std::cout << "No code location data is available."; - std::cout << std::endl; - } -} - -void TraceTaskExecutionSignals(xpti::trace_event_data_t * /*Parent*/, - xpti::trace_event_data_t *Event, - [[maybe_unused]] const void *UserData, - uint64_t InstanceID, bool IsBegin) { - if (!Event) - return; - - char *Key = 0; - uint64_t Value; - bool HaveKeyValue = - (xptiGetStashedTuple(&Key, Value) == xpti::result_t::XPTI_RESULT_SUCCESS); - - std::cout << "[SYCL] Task " << (IsBegin ? "begin" : "end ") - << " (event=" << Event << ",instanceID=" << InstanceID << ")" - << std::endl; - - // TODO: some metadata could be added at the "end" point (e.g. memory - // allocation and result ptr). To consider how to distinguish new data for the - // same event appeared between begin-end points. - if (!IsBegin || !PrintSyclVerbose) - return; - - if (HaveKeyValue) { - std::cout << "\t " << Key << " : " << Value << std::endl; - } - - xpti::metadata_t *Metadata = xptiQueryMetadata(Event); - for (auto &Item : *Metadata) { - std::cout << "\t " << xptiLookupString(Item.first) << " : " - << xpti::readMetadata(Item) << std::endl; - } -} - -void TraceQueueLifetimeSignals(xpti::trace_event_data_t * /*Parent*/, - xpti::trace_event_data_t *Event, - [[maybe_unused]] const void *UserData, - bool IsCreation) { - if (!Event) - return; - - std::cout << "[SYCL] Queue " << (IsCreation ? "create" : "destroy") << ": " - << std::endl; - xpti::metadata_t *Metadata = xptiQueryMetadata(Event); - for (auto &Item : *Metadata) { - std::string_view Key{xptiLookupString(Item.first)}; - if (IsCreation) - std::cout << "\t " << Key << " : " << xpti::readMetadata(Item) - << std::endl; - else if (Key == "queue_id") - std::cout << "\t" << Key << " : " - << xpti::getMetadata(Item).second - << std::endl; - } -} - -XPTI_CALLBACK_API void syclCallback(uint16_t TraceType, - xpti::trace_event_data_t *Parent, - xpti::trace_event_data_t *Event, - uint64_t InstanceID, const void *UserData) { - std::lock_guard Lock{GlobalLock}; - switch (TraceType) { - case xpti::trace_diagnostics: - TraceDiagnosticsMessage(Parent, Event, static_cast(UserData)); - break; - case xpti::trace_queue_create: - TraceQueueLifetimeSignals(Parent, Event, UserData, true); - break; - case xpti::trace_queue_destroy: - TraceQueueLifetimeSignals(Parent, Event, UserData, false); - break; - case xpti::trace_task_begin: - TraceTaskExecutionSignals(Parent, Event, UserData, InstanceID, true); - break; - case xpti::trace_task_end: - TraceTaskExecutionSignals(Parent, Event, UserData, InstanceID, false); - break; - default: { - if (PrintSyclVerbose) - std::cout << "Trace type is unexpected. Please update trace collector." - << std::endl; - } break; - } -} - -void syclPrintersInit() { - std::string_view PrinterType(std::getenv("SYCL_TRACE_PRINT_FORMAT")); - if (PrinterType == "classic") { - std::cerr << "Classic output is not supported yet for SYCL API\n"; - } else if (PrinterType == "verbose") { - PrintSyclVerbose = true; - } else if (PrinterType == "compact") { - PrintSyclVerbose = false; - } -} - -// For unification purpose -void syclPrintersFinish() {} diff --git a/sycl/tools/sycl-trace/ur_trace_collector.cpp b/sycl/tools/sycl-trace/ur_trace_collector.cpp deleted file mode 100644 index 4f9e1959bedce..0000000000000 --- a/sycl/tools/sycl-trace/ur_trace_collector.cpp +++ /dev/null @@ -1,122 +0,0 @@ -//==---------------------- ur_trace_collector.cpp --------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -/// \file ur_trace_collector.cpp -/// Routines to collect and print Unified Runtime calls. - -#include "xpti/xpti_trace_framework.h" - -#include -#include - -#include -#include -#include -#include -#include - -extern sycl::detail::SpinLock GlobalLock; - -extern bool HasZEPrinter; - -using PrinterT = std::function; - -static PrinterT *HeaderPrinter = nullptr; -static PrinterT *ResultPrinter = nullptr; - -static void setupClassicPrinter() { - ResultPrinter = new std::function([](const xpti::function_with_args_t *Data) { - ur::extras::printFunctionParams( - std::cout, static_cast(Data->function_id), - Data->args_data); - auto *result = static_cast(Data->ret_data); - - std::cout << ")\n---> " << *result << "\n\n"; - }); - - HeaderPrinter = new std::function([](const xpti::function_with_args_t *Data) { - std::cout << "---> " << Data->function_name << "(\n"; - }); -} - -static void setupPrettyPrinter(bool Verbose) { - HeaderPrinter = - new std::function([Verbose](const xpti::function_with_args_t *Data) { - if (Verbose) { - std::string Source = ""; - size_t Line = 0; - - auto *Payload = xptiQueryPayloadByUID(xptiGetUniversalId()); - - if (Payload) { - if (Payload->source_file != nullptr) { - Source = Payload->source_file; - Line = Payload->line_no; - } - } - - auto TID = std::this_thread::get_id(); - std::cout << "[UR:TID " << TID << ":"; - std::cout << Source << ":" << Line << "]\n"; - } else { - std::cout << "[UR] "; - } - std::cout << Data->function_name << "(\n"; - - if (HasZEPrinter) { - std::cout << " {" << std::endl; - } - }); - - ResultPrinter = new std::function([](const xpti::function_with_args_t *Data) { - if (HasZEPrinter) { - std::cout << "}"; - } - std::cout << " "; - ur::extras::printFunctionParams( - std::cout, static_cast(Data->function_id), - Data->args_data); - auto *result = static_cast(Data->ret_data); - - std::cout << ")\n---> " << *result << "\n\n"; - }); -} - -void urPrintersInit() { - std::string_view PrinterType(std::getenv("SYCL_TRACE_PRINT_FORMAT")); - - if (PrinterType == "classic") { - setupClassicPrinter(); - } else if (PrinterType == "verbose") { - setupPrettyPrinter(/*verbose*/ true); - } else if (PrinterType == "compact") { - setupPrettyPrinter(/*verbose*/ false); - } -} - -void urPrintersFinish() { - delete HeaderPrinter; - delete ResultPrinter; -} - -XPTI_CALLBACK_API void urCallback(uint16_t TraceType, - xpti::trace_event_data_t * /*Parent*/, - xpti::trace_event_data_t * /*Event*/, - uint64_t /*Instance*/, const void *UserData) { - if (!HeaderPrinter || !ResultPrinter) - return; - - // Lock while we print information - std::lock_guard _{GlobalLock}; - const auto *Data = static_cast(UserData); - if (TraceType == xpti::trace_function_with_args_begin) { - (*HeaderPrinter)(Data); - } else if (TraceType == xpti::trace_function_with_args_end) { - (*ResultPrinter)(Data); - } -} diff --git a/sycl/tools/sycl-trace/verification_collector.cpp b/sycl/tools/sycl-trace/verification_collector.cpp deleted file mode 100644 index f2267b3d0ed34..0000000000000 --- a/sycl/tools/sycl-trace/verification_collector.cpp +++ /dev/null @@ -1,54 +0,0 @@ -//==---------------------- verification_collector.cpp ----------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -/// \file verification_collector.cpp -/// Routines to verify function arguments and trace. - -#include "xpti/xpti_trace_framework.h" - -#include "usm_analyzer.hpp" - -#include - -#include -#include -#include -#include -#include - -extern sycl::detail::SpinLock GlobalLock; - -void vPrintersInit() { - std::string_view PrinterType(std::getenv("SYCL_TRACE_PRINT_FORMAT")); - // all types are the same now - std::ignore = PrinterType; - - auto &GS = USMAnalyzer::getInstance(); - // this environment variable is for proper testing only - GS.changeTerminationOnErrorState( - std::getenv("SYCL_TRACE_TERMINATE_ON_WARNING")); -} - -void vPrintersFinish() {} - -XPTI_CALLBACK_API void vCallback(uint16_t TraceType, - xpti::trace_event_data_t * /*Parent*/, - xpti::trace_event_data_t *ObjectEvent, - uint64_t /*Instance*/, const void *UserData) { - auto &GS = USMAnalyzer::getInstance(); - GS.fillLastTracepointData(ObjectEvent); - - // Lock while we print information - std::lock_guard _{GlobalLock}; - const auto *Data = static_cast(UserData); - if (TraceType == xpti::trace_function_with_args_begin) { - GS.handlePreCall(Data); - } else if (TraceType == xpti::trace_function_with_args_end) { - GS.handlePostCall(Data); - } -} diff --git a/sycl/tools/sycl-trace/ze_api_generator.py b/sycl/tools/sycl-trace/ze_api_generator.py deleted file mode 100644 index e6d8f5ce2a59e..0000000000000 --- a/sycl/tools/sycl-trace/ze_api_generator.py +++ /dev/null @@ -1,48 +0,0 @@ -import re -import sys - - -def camel_to_snake(src): - return re.sub(r"(? - -#include - -#include -#include -#include -#include -#include - -#define COLLECTOR_EXPORT_API __attribute__((__visibility__("default"))) - -int IndentationLevel = 0; - -enum class ZEApiKind { -#define _ZE_API(call, domain, cb, params_type) call, -#include "ze_api.def" -#undef _ZE_API -}; - -bool PrintVerbose = false; - -static std::string getResult(ze_result_t Res) { - std::string ResultStr; - switch (Res) { - case ZE_RESULT_SUCCESS: - ResultStr = "ZE_RESULT_SUCCESS"; - if (PrintVerbose) - ResultStr += " (success)"; - break; - case ZE_RESULT_NOT_READY: - ResultStr = "ZE_RESULT_NOT_READY"; - if (PrintVerbose) - ResultStr += " (synchronization primitive not signaled)"; - break; - case ZE_RESULT_ERROR_DEVICE_LOST: - ResultStr = "ZE_RESULT_ERROR_DEVICE_LOST"; - if (PrintVerbose) - ResultStr += - " (device hung, reset, was removed, or driver update occurred)"; - break; - case ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY: - ResultStr = "ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY"; - if (PrintVerbose) - ResultStr += " (insufficient host memory to satisfy call)"; - break; - case ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY: - ResultStr = "ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY"; - if (PrintVerbose) - ResultStr += " (insufficient device memory to satisfy call)"; - break; - case ZE_RESULT_ERROR_MODULE_BUILD_FAILURE: - ResultStr = "ZE_RESULT_ERROR_MODULE_BUILD_FAILURE"; - if (PrintVerbose) - ResultStr += - " (error occurred when building module, see build log for details)"; - break; - case ZE_RESULT_ERROR_MODULE_LINK_FAILURE: - ResultStr = "ZE_RESULT_ERROR_MODULE_LINK_FAILURE"; - if (PrintVerbose) - ResultStr += - " (error occurred when linking modules, see build log for details)"; - break; - case ZE_RESULT_ERROR_DEVICE_REQUIRES_RESET: - ResultStr = "ZE_RESULT_ERROR_DEVICE_REQUIRES_RESET"; - if (PrintVerbose) - ResultStr += " (device requires a reset)"; - break; - case ZE_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE: - ResultStr = "ZE_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE"; - if (PrintVerbose) - ResultStr += " (device currently in low power state)"; - break; - case ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS: - ResultStr = "ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS"; - if (PrintVerbose) - ResultStr += " (access denied due to permission level)"; - break; - case ZE_RESULT_ERROR_NOT_AVAILABLE: - ResultStr = "ZE_RESULT_ERROR_NOT_AVAILABLE"; - if (PrintVerbose) - ResultStr += " (resource already in use and simultaneous access not " - "allowed or resource was removed)"; - break; - case ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE: - ResultStr = "ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE"; - if (PrintVerbose) - ResultStr += " (external required dependency is unavailable or missing)"; - break; - case ZE_RESULT_ERROR_UNINITIALIZED: - ResultStr = "ZE_RESULT_ERROR_UNINITIALIZED"; - if (PrintVerbose) - ResultStr += " (driver is not initialized)"; - break; - case ZE_RESULT_ERROR_UNSUPPORTED_VERSION: - ResultStr = "ZE_RESULT_ERROR_UNSUPPORTED_VERSION"; - if (PrintVerbose) - ResultStr += " (generic error code for unsupported versions)"; - break; - case ZE_RESULT_ERROR_UNSUPPORTED_FEATURE: - ResultStr = "ZE_RESULT_ERROR_UNSUPPORTED_FEATURE"; - if (PrintVerbose) - ResultStr += " (generic error code for unsupported features)"; - break; - case ZE_RESULT_ERROR_INVALID_ARGUMENT: - ResultStr = "ZE_RESULT_ERROR_INVALID_ARGUMENT"; - if (PrintVerbose) - ResultStr += " (generic error code for invalid arguments)"; - break; - case ZE_RESULT_ERROR_INVALID_NULL_HANDLE: - ResultStr = "ZE_RESULT_ERROR_INVALID_NULL_HANDLE"; - if (PrintVerbose) - ResultStr += " (handle argument is not valid)"; - break; - case ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE: - ResultStr = "ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE"; - if (PrintVerbose) - ResultStr += " (object pointed to by handle still in-use by device)"; - break; - case ZE_RESULT_ERROR_INVALID_NULL_POINTER: - ResultStr = "ZE_RESULT_ERROR_INVALID_NULL_POINTER"; - if (PrintVerbose) - ResultStr += " (pointer argument may not be nullptr)"; - break; - case ZE_RESULT_ERROR_INVALID_SIZE: - ResultStr = "ZE_RESULT_ERROR_INVALID_SIZE"; - if (PrintVerbose) - ResultStr += " (size argument is invalid (e.g., must not be zero))"; - break; - case ZE_RESULT_ERROR_UNSUPPORTED_SIZE: - ResultStr = "ZE_RESULT_ERROR_UNSUPPORTED_SIZE"; - if (PrintVerbose) - ResultStr += - " (size argument is not supported by the device (e.g., too large))"; - break; - case ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT: - ResultStr = "ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT"; - if (PrintVerbose) - ResultStr += " (alignment argument is not supported by the device (e.g., " - "too small))"; - break; - case ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT: - ResultStr = "ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT"; - if (PrintVerbose) - ResultStr += " (synchronization object in invalid state)"; - break; - case ZE_RESULT_ERROR_INVALID_ENUMERATION: - ResultStr = "ZE_RESULT_ERROR_INVALID_ENUMERATION"; - if (PrintVerbose) - ResultStr += " (enumerator argument is not valid)"; - break; - case ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION: - ResultStr = "ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION"; - if (PrintVerbose) - ResultStr += " (enumerator argument is not supported by the device)"; - break; - case ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT: - ResultStr = "ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT"; - if (PrintVerbose) - ResultStr += " (image format is not supported by the device)"; - break; - case ZE_RESULT_ERROR_INVALID_NATIVE_BINARY: - ResultStr += "ZE_RESULT_ERROR_INVALID_NATIVE_BINARY"; - if (PrintVerbose) - ResultStr += " (native binary is not supported by the device)"; - break; - case ZE_RESULT_ERROR_INVALID_GLOBAL_NAME: - ResultStr = "ZE_RESULT_ERROR_INVALID_GLOBAL_NAME"; - if (PrintVerbose) - ResultStr += " (global variable is not found in the module)"; - break; - case ZE_RESULT_ERROR_INVALID_KERNEL_NAME: - ResultStr = "ZE_RESULT_ERROR_INVALID_KERNEL_NAME"; - if (PrintVerbose) - ResultStr += " (kernel name is not found in the module)"; - break; - case ZE_RESULT_ERROR_INVALID_FUNCTION_NAME: - ResultStr = "ZE_RESULT_ERROR_INVALID_FUNCTION_NAME"; - if (PrintVerbose) - ResultStr += " (function name is not found in the module)"; - break; - case ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: - ResultStr = "ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; - if (PrintVerbose) - ResultStr += - " (group size dimension is not valid for the kernel or device)"; - break; - case ZE_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION: - ResultStr = "ZE_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION"; - if (PrintVerbose) - ResultStr += - " (global width dimension is not valid for the kernel or device)"; - break; - case ZE_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX: - ResultStr = "ZE_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX"; - if (PrintVerbose) - ResultStr += " (kernel argument index is not valid for kernel)"; - break; - case ZE_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE: - ResultStr = "ZE_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE"; - if (PrintVerbose) - ResultStr += " (kernel argument size does not match kernel)"; - break; - case ZE_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE: - ResultStr = "ZE_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE"; - if (PrintVerbose) - ResultStr += - " (value of kernel attribute is not valid for the kernel or device)"; - break; - case ZE_RESULT_ERROR_INVALID_MODULE_UNLINKED: - ResultStr = "ZE_RESULT_ERROR_INVALID_MODULE_UNLINKED"; - if (PrintVerbose) - ResultStr += " (module with imports needs to be linked before kernels " - "can be created from it)"; - break; - case ZE_RESULT_ERROR_INVALID_COMMAND_LIST_TYPE: - ResultStr = "ZE_RESULT_ERROR_INVALID_COMMAND_LIST_TYPE"; - if (PrintVerbose) - ResultStr += " (command list type does not match command queue type)"; - break; - case ZE_RESULT_ERROR_OVERLAPPING_REGIONS: - ResultStr = "ZE_RESULT_ERROR_OVERLAPPING_REGIONS"; - if (PrintVerbose) - ResultStr += - " (copy operations do not support overlapping regions of memory)"; - break; - default: - ResultStr = "UNKNOWN ERROR"; - break; - } - - return ResultStr; -} - -extern "C" { - -COLLECTOR_EXPORT_API void callback(uint16_t TraceType, - xpti::trace_event_data_t * /*Parent*/, - xpti::trace_event_data_t * /*Event*/, - uint64_t /*Instance*/, - const void *UserData) { - const auto *Data = static_cast(UserData); - const auto PrintPrefix = [] { - if (IndentationLevel) - std::cout << "* "; - }; - if (TraceType == xpti::trace_function_with_args_begin) { - - const auto PrintOffset = [PrintPrefix]() { - PrintPrefix(); - std::cout << " "; - }; - - PrintPrefix(); - if (PrintVerbose) { - std::string Source = ""; - size_t Line = 0; - - auto *Payload = xptiQueryPayloadByUID(xptiGetUniversalId()); - - if (Payload) { - if (Payload->source_file != nullptr) { - Source = Payload->source_file; - Line = Payload->line_no; - } - } - - auto TID = std::this_thread::get_id(); - std::cout << "[L0:TID " << TID << ":"; - std::cout << Source << ":" << Line << "]\n"; - PrintPrefix(); - } else { - std::cout << "[L0] "; - } - - std::cout << Data->function_name << "(\n"; - - switch (Data->function_id) { -#include "ze_printers.def" - default: - break; // unknown API - } - - if (IndentationLevel) { - std::cout << "* "; - } - std::cout << std::flush; - } else if (TraceType == xpti::trace_function_with_args_end) { - std::cout << ") ---> " - << getResult(*static_cast(Data->ret_data)) - << std::endl; - PrintPrefix(); - std::cout << std::endl; - } -} - -COLLECTOR_EXPORT_API void init() { - std::string_view PrinterType(std::getenv("SYCL_TRACE_PRINT_FORMAT")); - if (PrinterType == "classic") { - std::cerr << "Classic output is unsupported for Level Zero\n"; - } else if (PrinterType == "verbose") { - PrintVerbose = true; - } else if (PrinterType == "compact") { - PrintVerbose = false; - } -} - -// For unification purpose -COLLECTOR_EXPORT_API void finish() {} - -COLLECTOR_EXPORT_API void setIndentationLevel(int NewLevel) { - IndentationLevel = NewLevel; -} -} diff --git a/sycl/tools/xpti_helpers/launch.hpp b/sycl/tools/xpti_helpers/launch.hpp deleted file mode 100644 index 81953f69662f4..0000000000000 --- a/sycl/tools/xpti_helpers/launch.hpp +++ /dev/null @@ -1,40 +0,0 @@ -//==----------------- launch.hpp -------------------------------------------==// -// -// 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 -#include -#include -#include -#include - -inline std::vector toCStyle(const std::vector &Arr) { - std::vector CArr; - CArr.reserve(Arr.size() + 1); - std::transform(Arr.begin(), Arr.end(), std::back_inserter(CArr), - [](const std::string &str) { return str.data(); }); - - CArr.push_back(nullptr); - - return CArr; -} - -/// Launches external application. -/// -/// \param Cmd is a path (full, relative, executable name in PATH) to executable -/// \param Args is program arguments. First argument is executable name. Last -/// argument is nullptr. -/// \param Env is program environment variables. Last variable is nullptr. -int launch(const std::string &Cmd, const std::vector &Args, - const std::vector &Env) { - std::vector CArgs = toCStyle(Args); - std::vector CEnv = toCStyle(Env); - return execve(Cmd.data(), const_cast(CArgs.data()), - const_cast(CEnv.data())); -} diff --git a/sycl/tools/xpti_helpers/usm_analyzer.hpp b/sycl/tools/xpti_helpers/usm_analyzer.hpp deleted file mode 100644 index 6df1c522899d9..0000000000000 --- a/sycl/tools/xpti_helpers/usm_analyzer.hpp +++ /dev/null @@ -1,424 +0,0 @@ -//==----------------- usm_analyzer.hpp -------------------------------------==// -// -// 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 -// -//===---------------------------------------------------------------------===// - -#include "xpti/xpti_trace_framework.h" - -#include - -#include -#include -#include -#include -#include -#include - -struct TracepointInfo { - std::string Source; - std::string Function; - uint32_t Line; -}; - -enum class AllocKind { host, device, shared }; - -struct AllocationInfo { - size_t Length; - AllocKind Kind; - TracepointInfo Location; -}; - -class USMAnalyzer { -private: - USMAnalyzer(){}; - // TO DO: mem allocations could be effectively validated with - // piextUSMGetMemAllocInfo - could be more robust - static void CheckPointerValidness(std::string ParameterDesc, const void *Ptr, - size_t size, std::string FunctionName) { - void *PtrToValidate = (const_cast(Ptr)); - - bool PointerFound = false; - auto &GS = USMAnalyzer::getInstance(); - auto &OutStream = GS.getOutStream(); - if (PtrToValidate == nullptr) { - OutStream << std::endl; - OutStream << PrintPrefix << "Function uses nullptr as " << ParameterDesc - << ".\n"; - OutStream << PrintIndentation << FunctionName << " location: "; - OutStream << " function " << GS.LastTracepoint.Function << " at "; - OutStream << GS.LastTracepoint.Source << ":" << GS.LastTracepoint.Line - << std::endl; - if (GS.TerminateOnError) - std::terminate(); - return; - } - - for (const auto &Alloc : GS.ActivePointers) { - const void *Begin = Alloc.first; - const void *End = - static_cast(Alloc.first) + Alloc.second.Length; - - if (PtrToValidate >= Begin && PtrToValidate < End) { - PointerFound = true; - const void *CopyRegionEnd = - static_cast(PtrToValidate) + size; - if (CopyRegionEnd > End) { - OutStream << std::endl; - OutStream << PrintPrefix << "Requested " << FunctionName - << " range exceeds allocated USM memory size for " - << ParameterDesc << ".\n"; - OutStream << PrintIndentation << "Allocation location: "; - OutStream << " function " << Alloc.second.Location.Function << " at "; - OutStream << Alloc.second.Location.Source << ":" - << Alloc.second.Location.Line << "\n"; - OutStream << PrintIndentation << FunctionName << " location: "; - OutStream << " function " << GS.LastTracepoint.Function << " at "; - OutStream << GS.LastTracepoint.Source << ":" << GS.LastTracepoint.Line - << std::endl; - if (GS.TerminateOnError) - std::terminate(); - } - break; - } - } - - if (!PointerFound) { - OutStream << std::endl; - OutStream << PrintPrefix - << "Function uses unknown USM pointer (could be already " - "released or not allocated as USM) as " - << ParameterDesc << ".\n"; - OutStream << PrintIndentation << FunctionName << " location: "; - OutStream << " function " << GS.LastTracepoint.Function << " at "; - OutStream << GS.LastTracepoint.Source << ":" << GS.LastTracepoint.Line - << std::endl; - if (GS.TerminateOnError) - std::terminate(); - } - } - - static void CheckPointerValidness(std::string ParameterDesc, const void *Ptr, - size_t pitch, size_t width, size_t length, - std::string FunctionName) { - void *PtrToValidate = *(void **)(const_cast(Ptr)); - bool PointerFound = false; - auto &GS = USMAnalyzer::getInstance(); - auto &OutStream = GS.getOutStream(); - if (width > length) { - OutStream << std::endl; - OutStream << PrintPrefix << "Requested " << FunctionName - << " width is greater than pitch for " << ParameterDesc - << ".\n"; - OutStream << PrintIndentation << FunctionName << " location: "; - OutStream << " function " << GS.LastTracepoint.Function << " at "; - OutStream << GS.LastTracepoint.Source << ":" << GS.LastTracepoint.Line - << std::endl; - if (GS.TerminateOnError) - std::terminate(); - return; - } - - if (PtrToValidate == nullptr) { - OutStream << std::endl; - OutStream << PrintPrefix << "Function uses nullptr as " << ParameterDesc - << ".\n"; - OutStream << PrintIndentation << FunctionName << " location: "; - OutStream << " function " << GS.LastTracepoint.Function << " at "; - OutStream << GS.LastTracepoint.Source << ":" << GS.LastTracepoint.Line - << std::endl; - if (GS.TerminateOnError) - std::terminate(); - return; - } - - for (const auto &Alloc : GS.ActivePointers) { - const void *Begin = Alloc.first; - const void *End = - static_cast(Alloc.first) + Alloc.second.Length; - if (PtrToValidate >= Begin && PtrToValidate < End) { - PointerFound = true; - const void *CopyRegionEnd = - static_cast(PtrToValidate) + pitch * length; - if (CopyRegionEnd > End) { - OutStream << std::endl; - OutStream << PrintPrefix << "Requested " << FunctionName - << " range exceeds allocated USM memory size for " - << ParameterDesc << ".\n"; - OutStream << PrintIndentation << "Allocation location: "; - OutStream << " function " << Alloc.second.Location.Function << " at "; - OutStream << Alloc.second.Location.Source << ":" - << Alloc.second.Location.Line << "\n"; - OutStream << PrintIndentation << FunctionName << " location: "; - OutStream << " function " << GS.LastTracepoint.Function << " at "; - OutStream << GS.LastTracepoint.Source << ":" << GS.LastTracepoint.Line - << std::endl; - if (GS.TerminateOnError) - std::terminate(); - } - - break; - } - } - if (!PointerFound) { - OutStream << std::endl; - OutStream << PrintPrefix - << "Function uses unknown USM pointer (could be already " - "released or not allocated as USM).\n"; - OutStream << PrintIndentation << FunctionName << " location: "; - OutStream << " function " << GS.LastTracepoint.Function << " at "; - OutStream << GS.LastTracepoint.Source << ":" << GS.LastTracepoint.Line - << std::endl; - if (GS.TerminateOnError) - std::terminate(); - } - } - - static constexpr char PrintPrefix[] = "[USM] "; - static constexpr char PrintIndentation[] = " | "; - bool PrintToError = false; - - std::ostream &getOutStream() { return PrintToError ? std::cerr : std::cout; } - -public: - // TO DO: allocations must be tracked with device - std::map ActivePointers; - TracepointInfo LastTracepoint; - bool TerminateOnError = false; - - USMAnalyzer(const USMAnalyzer &obj) = delete; - USMAnalyzer &operator=(const USMAnalyzer &rhs) = delete; - - static USMAnalyzer &getInstance() { - static USMAnalyzer s; - return s; - } - - void changeTerminationOnErrorState(bool EnableTermination) { - TerminateOnError = EnableTermination; - } - - void printToErrorStream() { PrintToError = true; } - - void handlePostCall(const xpti::function_with_args_t *Data) { - switch (static_cast(Data->function_id)) { - case UR_FUNCTION_USM_HOST_ALLOC: - handleUSMHostAlloc( - static_cast(Data->args_data)); - return; - case UR_FUNCTION_USM_DEVICE_ALLOC: - handleUSMDeviceAlloc( - static_cast(Data->args_data)); - return; - case UR_FUNCTION_USM_SHARED_ALLOC: - handleUSMSharedAlloc( - static_cast(Data->args_data)); - return; - default: - return; - } - } - - void handlePreCall(const xpti::function_with_args_t *Data) { - switch (static_cast(Data->function_id)) { - case UR_FUNCTION_USM_FREE: - handleUSMFree(static_cast(Data->args_data)); - return; - case UR_FUNCTION_MEM_BUFFER_CREATE: - handleMemBufferCreate( - static_cast(Data->args_data)); - return; - case UR_FUNCTION_ENQUEUE_USM_MEMCPY: - handleUSMEnqueueMemcpy( - static_cast(Data->args_data)); - return; - case UR_FUNCTION_ENQUEUE_USM_PREFETCH: - handleUSMEnqueuePrefetch( - static_cast(Data->args_data)); - return; - case UR_FUNCTION_ENQUEUE_USM_ADVISE: - handleUSMEnqueueMemAdvise( - static_cast(Data->args_data)); - return; - case UR_FUNCTION_ENQUEUE_USM_FILL_2D: - handleUSMEnqueueFill2D( - static_cast(Data->args_data)); - return; - case UR_FUNCTION_ENQUEUE_USM_MEMCPY_2D: - handleUSMEnqueueMemcpy2D( - static_cast(Data->args_data)); - return; - case UR_FUNCTION_KERNEL_SET_ARG_POINTER: - handleKernelSetArgPointer( - static_cast(Data->args_data)); - return; - default: - return; - } - } - - void fillLastTracepointData(const xpti::trace_event_data_t *ObjectEvent) { - const xpti::payload_t *Payload = - ObjectEvent && ObjectEvent->reserved.payload - ? ObjectEvent->reserved.payload - : xptiQueryPayloadByUID(xptiGetUniversalId()); - - if (Payload) { - if (Payload->source_file) - LastTracepoint.Source = Payload->source_file; - else - LastTracepoint.Source = ""; - LastTracepoint.Function = Payload->name; - LastTracepoint.Line = Payload->line_no; - } else { - LastTracepoint.Function = ""; - LastTracepoint.Source = ""; - LastTracepoint.Line = 0; - } - } - - static void handleUSMHostAlloc(const ur_usm_host_alloc_params_t *Params) { - auto &GS = USMAnalyzer::getInstance(); - AllocationInfo Info; - Info.Location = GS.LastTracepoint; - Info.Length = *Params->psize; - Info.Kind = AllocKind::host; - GS.ActivePointers[**Params->pppMem] = Info; - } - - static void handleUSMDeviceAlloc(const ur_usm_device_alloc_params_t *Params) { - auto &GS = USMAnalyzer::getInstance(); - - AllocationInfo Info; - Info.Location = GS.LastTracepoint; - Info.Length = *Params->psize; - Info.Kind = AllocKind::device; - GS.ActivePointers[**Params->pppMem] = Info; - } - - static void handleUSMSharedAlloc(const ur_usm_shared_alloc_params_t *Params) { - auto &GS = USMAnalyzer::getInstance(); - AllocationInfo Info; - Info.Location = GS.LastTracepoint; - Info.Length = *Params->psize; - Info.Kind = AllocKind::shared; - GS.ActivePointers[**Params->pppMem] = Info; - } - - static void handleUSMFree(const ur_usm_free_params_t *Params) { - auto &GS = USMAnalyzer::getInstance(); - auto &OutStream = GS.getOutStream(); - if (GS.ActivePointers.count(*Params->ppMem) == 0) { - OutStream << std::endl; - OutStream << PrintPrefix << "Attempt to free pointer " << std::hex - << *Params->ppMem; - OutStream << " that was not allocated with SYCL USM APIs.\n"; - OutStream << PrintIndentation << "Location: function " - << GS.LastTracepoint.Function; - OutStream << " at " << GS.LastTracepoint.Source << ":"; - OutStream << std::dec << GS.LastTracepoint.Line << "\n"; - if (GS.TerminateOnError) - std::terminate(); - } - GS.ActivePointers.erase(*Params->ppMem); - } - - static void - handleMemBufferCreate(const ur_mem_buffer_create_params_t *Params) { - auto &GS = USMAnalyzer::getInstance(); - auto &OutStream = GS.getOutStream(); - void *HostPtr = nullptr; - if (*Params->ppProperties) { - HostPtr = (*Params->ppProperties)->pHost; - } - for (const auto &Alloc : GS.ActivePointers) { - const void *Begin = Alloc.first; - const void *End = - static_cast(Alloc.first) + Alloc.second.Length; - // Host pointer was allocated with USM APIs - if (HostPtr >= Begin && HostPtr < End) { - bool NeedsTerminate = false; - if (Alloc.second.Kind != AllocKind::host) { - OutStream << PrintPrefix - << "Attempt to construct a buffer with non-host pointer.\n"; - NeedsTerminate = true; - } - - const void *HostEnd = static_cast(HostPtr) + *Params->psize; - if (HostEnd > End) { - OutStream << PrintPrefix - << "Buffer size exceeds allocated host memory size.\n"; - NeedsTerminate = true; - } - - if (NeedsTerminate) { - OutStream << PrintIndentation << "Allocation location: "; - OutStream << " function " << Alloc.second.Location.Function << " at "; - OutStream << Alloc.second.Location.Source << ":" - << Alloc.second.Location.Line << "\n"; - OutStream << PrintIndentation << "Buffer location: "; - OutStream << " function " << GS.LastTracepoint.Function << " at "; - OutStream << GS.LastTracepoint.Source << ":" << GS.LastTracepoint.Line - << "\n"; - if (GS.TerminateOnError) - std::terminate(); - } - break; - } - } - } - - static void - handleUSMEnqueueMemcpy(const ur_enqueue_usm_memcpy_params_t *Params) { - CheckPointerValidness("source memory block", *Params->ppSrc, *Params->psize, - "memcpy"); - CheckPointerValidness("destination memory block", *Params->ppDst, - *Params->psize, "memcpy"); - } - - static void - handleUSMEnqueueFill(const ur_enqueue_usm_memcpy_params_t *Params) { - CheckPointerValidness("input parameter", *Params->ppDst, *Params->psize, - "fill"); - } - - static void - handleUSMEnqueuePrefetch(const ur_enqueue_usm_prefetch_params_t *Params) { - CheckPointerValidness("input parameter", *Params->ppMem, *Params->psize, - "prefetch"); - } - - static void - handleUSMEnqueueMemAdvise(const ur_enqueue_usm_advise_params_t *Params) { - CheckPointerValidness("input parameter", *Params->ppMem, *Params->psize, - "mem_advise"); - } - - static void - handleUSMEnqueueFill2D(const ur_enqueue_usm_fill_2d_params_t *Params) { - // TO DO: add checks for pattern validity - CheckPointerValidness("input parameter", *Params->ppMem, *Params->ppitch, - *Params->pwidth, *Params->pheight, - "ext_oneapi_fill2d"); - } - - static void - handleUSMEnqueueMemcpy2D(const ur_enqueue_usm_memcpy_2d_params_t *Params) { - CheckPointerValidness("source parameter", *Params->ppSrc, - *Params->psrcPitch, *Params->pwidth, *Params->pheight, - "ext_oneapi_copy2d/ext_oneapi_memcpy2d"); - CheckPointerValidness("destination parameter", *Params->ppDst, - *Params->pdstPitch, *Params->pwidth, *Params->pheight, - "ext_oneapi_copy2d/ext_oneapi_memcpy2d"); - } - - static void - handleKernelSetArgPointer(const ur_kernel_set_arg_pointer_params_t *Params) { - void *Ptr = (const_cast(*Params->ppArgValue)); - CheckPointerValidness( - "kernel parameter with index = " + std::to_string(*Params->pargIndex), - Ptr, 0 /*no data how it will be used in kernel*/, "kernel"); - } -}; diff --git a/sycl/unittests/CMakeLists.txt b/sycl/unittests/CMakeLists.txt index 8831426784de2..9e21800e7be2c 100644 --- a/sycl/unittests/CMakeLists.txt +++ b/sycl/unittests/CMakeLists.txt @@ -53,10 +53,7 @@ if (LLVM_ENABLE_ZSTD) add_subdirectory(compression) endif() -# TODO Enable xpti tests for Windows -if (NOT WIN32) - add_subdirectory(xpti_trace) -endif() + add_subdirectory(sampler) add_subdirectory(reduction) add_subdirectory(OneAPIDeviceSelector) diff --git a/sycl/unittests/scheduler/SchedulerTestUtils.hpp b/sycl/unittests/scheduler/SchedulerTestUtils.hpp index ffc0567ba7daa..42f6b9ae1d963 100644 --- a/sycl/unittests/scheduler/SchedulerTestUtils.hpp +++ b/sycl/unittests/scheduler/SchedulerTestUtils.hpp @@ -54,7 +54,6 @@ class MockCommand : public sycl::detail::Command { } void printDot(std::ostream &) const override {} - void emitInstrumentationData() override {} const sycl::detail::Requirement *getRequirement() const final { return &MRequirement; diff --git a/sycl/unittests/xpti_trace/CMakeLists.txt b/sycl/unittests/xpti_trace/CMakeLists.txt deleted file mode 100644 index 195da6d566092..0000000000000 --- a/sycl/unittests/xpti_trace/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -add_subdirectory(xptitest_subscriber) - -add_definitions(-DXPTI_ENABLE_INSTRUMENTATION) -add_sycl_unittest(XptiTraceTests OBJECT - QueueApiFailures.cpp - NodeCreation.cpp - QueueIDCheck.cpp -) -target_link_libraries(XptiTraceTests PRIVATE xpti xptitest_subscriber) diff --git a/sycl/unittests/xpti_trace/NodeCreation.cpp b/sycl/unittests/xpti_trace/NodeCreation.cpp deleted file mode 100644 index 6adba2fabff9d..0000000000000 --- a/sycl/unittests/xpti_trace/NodeCreation.cpp +++ /dev/null @@ -1,239 +0,0 @@ -//==------------ NodeCreation.cpp --- XPTI integration unit tests ----------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include -#include -#include - -#include - -#include -#include - -#include -#include - -using ::testing::HasSubstr; -using namespace sycl; -XPTI_CALLBACK_API bool queryReceivedNotifications(uint16_t &TraceType, - std::string &Message); -XPTI_CALLBACK_API void resetReceivedNotifications(); -XPTI_CALLBACK_API void addAnalyzedTraceType(uint16_t); -XPTI_CALLBACK_API void clearAnalyzedTraceTypes(); - -class NodeCreation : public ::testing::Test { -protected: - void SetUp() { - xptiForceSetTraceEnabled(true); - xptiTraceTryToEnable(); - addAnalyzedTraceType(xpti::trace_node_create); - } - - void TearDown() { - resetReceivedNotifications(); - clearAnalyzedTraceTypes(); - xptiForceSetTraceEnabled(false); - } - -public: - unittest::ScopedEnvVar PathToXPTIFW{"XPTI_FRAMEWORK_DISPATCHER", - "libxptifw.so", [] {}}; - unittest::ScopedEnvVar XPTISubscriber{"XPTI_SUBSCRIBERS", - "libxptitest_subscriber.so", [] {}}; - sycl::unittest::UrMock<> MockAdapter; - - static constexpr char FileName[] = "NodeCreation.cpp"; - static constexpr char FunctionName[] = "TestCaseExecution"; - static constexpr int LineNumber = 8; - static constexpr int ColumnNumber = 13; - const sycl::detail::code_location TestCodeLocation = { - FileName, FunctionName, LineNumber, ColumnNumber}; - static constexpr size_t KernelSize = 1; -}; - -TEST_F(NodeCreation, QueueParallelForWithGraphNode) { - sycl::queue Q; - try { - sycl::buffer buf(sycl::range<1>(1)); - Q.submit( - [&](handler &Cgh) { - sycl::accessor acc(buf, Cgh, sycl::read_write); - Cgh.parallel_for>(1, [=](sycl::id<1> idx) {}); - }, - TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - } - Q.wait(); - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_node_create); - EXPECT_THAT(Message, HasSubstr("TestKernel")); -} - -TEST_F(NodeCreation, QueueParallelForWithNoGraphNode) { - sycl::queue Q; - try { - Q.parallel_for>(1, [=](sycl::id<1> idx) {}); - } catch (sycl::exception &e) { - std::ignore = e; - } - Q.wait(); - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_node_create); - EXPECT_THAT(Message, HasSubstr("TestKernel")); -} - -TEST_F(NodeCreation, QueueParallelForWithUserCodeLoc) { - sycl::queue Q; - try { - sycl::buffer buf(sycl::range<1>(1)); - sycl::detail::tls_code_loc_t myLoc( - {"LOCAL_CODELOC_FILE", "LOCAL_CODELOC_NAME", 1, 1}); - Q.submit( - [&](handler &Cgh) { - sycl::accessor acc(buf, Cgh, sycl::read_write); - Cgh.parallel_for>(1, [=](sycl::id<1> idx) {}); - }, - TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - } - Q.wait(); - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_node_create); - EXPECT_THAT(Message, HasSubstr("LOCAL_CODELOC_NAME")); -} - -TEST_F(NodeCreation, QueueMemcpyNode) { - sycl::queue Q; - - constexpr int n = 10 * sizeof(double); - double HostPtr[n]; - double *DeviceUSMPtr = (double *)sycl::malloc_device(n, Q); - Q.memcpy(DeviceUSMPtr, HostPtr, n).wait(); - sycl::free(DeviceUSMPtr, Q); - - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_node_create); - EXPECT_THAT(Message, HasSubstr("memory_transfer_node")); -} - -TEST_F(NodeCreation, QueueMemsetNode) { - sycl::queue Q; - - constexpr int n = 10 * sizeof(double); - double *DeviceUSMPtr = (double *)sycl::malloc_device(n, Q); - Q.memset(DeviceUSMPtr, 0, n).wait(); - sycl::free(DeviceUSMPtr, Q); - - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_node_create); - EXPECT_THAT(Message, HasSubstr("memory_transfer_node")); -} - -TEST_F(NodeCreation, CommandGraphRecord) { - sycl::queue Q; - try { - sycl::ext::oneapi::experimental::command_graph cmdGraph(Q.get_context(), - Q.get_device()); - - cmdGraph.begin_recording(Q); - - { - sycl::detail::tls_code_loc_t myLoc( - {"LOCAL_CODELOC_FILE", "LOCAL_CODELOC_NAME", 1, 1}); - Q.submit([&](handler &Cgh) { - Cgh.parallel_for>(1, [=](sycl::id<1> idx) {}); - }); - } - - cmdGraph.end_recording(Q); - - addAnalyzedTraceType(xpti::trace_task_begin); - addAnalyzedTraceType(xpti::trace_task_end); - - auto exeGraph = cmdGraph.finalize(); - - // Notifications should have been generated during finalize - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_node_create); - EXPECT_THAT(Message, HasSubstr("LOCAL_CODELOC_NAME")); - - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_task_begin); - - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_task_end); - - } catch (sycl::exception &e) { - FAIL() << "sycl::exception what=" << e.what(); - } -} - -TEST_F(NodeCreation, CommandGraphAddAPI) { - sycl::queue Q; - try { - sycl::ext::oneapi::experimental::command_graph cmdGraph(Q.get_context(), - Q.get_device()); - - auto doAddNode = [&](const sycl::detail::code_location &loc) { - sycl::detail::tls_code_loc_t codeLoc(loc); - return cmdGraph.add([&](handler &Cgh) { - Cgh.parallel_for>(1, [=](sycl::id<1> idx) {}); - }); - }; - - auto node1 = doAddNode({"LOCAL_CODELOC_FILE", "LOCAL_NODE_1", 1, 1}); - auto node2 = doAddNode({"LOCAL_CODELOC_FILE", "LOCAL_NODE_2", 2, 1}); - cmdGraph.make_edge(node1, node2); - - addAnalyzedTraceType(xpti::trace_task_begin); - addAnalyzedTraceType(xpti::trace_task_end); - - auto exeGraph = cmdGraph.finalize(); - - // Notifications should have get generated during finalize - // - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_node_create); - EXPECT_THAT(Message, HasSubstr("LOCAL_NODE_1")); - - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_task_begin); - - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_task_end); - - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_node_create); - EXPECT_THAT(Message, HasSubstr("LOCAL_NODE_2")); - - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_task_begin); - - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_task_end); - - } catch (sycl::exception &e) { - FAIL() << "sycl::exception what=" << e.what(); - } -} diff --git a/sycl/unittests/xpti_trace/QueueApiFailures.cpp b/sycl/unittests/xpti_trace/QueueApiFailures.cpp deleted file mode 100644 index b9744c4499418..0000000000000 --- a/sycl/unittests/xpti_trace/QueueApiFailures.cpp +++ /dev/null @@ -1,518 +0,0 @@ -//==------------ QueueApiFailures.cpp --- XPTI integration unit tests ------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include -#include -#include - -#include - -#include -#include - -#include - -#include - -using ::testing::HasSubstr; -using namespace sycl; -XPTI_CALLBACK_API bool queryReceivedNotifications(uint16_t &TraceType, - std::string &Message); -XPTI_CALLBACK_API void resetReceivedNotifications(); -XPTI_CALLBACK_API void addAnalyzedTraceType(uint16_t); - -inline ur_result_t redefinedAdapterGetLastError(void *) { - return UR_RESULT_ERROR_INVALID_VALUE; -} - -ur_result_t redefinedEnqueueKernelLaunch(void *) { - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; -} - -class QueueApiFailures : public ::testing::Test { -protected: - void SetUp() { - xptiForceSetTraceEnabled(true); - xptiTraceTryToEnable(); - addAnalyzedTraceType(xpti::trace_diagnostics); - } - - void TearDown() { - resetReceivedNotifications(); - xptiForceSetTraceEnabled(false); - } - -public: - static std::string BuildCodeLocationMessage(const char *FileName, - const char *FunctionName, - int LineNumber, - int ColumnNumber) { - const char Delimiter[] = ";"; - std::string Result(FunctionName); - Result.append(Delimiter); - Result.append(FileName); - Result.append(Delimiter); - Result.append(std::to_string(LineNumber) + Delimiter + - std::to_string(ColumnNumber)); - return Result; - } - - unittest::ScopedEnvVar PathToXPTIFW{"XPTI_FRAMEWORK_DISPATCHER", - "libxptifw.so", [] {}}; - unittest::ScopedEnvVar XPTISubscriber{"XPTI_SUBSCRIBERS", - "libxptitest_subscriber.so", [] {}}; - sycl::unittest::UrMock<> MockAdapter; - - static constexpr char FileName[] = "QueueApiFailures.cpp"; - static constexpr char FunctionName[] = "TestCaseExecution"; - static constexpr char ExtraFunctionName[] = "ExtraTestCaseExecution"; - static constexpr int LineNumber = 8; - static constexpr int ExtraLineNumber = 7; - static constexpr int ColumnNumber = 13; - const sycl::detail::code_location TestCodeLocation = { - FileName, FunctionName, LineNumber, ColumnNumber}; - const sycl::detail::code_location ExtraTestCodeLocation = { - FileName, ExtraFunctionName, ExtraLineNumber, ColumnNumber}; - static constexpr size_t KernelSize = 1; - using TestKI = detail::KernelInfo>; - - const std::string TestCodeLocationMessage = BuildCodeLocationMessage( - FileName, FunctionName, LineNumber, ColumnNumber); - const std::string ExtraTestCodeLocationMessage = BuildCodeLocationMessage( - FileName, ExtraFunctionName, ExtraLineNumber, ColumnNumber); - const std::string TestKernelLocationMessage = BuildCodeLocationMessage( - TestKI::getFileName(), TestKI::getFunctionName(), TestKI::getLineNumber(), - TestKI::getColumnNumber()); - const std::string URLevelFailMessage = "Native API failed"; - const std::string SYCLLevelFailMessage = "Enqueue process failed"; -}; - -TEST_F(QueueApiFailures, QueueSubmit) { - mock::getCallbacks().set_replace_callback("urEnqueueKernelLaunch", - &redefinedEnqueueKernelLaunch); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - sycl::queue Q; - bool ExceptionCaught = false; - try { - Q.submit( - [&](handler &Cgh) { - Cgh.single_task>([=]() {}); - }, - TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - ASSERT_TRUE(ExceptionCaught); - uint16_t TraceType = 0; - std::string Message; - EXPECT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestCodeLocationMessage)); - EXPECT_FALSE(queryReceivedNotifications(TraceType, Message)); -} - -TEST_F(QueueApiFailures, QueueSingleTask) { - mock::getCallbacks().set_replace_callback("urEnqueueKernelLaunch", - &redefinedEnqueueKernelLaunch); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - sycl::queue Q; - bool ExceptionCaught = false; - try { - Q.single_task>([=]() {}, TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - ASSERT_TRUE(ExceptionCaught); - uint16_t TraceType = 0; - std::string Message; - EXPECT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestCodeLocationMessage)); - EXPECT_FALSE(queryReceivedNotifications(TraceType, Message)); -} - -ur_result_t redefinedEnqueueUSMFill(void *) { - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; -} - -TEST_F(QueueApiFailures, QueueMemset) { - mock::getCallbacks().set_replace_callback("urEnqueueUSMFill", - &redefinedEnqueueUSMFill); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - sycl::queue Q; - bool ExceptionCaught = false; - unsigned char *HostAlloc = (unsigned char *)sycl::malloc_host(1, Q); - try { - Q.memset(HostAlloc, 42, 1, TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - sycl::free(HostAlloc, Q); - ASSERT_TRUE(ExceptionCaught); - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestCodeLocationMessage)); - EXPECT_FALSE(queryReceivedNotifications(TraceType, Message)); -} - -ur_result_t redefinedUSMEnqueueMemcpy(void *) { - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; -} - -TEST_F(QueueApiFailures, QueueMemcpy) { - mock::getCallbacks().set_replace_callback("urEnqueueUSMMemcpy", - &redefinedUSMEnqueueMemcpy); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - sycl::queue Q; - bool ExceptionCaught = false; - unsigned char *HostAllocSrc = (unsigned char *)sycl::malloc_host(1, Q); - unsigned char *HostAllocDst = (unsigned char *)sycl::malloc_host(1, Q); - try { - Q.memcpy(HostAllocDst, HostAllocSrc, 1, TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - sycl::free(HostAllocSrc, Q); - sycl::free(HostAllocDst, Q); - ASSERT_TRUE(ExceptionCaught); - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestCodeLocationMessage)); - EXPECT_FALSE(queryReceivedNotifications(TraceType, Message)); -} - -TEST_F(QueueApiFailures, QueueCopy) { - mock::getCallbacks().set_replace_callback("urEnqueueUSMMemcpy", - &redefinedUSMEnqueueMemcpy); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - sycl::queue Q; - bool ExceptionCaught = false; - unsigned char *HostAllocSrc = (unsigned char *)sycl::malloc_host(1, Q); - unsigned char *HostAllocDst = (unsigned char *)sycl::malloc_host(1, Q); - try { - Q.copy(HostAllocDst, HostAllocSrc, 1, TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - sycl::free(HostAllocSrc, Q); - sycl::free(HostAllocDst, Q); - ASSERT_TRUE(ExceptionCaught); - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestCodeLocationMessage)); - EXPECT_FALSE(queryReceivedNotifications(TraceType, Message)); -} - -TEST_F(QueueApiFailures, QueueFill) { - mock::getCallbacks().set_replace_callback("urEnqueueUSMFill", - &redefinedEnqueueUSMFill); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - sycl::queue Q; - bool ExceptionCaught = false; - unsigned char *HostAlloc = (unsigned char *)sycl::malloc_host(1, Q); - try { - Q.fill(HostAlloc, 42, 1, TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - sycl::free(HostAlloc, Q); - ASSERT_TRUE(ExceptionCaught); - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestCodeLocationMessage)); - EXPECT_THAT(Message, HasSubstr(URLevelFailMessage)); - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestCodeLocationMessage)); - EXPECT_THAT(Message, HasSubstr(SYCLLevelFailMessage)); - EXPECT_FALSE(queryReceivedNotifications(TraceType, Message)); -} - -inline ur_result_t redefinedUSMEnqueuePrefetch(void *) { - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; -} - -TEST_F(QueueApiFailures, QueuePrefetch) { - mock::getCallbacks().set_replace_callback("urEnqueueUSMPrefetch", - &redefinedUSMEnqueuePrefetch); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - sycl::queue Q; - bool ExceptionCaught = false; - unsigned char *HostAlloc = (unsigned char *)sycl::malloc_host(4, Q); - try { - Q.prefetch(HostAlloc, 2, TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - sycl::free(HostAlloc, Q); - ASSERT_TRUE(ExceptionCaught); - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestCodeLocationMessage)); - EXPECT_THAT(Message, HasSubstr(URLevelFailMessage)); - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestCodeLocationMessage)); - EXPECT_THAT(Message, HasSubstr(SYCLLevelFailMessage)); - EXPECT_FALSE(queryReceivedNotifications(TraceType, Message)); -} - -inline ur_result_t redefinedUSMEnqueueMemAdvise(void *) { - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; -} - -TEST_F(QueueApiFailures, QueueMemAdvise) { - mock::getCallbacks().set_replace_callback("urEnqueueUSMAdvise", - &redefinedUSMEnqueueMemAdvise); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - sycl::queue Q; - bool ExceptionCaught = false; - unsigned char *HostAlloc = (unsigned char *)sycl::malloc_host(1, Q); - try { - Q.mem_advise(HostAlloc, 1, 0 /*default*/, TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - sycl::free(HostAlloc, Q); - ASSERT_TRUE(ExceptionCaught); - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestCodeLocationMessage)); - EXPECT_FALSE(queryReceivedNotifications(TraceType, Message)); -} - -TEST_F(QueueApiFailures, QueueParallelFor) { - mock::getCallbacks().set_replace_callback("urEnqueueKernelLaunch", - &redefinedEnqueueKernelLaunch); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - sycl::queue Q; - bool ExceptionCaught = false; - const int globalWIs{512}; - try { - Q.parallel_for>(globalWIs, [=](sycl::id<1> idx) {}); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - Q.wait(); - ASSERT_TRUE(ExceptionCaught); - uint16_t TraceType = 0; - std::string Message; - EXPECT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(TestKernelLocationMessage)); - EXPECT_FALSE(queryReceivedNotifications(TraceType, Message)); -} - -inline ur_result_t redefinedEventWait(void *) { - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; -} - -inline void silentAsyncHandler(exception_list Exceptions) { - std::ignore = Exceptions; -} - -TEST_F(QueueApiFailures, QueueHostTaskWaitFail) { - mock::getCallbacks().set_replace_callback("urEventWait", &redefinedEventWait); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - sycl::queue Q(default_selector(), silentAsyncHandler); - bool ExceptionCaught = false; - event EventToDepend; - try { - EventToDepend = - Q.single_task>([=]() {}, TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - EXPECT_FALSE(ExceptionCaught); - const std::string HostTaskExceptionStr = "Host task exception"; - try { - Q.submit( - [&](handler &Cgh) { - Cgh.depends_on(EventToDepend); - Cgh.host_task( - [=]() { throw std::runtime_error(HostTaskExceptionStr); }); - }, - ExtraTestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - EXPECT_FALSE(ExceptionCaught); - Q.wait(); - - uint16_t TraceType = 0; - std::string Message; - EXPECT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(ExtraTestCodeLocationMessage)); - EXPECT_THAT(Message, Not(HasSubstr(HostTaskExceptionStr))); -} - -TEST_F(QueueApiFailures, QueueHostTaskFail) { - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - enum ExceptionType { STD_EXCEPTION = 0, SYCL_EXCEPTION }; - auto Test = [&](ExceptionType ExType) { - sycl::queue Q(default_selector(), silentAsyncHandler); - bool ExceptionCaught = false; - event EventToDepend; - const std::string HostTaskExeptionStr = "Host task exception"; - try { - EventToDepend = - Q.single_task>([=]() {}, TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - EXPECT_FALSE(ExceptionCaught); - try { - Q.submit( - [&](handler &Cgh) { - Cgh.depends_on(EventToDepend); - Cgh.host_task([=]() { - if (ExType == SYCL_EXCEPTION) - throw sycl::exception(sycl::make_error_code(errc::invalid), - HostTaskExeptionStr); - else - throw std::runtime_error(HostTaskExeptionStr); - }); - }, - ExtraTestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - EXPECT_FALSE(ExceptionCaught); - Q.wait(); - - uint16_t TraceType = 0; - std::string Message; - EXPECT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(ExtraTestCodeLocationMessage)); - EXPECT_THAT(Message, HasSubstr(HostTaskExeptionStr)); - resetReceivedNotifications(); - }; - Test(SYCL_EXCEPTION); - Test(STD_EXCEPTION); -} - -std::mutex m; -std::condition_variable cv; -bool EnqueueKernelLaunchCalled = false; - -ur_result_t redefinedEnqueueKernelLaunchWithStatus(void *) { - { - std::lock_guard lk(m); - EnqueueKernelLaunchCalled = true; - } - cv.notify_one(); - return UR_RESULT_ERROR_ADAPTER_SPECIFIC; -} - -TEST_F(QueueApiFailures, QueueKernelAsync) { - mock::getCallbacks().set_replace_callback( - "urEnqueueKernelLaunch", &redefinedEnqueueKernelLaunchWithStatus); - mock::getCallbacks().set_replace_callback("urAdapterGetLastError", - &redefinedAdapterGetLastError); - - sycl::queue Q(default_selector(), silentAsyncHandler); - bool ExceptionCaught = false; - event EventToDepend; - - std::mutex m; - std::function CustomHostLambda = [&m]() { - std::unique_lock InsideHostTaskLock(m); - }; - std::unique_lock TestLock(m, std::defer_lock); - TestLock.lock(); - try { - EventToDepend = Q.submit( - [&](handler &Cgh) { - Cgh.depends_on(EventToDepend); - Cgh.host_task(CustomHostLambda); - }, - TestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - EXPECT_FALSE(ExceptionCaught); - - try { - Q.submit( - [&](handler &Cgh) { - Cgh.depends_on(EventToDepend); - Cgh.single_task>([=]() {}); - }, - ExtraTestCodeLocation); - } catch (sycl::exception &e) { - std::ignore = e; - ExceptionCaught = true; - } - EXPECT_FALSE(ExceptionCaught); - TestLock.unlock(); - - // Need to wait till host task enqueue kernel to check code location report. - { - std::unique_lock lk(m); - cv.wait(lk, [] { return EnqueueKernelLaunchCalled; }); - } - - try { - Q.wait(); - } catch (...) { - // kernel enqueue leads to exception throw - } - - uint16_t TraceType = 0; - std::string Message; - EXPECT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_diagnostics); - EXPECT_THAT(Message, HasSubstr(ExtraTestCodeLocationMessage)); -} diff --git a/sycl/unittests/xpti_trace/QueueIDCheck.cpp b/sycl/unittests/xpti_trace/QueueIDCheck.cpp deleted file mode 100644 index 5dab29a603b3c..0000000000000 --- a/sycl/unittests/xpti_trace/QueueIDCheck.cpp +++ /dev/null @@ -1,191 +0,0 @@ -//==------------ QueueIDCheck.cpp --- XPTI integration unit tests ----------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include -#include -#include - -#include -#include - -#include -#include - -#include - -using ::testing::HasSubstr; -using namespace sycl; -XPTI_CALLBACK_API bool queryReceivedNotifications(uint16_t &TraceType, - std::string &Message); -XPTI_CALLBACK_API void resetReceivedNotifications(); -XPTI_CALLBACK_API void addAnalyzedTraceType(uint16_t); -XPTI_CALLBACK_API void clearAnalyzedTraceTypes(); - -class QueueID : public ::testing::Test { -protected: - void SetUp() { - xptiForceSetTraceEnabled(true); - xptiTraceTryToEnable(); - addAnalyzedTraceType(xpti::trace_task_begin); - addAnalyzedTraceType(xpti::trace_task_end); - } - - void TearDown() { - clearAnalyzedTraceTypes(); - resetReceivedNotifications(); - xptiForceSetTraceEnabled(false); - } - -public: - unittest::ScopedEnvVar PathToXPTIFW{"XPTI_FRAMEWORK_DISPATCHER", - "libxptifw.so", [] {}}; - unittest::ScopedEnvVar XPTISubscriber{"XPTI_SUBSCRIBERS", - "libxptitest_subscriber.so", [] {}}; - sycl::unittest::UrMock<> MockAdapter; - - static constexpr size_t KernelSize = 1; - - static constexpr char FileName[] = "QueueIDCheck.cpp"; - static constexpr char FunctionName[] = "TestCaseExecution"; - - void checkTaskBeginEnd(const std::string &QueueIDStr) { - uint16_t TraceType = 0; - std::string Message; - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_task_begin); - EXPECT_THAT(Message, HasSubstr("task_begin:queue_id:" + QueueIDStr)); - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_task_end); - EXPECT_THAT(Message, HasSubstr("task_end:queue_id:" + QueueIDStr)); - } -}; - -ur_queue_handle_t QueueHandle = nullptr; -inline ur_result_t redefinedQueueCreate(void *pParams) { - auto params = *static_cast(pParams); - QueueHandle = nullptr; - if (*params.pphQueue) - QueueHandle = **params.pphQueue; - return UR_RESULT_SUCCESS; -} - -TEST_F(QueueID, QueueID_QueueCreationAndDestroy) { - sycl::platform Plt{sycl::platform()}; - mock::getCallbacks().set_after_callback("urQueueCreate", - &redefinedQueueCreate); - sycl::context Context{Plt}; - addAnalyzedTraceType(xpti::trace_queue_create); - addAnalyzedTraceType(xpti::trace_queue_destroy); - uint16_t TraceType = 0; - std::string Message; - std::string Queue0IDSTr; - std::string Queue1IDSTr; - { - sycl::queue Q0{Context, sycl::default_selector{}}; - auto Queue0ImplPtr = sycl::detail::getSyclObjImpl(Q0); - Queue0IDSTr = std::to_string(Queue0ImplPtr->getQueueID()); - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_queue_create); - EXPECT_THAT(Message, HasSubstr("create:queue_id:" + Queue0IDSTr)); - ASSERT_NE(QueueHandle, nullptr); - EXPECT_THAT(Message, HasSubstr("queue_handle:" + - std::to_string(size_t(QueueHandle)))); - - sycl::queue Q1{Context, sycl::default_selector{}}; - auto Queue1ImplPtr = sycl::detail::getSyclObjImpl(Q1); - Queue1IDSTr = std::to_string(Queue1ImplPtr->getQueueID()); - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_queue_create); - EXPECT_THAT(Message, HasSubstr("create:queue_id:" + Queue1IDSTr)); - ASSERT_NE(QueueHandle, nullptr); - EXPECT_THAT(Message, HasSubstr("queue_handle:" + - std::to_string(size_t(QueueHandle)))); - } - - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_queue_destroy); - EXPECT_THAT(Message, HasSubstr("destroy:queue_id:" + Queue1IDSTr)); - ASSERT_TRUE(queryReceivedNotifications(TraceType, Message)); - EXPECT_EQ(TraceType, xpti::trace_queue_destroy); - EXPECT_THAT(Message, HasSubstr("destroy:queue_id:" + Queue0IDSTr)); -} - -TEST_F(QueueID, QueueCreationAndKernelWithDeps) { - sycl::queue Q0; - sycl::queue Q1; - auto Queue0ImplPtr = sycl::detail::getSyclObjImpl(Q0); - auto Queue1ImplPtr = sycl::detail::getSyclObjImpl(Q1); - sycl::buffer buf(sycl::range<1>(1)); - Q1.submit( - [&](handler &Cgh) { - sycl::accessor acc(buf, Cgh, sycl::read_write); - Cgh.parallel_for>(1, [=](sycl::id<1> idx) {}); - }, - {FileName, FunctionName, 1, 0}) - .wait(); - EXPECT_NE(Queue1ImplPtr->getQueueID(), Queue0ImplPtr->getQueueID()); - auto QueueIDSTr = std::to_string(Queue1ImplPtr->getQueueID()); - // alloca - checkTaskBeginEnd(QueueIDSTr); - // kernel - checkTaskBeginEnd(QueueIDSTr); -} - -// Re-enable this test after fixing -// https://github.com/intel/llvm/issues/12963 -TEST_F(QueueID, DISABLED_QueueCreationUSMOperations) { - sycl::queue Q0; - auto Queue0ImplPtr = sycl::detail::getSyclObjImpl(Q0); - auto QueueIDSTr = std::to_string(Queue0ImplPtr->getQueueID()); - - unsigned char *AllocSrc = (unsigned char *)sycl::malloc_device(1, Q0); - unsigned char *AllocDst = (unsigned char *)sycl::malloc_device(1, Q0); - Q0.memset(AllocSrc, 42, 1).wait(); - checkTaskBeginEnd(QueueIDSTr); - - Q0.memcpy(AllocDst, AllocSrc, 1).wait(); - checkTaskBeginEnd(QueueIDSTr); - - Q0.submit([&](handler &Cgh) { Cgh.memset(AllocSrc, 42, 1); }).wait(); - checkTaskBeginEnd(QueueIDSTr); - - Q0.submit([&](handler &Cgh) { Cgh.memcpy(AllocDst, AllocSrc, 1); }).wait(); - checkTaskBeginEnd(QueueIDSTr); - - sycl::free(AllocSrc, Q0); - sycl::free(AllocDst, Q0); -} - -TEST_F(QueueID, QueueCreationAndKernelNoDeps) { - sycl::queue Q0; - sycl::queue Q1; - - auto Queue0ImplPtr = sycl::detail::getSyclObjImpl(Q0); - auto Queue0IDSTr = std::to_string(Queue0ImplPtr->getQueueID()); - - auto Queue1ImplPtr = sycl::detail::getSyclObjImpl(Q1); - auto Queue1IDSTr = std::to_string(Queue1ImplPtr->getQueueID()); - - Q0.submit( - [&](handler &Cgh) { - Cgh.parallel_for>(1, [=](sycl::id<1> idx) {}); - }, - {FileName, FunctionName, 2, 0}) - .wait(); - checkTaskBeginEnd(Queue0IDSTr); - - Q1.submit( - [&](handler &Cgh) { - Cgh.parallel_for>(1, [=](sycl::id<1> idx) {}); - }, - {FileName, FunctionName, 3, 0}) - .wait(); - checkTaskBeginEnd(Queue1IDSTr); -} - -// host + kernel tasks diff --git a/sycl/unittests/xpti_trace/xptitest_subscriber/CMakeLists.txt b/sycl/unittests/xpti_trace/xptitest_subscriber/CMakeLists.txt deleted file mode 100644 index 84d52b9d858f4..0000000000000 --- a/sycl/unittests/xpti_trace/xptitest_subscriber/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_library(xptitest_subscriber SHARED XPTISubscriber.cpp) -target_compile_definitions(xptitest_subscriber PRIVATE XPTI_CALLBACK_API_EXPORTS) -target_link_libraries(xptitest_subscriber PRIVATE xptifw) diff --git a/sycl/unittests/xpti_trace/xptitest_subscriber/XPTISubscriber.cpp b/sycl/unittests/xpti_trace/xptitest_subscriber/XPTISubscriber.cpp deleted file mode 100644 index 2c79f76269c11..0000000000000 --- a/sycl/unittests/xpti_trace/xptitest_subscriber/XPTISubscriber.cpp +++ /dev/null @@ -1,173 +0,0 @@ -//==---------------------- XPTISubscriber.cpp ------------------------------==// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include "xpti/xpti_trace_framework.hpp" - -#include -#include -#include -#include -#include -#include -#include - -std::deque> GReceivedNotifications; -std::set GAnalyzedTraceTypes; - -XPTI_CALLBACK_API void addAnalyzedTraceType(uint16_t TraceType) { - GAnalyzedTraceTypes.insert(TraceType); -} - -XPTI_CALLBACK_API void clearAnalyzedTraceTypes() { - GAnalyzedTraceTypes.clear(); -} - -XPTI_CALLBACK_API void testCallback(uint16_t TraceType, - xpti::trace_event_data_t * /*Parent*/, - xpti::trace_event_data_t *Event, - uint64_t /*Instance*/, - const void *UserData) { - if (GAnalyzedTraceTypes.find(TraceType) == GAnalyzedTraceTypes.end()) - return; - - // Since "queue_id" is no longer a metadata item, we have to retrieve it from - // TLS using new XPTI API - char *Key = 0; - uint64_t Value; - bool HaveKeyValue = - (xptiGetStashedTuple(&Key, Value) == xpti::result_t::XPTI_RESULT_SUCCESS); - - if (TraceType == xpti::trace_diagnostics) { - std::string AggregatedData; - if (Event && Event->reserved.payload && Event->reserved.payload->name && - Event->reserved.payload->source_file) { - auto Payload = Event->reserved.payload; - const char Delimiter[] = ";"; - AggregatedData.append(Payload->name); - AggregatedData.append(Delimiter); - AggregatedData.append(Payload->source_file); - AggregatedData.append(Delimiter); - AggregatedData.append(std::to_string(Payload->line_no) + Delimiter + - std::to_string(Payload->column_no) + Delimiter); - } else - AggregatedData.append("code location unknown;"); - AggregatedData.append(static_cast(UserData)); - GReceivedNotifications.push_back(std::make_pair(TraceType, AggregatedData)); - } else if (TraceType == xpti::trace_node_create) { - std::string UData(static_cast(UserData)); - if (UData.find("command_group_node") != std::string::npos) { - auto Payload = xptiQueryPayload(Event); - xpti::metadata_t *Metadata = xptiQueryMetadata(Event); - for (const auto &Item : *Metadata) { - std::string_view Key{xptiLookupString(Item.first)}; - if (Key == "kernel_name") { - GReceivedNotifications.push_back( - std::make_pair(TraceType, UData + std::string(Payload->name))); - } - } - } else if (UData.find("memory_transfer_node") != std::string::npos) { - GReceivedNotifications.push_back(std::make_pair(TraceType, UData)); - } - } else if (TraceType == xpti::trace_queue_create) { - if (Event) { - std::string Message; - xpti::metadata_t *Metadata = xptiQueryMetadata(Event); - for (const auto &Item : *Metadata) { - std::string_view Key{xptiLookupString(Item.first)}; - if (Key == "queue_id") { - Message.append( - std::string("create:") + Key.data() + std::string(":") + - std::to_string( - xpti::getMetadata(Item).second)); - Message.append(";"); - } else if (Key == "queue_handle") { - Message.append( - Key.data() + std::string(":") + - std::to_string(xpti::getMetadata(Item).second)); - Message.append(";"); - } - } - GReceivedNotifications.push_back(std::make_pair(TraceType, Message)); - } - } else if (TraceType == xpti::trace_queue_destroy) { - if (Event) { - std::string Message; - xpti::metadata_t *Metadata = xptiQueryMetadata(Event); - for (const auto &Item : *Metadata) { - std::string_view Key{xptiLookupString(Item.first)}; - if (Key == "queue_id") { - Message.append( - std::string("destroy:") + Key.data() + std::string(":") + - std::to_string( - xpti::getMetadata(Item).second)); - Message.append(";"); - } else if (Key == "queue_handle") { - Message.append( - Key.data() + std::string(":") + - std::to_string(xpti::getMetadata(Item).second)); - Message.append(";"); - } - } - GReceivedNotifications.push_back(std::make_pair(TraceType, Message)); - } - } else if (TraceType == xpti::trace_task_begin) { - if (Event) { - std::string Message; - // Since we have changed we send the "queue_id" information, we no longer - // have to check the metadata for the instance ID - if (HaveKeyValue) { - Message.append(std::string("task_begin:") + Key + std::string(":") + - std::to_string(Value)); - } - GReceivedNotifications.push_back(std::make_pair(TraceType, Message)); - } - } else if (TraceType == xpti::trace_task_end) { - if (Event) { - std::string Message; - // Since we have changed we send the "queue_id" information, we no longer - // have to check the metadata for the instance ID - if (HaveKeyValue) { - Message.append(std::string("task_end:") + Key + std::string(":") + - std::to_string(Value)); - } - GReceivedNotifications.push_back(std::make_pair(TraceType, Message)); - } - } -} - -XPTI_CALLBACK_API void xptiTraceInit(unsigned int /*major_version*/, - unsigned int /*minor_version*/, - const char * /*version_str*/, - const char * /*StreamName*/) { - uint8_t StreamID = xptiRegisterStream("sycl"); - xptiRegisterCallback(StreamID, xpti::trace_diagnostics, testCallback); - xptiRegisterCallback(StreamID, xpti::trace_node_create, testCallback); - xptiRegisterCallback(StreamID, xpti::trace_task_begin, testCallback); - xptiRegisterCallback(StreamID, xpti::trace_task_end, testCallback); - xptiRegisterCallback(StreamID, xpti::trace_queue_create, testCallback); - xptiRegisterCallback(StreamID, xpti::trace_queue_destroy, testCallback); - xptiRegisterCallback(StreamID, xpti::trace_task_begin, testCallback); - xptiRegisterCallback(StreamID, xpti::trace_task_end, testCallback); -} - -XPTI_CALLBACK_API void xptiTraceFinish(const char * /*StreamName*/) {} - -XPTI_CALLBACK_API bool queryReceivedNotifications(uint16_t &TraceType, - std::string &Message) { - if (GReceivedNotifications.empty()) - return false; - auto &[traceType, message] = GReceivedNotifications.front(); - TraceType = traceType; - Message = message; - GReceivedNotifications.pop_front(); - return true; -} - -XPTI_CALLBACK_API void resetReceivedNotifications() { - GReceivedNotifications.clear(); -}