How victor-anisimov/librett works
Purpose and Public API
LibreTT is a portable GPU tensor-transpose library targeting CUDA/NVIDIA, HIP/AMD, and SYCL/Intel environments. Its public-facing API and library integration surface are centered in src/librett.h and src/librett.cpp; shared type definitions are in src/Types.h.
Build and Runtime Selection
The project supports CMake plus platform-specific Makefile flows. Top-level build orchestration is in CMakeLists.txt, while source-level target composition is in src/CMakeLists.txt. Platform selection is compile-time: CUDA, HIP, or SYCL builds provide the device runtime and compiler environment rather than a runtime backend abstraction.
Plan-Based Transpose Execution
Transpose requests are represented and prepared as plans, separating setup from execution. src/plan.h and src/plan.cpp define plan construction, likely including tensor shape/order decomposition and kernel strategy selection. src/calls.h forms the interface between planned operations and lower-level execution paths.
Kernel and GPU Model Layer
The core execution strategy combines generated/configured transpose kernels with hardware-aware selection. src/kernel.h and src/kernel.cpp encapsulate transpose-kernel logic; src/GpuModel.h and src/GpuModel.cpp model GPU capabilities used for scheduling or tuning. Device kernel implementation support is concentrated in src/GpuModelKernel.cpp and src/GpuModelKernel.h.
Device Memory and Runtime Boundary
GPU memory movement and device-specific utility behavior are isolated from planning logic. src/GpuMemcpy.h and src/GpuMemcpy.cpp handle device copies, while src/GpuMem.hpp provides GPU-memory abstractions. src/GpuUtils.h and src/GpuUtils.cpp supply backend/runtime utilities. SYCL-specific device adaptation is explicitly represented by src/sycl_device.hpp.
Performance Reuse and Lifecycle Support
Plans or kernel-related artifacts can be reused through src/LRUCache.h, avoiding repeated setup for recurring transpose shapes. Timing support is isolated in src/Timer.h and src/Timer.cpp, supporting performance-oriented execution and benchmarking without becoming part of the public API path.
Consumers and Validation Entry Points
Library consumers include the standalone sample at tests/example.cpp; functional and performance entry points are tests/librett_test.cpp and tests/librett_bench.cpp. Builds produce a static librett.a, public librett.h, and these executable clients. No external network services or persistent infrastructure are indicated; material dependencies are the selected CUDA, HIP, or SYCL GPU toolchain/runtime.
Main entry points: librett.cpp Library integration · plan.cpp Transpose plan · kernel.cpp Transpose kernels · librett.h LibreTT public API
Components 22
Build selection
Compile-time CUDA, HIP, or SYCL target selection.
- Top-level build
CMakeLists.txt - Library target build
src/CMakeLists.txt - CUDA / HIP / SYCL · Selected at compile time; provides the device runtime.
Library API
- LibreTT public API
src/librett.h - Library integration
src/librett.cpp - Shared types
src/Types.h
Planning and execution
- Transpose plan · Prepares shape decomposition and kernel strategy before execution.
src/plan.cpp - Plan interface
src/plan.h - Execution calls · Connects planned operations to lower-level execution.
src/calls.h - Transpose kernels
src/kernel.cpp - Kernel interface
src/kernel.h - Plan artifact cache · Reuses setup artifacts for recurring tensor shapes.
src/LRUCache.h
GPU runtime layer
- GPU capability model
src/GpuModel.cpp - Device model kernels
src/GpuModelKernel.cpp - Device memory copies
src/GpuMemcpy.cpp - GPU memory abstraction
src/GpuMem.hpp - GPU runtime utilities
src/GpuUtils.cpp - SYCL device adapter
src/sycl_device.hpp
Consumers
- Standalone example
tests/example.cpp - Functional tests
tests/librett_test.cpp - Performance benchmark
tests/librett_bench.cpp - Timing support
src/Timer.cpp
Connections 22
- Top-level build → Library target build: includes
- Library target build → CUDA / HIP / SYCL: selects
- Library target build → Library integration: builds
- LibreTT public API → Library integration: implemented by
- Library integration → Shared types: uses
- Library integration → Transpose plan: creates and executes
- Plan interface → Transpose plan: declares
- Transpose plan → Plan artifact cache: reuses
- Transpose plan → Execution calls: dispatches through
- Execution calls → Transpose kernels: invokes
- Kernel interface → Transpose kernels: declares
- Transpose kernels → GPU capability model: uses for tuning
- GPU capability model → Device model kernels: uses device support
- Transpose kernels → Device memory copies: moves tensor data
- Device memory copies → GPU memory abstraction: operates on
- Device memory copies → GPU runtime utilities: uses runtime utilities
- GPU runtime utilities → CUDA / HIP / SYCL: binds to
- SYCL device adapter → CUDA / HIP / SYCL: adapts
- Standalone example → LibreTT public API: uses
- Functional tests → LibreTT public API: validates
- Performance benchmark → LibreTT public API: measures
- Performance benchmark → Timing support: uses