forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clacc] Merge branch 'main' into clacc/main
This merge brings in the following commits from upstream: * 307bbd3, 4e34f06, b316126: These commits fix some exclusive access and race issues in libomptarget. Many conflicts with Clacc's implementation result: * They make significant changes to the `HostDataToTargetMap` data structure in `openmp/libomptarget/include/device.h` and thus update code within `device.cpp`, `omptarget.cpp`, etc. Parts of Clacc's OMPT offload prototype appear here. This merge resolves conflicts in favor of upstream and then reapplies Clacc's changes based on the new data structure. This merge also updates Clacc's `lookupHostPtr` and `getAccessibleBuffer` implementation in `device.cpp` to use the new `HostDataToTargetMap` interface. * They rearrange `InitLibrary` in `openmp/libomptarget/src/omptarget.cpp`. Clacc adds an OMPT offload callback here. This merge resolves conflicts in favor of upstream and then reinserts the OMPT callback. * They replace `DeallocTgtPtrInfo` with `PostProcessingInfo` in `openmp/libomptarget/src/omptarget.cpp`. Clacc adds `HstPtrName` field to `DeallocTgtPtrInfo` for OMPT support and thus to related `emplace_back` calls. However, that's now available via `PostProcessingInfo`'s `TPR` field, so this merge drops Clacc's change here. * They rewrite `targetDataEnd` in `openmp/libomptarget/src/omptarget.cpp`. Clacc instantiates an `OmptMapVarInfoRAII` before the `Device.deallocTgtPtr` call there. This merge resolves conflicts in favor of upstream and adds back the `OmptMapVarInfoRAII` instantiation. * As a drive-by fix, this merge adds `TIMESCOPE` calls to Clacc's implementations for `omp_target_is_accessible`, `omp_get_mapped_ptr`, `omp_get_mapped_hostptr`, and `omp_get_accessible_buffer`. * c1a6fe1: This commit changes the way mapped variables are looked up in libomptarget: * An effect is that, if `arr[N:M]` is currently mapped, then `omp_target_is_present` now returns true and `omp_get_mapped_ptr` now returns a non-null device pointer when passed a host pointer within `arr[0:N]`. * Whether this new behavior is correct is being discussed in <llvm#54899> and at <omp-lang@openmp.org>. No consensus has yet been reached. * The behavior of Clacc's implementations of `omp_target_is_accessible` and `omp_get_accessible_buffer` (a Clacc extension) are also affected for the case of size=0. This merge updates comments on those to explain the issue. * The above OpenMP behavior changes affect Clacc's implementation of `acc_is_present` and `acc_deviceptr`. This merge updates comments on those (and related comments on `acc_hostptr`) and adjusts their implementations so that they are immune to the OpenMP behavior change, even if it is later reverted. It also adjusts the implementation of `checkPresence` in `api.cpp` so it is immune as well, but this adjustment is currently NFC, as explained in the new comments there. * This merge updates references to the OpenACC and OpenMP specs in many related comments. * 79f661e, 6bd8dc9, 2cedaee, and f82ec55: These commits define new AST `Stmt` nodes (for the OpenMP loop construct) and thus insert new enumerators into `CXCursorKind` immediately before `CXCursor_LastStmt`. Clacc does the same. This merges combines those, keeping Clacc's enumerators last. * Various commits with which this merge resolves contextual conflicts.
- Loading branch information
Showing
13,951 changed files
with
666,445 additions
and
332,457 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//===- bolt/Passes/CMOVConversion.h ----------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This pass finds the following patterns: | ||
// jcc | ||
// / \ | ||
// (empty) mov src, dst | ||
// \ / | ||
// | ||
// and replaces them with: | ||
// | ||
// cmovcc src, dst | ||
// | ||
// The advantage of performing this conversion in BOLT (compared to compiler | ||
// heuristic driven instruction selection) is that BOLT can use LBR | ||
// misprediction information and only convert poorly predictable branches. | ||
// Note that branch misprediction rate is different from branch bias. | ||
// For well-predictable branches, it might be beneficial to leave jcc+mov as is | ||
// from microarchitectural perspective to avoid unneeded dependencies (CMOV | ||
// instruction has a dataflow dependence on flags and both operands). | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef BOLT_PASSES_CMOVCONVERSION_H | ||
#define BOLT_PASSES_CMOVCONVERSION_H | ||
|
||
#include "bolt/Passes/BinaryPasses.h" | ||
|
||
namespace llvm { | ||
namespace bolt { | ||
|
||
/// Pass for folding eligible hammocks into CMOV's if profitable. | ||
class CMOVConversion : public BinaryFunctionPass { | ||
struct Stats { | ||
/// Record how many possible cases there are. | ||
uint64_t StaticPossible = 0; | ||
uint64_t DynamicPossible = 0; | ||
|
||
/// Record how many cases were converted. | ||
uint64_t StaticPerformed = 0; | ||
uint64_t DynamicPerformed = 0; | ||
|
||
/// Record how many mispredictions were eliminated. | ||
uint64_t PossibleMP = 0; | ||
uint64_t RemovedMP = 0; | ||
|
||
Stats operator+(const Stats &O) { | ||
StaticPossible += O.StaticPossible; | ||
DynamicPossible += O.DynamicPossible; | ||
StaticPerformed += O.StaticPerformed; | ||
DynamicPerformed += O.DynamicPerformed; | ||
PossibleMP += O.PossibleMP; | ||
RemovedMP += O.RemovedMP; | ||
return *this; | ||
} | ||
double getStaticRatio() { return (double)StaticPerformed / StaticPossible; } | ||
double getDynamicRatio() { | ||
return (double)DynamicPerformed / DynamicPossible; | ||
} | ||
double getMPRatio() { return (double)RemovedMP / PossibleMP; } | ||
|
||
void dump(); | ||
}; | ||
// BinaryContext-wide stats | ||
Stats Global; | ||
|
||
void runOnFunction(BinaryFunction &Function); | ||
|
||
public: | ||
explicit CMOVConversion() : BinaryFunctionPass(false) {} | ||
|
||
const char *getName() const override { return "CMOV conversion"; } | ||
|
||
void runOnFunctions(BinaryContext &BC) override; | ||
}; | ||
|
||
} // namespace bolt | ||
} // namespace llvm | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.