Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add example runs to one CI job, minor stdout updates to examples.
  • Loading branch information
pratikvn committed Oct 1, 2020
commit e834dc15fe3fb2a7f3df5d7b492733ae4e559239
10 changes: 10 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ stages:
BUILD_OMP: "OFF"
BUILD_CUDA: "OFF"
BUILD_HIP: "OFF"
RUN_EXAMPLES: "OFF"
CONFIG_LOG: "ON"
CXX_FLAGS: ""
EXTRA_CMAKE_FLAGS: ""
Expand Down Expand Up @@ -61,6 +62,7 @@ stages:
-DGINKGO_BUILD_OMP=${BUILD_OMP} -DGINKGO_BUILD_CUDA=${BUILD_CUDA}
-DGINKGO_BUILD_HIP=${BUILD_HIP}
-DGINKGO_BUILD_TESTS=ON -DGINKGO_BUILD_EXAMPLES=ON
-DGINKGO_RUN_EXAMPLES=${RUN_EXAMPLES}
-DGINKGO_CONFIG_LOG_DETAILED=${CONFIG_LOG}
- ninja -j${NUM_CORES} -l${CI_LOAD_LIMIT}
dependencies: []
Expand All @@ -87,12 +89,18 @@ stages:
-DGINKGO_BUILD_OMP=${BUILD_OMP} -DGINKGO_BUILD_CUDA=${BUILD_CUDA}
-DGINKGO_BUILD_HIP=${BUILD_HIP}
-DGINKGO_BUILD_TESTS=ON -DGINKGO_BUILD_EXAMPLES=ON
-DGINKGO_RUN_EXAMPLES=${RUN_EXAMPLES}
-DGINKGO_CONFIG_LOG_DETAILED=${CONFIG_LOG}
- ninja -j${NUM_CORES} -l${CI_LOAD_LIMIT} install
- |
(( $(ctest -N | tail -1 | sed 's/Total Tests: //') != 0 )) || exit 1
- ctest -V
- ninja test_install
- |
if [ "${RUN_EXAMPLES}" == "ON" ]; then
ninja run_all_examples
ninja validate_all_examples
fi
dependencies: []
except:
- schedules
Expand Down Expand Up @@ -122,6 +130,7 @@ sync:


# Build jobs
# Job with example runs.
build/cuda90/gcc/all/debug/shared:
<<: *default_build_with_test
image: localhost:5000/gko-cuda90-gnu5-llvm39
Expand All @@ -131,6 +140,7 @@ build/cuda90/gcc/all/debug/shared:
BUILD_CUDA: "ON"
BUILD_HIP: "ON"
BUILD_TYPE: "Debug"
RUN_EXAMPLES: "ON"
CUDA_ARCH: 35
only:
variables:
Expand Down
39 changes: 38 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ function(setup_example_target target_name)
target_include_directories(${target_name} PRIVATE ${PROJECT_SOURCE_DIR})
endfunction()

set(EXAMPLES_EXEC_LIST "adaptiveprecision-blockjacobi;custom-logger;ginkgo-overhead;ginkgo-ranges;ilu-preconditioned-solver;ir-ilu-preconditioned-solver;inverse-iteration;iterative-refinement;mixed-precision-ir;nine-pt-stencil-solver;poisson-solver;preconditioned-solver;simple-solver;three-pt-stencil-solver;")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest listing one example per line, this makes for nicer diffs in the future.

Suggested change
set(EXAMPLES_EXEC_LIST "adaptiveprecision-blockjacobi;custom-logger;ginkgo-overhead;ginkgo-ranges;ilu-preconditioned-solver;ir-ilu-preconditioned-solver;inverse-iteration;iterative-refinement;mixed-precision-ir;nine-pt-stencil-solver;poisson-solver;preconditioned-solver;simple-solver;three-pt-stencil-solver;")
set(EXAMPLES_EXEC_LIST
adaptiveprecision-blockjacobi
custom-logger
ginkgo-overhead
ginkgo-ranges
ilu-preconditioned-solver
ir-ilu-preconditioned-solver
inverse-iteration
iterative-refinement
mixed-precision-ir
nine-pt-stencil-solver
poisson-solver
preconditioned-solver
simple-solver
three-pt-stencil-solver)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a list of examples which can take in executor as parameter? If so, I believe at least simple-solver-logging can be here as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but simple-solver-logging prints out pointers and they can be different on each run.


set(EXAMPLES_LIST "${EXAMPLES_EXEC_LIST};custom-matrix-format;custom-stopping-criterion;minimal-cuda-solver;papi-logging;performance-debugging;preconditioner-export;simple-solver-logging")
Comment thread
pratikvn marked this conversation as resolved.
Outdated

set(EXAMPLES_LIST "custom-logger;custom-matrix-format;custom-stopping-criterion;adaptiveprecision-blockjacobi;ginkgo-overhead;ginkgo-ranges;ilu-preconditioned-solver;ir-ilu-preconditioned-solver;inverse-iteration;iterative-refinement;minimal-cuda-solver;mixed-precision-ir;nine-pt-stencil-solver;papi-logging;performance-debugging;poisson-solver;preconditioned-solver;preconditioner-export;simple-solver;simple-solver-logging;three-pt-stencil-solver;")
if(GINKGO_BUILD_EXTLIB_EXAMPLE)
set(EXAMPLES_LIST "${EXAMPLES_LIST};external-lib-interfacing")
Comment thread
pratikvn marked this conversation as resolved.
Outdated
endif()
Expand All @@ -24,4 +26,39 @@ if(GINKGO_RUN_EXAMPLES)
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${example}/${example} > ${CMAKE_CURRENT_BINARY_DIR}/${example}/${example}.out
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
endforeach()
foreach(example ${EXAMPLES_LIST})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${example}/diff-command "#!/bin/bash
diff <(sed -n '7,$p' ${CMAKE_CURRENT_BINARY_DIR}/${example}/${example}.out | sed -E 's/([0-9]+.)//g') <(sed -n '6,$p' ${CMAKE_SOURCE_DIR}/examples/${example}/doc/results.dox | head -n -4 | sed -E 's/([0-9]+.)//g')")
Comment thread
upsj marked this conversation as resolved.
Outdated
add_custom_target("diff-${example}"
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/${example}/diff-command && ${CMAKE_CURRENT_BINARY_DIR}/${example}/diff-command
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
endforeach()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/run_all_examples.sh
"NUM_EXAMPLES=$(wc -l < example-targets.txt)\n"
"for i in $(seq 1 $NUM_EXAMPLES)\n"
"do\n"
" target_name=$(head -n $i example-targets.txt | tail -1)\n"
" ex_target=run-\$\{target_name\}\n"
" cmake --build ${CMAKE_BINARY_DIR} --target $ex_target\n"
"done\n")
add_custom_target("run_all_examples"
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/run_all_examples.sh && ${CMAKE_CURRENT_BINARY_DIR}/run_all_examples.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/validate_all_examples.sh
"NUM_EXAMPLES=$(wc -l < example-targets.txt)\n"
"for i in $(seq 1 $NUM_EXAMPLES)\n"
"do\n"
" target_name=$(head -n $i example-targets.txt | tail -1)\n"
" ex_target=diff-\$\{target_name\}\n"
" cmake --build ${CMAKE_BINARY_DIR} --target $ex_target\n"
"done\n")
add_custom_target("validate_all_examples"
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/validate_all_examples.sh && ${CMAKE_CURRENT_BINARY_DIR}/validate_all_examples.sh
Comment thread
upsj marked this conversation as resolved.
Outdated
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()

set(OUT_FILE "${CMAKE_BINARY_DIR}/examples/example-targets.txt")
file(WRITE ${OUT_FILE} "")
foreach(example ${EXAMPLES_EXEC_LIST})
file(APPEND ${OUT_FILE} "${example}\n")
endforeach()
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ int main(int argc, char *argv[])
A->apply(lend(one), lend(x), lend(neg_one), lend(b));
b->compute_norm2(lend(res));

std::cout << "Initial residual norm sqrt(r^T r): \n";
std::cout << "Initial residual norm sqrt(r^T r):\n";
write(std::cout, lend(initres));
std::cout << "Final residual norm sqrt(r^T r): \n";
std::cout << "Final residual norm sqrt(r^T r):\n";
write(std::cout, lend(res));

// Print solver statistics
Expand Down
2 changes: 1 addition & 1 deletion examples/adaptiveprecision-blockjacobi/doc/results.dox
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Final residual norm sqrt(r^T r):
1 1
5.69384e-06
CG iteration count: 5
CG execution time [ms]: 2.04779
CG execution time [ms]: 0.080041

@endcode

Expand Down
6 changes: 3 additions & 3 deletions examples/custom-logger/custom-logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ int main(int argc, char *argv[])
gko::HipExecutor::get_num_devices() > 0) {
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create());
} else {
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::cerr << "Usage: executable [executor]" << std::endl;
Comment thread
pratikvn marked this conversation as resolved.
Outdated
std::exit(-1);
}

