{"id":15053459,"url":"https://github.com/celtoys/remotery","last_synced_at":"2025-04-10T09:50:10.021Z","repository":{"id":14939838,"uuid":"17664381","full_name":"Celtoys/Remotery","owner":"Celtoys","description":"Single C file, Realtime CPU/GPU Profiler with Remote Web Viewer","archived":false,"fork":false,"pushed_at":"2024-08-28T08:52:43.000Z","size":2134,"stargazers_count":3204,"open_issues_count":36,"forks_count":277,"subscribers_count":79,"default_branch":"main","last_synced_at":"2025-04-03T05:08:47.278Z","etag":null,"topics":["c","cpu","cuda","d3d11","d3d12","gpu","metal","opengl","profiler","vulkan"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Azure/azure-sdk-for-php-samples","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Celtoys.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-03-12T11:15:35.000Z","updated_at":"2025-04-02T06:57:35.000Z","dependencies_parsed_at":"2023-01-11T18:56:20.351Z","dependency_job_id":"518cea74-efce-47b1-a5aa-043cd3801a0f","html_url":"https://github.com/Celtoys/Remotery","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Celtoys%2FRemotery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Celtoys%2FRemotery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Celtoys%2FRemotery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Celtoys%2FRemotery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Celtoys","download_url":"https://codeload.github.com/Celtoys/Remotery/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248197465,"owners_count":21063619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cpu","cuda","d3d11","d3d12","gpu","metal","opengl","profiler","vulkan"],"created_at":"2024-09-24T21:37:59.769Z","updated_at":"2025-04-10T09:50:09.985Z","avatar_url":"https://github.com/Celtoys.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Remotery\n--------\n\n[![Build](https://github.com/Celtoys/Remotery/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/Celtoys/Remotery/actions/workflows/build.yml)\n\nA realtime CPU/GPU profiler hosted in a single C file with a viewer that runs in a web browser.\n\n![RemoteryNew](https://github.com/Celtoys/Remotery/assets/1532903/bc5117f6-0f1e-438c-a096-67c8ff7747e7)\n\n\nFeatures:\n\n* Lightweight instrumentation of multiple threads running on the CPU and GPU.\n* Web viewer that runs in Chrome, Firefox and Safari; on Desktops, Mobiles or Tablets.\n* GPU UI rendering, bypassing the DOM completely, for real-time 60hz viewer updates at 10,000x the performance.\n* Automatic thread sampler that tells you what processor cores your threads are running on without requiring Administrator privileges.\n* Drop saved traces onto the Remotery window to load historical runs for inspection.\n* Console output for logging text.\n* Console input for sending commands to your game.\n* A Property API for recording named/typed values over time, alongside samples.\n* Profiles itself and shows how it's performing in the viewer.\n\nSupported Profiling Platforms:\n\n* Windows 7/8/10/11/UWP (Hololens), Linux, OSX, iOS, Android, Xbox One/Series, Free BSD.\n\nSupported GPU Profiling APIS:\n\n* D3D 11/12, OpenGL, CUDA, Metal, Vulkan.\n\nCompiling\n---------\n\n* Windows (MSVC) - add lib/Remotery.c and lib/Remotery.h to your program. Set include\n  directories to add Remotery/lib path. The required libraries (ws2_32.lib and winmm.lib) should be picked\n  up through the use of the `#pragma comment` directives in Remotery.c.\n\n* Windows (MINGW-64) - add lib/Remotery.c and lib/Remotery.h to your program. Set include\n  directories to add Remotery/lib path. You will need to link libws2_32.a and libwinmm.a yourself through your build system, as GCC (and therefore MINGW-64) do not support `#pragma comment` directives\n\n* Mac OS X (XCode) - simply add lib/Remotery.c, lib/Remotery.h and lib/Remotery.mm to your program.\n\n* Linux (GCC) - add the source in lib folder. Compilation of the code requires -pthreads for\n  library linkage. For example to compile the same run: cc lib/Remotery.c sample/sample.c\n  -I lib -pthread -lm\n\n* FreeBSD - the easiest way is to take a look at the official port\n  ([devel/remotery](https://www.freshports.org/devel/remotery/)) and modify the port's\n  Makefile if needed. There is also a package available via `pkg install remotery`.\n\n* Vulkan - Ensure your include directories are set such that the Vulkan headers can be\n  included with the statement: `#include \u003cvulkan/vulkan.h\u003e`. Currently the Vulkan implementation\n  requires either Vulkan 1.2+ with the `hostQueryReset` and `timelineSemaphore` features enabled,\n  or \u003c 1.2 with the `VK_EXT_host_query_reset` and `VK_KHR_timeline_semaphore` extensions. The\n  extension `VK_EXT_calibrated_timestamps` (or `VK_KHR_calibrated_timestamps`) is also always required.\n\nYou can define some extra macros to modify what features are compiled into Remotery:\n\n    Macro               Default     Description\n\n    RMT_ENABLED         1           Disable this to not include any bits of Remotery in your build\n    RMT_USE_TINYCRT     0           Used by the Celtoys TinyCRT library (not released yet)\n    RMT_USE_CUDA        0           Assuming CUDA headers/libs are setup, allow CUDA profiling\n    RMT_USE_D3D11       0           Assuming Direct3D 11 headers/libs are setup, allow D3D11 GPU profiling\n    RMT_USE_D3D12       0           Allow D3D12 GPU profiling\n    RMT_USE_OPENGL      0           Allow OpenGL GPU profiling (dynamically links OpenGL libraries on available platforms)\n    RMT_USE_METAL       0           Allow Metal profiling of command buffers\n    RMT_USE_VULKAN      0           Allow Vulkan GPU profiling\n\n\nBasic Use\n---------\n\nSee the sample directory for further examples. A quick example:\n\n    int main()\n    {\n        // Create the main instance of Remotery.\n        // You need only do this once per program.\n        Remotery* rmt;\n        rmt_CreateGlobalInstance(\u0026rmt);\n\n        // Explicit begin/end for C\n        {\n            rmt_BeginCPUSample(LogText, 0);\n            rmt_LogText(\"Time me, please!\");\n            rmt_EndCPUSample();\n        }\n\n        // Scoped begin/end for C++\n        {\n            rmt_ScopedCPUSample(LogText, 0);\n            rmt_LogText(\"Time me, too!\");\n        }\n\n        // Destroy the main instance of Remotery.\n        rmt_DestroyGlobalInstance(rmt);\n    }\n\n\nRunning the Viewer\n------------------\n\nDouble-click or launch `vis/index.html` from the browser.\n\n\nSampling CUDA GPU activity\n--------------------------\n\nRemotery allows for profiling multiple threads of CUDA execution using different asynchronous streams\nthat must all share the same context. After initialising both Remotery and CUDA you need to bind the\ntwo together using the call:\n\n    rmtCUDABind bind;\n    bind.context = m_Context;\n    bind.CtxSetCurrent = \u0026cuCtxSetCurrent;\n    bind.CtxGetCurrent = \u0026cuCtxGetCurrent;\n    bind.EventCreate = \u0026cuEventCreate;\n    bind.EventDestroy = \u0026cuEventDestroy;\n    bind.EventRecord = \u0026cuEventRecord;\n    bind.EventQuery = \u0026cuEventQuery;\n    bind.EventElapsedTime = \u0026cuEventElapsedTime;\n    rmt_BindCUDA(\u0026bind);\n\nExplicitly pointing to the CUDA interface allows Remotery to be included anywhere in your project without\nneed for you to link with the required CUDA libraries. After the bind completes you can safely sample any\nCUDA activity:\n\n    CUstream stream;\n\n    // Explicit begin/end for C\n    {\n        rmt_BeginCUDASample(UnscopedSample, stream);\n        // ... CUDA code ...\n        rmt_EndCUDASample(stream);\n    }\n\n    // Scoped begin/end for C++\n    {\n        rmt_ScopedCUDASample(ScopedSample, stream);\n        // ... CUDA code ...\n    }\n\nRemotery supports only one context for all threads and will use cuCtxGetCurrent and cuCtxSetCurrent to\nensure the current thread has the context you specify in rmtCUDABind.context.\n\n\nSampling Direct3D 11 GPU activity\n---------------------------------\n\nRemotery allows sampling of D3D11 GPU activity on multiple devices on multiple threads. After initialising Remotery, you need to bind it to D3D11 with a single call from the thread that owns the device context:\n\n    // Parameters are ID3D11Device* and ID3D11DeviceContext*\n    rmt_BindD3D11(d3d11_device, d3d11_context);\n\nSampling is then a simple case of:\n\n    // Explicit begin/end for C\n    {\n        rmt_BeginD3D11Sample(UnscopedSample);\n        // ... D3D code ...\n        rmt_EndD3D11Sample();\n    }\n\n    // Scoped begin/end for C++\n    {\n        rmt_ScopedD3D11Sample(ScopedSample);\n        // ... D3D code ...\n    }\n\nSubsequent sampling calls from the same thread will use that device/context combination. When you shutdown your D3D11 device and context, ensure you notify Remotery before shutting down Remotery itself:\n\n    rmt_UnbindD3D11();\n\n\nSampling OpenGL GPU activity\n----------------------------\n\nRemotery allows sampling of GPU activity on your main OpenGL context. After initialising Remotery, you need\nto bind it to OpenGL with the single call:\n\n    rmt_BindOpenGL();\n\nSampling is then a simple case of:\n\n    // Explicit begin/end for C\n    {\n        rmt_BeginOpenGLSample(UnscopedSample);\n        // ... OpenGL code ...\n        rmt_EndOpenGLSample();\n    }\n\n    // Scoped begin/end for C++\n    {\n        rmt_ScopedOpenGLSample(ScopedSample);\n        // ... OpenGL code ...\n    }\n\nSupport for multiple contexts can be added pretty easily if there is demand for the feature. When you shutdown\nyour OpenGL device and context, ensure you notify Remotery before shutting down Remotery itself:\n\n    rmt_UnbindOpenGL();\n\n\nSampling Metal GPU activity\n---------------------------\n\nRemotery can sample Metal command buffers issued to the GPU from multiple threads. As the Metal API does not\nsupport finer grained profiling, samples will return only the timing of the bound command buffer, irrespective\nof how many you issue. As such, make sure you bind and sample the command buffer for each call site:\n\n    rmt_BindMetal(mtl_command_buffer);\n    rmt_ScopedMetalSample(command_buffer_name);\n\nThe C API supports begin/end also:\n\n    rmt_BindMetal(mtl_command_buffer);\n    rmt_BeginMetalSample(command_buffer_name);\n    ...\n    rmt_EndMetalSample();\n\n\nSampling Vulkan GPU activity\n---------------------------\n\nRemotery can sample Vulkan command buffers issued to the GPU on multiple queues from multiple threads. Command buffers\nmust be submitted to the same queue as the samples are issued to. Multiple queues can be profiled by creating multiple\nVulkan bind objects.\n\n    rmtVulkanFunctions vulkan_funcs;\n    vulkan_funcs.vkGetPhysicalDeviceProperties = (void*)my_vulkan_instance_table-\u003evkGetPhysicalDeviceProperties;\n    vulkan_funcs.vkQueueSubmit = (void*)my_vulkan_device_table-\u003evkQueueSubmit;\n    // ... All other function pointers\n\n    // Parameters are VkInstance, VkPhysicalDevice, VkDevice, VkQueue, rmtVulkanFunctions*, rmtVulkanBind**\n    // NOTE: The Vulkan functions are copied internally and so do not have to be kept alive after this call.\n    rmtVulkanBind* vulkan_bind = NULL;\n    rmt_BindVulkan(instance, physical_device, device, queue, \u0026vulkan_funcs, \u0026vulkan_bind);\n\nSampling is then a simple case of:\n\n    // Explicit begin/end for C\n    {\n        rmt_BeginVulkanSample(vulkan_bind, command_buffer, UnscopedSample);\n        // ... Vulkan code ...\n        rmt_EndVulkanSample();\n    }\n\n    // Scoped begin/end for C++\n    {\n        rmt_ScopedVulkanSample(vulkan_bind, command_buffer, ScopedSample);\n        // ... Vulkan code ...\n    }\n\nNOTE: Vulkan sampling on Apple platforms via MoltenVK must be done with caution. Metal doesn't natively support timestamps\ninside of render or compute passes, so MoltenVK simply reports all timestamps inside those scopes as the begin/end time of\nthe entire render pass!\n\nSampling calls using the same `vulkan_bind` object measure use the device and queue specified when the bind was created.\nOnce per frame you must call `rmt_MarkFrame()` to gather GPU timestamps on the CPU.\n\n    // End of frame, possibly after calling vkPresentKHR or at the very beginning of the frame\n    rmt_MarkFrame();\n\nBefore you destroy your Vulkan device and queue you can manually clean up resources by calling `rmt_UnbindVulkan`, though this is\ndone automatically by `rmt_DestroyGlobalInstance` as well for all `rmt_BindVulkan` objects:\n\n    rmt_UnbindVulkan(vulkan_bind);\n\n\nApplying Configuration Settings\n-------------------------------\n\nBefore creating your Remotery instance, you can configure its behaviour by retrieving its settings object:\n\n    rmtSettings* settings = rmt_Settings();\n\nSome important settings are:\n\n    // Redirect any Remotery allocations to your own malloc/free, with an additional context pointer\n    // that gets passed to your callbacks.\n    settings-\u003emalloc;\n    settings-\u003efree;\n    settings-\u003emm_context;\n\n    // Specify an input handler that receives text input from the Remotery console, with an additional\n    // context pointer that gets passed to your callback.\n    // The handler will be called from the Remotery thread so synchronization with a mutex or atomics\n    // might be needed to avoid race conditions with your threads.\n    settings-\u003einput_handler;\n    settings-\u003einput_handler_context;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceltoys%2Fremotery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceltoys%2Fremotery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceltoys%2Fremotery/lists"}