Adding span tests to improve coverage#17472
Conversation
|
@dotnet-bot test code coverage please |
|
Questions:
|
|
@dotnet-bot test Innerloop OSX10.12 Debug x64 Build and Test please |
Use #if instead and use readonly static instead of #if DEBUG
readonly static bool IsHardwareAccelerated = false;
#else
readonly static bool IsHardwareAccelerated = Vector.IsHardwareAccelerated;
#end
Input is multiple of Vector length without match |
I do not want to change the source. I am wondering if there is a change on the test infra side that would test this branch. Do we run CI on machines where this is false? |
I tried that with the following test, but I don't hit that branch: |
|
Might be alignment adjustment as the array is allocated each time and will move in memory. Allocate an fixed array then for loop down it to move the alignment? e.g. something like byte[] array = new byte[4 * Vector<byte>.Count];
for (var i = 0; i < array.Length - Vector<byte>.Count; i++)
{
var span = new Span<byte>(array, i, Vector<byte>.Count);
int idx = span.IndexOf((byte)'1');
Assert.Equal(-1, idx);
} |
This doesn't hit it either. Also, in your example code, the span length is always Vector.Count which means you always drop down to SequentialScan (i.e., this is false): I tried the following and still byte[] array = new byte[6 * Vector<byte>.Count];
for (var i = 0; i < array.Length - 3* Vector<byte>.Count; i++)
{
var span = new Span<byte>(array, i, 3* Vector<byte>.Count);
int idx = span.IndexOf((byte)'1');
Assert.Equal(-1, idx);
} |
|
@dotnet-bot test code coverage please |
|
:( |
|
@benaadams, is this unnecessary/dead code then? @shiftylogic, does this PR look good? |
|
Would suggest an unnecessary jump back; might need to be |
|
You can disable vectorization by setting You can force a shorter vector lengths (assuming you normally run on AVX capable HW) via Both of these are available in release builds, I believe. |
@AndyAyersMS, thanks :) |
|
@dotnet-bot test code coverage please |
@benaadams, I submit a PR with changes to the IndexOf worker method, please take a look: #17500 |
|
It's an environment setting. It needs to be determined when the CLR initializes, before any jitting happens, since it alters the way SIMD types are handled. You can't set this from C# code. |
So how can we add this to CI? |
|
@dotnet-bot test Innerloop Windows_NT Debug x86 Build and Test please |
|
There might be some sort of customizable environment setup that you could leverage to get the right settings in place before running tests. CoreCLR's CI has this for things like jit stress and gc stress. |
Who would be the right person to talk to about making this change? @crummel |
|
@shiftylogic, good to go? |
|
👍 |
|
Fixes part of dotnet/corefxlab#1314 |

Fixes #17078
Adding tests for:
Gets us much closer to 100% test coverage (for slow span at least), esp if you include outer-loop and 32-bit tests.