-
Notifications
You must be signed in to change notification settings - Fork 344
[Pre-release] Productize System.Span and ReadOnlySpan #1314
Comments
Issue tracking the work items for Span cc @KrzysztofCwalina, @shiftylogic, @jkotas, @davidfowl, @joshfree |
dotnet/corefx#14533 should be P0. It is a real bug, not just a test issue. |
dotnet/corefx#14376 should be pri 1. I would do it rather than dotnet/corefx#14486. Debugging span code is so painful without this fix. I moved it. |
Also, some of the Future items are probably not actually future, e.g. #1298. But, I would just move the Memory (and friends) issues to a separate location. This issue should track System.Memory.dll APIs only. |
Thanks for organizing this @ahsonkhan. |
Updated. |
Should Span Fill & Clear be moved to extension methods in corefx from operations on Span in coreclr? They don't particularly need access to anything only internal to the struct and then could be specialized with Vectors if that was better. |
@benaadams, can you expand on that? Why would Fill/Clear being extension method allow for use of vectors? |
They could be in corefx and you'd have multiple methods much like public static void Fill(this Span<T> span, T value)
{
// General implementation
}
public static void Fill(this Span<byte> span, byte value)
{
// add handling for non-vector lengths
var vector = new Vector<byte>(value);
ref var dest = ref span.DangerousGetPinnableReference();
var length = span.Length;
for (var offset = 0; offset < length; offset += Vector<byte>.Count)
{
Unsafe.As<byte, Vector<byte>>(ref Unsafe.Add(ref dest, offset)) = vector;
}
}
|
They are in corefx though: https://github.com/dotnet/corefx/blob/master/src/System.Memory/src/System/Span.cs#L234 Does Fill have to be an extension method for it to have byte/other overloads? Also, isn't this always going to be faster than vectorization for the T=byte case? |
They are instance methods on the generic type; so both in coreclr and corefx for fast and slow span respectively. Instance methods always take precedence over extension methods. Also wouldn't make sense to have |
The type specific "optimizations" do not have to be made as overloads, but could be simple Anyway, I think @benaadams has a valid point that making On the other hand there are some drawbacks too. Fast I had the same thoughts when proposing |
Because they are baked into the generic type. For Vector it makes sense as its only a Vector of what the JIT supports. However it allows no scope for user defined overloads for their specific type; e.g.
|
@benadams, regarding a comment you made in another thread related to this:
Are these statements true:
|
(edit) had it wrong before; didn't make method public Yes those statements are true class Program
{
static void Main(string[] args)
{
var value = new MyType<byte>();
value.Output();
}
}
public class MyType<T>
{
public void Output()
{
Console.WriteLine("Generic instance method called");
}
}
public static class MyTypeExtensions
{
public static void Output(this MyType<byte> myType)
{
Console.WriteLine("MyType<byte> Extension method called");
}
} Outputs
|
So it only makes sense to be an instance method over extension method if it gets a benefit from having internal access; which these methods don't need since they use the public method |
@ahsonkhan, we have a similar issue in corefx, don't we? If yes, can you move undone items to corefx and close this issue? |
@ahsonkhan, I am closing this one. I assume all the items are done or moved to corefx. |
Pri 0 - Must complete for release
Pri 1 - Nice to have
Pri 2 - Nice to have
Future - Not part of this release
- [ ] Add a way to efficiently compare memory - https://github.com/dotnet/corefx/issues/16878- [ ] Span == null throws ArgumentNullException - https://github.com/dotnet/corefx/issues/16730- [ ] Span: Add BinarySearch(...) extension methods for ReadOnlySpan (and Span) - https://github.com/dotnet/corefx/issues/15818- [ ] Proposal: Add Sort(...) extension methods for Span - https://github.com/dotnet/corefx/issues/15329- [ ] Slicing pattern (range) - #1306- [ ] Finish design for Memory and friends - #1296This issue tracks System.Memory.dll APIs only- [ ] Design BytesReader - #1297This issue tracks System.Memory.dll APIs only- [ ] Implement Memory final design - #1298This issue tracks System.Memory.dll APIs onlyThe text was updated successfully, but these errors were encountered: