How rocm/clr works
Project Type and Purpose
• This is a multi‐language compute runtime library (not a typical web or microservice app). It implements AMD’s HIP and OpenCL™ APIs (“hipamd” and “opencl” folders) atop a shared core runtime library (“rocclr”). It compiles down to static/shared libraries used by GPU drivers and user applications.
High‐Level Architecture & Components
a. Language Frontends
• hipamd – HIP runtime implementation on AMD GPUs
• opencl – OpenCL™ runtime implementation on AMD GPUs
b. Shared Core Runtime (rocclr)
• Compiler submodule – SPIR-V, HSAIL, PAL translation backends
• Device submodule – GPU command submission, memory management, profiling
• Platform submodule – API objects (contexts, queues, kernels) and interoperability (GL/D3D)
• ELF loader – parses code objects (ELF)
• OS abstraction – cross‐platform support for Linux/Windows, threading, allocation
• Utilities – logging, flags, versioning
c. External Dependencies & Services
• HSA Runtime Loader (libhsa)
• PAL (Platform Abstraction Library) – low‐level GPU interface
• System OS Kernel / GPU Driver
Relationships & Data Flow
• User application calls HIP or OpenCL™ API →
• hipamd/opencl frontend layers translate calls into internal rocclr calls →
• rocclr “Platform” constructs command buffers, dispatches to “Device” module →
• Device module uses HSA loader & PAL interfaces to submit work to GPU →
• OS layer handles memory allocation, threads, synchronization →
• GPU executes kernels, returns events/status back up the stack →
• Profiling/tracing subsystems record API usage (hip_api_trace, cl_profile_amd)
Architectural Patterns & Design Principles
• Layered Architecture: clear separation between frontends, core runtime, OS abstraction, and hardware interface
• Adapter/Facade: rocclr abstracts HSA and PAL differences, exposing a unified interface to hipamd/opencl
• Plugin‐style backends: compiler submodule isolates target‐specific translation logic
• Cross‐platform portability: OS layer abstracts Windows/Linux differences