-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabled the use with both explicit and implicit executor #12
- Loading branch information
Showing
7 changed files
with
91 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Ginkgo | ||
|
||
# Type alias | ||
const (Tv, Ti) = (Float32, Int32) | ||
|
||
# Print ginkgo library version | ||
version() | ||
|
||
# Obtain executor with a specific backend | ||
const exec = create(:omp) | ||
|
||
# Read matrix and vector from mtk files | ||
A = GkoCsr{Tv, Ti}("data/A.mtx", exec) | ||
b = GkoDense{Tv}("data/b.mtx", exec) | ||
x = GkoDense{Tv}("data/x0.mtx", exec) | ||
|
||
cg!(x, A, b, exec; maxiter = 20, reduction = 1.0e-7) | ||
|
||
@info "Solution (x):" | ||
display(x) | ||
|
||
one = number(Tv(1.0), exec) | ||
neg_one = number(Tv(-1.0), exec) | ||
res = number(Tv(0.0), exec) | ||
|
||
# x = one*A*b + neg_one*x | ||
spmm!(A, one, x, neg_one, b) | ||
|
||
|
||
norm2!(b, res) | ||
@info "Residual norm sqrt(r^T r):" | ||
display(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters