Closed sergey-tihon closed 7 years ago
In order to fix System.DllNotFoundException: opencl.dll
the OpenCL.Net.dll.config
should exist near exe
file with the following content, this actually allows map dll reference to macOS implementation.
<configuration>
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
</configuration>
The current OpenCL
platform name is Apple
on macOS.
So, the following code
let (platforms, error) = OpenCL.Net.Cl.GetPlatformIDs()
for pl in platforms do
let (_,paramSize) = OpenCL.Net.Cl.GetPlatformInfo(pl, PlatformInfo.Name, System.IntPtr.Zero, InfoBuffer.Empty)
use buffer = new InfoBuffer(paramSize)
Cl.GetPlatformInfo(pl, PlatformInfo.Name, paramSize, buffer) |> ignore
printfn "Platform=%A" (buffer)
let provider = ComputeProvider.Create()//("Apple", DeviceType.Default)
for d in provider.Devices do
let getInfo (pName:DeviceInfo)=
let (_,paramSize) = Cl.GetDeviceInfo(d, pName, System.IntPtr.Zero, InfoBuffer.Empty)
use buffer = new InfoBuffer(paramSize)
Cl.GetDeviceInfo(d, pName, paramSize, buffer) |> ignore
buffer.ToString()
printfn "Device=[Name=%s;\tDriverVersion=%A]"
(getInfo DeviceInfo.Name)
((getInfo DeviceInfo.DriverVersion))
prints
Platform=Apple Device=[Name=Intel(R) HD Graphics 530; DriverVersion="1.2(Apr 22 2017 16:00:49)"] Device=[Name=AMD Radeon Pro 460 Compute Engine; DriverVersion="1.2 (Apr 27 2017 22:10:57)"]
Static ctor
of Brahma.Helpers.Timer<TMarker>
do P/Invoke calls to Kernel32.dll, so this Timer cannot be used on macOS and lines (like below) should be commented
Timer<string>.Global.Start()
...
Timer<string>.Global.Lap("OpenCL")
When I commented all calls to Timer<string>.Global
I see the different error:
(Brahma cannot compile command Expr to OpenCL kernel)
Multiplying two 200x200 matrices 10 times using .NET...
done.
Multiplying two 200x200 matrices 10 times using OpenCL and selected platform/device : [Platform: Apple, device type:Gpu]
[Platform: Apple, device type:Gpu]
...
Unhandled Exception:
System.Exception:
at Brahma.FSharp.OpenCL.Core.ComputeProvider.CompileQuery[T] (Brahma.OpenCL.ComputeProvider this, Microsoft.FSharp.Quotations.FSharpExpr lambda, System.Collections.Generic.IEnume
rable`1[T] translatorOptions, Microsoft.FSharp.Collections.FSharpList`1[T] additionalSources) [0x00153] in <594a167316e8481da745038373164a59>:0
at Brahma.FSharp.OpenCL.Core.ComputeProvider.Compile[TRange,a] (Brahma.OpenCL.ComputeProvider this, Microsoft.FSharp.Quotations.FSharpExpr`1[T] query, Microsoft.FSharp.Core.FShar
pOption`1[T] _options, Microsoft.FSharp.Core.FSharpOption`1[T] translatorOptions, Microsoft.FSharp.Core.FSharpOption`1[T] _outCode, Microsoft.FSharp.Core.FSharpOption`1[T] kernelNa
me, Microsoft.FSharp.Core.FSharpOption`1[T] _additionalSources) [0x0002d] in <594a167316e8481da745038373164a59>:0
at BrahmaTest.Main (System.String platformName, System.Single[] m1, System.Single[] m2) [0x00219] in <595a6f50d4251104a7450383506f5a59>:0
at BrahmaTest.main (System.String[] argv) [0x001d3] in <595a6f50d4251104a7450383506f5a59>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception:
at Brahma.FSharp.OpenCL.Core.ComputeProvider.CompileQuery[T] (Brahma.OpenCL.ComputeProvider this, Microsoft.FSharp.Quotations.FSharpExpr lambda, System.Collections.Generic.IEnume
rable`1[T] translatorOptions, Microsoft.FSharp.Collections.FSharpList`1[T] additionalSources) [0x00153] in <594a167316e8481da745038373164a59>:0
at Brahma.FSharp.OpenCL.Core.ComputeProvider.Compile[TRange,a] (Brahma.OpenCL.ComputeProvider this, Microsoft.FSharp.Quotations.FSharpExpr`1[T] query, Microsoft.FSharp.Core.FShar
pOption`1[T] _options, Microsoft.FSharp.Core.FSharpOption`1[T] translatorOptions, Microsoft.FSharp.Core.FSharpOption`1[T] _outCode, Microsoft.FSharp.Core.FSharpOption`1[T] kernelNa
me, Microsoft.FSharp.Core.FSharpOption`1[T] _additionalSources) [0x0002d] in <594a167316e8481da745038373164a59>:0
at BrahmaTest.Main (System.String platformName, System.Single[] m1, System.Single[] m2) [0x00219] in <595a6f50d4251104a7450383506f5a59>:0
at BrahmaTest.main (System.String[] argv) [0x001d3] in <595a6f50d4251104a7450383506f5a59>:0
Note: This is strange that stack trace does not have line numbers (:0
all the time), this makes troubleshooting more complicated. I guess that it could be fixed if you ship pdb
files together with dll
s inside NuGet
package.
Error message after executing new sample on macOS
using Brahma.FSharp v1.1.2
Multiplying two 300x300 matrices 10 times using .NET...
done.
Multiplying two 300x300 matrices 10 times using OpenCL and selected platform/device : [Platform: Apple, device type:Gpu]
[Platform: Apple, device type:Gpu]
...
Unhandled Exception:
System.Exception:
Error code: InvalidBuildOptions
at Brahma.FSharp.OpenCL.Core+getProgramProcessingError@42TT[a,b].Invoke (a errCode, OpenCL.Net.Program program) [0x000c4] in <595cbbd516e8481da7450383d5bb5c59>:0
at Microsoft.FSharp.Core.FSharpFunc`2[T,TResult].InvokeFast[V] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] func, T arg1, TResult arg2) [0x0000d] in <5939249c904cf4daa74503839c243959>:0
at Brahma.FSharp.OpenCL.Core.ComputeProvider.CompileQuery[T] (Brahma.OpenCL.ComputeProvider this, Microsoft.FSharp.Quotations.FSharpExpr lambda, System.Collections.Generic.IEnumerable`1[T] translatorOptions, Microsoft.FSharp.Collections.FSharpList`1[T] additionalSources) [0x0010e] in <595cbbd516e8481da7450383d5bb5c59>:0
at Brahma.FSharp.OpenCL.Core.ComputeProvider.Compile[TRange,a] (Brahma.OpenCL.ComputeProvider this, Microsoft.FSharp.Quotations.FSharpExpr`1[T] query, Microsoft.FSharp.Core.FSharpOption`1[T] _options, Microsoft.FSharp.Core.FSharpOption`1[T] translatorOptions, Microsoft.FSharp.Core.FSharpOption`1[T] _outCode, Microsoft.FSharp.Core.FSharpOption`1[T] kernelName, Microsoft.FSharp.Core.FSharpOption`1[T] _additionalSources) [0x0002d] in <595cbbd516e8481da7450383d5bb5c59>:0
at BrahmaTest.Main (System.String platformName, System.Int32 mSize) [0x0022d] in <596b094ed4251104a74503834e096b59>:0
at BrahmaTest.main (System.String[] argv) [0x0000d] in <596b094ed4251104a74503834e096b59>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception:
Error code: InvalidBuildOptions
at Brahma.FSharp.OpenCL.Core+getProgramProcessingError@42TT[a,b].Invoke (a errCode, OpenCL.Net.Program program) [0x000c4] in <595cbbd516e8481da7450383d5bb5c59>:0
at Microsoft.FSharp.Core.FSharpFunc`2[T,TResult].InvokeFast[V] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] func, T arg1, TResult arg2) [0x0000d] in <5939249c904cf4daa74503839c243959>:0
at Brahma.FSharp.OpenCL.Core.ComputeProvider.CompileQuery[T] (Brahma.OpenCL.ComputeProvider this, Microsoft.FSharp.Quotations.FSharpExpr lambda, System.Collections.Generic.IEnumerable`1[T] translatorOptions, Microsoft.FSharp.Collections.FSharpList`1[T] additionalSources) [0x0010e] in <595cbbd516e8481da7450383d5bb5c59>:0
at Brahma.FSharp.OpenCL.Core.ComputeProvider.Compile[TRange,a] (Brahma.OpenCL.ComputeProvider this, Microsoft.FSharp.Quotations.FSharpExpr`1[T] query, Microsoft.FSharp.Core.FSharpOption`1[T] _options, Microsoft.FSharp.Core.FSharpOption`1[T] translatorOptions, Microsoft.FSharp.Core.FSharpOption`1[T] _outCode, Microsoft.FSharp.Core.FSharpOption`1[T] kernelName, Microsoft.FSharp.Core.FSharpOption`1[T] _additionalSources) [0x0002d] in <595cbbd516e8481da7450383d5bb5c59>:0
at BrahmaTest.Main (System.String platformName, System.Int32 mSize) [0x0022d] in <596b094ed4251104a74503834e096b59>:0
at BrahmaTest.main (System.String[] argv) [0x0000d] in <596b094ed4251104a74503834e096b59>:0
@sergey-tihon Thanks for additional informatuion. Seems, that it was a problem with extra spaces in compiler options. Fixed in Brahma.FSharp v1.1.3.
Woohoo !!! Thank you for help @gsvgit .
Brahma.FSharp
works on macOS
now!!!
Description
Is possible to use
Brahma.FSharp
on macOS / Mono 5+?Repro steps
Actual behavior
The error that I see (this probably could be more informative)
Additional info
I did try to print platform details before execution of
Main
method.I this case I see the following error
Related information