CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
65 lines
3.1 KiB
Markdown
65 lines
3.1 KiB
Markdown
# Shared Utilities
|
|
|
|
The `util` library provides low-level building blocks shared across
|
|
rocjitsu and simdojo. It is a header-heavy library with minimal
|
|
compiled sources.
|
|
|
|
## Headers
|
|
|
|
### Bit Manipulation
|
|
|
|
| File | Description |
|
|
|------|-------------|
|
|
| `bit.h` | Bit masks, insertion, extraction, counting, alignment. Provides `mask()`, `insert_bits()`, `bits()`, `is_power_of_2()`, `align_up()`. |
|
|
| `bitfield.h` | Typed bitfield access over integral or array storage. `Bitfield<N>` with templated `get<>()` / `set()` for arbitrary bit ranges. |
|
|
|
|
### Data Types and Conversions
|
|
|
|
| File | Description |
|
|
|------|-------------|
|
|
| `data_types.h` | Floating-point format conversions: FP16, BF16, FP8 (E4M3), BF8 (E5M2), FP4, FP6. Scalar and vectorized block converters with IEEE-754 rounding modes (truncation, round-to-nearest-even, stochastic). |
|
|
| `convert.h` | Type-erasing conversion between opaque C API handles and internal object pointers. |
|
|
|
|
### SIMD
|
|
|
|
| File | Description |
|
|
|------|-------------|
|
|
| `simd.h` | Vectorized operations via `<experimental/simd>` with scalar fallback. Float conversions, integer arithmetic (`mul_hi`, `popcount`, `clz`), rounding, and transcendental approximations (`rcp`, `rsq`, `log`, `exp`). |
|
|
| `simd_test_hooks.h` | Test-only seam for forcing scalar execution to compare against SIMD paths. |
|
|
|
|
### Memory and Concurrency
|
|
|
|
| File | Description |
|
|
|------|-------------|
|
|
| `arena_alloc.h` | Fixed-size block pool allocator with free-list. `ArenaAlloc<BlockSize, NumBlocks, BlockAlign>` provides O(1) alloc/dealloc with global-allocator fallback. |
|
|
| `spinlock.h` | TTAS spinlock optimized for sub-microsecond critical sections. Uses C++20 `atomic::wait()` with ThreadSanitizer annotations. |
|
|
| `intrusive_list.h` | Bidirectional intrusive linked list with optional parent-pointer tracking. `IntrusiveList<T>` and `IListNode<T>` with O(1) insert/erase. |
|
|
| `unique_handle.h` | Move-only RAII ownership for POSIX file descriptors, Win32 handles, and custom handle traits. |
|
|
|
|
### Diagnostics
|
|
|
|
| File | Description |
|
|
|------|-------------|
|
|
| `log.h` | Compile-time and runtime configurable logging with named groups (VM, CP). Thread-safe, supports lazy evaluation via lambda forms. Use `Logger::print<GroupId>()` for group-filtered output. |
|
|
| `except.h` | Exception hierarchy: `Exception` (base), `InvalidInst`, `UnimplementedInst`, `ConfigError`. All derive from `std::exception`. |
|
|
|
|
### Miscellaneous
|
|
|
|
| File | Description |
|
|
|------|-------------|
|
|
| `dynamic_loader.h` | Runtime symbol resolution via `dlsym` (Linux) / `GetProcAddress` (Windows). `lookup_symbol<T>()` returns a typed function pointer. |
|
|
| `meta_programming.h` | Type traits and concepts: `IsIntegral`, `IsUnsigned`, `IsArithmetic`, `IsVoid`. Also provides `GetOption` for template option extraction and `always_false_v<T>` for deferred static assertions. |
|
|
|
|
## Usage
|
|
|
|
All headers are under `lib/util/include/util/` and can be included as:
|
|
|
|
```cpp
|
|
#include "util/log.h"
|
|
#include "util/bit.h"
|
|
```
|
|
|
|
Header-only consumers link `util_headers` in CMake. The `util` target links
|
|
`util_headers` publicly and adds the small compiled SIMD implementation used by
|
|
rocjitsu and simdojo.
|