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

Update example_device_radix_sort.cu #1608

Merged
merged 3 commits into from
Apr 12, 2024

Conversation

eriktedhamre
Copy link
Contributor

Description

Updates the Pair::operator< in example_device_radix_sort.cu to treat +0.f and -0.f as equivalent.

closes Issue 1575

Checklist

I assume adding tests is irrelevant due to this being an example. I did test that my solution produces the desired result.

Something to note is that the how to compile example: nvcc -arch=sm_80 example_device_radix_sort.cu -I../.. -lcudart -O3 did not work for me when standing in cccl/cub/examples/device.
But produced: In file included from ../../cub/util_allocator.cuh:36, from example_device_radix_sort.cu:45: ../../cub/config.cuh:36:10: fatal error: cuda/__cccl_config: No such file or directory 36 | #include <cuda/__cccl_config> | ^~~~~~~~~~~~~~~~~~~~ compilation terminated.
I could however run nvcc -arch=sm_80 examples/device/example_device_radix_sort.cu -Iexamples/ -lcudart from cccl/cub.

Copy link

copy-pr-bot bot commented Apr 9, 2024

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Copy link
Collaborator

@alliepiper alliepiper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we can simplify this further to just:

bool operator<(const Pair& b) const
{
  return key < b.key;
}

The default rules for float comparison will give us what we want regarding +/- zeros: https://godbolt.org/z/jds6nWfEh

@alliepiper
Copy link
Collaborator

As for building them, the instructions are likely out of date and we typically just use CMake for everything.

We can make build examples easier by adding some CMake presets and updating the documentation to show how to use them. I've filed a feature request for this, #1617.

@alliepiper
Copy link
Collaborator

/ok to test

Copy link
Collaborator

@alliepiper alliepiper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thanks for the contribution!

@alliepiper alliepiper merged commit c994ff1 into NVIDIA:main Apr 12, 2024
402 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[BUG]:example_device_radix_sort.cu reference solution incorrectly treats -0.f as different from +0.f
2 participants