Skip to content

Commit d67fde3

Browse files
committed
add QOI io measurements
1 parent 0675d06 commit d67fde3

File tree

3 files changed

+61
-34
lines changed

3 files changed

+61
-34
lines changed

examples/image_filtering/src/host/exporter/exporter.adb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ package body Exporter is
8383
QOI.Encode (Data.all, Desc, Output.all, Output_Size);
8484

8585
if Output_Size /= 0 then
86-
Put_Line ("DUMP_QOI : " & abs_filename);
86+
Put_Line ("Dumping QOI ... : " & abs_filename);
8787
Write_To_File (abs_filename, Output.all, Output_Size);
8888
else
89-
Put_Line ("DUMP_QOI : Encode failed");
89+
Put_Line ("Dumping QOI : Encode failed");
9090
GNAT.OS_Lib.OS_Exit (1);
9191
end if;
9292
end;

examples/image_filtering/src/host/importer/importer.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ package body Importer is
6565

6666
begin
6767

68-
Aio.Put_Line ("LOAD_QOI : " & Abs_Filename);
68+
Aio.Put_Line ("Loading QOI ... : " & Abs_Filename);
6969

7070
Fd := GNAT.OS_Lib.Open_Read (Abs_Filename, Binary);
7171

examples/image_filtering/src/host/main.adb

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -60,40 +60,67 @@ procedure Main is
6060

6161
procedure Free is new Ada.Unchecked_Deallocation (G.Image, G.Image_Access);
6262

63-
begin
63+
procedure Read_Cmd_Parameters is
64+
begin
65+
GLP.Parse_Command_Line (Parameters => Descriptors, Result => Param);
66+
end;
67+
68+
procedure Load_QOI_image is
69+
begin
70+
Start_Time := Clock;
71+
Original_Img := Importer.Load_QOI (+Param.Input_Image);
72+
Elapsed_Time := Clock - Start_Time;
73+
AIO.Put_Line ("Load QOI image time: " & Duration'Image (To_Duration (Elapsed_Time)) & " seconds");
74+
Filtered_Img := new G.Image (1 .. Original_Img'Length (1), 1 .. Original_Img'Length (2));
75+
end;
76+
77+
procedure Filter_Image is
78+
begin
79+
Start_Time := Clock;
80+
81+
case Param.Device is
82+
when P.Cpu =>
83+
BH.Bilateral_Cpu (Host_Img => Original_Img.all,
84+
Host_Filtered_Img => Filtered_Img.all,
85+
Width => Original_Img'Length (1),
86+
Height => Original_Img'Length (2),
87+
Spatial_Stdev => Param.Spatial_Stdev,
88+
Color_Dist_Stdev => Param.Color_Dist_Stdev);
89+
when P.Gpu =>
90+
BH.Bilateral_CUDA (Host_Img => Original_Img.all,
91+
Host_Filtered_Img => Filtered_Img.all,
92+
Width => Original_Img'Length (1),
93+
Height => Original_Img'Length (2),
94+
Spatial_Stdev => Param.Spatial_Stdev,
95+
Color_Dist_Stdev => Param.Color_Dist_Stdev);
96+
end case;
97+
98+
Elapsed_Time := Clock - Start_Time;
99+
AIO.Put_Line ("Filtering time (" & Param.Device'Image & "): " & Duration'Image (To_Duration (Elapsed_Time)) & " seconds");
100+
end;
101+
102+
procedure Dump_QOI_image is
103+
begin
104+
Start_Time := Clock;
105+
Exporter.Dump_QOI (+Param.Output_Image, Filtered_Img);
106+
Elapsed_Time := Clock - Start_Time;
107+
AIO.Put_Line ("Dump QOI image time: " & Duration'Image (To_Duration (Elapsed_Time)) & " seconds");
108+
end;
109+
110+
procedure Free_Ressources is
111+
begin
112+
Free (Original_Img);
113+
Free (Filtered_Img);
114+
end;
64115

65-
GLP.Parse_Command_Line (Parameters => Descriptors, Result => Param);
66-
Original_Img := Importer.Load_QOI (+Param.Input_Image);
67-
Filtered_Img := new G.Image (1 .. Original_Img'Length (1), 1 .. Original_Img'Length (2));
68-
69-
Start_Time := Clock;
70-
71-
case Param.Device is
72-
when P.Cpu =>
73-
BH.Bilateral_Cpu (Host_Img => Original_Img.all,
74-
Host_Filtered_Img => Filtered_Img.all,
75-
Width => Original_Img'Length (1),
76-
Height => Original_Img'Length (2),
77-
Spatial_Stdev => Param.Spatial_Stdev,
78-
Color_Dist_Stdev => Param.Color_Dist_Stdev);
79-
when P.Gpu =>
80-
BH.Bilateral_CUDA (Host_Img => Original_Img.all,
81-
Host_Filtered_Img => Filtered_Img.all,
82-
Width => Original_Img'Length (1),
83-
Height => Original_Img'Length (2),
84-
Spatial_Stdev => Param.Spatial_Stdev,
85-
Color_Dist_Stdev => Param.Color_Dist_Stdev);
86-
end case;
87-
88-
Elapsed_Time := Clock - Start_Time;
89-
AIO.Put_Line ("Filtering time (" & Param.Device'Image & "): " & Duration'Image (To_Duration (Elapsed_Time)) & " seconds");
90-
91-
Exporter.Dump_QOI (+Param.Output_Image, Filtered_Img);
116+
begin
92117

118+
Read_Cmd_Parameters;
119+
Load_QOI_image;
120+
Filter_Image;
121+
Dump_QOI_image;
93122
AIO.Put_Line ("Result found in " & Param.Output_Image'Image);
94-
95-
Free (Original_Img);
96-
Free (Filtered_Img);
123+
Free_Ressources;
97124

98125
exception
99126
when Msg : GLP.Bad_Command =>

0 commit comments

Comments
 (0)