arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1811.08768cs.MS
收藏

C++中的实用稀疏矩阵与混合存储和基于模板的表达式优化

Practical Sparse Matrices in C++ with Hybrid Storage and Template-Based Expression Optimisation

Conrad Sanderson, Ryan Curtin

摘要:

尽管稀疏矩阵在许多科学领域中的重要性,但软件实现仍然难以用于非专家用户,通常需要理解所选择的稀疏矩阵存储格式的基本细节。此外,为了实现良好的性能,可能需要在一个程序中使用几种格式,这需要在格式之间进行显式选择和转换。这可能既乏味又容易出错,特别是对于非专业用户。出于这些问题,我们提出了一个用户友好的和开源的稀疏矩阵类的C++语言,具有高层次的应用程序编程接口故意类似于广泛使用的MATLAB语言。这有助于直接在C++中进行原型设计,并有助于将研究代码转换为生产环境。类内部使用两种主要方法来实现高效执行:(i)混合储存架构,可在三种基本储存格式之间自动无缝切换(压缩稀疏列、红黑树、坐标列表),这取决于哪种格式最适合和/或可用于特定操作,以及(ii)基于模板的元编程框架,用于自动检测和优化公共表达模式的执行。对具有各种非零元素密度的大型稀疏矩阵的经验评估表明了混合存储框架和表达式优化机制的优点。

英文摘要:

Despite the importance of sparse matrices in numerous fields of science, software implementations remain difficult to use for non-expert users, generally requiring the understanding of underlying details of the chosen sparse matrix storage format. In addition, to achieve good performance, several formats may need to be used in one program, requiring explicit selection and conversion between the formats. This can be both tedious and error-prone, especially for non-expert users. Motivated by these issues, we present a user-friendly and open-source sparse matrix class for the C++ language, with a high-level application programming interface deliberately similar to the widely used MATLAB language. This facilitates prototyping directly in C++ and aids the conversion of research code into production environments. The class internally uses two main approaches to achieve efficient execution: (i) a hybrid storage framework, which automatically and seamlessly switches between three underlying storage formats (compressed sparse column, Red-Black tree, coordinate list) depending on which format is best suited and/or available for specific operations, and (ii) a template-based meta-programming framework to automatically detect and optimise execution of common expression patterns. Empirical evaluations on large sparse matrices with various densities of non-zero elements demonstrate the advantages of the hybrid storage framework and the expression optimisation mechanism.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