-
Notifications
You must be signed in to change notification settings - Fork 842
[SYCL][FPGA] Add support for loop count attribute. #3438
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
Changes from 32 commits
488dfb9
b0f255e
0324f5f
a3a8613
5abbbe6
48d6df0
61fba57
99cb85f
44b8681
7622568
c3d8c59
4dba2ea
50a06c7
1bb84bc
40a3279
1f84add
6ab3b07
a5ad650
fd34d55
d812fa4
fd74842
93cbc1d
73f92a4
80f372a
639794e
d2884f0
5ab429b
c73cd83
86ae532
3044f88
453b654
9d46fc0
a44e1ce
1a20635
c10bfaf
cefac8a
6ddf9ce
d0ddcdd
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2951,6 +2951,43 @@ or ``ivdep``. | |||||
| }]; | ||||||
| } | ||||||
|
|
||||||
| def SYCLIntelFPGALoopCountAttrDocs : Documentation { | ||||||
| let Category = DocCatVariable; | ||||||
| let Heading = "intel::loop_count_min, intel::loop_count_max, intel::loop_count_avg"; | ||||||
| let Content = [{ | ||||||
| The "loop_count" attribute specifies the minimum, maximum, or average number of | ||||||
|
Contributor
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.
Suggested change
|
||||||
| iterations for a for loop. In addition, a list of commonly occurring values | ||||||
|
AaronBallman marked this conversation as resolved.
Outdated
|
||||||
| can be specified to help the compiler generate multiple versions and perform | ||||||
|
AaronBallman marked this conversation as resolved.
Outdated
|
||||||
| complete unrolling. | ||||||
|
|
||||||
| .. code-block:: c++ | ||||||
|
AaronBallman marked this conversation as resolved.
|
||||||
|
|
||||||
| void foo() { | ||||||
| int a[10]; | ||||||
| [[intel::loop_count_min(40)] for (int i = 0; i < 10; ++i) a[i] = 0; | ||||||
| } | ||||||
|
|
||||||
| void zoo() { | ||||||
| int a[10]; | ||||||
| [[intel::loop_count_max(40)] for (int i = 0; i < 10; ++i) a[i] = 0; | ||||||
| } | ||||||
|
|
||||||
| void goo() { | ||||||
| int a[10]; | ||||||
| [[intel::loop_count_min(10)] | ||||||
| [[intel::loop_count_max(40)] | ||||||
| [[intel::loop_count_avg(15)] | ||||||
| for (int i = 0; i < 10; ++i) a[i] = 0; | ||||||
| } | ||||||
|
|
||||||
| template<int N> | ||||||
| void bar() { | ||||||
| [[intel::loop_count_avg(N)]] for(;;) { } | ||||||
| } | ||||||
|
|
||||||
| }]; | ||||||
| } | ||||||
|
|
||||||
| def SYCLIntelFPGAMaxInterleavingAttrDocs : Documentation { | ||||||
| let Category = DocCatVariable; | ||||||
| let Heading = "intel::max_interleaving"; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -553,10 +553,10 @@ MDNode *LoopInfo::createMetadata( | |
|
|
||
| // Setting max_concurrency attribute with number of threads | ||
| if (Attrs.SYCLMaxConcurrencyEnable) { | ||
| Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.max_concurrency.count"), | ||
| ConstantAsMetadata::get(ConstantInt::get( | ||
| llvm::Type::getInt32Ty(Ctx), | ||
| Attrs.SYCLMaxConcurrencyNThreads))}; | ||
| Metadata *Vals[] = { | ||
| MDString::get(Ctx, "llvm.loop.max_concurrency.count"), | ||
| ConstantAsMetadata::get(ConstantInt::get( | ||
| llvm::Type::getInt32Ty(Ctx), Attrs.SYCLMaxConcurrencyNThreads))}; | ||
|
smanna12 marked this conversation as resolved.
Outdated
|
||
| LoopProperties.push_back(MDNode::get(Ctx, Vals)); | ||
| } | ||
|
|
||
|
|
@@ -605,6 +605,16 @@ MDNode *LoopInfo::createMetadata( | |
| LoopProperties.push_back(MDNode::get(Ctx, Vals)); | ||
| } | ||
|
|
||
| if (Attrs.SYCLIntelFPGALoopCountEnable) { | ||
| for (int i = 0; i < Attrs.SYCLIntelFPGALoopCountVariant.size(); i++) { | ||
|
Contributor
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. It'd be nice to replace this with a range-based for loop once you unify the lists. |
||
| Metadata *Vals[] = { | ||
| MDString::get(Ctx, Attrs.SYCLIntelFPGALoopCountVariant[i]), | ||
| ConstantAsMetadata::get( | ||
| ConstantInt::get(llvm::Type::getInt32Ty(Ctx), | ||
| Attrs.SYCLIntelFPGALoopCountValue[i]))}; | ||
| LoopProperties.push_back(MDNode::get(Ctx, Vals)); | ||
| } | ||
| } | ||
| LoopProperties.insert(LoopProperties.end(), AdditionalLoopProperties.begin(), | ||
| AdditionalLoopProperties.end()); | ||
| return createFullUnrollMetadata(Attrs, LoopProperties, HasUserTransforms); | ||
|
|
@@ -621,10 +631,12 @@ LoopAttributes::LoopAttributes(bool IsParallel) | |
| SYCLLoopCoalesceNLevels(0), SYCLLoopPipeliningDisable(false), | ||
| SYCLMaxInterleavingEnable(false), SYCLMaxInterleavingNInvocations(0), | ||
| SYCLSpeculatedIterationsEnable(false), | ||
| SYCLSpeculatedIterationsNIterations(0), UnrollCount(0), | ||
| UnrollAndJamCount(0), DistributeEnable(LoopAttributes::Unspecified), | ||
| PipelineDisabled(false), PipelineInitiationInterval(0), | ||
| SYCLNofusionEnable(false), MustProgress(false) {} | ||
| SYCLSpeculatedIterationsNIterations(0), | ||
| SYCLIntelFPGALoopCountEnable(false), SYCLIntelFPGALoopCountValue(0), | ||
| SYCLIntelFPGALoopCountVariant(0), UnrollCount(0), UnrollAndJamCount(0), | ||
| DistributeEnable(LoopAttributes::Unspecified), PipelineDisabled(false), | ||
| PipelineInitiationInterval(0), SYCLNofusionEnable(false), | ||
| MustProgress(false) {} | ||
|
|
||
| void LoopAttributes::clear() { | ||
| IsParallel = false; | ||
|
|
@@ -643,6 +655,9 @@ void LoopAttributes::clear() { | |
| SYCLMaxInterleavingNInvocations = 0; | ||
| SYCLSpeculatedIterationsEnable = false; | ||
| SYCLSpeculatedIterationsNIterations = 0; | ||
| SYCLIntelFPGALoopCountEnable = false; | ||
| SYCLIntelFPGALoopCountVariant.clear(); | ||
| SYCLIntelFPGALoopCountValue.clear(); | ||
|
Contributor
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. I'm not keen on keeping parallel lists for this sort of thing -- why not a single list of pairs, or some other data structure that keeps the variants and their values tied together? |
||
| UnrollCount = 0; | ||
| UnrollAndJamCount = 0; | ||
| VectorizeEnable = LoopAttributes::Unspecified; | ||
|
|
@@ -680,8 +695,11 @@ LoopInfo::LoopInfo(BasicBlock *Header, const LoopAttributes &Attrs, | |
| Attrs.SYCLMaxInterleavingNInvocations == 0 && | ||
| Attrs.SYCLSpeculatedIterationsEnable == false && | ||
| Attrs.SYCLSpeculatedIterationsNIterations == 0 && | ||
| Attrs.UnrollCount == 0 && Attrs.UnrollAndJamCount == 0 && | ||
| !Attrs.PipelineDisabled && Attrs.PipelineInitiationInterval == 0 && | ||
| Attrs.SYCLIntelFPGALoopCountEnable == 0 && | ||
| Attrs.SYCLIntelFPGALoopCountVariant.empty() && | ||
| Attrs.SYCLIntelFPGALoopCountValue.empty() && Attrs.UnrollCount == 0 && | ||
| Attrs.UnrollAndJamCount == 0 && !Attrs.PipelineDisabled && | ||
| Attrs.PipelineInitiationInterval == 0 && | ||
| Attrs.VectorizePredicateEnable == LoopAttributes::Unspecified && | ||
| Attrs.VectorizeEnable == LoopAttributes::Unspecified && | ||
| Attrs.UnrollEnable == LoopAttributes::Unspecified && | ||
|
|
@@ -1030,6 +1048,20 @@ void LoopInfoStack::push(BasicBlock *Header, clang::ASTContext &Ctx, | |
| ->getSExtValue()); | ||
| } | ||
|
|
||
| if (const auto *IntelFPGALoopCountAvg = | ||
| dyn_cast<SYCLIntelFPGALoopCountAttr>(A)) { | ||
| setSYCLIntelFPGALoopCountEnable(); | ||
| setSYCLIntelFPGALoopCountValue(IntelFPGALoopCountAvg->getNTripCount() | ||
| ->getIntegerConstantExpr(Ctx) | ||
| ->getSExtValue()); | ||
| const char *var = IntelFPGALoopCountAvg->isMax() | ||
| ? "llvm.loop.intel.loopcount_max" | ||
| : IntelFPGALoopCountAvg->isMin() | ||
| ? "llvm.loop.intel.loopcount_min" | ||
| : "llvm.loop.intel.loopcount_avg"; | ||
| setSYCLIntelFPGALoopCountVariant(var); | ||
| } | ||
|
|
||
| if (const auto *IntelFPGALoopCoalesce = | ||
| dyn_cast<SYCLIntelFPGALoopCoalesceAttr>(A)) { | ||
| if (auto *LCE = IntelFPGALoopCoalesce->getNExpr()) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.