F# performance in scientific computing

前端 未结 10 1182
闹比i
闹比i 2020-12-22 17:12

I am curious as to how F# performance compares to C++ performance? I asked a similar question with regards to Java, and the impression I got was that Java is not suitable f

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-22 17:34

    • F# does floating point computation as fast as the .NET CLR will allow it. Not much difference from C# or other .NET languages.
    • F# does not allow vector instructions by itself, but if your CLR has an API for these, F# should not have problems using it. See for instance Mono.
    • As far as I know, there is only one F# compiler for the moment, so maybe the question should be "how good is the F# compiler when it comes to optimisation?". The answer is in any case "potentially as good as the C# compiler, probably a little bit worse at the moment". Note that F# differs from e.g. C# in its support for inlining at compile time, which potentially allows for more efficient code which rely on generics.
    • Memory foot prints of F# programs are similar to that of other .NET languages. The amount of control you have over allocation and garbage collection is the same as in other .NET languages.
    • I don't know about the support for distributed memory.
    • F# has very nice primitives for dealing with flat data structures, e.g. arrays and lists. Look for instance at the content of the Array module: map, map2, mapi, iter, fold, zip... Arrays are popular in scientific computing, I guess due to their inherently good memory locality properties.
    • For scientific computation packages using F#, you may want to look at what Jon Harrop is doing.

提交回复
热议问题