Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8d13f7c
vect-instructions: new tool/rlc/test/examples/vectorization folder wi…
pollo-fritto Apr 6, 2025
0f7c021
vect-instructions: void version of red and vector_sum
pollo-fritto Apr 6, 2025
6755515
vect-instructions: enabled slp-vectorizer pass
pollo-fritto Apr 13, 2025
1d7ce93
dictionary vectorization attempts
pollo-fritto Apr 24, 2025
3f93097
vect-instructions: dictionary vect attempt with opt -O3, moved pipeli…
pollo-fritto Apr 25, 2025
f27f9c4
vect-instructions: compiled dict.rl with -g, now opt remarks have fil…
pollo-fritto Apr 25, 2025
10d7b20
vect-instructions: added to BackEnd.cpp:runOptimizer() identification…
pollo-fritto Apr 27, 2025
cf0de32
vect-instructions: update runOptimizer()
pollo-fritto May 4, 2025
66995b8
vect-instructions: Add script to merge .csv, increment size of Dict I…
pollo-fritto May 10, 2025
c2e024c
vect-instructions: add SoA_dictionary and dict-soa test, edit merge_b…
pollo-fritto May 25, 2025
17f647d
vect-instructions: update merge_bench.sh, Conversion.cpp for noalias
pollo-fritto May 26, 2025
b58628e
vect-instructions: Edit SoA_dictionary: _insert() vectorized
pollo-fritto May 27, 2025
2163921
vect-instructions: SoA Dict Fix vectorized functions and vectorize more
May 29, 2025
7bd6485
vect-instructions: update Soa_dictionary: get() contains() and remove…
pollo-fritto Jun 2, 2025
4ec6e95
vect-instructions: soa_dictionary testing
pollo-fritto Aug 17, 2025
ae600be
vect-instructions: trying to vectorize get and remove
pollo-fritto Aug 24, 2025
9883f04
vect-instr: code cleanup
pollo-fritto Aug 27, 2025
169eb45
vect-instr: file cleanup
pollo-fritto Aug 27, 2025
a6412bb
remove merge_benchs.sh
pollo-fritto Jan 10, 2026
76b28e4
remove default attributes
pollo-fritto Jan 10, 2026
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
106 changes: 56 additions & 50 deletions lib/backend/src/BackEnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,48 @@ class AddWindowsDLLExportPass: public PassInfoMixin<AddWindowsDLLExportPass>
};
};

struct mlir::rlc::TargetInfoImpl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know that this is probably due to the rebase, but does this piece of code really need to be moved away from its original location?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need it to be before runOptimizer() because one of its arguments has this structure type

{
public:
TargetInfoImpl(std::string triple, bool shared, bool optimize)
: triple(triple),
optimize(
optimize ? CodeGenOptLevel::Aggressive : CodeGenOptLevel::Default),
reloc(shared ? llvm::Reloc::PIC_ : llvm::Reloc::Static)
{
std::string Error;
target = llvm::TargetRegistry::lookupTarget("", this->triple, Error);
assert(target);
options = llvm::codegen::InitTargetOptionsFromCodeGenFlags(this->triple);

auto *Ptr = target->createTargetMachine(
this->triple.getTriple(),
"",
"",
options,
reloc,
llvm::CodeModel::Large,
this->optimize);
targetMachine = unique_ptr<TargetMachine>(Ptr);

datalayout =
std::make_unique<llvm::DataLayout>(targetMachine->createDataLayout());
}

llvm::Triple triple;
llvm::CodeModel::Model model;
llvm::CodeGenOptLevel optimize;
llvm::Reloc::Model reloc;
const llvm::Target *target;
llvm::TargetOptions options;
std::unique_ptr<llvm::TargetMachine> targetMachine;
std::unique_ptr<llvm::DataLayout> datalayout;
};

static const bool printTimings = false;

