├── isea.bat ├── memory.cpp ├── wiki ├── DGML.png ├── WPA.png ├── SEA-QT.PNG ├── SEA-gv.png ├── nodejs.png ├── pprof.png ├── SEA-QT2.PNG ├── SEA-chrome.PNG ├── RadTelemetry.PNG ├── SEA_zverokod.png └── XCodeInstruments.png ├── sea_itt_lib ├── IntelSEAPI.man ├── register.bat ├── Copyright.txt ├── IntelSEAPI_roi.xml ├── ETWHandler.cpp ├── DTraceHandler.cpp ├── SystraceHandler.cpp ├── sea_itt_lib.mm ├── IntelSEAPI.wprp ├── Recorder.h ├── mmv_stats.cpp ├── RadTelemetry.cpp ├── IntelSEAPI.instrument ├── ETLRelogger.cpp ├── Utils.h └── CMakeLists.txt ├── test_linux.sh ├── isea_test.h ├── ittnotify ├── src │ └── ittnotify │ │ ├── LICENSE.BSD │ │ ├── disable_warnings.h │ │ └── ittnotify_types.h ├── CMakeLists.txt └── include │ └── libittnotify.h ├── test_osx.sh ├── test_win.bat ├── test_dotnet.bat ├── dotnet ├── SEAPI │ ├── IInitializer.cs │ ├── Scope.cs │ ├── Track.cs │ ├── InitializerBase.cs │ ├── INative.cs │ ├── Task.cs │ ├── SEAPI.csproj │ ├── OSXInitializer.cs │ ├── WindowsInitializer.cs │ ├── NativeBase.cs │ ├── ITT.cs │ ├── LinuxInitializer.cs │ └── Native.tt ├── SEAPI_Test │ ├── SEAPI_Test.csproj │ └── Program.cs └── SEAPI.sln ├── .gitignore ├── isea.sh ├── runtool ├── strings.py ├── python_compat.py ├── exporters │ ├── Stat.py │ ├── BestTraceFormat.py │ ├── memory.py │ ├── GraphViz.py │ ├── DGML.py │ └── QtCreatorProfiler.py ├── decoders │ ├── PVR.py │ ├── MSNT_SystemTrace.py │ └── SteamVR.py ├── importers │ ├── mac_log.py │ ├── perf.py │ ├── json.py │ └── ftrace.py └── collectors │ ├── android.py │ └── ftrace.py ├── README.md ├── trace_viewer ├── compile.py └── prefix.html ├── java └── com_intel_sea_IntelSEAPI.cpp ├── CompilerAutomatedInstrumentation.cpp ├── driver └── sea_itt_driver.c └── README.txt /isea.bat: -------------------------------------------------------------------------------- 1 | python %~dp0..\runtool\sea_runtool.py %* 2 | -------------------------------------------------------------------------------- /memory.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/memory.cpp -------------------------------------------------------------------------------- /wiki/DGML.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/DGML.png -------------------------------------------------------------------------------- /wiki/WPA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/WPA.png -------------------------------------------------------------------------------- /wiki/SEA-QT.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/SEA-QT.PNG -------------------------------------------------------------------------------- /wiki/SEA-gv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/SEA-gv.png -------------------------------------------------------------------------------- /wiki/nodejs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/nodejs.png -------------------------------------------------------------------------------- /wiki/pprof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/pprof.png -------------------------------------------------------------------------------- /wiki/SEA-QT2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/SEA-QT2.PNG -------------------------------------------------------------------------------- /wiki/SEA-chrome.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/SEA-chrome.PNG -------------------------------------------------------------------------------- /wiki/RadTelemetry.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/RadTelemetry.PNG -------------------------------------------------------------------------------- /wiki/SEA_zverokod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/SEA_zverokod.png -------------------------------------------------------------------------------- /wiki/XCodeInstruments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/wiki/XCodeInstruments.png -------------------------------------------------------------------------------- /sea_itt_lib/IntelSEAPI.man: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/sea_itt_lib/IntelSEAPI.man -------------------------------------------------------------------------------- /test_linux.sh: -------------------------------------------------------------------------------- 1 | python ./runtool/sea_runtool.py -o /tmp/Test -f gt qt gv dgml --stacks ! ./bin/TestIntelSEAPI32 -------------------------------------------------------------------------------- /isea_test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | std::string get_environ_value(const std::string& name); 5 | -------------------------------------------------------------------------------- /ittnotify/src/ittnotify/LICENSE.BSD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IntelSEAPI/HEAD/ittnotify/src/ittnotify/LICENSE.BSD -------------------------------------------------------------------------------- /test_osx.sh: -------------------------------------------------------------------------------- 1 | python3 ./runtool/sea_runtool.py -o ./build_darwin/Test -f gt qt gv dgml --stacks --memory=detailed --dir ./bin ! ./bin/TestIntelSEAPI 2 | -------------------------------------------------------------------------------- /test_win.bat: -------------------------------------------------------------------------------- 1 | python ./runtool/sea_runtool.py -o ./build_win/Test -f gt qt gv dgml --stacks --memory=detailed ! ./bin/TestIntelSEAPI32.exe 2 | pause 3 | -------------------------------------------------------------------------------- /test_dotnet.bat: -------------------------------------------------------------------------------- 1 | python ./runtool/sea_runtool.py -o ./dotnet/bin/Test -f gt qt gv dgml --stacks ! dotnet ./dotnet/bin/netcoreapp2.0/SEAPI_Test.dll 2 | pause -------------------------------------------------------------------------------- /dotnet/SEAPI/IInitializer.cs: -------------------------------------------------------------------------------- 1 | namespace SEAPI 2 | { 3 | internal interface IInitializer 4 | { 5 | void Init(); 6 | INative CreateNative(); 7 | } 8 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build_*/ 2 | *.pyc 3 | *.pyo 4 | bin/ 5 | .vs/ 6 | obj/ 7 | *.user 8 | runtool/SEARunTool.pyproj 9 | runtool/.idea/ 10 | .idea/ 11 | tags 12 | cmake-build* 13 | -------------------------------------------------------------------------------- /isea.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | SCRIPT_NAME=$(perl -e 'use Cwd "abs_path"; print abs_path(@ARGV[0])' -- "$0") 3 | BASEDIR=$(dirname ${SCRIPT_NAME}) 4 | python ${BASEDIR}/runtool/sea_runtool.py "$@" 5 | -------------------------------------------------------------------------------- /dotnet/SEAPI/Scope.cs: -------------------------------------------------------------------------------- 1 | namespace SEAPI 2 | { 3 | public enum Scope 4 | { 5 | Global = 1, 6 | Process = 2, 7 | Thread = 3, 8 | Task = 4 9 | }; 10 | } -------------------------------------------------------------------------------- /sea_itt_lib/register.bat: -------------------------------------------------------------------------------- 1 | start README.txt 2 | wevtutil.exe um "%CD%\ETW\IntelSEAPI.man" 3 | wevtutil.exe im "%CD%\ETW\IntelSEAPI.man" /rf:"%CD%\bin\IntelSEAPI32.dll" /mf:"%CD%\bin\IntelSEAPI32.dll" 4 | -------------------------------------------------------------------------------- /runtool/strings.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | converting = 'Converting: %s (%s)' 3 | parsing_files = 'Parsing files: %s (%s)' 4 | catapulting = 'Generating HTML page' 5 | -------------------------------------------------------------------------------- /dotnet/SEAPI/Track.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SEAPI 4 | { 5 | public class Track : IDisposable 6 | { 7 | private readonly INative _native; 8 | 9 | internal Track(INative native, IntPtr pointer) 10 | { 11 | _native = native; 12 | _native.SetTrack(pointer); 13 | } 14 | 15 | public void Dispose() 16 | { 17 | _native.SetTrack(IntPtr.Zero); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DISCONTINUATION OF PROJECT 2 | 3 | This project will no longer be maintained by Intel. 4 | 5 | Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project. 6 | 7 | Intel no longer accepts patches to this project. 8 | 9 | If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project. 10 | 11 | Contact: webadmin@linux.intel.com 12 | -------------------------------------------------------------------------------- /trace_viewer/compile.py: -------------------------------------------------------------------------------- 1 | import os 2 | import codecs 3 | 4 | # use vulcanized_traceviewer to create trace_viewer_full.html 5 | 6 | 7 | def read_file(filename): 8 | with codecs.open(filename, 'r', 'utf-8') as fh: 9 | return fh.read() 10 | 11 | 12 | result = read_file('prefix.html') 13 | 14 | viewer = read_file('trace_viewer_full.html') 15 | result = result.replace('{{TRACE_VIEWER_HTML}}', viewer) 16 | 17 | license = read_file('LICENSE') 18 | result = result.replace('{{ISEA_CATAPULT_LICENSE}}', license) 19 | 20 | with codecs.open(os.path.join('../isea.htm'), 'w', 'utf-8') as fh: 21 | fh.writelines(result) 22 | 23 | -------------------------------------------------------------------------------- /runtool/python_compat.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.version_info[0] > 2: 4 | import queue as queue 5 | basestring = (str, bytes) 6 | unicode = str 7 | 8 | def func_name(func_object): 9 | return func_object.__name__ 10 | def func_globals(func_object): 11 | return func_object.__globals__ 12 | def func_code(func_object): 13 | return func_object.__code__ 14 | 15 | raw_input = input 16 | else: 17 | import Queue as queue 18 | basestring = basestring 19 | unicode = unicode 20 | 21 | def func_name(func_object): 22 | return func_object.func_name 23 | def func_globals(func_object): 24 | return func_object.func_globals 25 | def func_code(func_object): 26 | return func_object.func_code 27 | -------------------------------------------------------------------------------- /dotnet/SEAPI_Test/SEAPI_Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.0 5 | Debug;Release 6 | AnyCPU 7 | 8 | Exe 9 | SEAPI_Test.Program 10 | 11 | 12 | 13 | ..\bin\ 14 | x64 15 | 16 | 17 | 18 | ..\bin\ 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /dotnet/SEAPI/InitializerBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | using System.Runtime.Loader; 5 | 6 | namespace SEAPI 7 | { 8 | internal abstract class InitializerBase : AssemblyLoadContext, IInitializer 9 | { 10 | protected static readonly string Bitness = GetBitness(); 11 | 12 | public abstract void Init(); 13 | public abstract INative CreateNative(); 14 | 15 | protected override Assembly Load(AssemblyName assemblyName) 16 | { 17 | return null; 18 | } 19 | 20 | private static string GetBitness() 21 | { 22 | switch (RuntimeInformation.OSArchitecture) 23 | { 24 | case Architecture.Arm: 25 | case Architecture.X86: 26 | return "32"; 27 | case Architecture.Arm64: 28 | case Architecture.X64: 29 | return "64"; 30 | default: 31 | throw new ArgumentOutOfRangeException(); 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /dotnet/SEAPI/INative.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SEAPI 4 | { 5 | internal interface INative 6 | { 7 | IntPtr CreateDomain(string name); 8 | void Marker(IntPtr domain, ulong id, string name, int scope, ulong timestamp); 9 | void BeginTask(IntPtr domain, ulong id, ulong parent, string name, ulong timestamp); 10 | void BeginOverlappedTask(IntPtr domain, ulong id, ulong parent, string name, ulong timestamp); 11 | void AddMetadata(IntPtr domain, ulong id, string name, double value); 12 | void AddStringMetadata(IntPtr domain, ulong id, string name, string value); 13 | void AddBlobMetadata(IntPtr domain, ulong id, string name, IntPtr value, uint size); 14 | void EndTask(IntPtr domain, ulong timestamp); 15 | void EndOverlappedTask(IntPtr domain, ulong timestamp, ulong taskId); 16 | IntPtr CreateCounter(IntPtr domain, string name); 17 | void SetCounter(IntPtr id, double value, ulong timestamp); 18 | IntPtr CreateTrack(string group, string track); 19 | void SetTrack(IntPtr track); 20 | ulong GetTimeStamp(); 21 | } 22 | } -------------------------------------------------------------------------------- /dotnet/SEAPI/Task.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SEAPI 4 | { 5 | public class Task : IDisposable 6 | { 7 | private readonly IntPtr _domain; 8 | private readonly INative _native; 9 | internal readonly ulong Id; 10 | 11 | internal Task(INative native, IntPtr domain, string name, ulong id, Task parent) 12 | { 13 | _native = native; 14 | _domain = domain; 15 | Id = id; 16 | _native.BeginTask(domain, id, parent?.Id ?? 0, name, 0); 17 | } 18 | 19 | 20 | public void Dispose() 21 | { 22 | _native.EndTask(_domain, 0); 23 | } 24 | 25 | public Task AddArgument(string name, double value) 26 | { 27 | _native.AddMetadata(_domain, Id, name, value); 28 | return this; 29 | } 30 | 31 | public Task AddArgument(string name, string value) 32 | { 33 | _native.AddStringMetadata(_domain, Id, name, value); 34 | return this; 35 | } 36 | 37 | public Task AddData(string name, byte[] value) 38 | { 39 | unsafe 40 | { 41 | fixed (byte* p = value) 42 | { 43 | _native.AddBlobMetadata(_domain, Id, name, (IntPtr)p, (uint)value.Length); 44 | } 45 | } 46 | 47 | return this; 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /dotnet/SEAPI_Test/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using SEAPI; 4 | 5 | namespace SEAPI_Test 6 | { 7 | public static class Program 8 | { 9 | private static readonly Random Random = new Random(); 10 | 11 | private static void StartTask(ITT domain) 12 | { 13 | using (domain.GetTask("dotnet_task")) 14 | { 15 | Thread.Sleep(10); 16 | if (Random.Next(2) != 0) 17 | { 18 | StartTask(domain); 19 | } 20 | 21 | Thread.Sleep(10); 22 | } 23 | } 24 | 25 | public static void Main(string[] args) 26 | { 27 | var domain = ITT.CreateDomain("dotnet"); 28 | domain.Marker("Begin"); 29 | var ts1 = ITT.GetTimeStamp(); 30 | using (var task = domain.GetTask("Main")) 31 | { 32 | for (var i = 0; i < 100; i++) 33 | { 34 | StartTask(domain); 35 | domain.SetCounter("dotnet_counter", i); 36 | } 37 | } 38 | 39 | var ts2 = ITT.GetTimeStamp(); 40 | domain.Marker("End"); 41 | using (ITT.GetTrack("group", "track")) 42 | { 43 | var dur = (ts2 - ts1) / 100 + 1; 44 | for (var i = ts1; i <= ts2; i += dur) 45 | { 46 | domain.SubmitTask("submitted", dur, dur / 2); 47 | } 48 | } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /runtool/exporters/Stat.py: -------------------------------------------------------------------------------- 1 | import os 2 | import csv 3 | import shutil 4 | from sea_runtool import GraphCombiner 5 | 6 | # Supported values are "csv" and "tsv" 7 | FILE_EXTENSION = ".csv" 8 | 9 | class Stat(GraphCombiner): 10 | def __init__(self, args, tree): 11 | GraphCombiner.__init__(self, args, tree) 12 | 13 | def get_targets(self): 14 | return [self.args.output + FILE_EXTENSION] 15 | 16 | def finish(self): 17 | GraphCombiner.finish(self) 18 | delim = ',' 19 | if FILE_EXTENSION == ".tsv": 20 | delim = '\t' 21 | with open(self.get_targets()[-1], 'w') as f: 22 | writer = csv.writer(f, delimiter=delim) 23 | writer.writerow(["domain", "name", "min", "max", "avg", "total", "count"]) 24 | for domain, data in self.per_domain.items(): 25 | for task_name, task_data in data['tasks'].items(): 26 | time = task_data['time'] 27 | writer.writerow([domain, task_name, min(time), max(time), sum(time) / len(time), sum(time), len(time)]) 28 | 29 | @staticmethod 30 | def join_traces(traces, output, args): # FIXME: implement real joiner 31 | sorting = [] 32 | for trace in traces: 33 | sorting.append((os.path.getsize(trace), trace)) 34 | sorting.sort(key=lambda size_trace: size_trace[0], reverse=True) 35 | shutil.copyfile(sorting[0][1], output + ".tsv") 36 | return output + ".tsv" 37 | 38 | EXPORTER_DESCRIPTORS = [{ 39 | 'format': 'stat', 40 | 'available': True, 41 | 'exporter': Stat 42 | }] 43 | -------------------------------------------------------------------------------- /sea_itt_lib/Copyright.txt: -------------------------------------------------------------------------------- 1 | Intel(R) Single Event API 2 | 3 | This file is provided under the BSD 3-Clause license. 4 | Copyright (c) 2021, Intel Corporation 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 8 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 9 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 13 | 14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 15 | 16 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 | -------------------------------------------------------------------------------- /dotnet/SEAPI/SEAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | Debug;Release 6 | x64;x86 7 | 8 | 9 | 10 | TRACE;DEBUG;BUILD64;NETSTANDARD2_0 11 | true 12 | 13 | 14 | 15 | TRACE;DEBUG;NETSTANDARD2_0 16 | 17 | 18 | 19 | TRACE;BUILD64;RELEASE;NETSTANDARD2_0 20 | 21 | 22 | 23 | TRACE;RELEASE;NETSTANDARD2_0 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | TextTemplatingFileGenerator 33 | Native.cs 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | True 44 | True 45 | Native.tt 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /dotnet/SEAPI/OSXInitializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace SEAPI 5 | { 6 | internal class OSXInitializer : InitializerBase 7 | { 8 | private const string LibraryName = "libIntelSEAPI.dylib"; 9 | 10 | public override void Init() 11 | { 12 | if (TryGetFromEnvironment(out var path) || 13 | TryGetFromCurrentFolder(out path) || 14 | TryGetFromBuildFolder(out path)) 15 | { 16 | LoadUnmanagedDllFromPath(path); 17 | } 18 | } 19 | 20 | public override INative CreateNative() 21 | { 22 | return new libIntelSEAPINative(); 23 | } 24 | 25 | private static bool TryGetFromEnvironment(out string path) 26 | { 27 | path = Environment.GetEnvironmentVariable("DYLD_INSERT_LIBRARIES"); 28 | return !string.IsNullOrWhiteSpace(path) && path.EndsWith(LibraryName) && File.Exists(path); 29 | } 30 | 31 | private static bool TryGetFromCurrentFolder(out string path) 32 | { 33 | path = Path.Combine(Directory.GetCurrentDirectory(), LibraryName); 34 | return File.Exists(path); 35 | } 36 | 37 | private static bool TryGetFromBuildFolder(out string path) 38 | { 39 | var dir = new DirectoryInfo(Directory.GetCurrentDirectory()); 40 | while (dir != null && dir.Name != "dotnet") 41 | { 42 | dir = dir.Parent; 43 | } 44 | 45 | if (dir == null) 46 | { 47 | path = null; 48 | return false; 49 | } 50 | 51 | path = Path.Combine(dir.Parent.FullName, "bin", LibraryName); 52 | return File.Exists(path); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /dotnet/SEAPI/WindowsInitializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace SEAPI 5 | { 6 | internal class WindowsInitializer : InitializerBase 7 | { 8 | private static readonly string LibraryName = $"IntelSEAPI{Bitness}.dll"; 9 | 10 | public override void Init() 11 | { 12 | if (TryGetFromEnvironment(out var path) || 13 | TryGetFromCurrentFolder(out path) || 14 | TryGetFromBuildFolder(out path)) 15 | { 16 | LoadUnmanagedDllFromPath(path); 17 | } 18 | } 19 | 20 | public override INative CreateNative() 21 | { 22 | if (Bitness == "32") 23 | { 24 | return new IntelSEAPI32Native(); 25 | } 26 | 27 | return new IntelSEAPI64Native(); 28 | } 29 | 30 | private static bool TryGetFromEnvironment(out string path) 31 | { 32 | path = Environment.GetEnvironmentVariable($"INTEL_LIBITTNOTIFY{Bitness}"); 33 | return !string.IsNullOrWhiteSpace(path) && path.EndsWith(LibraryName) && File.Exists(path); 34 | } 35 | 36 | private static bool TryGetFromCurrentFolder(out string path) 37 | { 38 | path = Path.Combine(Directory.GetCurrentDirectory(), LibraryName); 39 | return File.Exists(path); 40 | } 41 | 42 | private static bool TryGetFromBuildFolder(out string path) 43 | { 44 | var dir = new DirectoryInfo(Directory.GetCurrentDirectory()); 45 | while (dir != null && dir.Name != "dotnet") 46 | { 47 | dir = dir.Parent; 48 | } 49 | 50 | if (dir == null) 51 | { 52 | path = null; 53 | return false; 54 | } 55 | 56 | path = Path.Combine(dir.Parent.FullName, "bin", LibraryName); 57 | return File.Exists(path); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /sea_itt_lib/IntelSEAPI_roi.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /dotnet/SEAPI.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2020 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SEAPI", "SEAPI\SEAPI.csproj", "{5C924CEC-6742-46A6-BACA-D698EA00CB62}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SEAPI_Test", "SEAPI_Test\SEAPI_Test.csproj", "{E7A75EEC-6CB4-4536-B281-FD51B2959B35}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {5C924CEC-6742-46A6-BACA-D698EA00CB62}.Debug|x64.ActiveCfg = Debug|x64 19 | {5C924CEC-6742-46A6-BACA-D698EA00CB62}.Debug|x86.ActiveCfg = Debug|x86 20 | {5C924CEC-6742-46A6-BACA-D698EA00CB62}.Release|x64.ActiveCfg = Release|x64 21 | {5C924CEC-6742-46A6-BACA-D698EA00CB62}.Release|x64.Build.0 = Release|x64 22 | {5C924CEC-6742-46A6-BACA-D698EA00CB62}.Release|x86.ActiveCfg = Release|x86 23 | {5C924CEC-6742-46A6-BACA-D698EA00CB62}.Release|x86.Build.0 = Release|x86 24 | {E7A75EEC-6CB4-4536-B281-FD51B2959B35}.Debug|x64.ActiveCfg = Debug|Any CPU 25 | {E7A75EEC-6CB4-4536-B281-FD51B2959B35}.Debug|x64.Build.0 = Debug|Any CPU 26 | {E7A75EEC-6CB4-4536-B281-FD51B2959B35}.Debug|x86.ActiveCfg = Debug|Any CPU 27 | {E7A75EEC-6CB4-4536-B281-FD51B2959B35}.Debug|x86.Build.0 = Debug|Any CPU 28 | {E7A75EEC-6CB4-4536-B281-FD51B2959B35}.Release|x64.ActiveCfg = Release|Any CPU 29 | {E7A75EEC-6CB4-4536-B281-FD51B2959B35}.Release|x64.Build.0 = Release|Any CPU 30 | {E7A75EEC-6CB4-4536-B281-FD51B2959B35}.Release|x86.ActiveCfg = Release|Any CPU 31 | {E7A75EEC-6CB4-4536-B281-FD51B2959B35}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(ExtensibilityGlobals) = postSolution 37 | SolutionGuid = {BCF409B9-F658-442B-AC72-8C2A81A4D2DE} 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /sea_itt_lib/ETWHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "IttNotifyStdSrc.h" 2 | 3 | using namespace sea; 4 | 5 | class CETW: public IHandler 6 | { 7 | public: 8 | CETW& operator = (const CETW&) = delete; 9 | void operator = (size_t cookie) 10 | { 11 | m_cookie = m_cookie; 12 | } 13 | inline unsigned short GetDepth(STaskDescriptor* pTask) 14 | { 15 | unsigned short count = 0; 16 | for (;pTask; pTask = pTask->prev, ++count); 17 | return count; 18 | } 19 | 20 | //TODO: It can be called from task_begin_ex. May be ROI allows taking time from records? 21 | void TaskBegin(STaskDescriptor& oTask, bool bOverlapped) override 22 | { 23 | } 24 | 25 | void AddArg(STaskDescriptor& oTask, const __itt_string_handle *pKey, const char *data, size_t length) 26 | { 27 | Cookie(oTask).Add(pKey->strA, length ? std::string(data, length).c_str() : data); 28 | } 29 | 30 | void TaskEnd(STaskDescriptor& oTask, const CTraceEventFormat::SRegularFields& rf, bool bOverlapped) override 31 | { 32 | if (!oTask.pName) 33 | return; 34 | __itt_id id = (bOverlapped || oTask.id.d1 || oTask.id.d2) ? oTask.id : __itt_id{ uint64_t(&oTask), uint64_t(&oTask) }; 35 | uint64_t data[3] = { uint64_t(rf.pid), uint64_t(rf.tid), rf.nanoseconds }; 36 | EventWriteTASK_COMPLETE(oTask.pDomain->nameA, oTask.pName->strA, &IdCaster{ id }.to, &IdCaster{ oTask.parent }.to, Cookie(oTask).Str().c_str(), rf.nanoseconds - oTask.rf.nanoseconds, data); 37 | } 38 | 39 | void Marker(const CTraceEventFormat::SRegularFields& rf, const __itt_domain *pDomain, __itt_id id, __itt_string_handle *pName, __itt_scope scope) override 40 | { 41 | uint64_t data[3] = { uint64_t(rf.pid), uint64_t(rf.tid), rf.nanoseconds }; 42 | EventWriteMARKER(pDomain->nameA, pName->strA, id.d1, GetScope(scope), data); 43 | } 44 | 45 | void Counter(const CTraceEventFormat::SRegularFields& rf, const __itt_domain *pDomain, const __itt_string_handle *pName, double value) override 46 | { 47 | uint64_t data[3] = { uint64_t(rf.pid), uint64_t(rf.tid), rf.nanoseconds }; 48 | EventWriteCOUNTER(pDomain->nameA, pName->strA, value, data); 49 | } 50 | 51 | }* g_pETWHandler = IHandler::Register(true); 52 | 53 | -------------------------------------------------------------------------------- /runtool/decoders/PVR.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | sys.path.append(os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'importers'))) 4 | from etw import GPUQueue 5 | 6 | TRACK_INDEX, TRACK_NAME = -1, 'GPU' 7 | 8 | 9 | class PVRFtrace(GPUQueue): 10 | 11 | def __init__(self, args, callbacks): 12 | GPUQueue.__init__(self, args, callbacks) 13 | self.gpu = self.callbacks.process(TRACK_INDEX, TRACK_NAME) 14 | 15 | @staticmethod 16 | def parse_args(args): 17 | return dict(pair.split('=') for pair in args.split()) 18 | 19 | @staticmethod 20 | def get_gpu_lane(idx): 21 | if idx == 1: 22 | return 'Tile Accelerator' 23 | if idx == 2: 24 | return '3D' 25 | return 'Unknown' 26 | 27 | def handle_record(self, proc, pid, tid, cpu, flags, timestamp, name, args): 28 | if name not in ['PVR_start', 'PVR_end']: 29 | return 30 | args = self.parse_args(args) 31 | tid = int(args['node']) 32 | thread = self.gpu.thread(tid, self.get_gpu_lane(tid)) 33 | if name == 'PVR_start': 34 | task = thread.task('GPU', 'PVR') 35 | task.begin(timestamp) 36 | thread.task_stack.append(task) 37 | elif name == 'PVR_end': 38 | if thread.task_stack: 39 | task = thread.task_stack.pop() 40 | task.end(timestamp) 41 | 42 | def finalize(self): 43 | pass 44 | 45 | 46 | class PVRCSV(GPUQueue): 47 | def __init__(self, args, callbacks): 48 | GPUQueue.__init__(self, args, callbacks) 49 | self.gpu = self.callbacks.process(TRACK_INDEX, TRACK_NAME).thread(-1) 50 | 51 | def handle_record(self, data): 52 | for item in ['name', 'start_tsc.CLOCK_MONOTONIC_RAW', 'end_tsc']: 53 | if item not in data: 54 | return 55 | frame = self.gpu.frame(data['name']) 56 | start = int(data['start_tsc.CLOCK_MONOTONIC_RAW']) 57 | end = int(data['end_tsc']) 58 | frame.complete(start, end-start) 59 | 60 | def finalize(self): 61 | pass 62 | 63 | 64 | DECODER_DESCRIPTORS = [{ 65 | 'format': 'ftrace', 66 | 'available': True, 67 | 'decoder': PVRFtrace 68 | }, 69 | { 70 | 'format': 'csv', 71 | 'available': True, 72 | 'decoder': PVRCSV 73 | } 74 | ] 75 | -------------------------------------------------------------------------------- /runtool/exporters/BestTraceFormat.py: -------------------------------------------------------------------------------- 1 | from sea_runtool import TaskCombiner 2 | 3 | ################################### 4 | # TODO: add OS events (sched/vsync) 5 | class BestTraceFormat(TaskCombiner): 6 | """Writer for Best Trace Format. 7 | 8 | Specs for BTF v2.1.3: https://wiki.eclipse.org/images/e/e6/TA_BTF_Specification_2.1.3_Eclipse_Auto_IWG.pdf 9 | """ 10 | 11 | def __init__(self, args, tree): 12 | """Open the .btf file and write its header.""" 13 | TaskCombiner.__init__(self, args, tree) 14 | self.file = open(self.get_targets()[-1], "w+b") 15 | self._write('#version 2.1.3\n') 16 | self._write('#creator GDP-SEA\n') 17 | self._write('#creationDate 2014-02-19T11:39:20Z\n') 18 | self._write('#timeScale ns\n') 19 | 20 | def get_targets(self): 21 | return [self.args.output + ".btf"] 22 | 23 | def complete_task(self, type, b, e): 24 | """ 25 | type -- task type : {"task", "frame", "counter"} 26 | b -- { 'thread_name': '0x6296', 'domain': 'gles.trace.ergs', 'str': 'glPopMatrix', 'time': 1443097648250368731, 'tid': 25238, 'pid': 25238} 27 | e -- { 'tid': 25238, 'thread_name': '0x6296', 'domain': 'gles.trace.ergs', 'pid': 25238, 'time': 1443097648250548143} 28 | """ 29 | #