Skip to content

Commit

Permalink
Review update.
Browse files Browse the repository at this point in the history
+ Formatting.
+ combie loops.
+ revert usage prints.
  • Loading branch information
pratikvn committed Sep 29, 2020
1 parent ecea91c commit d46ba9e
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 36 deletions.
63 changes: 39 additions & 24 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
option(GINKGO_BUILD_EXTLIB_EXAMPLE "Build the external-lib-interfacing with deal.II, you need to link the deal.II library." OFF)
option(GINKGO_RUN_EXAMPLES "Run the examples." OFF)

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)

set(EXAMPLES_LIST "${EXAMPLES_EXEC_LIST};custom-matrix-format;custom-stopping-criterion;minimal-cuda-solver;papi-logging;performance-debugging;preconditioner-export;simple-solver-logging")
set(EXAMPLES_LIST
${EXAMPLES_EXEC_LIST}
custom-matrix-format
custom-stopping-criterion
minimal-cuda-solver
papi-logging
performance-debugging
preconditioner-export
simple-solver-logging)

if(GINKGO_BUILD_EXTLIB_EXAMPLE)
set(EXAMPLES_LIST "${EXAMPLES_LIST};external-lib-interfacing")
list(APPEND EXAMPLES_LIST external-lib-interfacing)
endif()

foreach(example ${EXAMPLES_LIST})
add_subdirectory(${example})
add_custom_target("run-${example}"
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${example}/${example} > ${CMAKE_CURRENT_BINARY_DIR}/${example}/${example}.out
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
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')")
add_custom_target("validate-${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()

if(GINKGO_RUN_EXAMPLES)
foreach(example ${EXAMPLES_LIST})
add_custom_target("run-${example}"
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')")
add_custom_target("validate-${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()
add_custom_target(run_all_examples)
add_custom_target(validate_all_examples)
foreach(run_ex ${EXAMPLES_EXEC_LIST})
add_dependencies(run_all_examples "run-${run_ex}")
add_dependencies(validate_all_examples "validate-${run_ex}")
endforeach()
endif()
add_custom_target(run_all_examples)
add_custom_target(validate_all_examples)
foreach(run_ex ${EXAMPLES_EXEC_LIST})
add_dependencies(run_all_examples "run-${run_ex}")
add_dependencies(validate_all_examples "validate-${run_ex}")
endforeach()
2 changes: 1 addition & 1 deletion 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: executable [executor]" << std::endl;
std::cerr << "Usage: " << argv[0] << " [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: executable [executor]" << std::endl;
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::exit(-1);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/ginkgo-overhead/ginkgo-overhead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main(int argc, char *argv[])

long unsigned num_iters = 1000000;
if (argc > 2) {
print_usage_and_exit("executable");
print_usage_and_exit(argv[0]);
}
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: executable [executor]" << std::endl;
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::exit(-1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +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: executable [executor] [sweeps]" << std::endl;
std::cerr << "Usage: " << argv[0] << " [executor] [sweeps]" << std::endl;
std::exit(-1);
}
unsigned int sweeps = (argc == 3) ? atoi(argv[2]) : 5u;
Expand Down
2 changes: 1 addition & 1 deletion 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: executable [executor]" << std::endl;
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::exit(-1);
}

Expand Down
2 changes: 1 addition & 1 deletion 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: executable [executor]" << std::endl;
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::exit(-1);
}

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: executable [executor]" << std::endl;
std::cerr << "Usage: " << argv[0] << " [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("executable");
print_usage(argv[0]);
}

// Read the input matrix file directory
Expand Down
2 changes: 1 addition & 1 deletion examples/preconditioned-solver/preconditioned-solver.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: executable [executor]" << std::endl;
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::exit(-1);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/simple-solver-logging/simple-solver-logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,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: executable [executor]" << std::endl;
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::exit(-1);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/simple-solver/simple-solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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: executable [executor]" << std::endl;
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
std::exit(-1);
}

Expand Down

0 comments on commit d46ba9e

Please sign in to comment.