This document summarizes the integration of SYCL GPU acceleration into the AV2 video codec with RTCD (Run-Time CPU Detection) support.
- Added SYCL source files to
AVM_AV2_COMMON_SOURCES:av2/common/av2_inv_txfm_sycl.c- Inverse transform SYCL wrappers
- Added SYCL source files to
AVM_AV2_ENCODER_SOURCES:av2/encoder/av2_fwd_txfm_sycl.c- Forward transform SYCL wrappers
- Added SYCL-specific compiler flags and library linking in
setup_av2_targets()
- Added SYCL subdirectory inclusion and library linking in
setup_avm_dsp_targets() - Links
avm_sycllibrary to mainavmtarget whenHAVE_SYCLis enabled
- Added
syclspecialization to transform functions:inv_stxfm: Added SYCL specializationav2_highbd_inv_txfm_add: Added SYCL specializationfwd_stxfm: Added SYCL specializationfwd_txfm: Added SYCL specialization
sycl_context.cpp/hpp- SYCL context and device managementsycl_txfm.cpp/hpp- Transform kernels (DCT, ADST, IDTX)sycl_txfm_optimized.cpp- Optimized transform kernelssycl_me.cpp/hpp- Motion estimation kernelssycl_lpf.cpp/hpp- Loop filter kernelssycl_intra.cpp/hpp- Intra prediction kernelssycl_api.cpp/h- High-level SYCL APIsycl_wrapper.cpp/hpp- C wrapper functions for SYCL
-
av2/common/av2_inv_txfm_sycl.c- C wrapper functions for inverse transforms
- Handles GPU memory allocation and data transfer
- Falls back to C implementation when SYCL is unavailable
-
av2/encoder/av2_fwd_txfm_sycl.c- C wrapper functions for forward transforms
- Handles GPU memory allocation and data transfer
- Falls back to C implementation when SYCL is unavailable
To enable SYCL GPU acceleration, configure CMake with:
cmake -DAVM_ENABLE_SYCL=ON -DSYCL_BACKEND=CUDA ..Or for Intel/Metal backends:
cmake -DAVM_ENABLE_SYCL=ON -DSYCL_BACKEND=METAL ..SYCL sources are compiled with:
-fsycl- Enable SYCL support-fsycl-targets=nvptx64-nvidia-cuda- For CUDA backend-fsycl-targets=spir64_gen- For Intel/Metal backend
The RTCD system automatically selects the best implementation at runtime:
- CPU SIMD: AVX2, SSE4.1, SSSE3, NEON (selected based on CPU features)
- GPU SYCL: Automatically used when GPU is available and SYCL is enabled
- C Fallback: Used when no optimized implementation is available
Function selection priority: GPU SYCL > CPU SIMD > C
- 4x4, 8x8, 16x16, 32x32, 64x64
- DCT-II (Discrete Cosine Transform Type II)
- ADST (Asymmetric Discrete Sine Transform)
- IDTX (Identity Transform)
- Hybrid transforms (different row/column types)
- Device buffers are allocated per transform call
- Data is transferred between host and device as needed
- Automatic fallback to C implementation for unsupported sizes
To verify SYCL integration:
-
Build with SYCL enabled:
mkdir build && cd build cmake -DAVM_ENABLE_SYCL=ON -DCONFIG_AV2_ENCODER=ON .. make
-
Run the minimal SYCL test:
cd /tmp/avm-sycl-gpu-acceleration icpx -fsycl minimal_sycl_test.cpp -o minimal_sycl_test ONEAPI_DEVICE_SELECTOR=cuda:0 ./minimal_sycl_test -
Check for SYCL device detection in application output:
[SYCL] Initialized successfully Device: <GPU Name> Backend: <Backend Name> Type: GPU
- For small blocks (4x4, 8x8), CPU SIMD may be faster due to memory transfer overhead
- GPU acceleration is most beneficial for larger blocks (16x16, 32x32, 64x64)
- The current implementation processes individual blocks
- Future optimizations could batch multiple blocks for better GPU utilization
- Current implementation uses synchronous waits for simplicity
- Future versions could use async operations and streams for better performance
- Batch Processing: Process multiple blocks in a single kernel launch
- Pinned Memory: Use pinned host memory for faster transfers
- Async Streams: Overlap computation and data transfer
- More Transforms: Add GPU kernels for more transform types
- Motion Estimation: Full GPU acceleration for motion search
- Loop Filters: GPU acceleration for CDEF, GDF, restoration filters
- Ensure Intel oneAPI or compatible SYCL compiler is installed
- Check that
-fsyclflag is supported by your compiler - Verify
AVM_ENABLE_SYCL=ONis set in CMake
- Check GPU drivers are installed and working
- Verify
ONEAPI_DEVICE_SELECTORenvironment variable - Check SYCL backend selection (CUDA vs METAL vs OpenCL)
- Ensure SYCL headers are in include path
- Check for conflicts between SYCL and other SIMD flags
- Verify all SYCL sources are compiled with
-fsycl
- Intel oneAPI Documentation: https://www.intel.com/content/www/us/en/developer/tools/oneapi/overview.html
- SYCL Specification: https://www.khronos.org/sycl/
- AV2 Codec Documentation: See AOM repository