Expand Down Expand Up @@ -292,7 +292,7 @@ int main(int argc, char *argv[])
solver->apply(gko::lend(b), gko::lend(x));

// Print the solution to the command line.
std::cout << "Solution (x): \n";
std::cout << "Solution (x):\n";
write(std::cout, gko::lend(x));

// Print the table of the residuals obtained from the logger
Expand All @@ -311,6 +311,6 @@ int main(int argc, char *argv[])
A->apply(gko::lend(one), gko::lend(x), gko::lend(neg_one), gko::lend(b));
b->compute_norm2(gko::lend(res));

std::cout << "Residual norm sqrt(r^T r): \n";
std::cout << "Residual norm sqrt(r^T r):\n";
write(std::cout, gko::lend(res));
}
2 changes: 1 addition & 1 deletion examples/custom-matrix-format/custom-matrix-format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ int main(int argc, char *argv[])
using cg = gko::solver::Cg<ValueType>;

if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " DISCRETIZATION_POINTS [executor]"
std::cerr << "Usage: executable DISCRETIZATION_POINTS [executor]"
<< std::endl;
std::exit(-1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ int main(int argc, char *argv[])
gko::HipExecutor::get_num_devices() > 0) {
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
} else {
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::cerr << "Usage: executable [executor]" << std::endl;
std::exit(-1);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/ginkgo-overhead/doc/results.dox
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ This is the expected output:

@code{.cpp}

Running 1000000 iterations of the CG solver took a total of 1.62987 seconds.
Average library overhead: 1629.87 [nanoseconds / iteration]
Running 1000000 iterations of the CG solver took a total of 1.60337 seconds.
Average library overhead: 1603.37 [nanoseconds / iteration]

@endcode

Expand Down
5 changes: 2 additions & 3 deletions examples/ginkgo-overhead/ginkgo-overhead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream>


[[noreturn]] void print_usage_and_exit(const char *name)
{
[[noreturn]] void print_usage_and_exit(const char *name) {
std::cerr << "Usage: " << name << " [NUM_ITERS]" << std::endl;
std::exit(-1);
}
Expand All @@ -56,7 +55,7 @@ int main(int argc, char *argv[])

long unsigned num_iters = 1000000;
if (argc > 2) {
print_usage_and_exit(argv[0]);
print_usage_and_exit("executable");
}
if (argc == 2) {
num_iters = std::atol(argv[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char *argv[])
gko::HipExecutor::get_num_devices() > 0) {
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
} else {
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::cerr << "Usage: executable [executor]" << std::endl;
std::exit(-1);
}

Expand Down Expand Up @@ -116,7 +116,7 @@ int main(int argc, char *argv[])
ilu_gmres->apply(gko::lend(b), gko::lend(x));

// Print solution
std::cout << "Solution (x): \n";
std::cout << "Solution (x):\n";
write(std::cout, gko::lend(x));

// Calculate residual
Expand All @@ -126,6 +126,6 @@ int main(int argc, char *argv[])
A->apply(gko::lend(one), gko::lend(x), gko::lend(neg_one), gko::lend(b));
b->compute_norm2(gko::lend(res));

std::cout << "Residual norm sqrt(r^T r): \n";
std::cout << "Residual norm sqrt(r^T r):\n";
write(std::cout, gko::lend(res));
}
2 changes: 1 addition & 1 deletion examples/ir-ilu-preconditioned-solver/doc/results.dox
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Solution (x):
0.0121141
0.0123025
GMRES iteration count: 8
GMRES execution time [ms]: 3.89406
GMRES execution time [ms]: 0.377673
Residual norm sqrt(r^T r):
%%MatrixMarket matrix array real general
1 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ int main(int argc, char *argv[])
gko::HipExecutor::get_num_devices() > 0) {
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
} else {
std::cerr << "Usage: " << argv[0] << " [executor] [sweeps]"
<< std::endl;
std::cerr << "Usage: executable [executor] [sweeps]" << std::endl;
std::exit(-1);
}
unsigned int sweeps = (argc == 3) ? atoi(argv[2]) : 5u;
Expand Down Expand Up @@ -165,10 +164,10 @@ int main(int argc, char *argv[])
time += std::chrono::duration_cast<std::chrono::nanoseconds>(toc - tic);
}

