Skip to content
Merged
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
18 changes: 12 additions & 6 deletions llvm/include/llvm/SYCLPostLink/ModuleSplitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/SYCLLowerIR/SYCLDeviceRequirements.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/PropertySetIO.h"

Expand Down Expand Up @@ -238,8 +239,11 @@ class ModuleDesc {

#ifndef NDEBUG
void verifyESIMDProperty() const;
void dump() const;
#endif // NDEBUG

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
#endif
};

// Module split support interface.
Expand Down Expand Up @@ -303,11 +307,13 @@ getDeviceCodeSplitter(ModuleDesc &&MD, IRSplitMode Mode, bool IROutputOnly,
bool EmitOnlyKernelsAsEntryPoints,
bool AllowDeviceImageDependencies);

#ifndef NDEBUG
void dumpEntryPoints(const EntryPointSet &C, const char *Msg = "", int Tab = 0);
void dumpEntryPoints(const Module &M, bool OnlyKernelsAreEntryPoints = false,
const char *Msg = "", int Tab = 0);
#endif // NDEBUG
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dumpEntryPoints(const EntryPointSet &C,
const char *Msg = "", int Tab = 0);
LLVM_DUMP_METHOD void dumpEntryPoints(const Module &M,
bool OnlyKernelsAreEntryPoints = false,
const char *Msg = "", int Tab = 0);
#endif

struct SplitModule {
std::string ModuleFilePath;
Expand Down
16 changes: 1 addition & 15 deletions llvm/lib/SYCLPostLink/ESIMDPostSplitProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,6 @@
#include <string>
#include <vector>

#ifdef NDEBUG
#define DUMP_ENTRY_POINTS(...)
#else
constexpr int DebugESIMDPostSplit = 0;

#define DUMP_ENTRY_POINTS(...) \
if (DebugESIMDPostSplit > 0) { \
llvm::module_split::dumpEntryPoints(__VA_ARGS__); \
}
#endif // NDEBUG

using namespace llvm;
using namespace llvm::module_split;

Expand Down Expand Up @@ -134,11 +123,9 @@ llvm::sycl::handleESIMD(ModuleDesc MDesc,

SplitOccurred |= Result.size() > 1;

for (ModuleDesc &MD : Result) {
DUMP_ENTRY_POINTS(MD.entries(), MD.Name.c_str(), 4);
for (ModuleDesc &MD : Result)
if (Options.LowerESIMD && MD.isESIMD())
Modified |= lowerESIMDConstructs(MD, Options);
}

if (Options.SplitESIMD || Result.size() == 1)
return std::move(Result);
Expand All @@ -164,7 +151,6 @@ llvm::sycl::handleESIMD(ModuleDesc MDesc,
Linked.rebuildEntryPoints(Names);
Result.clear();
Result.emplace_back(std::move(Linked));
DUMP_ENTRY_POINTS(Result.back().entries(), Result.back().Name.c_str(), 4);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just double checking that we don't need this anymore, not even under the appropriate ifdefs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could use LLVM_DEBUG(...) for that. I just don't know whether anyone really needs that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm good with removing it, just wanted to make sure it was intended.

Modified = true;

return std::move(Result);
Expand Down
102 changes: 51 additions & 51 deletions llvm/lib/SYCLPostLink/ModuleSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,55 +561,6 @@ Error ModuleSplitterBase::verifyNoCrossModuleDeviceGlobalUsage() {
return Error::success();
}

#ifndef NDEBUG

const char *toString(SyclEsimdSplitStatus S) {
switch (S) {
case SyclEsimdSplitStatus::ESIMD_ONLY:
return "ESIMD_ONLY";
case SyclEsimdSplitStatus::SYCL_ONLY:
return "SYCL_ONLY";
case SyclEsimdSplitStatus::SYCL_AND_ESIMD:
return "SYCL_AND_ESIMD";
}
return "<UNKNOWN_STATUS>";
}

void tab(int N) {
for (int I = 0; I < N; ++I) {
llvm::errs() << " ";
}
}

void dumpEntryPoints(const EntryPointSet &C, const char *msg, int Tab) {
tab(Tab);
llvm::errs() << "ENTRY POINTS"
<< " " << msg << " {\n";
for (const Function *F : C) {
tab(Tab);
llvm::errs() << " " << F->getName() << "\n";
}
tab(Tab);
llvm::errs() << "}\n";
}

void dumpEntryPoints(const Module &M, bool OnlyKernelsAreEntryPoints,
const char *msg, int Tab) {
tab(Tab);
llvm::errs() << "ENTRY POINTS (Module)"
<< " " << msg << " {\n";
for (const auto &F : M) {
if (isEntryPoint(F, OnlyKernelsAreEntryPoints)) {
tab(Tab);
llvm::errs() << " " << F.getName() << "\n";
}
}
tab(Tab);
llvm::errs() << "}\n";
}

#endif // NDEBUG

void ModuleDesc::assignMergedProperties(const ModuleDesc &MD1,
const ModuleDesc &MD2) {
EntryPoints.Props = MD1.EntryPoints.Props.merge(MD2.EntryPoints.Props);
Expand Down Expand Up @@ -847,16 +798,65 @@ void ModuleDesc::verifyESIMDProperty() const {
// }
//}
}
#endif // NDEBUG

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD const char *toString(SyclEsimdSplitStatus S) {
switch (S) {
case SyclEsimdSplitStatus::ESIMD_ONLY:
return "ESIMD_ONLY";
case SyclEsimdSplitStatus::SYCL_ONLY:
return "SYCL_ONLY";
case SyclEsimdSplitStatus::SYCL_AND_ESIMD:
return "SYCL_AND_ESIMD";
}
return "<UNKNOWN_STATUS>";
}

void ModuleDesc::dump() const {
LLVM_DUMP_METHOD void tab(int N) {
for (int I = 0; I < N; ++I) {
llvm::errs() << " ";
}
}

LLVM_DUMP_METHOD void dumpEntryPoints(const EntryPointSet &C, const char *msg,
int Tab) {
tab(Tab);
llvm::errs() << "ENTRY POINTS"
<< " " << msg << " {\n";
for (const Function *F : C) {
tab(Tab);
llvm::errs() << " " << F->getName() << "\n";
}
tab(Tab);
llvm::errs() << "}\n";
}

LLVM_DUMP_METHOD void dumpEntryPoints(const Module &M,
bool OnlyKernelsAreEntryPoints,
const char *msg, int Tab) {
tab(Tab);
llvm::errs() << "ENTRY POINTS (Module)"
<< " " << msg << " {\n";
for (const auto &F : M) {
if (isEntryPoint(F, OnlyKernelsAreEntryPoints)) {
tab(Tab);
llvm::errs() << " " << F.getName() << "\n";
}
}
tab(Tab);
llvm::errs() << "}\n";
}

LLVM_DUMP_METHOD void ModuleDesc::dump() const {
llvm::errs() << "split_module::ModuleDesc[" << Name << "] {\n";
llvm::errs() << " ESIMD:" << toString(EntryPoints.Props.HasESIMD)
<< ", SpecConstMet:" << (Props.SpecConstsMet ? "YES" : "NO")
<< "\n";
dumpEntryPoints(entries(), EntryPoints.GroupId.c_str(), 1);
llvm::errs() << "}\n";
}
#endif // NDEBUG
#endif

void ModuleDesc::saveSplitInformationAsMetadata() {
// Add metadata to the module so we can identify what kind of SYCL/ESIMD split
Expand Down