MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / atomic_load

Method atomic_load

crates/rustc_codegen_nvvm/src/builder.rs:489–515  ·  view source on GitHub ↗
(
        &mut self,
        ty: &'ll Type,
        ptr: &'ll Value,
        _order: AtomicOrdering,
        _size: Size,
    )

Source from the content-addressed store, hash-verified

487 }
488
489 fn atomic_load(
490 &mut self,
491 ty: &'ll Type,
492 ptr: &'ll Value,
493 _order: AtomicOrdering,
494 _size: Size,
495 ) -> &'ll Value {
496 // core seems to think that nvptx has atomic loads, which is not true for NVVM IR,
497 // therefore our only option is to print that this is not supported then trap.
498 // i have heard of cursed things such as emulating this with __threadfence and volatile loads
499 // but that needs to be experimented with in terms of safety and behavior.
500 // NVVM has explicit intrinsics for adding and subtracting floats which we expose elsewhere
501
502 // TODO(RDambrosio016): is there a way we can just generate a panic with a message instead
503 // of doing this ourselves? since all panics will be aborts, it should be equivalent
504 // let message = "Atomic Loads are not supported in CUDA.\0";
505
506 // let vprintf = self.get_intrinsic("vprintf");
507 // let formatlist = self.const_str(Symbol::intern(message)).0;
508 // let valist = self.const_null(self.type_void());
509
510 // self.call(vprintf, &[formatlist, valist], None);
511
512 let trap = self.get_intrinsic("llvm.trap");
513 self.call(ty, trap, &[], None);
514 unsafe { llvm::LLVMBuildLoad(self.llbuilder, ptr, unnamed()) }
515 }
516
517 fn load_operand(&mut self, place: PlaceRef<'tcx, &'ll Value>) -> OperandRef<'tcx, &'ll Value> {
518 trace!("Load operand `{:?}`", place);

Callers

nothing calls this directly

Calls 3

unnamedFunction · 0.85
get_intrinsicMethod · 0.80
callMethod · 0.80

Tested by

no test coverage detected