Skip to content
This repository was archived by the owner on Jan 8, 2021. It is now read-only.

Commit e5e51df

Browse files
committed
Modify offloading loop scale
1 parent 85a0093 commit e5e51df

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

include/llvm/Analysis/BlockFrequencyInfoImpl.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#include <string>
4444
#include <utility>
4545
#include <vector>
46+
#include "llvm/IR/Function.h"
47+
#include "llvm/IR/Module.h"
4648

4749
#define DEBUG_TYPE "block-freq"
4850

@@ -1144,6 +1146,23 @@ template <class BT> void BlockFrequencyInfoImpl<BT>::computeMassInLoops() {
11441146
}
11451147
}
11461148

1149+
// lld: OpenMP offloading outer loop
1150+
namespace bfi_detail {
1151+
template <class FT>
1152+
void changeLoopScale(ScaledNumber<uint64_t> *Scale, const FT *F) {}
1153+
template <>
1154+
inline void changeLoopScale<Function>(ScaledNumber<uint64_t> *Scale,
1155+
const Function *F) {
1156+
auto *M = F->getParent();
1157+
std::string TT = M->getTargetTriple();
1158+
if (TT.find("cuda") != std::string::npos) {
1159+
dbgs() << "change loop scale from " << *Scale << " to ";
1160+
*Scale = ScaledNumber<uint64_t>(1, 0).inverse();
1161+
dbgs() << *Scale << "\n";
1162+
}
1163+
}
1164+
} // namespace bfi_detail
1165+
11471166
template <class BT>
11481167
bool BlockFrequencyInfoImpl<BT>::computeMassInLoop(LoopData &Loop) {
11491168
// Compute mass in loop.
@@ -1214,6 +1233,9 @@ bool BlockFrequencyInfoImpl<BT>::computeMassInLoop(LoopData &Loop) {
12141233
}
12151234

12161235
computeLoopScale(Loop);
1236+
// lld: OpenMP offloading outer loop
1237+
if (&Loop == &(*Loops.begin()))
1238+
bfi_detail::changeLoopScale(&(Loop.Scale), F);
12171239
packageLoop(Loop);
12181240
return true;
12191241
}

0 commit comments

Comments
 (0)