libcudacxx icon indicating copy to clipboard operation
libcudacxx copied to clipboard

Port `std::span` and enable if for C++11 onwards to support mdspan

Open miscco opened this issue 3 years ago • 7 comments

In addition to porting the span implementation from libc++ the PR does the following:

  • Remove outdated support for tuple interface
  • Remove outdated support for const_iterator
  • Change index_type to size_type

I intentionally did not adopt the ranges support, as that is out of scope.

miscco avatar Sep 13 '22 12:09 miscco

Notably, this does not include any of the ranges work. We can only add that once we added ranges support.

miscco avatar Sep 13 '22 12:09 miscco

It seems like there are more changes to the upstream implementation than I'm used to seeing for porting a header for libc++. Could you update the PR description with a summary of what needed to be changed?

Yeah, <span> underwent a ton of last minute changes. If I remember the last 3 standards meetings where quite loaded with changes. That involved:

  • Removing tuple support
  • Removing const_iterator support
  • Changing index_type to size_type
  • Ranges support

I intentionally did not adopt any ranges changes, as we do not have a ranges implementation working yet.

miscco avatar Sep 14 '22 05:09 miscco

Yeah, <span> underwent a ton of last minute changes.

Ah, so this is because our upstream copy of libc++ is a bit old. That makes more sense.

Would it be possible/sane to just checkout the span related files and tests from upstream libc++? Or is that effectively what you did?

jrhemstad avatar Sep 14 '22 14:09 jrhemstad

Yeah, <span> underwent a ton of last minute changes.

Ah, so this is because our upstream copy of libc++ is a bit old. That makes more sense.

Would it be possible/sane to just checkout the span related files and tests from upstream libc++? Or is that effectively what you did?

Yes and no. I went ahead and ported all fixes that apply to us. However, the container interface has changed drastically due to ranges support, so it is not a 100% port.

miscco avatar Sep 14 '22 14:09 miscco

Should we consider keeping a copy of the original libcxx tests in libcxx/test/std/...?

I think it's an important piece of coverage.

wmaxey avatar Sep 14 '22 22:09 wmaxey

Should we consider keeping a copy of the original libcxx tests in libcxx/test/std/...?

I think it's an important piece of coverage.

I did not test the old tests, some of them will definitely fail, like those for the tuple interface.

So I guess we should either remove them or adopt them to the new state of things

miscco avatar Sep 15 '22 06:09 miscco

I did not test the old tests, some of them will definitely fail, like those for the tuple interface. So I guess we should either remove them or adopt them to the new state of things

We could skip interfaces we don't support. 🤔

wmaxey avatar Sep 15 '22 06:09 wmaxey

Need to update include/cuda/std/detail/libcxx/include/version and define __cpp_lib_span. Otherwise, this worked for my mdspan tests. Thanks!

youyu3 avatar Sep 30 '22 18:09 youyu3

Will run tests and merge if no issues occur.

wmaxey avatar Sep 30 '22 20:09 wmaxey

Need to update include/cuda/std/detail/libcxx/include/version and define __cpp_lib_span. Otherwise, this worked for my mdspan tests. Thanks!

Should that be addressed in this PR?

wmaxey avatar Sep 30 '22 20:09 wmaxey

It should.

griwes avatar Sep 30 '22 20:09 griwes