Skip to content

Commit 4c8541c

Browse files
Sebastien Loiselclaude
andcommitted
Migrate from LinearAlgebraMPI to HPCLinearAlgebra
Update MultiGridBarrierMPI to use the renamed HPCLinearAlgebra package with its new backend-based API: - Update imports to use HPCLinearAlgebra and new type names (HPCVector, HPCMatrix, HPCSparseMatrix) - Update constructors to use backend parameter: HPCMatrix(data, backend) - Add _backend_instance_from_type() to support CUDA/Metal backends in amgb_zeros for vectors - Make GPU backend creation lazy in test_utils.jl to avoid calling backend_cuda_mpi() before MPI.Init() - Add test_2d.jl for 2D integration tests with CUDA support - Fix runtests.jl to use 2 ranks for 2D tests (NCCL fails when ranks exceed available GPUs) - Update documentation references Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2b4cc69 commit 4c8541c

12 files changed

Lines changed: 569 additions & 222 deletions

File tree

Project.toml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
11
name = "MultiGridBarrierMPI"
22
uuid = "abf18f27-d12f-4566-94ed-07bf0c385f70"
3-
version = "0.1.1"
43
authors = ["S. Loisel"]
4+
version = "0.1.1"
55

66
[deps]
77
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
8+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
9+
CUDSS_jll = "4889d778-9329-5762-9fec-0578a5d30366"
810
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
9-
LinearAlgebraMPI = "5bdd2be4-ae34-42ef-8b36-f4c85d48f377"
11+
HPCLinearAlgebra = "537374f1-5608-4525-82fb-641dce542540"
1012
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
13+
MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"
14+
Metal = "dde4c033-4e86-420c-a63e-0dd931031962"
1115
MultiGridBarrier = "9e2c1f1d-9131-4ad4-b32f-bd2a0b0ecd1e"
16+
NCCL_jll = "4d6d38e4-5b87-5e63-912a-873ff2d649b7"
1217
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1318
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
19+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1420
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1521

22+
[sources]
23+
HPCLinearAlgebra = {path = "../LinearAlgebraMPI.jl"}
24+
1625
[compat]
1726
BenchmarkTools = "1.6"
18-
LinearAlgebraMPI = "0.1"
27+
CUDA = "5.9.6"
28+
CUDSS_jll = "0.7.1"
29+
HPCLinearAlgebra = "0.1"
1930
MPI = "0.20"
31+
MPIPreferences = "0.1.11"
32+
Metal = "1.9.1"
2033
MultiGridBarrier = "0.11"
34+
NCCL_jll = "2"
2135
PrecompileTools = "1"
36+
StaticArrays = "1.9.16"
2237
julia = "1.10"
2338

2439
[extras]

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
**Author:** S. Loisel
99

10-
A Julia package that bridges MultiGridBarrier.jl and LinearAlgebraMPI.jl for distributed multigrid barrier computations using native MPI types.
10+
A Julia package that bridges MultiGridBarrier.jl and HPCLinearAlgebra.jl for distributed multigrid barrier computations using native MPI types.
1111

1212
## Overview
1313

14-
MultiGridBarrierMPI.jl extends the MultiGridBarrier.jl package to work with LinearAlgebraMPI.jl's distributed matrix and vector types. This enables efficient parallel computation of multigrid barrier methods across multiple MPI ranks without requiring PETSc.
14+
MultiGridBarrierMPI.jl extends the MultiGridBarrier.jl package to work with HPCLinearAlgebra.jl's distributed matrix and vector types. This enables efficient parallel computation of multigrid barrier methods across multiple MPI ranks without requiring PETSc.
1515

1616
## Key Features
1717

1818
- **1D, 2D, and 3D Support**: Full support for 1D, 2D triangular, and 3D hexahedral finite elements
1919
- **Seamless Integration**: Drop-in replacement for MultiGridBarrier's native types
20-
- **Pure Julia MPI**: Uses LinearAlgebraMPI.jl for distributed linear algebra (no external libraries required)
20+
- **Pure Julia MPI**: Uses HPCLinearAlgebra.jl for distributed linear algebra (no external libraries required)
2121
- **Type Conversion**: Easy conversion between native Julia arrays and MPI distributed types
2222
- **MPI-Aware**: All operations correctly handle MPI collective requirements
2323
- **MUMPS Solver**: Uses MUMPS direct solver for accurate Newton iterations
@@ -31,7 +31,7 @@ using MPI
3131
MPI.Init()
3232

3333
using MultiGridBarrierMPI
34-
using LinearAlgebraMPI
34+
using HPCLinearAlgebra
3535

