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

Add first batch of Catch2 tests for DeviceRadixSort #1164

Merged
merged 17 commits into from
Dec 6, 2023

Conversation

alliepiper
Copy link
Collaborator

Description

This is part of #86.

This adds basic testing. A future PR will include tests for segmented sort and large inputs (>2^32 items), at which point the old radix sort tests can be removed.

Copy link
Collaborator

@gevtushenko gevtushenko left a comment

Choose a reason for hiding this comment

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

CI hasn't started, you might need to rebase on main to incorporate recent CI fixes.

cub/test/c2h/utility.cuh Outdated Show resolved Hide resolved
cub/test/catch2_sort_helper.cuh Outdated Show resolved Hide resolved
cub/test/catch2_sort_helper.cuh Outdated Show resolved Hide resolved
cub/test/catch2_sort_helper.cuh Outdated Show resolved Hide resolved
cub/test/catch2_test_device_radix_sort_keys.cu Outdated Show resolved Hide resolved
Comment on lines 160 to 161
const int begin_bit = GENERATE_COPY(0, 1, num_bits / 3, 3 * num_bits / 4, num_bits);
const int end_bit = GENERATE_COPY(0, 1, num_bits / 3, 3 * num_bits / 4, num_bits);
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: same motivation as with num_items:

Suggested change
const int begin_bit = GENERATE_COPY(0, 1, num_bits / 3, 3 * num_bits / 4, num_bits);
const int end_bit = GENERATE_COPY(0, 1, num_bits / 3, 3 * num_bits / 4, num_bits);
const int begin_bit = GENERATE_COPY(take(2, random(0, num_bits)));
const int end_bit = GENERATE_COPY(take(2, random(begin_bit, num_bits)));

Copy link
Collaborator Author

@alliepiper alliepiper Dec 4, 2023

Choose a reason for hiding this comment

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

This is generating cases where end_bit < begin_bit, likely due to Catch2 generator lifetime issues -- it doesn't seem to be updating the generator expressions as expected, even with GENERATE_COPY. I don't think Catch2 expects the values of the captured variables to be changed dynamically like this.

I'll leave this as is for now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@allisonvacanti I was not able to reproduce this:

#define CATCH_CONFIG_MAIN

#include <catch2/catch.hpp>

TEST_CASE("Test", "[test]") {
  const int num_bits = 64;
  const int dummy = GENERATE_COPY(range(0, num_bits));
  const int begin_bit = GENERATE_COPY(take(300, random(0, num_bits)));
  const int end_bit = GENERATE_COPY(take(300, random(begin_bit, num_bits)));

  if (end_bit < begin_bit) {
    INFO("begin_bit = " << begin_bit);
    INFO("end_bit = " << end_bit);
    FAIL("end_bit < begin_bit");
  }
}

Do you have a reproducer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IIRC I was using something like this:

  const int begin_bit = GENERATE_COPY(take(2, random(0, num_bits)));
  const int end_bit = GENERATE_COPY(begin_bit, take(2, random(begin_bit, num_bits)));

to make sure that we'd always cover the begin_bit == end_bit edgecase.

cub/test/catch2_test_device_radix_sort_keys.cu Outdated Show resolved Hide resolved
cub/test/test_device_radix_sort.cu Show resolved Hide resolved
@alliepiper alliepiper merged commit a59bf20 into NVIDIA:main Dec 6, 2023
516 checks passed
@alliepiper alliepiper deleted the catch2-device-radix-sort branch December 6, 2023 14:07
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.

None yet

2 participants