Skip to content
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

Support newer LLVM versions #170

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ jobs:
-DLLVM_PARALLEL_LINK_JOBS=1 ../cmake/superbuild \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_STANDARD=14 \
-DLLVM_ENABLE_CXX1Y=ON \
-DOPTSCHEDSUPER_LLVM_EXTRA_CMAKE_ARGS='-DLLVM_ENABLE_ASSERTIONS=ON' \
-DOPTSCHED_EXTRA_DEFINITIONS='-DIS_DEBUG'

Expand Down Expand Up @@ -188,6 +190,7 @@ jobs:
cmake ../llvm-project/llvm -GNinja -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_STANDARD=14 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
'-DLLVM_TARGETS_TO_BUILD=X86;AMDGPU' \
-DLLVM_TABLEGEN=$(which llvm-tblgen-7) \
Expand Down
149 changes: 149 additions & 0 deletions .github/workflows/llvm-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Check LLVM Versions

on:
push:
branches: [ master ]
issue_comment: # On PR issue comment
types: [ created ]

jobs:
comment-triggered:
runs-on: ubuntu-20.04

outputs:
value: ${{ steps.value.outputs.value }}
checks_should_run: ${{ steps.checks_should_run.outputs.checks_should_run }}

steps:
- id: value
# Allow triggering with a comment of `Do: Check LLVM Versions`.
# If we are a pull_request, we have the trigger comment, and the person
# requesting is the one who made the PR, then we run.
run: >-
echo "::set-output name=value::${{ github.event_name == 'issue_comment'
&& github.event.issue.pull_request != ''
&& github.event.comment.body == 'Do: Check LLVM Versions'
&& github.event.comment.user.id == github.event.issue.user.id }}"

- id: checks_should_run
run: >-
echo "::set-output name=checks_should_run::${{
steps.value.outputs.value == 'true'
|| github.event_name == 'push'
|| github.event_name == 'pull_request' }}"

init-report:
needs: comment-triggered
runs-on: ubuntu-20.04
if: needs.comment-triggered.outputs.value == 'true'

outputs:
report: ${{ steps.report.outputs.comment-id }}

steps:
- name: Initialize Report
uses: peter-evans/[email protected]
id: report
with:
issue-number: ${{ github.event.issue.number }}
body: |
Checking LLVM versions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

check-llvm-versions:
needs: comment-triggered
runs-on: ubuntu-${{ matrix.os }}
if: needs.comment-triggered.outputs.checks_should_run == 'true'

strategy:
fail-fast: false
matrix:
include:
- llvm: 7
llvm-ver: 7.1
os: 18.04
ubuntu: bionic
- llvm: 8
llvm-ver: 8.0
os: 18.04
ubuntu: bionic
- llvm: 9
llvm-ver: 9.0
os: 20.04
ubuntu: focal
- llvm: 10
llvm-ver: 10.0
os: 20.04
ubuntu: focal
- llvm: 11
llvm-ver: 11.1
os: 20.04
ubuntu: focal
- llvm: 12
llvm-ver: 12.0
os: 20.04
ubuntu: focal
- llvm: 13
llvm-ver: 13.0
os: 20.04
ubuntu: focal

steps:
- name: Install dependencies
run: |
# Setup LLVM GPG Key
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -

sudo add-apt-repository "deb http://apt.llvm.org/${{ matrix.ubuntu }}/ llvm-toolchain-${{ matrix.ubuntu }}-${{ matrix.llvm }} main"
sudo apt-get update

sudo apt-get install clang++-${{ matrix.llvm }} llvm-${{ matrix.llvm }} ninja-build

- uses: actions/checkout@v2
with:
fetch-depth: 0

- run: |
echo ${{ github.token }} | gh auth login --with-token
gh pr checkout ${{ github.event.issue.number }}
if: needs.comment-triggered.outputs.value == 'true'

- name: Configure OptSched
run: |
mkdir build-optsched && cd build-optsched

