@@ -4,7 +4,7 @@ open Argu
44open Argu.ArguAttributes
55open Brahma.FSharp
66
7- type Platforms = CPU = 1 | CPUParallel = 2 | NVidia = 3 | IntelGPU = 4 | AnyGPU = 5
7+ type Platforms = CPU = 1 | CPUParallel = 2 | Nvidia = 3 | IntelGPU = 4 | AnyGPU = 5
88
99[<CliPrefix( CliPrefix.DoubleDash) >]
1010[<NoAppSettings>]
@@ -13,7 +13,7 @@ type ImageProcessingArguments =
1313 | Output of string
1414 | Platform of Platforms
1515 | WorkGroupSize of uint
16- | MatrixSize of uint
16+ | Stream of list < Platforms >
1717 with
1818 interface IArgParserTemplate with
1919 member arg.Usage =
@@ -22,7 +22,8 @@ type ImageProcessingArguments =
2222 | Output _ -> " File to store result."
2323 | Platform _ -> " Where to run."
2424 | WorkGroupSize _ -> " Work group size."
25- | MatrixSize _ -> " Number of columns (or rows). We use square matrices."
25+ | Stream _ -> " Folder processing on multiple devices."
26+
2627module Main =
2728 //let pathToExamples = "/home/gsv/Projects/TestProj2020/src/ImgProcessing/Examples"
2829 //let inputFolder = System.IO.Path.Combine(pathToExamples, "input")
@@ -40,32 +41,45 @@ module Main =
4041 let output = results.GetResult( Output, defaultValue = " out.jpg" )
4142 let platform = results.GetResult( Platform, defaultValue = Platforms.CPU)
4243 let workGroupSize = results.GetResult( WorkGroupSize, defaultValue = 64 u)
43- let matrixSize = results.GetResult( MatrixSize , defaultValue = 512 u )
44+ let devicesForStream = results.GetResult( Stream , defaultValue = [] )
4445
4546 let filters = [
47+ ImageProcessing.gaussianBlurKernel
48+ ImageProcessing.gaussianBlurKernel
4649 ImageProcessing.gaussianBlurKernel
4750 ImageProcessing.gaussianBlurKernel
4851 ImageProcessing.edgesKernel
4952 ]
5053
51- (*
52- let applyFiltersOnGPU =
54+
55+ let applyFiltersOnGPU platform =
5356 let device =
5457 match platform with
5558 | Platforms.AnyGPU -> ClDevice.GetFirstAppropriateDevice()
5659 | _ ->
5760 let platform =
5861 match platform with
59- | Platforms.NVidia -> Platform.Nvidia
62+ | Platforms.Nvidia -> Platform.Nvidia
6063 | Platforms.IntelGPU -> Platform.Intel
6164 ClDevice.GetAvailableDevices( platform = platform)
6265 |> Seq.head
6366 printfn $" Device: %A {device.Name}"
6467
65- let context = ClContext( device)
68+ let context = ClContext device
6669 ImageProcessing.applyFiltersGPU context 64
67- *)
6870
71+ match devicesForStream with
72+ | hd :: tl ->
73+ let appliers = List.map applyFiltersOnGPU devicesForStream |> List.map ( fun f -> f filters)
74+ let imagesToProcess =
75+ Streaming.listAllFiles input
76+ |> List.map ( fun file -> Streaming.Img( ImageProcessing.loadAsImage file))
77+ let start = System.DateTime.Now
78+ Streaming.processAllLoadedFiles imagesToProcess appliers
79+ //Streaming.processAllFiles input output appliers
80+ printfn $" TotalTime = %f {(System.DateTime.Now - start).TotalMilliseconds}"
81+
82+ (*
6983 match platform with
7084 | Platforms.CPU ->
7185 let mutable image = ImageProcessing.loadAs2DArray input
@@ -83,7 +97,7 @@ module Main =
8397 image <- ImageProcessing.applyFilterCpuParallel filter image
8498 printfn $"CPU processing time: {(System.DateTime.Now - start).TotalMilliseconds} ms"
8599 ImageProcessing.save2DByteArrayAsImage image output
86-
100+ *)
87101 (* | _ ->
88102 let start = System.DateTime.Now
89103 let grayscaleImage = ImageProcessing.loadAsImage input
0 commit comments