Skip to content

Commit

Permalink
Merge pull request #38 from pmccormick/release/10.x
Browse files Browse the repository at this point in the history
Updates for new cilktools
  • Loading branch information
stelleg authored Oct 13, 2021
2 parents 4c4a22d + cdad89b commit 7fc8421
Show file tree
Hide file tree
Showing 12 changed files with 875 additions and 281 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

# External projects
/cheetah
/cilktools

#==============================================================================#
# Explicit files to ignore (only matches one).
Expand Down
4 changes: 2 additions & 2 deletions kitsune/cmake/caches/kitsune-dev.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
# you are working on. By default we provide the full suite of
# clang+tools, openmp, lld, and a debugger via lldb.
set(LLVM_ENABLE_PROJECTS
clang;openmp;
clang;openmp
CACHE STRING "")

message(DEBUG " --> KITSUNE-DEV - enabled LLVM projects: ${LLVM_ENABLE_PROJECTS}")
Expand Down Expand Up @@ -63,7 +63,7 @@ set(CLANG_CONFIG_FILE_USER_DIR "$ENV{HOME}/.kitsune" CACHE STRING "")
set(CUDA_HOST_COMPILER "/usr/bin/gcc-8" CACHE STRING "")
#endif()

set(_runtimes_list "cheetah")
set(_runtimes_list "cheetah;cilktools")

# Various helpful LLVM-level settings for development/debugging.
set(LLVM_ENABLE_WARNINGS OFF CACHE BOOL "") # sometimes errors get lost in all the warnings...
Expand Down
1 change: 0 additions & 1 deletion kitsune/examples/kokkos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ set(_example_srcs

set(_example_view_srcs
raytrace.cpp
vecadd-views.cpp
)

# Build the pure-kokkos serial target version of all the examples first.
Expand Down
9 changes: 6 additions & 3 deletions llvm/include/llvm/Analysis/MemoryBuiltins.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,13 @@ inline CallInst *extractCallocCall(Value *I, const TargetLibraryInfo *TLI) {
bool isLibFreeFunction(const Function *F, const LibFunc TLIFn);

/// isFreeCall - Returns non-null if the value is a call to the builtin free()
const CallInst *isFreeCall(const Value *I, const TargetLibraryInfo *TLI);
const CallInst *isFreeCall(const Value *I, const TargetLibraryInfo *TLI,
bool IgnoreBuiltinAttr = false);

inline CallInst *isFreeCall(Value *I, const TargetLibraryInfo *TLI) {
return const_cast<CallInst*>(isFreeCall((const Value*)I, TLI));
inline CallInst *isFreeCall(Value *I, const TargetLibraryInfo *TLI,
bool IgnoreBuiltinAttr = false) {
return const_cast<CallInst *>(
isFreeCall((const Value *)I, TLI, IgnoreBuiltinAttr));
}

//===----------------------------------------------------------------------===//
Expand Down
43 changes: 26 additions & 17 deletions llvm/include/llvm/Transforms/Instrumentation/CSI.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static const char *const CsiDisableInstrumentationName =
using csi_id_t = int64_t;
static const csi_id_t CsiUnknownId = -1;
static const csi_id_t CsiCallsiteUnknownTargetId = CsiUnknownId;
// See llvm/tools/clang/lib/CodeGen/CodeGenModule.h:
// See clang/lib/CodeGen/CodeGenModule.h:
static const int CsiUnitCtorPriority = 0;

/// Maintains a mapping from CSI ID to static data for that ID.
Expand Down Expand Up @@ -803,6 +803,7 @@ class CsiLoadStoreProperty : public CsiProperty {
IntegerType::get(C, PropBits.IsConstant),
IntegerType::get(C, PropBits.IsOnStack),
IntegerType::get(C, PropBits.MayBeCaptured),
IntegerType::get(C, PropBits.IsAtomic),
IntegerType::get(C, PropBits.LoadReadBeforeWriteInBB),
IntegerType::get(C, PropBits.Padding)));
}
Expand Down Expand Up @@ -844,6 +845,8 @@ class CsiLoadStoreProperty : public CsiProperty {
void setIsOnStack(bool v) { PropValue.Fields.IsOnStack = v; }
/// Set the value of the MayBeCaptured property.
void setMayBeCaptured(bool v) { PropValue.Fields.MayBeCaptured = v; }
/// Set the value of the IsAtomic property.
void setIsAtomic(bool v) { PropValue.Fields.IsAtomic = v; }
/// Set the value of the LoadReadBeforeWriteInBB property.
void setLoadReadBeforeWriteInBB(bool v) {
PropValue.Fields.LoadReadBeforeWriteInBB = v;
Expand All @@ -858,8 +861,9 @@ class CsiLoadStoreProperty : public CsiProperty {
unsigned IsConstant : 1;
unsigned IsOnStack : 1;
unsigned MayBeCaptured : 1;
unsigned IsAtomic : 1;
unsigned LoadReadBeforeWriteInBB : 1;
uint64_t Padding : 53;
uint64_t Padding : 50;
} Fields;
uint64_t Bits;
} Property;
Expand All @@ -873,13 +877,14 @@ class CsiLoadStoreProperty : public CsiProperty {
int IsConstant;
int IsOnStack;
int MayBeCaptured;
int IsAtomic;
int LoadReadBeforeWriteInBB;
int Padding;
} PropertyBits;

/// The number of bits representing each property.
static constexpr PropertyBits PropBits = {
8, 1, 1, 1, 1, 1, (64 - 8 - 1 - 1 - 1 - 1 - 1)};
8, 1, 1, 1, 1, 1, 1, (64 - 8 - 1 - 1 - 1 - 1 - 1 - 1)};
};

