Repository navigation
Conversation
- adds __fp64_to_ordered_int helper that uses a selection form to convert the bit pattern to int64 with the same ordering as fp64 - adds double overloads for isgreater, isless, isgreaterequal, islessequal and islessgreater - uses _CCCL_DISPATCH_SLOW_FP64_TARGET to dispatch between "slow" and "fast" fp64 arithmetic targets
quite -> quiet in min_max.h
- adds __fp64_to_total_order_int helper that maps the bit pattern to int64 in IEEE totalOrder (-0 < +0) - adds branch-free __fp64_fmax_fmin_int helper that matches the hardware result bitwise (NaN handling, quiet bit) - uses _CCCL_DISPATCH_SLOW_FP64_TARGET in fmax and fmin to dispatch to the integer path for double
- tests for fmin/fmax and the comparison functions isless, islessequal, isgreater, isgreaterequal, islessgreater
…argets the generic fallback (x < y ? y : x) returns either zero for ±0, while the integer path on slow targets orders -0 < +0
miscco
left a comment
There was a problem hiding this comment.
LGTM but I want @fbusato or @davebayer to weigh in too
|
Ready for review |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Double comparison predicates libcudacxx/include/cuda/std/__cmath/traits.h, libcudacxx/test/libcudacxx/std/numerics/c.math/fp_traits.pass.cpp, libcudacxx/benchmarks/bench/comparison/basic.cu |
Adds ordered-integer implementations for five double comparison predicates on slow-FP64 targets. Tests cover signed zeros, NaNs, infinities, denormals, limits, and mixed arguments. Adds benchmarks for the predicates. |
Double min/max functions libcudacxx/include/cuda/std/__cmath/min_max.h, libcudacxx/test/libcudacxx/std/numerics/c.math/fp_min_max.pass.cpp, libcudacxx/benchmarks/bench/fmin_fmax/basic.cu |
Adds integer-based double selection and slow-FP64 dispatch for fmin and fmax. Tests cover signed zeros, NaNs, infinities, denormals, and mixed arguments. Adds benchmarks for both functions. |
Possibly related issues
- [FEA]: Optimize double-precision
<cmath>functionalities with integer path #11894 requests integer paths for double-precision<cmath>functions on slow-FP64 GPUs. This PR adds paths for comparison predicates andfmin/fmax; the issue also names functions not changed here.
Suggested reviewers: fbusato
Change: Refactor
Merge Risk: 
Minimal · previous review 9fa59
-
No merge-blocking behavior was identified; the change is ready for normal checks.
|
/ok to test e672e96 |
🔬 Benchmark SASS comparisonHow to request a benchmark run
Targets with a SASS change
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/sass diff ok e672e96 |
🥳 CI Workflow Results🟩 Finished in 1d 00h: Pass: 100%/230 | Total: 6d 12h | Max: 3h 25m | Hits: 54%/1571631See results here. |
Description
Part of #11894
Comparison functions
isgreater,isless,isgreaterequal,islessequalandislessgreatercompile toDSETPfordouble, which is slow on GPUs with low FP64 throughput -> idea to convert to int64 representation with the same ordering as double for the comparison__fp64_to_ordered_intmaps the bits ofdoubletoint64_twith the same ordering:I chose a selection form:
key = x < 0 ? INT64_MIN - x : x -> -0 and +0 map to the same value
The function is local to
traits.h, as discussed in [FEA]: Optimize double-precision<cmath>functionalities with integer path #11894isnanfast pathBenchmarks:
No FP64 instructions are emitted by the compiler on slow FP64 targets.
fmax/fmin
__fp64_to_total_order_intmaps the bits of adoubletoint64_tin total order, i.e. -0 < +0. NaNs are placed beyond +-inf__fp64_fmax_fmin_intadds function template that provides branch free min/max paths for doubles with integer instructions. -0 < +0, single NaN ignored and two NaNs return first argument quietedBenchmarks:
fmax/fminalso affect downstream paths in CUB viacuda::std::minimum/maximum:The only downstream benchmark negatively affected is using fabs, which is the reason for the slowdown. I'll address this in a separate PR.
Added tests for comparisons and fmin/fmax that cover edge cases
Checklist