3636
# Solve with MPI distributed types (L=3 refinement levels)
3737
sol_mpi = fem2d_mpi_solve(Float64; L=3, p=1.0, verbose=false)
@@ -92,7 +92,7 @@ julia --project make.jl
9292
This package is part of a larger ecosystem:
9393

9494
- **[MultiGridBarrier.jl](https://github.com/sloisel/MultiGridBarrier.jl)**: Core multigrid barrier method implementation
95-
- **[LinearAlgebraMPI.jl](https://github.com/sloisel/LinearAlgebraMPI.jl)**: Pure Julia distributed linear algebra with MPI
95+
- **[HPCLinearAlgebra.jl](https://github.com/sloisel/HPCLinearAlgebra.jl)**: Pure Julia distributed linear algebra with MPI
9696
- **MPI.jl**: Julia MPI bindings for distributed computing
9797

9898
## Requirements

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
DocumenterTools = "35a29f4d-8980-5a13-9543-d66fff28ecb8"
4-
LinearAlgebraMPI = "5bdd2be4-ae34-42ef-8b36-f4c85d48f377"
4+
HPCLinearAlgebra = "537374f1-5608-4525-82fb-641dce542540"
55
MultiGridBarrier = "9e2c1f1d-9131-4ad4-b32f-bd2a0b0ecd1e"
66
MultiGridBarrierMPI = "abf18f27-d12f-4566-94ed-07bf0c385f70"
77

docs/src/api.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ When converting from native Julia types to MPI distributed types:
4848

4949
| Native Type | MPI Type | Usage |
5050
|-------------|----------|-------|
51-
| `Matrix{T}` | `MatrixMPI{T}` | Geometry coordinates, dense data |
52-
| `Vector{T}` | `VectorMPI{T}` | Weights, dense vectors |
53-
| `SparseMatrixCSC{T,Int}` | `SparseMatrixMPI{T}` | Sparse operators, subspace matrices |
51+
| `Matrix{T}` | `HPCMatrix{T}` | Geometry coordinates, dense data |
52+
| `Vector{T}` | `HPCVector{T}` | Weights, dense vectors |
53+
| `SparseMatrixCSC{T,Int}` | `HPCSparseMatrix{T}` | Sparse operators, subspace matrices |
5454

5555
### MPI to Native Conversions
5656

5757
When converting from MPI distributed types back to native Julia types:
5858

5959
| MPI Type | Native Type |
6060
|----------|-------------|
61-
| `MatrixMPI{T}` | `Matrix{T}` |
62-
| `VectorMPI{T}` | `Vector{T}` |
63-
| `SparseMatrixMPI{T}` | `SparseMatrixCSC{T,Int}` |
61+
| `HPCMatrix{T}` | `Matrix{T}` |
62+
| `HPCVector{T}` | `Vector{T}` |
63+
| `HPCSparseMatrix{T}` | `SparseMatrixCSC{T,Int}` |
6464

6565
## Geometry Structure
6666

@@ -73,14 +73,14 @@ Geometry{T, Matrix{T}, Vector{T}, SparseMatrixCSC{T,Int}, Discretization}
7373

7474
**MPI Geometry:**
7575
```julia
76-
Geometry{T, MatrixMPI{T}, VectorMPI{T}, SparseMatrixMPI{T}, Discretization}
76+
Geometry{T, HPCMatrix{T}, HPCVector{T}, HPCSparseMatrix{T}, Discretization}
7777
```
7878

7979
### Fields
8080

8181
- **`discretization`**: Discretization information (domain, mesh, etc.)
82-
- **`x`**: Geometry coordinates (Matrix or MatrixMPI)
83-
- **`w`**: Quadrature weights (Vector or VectorMPI)
82+
- **`x`**: Geometry coordinates (Matrix or HPCMatrix)
83+
- **`w`**: Quadrature weights (Vector or HPCVector)
8484
- **`operators`**: Dictionary of operators (id, dx, dy, etc.)
8585
- **`subspaces`**: Dictionary of subspace projection matrices
8686
- **`refine`**: Vector of refinement matrices (coarse -> fine)
@@ -104,12 +104,12 @@ The `AMGBSOL` type from MultiGridBarrier contains the complete solution:
104104

105105
## MPI and IO Utilities
106106

107-
### LinearAlgebraMPI.io0()
107+
### HPCLinearAlgebra.io0()
108108

109109
Returns an IO stream that only writes on rank 0:
110110

111111
```julia
112-
using LinearAlgebraMPI
112+
using HPCLinearAlgebra
113113

114114
println(io0(), "This prints once from rank 0")
115115
```
@@ -132,7 +132,7 @@ using MPI
132132
MPI.Init()
133133

134134
using MultiGridBarrierMPI
135-
using LinearAlgebraMPI
135+
using HPCLinearAlgebra
136136
using MultiGridBarrier
137137
using LinearAlgebra
138138

@@ -163,7 +163,7 @@ id_native = g_native.operators[:id] # SparseMatrixCSC
163163

164164
# MPI geometry
165165
g_mpi = native_to_mpi(g_native)
166-
id_mpi = g_mpi.operators[:id] # SparseMatrixMPI
166+
id_mpi = g_mpi.operators[:id] # HPCSparseMatrix
167167

168168
# Convert back if needed
169169
id_back = SparseMatrixCSC(id_mpi) # SparseMatrixCSC

docs/src/guide.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ using MPI
3030
MPI.Init()
3131

3232
using MultiGridBarrierMPI
33-
using LinearAlgebraMPI
33+
using HPCLinearAlgebra
3434
using MultiGridBarrier
3535

3636
# Step 1: Solve with MPI distributed types
@@ -100,9 +100,9 @@ g_mpi = native_to_mpi(g_native)
100100

101101
| Native Type | MPI Type | Description |
102102
|-------------|----------|-------------|
103-
| `Matrix{T}` | `MatrixMPI{T}` | Dense distributed matrix |
104-
| `Vector{T}` | `VectorMPI{T}` | Dense distributed vector |
105-
| `SparseMatrixCSC{T,Int}` | `SparseMatrixMPI{T}` | Sparse distributed matrix |
103+
| `Matrix{T}` | `HPCMatrix{T}` | Dense distributed matrix |
104+
| `Vector{T}` | `HPCVector{T}` | Dense distributed vector |
105+
| `SparseMatrixCSC{T,Int}` | `HPCSparseMatrix{T}` | Sparse distributed matrix |
106106

107107
### MPI to Native
108108

@@ -135,7 +135,7 @@ using MPI
135135
MPI.Init()
136136

137137
using MultiGridBarrierMPI
138-
using LinearAlgebraMPI
138+
using HPCLinearAlgebra
139139
using MultiGridBarrier
140140

141141
# 1. Create native geometry with specific parameters
@@ -168,7 +168,7 @@ using MPI
168168
MPI.Init()
169169

170170
using MultiGridBarrierMPI
171-
using LinearAlgebraMPI
171+
using HPCLinearAlgebra
172172
using MultiGridBarrier
173173
using LinearAlgebra
174174

@@ -193,10 +193,10 @@ end
193193

194194
### Printing from One Rank
195195

196-
Use `io0()` from LinearAlgebraMPI to print from rank 0 only:
196+
Use `io0()` from HPCLinearAlgebra to print from rank 0 only:
197197

198198
```julia
199-
using LinearAlgebraMPI
199+
using HPCLinearAlgebra
200200

201201
# This prints once (from rank 0)
202202
println(io0(), "Hello from rank 0!")
@@ -268,7 +268,7 @@ using MPI
268268
MPI.Init()
269269

270270
using MultiGridBarrierMPI
271-
using LinearAlgebraMPI
271+
using HPCLinearAlgebra
272272

273273
# Solve a 1D problem with 4 multigrid levels (2^4 = 16 elements)
274274
sol = fem1d_mpi_solve(Float64; L=4, p=1.0, verbose=true)
@@ -297,7 +297,7 @@ using MPI
297297
MPI.Init()
298298

299299
using MultiGridBarrierMPI
300-
using LinearAlgebraMPI
300+
using HPCLinearAlgebra
301301

302302
# Solve a 2D problem
303303
sol = fem2d_mpi_solve(Float64; L=2, p=1.0, verbose=true)
@@ -327,7 +327,7 @@ using MPI
327327
MPI.Init()
328328

329329
using MultiGridBarrierMPI
330-
using LinearAlgebraMPI
330+
using HPCLinearAlgebra
331331

332332
# Solve a 3D problem with Q3 elements and 2 multigrid levels
333333
sol = fem3d_mpi_solve(Float64; L=2, k=3, p=1.0, verbose=true)
@@ -357,7 +357,7 @@ using MPI
357357
MPI.Init()
358358

359359
using MultiGridBarrierMPI
360-
using LinearAlgebraMPI
360+
using HPCLinearAlgebra
361361
using MultiGridBarrier
362362

363363
# Create MPI geometry
@@ -393,7 +393,7 @@ using MPI
393393
MPI.Init()
394394

395395
using MultiGridBarrierMPI
396-
using LinearAlgebraMPI
396+
using HPCLinearAlgebra
397397

398398
sol = fem2d_mpi_solve(Float64; L=3, p=1.0)
399399
sol_native = mpi_to_native(sol)

docs/src/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ v = string(pkgversion(MultiGridBarrierMPI))
1010
md"# MultiGridBarrierMPI.jl $v"
1111
```
1212

13-
**A Julia package that bridges MultiGridBarrier.jl and LinearAlgebraMPI.jl for distributed multigrid barrier computations.**
13+
**A Julia package that bridges MultiGridBarrier.jl and HPCLinearAlgebra.jl for distributed multigrid barrier computations.**
1414

1515
## Overview
1616

17-
MultiGridBarrierMPI.jl extends the MultiGridBarrier.jl package to work with LinearAlgebraMPI.jl's distributed matrix and vector types. This enables efficient parallel computation of multigrid barrier methods across multiple MPI ranks using pure Julia distributed types (no PETSc required).
17+
MultiGridBarrierMPI.jl extends the MultiGridBarrier.jl package to work with HPCLinearAlgebra.jl's distributed matrix and vector types. This enables efficient parallel computation of multigrid barrier methods across multiple MPI ranks using pure Julia distributed types (no PETSc required).
1818

1919
## Key Features
2020

2121
- **1D, 2D, and 3D Support**: Full support for 1D elements, 2D triangular, and 3D hexahedral finite elements
2222
- **Seamless Integration**: Drop-in replacement for MultiGridBarrier's native types
23-
- **Pure Julia MPI**: Uses LinearAlgebraMPI.jl for distributed linear algebra
23+
- **Pure Julia MPI**: Uses HPCLinearAlgebra.jl for distributed linear algebra
2424
- **Type Conversion**: Easy conversion between native Julia arrays and MPI distributed types
2525
- **MPI-Aware**: All operations correctly handle MPI collective requirements
2626
- **MUMPS Solver**: Uses MUMPS direct solver for accurate Newton iterations
@@ -34,7 +34,7 @@ using MPI
3434
MPI.Init()
3535

3636
using MultiGridBarrierMPI
37-
using LinearAlgebraMPI
37+
using HPCLinearAlgebra
3838
using MultiGridBarrier
3939

4040
# Solve with MPI distributed types (L=3 refinement levels)
@@ -71,7 +71,7 @@ Depth = 2
7171
This package is part of a larger ecosystem:
7272

7373
- **[MultiGridBarrier.jl](https://github.com/sloisel/MultiGridBarrier.jl)**: Core multigrid barrier method implementation (1D, 2D, and 3D)
74-
- **[LinearAlgebraMPI.jl](https://github.com/sloisel/LinearAlgebraMPI.jl)**: Pure Julia distributed linear algebra with MPI
74+
- **[HPCLinearAlgebra.jl](https://github.com/sloisel/HPCLinearAlgebra.jl)**: Pure Julia distributed linear algebra with MPI
7575
- **MPI.jl**: Julia MPI bindings for distributed computing
7676

7777
## Requirements

docs/src/installation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For HPC environments, you may want to configure MPI.jl to use your system's MPI
1010

1111
### MUMPS
1212

13-
The package uses MUMPS for sparse direct solves through LinearAlgebraMPI.jl. MUMPS is typically available through your system's package manager or HPC module system.
13+
The package uses MUMPS for sparse direct solves through HPCLinearAlgebra.jl. MUMPS is typically available through your system's package manager or HPC module system.
1414

1515
## Package Installation
1616

@@ -75,7 +75,7 @@ using MPI
7575
MPI.Init()
7676

7777
using MultiGridBarrierMPI
78-
using LinearAlgebraMPI
78+
using HPCLinearAlgebra
7979

8080
# Your parallel code here
8181
sol = fem2d_mpi_solve(Float64; L=3, p=1.0)
@@ -89,7 +89,7 @@ mpiexec -n 4 julia --project my_program.jl
8989
```
9090

9191
!!! tip "Output from Rank 0 Only"
92-
Use `io0()` from LinearAlgebraMPI for output to avoid duplicate messages:
92+
Use `io0()` from HPCLinearAlgebra for output to avoid duplicate messages:
9393
```julia
9494
println(io0(), "This prints once from rank 0")
9595
```
@@ -106,7 +106,7 @@ using Pkg; Pkg.build("MPI")
106106

107107
### MUMPS Issues
108108

109-
If MUMPS fails to load, ensure it's properly installed on your system and that LinearAlgebraMPI.jl can find it.
109+
If MUMPS fails to load, ensure it's properly installed on your system and that HPCLinearAlgebra.jl can find it.
110110

111111
### Test Failures
112112

0 commit comments

Comments
 (0)