@@ -401,6 +401,36 @@ def NVVM_ReduxOp :
401401 }];
402402}
403403
404+ //===----------------------------------------------------------------------===//
405+ // NVVM nanosleep
406+ //===----------------------------------------------------------------------===//
407+
408+ def NVVM_NanosleepOp : NVVM_Op<"nanosleep">,
409+ Arguments<(ins
410+ ConfinedAttr<I32Attr, [IntMinValue<1>, IntMaxValue<1000000>]>:$duration)>
411+ {
412+ let summary = "Suspends the thread for a specified duration.";
413+
414+ let description = [{
415+ The op suspends the thread for a sleep duration approximately close to the
416+ delay `$duration`, specified in nanoseconds.
417+
418+ The sleep duration is approximated, but guaranteed to be in the
419+ interval [0, 2*t]. The maximum sleep duration is 1 millisecond.
420+ The implementation may reduce the sleep duration for individual threads
421+ within a warp such that all sleeping threads in the warp wake up together.
422+
423+ [For more information, see PTX ISA](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#miscellaneous-instructions-nanosleep)
424+ }];
425+
426+ string llvmBuilder = [{
427+ createIntrinsicCall(builder,
428+ llvm::Intrinsic::nvvm_nanosleep,
429+ {builder.getInt32($duration)});
430+ }];
431+ let assemblyFormat = "attr-dict $duration";
432+ }
433+
404434//===----------------------------------------------------------------------===//
405435// NVVM Performance Monitor events
406436//===----------------------------------------------------------------------===//
0 commit comments