Repository: NVIDIA/cccl

Issue #4005: [BUG]: vsmem_helper instantiation in c.parallel merge_sort and unique_by_key is inconsistent in host and device code
Created: 2025-03-04T04:23:07Z
Is this a duplicate?

 I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct

Type of Bug
Silent Failure
Component
cuda.parallel (Python)
Describe the bug
The kernels in unique by key and merge sort accept (or should accept) a vsmem helper as a template parameter. Currently in the c.parallel implementations we don't pass this helper to the part of the code that generates the kernel instantiation code.
How to Reproduce
N/A
Expected behavior
N/A
Reproduction link
No response
Operating System
No response
nvidia-smi output
No response
NVCC version
No response

Duplicate issue #4240: [BUG]: cccl.c merge_sort with custom types falis for larger inputs
Created: 2025-03-23T16:17:16Z
Is this a duplicate?

 I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct

Type of Bug
Silent Failure
Component
cuda.parallel (Python)
Describe the bug
For larger inputs, merge_sort fails with custom types as input. This happens at the cccl.c layer, but can also be reproduced from Python.
How to Reproduce
With the following diff:
diff --git a/c/parallel/test/test_merge_sort.cpp b/c/parallel/test/test_merge_sort.cpp
index d4118c4af..316c4f531 100644
--- a/c/parallel/test/test_merge_sort.cpp
+++ b/c/parallel/test/test_merge_sort.cpp
@@ -173,7 +173,7 @@ struct item_pair

 TEST_CASE("DeviceMergeSort:SortPairsCopy works with custom types", "[merge_sort]")
 {
-  const size_t num_items = GENERATE_COPY(take(2, random(1, 10)), values({5, 100, 200}));
+  const size_t num_items = GENERATE_COPY(take(2, random(1, 10)), values({5, 100, 1000}));
   operation_t op         = make_operation(
     "op",

I see the following unit test failure:
$ ./bin/cccl.c.parallel.test.merge_sort.cpp &| tee test.log
Randomness seeded to: 1435427281

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cccl.c.parallel.test.merge_sort.cpp is a Catch2 v3.8.0 host application.
Run with -? for options

-------------------------------------------------------------------------------
DeviceMergeSort:SortPairsCopy works with custom types
-------------------------------------------------------------------------------
workspace/cccl/c/parallel/test/test_merge_sort.cpp:174
...............................................................................

workspace/cccl/c/parallel/test/test_merge_sort.cpp:208: FAILED:
  REQUIRE( std::equal( expected_keys.begin(), expected_keys.end(), std::vector<key_pair>(output_keys_it).
begin(), [](const key_pair& lhs, const key_pair& rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; }) )
with expansion:
  false

===============================================================================
test cases:   19 |   18 passed | 1 failed
assertions: 2193 | 2192 passed | 1 failed

Expected behavior
This unit test should not fail for larger inputs.
Reproduction link
No response
Operating System
No response
nvidia-smi output
No response
NVCC version
No response

Closing comment (2025-03-23T16:18:40Z): Perhaps this could be related to #4005, @NaderAlAwar? Just a wild guess