Skip to content

Commit 4c547fd

Browse files
committed
[oneMKL samples][computed tomography] Addressing second round of review comments
1 parent 6c73a33 commit 4c547fd

File tree

3 files changed

+66
-70
lines changed

3 files changed

+66
-70
lines changed

Libraries/oneMKL/computed_tomography/GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ all: run
77
run: computed_tomography
88
./computed_tomography
99

10-
MKL_COPTS = -DMKL_ILP64 -qmkl -qmkl-sycl-impl=dft
10+
MKL_COPTS = -qmkl -qmkl-sycl-impl=dft
1111

1212
DPCPP_OPTS = $(MKL_COPTS) -fsycl-device-code-split=per_kernel
1313

Libraries/oneMKL/computed_tomography/computed_tomography.cpp

Lines changed: 63 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -25,69 +25,6 @@
2525
#define M_PI 3.14159265358979323846
2626
#endif
2727

28-
constexpr int default_p = 400;
29-
constexpr int default_q = 400;
30-
constexpr double default_S_to_D = 1.0;
31-
static const std::string default_original_bmpname = "input.bmp";
32-
static const std::string default_radon_bmpname = "radon.bmp";
33-
static const std::string default_restored_bmpname = "restored.bmp";
34-
static const std::string default_errors_bmpname = "errors.bmp";
35-
constexpr int default_crop = 1;
36-
#ifdef _WIN64
37-
static const std::string program_name = "compute_tomography.exe";
38-
#else
39-
static const std::string program_name = "compute_tomography";
40-
#endif
41-
constexpr double arbitrary_error_threshold = 0.1;
42-
static const std::string usage_info =
43-
"\n\
44-
Usage:\n\
45-
======\n\
46-
" + program_name + " p q in radon_out restored_out S_to_D err_out crop\n\
47-
Inputs:\n\
48-
-------\n\
49-
p - number of projection directions considered for the Radon\n\
50-
transform (number of angles spanning a range of M_PI).\n\
51-
p must be a strictly positive integer (default value is " +
52-
std::to_string(default_p) + ").\n\
53-
q - number of samples of the Radon transform for every\n\
54-
projection direction.\n\
55-
q must be a strictly positive integer (default value is " +
56-
std::to_string(default_q) + ").\n\
57-
in - name of the input image used to generate Radon transform data.\n\
58-
The file must be a 24-bit uncompressed bitmap file.\n\
59-
\"" + default_original_bmpname + "\" is considered by default.\n\
60-
S_to_D - ratio of the scanning width used for sampling the Radon\n\
61-
transform (for any projection direction) to the diagonal of\n\
62-
the input image.\n\
63-
S_to_D must be a floating-point value larger than or equal\n\
64-
to 1.0 (default value is " +
65-
std::to_string(default_S_to_D) + ").\n\
66-
crop - integer flag indicating whether to crop the generated bitmap\n\
67-
output images to their range of relevance or not. Images are\n\
68-
(resp. are not) cropped if the value is 1 (resp. 0).\n\
69-
The supported values are 0 and 1 (default value is "
70-
+ std::to_string(default_crop) + ").\n\
71-
Outputs:\n\
72-
--------\n\
73-
radon_out - name of a 24-bit uncompressed bitmap image file storing a\n\
74-
gray-scaled image representing the generated Radon\n\
75-
transform data points.\n\
76-
\"" + default_radon_bmpname + "\" is used by default.\n\
77-
restored_out - name of a 24-bit uncompressed bitmap image file storing a\n\
78-
gray-scaled image representing the image reconstructed\n\
79-
from the Radon transform data points.\n\
80-
\"" + default_restored_bmpname + "\" is used by default.\n\
81-
err_out - name of a 24-bit uncompressed bitmap image file storing a\n\
82-
gray-scaled image representing the pixel-wise error in the\n\
83-
restored_out file. This file is created only if the mean\n\
84-
global error is found to exceed "
85-
+ std::to_string(100.0*arbitrary_error_threshold) +
86-
"% of the maximum\n\
87-
gray-scale value in the original image.\n\
88-
\"" + default_errors_bmpname + "\" is considered by default.\n\
89-
";
90-
9128
namespace dft_ns = oneapi::mkl::dft;
9229
using real_descriptor_t =
9330
dft_ns::descriptor<dft_ns::precision::DOUBLE, dft_ns::domain::REAL>;
@@ -807,6 +744,65 @@ double compute_errors(padded_matrix& errors,
807744
}
808745

809746
int main(int argc, char **argv) {
747+
constexpr int default_p = 400;
748+
constexpr int default_q = 400;
749+
constexpr double default_S_to_D = 1.0;
750+
constexpr std::string_view default_original_bmpname = "input.bmp";
751+
constexpr std::string_view default_radon_bmpname = "radon.bmp";
752+
constexpr std::string_view default_restored_bmpname = "restored.bmp";
753+
constexpr std::string_view default_errors_bmpname = "errors.bmp";
754+
constexpr int default_crop = 1;
755+
constexpr double arbitrary_error_threshold = 0.1;
756+
/*----------------------- USAGE INFO START --------------------------------*/
757+
const std::string usage_info =
758+
"\n\
759+
Usage:\n\
760+
======\n\
761+
" + std::string(argv[0]) + " p q in radon_out restored_out S_to_D err_out crop\n\
762+
Inputs:\n\
763+
-------\n\
764+
p - number of projection directions considered for the Radon\n\
765+
transform (number of angles spanning a range of M_PI).\n\
766+
p must be a strictly positive integer (default value is " +
767+
std::to_string(default_p) + ").\n\
768+
q - number of samples of the Radon transform for every\n\
769+
projection direction.\n\
770+
q must be a strictly positive integer (default value is " +
771+
std::to_string(default_q) + ").\n\
772+
in - name of the input image used to generate Radon transform data.\n\
773+
The file must be a 24-bit uncompressed bitmap file.\n\
774+
\"" + std::string(default_original_bmpname) + "\" is considered by default.\n\
775+
S_to_D - ratio of the scanning width used for sampling the Radon\n\
776+
transform (for any projection direction) to the diagonal of\n\
777+
the input image.\n\
778+
S_to_D must be a floating-point value larger than or equal\n\
779+
to 1.0 (default value is " +
780+
std::to_string(default_S_to_D) + ").\n\
781+
crop - integer flag indicating whether to crop the generated bitmap\n\
782+
output images to their range of relevance or not. Images are\n\
783+
(resp. are not) cropped if the value is 1 (resp. 0).\n\
784+
The supported values are 0 and 1 (default value is "
785+
+ std::to_string(default_crop) + ").\n\
786+
Outputs:\n\
787+
--------\n\
788+
radon_out - name of a 24-bit uncompressed bitmap image file storing a\n\
789+
gray-scaled image representing the generated Radon\n\
790+
transform data points.\n\
791+
\"" + std::string(default_radon_bmpname) + "\" is used by default.\n\
792+
restored_out - name of a 24-bit uncompressed bitmap image file storing a\n\
793+
gray-scaled image representing the image reconstructed\n\
794+
from the Radon transform data points.\n\
795+
\"" + std::string(default_restored_bmpname) + "\" is used by default.\n\
796+
err_out - name of a 24-bit uncompressed bitmap image file storing a\n\
797+
gray-scaled image representing the pixel-wise error in the\n\
798+
restored_out file. This file is created only if the mean\n\
799+
global error is found to exceed "
800+
+ std::to_string(100.0*arbitrary_error_threshold) +
801+
"% of the maximum\n\
802+
gray-scale value in the original image.\n\
803+
\"" + std::string(default_errors_bmpname) + "\" is considered by default.\n\
804+
";
805+
/*------------------------ USAGE INFO END --------------------------------*/
810806
if (argc > 1 &&
811807
(std::strcmp(argv[1], "-h") == 0 || std::strcmp(argv[1], "-H") == 0)) {
812808
std::cout << usage_info << std::endl;
@@ -817,15 +813,15 @@ int main(int argc, char **argv) {
817813
const int q = argc > 2 ? std::atoi(argv[2]) :
818814
default_q;
819815
const std::string original_bmpname = argc > 3 ? argv[3] :
820-
default_original_bmpname;
816+
std::string(default_original_bmpname);
821817
const std::string radon_bmpname = argc > 4 ? argv[4] :
822-
default_radon_bmpname;
818+
std::string(default_radon_bmpname);
823819
const std::string restored_bmpname = argc > 5 ? argv[5] :
824-
default_restored_bmpname;
820+
std::string(default_restored_bmpname);
825821
const double S_to_D = argc > 6 ? std::atof(argv[6]) :
826822
default_S_to_D;
827823
const std::string errors_bmpname = argc > 7 ? argv[7] :
828-
default_errors_bmpname;
824+
std::string(default_errors_bmpname);
829825
const int crop = argc > 8 ? std::atoi(argv[8]) :
830826
default_crop;
831827
// validate numerical input arguments

Libraries/oneMKL/computed_tomography/makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ run: computed_tomography.exe
1010
DPCPP_OPTS=/I"$(MKLROOT)\include" /Qmkl /Qmkl-sycl-impl=dft /EHsc -fsycl-device-code-split=per_kernel OpenCL.lib
1111

1212
computed_tomography.exe: computed_tomography.cpp
13-
icx-cl -fsycl computed_tomography.cpp /Fecomputed_tomography.exe $(DPCPP_OPTS)
13+
icx-cl -fsycl $< /Fe$@ $(DPCPP_OPTS)
1414

1515
clean:
16-
del /q computed_tomography.exe computed_tomography.exp computed_tomography.lib radon.bmp restored.bmp errors.bmp
16+
del /q /f computed_tomography.exe computed_tomography.exp computed_tomography.lib radon.bmp restored.bmp errors.bmp
1717

1818
pseudo: clean run all

0 commit comments

Comments
 (0)