Skip to content

Commit 53e037c

Browse files
vmustyapszymich
authored andcommitted
Put VC SPIR-V and build options into ZE binary
.
1 parent fca818b commit 53e037c

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

IGC/VectorCompiler/igcdeps/include/vc/igcdeps/cmc.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ class CGen8CMProgram : public iOpenCL::CGen8OpenCLProgramBase {
126126
bool KernelIsDebuggable = false;
127127
};
128128

129-
explicit CGen8CMProgram(PLATFORM platform, const WA_TABLE& WATable);
129+
explicit CGen8CMProgram(PLATFORM platform, const WA_TABLE &WATable,
130+
llvm::ArrayRef<char> SPIRV = llvm::None,
131+
llvm::Optional<llvm::StringRef> Opts = llvm::None);
130132

131133
// Produce the final ELF binary with the given CM kernels
132134
// in OpenCL format.
@@ -148,6 +150,9 @@ class CGen8CMProgram : public iOpenCL::CGen8OpenCLProgramBase {
148150
std::string m_ErrorLog;
149151

150152
private:
153+
llvm::ArrayRef<char> m_spirv;
154+
llvm::Optional<llvm::StringRef> m_opts;
155+
151156
TmpFilesStorage extractRawDebugInfo(llvm::raw_ostream &ErrStream);
152157
std::unique_ptr<llvm::MemoryBuffer> buildZeDebugInfo();
153158
};

IGC/VectorCompiler/igcdeps/src/PatchTokens.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ struct DebugInfo {
2727
};
2828

2929
// Implementation of CGen8CMProgram.
30-
CGen8CMProgram::CGen8CMProgram(PLATFORM platform, const WA_TABLE& WATable)
30+
CGen8CMProgram::CGen8CMProgram(PLATFORM platform, const WA_TABLE &WATable,
31+
llvm::ArrayRef<char> SPIRV,
32+
llvm::Optional<llvm::StringRef> Opts)
3133
: CGen8OpenCLProgramBase(platform, m_ContextProvider, WATable),
32-
m_programInfo(new IGC::SOpenCLProgramInfo) {}
33-
34+
m_programInfo(new IGC::SOpenCLProgramInfo), m_spirv(SPIRV), m_opts(Opts) {
35+
}
3436

3537
TmpFilesStorage
3638
CGen8CMProgram::extractRawDebugInfo(llvm::raw_ostream &ErrStream) {
@@ -180,8 +182,20 @@ void CGen8CMProgram::GetZEBinary(llvm::raw_pwrite_stream &programBinary,
180182
// Contains buffer to an optional debug info. Should exists till zebuilder
181183
// is destroyed.
182184
std::unique_ptr<llvm::MemoryBuffer> DebugInfoHolder;
183-
iOpenCL::ZEBinaryBuilder zebuilder{m_Platform, pointerSizeInBytes == 8,
184-
*m_programInfo, nullptr, 0, nullptr, 0, nullptr, 0};
185+
186+
const uint8_t *SpirvData = reinterpret_cast<const uint8_t *>(m_spirv.data());
187+
size_t SpirvSize = m_spirv.size();
188+
189+
const uint8_t *OptsData = nullptr;
190+
size_t OptsSize = 0;
191+
if (m_opts) {
192+
OptsData = reinterpret_cast<const uint8_t *>(m_opts->data());
193+
OptsSize = m_opts->size();
194+
}
195+
196+
iOpenCL::ZEBinaryBuilder zebuilder(m_Platform, pointerSizeInBytes == 8,
197+
*m_programInfo, SpirvData, SpirvSize,
198+
nullptr, 0, OptsData, OptsSize);
185199
zebuilder.setGfxCoreFamily(m_Platform.eRenderCoreFamily);
186200

187201
for (const auto &kernel : m_kernels) {

IGC/VectorCompiler/igcdeps/src/TranslationInterface.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ parseOptions(vc::ShaderDumper &Dumper, llvm::StringRef ApiOptions,
478478
RawInputDumper.release();
479479
InputDumper.release();
480480
}
481+
if (ExpOptions)
482+
ExpOptions->ApiOptions = ApiOptions.str();
481483
return std::move(ExpOptions);
482484
}
483485

@@ -683,7 +685,8 @@ std::error_code vc::translateBuild(const TC::STB_TranslateInputArgs *InputArgs,
683685
case vc::BinaryKind::ZE: {
684686
auto &CompileResult = std::get<vc::ocl::CompileOutput>(Res);
685687
vc::CGen8CMProgram CMProgram{IGCPlatform.getPlatformInfo(),
686-
IGCPlatform.getWATable()};
688+
IGCPlatform.getWATable(), Input,
689+
llvm::StringRef(Opts.ApiOptions)};
687690
vc::createBinary(CMProgram, CompileResult);
688691
llvm::SmallVector<char, 0> ProgramBinary;
689692
llvm::raw_svector_ostream ProgramBinaryOS{ProgramBinary};

IGC/VectorCompiler/include/vc/Driver/Driver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ struct CompileOptions {
6868
// Optional Shader Overrider
6969
std::unique_ptr<vc::ShaderOverrider> ShaderOverrider = nullptr;
7070

71+
std::string ApiOptions;
72+
7173
// Output binary format
7274
// API options:
7375
// -[cl,ze]-enable-zebin

0 commit comments

Comments
 (0)