-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[NVPTX] Add prefetch tensormap variant #146203
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
base: main
Are you sure you want to change the base?
Changes from all commits
7e3815b
775daa3
aa8e4d0
6931c80
887e139
9ddbcfe
383d07e
0851ae0
9ea1ca3
0d26914
bab560b
f009291
2457b1a
ee0e82c
45f5af0
ec1e1a0
7256bc6
4745db5
1102a58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,12 @@ def AS_match { | |
code global = [{ | ||
return ChkMemSDNodeAddressSpace(N, llvm::ADDRESS_SPACE_GLOBAL); | ||
}]; | ||
code const = [{ | ||
return ChkMemSDNodeAddressSpace(N, llvm::ADDRESS_SPACE_CONST); | ||
}]; | ||
code param = [{ | ||
return ChkMemSDNodeAddressSpace(N, llvm::ADDRESS_SPACE_PARAM); | ||
}]; | ||
} | ||
|
||
// A node that will be replaced with the current PTX version. | ||
|
@@ -744,35 +750,42 @@ foreach dim = [1, 2, 3, 4, 5] in { | |
} | ||
} | ||
|
||
//Prefetch and Prefetchu | ||
//Prefetchu and Prefetch | ||
|
||
defvar frag_pat = (int_nvvm_prefetch_tensormap node:$addr); | ||
|
||
def prefetch_tensormap_const : PatFrag<!setdagop(frag_pat, ops), frag_pat, AS_match.const>; | ||
def prefetch_tensormap_gen : PatFrag<!setdagop(frag_pat, ops), frag_pat, AS_match.generic>; | ||
def prefetch_tensormap_param : PatFrag<!setdagop(frag_pat, ops), frag_pat, AS_match.param>; | ||
|
||
class PREFETCH_INTRS<string InstName> : | ||
multiclass PREFETCH_TENSORMAP_INST<string addrspace_name, PatFrag pattern_frag> { | ||
def "" : BasicNVPTXInst<(outs), (ins ADDR:$addr), | ||
!strconcat("prefetch", !if(!eq(addrspace_name, ""), "", | ||
!strconcat(".", addrspace_name)), ".tensormap [$addr];"), | ||
[(pattern_frag addr:$addr)]>, | ||
Requires<[hasPTX<80>, hasSM<90>]>; | ||
Comment on lines
+762
to
+766
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
} | ||
|
||
defm PREFETCH_CONST_TENSORMAP : PREFETCH_TENSORMAP_INST<"const", prefetch_tensormap_const>; | ||
defm PREFETCH_GENERIC_TENSORMAP : PREFETCH_TENSORMAP_INST<"", prefetch_tensormap_gen>; | ||
defm PREFETCH_PARAM_TENSORMAP : PREFETCH_TENSORMAP_INST<"param", prefetch_tensormap_param>; | ||
|
||
class PREFETCH_INTRS<string InstName, Intrinsic Intr> : | ||
BasicNVPTXInst<(outs), (ins ADDR:$addr), | ||
InstName, | ||
[(!cast<Intrinsic>(!strconcat("int_nvvm_", | ||
!subst(".", "_", InstName))) addr:$addr)]>, | ||
Requires<[hasPTX<80>, hasSM<90>]>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why have these predicates been removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this needs to be added, fixing in progress. Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has this been fixed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missed this, will update. thanks |
||
|
||
|
||
def PREFETCH_L1 : PREFETCH_INTRS<"prefetch.L1">; | ||
def PREFETCH_L2 : PREFETCH_INTRS<"prefetch.L2">; | ||
def PREFETCH_GLOBAL_L1 : PREFETCH_INTRS<"prefetch.global.L1">; | ||
def PREFETCH_LOCAL_L1 : PREFETCH_INTRS<"prefetch.local.L1">; | ||
def PREFETCH_GLOBAL_L2 : PREFETCH_INTRS<"prefetch.global.L2">; | ||
def PREFETCH_LOCAL_L2 : PREFETCH_INTRS<"prefetch.local.L2">; | ||
|
||
def PREFETCH_GLOBAL_L2_EVICT_NORMAL : BasicNVPTXInst<(outs), (ins ADDR:$addr), | ||
"prefetch.global.L2::evict_normal", | ||
[(int_nvvm_prefetch_global_L2_evict_normal addr:$addr)]>, | ||
Requires<[hasPTX<80>, hasSM<90>]>; | ||
|
||
def PREFETCH_GLOBAL_L2_EVICT_LAST : BasicNVPTXInst<(outs), (ins ADDR:$addr), | ||
"prefetch.global.L2::evict_last", | ||
[(int_nvvm_prefetch_global_L2_evict_last addr:$addr)]>, | ||
Requires<[hasPTX<80>, hasSM<90>]>; | ||
|
||
|
||
def PREFETCHU_L1 : PREFETCH_INTRS<"prefetchu.L1">; | ||
[(Intr addr:$addr)]>; | ||
|
||
def PREFETCHU_L1 : PREFETCH_INTRS<"prefetchu.L1", int_nvvm_prefetchu_L1>; | ||
def PREFETCH_L1 : PREFETCH_INTRS<"prefetch.L1", int_nvvm_prefetch_L1>; | ||
def PREFETCH_L2 : PREFETCH_INTRS<"prefetch.L2", int_nvvm_prefetch_L2>; | ||
def PREFETCH_GLOBAL_L1 : PREFETCH_INTRS<"prefetch.global.L1", int_nvvm_prefetch_global_L1>; | ||
def PREFETCH_LOCAL_L1 : PREFETCH_INTRS<"prefetch.local.L1", int_nvvm_prefetch_local_L1>; | ||
def PREFETCH_GLOBAL_L2 : PREFETCH_INTRS<"prefetch.global.L2", int_nvvm_prefetch_global_L2>; | ||
def PREFETCH_LOCAL_L2 : PREFETCH_INTRS<"prefetch.local.L2", int_nvvm_prefetch_local_L2>; | ||
def PREFETCH_GLOBAL_L2_EVICT_NORMAL : PREFETCH_INTRS<"prefetch.global.L2::evict_normal", | ||
int_nvvm_prefetch_global_L2_evict_normal>; | ||
def PREFETCH_GLOBAL_L2_EVICT_LAST : PREFETCH_INTRS<"prefetch.global.L2::evict_last", | ||
int_nvvm_prefetch_global_L2_evict_last>; | ||
|
||
//Applypriority intrinsics | ||
class APPLYPRIORITY_L2_INTRS<string addrspace> : | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -564,7 +564,8 @@ bool NVPTXTTIImpl::collectFlatAddressOperands(SmallVectorImpl<int> &OpIndexes, | |
case Intrinsic::nvvm_isspacep_global: | ||
case Intrinsic::nvvm_isspacep_local: | ||
case Intrinsic::nvvm_isspacep_shared: | ||
case Intrinsic::nvvm_isspacep_shared_cluster: { | ||
case Intrinsic::nvvm_isspacep_shared_cluster: | ||
case Intrinsic::nvvm_prefetch_tensormap: { | ||
OpIndexes.push_back(0); | ||
return true; | ||
} | ||
|
@@ -587,6 +588,15 @@ Value *NVPTXTTIImpl::rewriteIntrinsicWithAddressSpace(IntrinsicInst *II, | |
return ConstantInt::get(II->getType(), *R); | ||
return nullptr; | ||
} | ||
case Intrinsic::nvvm_prefetch_tensormap: { | ||
IRBuilder<> Builder(II); | ||
Module *M = II->getModule(); | ||
Function *NewIntrinsic = Intrinsic::getDeclaration( | ||
M, Intrinsic::nvvm_prefetch_tensormap, {NewV->getType()}); | ||
CallInst *NewCall = Builder.CreateCall(NewIntrinsic, {NewV}); | ||
NewCall->setAttributes(II->getAttributes()); | ||
Comment on lines
+593
to
+597
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
return NewCall; | ||
} | ||
} | ||
return nullptr; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this part of the multiclass and just pass
AS_match.const/generic/param
as a parameter?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok yes.