Skip to content

Commit 015908a

Browse files
committed
applypriority intrinsics
1 parent 747588d commit 015908a

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

llvm/docs/NVPTXUsage.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,30 @@ uses and eviction priority which can be accessed by the '``.level::eviction_prio
630630
For more information, refer to the PTX ISA
631631
`<https://docs.nvidia.com/cuda/parallel-thread-execution/#data-movement-and-conversion-instructions-prefetch-prefetchu>`_.
632632

633+
'``llvm.nvvm.applypriority.*``'
634+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
635+
636+
Syntax:
637+
"""""""
638+
639+
.. code-block:: llvm
640+
641+
declare void @llvm.nvvm.applypriority.global.L2.evict.normal(ptr addrspace(1) %global_ptr, i64 %size)
642+
declare void @llvm.nvvm.applypriority.L2.evict.normal(ptr %ptr, i64 %size)
643+
644+
Overview:
645+
"""""""""
646+
647+
The '``@llvm.nvvm.applypriority.*``' applies the cache eviction priority specified by the
648+
.level::eviction_priority qualifier to the address range [a..a+size) in the specified cache
649+
level. If no state space is specified then Generic Addressing is used. If the specified address
650+
does not fall within the address window of .global state space then the behavior is undefined.
651+
The operand size is an integer constant that specifies the amount of data, in bytes, in the specified cache
652+
level on which the priority is to be applied. The only supported value for the size operand is 128.
653+
654+
For more information, refer to the PTX ISA
655+
`<https://docs.nvidia.com/cuda/parallel-thread-execution/#data-movement-and-conversion-instructions-applypriority>`_.
656+
633657
'``llvm.nvvm.cp.async.bulk.tensor.g2s.tile.[1-5]d``'
634658
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
635659

llvm/include/llvm/IR/IntrinsicsNVVM.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5043,6 +5043,16 @@ def int_nvvm_prefetch_global_L2_evict_last: Intrinsic<[], [llvm_global_ptr_ty],
50435043
def int_nvvm_prefetchu_L1 : Intrinsic<[], [llvm_ptr_ty],
50445044
[IntrArgMemOnly, ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
50455045

5046+
def int_nvvm_applypriority_global_L2_evict_normal
5047+
: Intrinsic<[], [llvm_global_ptr_ty, llvm_i64_ty],
5048+
[IntrArgMemOnly, ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>,
5049+
ImmArg<ArgIndex<1>>]>;
5050+
5051+
def int_nvvm_applypriority_L2_evict_normal
5052+
: Intrinsic<[], [llvm_ptr_ty, llvm_i64_ty],
5053+
[IntrArgMemOnly, ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>,
5054+
ImmArg<ArgIndex<1>>]>;
5055+
50465056

50475057
// Intrinsics for Bulk Copy using TMA (non-tensor)
50485058
// From Global to Shared Cluster

llvm/lib/Target/NVPTX/NVPTXIntrinsics.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,22 @@ def PREFETCH_GLOBAL_L2_EVICT_LAST : NVPTXInst<(outs), (ins Int64Regs:$addr),
789789

790790
def PREFETCHU_L1 : PREFETCH_INTRS<"prefetchu.L1">;
791791

792+
//Applypriority intrinsics
793+
multiclass APPLYPRIORITY_L2_INTRS<string addr> {
794+
defvar InstName = "applypriority."
795+
# !if(!eq(addr, ""), "", addr # ".")
796+
# "L2::evict_normal";
797+
798+
def APPLYPRIORITY_L2 : NVPTXInst<(outs), (ins Int64Regs:$addr, Int64Regs:$size),
799+
InstName # " [$addr], $size;",
800+
[(!cast<Intrinsic>("int_nvvm_" # !subst("::", "_", !subst(".", "_", InstName)))
801+
i64:$addr, i64:$size)]>,
802+
Requires<[hasPTX<80>, hasSM<90>]>;
803+
}
804+
805+
defm APPLYPRIORITY_L2_EVICT_NORMAL : APPLYPRIORITY_L2_INTRS<"">;
806+
defm APPLYPRIORITY_GLOBAL_L2_EVICT_NORMAL : APPLYPRIORITY_L2_INTRS<"global">;
807+
792808
//-----------------------------------
793809
// MBarrier Functions
794810
//-----------------------------------
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc < %s -mtriple=nvptx64 -mcpu=sm_90 -mattr=+ptx80| FileCheck --check-prefixes=CHECK-PTX64 %s
3+
; RUN: %if ptxas-12.3 %{ llc < %s -mtriple=nvptx64 -mcpu=sm_90 -mattr=+ptx80| %ptxas-verify -arch=sm_90 %}
4+
5+
target triple = "nvptx64-nvidia-cuda"
6+
7+
declare void @llvm.nvvm.applypriority.global.L2.evict.normal(ptr addrspace(1) %global_ptr, i64 %size)
8+
declare void @llvm.nvvm.applypriority.L2.evict.normal(ptr %ptr, i64 %size)
9+
10+
define void @applypriority_global_L2(ptr addrspace(1) %global_ptr, i64 %size) {
11+
; CHECK-PTX64-LABEL: applypriority_global_L2(
12+
; CHECK-PTX64: {
13+
; CHECK-PTX64-NEXT: .reg .b64 %rd<2>;
14+
; CHECK-PTX64-EMPTY:
15+
; CHECK-PTX64-NEXT: // %bb.0:
16+
; CHECK-PTX64-NEXT: ld.param.u64 %rd1, [applypriority_global_L2_param_0];
17+
; CHECK-PTX64-NEXT: applypriority.global.L2::evict_normal [%rd1], 128;
18+
; CHECK-PTX64-NEXT: ret;
19+
tail call void @llvm.nvvm.applypriority.global.L2.evict.normal(ptr addrspace(1) %global_ptr, i64 128)
20+
ret void
21+
}
22+
23+
define void @applypriority_L2(ptr %ptr, i64 %size) {
24+
; CHECK-PTX64-LABEL: applypriority_L2(
25+
; CHECK-PTX64: {
26+
; CHECK-PTX64-NEXT: .reg .b64 %rd<2>;
27+
; CHECK-PTX64-EMPTY:
28+
; CHECK-PTX64-NEXT: // %bb.0:
29+
; CHECK-PTX64-NEXT: ld.param.u64 %rd1, [applypriority_L2_param_0];
30+
; CHECK-PTX64-NEXT: applypriority.L2::evict_normal [%rd1], 128;
31+
; CHECK-PTX64-NEXT: ret;
32+
tail call void @llvm.nvvm.applypriority.L2.evict.normal(ptr %ptr, i64 128)
33+
ret void
34+
}

0 commit comments

Comments
 (0)