Skip to content

Commit aff5a3a

Browse files
committed
ENH: Rename nxrunner --ooc-memory-budget flag to --memory-budget
* Rename the CLI flag, ArgumentType enum entry, k_ constants, help function, local variable, and error-message strings to drop the "Ooc" prefix * Update calls into Preferences to match the renamed API (setMemoryBudgetBytes, memoryBudgetBytes, k_MemoryBudgetBytes_Key) The MemoryBudgetManager now lives in simplnx core (not the SimplnxOoc plugin) and applies to any cache subsystem that registers against it, so the "Ooc" qualifier is no longer accurate. Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
1 parent 729ab1d commit aff5a3a

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

src/nxrunner/src/nxrunner.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ constexpr StringLiteral k_PreflightParamShort = "-p";
5858
constexpr StringLiteral k_LogFileParamShort = "-l";
5959
constexpr StringLiteral k_ConvertParamShort = "-c";
6060
constexpr StringLiteral k_ConvertOutputParamShort = "-co";
61-
constexpr StringLiteral k_OocMemoryBudgetParamLong = "--ooc-memory-budget";
62-
constexpr StringLiteral k_OocMemoryBudgetParamShort = "-b";
61+
constexpr StringLiteral k_MemoryBudgetParamLong = "--memory-budget";
62+
constexpr StringLiteral k_MemoryBudgetParamShort = "-b";
6363

6464
void LoadApp()
6565
{
@@ -152,7 +152,7 @@ enum class ArgumentType
152152
Logfile,
153153
Convert,
154154
ConvertOutput,
155-
OocMemoryBudget
155+
MemoryBudget
156156
};
157157

158158
struct Argument
@@ -251,10 +251,10 @@ Result<CliArguments> ParseParameters(int argc, char* argv[])
251251
std::string argStr = ParseArgument(argc, argv, index);
252252
args.emplace_back(ArgumentType::ConvertOutput, argStr);
253253
}
254-
else if(arg == k_OocMemoryBudgetParamLong || arg == k_OocMemoryBudgetParamShort)
254+
else if(arg == k_MemoryBudgetParamLong || arg == k_MemoryBudgetParamShort)
255255
{
256256
std::string argStr = ParseArgument(argc, argv, index);
257-
args.emplace_back(ArgumentType::OocMemoryBudget, argStr);
257+
args.emplace_back(ArgumentType::MemoryBudget, argStr);
258258
}
259259
else
260260
{
@@ -465,7 +465,7 @@ void DisplayDefaultHelp()
465465
cliOut << fmt::format("\t {}|{} <pipeline filepath> [{}|{} <log filepath>]\t", k_ConvertParamLong, k_ConvertParamShort, k_LogFileParamLong, k_LogFileParamShort)
466466
<< "\t Convert the SIMPL pipeline at the target filepath. Optionally, create a log file at the specified path.";
467467
cliOut << fmt::format("\t <operand [argument]> [{}|{} <log filepath>]\t", k_LogFileParamLong, k_LogFileParamShort) << "\t Creates a log file at the specified path.";
468-
cliOut << fmt::format("\t {}|{} <gigabytes>\t", k_OocMemoryBudgetParamLong, k_OocMemoryBudgetParamShort)
468+
cliOut << fmt::format("\t {}|{} <gigabytes>\t", k_MemoryBudgetParamLong, k_MemoryBudgetParamShort)
469469
<< "\t Override the OOC memory budget for this run (decimal GB, e.g. 8 or 1.5). Does not modify saved preferences.\n";
470470
cliOut.endline();
471471
}
@@ -509,10 +509,10 @@ void DisplayLogfileHelp()
509509
cliOut.endline();
510510
}
511511

