Skip to content

Commit d46ba9e

Browse files
committed
Review update.
+ Formatting. + combie loops. + revert usage prints.
1 parent ecea91c commit d46ba9e

13 files changed

Lines changed: 51 additions & 36 deletions

File tree

examples/CMakeLists.txt

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,50 @@
11
option(GINKGO_BUILD_EXTLIB_EXAMPLE "Build the external-lib-interfacing with deal.II, you need to link the deal.II library." OFF)
2-
option(GINKGO_RUN_EXAMPLES "Run the examples." OFF)
32

4-
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;")
3+
set(EXAMPLES_EXEC_LIST
4+
adaptiveprecision-blockjacobi
5+
custom-logger
6+
ginkgo-overhead
7+
ginkgo-ranges
8+
ilu-preconditioned-solver
9+
ir-ilu-preconditioned-solver
10+
inverse-iteration
11+
iterative-refinement
12+
mixed-precision-ir
13+
nine-pt-stencil-solver
14+
poisson-solver
15+
preconditioned-solver
16+
simple-solver
17+
three-pt-stencil-solver)
518

6-
set(EXAMPLES_LIST "${EXAMPLES_EXEC_LIST};custom-matrix-format;custom-stopping-criterion;minimal-cuda-solver;papi-logging;performance-debugging;preconditioner-export;simple-solver-logging")
19+
set(EXAMPLES_LIST
20+
${EXAMPLES_EXEC_LIST}
21+
custom-matrix-format
22+
custom-stopping-criterion
23+
minimal-cuda-solver
24+
papi-logging
25+
performance-debugging
26+
preconditioner-export
27+
simple-solver-logging)
728

829
if(GINKGO_BUILD_EXTLIB_EXAMPLE)
9-
set(EXAMPLES_LIST "${EXAMPLES_LIST};external-lib-interfacing")
30+
list(APPEND EXAMPLES_LIST external-lib-interfacing)
1031
endif()
1132

1233
foreach(example ${EXAMPLES_LIST})
1334
add_subdirectory(${example})
35+
add_custom_target("run-${example}"
36+
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${example}/${example} > ${CMAKE_CURRENT_BINARY_DIR}/${example}/${example}.out
37+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
38+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${example}/diff-command "#!/bin/bash
39+
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')")
40+
add_custom_target("validate-${example}"
41+
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/${example}/diff-command && ${CMAKE_CURRENT_BINARY_DIR}/${example}/diff-command
42+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
1443
endforeach()
1544

16-
if(GINKGO_RUN_EXAMPLES)
17-
foreach(example ${EXAMPLES_LIST})
18-
add_custom_target("run-${example}"
19-
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${example}/${example} > ${CMAKE_CURRENT_BINARY_DIR}/${example}/${example}.out
20-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
21-
endforeach()
22-
foreach(example ${EXAMPLES_LIST})
23-
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${example}/diff-command "#!/bin/bash
24-
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')")
25-
add_custom_target("validate-${example}"
26-
COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/${example}/diff-command && ${CMAKE_CURRENT_BINARY_DIR}/${example}/diff-command
27-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
28-
endforeach()
29-
add_custom_target(run_all_examples)
30-
add_custom_target(validate_all_examples)
31-
foreach(run_ex ${EXAMPLES_EXEC_LIST})
32-
add_dependencies(run_all_examples "run-${run_ex}")
33-
add_dependencies(validate_all_examples "validate-${run_ex}")
34-
endforeach()
35-
endif()
45+
add_custom_target(run_all_examples)
46+
add_custom_target(validate_all_examples)
47+
foreach(run_ex ${EXAMPLES_EXEC_LIST})
48+
add_dependencies(run_all_examples "run-${run_ex}")
49+
add_dependencies(validate_all_examples "validate-${run_ex}")
50+
endforeach()

examples/custom-logger/custom-logger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ int main(int argc, char *argv[])
232232
gko::HipExecutor::get_num_devices() > 0) {
233233
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create());
234234
} else {
235-
std::cerr << "Usage: executable [executor]" << std::endl;
235+
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
236236
std::exit(-1);
237237
}
238238

examples/custom-stopping-criterion/custom-stopping-criterion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int main(int argc, char *argv[])
155155
gko::HipExecutor::get_num_devices() > 0) {
156156
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
157157
} else {
158-
std::cerr << "Usage: executable [executor]" << std::endl;
158+
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
159159
std::exit(-1);
160160
}
161161

examples/ginkgo-overhead/ginkgo-overhead.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
5555

5656
long unsigned num_iters = 1000000;
5757
if (argc > 2) {
58-
print_usage_and_exit("executable");
58+
print_usage_and_exit(argv[0]);
5959
}
6060
if (argc == 2) {
6161
num_iters = std::atol(argv[1]);

examples/ilu-preconditioned-solver/ilu-preconditioned-solver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
6868
gko::HipExecutor::get_num_devices() > 0) {
6969
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
7070
} else {
71-
std::cerr << "Usage: executable [executor]" << std::endl;
71+
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
7272
std::exit(-1);
7373
}
7474

examples/ir-ilu-preconditioned-solver/ir-ilu-preconditioned-solver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
7070
gko::HipExecutor::get_num_devices() > 0) {
7171
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
7272
} else {
73-
std::cerr << "Usage: executable [executor] [sweeps]" << std::endl;
73+
std::cerr << "Usage: " << argv[0] << " [executor] [sweeps]" << std::endl;
7474
std::exit(-1);
7575
}
7676
unsigned int sweeps = (argc == 3) ? atoi(argv[2]) : 5u;

examples/iterative-refinement/iterative-refinement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
6868
gko::HipExecutor::get_num_devices() > 0) {
6969
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
7070
} else {
71-
std::cerr << "Usage: executable [executor]" << std::endl;
71+
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
7272
std::exit(-1);
7373
}
7474

examples/mixed-precision-ir/mixed-precision-ir.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
7676
gko::HipExecutor::get_num_devices() > 0) {
7777
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
7878
} else {
79-
std::cerr << "Usage: executable [executor]" << std::endl;
79+
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
8080
std::exit(-1);
8181
}
8282

examples/papi-logging/papi-logging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
151151
gko::HipExecutor::get_num_devices() > 0) {
152152
exec = gko::HipExecutor::create(0, gko::OmpExecutor::create(), true);
153153
} else {
154-
std::cerr << "Usage: executable [executor]" << std::endl;
154+
std::cerr << "Usage: " << argv[0] << " [executor]" << std::endl;
155155
std::exit(-1);
156156
}
157157

examples/performance-debugging/performance-debugging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ int main(int argc, char *argv[])
378378
gko::CudaExecutor::get_num_devices() > 0) {
379379
exec = gko::CudaExecutor::create(0, gko::OmpExecutor::create(), true);
380380
} else {
381-
print_usage("executable");
381+
print_usage(argv[0]);
382382
}
383383

384384
// Read the input matrix file directory

0 commit comments

Comments
 (0)