Skip to content
Open
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
2 changes: 1 addition & 1 deletion include/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ namespace vc4c
*
* @return whether the parameter was successfully parsed and applied to the configuration
*/
bool parseConfigurationParameter(Configuration& config, const std::string& arg);
bool parseConfigurationParameter(Configuration& config, bool, const std::string& arg);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The parameter needs a name


} /* namespace tools */
} /* namespace vc4c */
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ int main(int argc, char** argv)
// increment `i` more than usual, because argv[i + 1] is already consumed
i += 1;
}
else if(!vc4c::tools::parseConfigurationParameter(config, argv[i]) || strstr(argv[i], "-cl") == argv[i])
else if(!vc4c::tools::parseConfigurationParameter(config, true, argv[i]) || strstr(argv[i], "-cl") == argv[i])
// pass every not understood option to the pre-compiler, as well as every OpenCL compiler option
options.append(argv[i]).append(" ");
}
Expand Down
18 changes: 12 additions & 6 deletions src/tools/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static std::set<std::string> createAvailableOptimizations()
return opts;
}

bool tools::parseConfigurationParameter(Configuration& config, const std::string& arg)
bool tools::parseConfigurationParameter(Configuration& config, bool printFlag, const std::string& arg)
{
static auto availableOptimizations = createAvailableOptimizations();
if(arg == "-cl-opt-disable")
Expand Down Expand Up @@ -151,7 +151,8 @@ bool tools::parseConfigurationParameter(Configuration& config, const std::string
return true;
}

std::cerr << "Cannot disable unknown optimization: " << passName << std::endl;
if(printFlag)
std::cerr << "Cannot disable unknown optimization: " << passName << std::endl;
return false;
}
else if(arg.find("--f") == 0)
Expand All @@ -169,8 +170,9 @@ bool tools::parseConfigurationParameter(Configuration& config, const std::string
}
catch(std::exception& e)
{
std::cerr << "Error converting optimization parameter for '" << paramName << ": " << e.what()
<< std::endl;
if(printFlag)
std::cerr << "Error converting optimization parameter for '" << paramName << ": " << e.what()
<< std::endl;
return false;
}
if(paramName == "combine-load-threshold")
Expand All @@ -189,7 +191,9 @@ bool tools::parseConfigurationParameter(Configuration& config, const std::string
config.additionalOptions.maxCommonExpressionDinstance = static_cast<unsigned>(intValue);
else
{
std::cerr << "Cannot set unknown optimization parameter: " << paramName << " to " << value << std::endl;
if(printFlag)
std::cerr << "Cannot set unknown optimization parameter: " << paramName << " to " << value
<< std::endl;
return false;
}
return true;
Expand All @@ -200,7 +204,9 @@ bool tools::parseConfigurationParameter(Configuration& config, const std::string
logging::debug() << "Enabling optimization: " << passName << logging::endl;
return true;
}
std::cerr << "Cannot enable unknown optimization: " << passName << std::endl;

if(printFlag)
std::cerr << "Cannot enable unknown optimization: " << passName << std::endl;
return false;
}
return false;
Expand Down
9 changes: 4 additions & 5 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static Test::Suite* newConversionFunctionsTest()
}

/*
*
*
*/
int main(int argc, char** argv)
{
Expand All @@ -126,7 +126,7 @@ int main(int argc, char** argv)
Test::registerSuite(newLLVMCompilationTest<false>, "test-compilation-llvm", "Runs all the compilation tests using the LLVM-IR front-end", false);
Test::registerSuite(newSPIRVCompiltionTest<false>, "test-compilation-spirv", "Runs all the compilation tests using the SPIR-V front-end", false);
Test::registerSuite(newFastRegressionTest, "fast-regressions", "Runs regression test-cases marked as fast", false);

Test::registerSuite(newEmulatorTest, "test-emulator", "Runs selected code-samples through the emulator");
Test::registerSuite(newMathFunctionsTest, "emulate-math", "Runs emulation tests for the OpenCL standard-library math functions");
Test::registerSuite(Test::newInstance<TestGraph>, "test-graph", "Runs basic test for the graph data structure");
Expand All @@ -142,8 +142,8 @@ int main(int argc, char** argv)
auto args = std::vector<char*>();

for(auto i = 1; i < argc; ++i)
{
if (!vc4c::tools::parseConfigurationParameter(config, argv[i]))
{
if (!vc4c::tools::parseConfigurationParameter(config, false, argv[i]))
args.push_back(argv[i]);

//TODO rewrite, actually print same help (parts of it) as VC4C
Expand All @@ -153,4 +153,3 @@ int main(int argc, char** argv)

return Test::runSuites(int(args.size()), args.data());
}