class CsiAllocaProperty : public CsiProperty {
Expand Down Expand Up @@ -1049,18 +1054,6 @@ struct CSIImpl {
Options(Options) {
loadConfiguration();
}
CSIImpl(Module &M, CallGraph *CG,
function_ref<DominatorTree &(Function &)> GetDomTree,
function_ref<LoopInfo &(Function &)> GetLoopInfo,
function_ref<TaskInfo &(Function &)> GetTaskInfo,
function_ref<TargetLibraryInfo &(Function &)> GetTLI,
function_ref<ScalarEvolution &(Function &)> GetSE,
const CSIOptions &Options = CSIOptions())
: M(M), DL(M.getDataLayout()), CG(CG), GetDomTree(GetDomTree),
GetLoopInfo(GetLoopInfo), GetTaskInfo(GetTaskInfo), GetTLI(GetTLI),
GetScalarEvolution(GetSE), Options(Options) {
loadConfiguration();
}

virtual ~CSIImpl() {}

Expand All @@ -1073,7 +1066,7 @@ struct CSIImpl {
static bool isVtableAccess(Instruction *I);
static bool addrPointsToConstantData(Value *Addr);
static bool isAtomic(Instruction *I);
static void getAllocFnArgs(const Instruction *I,
static bool getAllocFnArgs(const Instruction *I,
SmallVectorImpl<Value *> &AllocFnArgs,
Type *SizeTy, Type *AddrTy,
const TargetLibraryInfo &TLI);
Expand All @@ -1095,6 +1088,9 @@ struct CSIImpl {

static bool spawnsTapirLoopBody(DetachInst *DI, LoopInfo &LI, TaskInfo &TI);

static BasicBlock::iterator
getFirstInsertionPtInDetachedBlock(BasicBlock *Detached);

protected:
/// Initialize the CSI pass.
void initializeCsi();
Expand Down Expand Up @@ -1239,6 +1235,9 @@ struct CSIImpl {
ZnwmSt11align_val_tRKSt9nothrow_t,
ZnajSt11align_val_tRKSt9nothrow_t,
ZnamSt11align_val_tRKSt9nothrow_t,
posix_memalign,
strdup,
strndup,
LAST_ALLOCFNTY
};

Expand All @@ -1250,8 +1249,8 @@ struct CSIImpl {
return AllocFnTy::malloc;
case LibFunc_valloc:
return AllocFnTy::valloc;
// aligned_alloc(align_val_t, size_t)
case LibFunc_aligned_alloc:
// aligned_alloc(align_val_t, size_t)
return AllocFnTy::aligned_alloc;
case LibFunc_calloc:
return AllocFnTy::calloc;
Expand Down Expand Up @@ -1331,6 +1330,15 @@ struct CSIImpl {
case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t:
// new[](unsigned long, align_val_t, nothrow)
return AllocFnTy::ZnamSt11align_val_tRKSt9nothrow_t;
case LibFunc_posix_memalign:
// posix_memalign(void **, size_t, size_t)
return AllocFnTy::posix_memalign;
case LibFunc_strdup:
// strdup(const char *)
return AllocFnTy::strdup;
case LibFunc_strndup:
// strdup(const char *, size_t)
return AllocFnTy::strndup;
}
}

Expand Down Expand Up @@ -1496,6 +1504,7 @@ struct CSIImpl {

DenseMap<std::pair<BasicBlock *, Function *>,
SmallVector<PHINode *, 4>> ArgPHIs;
SmallPtrSet<SyncInst *, 12> SyncsWithUnwinds;
DenseMap<BasicBlock *, CallInst *> callsAfterSync;
std::unique_ptr<InstrumentationConfig> Config;

Expand Down
17 changes: 9 additions & 8 deletions llvm/include/llvm/Transforms/Utils/TapirUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ bool isDetachedRethrow(const Instruction *I, const Value *SyncRegion = nullptr);
/// taskframe.resume uses \p TaskFrame.
bool isTaskFrameResume(const Instruction *I, const Value *TaskFrame = nullptr);

/// Returns true if the given basic block \p B is a placeholder successor of a
/// taskframe.resume or detached.rethrow.
bool isTapirPlaceholderSuccessor(const BasicBlock *B);

/// Returns a taskframe.resume that uses the given taskframe, or nullptr if no
/// taskframe.resume uses this taskframe.
InvokeInst *getTaskFrameResume(Value *TaskFrame);
Expand All @@ -61,9 +65,10 @@ bool isSyncUnwind(const Instruction *I, const Value *SyncRegion = nullptr);
/// instructions.
bool isPlaceholderSuccessor(const BasicBlock *B);

/// Returns true if the given basic block ends a taskframe, false otherwise. If
/// \p TaskFrame is specified, then additionally checks that the
/// taskframe.end uses \p TaskFrame.
/// Returns true if the given basic block ends a taskframe, false otherwise. In
/// particular, this method checks if the penultimate instruction in the basic
/// block is a taskframe.end intrinsic call. If \p TaskFrame is specified, then
/// additionally checks that the taskframe.end uses \p TaskFrame.
bool endsTaskFrame(const BasicBlock *B, const Value *TaskFrame = nullptr);

/// Returns the spindle containing the taskframe.create used by task \p T, or
Expand Down Expand Up @@ -218,7 +223,6 @@ class TapirLoopHints {
enum SpawningStrategy {
ST_SEQ,
ST_DAC,
ST_OCL,
ST_END,
};

Expand Down Expand Up @@ -260,12 +264,9 @@ class TapirLoopHints {
return "Spawn iterations sequentially";
case TapirLoopHints::ST_DAC:
return "Use divide-and-conquer";
case TapirLoopHints::ST_OCL:
return "Use opencl";
case TapirLoopHints::ST_END:
return "Unknown";
}
return "Unknown";
}

TapirLoopHints(const Loop *L)
Expand Down Expand Up @@ -310,7 +311,7 @@ class TapirLoopHints {
}

void setAlreadyStripMined() {
//Grainsize.Value = 1;
Grainsize.Value = 1;
Hint Hints[] = {Grainsize};
writeHintsToMetadata(Hints);
}
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Analysis/MemoryBuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,12 @@ bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
}

/// isFreeCall - Returns non-null if the value is a call to the builtin free()
const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI,
bool IgnoreBuiltinAttr) {
bool IsNoBuiltinCall;
const Function *Callee =
getCalledFunction(I, /*LookThroughBitCast=*/false, IsNoBuiltinCall);
if (Callee == nullptr || IsNoBuiltinCall)
if (Callee == nullptr || (IsNoBuiltinCall && !IgnoreBuiltinAttr))
return nullptr;

StringRef FnName = Callee->getName();
Expand Down
Loading

0 comments on commit 7fc8421

Please sign in to comment.