static void runOptimizer(
const mlir::rlc::TargetInfoImpl &pimpl,
llvm::Module &M,
bool optimize,
bool emitSanitizerInstrumentation,
Expand All @@ -144,17 +183,22 @@ static void runOptimizer(
if (printTimings)
TimePasses->registerCallbacks(PIC);


// Create the analysis managers.
LoopAnalysisManager LAM;
FunctionAnalysisManager FAM;
CGSCCAnalysisManager CGAM;
ModuleAnalysisManager MAM;

PipelineTuningOptions PTO;
// If !optimize this will be discarded
PTO.SLPVectorization = true;

// Create the new pass manager builder.
// Take a look at the PassBuilder constructor parameters for more
// customization, e.g. specifying a TargetMachine or various debugging
// options.
PassBuilder PB(nullptr, llvm::PipelineTuningOptions(), std::nullopt, &PIC);
PassBuilder PB(pimpl.targetMachine.get(), PTO, std::nullopt, &PIC);

// Register all the basic analyses with the managers.
PB.registerModuleAnalyses(MAM);
Expand All @@ -165,73 +209,35 @@ static void runOptimizer(

// Create the pass manager.
// This one corresponds to a typical -O2 optimization pipeline.
ModulePassManager MPM;

if (optimize)
{
ModulePassManager passManager;
FunctionPassManager functionPassManager;
MPM = PB.buildPerModuleDefaultPipeline(OptimizationLevel::O2);
if (targetIsWindows)
functionPassManager.addPass(AddWindowsDLLExportPass());
functionPassManager.addPass(llvm::PromotePass());
passManager.addPass(
MPM.addPass(
createModuleToFunctionPassAdaptor(std::move(functionPassManager)));
if (emitSanitizerInstrumentation and not targetIsWindows)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is something going on here that happen probably due to the rebasing. it seem that ode that was there before has been accidentally removed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These instructions were repeated in both branches' end, I just moved them down

addFuzzerInstrumentationPass(passManager);
passManager.run(M, MAM);

PB.buildPerModuleDefaultPipeline(OptimizationLevel::O2).run(M, MAM);
}
else
{
ModulePassManager MPM = PB.buildO0DefaultPipeline(
MPM = PB.buildO0DefaultPipeline(
OptimizationLevel::O0, ThinOrFullLTOPhase::None);
if (targetIsWindows)
MPM.addPass(createModuleToFunctionPassAdaptor(AddWindowsDLLExportPass()));
if (emitSanitizerInstrumentation and not targetIsWindows)
addFuzzerInstrumentationPass(MPM);
MPM.run(M, MAM);
}

if (emitSanitizerInstrumentation and not targetIsWindows)
addFuzzerInstrumentationPass(MPM);

MPM.run(M, MAM);

if (printTimings)
TimePasses->print();
}

struct mlir::rlc::TargetInfoImpl
{
public:
TargetInfoImpl(std::string triple, bool shared, bool optimize)
: triple(triple),
optimize(
optimize ? CodeGenOptLevel::Aggressive : CodeGenOptLevel::Default),
reloc(shared ? llvm::Reloc::PIC_ : llvm::Reloc::Static)
{
std::string Error;
target = llvm::TargetRegistry::lookupTarget("", this->triple, Error);
assert(target);
options = llvm::codegen::InitTargetOptionsFromCodeGenFlags(this->triple);

auto *Ptr = target->createTargetMachine(
this->triple.getTriple(),
"",
"",
options,
reloc,
llvm::CodeModel::Large,
this->optimize);
targetMachine = unique_ptr<TargetMachine>(Ptr);

datalayout =
std::make_unique<llvm::DataLayout>(targetMachine->createDataLayout());
}

llvm::Triple triple;
llvm::CodeModel::Model model;
llvm::CodeGenOptLevel optimize;
llvm::Reloc::Model reloc;
const llvm::Target *target;
llvm::TargetOptions options;
std::unique_ptr<llvm::TargetMachine> targetMachine;
std::unique_ptr<llvm::DataLayout> datalayout;
};

mlir::rlc::TargetInfo::TargetInfo(
std::string triple, bool shared, bool optimize)
Expand Down Expand Up @@ -556,7 +562,7 @@ namespace mlir::rlc
assert(Module);
Module->setTargetTriple(targetInfo->triple());

runOptimizer(
runOptimizer(*targetInfo->pimpl,
*Module,
targetInfo->optimize(),
emitSanitizer,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/benchmark/src/DictIntBenchBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static std::random_device rd;
static std::mt19937 gen(rd());

constexpr std::size_t minRange = 1 << 2;
constexpr std::size_t maxRange = 1 << 10;
constexpr std::size_t maxRange = 1 << 20;

// Helper function to generate random unique integers
static std::vector<int64_t> GenerateRandomIntegers(int n)
Expand Down
Loading