Skip to content

Template CSR4MPI for multi-scalar type support without recompilation - #4

Merged
deltaeecs merged 4 commits into
masterfrom
copilot/implement-data-type-compilation
Dec 4, 2025
Merged

Template CSR4MPI for multi-scalar type support without recompilation#4
deltaeecs merged 4 commits into
masterfrom
copilot/implement-data-type-compilation

Conversation

Copilot AI commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

Eliminates the CSR4MPI_VALUE_TYPE compile-time switch by converting all classes to C++ templates. All four scalar types (float, double, complex, complex) are now available simultaneously in a single library build.

Changes

  • Templated classes (now header-only):

    • cCSRMatrix<Scalar>, cCommPattern<Scalar>, cRemoteEntry<Scalar>
    • cCSRComm<Scalar>, cMumpsAdapter<Scalar>
  • Templated operations:

    • SpMV<Scalar>(), SpMM<Scalar>(), SpMMBlas<Scalar>()
    • LoadMatrixMarket<Scalar>(), DistributedSpMV<Scalar>()
  • Type support in Global.h:

    • Type traits: is_complex_v<T>, is_supported_scalar_v<T>, real_type_t<T>
    • Shared MPI helper: mpi_helper::GetMPIDatatype<Scalar>()
  • Convenience aliases:

    • cCSRMatrixF, cCSRMatrixD, cCSRMatrixCF, cCSRMatrixCD

Usage

// All types available without recompilation
cCSRMatrix<double> matD(0, n, n, rowPtr, colInd, values);
cCSRMatrix<std::complex<float>> matCF(...);

std::vector<double> x(n, 1.0), y;
SpMV(matD, x, y);

Tests

Added test_all_scalar_types.cpp with typed tests covering all 4 scalar types (52 tests total).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

指定计划,实现如下目标:将四种数据类型 (float, double, complex, complex)同时编译进库文件,可以的话,头文件模板化,去除对 DCSR4MPI_VALUE_TYPE 的依赖,避免切换类型重新编译。几种数据类型都要进行充分的测试验证


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 4, 2025 03:57
- Template all classes to support float, double, complex<float>, complex<double>
- Remove CSR4MPI_VALUE_TYPE macro dependency from headers
- Convert all implementations to header-only templates
- Add type traits and type aliases for all scalar types
- Add comprehensive tests for all 4 scalar types
- Update tests and benchmarks to use templated classes

Co-authored-by: deltaeecs <48714525+deltaeecs@users.noreply.github.com>
…plify ApproxEqual

- Move GetMPIDatatype helper to Global.h to avoid code duplication
- Simplify ApproxEqual in tests by removing unnecessary if-else branches
- Use mpi_helper namespace for the consolidated helper function

Co-authored-by: deltaeecs <48714525+deltaeecs@users.noreply.github.com>
Co-authored-by: deltaeecs <48714525+deltaeecs@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for multiple data types in library Template CSR4MPI for multi-scalar type support without recompilation Dec 4, 2025
Copilot AI requested a review from deltaeecs December 4, 2025 04:06
@deltaeecs
deltaeecs marked this pull request as ready for review December 4, 2025 06:42
@deltaeecs
deltaeecs merged commit 2a4bab7 into master Dec 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants