Skip to content

Unsupported construct: BinaryOp Cmp not yet implemented #136

Closed

Description

@mutantbob

While implementing Ord for a custom type I have encountered

error: [rustc_codegen_cuda] Device codegen failed: PTX generation failed: Translation failed: asplode: [name: "Span { id: 8, repr: "/home/thoth/.rustup/toolchains/nightly-2026-04-03-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cmp.rs:2012:21: 2012:72" }", loc: (?)] Compilation error: invalid input program.
       Unsupported construct: BinaryOp Cmp not yet implemented

I hope you can easily reproduce it using this kernel:

use cuda_device::cuda_module;

#[cuda_module]
mod kernels {
    use cuda_device::{DisjointSlice, kernel, thread};
    use std::cmp::Ordering;

    #[kernel]
    pub fn asplode(mut _dst: DisjointSlice<usize>) {
        let _idx = thread::index_1d();

        let x = Foo::<u32>::default().cmp(&Foo::default());
    }

    #[derive(Eq, PartialEq, PartialOrd, Default)]
    struct Foo<T> {
        pieces: [T; 4],
    }

    impl<T> Ord for Foo<T>
    where
        T: Ord,
    {
        fn cmp(&self, other: &Self) -> Ordering {
            self.pieces[0].cmp(&other.pieces[0])
        }
    }
}

Activity

  1. added
    bug
    codegen
    on Jun 8, 2026
  2. advpropsys commented on Jun 8, 2026

    @advpropsys
    Contributor

    I opened a PR for this in #147.

    The patch imports and lowers MIR BinaryOp::Cmp for Ord::cmp, and adds an ord_cmp regression example covering signed and unsigned integer comparisons, including usize and isize.

    Validation included cargo oxide run ord_cmp --arch sm_103, which passed all less/equal/greater cases.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcodegen

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions