###### tags: `Intringic` `Unity` # x86専用命令(Avx)でsqrtとrcp(rsqrt)とその他アルゴリズムで計測 ## 計測コード 1. 普通のコード ```csharp! for (int i = 0; i < fb.Length; i++) { fb[i] = Mathf.Sqrt(fa1[i]); } ``` 2. rcp(rsqrt) ```csharp! mm256_rcp_ps(mm256_rsqrt_ps(reg)); ``` 3. rsqrt * self ```csharp! mm256_mul_ps(mm256_rsqrt_ps(reg),reg); ``` 3. fast sqrt ```csharp! float estimate = x; for (int i = 0; i < 5; i++) { estimate = (estimate + (x / estimate)) * 0.5f; } return estimate; //このコードをSIMD化 ``` ## 検証結果(i7 8700) 1位 rcp(rsqrt) score 500くらい 2位 rcp * self score 850くらい 3位 fastSqrt score 2500くらい(繰り返し回数5回) 4位 normal score 20000くらい 大体Latencyで予想できる感じになった。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up