Skip to content

Commit

Permalink
cilkgraph computation DAG generation tool
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyzzhang committed Feb 2, 2024
1 parent 3a0979d commit 0b39c12
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/include/clang/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ class LangOptions : public LangOptionsBase {
Cilktool_None = 0,
Cilktool_Cilkscale,
Cilktool_Cilkscale_InstructionCount,
Cilktool_Cilkscale_Benchmark
Cilktool_Cilkscale_Benchmark,
Cilktool_Cilkgraph
};

enum CilkVersion {
Expand Down
23 changes: 23 additions & 0 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,20 @@ static CSIOptions getCSIOptionsForCilkscaleBenchmark() {
return Options;
}

static CSIOptions getCSIOptionsForCilkgraph() {
CSIOptions Options;
// Disable CSI hooks that Cilkgraph doesn't need.
Options.InstrumentLoops = false;
// Options.InstrumentBasicBlocks = false;
Options.InstrumentMemoryAccesses = false;
Options.InstrumentCalls = false;
Options.InstrumentAtomics = false;
Options.InstrumentMemIntrinsics = false;
Options.InstrumentAllocas = false;
Options.InstrumentAllocFns = false;
return Options;
}

static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,
const CodeGenOptions &CodeGenOpts) {
TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple);
Expand Down Expand Up @@ -1096,6 +1110,15 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
MPM.addPass(PB.buildPostCilkInstrumentationPipeline(Level));
});
break;
case LangOptions::CilktoolKind::Cilktool_Cilkgraph:
PB.registerTapirLoopEndEPCallback(
[&PB](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(CSISetupPass(getCSIOptionsForCilkgraph()));
MPM.addPass(ComprehensiveStaticInstrumentationPass(
getCSIOptionsForCilkgraph()));
MPM.addPass(PB.buildPostCilkInstrumentationPipeline(Level));
});
break;
}
}
// Register the CSI pass.
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@ parseCilktoolKind(StringRef FlagName, ArgList &Args, DiagnosticsEngine &Diags) {
LangOptions::Cilktool_Cilkscale_InstructionCount)
.Case("cilkscale-benchmark",
LangOptions::Cilktool_Cilkscale_Benchmark)
.Case("cilkgraph", LangOptions::Cilktool_Cilkgraph)
.Default(LangOptions::Cilktool_None);
if (ParsedCilktool == LangOptions::Cilktool_None)
Diags.Report(diag::err_drv_invalid_value) << FlagName << Val;
Expand All @@ -1336,6 +1337,9 @@ serializeCilktoolKind(LangOptions::CilktoolKind K) {
case LangOptions::Cilktool_Cilkscale_Benchmark:
CilktoolStr = "cilkscale-benchmark";
break;
case LangOptions::Cilktool_Cilkgraph:
CilktoolStr = "cilkgraph";
break;
case LangOptions::Cilktool_None:
break;
}
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
case LangOptions::CilktoolKind::Cilktool_Cilkscale_Benchmark:
Builder.defineMacro("__cilkscale__");
break;
case LangOptions::CilktoolKind::Cilktool_Cilkgraph:
Builder.defineMacro("__cilkgraph__");
break;
default: break;
}

Expand Down

0 comments on commit 0b39c12

Please sign in to comment.