Validate Backend Abstraction with Multiple Backend Implementations
Current State
The backend abstraction (wl_compute_backend_t vtable) has only been tested with a single backend implementation: Columnar.
// wirelog/backend.h:85-107
typedef struct {
wl_session_t* (*session_create)(wl_compute_backend_t*, ...);
void (*session_destroy)(wl_session_t*);
int (*session_insert)(wl_session_t*, ...);
int (*session_remove)(wl_session_t*, ...);
int (*session_step)(wl_session_t*);
int (*session_set_delta_cb)(wl_session_t*, ...);
wl_snapshot_t* (*session_snapshot)(wl_session_t*);
} wl_compute_backend_t;
Only wl_backend_columnar() is implemented. No other backend exists to validate the interface.
Why This Matters
1. Hidden Assumptions
With only one implementation, it's impossible to detect:
- Columnar-specific assumptions baked into the vtable interface
- Missing operations needed for different compute paradigms
- Implicit dependencies on columnar data representation
- Operations that don't generalize (e.g., K-Fusion is columnar-specific)
Example: K-Fusion assumes column-major layout. FPGA or GPU backends might need different parallelization strategies.
2. Interface Design Risk
The vtable may have fundamental design flaws that only become apparent when:
- Adding an FPGA backend (different execution model)
- Adding a GPU backend (GPU memory management, kernel compilation)
- Adding a distributed backend (network I/O, fault tolerance)
These flaws would force retrofitting the interface, affecting all backends.
3. Delayed Problem Discovery
As noted in ARCHITECTURE.md:
"Architectural flaws in backend interface may be hidden until 2nd backend is added"
This is a known risk with no validation before major architectural changes.
4. Plan Representation Assumptions
Execution plans are generated assuming columnar backend semantics:
These may not apply to other backends.
Problem Scenario: FPGA Backend
If we implement an FPGA backend:
-
Data Transfer: Need Arrow IPC for host-FPGA data movement
- Columnar: in-memory columnar arrays
- FPGA: Arrow IPC serialization/deserialization overhead
- Interface may need session_serialize/session_deserialize
-
Parallelization: K-Fusion assumes CPU workqueue parallelism
- Columnar: deep-copy K-fusion workers
- FPGA: streaming pipeline logic, no deep copies
- K-fusion operator incompatible; needs different plan shape
-
Memory Management: Columnar uses malloc; FPGA needs host memory pinning
- Need backend-specific allocation strategies
- vtable may need memory_alloc/memory_free callbacks
-
Incremental Computation: Columnar uses differential arrangements
- FPGA may use different delta tracking (on-device)
- session_snapshot semantics may differ
-
Error Handling: FPGA execution errors vs. CPU memory errors are different
- Columnar: returns error codes
- FPGA: may need async error notification
- vtable may need error callback
Solution: Implement FPGA Backend
Add a second backend implementation to validate the abstraction:
Phase 1: Basic FPGA Backend (Validation Phase)
Phase 2: Data Transfer
Phase 3: Plan Adaptation
Phase 4: Performance Validation
Benefits
- Validates backend abstraction is truly pluggable
- Discovers hidden columnar-specific assumptions early
- Forces core engine to be truly backend-agnostic
- Proves new backends can be added without modifying core
- Establishes patterns for future backends (GPU, distributed)
- Catches interface design flaws before they spread
Risk if Not Done
Related Issues
Definition of Done
- FPGA backend compiles and links against core engine
- FPGA backend passes existing test suite (or tests correctly fail due to FPGA-specific limitations)
- No core engine changes needed to support FPGA (except interface bugs found and fixed)
- Interface gaps documented and tracked as separate issues
- Core engine is demonstrably backend-agnostic
Validate Backend Abstraction with Multiple Backend Implementations
Current State
The backend abstraction (wl_compute_backend_t vtable) has only been tested with a single backend implementation: Columnar.
Only wl_backend_columnar() is implemented. No other backend exists to validate the interface.
Why This Matters
1. Hidden Assumptions
With only one implementation, it's impossible to detect:
Example: K-Fusion assumes column-major layout. FPGA or GPU backends might need different parallelization strategies.
2. Interface Design Risk
The vtable may have fundamental design flaws that only become apparent when:
These flaws would force retrofitting the interface, affecting all backends.
3. Delayed Problem Discovery
As noted in ARCHITECTURE.md:
This is a known risk with no validation before major architectural changes.
4. Plan Representation Assumptions
Execution plans are generated assuming columnar backend semantics:
These may not apply to other backends.
Problem Scenario: FPGA Backend
If we implement an FPGA backend:
Data Transfer: Need Arrow IPC for host-FPGA data movement
Parallelization: K-Fusion assumes CPU workqueue parallelism
Memory Management: Columnar uses malloc; FPGA needs host memory pinning
Incremental Computation: Columnar uses differential arrangements
Error Handling: FPGA execution errors vs. CPU memory errors are different
Solution: Implement FPGA Backend
Add a second backend implementation to validate the abstraction:
Phase 1: Basic FPGA Backend (Validation Phase)
Phase 2: Data Transfer
Phase 3: Plan Adaptation
Phase 4: Performance Validation
Benefits
Risk if Not Done
Related Issues
Definition of Done