Skip to content

Commit

Permalink
Add an example as an integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikvn committed Oct 25, 2021
1 parent 30d3cc6 commit ae22432
Show file tree
Hide file tree
Showing 13 changed files with 427 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set(EXAMPLES_LIST
ginkgo-overhead
minimal-cuda-solver
mixed-spmv
mpi-simple-solver
mixed-multigrid-solver
multigrid-preconditioned-solver
par-ilu-convergence
Expand Down
17 changes: 17 additions & 0 deletions examples/mpi-simple-solver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.9)
project(mpi-simple-solver)

# We only need to find Ginkgo if we build this example stand-alone
if (NOT GINKGO_BUILD_EXAMPLES)
find_package(Ginkgo 1.5.0 REQUIRED)
find_package(MPI REQUIRED)
endif()

add_executable(mpi-simple-solver mpi-simple-solver.cpp)
target_link_libraries(mpi-simple-solver Ginkgo::ginkgo)
target_link_libraries(mpi-simple-solver MPI::MPI_CXX)

# Copy the data files to the execution directory
configure_file(data/A.mtx data/A.mtx COPYONLY)
configure_file(data/b.mtx data/b.mtx COPYONLY)
configure_file(data/x0.mtx data/x0.mtx COPYONLY)
16 changes: 16 additions & 0 deletions examples/mpi-simple-solver/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# set up script
if [ $# -ne 1 ]; then
echo -e "Usage: $0 GINKGO_BUILD_DIRECTORY"
exit 1
fi
BUILD_DIR=$1
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" &>/dev/null && pwd )

source ${THIS_DIR}/../build-setup.sh

# build
${CXX} -std=c++14 -o ${THIS_DIR}/mpi-simple-solver ${THIS_DIR}/mpi-simple-solver.cpp \
-I${THIS_DIR}/../../include -I${BUILD_DIR}/include \
-L${THIS_DIR} ${LINK_FLAGS}
114 changes: 114 additions & 0 deletions examples/mpi-simple-solver/data/A.mtx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
%%MatrixMarket matrix coordinate integer symmetric
%-------------------------------------------------------------------------------
% UF Sparse Matrix Collection, Tim Davis
% http://www.cise.ufl.edu/research/sparse/matrices/JGD_Trefethen/Trefethen_20b
% name: JGD_Trefethen/Trefethen_20b
% [Diagonal matrices with primes, Nick Trefethen, Oxford Univ.]
% id: 2203
% date: 2008
% author: N. Trefethen
% ed: J.-G. Dumas
% fields: name title A id date author ed kind notes
% kind: combinatorial problem
%-------------------------------------------------------------------------------
% notes:
% Diagonal matrices with primes, Nick Trefethen, Oxford Univ.
% From Jean-Guillaume Dumas' Sparse Integer Matrix Collection,
% http://ljk.imag.fr/membres/Jean-Guillaume.Dumas/simc.html
%
% Problem 7 of the Hundred-dollar, Hundred-digit Challenge Problems,
% SIAM News, vol 35, no. 1.
%
% 7. Let A be the 20,000 x 20,000 matrix whose entries are zero
% everywhere except for the primes 2, 3, 5, 7, . . . , 224737 along the
% main diagonal and the number 1 in all the positions A(i,j) with
% |i-j| = 1,2,4,8, . . . ,16384. What is the (1,1) entry of inv(A)?
%
% http://www.siam.org/news/news.php?id=388
%
% Filename in JGD collection: Trefethen/trefethen_20__19_minor.sms
%-------------------------------------------------------------------------------
19 19 83
1 1 3
2 1 1
3 1 1
5 1 1
9 1 1
17 1 1
2 2 5
3 2 1
4 2 1
6 2 1
10 2 1
18 2 1
3 3 7
4 3 1
5 3 1
7 3 1
11 3 1
19 3 1
4 4 11
5 4 1
6 4 1
8 4 1
12 4 1
5 5 13
6 5 1
7 5 1
9 5 1
13 5 1
6 6 17
7 6 1
8 6 1
10 6 1
14 6 1
7 7 19
8 7 1
9 7 1
11 7 1
15 7 1
8 8 23
9 8 1
10 8 1
12 8 1
16 8 1
9 9 29
10 9 1
11 9 1
13 9 1
17 9 1
10 10 31
11 10 1
12 10 1
14 10 1
18 10 1
11 11 37
12 11 1
13 11 1
15 11 1
19 11 1
12 12 41
13 12 1
14 12 1
16 12 1
13 13 43
14 13 1
15 13 1
17 13 1
14 14 47
15 14 1
16 14 1
18 14 1
15 15 53
16 15 1
17 15 1
19 15 1
16 16 59
17 16 1
18 16 1
17 17 61
18 17 1
19 17 1
18 18 67
19 18 1
19 19 71
21 changes: 21 additions & 0 deletions examples/mpi-simple-solver/data/b.mtx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
%%MatrixMarket matrix array real general
19 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
21 changes: 21 additions & 0 deletions examples/mpi-simple-solver/data/x0.mtx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
%%MatrixMarket matrix array real general
19 1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1 change: 1 addition & 0 deletions examples/mpi-simple-solver/doc/builds-on
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

19 changes: 19 additions & 0 deletions examples/mpi-simple-solver/doc/intro.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<a name="Intro"></a>
<h1>Introduction</h1>
This simple solver example should help you get started with Ginkgo. This example is meant for you to understand
how Ginkgo works and how you can solve a simple linear system with Ginkgo. We encourage you to play with the code,
change the parameters and see what is best suited for your purposes.

<h3> About the example </h3>
Each example has the following sections:
<ol>
<li> <b>Introduction:</b>This gives an overview of the example and mentions
any interesting aspects in the example that might help the reader.
<li> <b>The commented program:</b> This section is intended for you to
understand the details of the example so that you can play with it and understand
Ginkgo and its features better.
<li> <b>Results:</b> This section shows the results of the code when run. Though the
results may not be completely the same, you can expect the behaviour to be similar.
<li> <b>The plain program:</b> This is the complete code without any comments to have
an complete overview of the code.
</ol>
1 change: 1 addition & 0 deletions examples/mpi-simple-solver/doc/kind
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
basic
35 changes: 35 additions & 0 deletions examples/mpi-simple-solver/doc/results.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<h1>Results</h1>
The following is the expected result:

@code{.cpp}

Solution (x):
%%MatrixMarket matrix array real general
19 1
0.252218
0.108645
0.0662811
0.0630433
0.0384088
0.0396536
0.0402648
0.0338935
0.0193098
0.0234653
0.0211499
0.0196413
0.0199151
0.0181674
0.0162722
0.0150714
0.0107016
0.0121141
0.0123025
Residual norm sqrt(r^T r):
%%MatrixMarket matrix array real general
1 1
2.10788e-15

@endcode

<h3> Comments about programming and debugging </h3>
1 change: 1 addition & 0 deletions examples/mpi-simple-solver/doc/short-intro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The simple solver example.
1 change: 1 addition & 0 deletions examples/mpi-simple-solver/doc/tooltip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Solve a simple linear system with CG. Read a matrix and right hand side from a file.
Loading

0 comments on commit ae22432

Please sign in to comment.