-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easy multiplatform support #23
Comments
"At run-time the JIT will replace them with SSE2 or their analogues on ARM, depending on which architecture the app is running on." Would love to see where you read this :) The thing is i don't have a macbook or any arm related hardware. So it's really hard to test. |
Don't need to read it, I've tried it myself on sharplab.io. Click on the link below to see it yourself. On your left-hand side is the c# code. On your right-hand side is the JIT-ted code. You can see that the code generated by the JIT compiler is identical. By the way, there is a nice VS plugin called |
By the way, M1 results for the Get benchmark is about the same as yours - "7.5 ms" (on a Macbook Air, without a fan) which is pretty impressive Updated: ARM cpus are getting stronger and stronger |
If you are really interested to see the code where the JIT emits the instructions you can take a look in these two files Search for |
These are the default implementations of the methods. |
FYI, just made my brother run the DenseMapSIMD tests, and all 26 of them have passed successfully on his Macbook Air M1. This is after replacing the Sse2 intrinsics with the platform independent ones. However 6 |
Ill take a look mate :) |
not really sure why they are failing, they seem to work on my intel cpu |
Sorry about that ... the failing tests are for FastMap [TestMethod]
public void AssertCustomEnumerators()
{
var map = new FastMap<uint, uint>();
map.Emplace(202, 202); //13
map.Emplace(131, 131); //15
map.Emplace(597, 597); //15
map.Emplace(681, 681); //14
map.Emplace(893, 893); //14
map.Emplace(516, 516); //14
var count = 0;
var count2 = 0;
foreach (uint unused in map.Keys)
{
count++;
}
Assert.IsTrue(count == 6);
foreach (uint unused in map.Values)
{
count2++;
}
Assert.IsTrue(count2 == 6);
} It fails on |
Should probably add a deprecated attribute. I like my robinhood hashmap implementation thats the only reason its still in here. |
Did you manage to reproduce it on your machine? |
yea thnx |
Here's a sample run of GetBenchmark under M1 using "VisualStudio for Mac". The results of FastMap are debatable, considering that 6 of its tests are failing BenchmarkDotNet=v0.13.1, OS=macOS 13.2.1 (22D68) [Darwin 22.3.0] InvocationCount=128 IterationCount=50 LaunchCount=1
|
Actually was looking for something like this: dotnet/runtime#49397 Anyhow, if you like you can submit a pull request :) |
Done |
Hey,
I have noticed that we can easily address this issue. Currently we only use two x86 SSE2 instructions -
Sse2.CompareEqual
andSse2.MoveMask
. Those two can be easily replaced with platform independent equivalents - the static methodVector128.Equal
and the extension methodVector128.ExtractMostSignificantBits
.At run-time the JIT will replace them with SSE2 or their analogues on ARM, depending on which architecture the app is running on.
So basically code like this
Faster.Map/src/DenseMapSIMD.cs
Lines 231 to 235 in 7e1fb1e
can be changed to
I've tried and replaced the SSE2 calls with
Vector128.Equal
andVector128.ExtractMostSignificantBits
and it started working on my brother's Macbook Air with M1 processor without x86 emulation.To make it work, we also need to change this check
Faster.Map/src/DenseMapSIMD.cs
Lines 153 to 156 in 7e1fb1e
to
Isn't that cool or what?
The text was updated successfully, but these errors were encountered: