Storm 1.10.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SylvanSettings.cpp
Go to the documentation of this file.
2
5
11
12namespace storm {
13namespace settings {
14namespace modules {
15
16const std::string SylvanSettings::moduleName = "sylvan";
17const std::string SylvanSettings::maximalMemoryOptionName = "maxmem";
18const std::string SylvanSettings::threadCountOptionName = "threads";
19
21 this->addOption(storm::settings::OptionBuilder(moduleName, maximalMemoryOptionName, true, "Sets the upper bound of memory available to Sylvan in MB.")
22 .setIsAdvanced()
23 .addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("value", "The memory available to Sylvan.")
24 .setDefaultValueUnsignedInteger(4096)
25 .build())
26 .build());
27 this->addOption(storm::settings::OptionBuilder(moduleName, threadCountOptionName, true, "Sets the number of threads used by Sylvan.")
28 .setIsAdvanced()
30 "value", "The number of threads available to Sylvan (0 means 'auto-detect').")
31 .build())
32 .build());
33}
34
35uint_fast64_t SylvanSettings::getMaximalMemory() const {
36 return this->getOption(maximalMemoryOptionName).getArgumentByName("value").getValueAsUnsignedInteger();
37}
38
40 return this->getOption(threadCountOptionName).getArgumentByName("value").getHasBeenSet();
41}
42
45 auto numberFromSettings = this->getOption(threadCountOptionName).getArgumentByName("value").getValueAsUnsignedInteger();
46 if (numberFromSettings != 0u) {
47 return numberFromSettings;
48 }
49 }
50 // Automatic detection
51#ifdef APPLE_SILICON
52 // Prevents issues with multi-threaded execution on Apple Silicon
53 return 1u;
54#else
55 return std::max(1u, storm::utility::getNumberOfThreads());
56#endif
57}
58
61 auto const autoDetectThreads = std::max(1u, storm::utility::getNumberOfThreads());
62 auto const numberFromSettings = getNumberOfThreads();
63#ifdef APPLE_SILICON
64 STORM_LOG_WARN_COND(numberFromSettings <= 1,
65 "Sylvan does not properly work for multiple threads on Apple Silicon. We recommend limiting the number of threads to 1.");
66#endif
67 STORM_LOG_WARN_COND(numberFromSettings <= autoDetectThreads, "Setting the number of sylvan threads to "
68 << numberFromSettings << " which exceeds the recommended number for your system ("
69 << autoDetectThreads << ").");
70 }
71 return true;
72}
73
74} // namespace modules
75} // namespace settings
76} // namespace storm
virtual uint_fast64_t getValueAsUnsignedInteger() const =0
Retrieves the value of this argument as an unsigned integer.
virtual bool getHasBeenSet() const
Retrieves whether the argument has been set.
static ArgumentBuilder createUnsignedIntegerArgument(std::string const &name, std::string const &description)
Creates an unsigned integer argument with the given parameters.
This class provides the interface to create an option...
ArgumentBase const & getArgumentByName(std::string const &argumentName) const
Returns a reference to the argument with the specified long name.
Definition Option.cpp:79
This is the base class of the settings for a particular module.
void addOption(std::shared_ptr< Option > const &option)
Adds and registers the given option.
Option & getOption(std::string const &longName)
Retrieves the option with the given long name.
uint_fast64_t getMaximalMemory() const
Retrieves the maximal amount of memory (in megabytes) that Sylvan can occupy.
SylvanSettings()
Creates a new set of Sylvan settings.
uint_fast64_t getNumberOfThreads() const
Retrieves the amount of threads available to Sylvan.
bool check() const override
Checks whether the settings are consistent.
bool isNumberOfThreadsSet() const
Retrieves whether the number of threads to use was set.
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:38
uint getNumberOfThreads()
Definition threads.cpp:53
LabParser.cpp.