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

SPIR-V wishlist #17

Open
Jasper-Bekkers opened this issue Aug 20, 2020 · 5 comments
Open

SPIR-V wishlist #17

Jasper-Bekkers opened this issue Aug 20, 2020 · 5 comments
Labels
t: tracking issue An issue tracking the progress of a specific feature or change.

Comments

@Jasper-Bekkers
Copy link
Contributor

Tracking issue for features we think are missing or useful in to have in SPIR-V

  • OpTrap: trigger a breakpoint
@Jasper-Bekkers
Copy link
Contributor Author

Noticed a few comments other things in the codebase yesterday:

  • Checked math as native SPIR-V ops could help slightly more optimized checked math routines
    fn checked_binop(
    &mut self,
    _oop: OverflowOp,
    _ty: Ty<'_>,
    _lhs: Self::Value,
    _rhs: Self::Value,
    ) -> (Self::Value, Self::Value) {
    panic!("TODO: Checked binary operations are not supported yet");
    }
  • Saturating math ops (already supported by some GPU ISAs - so should be easier to drive adoption for):
    sym::wrapping_add => math_intrinsic! {self, arg_tys, args, add, add, fadd},
    sym::wrapping_sub => math_intrinsic! {self, arg_tys, args, sub, sub, fsub},
    sym::wrapping_mul => math_intrinsic! {self, arg_tys, args, mul, mul, fmul},
    sym::saturating_add => math_intrinsic! {self, arg_tys, args, add, add, fadd},
    sym::saturating_sub => math_intrinsic! {self, arg_tys, args, sub, sub, fsub},
    sym::unchecked_add => math_intrinsic! {self, arg_tys, args, add, add, fadd},
    sym::unchecked_sub => math_intrinsic! {self, arg_tys, args, sub, sub, fsub},
    sym::unchecked_mul => math_intrinsic! {self, arg_tys, args, mul, mul, fmul},
    sym::unchecked_div => math_intrinsic! {self, arg_tys, args, sdiv, udiv, fdiv},
    sym::unchecked_rem => math_intrinsic! {self, arg_tys, args, srem, urem, frem},
    sym::unchecked_shl => math_intrinsic_int! {self, arg_tys, args, shl, shl},
  • Equivalent of llvm.expect:
    fn expect(&mut self, cond: Self::Value, _expected: bool) -> Self::Value {
    // TODO: llvm.expect
    cond
    }
  • Equivalent of llvm.sideeffects:
    fn sideeffect(&mut self) {
    // TODO: This is currently ignored.
    // It corresponds to the llvm.sideeffect intrinsic - does spir-v have an equivalent?
    }
  • Equivalent of llvm.assume:
    fn assume(&mut self, _val: Self::Value) {
    // TODO: llvm.assume
    }

@khyperia
Copy link
Contributor

khyperia commented Sep 1, 2020

For the "equivalent of llvm.*", there are a lot of these, those are just the ones that have been hit so far - I've just been JITting them into the codebase. For a reasonably full list, look at this file - for example, llvm.expect.i1 (sym::likely/sym::unlikely), llvm.debugtrap (sym::breakpoint), and so forth. (including llvm.trap (sym::abort), which was already mentioned at the start of this thread)

https://github.com/rust-lang/rust/blob/e88e908e66cd1e6e30d789b37bcd774951d01856/compiler/rustc_codegen_llvm/src/intrinsic.rs

@Jasper-Bekkers
Copy link
Contributor Author

@nhaehnle
Copy link

* Potentially request OpControlBarrier  for non-uniform controlflow (useful for #29)

To clarify, for #29 the thinking is that OpControlBarrier without undefined behavior may be useful. This would be done by making the behavior a guaranteed hang when it's not executed in uniform control flow...

@Jasper-Bekkers
Copy link
Contributor Author

@khyperia
not only is this legal spir-v, it is unspecified what the return value is (like, it's not specified as undefined, it's unspecified)

         %f_ = OpFunction %int None %7
          %9 = OpLabel
          %x = OpVariable %_ptr_Function_int Function
         %12 = OpLoad %int %x
               OpReturnValue %12
               OpFunctionEnd

can we get this fixed in the spec, please?
this is equivalent to the glsl

int f() {
    int x; // explicitly uninitialized
    return x;
}

@XAMPPRocky XAMPPRocky added the t: tracking issue An issue tracking the progress of a specific feature or change. label Mar 3, 2021
@oisyn oisyn added t: tracking issue An issue tracking the progress of a specific feature or change. and removed t: tracking issue An issue tracking the progress of a specific feature or change. labels Nov 15, 2022
@rust-gpu-bot
Copy link

This issue is now being tracked at: Rust-GPU/rust-gpu#141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: tracking issue An issue tracking the progress of a specific feature or change.
Projects
None yet
Development

No branches or pull requests

6 participants