How rapidsai/cucim works
Main Components
• Core Library (C++):
– Core framework and API: Found in cpp/src/core and related folders (framework initialization, plugin management, versioning).
– Modules for caching (cpp/src/cache), IO (cpp/src/io), file system handling, thread pooling (concurrent modules), and memory management.
– Utility modules (logger, configuration, macros, etc.).
• GPU Acceleration:
– Integration with CUDA (see references to CUDA kernels in core operations, cuda_kernel_source files, and dependencies like NVJPEG, rmm, etc.).
• Plugin Architecture:
– Separate plugins under cpp/plugins (e.g., cucim.kit.cumed and cucim.kit.cuslide) that extend the runtime with format-specific decoding (TIFF, SVS, JPEG2000, etc.).
• Python Bindings:
– Python interface module located in the python directory using pybind11 (with modules under python/pybind11 and python/cucim) to expose the same API as the C++ core.
• Build and Packaging Infrastructure:
– Build system via CMake (CMakeLists.txt files in various directories).
– CI/CD pipelines under the .github and ci directories.
– Packaging scripts for conda (conda/) and PyPI (python/cucim setup).
• Additional Elements:
– Benchmarks (for performance tests in benchmarks/ directory).
– Documentation, examples, notebooks (showing demo usage and integration).
– Third-party libraries and licenses (3rdparty directory).
Relationships and Interactions
• Within the C++ core, delineate submodules such as IO, caching, plugin management, and GPU-accelerated routines (kernel execution).
• Plugin modules with the core library, showing that they register with (or are discovered by) the plugin manager for format-specific operations.
• How the system integrates external dependencies (CUDA libraries, boost, etc.) which are managed via 3rdparty and CMake scripts.
• Data flow: Source image files (from disk or via GDS as seen in dependencies and experiments) are processed by the IO module, then passed through the caching/loader layers and finally processed with GPU-optimized operations.
Architectural Patterns and Design Principles
• Modular design: Core functionality is split into well-defined modules (IO, caching, memory, plugins) which simplifies maintenance and extension.
• Plugin Pattern: The use of separate components that can be dynamically loaded or compiled in to support additional image formats.
• Separation of Concerns: The distinct separation between the performance-critical C++/CUDA backend and the user-friendly Python front-end.
• Build and Distribution Abstraction: Clear use of CMake, CI workflows, and packaging across multiple platforms (conda, PyPI).
Relevant Technologies, Frameworks, and Libraries
• C++ with modern standards (utilizing C++20 features in some modules).
• CUDA for GPU acceleration.
• Pybind11 for Python bindings.
• External libraries such as Boost, CLI11, fmt, and others as listed in the 3rdparty folder.
• Various CMake scripts and modules that drive the build process.
• CI/CD tools integrated with GitHub Actions.