Skip to content

Commit aa9b484

Browse files
PiotrFusiksys_zuul
authored andcommitted
Introduce ExtraOCLOptions debug key.
Change-Id: I956d7b395dbab4614ca098fd6a9cd7bfdc160a2a
1 parent 0a907cc commit aa9b484

File tree

3 files changed

+48
-29
lines changed

3 files changed

+48
-29
lines changed

IGC/AdaptorOCL/ocl_igc_interface/impl/igc_ocl_translation_ctx_impl.h

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ CIF_DECLARE_INTERFACE_PIMPL(IgcOclTranslationCtx) : CIF::PimplBase
177177
inputArgs.InputSize = static_cast<uint32_t>(src->GetSizeRaw());
178178
}
179179
if(options != nullptr){
180-
inputArgs.pOptions = options->GetMemory<char>();
180+
inputArgs.pOptions = options->GetMemory<char>();
181181
inputArgs.OptionsSize = static_cast<uint32_t>(options->GetSizeRaw());
182182
}
183183
if(internalOptions != nullptr){
@@ -205,16 +205,15 @@ CIF_DECLARE_INTERFACE_PIMPL(IgcOclTranslationCtx) : CIF::PimplBase
205205
TC::STB_TranslateOutputArgs output;
206206
CIF::SafeZeroOut(output);
207207

208-
std::string RegKeysFlagsFromOptions = "";
209-
if (inputArgs.pOptions != NULL)
208+
std::string RegKeysFlagsFromOptions;
209+
if (inputArgs.pOptions != nullptr)
210210
{
211-
const std::string& igc_optsName = "-igc_opts";
212-
const std::string& optionsWithFlags = (const char*)inputArgs.pOptions;
213-
std::size_t found = optionsWithFlags.find(igc_optsName);
211+
const std::string optionsWithFlags = inputArgs.pOptions;
212+
std::size_t found = optionsWithFlags.find("-igc_opts");
214213
if (found != std::string::npos)
215214
{
216-
std::size_t foundFirstSingleQuote = optionsWithFlags.find("'", found);
217-
std::size_t foundSecondSingleQuote = optionsWithFlags.find("'", foundFirstSingleQuote + 1);
215+
std::size_t foundFirstSingleQuote = optionsWithFlags.find('\'', found);
216+
std::size_t foundSecondSingleQuote = optionsWithFlags.find('\'', foundFirstSingleQuote + 1);
218217
if (foundFirstSingleQuote != std::string::npos && foundSecondSingleQuote)
219218
{
220219
RegKeysFlagsFromOptions = optionsWithFlags.substr(foundFirstSingleQuote + 1, (foundSecondSingleQuote - foundFirstSingleQuote - 1));
@@ -226,6 +225,19 @@ CIF_DECLARE_INTERFACE_PIMPL(IgcOclTranslationCtx) : CIF::PimplBase
226225
LoadRegistryKeys(RegKeysFlagsFromOptions, &RegFlagNameError);
227226
if(RegFlagNameError) outputInterface->GetImpl()->SetError(TranslationErrorType::Unused, "Invalid registry flag name in -igc_opts, at least one flag has been ignored");
228227

228+
const char *extraOptions = IGC_GET_REGKEYSTRING(ExtraOCLOptions);
229+
std::string combinedOptions;
230+
if (extraOptions[0] != '\0')
231+
{
232+
if (inputArgs.pOptions != nullptr)
233+
{
234+
combinedOptions = std::string(inputArgs.pOptions) + ' ';
235+
}
236+
combinedOptions += extraOptions;
237+
inputArgs.pOptions = combinedOptions.c_str();
238+
inputArgs.OptionsSize = combinedOptions.size();
239+
}
240+
229241
bool success = false;
230242
if (this->inType == CodeType::elf)
231243
{

IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,15 @@ namespace TC
923923
{
924924
pClangArgs->options.assign(pOptions);
925925
}
926+
#if defined(IGC_DEBUG_VARIABLES)
927+
char debugOptions[1024];
928+
if (FCL::FCLReadIGCRegistry("ExtraOCLOptions", debugOptions, sizeof(debugOptions)))
929+
{
930+
if (!pClangArgs->options.empty())
931+
pClangArgs->options += ' ';
932+
pClangArgs->options += debugOptions;
933+
}
934+
#endif
926935

927936
GetOclCVersionFromOptions(pOptions, pInternalOptions, pClangArgs->oclVersion, exceptString);
928937
EnsureProperPCH(pClangArgs, pInternalOptions, exceptString);
@@ -967,7 +976,7 @@ namespace TC
967976
if (pData != NULL)
968977
{
969978
assert(pData[uiDataSize - 1] == '\0' && "Program source is not null terminated");
970-
pClangArgs->pszProgramSource = (const char *)pData;
979+
pClangArgs->pszProgramSource = pData;
971980
}
972981
}
973982

@@ -1008,27 +1017,25 @@ namespace TC
10081017

10091018
if (!extensions.empty())
10101019
{
1011-
output << "-cl-ext=-all,";
1012-
output << "+" << extensions[0];
1020+
output << "-cl-ext=-all";
1021+
for (const std::string &extension : extensions)
1022+
output << ",+" << extension;
10131023
}
10141024

1015-
for (unsigned i = 1; i < extensions.size(); i++)
1016-
output << ",+" << extensions[i];
1017-
10181025
output.flush();
10191026
return output.str();
10201027
}
10211028

10221029
std::string GetListOfExtensionsFromInternalOptions(const std::string& internalOptions) {
1023-
size_t start_pos = 0, end_pos = 0;
1024-
std::string clextString = "";
1030+
size_t start_pos = 0, end_pos = 0;
1031+
std::string clextString = "";
10251032

1026-
while ((start_pos = internalOptions.find("-cl-ext=", end_pos)) != std::string::npos) {
1027-
end_pos = internalOptions.find(" ", start_pos);
1028-
clextString += internalOptions.substr(start_pos, end_pos - start_pos) + " ";
1029-
}
1033+
while ((start_pos = internalOptions.find("-cl-ext=", end_pos)) != std::string::npos) {
1034+
end_pos = internalOptions.find(' ', start_pos);
1035+
clextString += internalOptions.substr(start_pos, end_pos - start_pos) + " ";
1036+
}
10301037

1031-
return clextString;
1038+
return clextString;
10321039
}
10331040

10341041
std::string GetCDefinesFromInternalOptions(const char *pInternalOptions) {
@@ -1761,15 +1768,14 @@ namespace TC
17611768
bool successTC = TranslateClang(&args, pOutputArgs, exceptString, pInputArgs->pInternalOptions);
17621769

17631770
#if defined(IGC_DEBUG_VARIABLES)
1764-
if (pInputArgs->pOptions != NULL)
1771+
if (pInputArgs->pOptions != nullptr)
17651772
{
1766-
const std::string& igc_optsName = "-igc_opts";
1767-
const std::string& optionsWithFlags = (const char*)pInputArgs->pOptions;
1768-
std::size_t found = optionsWithFlags.find(igc_optsName);
1773+
const std::string optionsWithFlags = pInputArgs->pOptions;
1774+
std::size_t found = optionsWithFlags.find("-igc_opts");
17691775
if (found != std::string::npos)
17701776
{
1771-
std::size_t foundFirstSingleQuote = optionsWithFlags.find("'", found);
1772-
std::size_t foundSecondSingleQuote = optionsWithFlags.find("'", foundFirstSingleQuote + 1);
1777+
std::size_t foundFirstSingleQuote = optionsWithFlags.find('\'', found);
1778+
std::size_t foundSecondSingleQuote = optionsWithFlags.find('\'', foundFirstSingleQuote + 1);
17731779
if (foundFirstSingleQuote != std::string::npos && foundSecondSingleQuote != std::string::npos)
17741780
{
17751781
FCL::RegKeysFlagsFromOptions = optionsWithFlags.substr(foundFirstSingleQuote + 1, foundSecondSingleQuote - foundFirstSingleQuote - 1);
@@ -1783,12 +1789,12 @@ namespace TC
17831789
// Works for all OSes. Creates dir if necessary.
17841790
const char *pOutputFolder = FCL::GetShaderOutputFolder();
17851791
stringstream ss;
1786-
char* pBuffer = (char *)pInputArgs->pInput;
1792+
const char* pBuffer = pInputArgs->pInput;
17871793
UINT bufferSize = pInputArgs->InputSize;
17881794

17891795
// Create hash based on cclang binary output (currently llvm binary; later also spirv).
17901796
// Hash computed in fcl needs to be same as the one computed in igc.
1791-
// This is to ensure easy matching .cl files dumped in fcl with .ll/.dat/.asm/... files dumoed in igc.
1797+
// This is to ensure easy matching .cl files dumped in fcl with .ll/.dat/.asm/... files dumped in igc.
17921798
QWORD hash = iSTD::Hash(reinterpret_cast<const DWORD *>(pOutputArgs->pOutput), (DWORD)(pOutputArgs->OutputSize) / 4);
17931799

17941800
ss << pOutputFolder;

IGC/common/igc_flags.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ DECLARE_IGC_REGKEY(bool, InitializeAddressRegistersBeforeUse, false, "Settin
252252
DECLARE_IGC_REGKEY(bool, EnableSIMDLaneDebugging, false, "Setting this to 1 (true) enables SIMD lane location expression emmitions for GPU debugger", false)
253253
DECLARE_IGC_REGKEY(bool, EnableGTLocationDebugging, false, "Setting this to 1 (true) enables GT location expression emmitions for GPU debugger", false)
254254
DECLARE_IGC_REGKEY(bool, EnableWriteOldFPToStack, false, "Setting this to 1 (true) writes the caller frame's frame-pointer to the start of callee's frame on stack, to support stack walk", false)
255+
DECLARE_IGC_REGKEY(debugString, ExtraOCLOptions, 0, "Extra options for OpenCL", false)
255256

256257
DECLARE_IGC_GROUP("IGC Features")
257258
DECLARE_IGC_REGKEY(bool, EnableOCLSIMD16, true, "Enable OCL SIMD16 mode", true)

0 commit comments

Comments
 (0)