512-
void DisplayOocMemoryBudgetHelp()
512+
void DisplayMemoryBudgetHelp()
513513
{
514514
cliOut << "To override the OOC memory budget for this run:\n\t";
515-
cliOut << fmt::format("\t {}|{} <gigabytes>\t", k_OocMemoryBudgetParamLong, k_OocMemoryBudgetParamShort)
515+
cliOut << fmt::format("\t {}|{} <gigabytes>\t", k_MemoryBudgetParamLong, k_MemoryBudgetParamShort)
516516
<< "\t Override the OOC memory budget for this run only (decimal gigabytes, e.g. 8 or 1.5). Does not modify saved preferences.";
517517
cliOut.endline();
518518
}
@@ -546,8 +546,8 @@ Result<> DisplayHelpMenu(const std::vector<Argument>& arguments)
546546
DisplayLogfileHelp();
547547
return {};
548548
}
549-
case ArgumentType::OocMemoryBudget: {
550-
DisplayOocMemoryBudgetHelp();
549+
case ArgumentType::MemoryBudget: {
550+
DisplayMemoryBudgetHelp();
551551
return {};
552552
}
553553
case ArgumentType::Invalid: {
@@ -595,7 +595,7 @@ int main(int argc, char* argv[])
595595
CliArguments arguments = parsingResult.value();
596596
std::vector<Result<>> results;
597597

598-
std::optional<uint64> overrideOocMemoryBudgetBytes;
598+
std::optional<uint64> overrideMemoryBudgetBytes;
599599

600600
// Set log file and check for parsing errors
601601
for(const Argument& argument : arguments)
@@ -610,10 +610,10 @@ int main(int argc, char* argv[])
610610
results.push_back(SetLogFile(argument));
611611
break;
612612
}
613-
case ArgumentType::OocMemoryBudget: {
613+
case ArgumentType::MemoryBudget: {
614614
if(argument.value.empty())
615615
{
616-
results.push_back(nx::core::MakeErrorResult(k_InvalidArgumentError, "--ooc-memory-budget requires a value in gigabytes (e.g. 8 or 1.5)"));
616+
results.push_back(nx::core::MakeErrorResult(k_InvalidArgumentError, "--memory-budget requires a value in gigabytes (e.g. 8 or 1.5)"));
617617
break;
618618
}
619619
try
@@ -623,13 +623,13 @@ int main(int argc, char* argv[])
623623
if(parsedChars != argument.value.size() || !std::isfinite(gb) || gb <= 0.0)
624624
{
625625
results.push_back(
626-
nx::core::MakeErrorResult(k_InvalidArgumentError, fmt::format("Invalid value for --ooc-memory-budget: '{}' (must be a finite, positive number of gigabytes)", argument.value)));
626+
nx::core::MakeErrorResult(k_InvalidArgumentError, fmt::format("Invalid value for --memory-budget: '{}' (must be a finite, positive number of gigabytes)", argument.value)));
627627
break;
628628
}
629-
overrideOocMemoryBudgetBytes = static_cast<uint64>(gb * 1024.0 * 1024.0 * 1024.0);
629+
overrideMemoryBudgetBytes = static_cast<uint64>(gb * 1024.0 * 1024.0 * 1024.0);
630630
} catch(const std::exception&)
631631
{
632-
results.push_back(nx::core::MakeErrorResult(k_InvalidArgumentError, fmt::format("Invalid value for --ooc-memory-budget: '{}' (expected a positive number of gigabytes)", argument.value)));
632+
results.push_back(nx::core::MakeErrorResult(k_InvalidArgumentError, fmt::format("Invalid value for --memory-budget: '{}' (expected a positive number of gigabytes)", argument.value)));
633633
}
634634
break;
635635
}
@@ -667,28 +667,28 @@ int main(int argc, char* argv[])
667667
}
668668
if(wasPresent)
669669
{
670-
prefs->setOocMemoryBudgetBytes(originalValue);
670+
prefs->setMemoryBudgetBytes(originalValue);
671671
}
672672
else
673673
{
674-
prefs->removeValue(Preferences::k_OocMemoryBudgetBytes_Key);
674+
prefs->removeValue(Preferences::k_MemoryBudgetBytes_Key);
675675
}
676676
}
677677
};
678678
PreferencesBudgetRestorer budgetRestorer;
679679

680-
if(overrideOocMemoryBudgetBytes.has_value())
680+
if(overrideMemoryBudgetBytes.has_value())
681681
{
682682
Preferences* preferences = app->getPreferences();
683683
if(preferences != nullptr)
684684
{
685685
budgetRestorer.prefs = preferences;
686-
budgetRestorer.wasPresent = preferences->contains(std::string(Preferences::k_OocMemoryBudgetBytes_Key));
686+
budgetRestorer.wasPresent = preferences->contains(std::string(Preferences::k_MemoryBudgetBytes_Key));
687687
if(budgetRestorer.wasPresent)
688688
{
689-
budgetRestorer.originalValue = preferences->oocMemoryBudgetBytes();
689+
budgetRestorer.originalValue = preferences->memoryBudgetBytes();
690690
}
691-
preferences->setOocMemoryBudgetBytes(*overrideOocMemoryBudgetBytes);
691+
preferences->setMemoryBudgetBytes(*overrideMemoryBudgetBytes);
692692
}
693693
}
694694

0 commit comments

Comments
 (0)