daphne-eu / daphne

DAPHNE: An Open and Extensible System Infrastructure for Integrated Data Analysis Pipelines
Apache License 2.0
67 stars 62 forks source link

[DAPHNE-#811] Extension of EwBinaryMat and EwUnaryMat Kernels to Support Sparse and Dense Matrix Addition #812

Open StoeckOverflow opened 3 months ago

StoeckOverflow commented 3 months ago

Overview

This draft pull request introduces an extension to the EwBinaryMat and EwUnaryMat kernels to support efficient operations for matrix addition between dense and sparse matrices (see issue #811). The following kernels have been added:

Implementation Details

As part of this implementation, a resize method was added to the CSRMatrix class to dynamically handle the reallocation of memory when the number of non-zero elements exceeds the initially allocated space.

Questions Regarding resize Method Implementation

The resize method is essential for managing dynamic memory allocation within sparse matrices, especially when the number of non-zero elements increases during operations.

  1. Comparison with Dense Matrices: In some scenarios, the memory usage of a CSR matrix may approach or even exceed that of a dense matrix, particularly when the matrix is nearly dense or when the overhead from storing indices becomes significant. Is it advisable to dynamically adjust the size of the CSR matrix in these cases, considering that the most efficient representation should have already been chosen in a previous compiler pass?

  2. Alternative Approaches: Are there alternative methods that could offer more efficiency in handling dynamic resizing, especially in the context of sparse matrices?