cmake .. -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DOPTSCHED_LLVM_VERSION=${{ matrix.llvm-ver }} \
-DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc \
-DOPTSCHED_ENABLE_AMDGPU=OFF \
-DCMAKE_INSTALL_PREFIX=$PWD/install

- name: Build OptSched
working-directory: build-optsched
run: ninja

- name: Run tests
working-directory: build-optsched
run: ctest -VV

report:
needs: [comment-triggered, init-report, check-llvm-versions]
runs-on: ubuntu-20.04
if: always()

steps:
- name: Report CI
if: needs.comment-triggered.outputs.value == 'true'
uses: peter-evans/[email protected]
with:
comment-id: ${{ needs.init-report.outputs.report }}
body: |
| Check | Status |
| ----- | ------ |
${{
format('| Check LLVM Versions | {0}{1}{2} |',
needs.check-llvm-versions.result == 'success' && '✔ Passed' || '',
needs.check-llvm-versions.result == 'failure' && '❌ Failed' || '',
(needs.check-llvm-versions.result != 'success' && needs.check-llvm-versions.result != 'failure') && 'Skipped' || ''
)
}}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/build
/.vscode
build
.vscode
__pycache__
*.pyc
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4.3)
cmake_minimum_required(VERSION 3.8)

project(OptSched)

Expand Down
4 changes: 2 additions & 2 deletions include/opt-sched/Scheduler/lnkd_lst.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ template <class EntryType>
std::unique_ptr<EntryAllocator<typename EntryType::value_type>>
makeDynamicOrArenaAllocator(int MaxSize) {
if (MaxSize == INVALID_VALUE)
return llvm::make_unique<DynamicEntryAllocator<EntryType>>();
return std::make_unique<DynamicEntryAllocator<EntryType>>();
else
return llvm::make_unique<ArenaEntryAllocator<EntryType>>(MaxSize);
return std::make_unique<ArenaEntryAllocator<EntryType>>(MaxSize);
}

