Skip to content
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

GH-40252: [C++] Make span SFINAE standards-conforming to enable compilation with nvcc #40253

Merged
merged 7 commits into from
Mar 13, 2024

Conversation

vyasr
Copy link
Contributor

@vyasr vyasr commented Feb 26, 2024

Rationale for this change

The current code uses an incomplete type in a SFINAE construct.

Closes #40252

What changes are included in this PR?

This PR changes the way that the type is specified to avoid any UB.

Are these changes tested?

I tested locally that code that originally failed to compile with nvcc now compiles successfully. The same code also compiles under clang and gcc. This is a minimal reproducer:

#include <arrow/api.h>
#include <vector>

int main() {
  arrow::util::span<int> x{std::vector<int>{1, 2, 3}};
}

I did not include it here because it is a compile-time rather than runtime issue, and because at present it only manifests on nvcc.

Are there any user-facing changes?

No.

Copy link

⚠️ GitHub issue #40252 has been automatically assigned in GitHub to PR creator.

@vyasr
Copy link
Contributor Author

vyasr commented Feb 26, 2024

I should say that I've tested this with both CUDA 11.8 and CUDA 12.0.

It looks like there are some additional cases that the proposed fix doesn't support according to the current tests, though. I'll have to dig into those cases further.

cpp/src/arrow/util/span.h Outdated Show resolved Hide resolved
@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Feb 27, 2024
@felipecrv
Copy link
Contributor

CI builds are complaining.

@vyasr
Copy link
Contributor Author

vyasr commented Feb 27, 2024

CI builds are complaining.

Yes, apologies, that's what I was referring to in my previous comment. It looks like a different construct is needed here, and I need to play with the various cases a bit more.

@vyasr
Copy link
Contributor Author

vyasr commented Mar 9, 2024

@felipecrv @pitrou thanks for your patience. I have something that is working now (still waiting to see if it has any issues on the Windows builds in CI, but I've tested various compilers on Linux and they're happy so I'm hopeful). It's a bit more verbose than the old construct, but equally readable.

@pitrou
Copy link
Member

pitrou commented Mar 9, 2024

@github-actions crossbow submit -g cpp

Copy link

github-actions bot commented Mar 9, 2024

Revision: 729bdc4

Submitted crossbow builds: ursacomputing/crossbow @ actions-ea9fb86209

Task Status
test-alpine-linux-cpp GitHub Actions
test-build-cpp-fuzz GitHub Actions
test-conda-cpp GitHub Actions
test-conda-cpp-valgrind Azure
test-cuda-cpp GitHub Actions
test-debian-11-cpp-amd64 GitHub Actions
test-debian-11-cpp-i386 GitHub Actions
test-fedora-39-cpp GitHub Actions
test-ubuntu-20.04-cpp GitHub Actions
test-ubuntu-20.04-cpp-bundled GitHub Actions
test-ubuntu-20.04-cpp-minimal-with-formats GitHub Actions
test-ubuntu-20.04-cpp-thread-sanitizer GitHub Actions
test-ubuntu-22.04-cpp GitHub Actions
test-ubuntu-22.04-cpp-20 GitHub Actions
test-ubuntu-22.04-cpp-no-threading GitHub Actions
test-ubuntu-24.04-cpp GitHub Actions
test-ubuntu-24.04-cpp-gcc-14 GitHub Actions

cpp/src/arrow/util/span_test.cc Show resolved Hide resolved
cpp/src/arrow/util/span.h Show resolved Hide resolved
@pitrou
Copy link
Member

pitrou commented Mar 13, 2024

Thanks! The AppVeyor is unexpected but also seems unrelated. I'll merge.

@pitrou pitrou merged commit ed19a92 into apache:main Mar 13, 2024
35 of 36 checks passed
@pitrou pitrou removed the awaiting committer review Awaiting committer review label Mar 13, 2024
@pitrou
Copy link
Member

pitrou commented Mar 13, 2024

@raulcd This is a possible candidate for 15.0.2, but not critical.

@bdice
Copy link

bdice commented Mar 13, 2024

Thanks all! This would be nice to get in 15.0.2 if possible. It blocks RAPIDS updating Arrow from 14 to 15. Not super high priority - so it's fine if it slips to a later patch release or a near-term major release - but it would be nice to keep up with the latest Arrow major version.

raulcd pushed a commit that referenced this pull request Mar 13, 2024
…lation with nvcc (#40253)

### Rationale for this change

The current code uses an incomplete type in a SFINAE construct.

Closes #40252 

### What changes are included in this PR?

This PR changes the way that the type is specified to avoid any UB.

### Are these changes tested?

I tested locally that code that originally failed to compile with nvcc now compiles successfully. The same code also compiles under clang and gcc. This is a minimal reproducer:
```
#include <arrow/api.h>
#include <vector>

int main() {
  arrow::util::span<int> x{std::vector<int>{1, 2, 3}};
}
```

I did not include it here because it is a compile-time rather than runtime issue, and because at present it only manifests on nvcc.

### Are there any user-facing changes?

No.

* GitHub Issue: #40252

Authored-by: Vyas Ramasubramani <vyasr@nvidia.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
@raulcd
Copy link
Member

raulcd commented Mar 13, 2024

I have created a new Release Candidate to include this issue so we can unblock RAPIDS.

Copy link

After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit ed19a92.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 3 possible false positives for unstable benchmarks that are known to sometimes produce them.

@vyasr vyasr deleted the fix/span_sfinae branch March 13, 2024 22:45
@vyasr
Copy link
Contributor Author

vyasr commented Mar 13, 2024

Thank you for pushing on the patch release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[C++] Span implementation includes non-conformant SFINAE
5 participants