std::cout << "Using " << sweeps << " block-Jacobi sweeps. \n";
std::cout << "Using " << sweeps << " block-Jacobi sweeps.\n";

// Print solution
std::cout << "Solution (x): \n";
std::cout << "Solution (x):\n";
write(std::cout, gko::lend(x));

// Calculate residual
Expand All @@ -182,6 +181,6 @@ int main(int argc, char *argv[])
<< "\n";
std::cout << "GMRES execution time [ms]: "
<< static_cast<double>(time.count()) / 100000000.0 << "\n";
std::cout << "Residual norm sqrt(r^T r): \n";
std::cout << "Residual norm sqrt(r^T r):\n";
write(std::cout, gko::lend(res));
}
2 changes: 1 addition & 1 deletion examples/iterative-refinement/doc/results.dox
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Final residual norm sqrt(r^T r):
1 1
4.23821e-11
IR iteration count: 24
IR execution time [ms]: 14.9084
IR execution time [ms]: 0.794962

@endcode

Expand Down
6 changes: 3 additions & 3 deletions examples/iterative-refinement/iterative-refinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char *argv[])
gko::HipExecutor::get_num_devices() > 0) {
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
} else {
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::cerr << "Usage: executable [executor]" << std::endl;
std::exit(-1);
}

Expand Down Expand Up @@ -138,9 +138,9 @@ int main(int argc, char *argv[])
A->apply(lend(one), lend(x), lend(neg_one), lend(b));
b->compute_norm2(lend(res));

std::cout << "Initial residual norm sqrt(r^T r): \n";
std::cout << "Initial residual norm sqrt(r^T r):\n";
write(std::cout, lend(initres));
std::cout << "Final residual norm sqrt(r^T r): \n";
std::cout << "Final residual norm sqrt(r^T r):\n";
write(std::cout, lend(res));

// Print solver statistics
Expand Down
2 changes: 1 addition & 1 deletion examples/mixed-precision-ir/doc/results.dox
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Final residual norm sqrt(r^T r):
1 1
1.22728e-10
MPIR iteration count: 25
MPIR execution time [ms]: 14.2256
MPIR execution time [ms]: 0.846559

@endcode

Expand Down
6 changes: 3 additions & 3 deletions examples/mixed-precision-ir/mixed-precision-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int main(int argc, char *argv[])
gko::HipExecutor::get_num_devices() > 0) {
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
} else {
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::cerr << "Usage: executable [executor]" << std::endl;
std::exit(-1);
}

Expand Down Expand Up @@ -168,9 +168,9 @@ int main(int argc, char *argv[])
A->apply(lend(one), lend(x), lend(neg_one), lend(b));
b->compute_norm2(lend(res_vec));

std::cout << "Initial residual norm sqrt(r^T r): \n";
std::cout << "Initial residual norm sqrt(r^T r):\n";
write(std::cout, lend(initres_vec));
std::cout << "Final residual norm sqrt(r^T r): \n";
std::cout << "Final residual norm sqrt(r^T r):\n";
write(std::cout, lend(res_vec));

// Print solver statistics
Expand Down
19 changes: 4 additions & 15 deletions examples/nine-pt-stencil-solver/doc/results.dox
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<h1>Results</h1>

The expected output of the relative error at K=10 should be
The expected output should be

@code{.cpp}

0.00150263 0.00676184 0.0210368 0.0488355 0.0946657 0.163035 0.258452 0.385425 0.54846 0.752066
0.00676184 0.012021 0.026296 0.0540947 0.0999249 0.168295 0.263712 0.390684 0.553719 0.757325
0.0210368 0.026296 0.040571 0.0683697 0.1142 0.18257 0.277987 0.404959 0.567994 0.7716
0.0488354 0.0540947 0.0683697 0.0961683 0.141998 0.210368 0.305785 0.432757 0.595793 0.799399
0.0946656 0.0999248 0.1142 0.141998 0.187829 0.256198 0.351615 0.478588 0.641623 0.845229
0.163035 0.168295 0.182569 0.210368 0.256198 0.324568 0.419985 0.546957 0.709993 0.913599
0.258452 0.263711 0.277987 0.305785 0.351615 0.419985 0.515402 0.642374 0.80541 1.00902
0.385424 0.390684 0.404959 0.432757 0.478588 0.546957 0.642374 0.769346 0.932382 1.13599
0.54846 0.553719 0.567994 0.595793 0.641623 0.709992 0.805409 0.932382 1.09542 1.29902
0.752066 0.757325 0.7716 0.799399 0.845229 0.913599 1.00902 1.13599 1.29902 1.50263

The average relative error is 1.4283e-07
The runtime is 5.784994 ms
Usage: executable DISCRETIZATION_POINTS [executor] [stencil_alpha] [stencil_beta] [stencil_gamma]
The average relative error is 6.35715e-06
The runtime is 167.320520 ms

@endcode

Expand Down
5 changes: 4 additions & 1 deletion examples/nine-pt-stencil-solver/nine-pt-stencil-solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,11 @@ void solve_system(const std::string &executor_string,

int main(int argc, char *argv[])
{
// Print version information
std::cout << gko::version_info::get() << std::endl;

if (argc < 2) {
std::cout << "Usage: " << argv[0] << " DISCRETIZATION_POINTS [executor]"
std::cout << "Usage: executable DISCRETIZATION_POINTS [executor]"
Comment thread
pratikvn marked this conversation as resolved.
Outdated
<< " [stencil_alpha] [stencil_beta] [stencil_gamma]"
<< std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/papi-logging/papi-logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int main(int argc, char *argv[])
gko::HipExecutor::get_num_devices() > 0) {
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
} else {
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::cerr << "Usage: executable [executor]" << std::endl;
std::exit(-1);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/performance-debugging/performance-debugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ int main(int argc, char *argv[])
gko::CudaExecutor::get_num_devices() > 0) {
exec = gko::CudaExecutor::create(0, gko::OmpExecutor::create(), true);
} else {
print_usage(argv[0]);
print_usage("executable");
}

// Read the input matrix file directory
Expand Down
Loading