template <class T> class LinkedList;
Expand Down
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ add_optsched_library(OptSched
${OPTSCHED_SRCS}
LINK_LIBS ${OPTSCHED_LINK_LIBS}
)
target_compile_features(OptSched PUBLIC cxx_std_14) # We need >= C++14
add_dependencies(OptSched ${OPTSCHED_TARGET_DEPS})
4 changes: 2 additions & 2 deletions lib/Scheduler/aco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ std::unique_ptr<InstSchedule>
ACOScheduler::FindOneSchedule(InstCount TargetRPCost) {
SchedInstruction *lastInst = NULL;
std::unique_ptr<InstSchedule> schedule =
llvm::make_unique<InstSchedule>(machMdl_, dataDepGraph_, true);
std::make_unique<InstSchedule>(machMdl_, dataDepGraph_, true);
InstCount maxPriority = rdyLst_->MaxPriority();
if (maxPriority == 0)
maxPriority = 1; // divide by 0 is bad
Expand Down Expand Up @@ -671,7 +671,7 @@ void PrintSchedule(InstSchedule *schedule) {
void ACOScheduler::setInitialSched(InstSchedule *Sched) {
if (Sched) {
InitialSchedule =
llvm::make_unique<InstSchedule>(machMdl_, dataDepGraph_, VrfySched_);
std::make_unique<InstSchedule>(machMdl_, dataDepGraph_, VrfySched_);
InitialSchedule->Copy(Sched);
}
}
Expand Down
25 changes: 13 additions & 12 deletions lib/Scheduler/bb_spill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static InstCount ComputeSLILStaticLowerBound(int64_t regTypeCnt_,
// between the recursive successor list of this instruction and the
// recursive predecessors of the dependent instruction.
auto recSuccBV = inst->GetRcrsvNghbrBitVector(DIR_FRWRD);
for (Register *def : inst->GetDefs()) {
for (opt_sched::Register *def : inst->GetDefs()) {
for (const auto &dependentInst : def->GetUseList()) {
auto recPredBV = const_cast<SchedInstruction *>(dependentInst)
->GetRcrsvNghbrBitVector(DIR_BKWRD);
Expand All @@ -225,14 +225,15 @@ static InstCount ComputeSLILStaticLowerBound(int64_t regTypeCnt_,
// based on the instructions that use more than one register (defined by
// different instructions).
int commonUseLowerBound = closureLowerBound;
std::vector<std::pair<const SchedInstruction *, Register *>> usedInsts;
std::vector<std::pair<const SchedInstruction *, opt_sched::Register *>>
usedInsts;
for (int i = 0; i < dataDepGraph_->GetInstCnt(); ++i) {
const auto &inst = dataDepGraph_->GetInstByIndx(i);

// Get a list of instructions that define the registers, in array form.
usedInsts.clear();
llvm::transform(inst->GetUses(), std::back_inserter(usedInsts),
[&](Register *reg) {
[&](opt_sched::Register *reg) {
assert(reg->GetDefList().size() == 1 &&
"Number of defs for register is not 1!");
return std::make_pair(*(reg->GetDefList().begin()), reg);
Expand Down Expand Up @@ -477,7 +478,7 @@ void BBWithSpill::UpdateSpillInfoForSchdul_(SchedInstruction *inst,
#endif

// Update Live regs after uses
for (Register *use : inst->GetUses()) {
for (opt_sched::Register *use : inst->GetUses()) {
regType = use->GetType();
regNum = use->GetNum();
physRegNum = use->GetPhysicalNumber();
Expand Down Expand Up @@ -519,7 +520,7 @@ void BBWithSpill::UpdateSpillInfoForSchdul_(SchedInstruction *inst,
}

// Update Live regs after defs
for (Register *def : inst->GetDefs()) {
for (opt_sched::Register *def : inst->GetDefs()) {
regType = def->GetType();
regNum = def->GetNum();
physRegNum = def->GetPhysicalNumber();
Expand Down Expand Up @@ -575,7 +576,7 @@ void BBWithSpill::UpdateSpillInfoForSchdul_(SchedInstruction *inst,
sumOfLiveIntervalLengths_[i] += liveRegs_[i].GetOneCnt();
for (int j = 0; j < liveRegs_[i].GetSize(); ++j) {
if (liveRegs_[i].GetBit(j)) {
const Register *reg = regFiles_[i].GetReg(j);
const opt_sched::Register *reg = regFiles_[i].GetReg(j);
if (!reg->IsInInterval(inst) && !reg->IsInPossibleInterval(inst)) {
++dynamicSlilLowerBound_;
}
Expand Down Expand Up @@ -636,7 +637,7 @@ void BBWithSpill::UpdateSpillInfoForUnSchdul_(SchedInstruction *inst) {
for (int i = 0; i < regTypeCnt_; ++i) {
for (int j = 0; j < liveRegs_[i].GetSize(); ++j) {
if (liveRegs_[i].GetBit(j)) {
const Register *reg = regFiles_[i].GetReg(j);
const opt_sched::Register *reg = regFiles_[i].GetReg(j);
sumOfLiveIntervalLengths_[i]--;
if (!reg->IsInInterval(inst) && !reg->IsInPossibleInterval(inst)) {
--dynamicSlilLowerBound_;
Expand All @@ -649,7 +650,7 @@ void BBWithSpill::UpdateSpillInfoForUnSchdul_(SchedInstruction *inst) {
}

// Update Live regs
for (Register *def : inst->GetDefs()) {
for (opt_sched::Register *def : inst->GetDefs()) {
regType = def->GetType();
regNum = def->GetNum();
physRegNum = def->GetPhysicalNumber();
Expand All @@ -674,7 +675,7 @@ void BBWithSpill::UpdateSpillInfoForUnSchdul_(SchedInstruction *inst) {
//}
}

for (Register *use : inst->GetUses()) {
for (opt_sched::Register *use : inst->GetUses()) {
regType = use->GetType();
regNum = use->GetNum();
physRegNum = use->GetPhysicalNumber();
Expand Down Expand Up @@ -1091,8 +1092,8 @@ bool BBWithSpill::ChkInstLglty(SchedInstruction *inst) {
/*
int16_t regType;
int defCnt, physRegNum;
Register **defs;
Register *def, *liveDef;
opt_sched::Register **defs;
opt_sched::Register *def, *liveDef;

#ifdef IS_DEBUG_CHECK
Logger::Info("Checking inst %d %s", inst->GetNum(), inst->GetOpCode());
Expand All @@ -1111,7 +1112,7 @@ bool BBWithSpill::ChkInstLglty(SchedInstruction *inst) {
}

// Update Live regs
for (Register *def : inst->GetDefs()) {
for (opt_sched::Register *def : inst->GetDefs()) {
regType = def->GetType();
physRegNum = def->GetPhysicalNumber();

Expand Down
2 changes: 1 addition & 1 deletion lib/Scheduler/data_dep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ DataDepGraph::DataDepGraph(MachineModel *machMdl, LATENCY_PRECISION ltncyPrcsn)
entryInstCnt_ = 0;
exitInstCnt_ = 0;

RegFiles = llvm::make_unique<RegisterFile[]>(machMdl_->GetRegTypeCnt());
RegFiles = std::make_unique<RegisterFile[]>(machMdl_->GetRegTypeCnt());
}

DataDepGraph::~DataDepGraph() {
Expand Down
2 changes: 1 addition & 1 deletion lib/Scheduler/graph_trans_ilp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ StaticNodeSupILPTrans::DataAlloc::DataAlloc(DataDepGraph &DDG)
SuperiorNodesList(
createSuperiorNodesList(wrapAs2D(SuperiorArray, DDG.GetNodeCnt()))),
AddedEdges(), Stats(),
Data_(llvm::make_unique<Data>(Data{
Data_(std::make_unique<Data>(Data{
DDG,
wrapAs2D(this->DistanceTable, DDG.GetNodeCnt()),
wrapAs2D(this->SuperiorArray, DDG.GetNodeCnt()),
Expand Down
4 changes: 2 additions & 2 deletions lib/Scheduler/register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void RegisterFile::ResetCrntLngths() {

Register *RegisterFile::getNext() {
size_t RegNum = Regs.size();
auto Reg = llvm::make_unique<Register>();
auto Reg = std::make_unique<Register>();
Reg->SetType(regType_);
Reg->SetNum(RegNum);
Regs.push_back(std::move(Reg));
Expand All @@ -178,7 +178,7 @@ void RegisterFile::SetRegCnt(int regCnt) {

Regs.resize(regCnt);
for (int i = 0; i < getCount(); i++) {
auto Reg = llvm::make_unique<Register>();
auto Reg = std::make_unique<Register>();
Reg->SetType(regType_);
Reg->SetNum(i);
Regs[i] = std::move(Reg);
Expand Down
2 changes: 1 addition & 1 deletion lib/Scheduler/sched_region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static bool isBbEnabled(Config &schedIni, Milliseconds rgnTimeout) {

static void dumpDDG(DataDepGraph *DDG, llvm::StringRef DDGDumpPath,
llvm::StringRef Suffix = "") {
std::string Path = DDGDumpPath;
std::string Path(DDGDumpPath);
Path += DDG->GetDagID();

if (!Suffix.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Wrapper/AMDGPU/GCNOptSched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static cl::opt<bool>

static ScheduleDAGInstrs *createOptSchedGCN(MachineSchedContext *C) {
ScheduleDAGMILive *DAG = new ScheduleDAGOptSchedGCN(
C, llvm::make_unique<GCNMaxOccupancySchedStrategy>(C));
C, std::make_unique<GCNMaxOccupancySchedStrategy>(C));
DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
return DAG;
Expand Down
2 changes: 1 addition & 1 deletion lib/Wrapper/AMDGPU/OptSchedDDGWrapperGCN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace {

std::unique_ptr<SubRegSet>
createSubRegSet(unsigned Reg, const MachineRegisterInfo &MRI, int16_t Type) {
return llvm::make_unique<SubRegSet>(
return std::make_unique<SubRegSet>(
MRI.getMaxLaneMaskForVReg(Reg).getNumLanes(), Type);
}

Expand Down
Loading