Rust-GPU / Rust-CUDA

Ecosystem of libraries and tools for writing and executing fast GPU code fully in Rust.
Apache License 2.0
3.02k stars 115 forks source link

internal compiler error: unknown intrinsic 'raw_eq' #35

Closed andll closed 2 years ago

andll commented 2 years ago

I am interested in trying ed25519 signature verification on cuda, and was trying to compile ed25519-dalek crate.

More specifically, for now I just added it as a dependency to gpu/add example to see if there will be any compilation errors.

I had to remove code related to secret key generation(since I am only interested in verification) and zeroize crate since it was causing obvious errors (see https://github.com/andll/ed25519-dalek/commit/132de2d6735117262802845370b098745bf7a68c), but after that I get compiler error that I don't understand / know how to fix

  error: internal compiler error: crates/rustc_codegen_nvvm/src/intrinsic.rs:430:18: unknown intrinsic 'raw_eq'

  thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1170:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  warning: `ed25519-dalek` (lib) generated 3 warnings
  error: could not compile `ed25519-dalek`; 3 warnings emitted
  warning: build failed, waiting for other jobs to finish...
  error: atomic fence is not supported, use cuda_std intrinsics instead

I am also not sure if 'unknown intrinsic' and 'atomic fence is not supported' referring to the same problem or are they different issue.

Problem with those errors is that they don't point to source code that cause them, so for person like me who is not familiar with compiler internals don't even know where to look.

Do you have any advice what are the things in source that can cause this that I can try to remove/change with something else?

Is there a way to pin point specific source code line that cause the issue?

RDambrosio016 commented 2 years ago

This is a bug in the codegen, it seems i may have forgotten to add the raw_eq intrinsic to the intrinsic handler, and that intrinsic is apparently codegenned for... something in that crate. I will try to fix that right now. The second error is intentional, NVVM IR does not support atomic fence instructions because fences on the GPU can be thread block fences, device fences, or system fences. And they do not support ordering or synchronization scopes, therefore its best to just error on them and make users use the cuda_std versions to be more explicit.

RDambrosio016 commented 2 years ago

should be fixed in 0.2.3, i don't currently plan to support core atomic fences since i'd have to guess their use based on the ordering and scope and that seems too dangerous

andll commented 2 years ago

Thank you!