Commit e5b6793b authored by Bednárek David RNDr. Ph.D.'s avatar Bednárek David RNDr. Ph.D.
Browse files

--threads arguments

well-defined uniform distribution in levenasgn.hpp
parent 54a06af8
......@@ -1959,7 +1959,7 @@ namespace fmwkng {
using self_ = root_data_holder< config_t>;
public:
root_data_holder(int argc, char** argv, const gold_data& gd = gold_data{})
: gd_(gd), direct_print_(true)
: gd_(gd), direct_print_(true), threads_(1)
{
std::fill(platform_enablers_.begin(), platform_enablers_.end(), true);
process_arguments(std::vector< std::string>(argv + 1, argv + argc));
......@@ -2122,6 +2122,10 @@ namespace fmwkng {
{
return direct_print_;
}
std::size_t preferred_concurrency() const
{
return threads_;
}
private:
std::array<bool, config_t::platforms::size_v> platform_enablers_;
typename config_t::ranges::tuple_t range_configs_;
......@@ -2132,6 +2136,7 @@ namespace fmwkng {
gold_data gd_;
std::string machine_name_;
bool direct_print_;
std::size_t threads_;
void print_elements() const
{
......@@ -2188,6 +2193,24 @@ namespace fmwkng {
}
}
}
{
threads_ = std::thread::hardware_concurrency();
try {
#pragma warning(push)
#pragma warning(disable: 4996)
auto env1 = std::getenv("SLURM_CPUS_ON_NODE");
#pragma warning(pop)
if (env1)
{
auto num1 = std::stoi(env1);
if (num1 >= 1 && num1 <= 256)
threads_ = num1;
}
}
catch (...)
{
}
}
for (auto it = arg.begin(); it != arg.end(); ++it)
{
auto& a = *it;
......@@ -2214,6 +2237,17 @@ namespace fmwkng {
{
machine_name_ = value;
}
else if (name == "threads")
{
try {
auto num1 = std::stoi(std::string(value));
if (num1 >= 1 && num1 <= 256)
threads_ = num1;
}
catch (...)
{
}
}
else if (name == "direct-print")
{
if (value == "1" || value == "true" || value == "on")
......@@ -3828,30 +3862,9 @@ namespace fmwkng {
using my_data = typename my_tuple_t::my_data;
my_tuple_t dt_;
static std::size_t preferred_concurrency()
std::size_t preferred_concurrency() const
{
static std::size_t pc = compute_preferred_concurrency();
return pc;
}
static std::size_t compute_preferred_concurrency()
{
try {
#pragma warning(push)
#pragma warning(disable: 4996)
auto env1 = std::getenv("SLURM_CPUS_ON_NODE");
#pragma warning(pop)
if (env1)
{
auto num1 = std::stoi(env1);
if ( num1 >= 1 && num1 <= 256 )
return num1;
}
}
catch (...)
{
}
return std::thread::hardware_concurrency();
return my_root_pointer()->preferred_concurrency();
}
};
#pragma endregion
......
......@@ -92,13 +92,13 @@ namespace levenasgn {
data_element get()
{
return ui_(engine_);
return data_element(ui_(engine_));
}
private:
typedef std::mt19937_64 M;
M engine_;
typedef std::uniform_int_distribution< data_element> D;
typedef fmwkng::well_defined_uniform D;
D ui_;
};
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment