arrayfire / arrayfire-dotnet

.NET wrapper for ArrayFire
BSD 3-Clause "New" or "Revised" License
78 stars 21 forks source link

severe performance issues when calling stats functions, arrayfire 10x slower or more #34

Closed sanikolov closed 2 years ago

sanikolov commented 2 years ago

OS=windows 10 dotnet = net5.0 CPU = i5-4590 GPU = GE Force GTX 1050 Ti, plus the latest NVDIA CUDA runtime and drivers

See the attached F# script. Usage: dotnet fsi /optimize+ /r:ArrayFire.dll /r:MathNet.Numerics.dll compare_algos.fsx Results

BE CPU, parallel true: arrayfire is 88.67 x slower than math.numerics, arrayfire 4431.84 ms vs numerics 49.98 ms
BE CPU, parallel false: arrayfire is 9.48 x slower than math.numerics, arrayfire 1332.35 ms vs numerics 140.47 ms
BE CUDA, parallel true: arrayfire is 97.91 x slower than math.numerics, arrayfire 3888.30 ms vs numerics 39.71 ms
BE CUDA, parallel false: arrayfire is 38.58 x slower than math.numerics, arrayfire 3603.61 ms vs numerics 93.42 ms

I would have expected a GPU algo to outperform the CPU equivalent. See at least 2 references regarding this expectation:

To reproduce rename the attached compare_algos.txt file to compare_algos.fsx and run it as shown above. It won't hurt to download the Math.Numerics.dll from nuget first. This performance issue is probably not related to the .NET bindings. If so please move it to the arrayfire repo.

compare_algos.txt

sanikolov commented 2 years ago

I believe the issue here is that the dimensions of the two arrays are 1. If more dimensions are provided then performance ought to be much better

sanikolov commented 2 years ago

Closing issue because arrayfire (any decent GPU software really) performs better for large sizes, e.g. 200K element arrays rather than the small 1000 element arrays I've provided in the script.