Skip to content

Commit

Permalink
Fix: issues with hardware_concurrency declaration.
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinB committed Dec 14, 2018
1 parent c6336fe commit 20d5fe5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/backends/tsne/tsnelib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,16 @@
#include "csvinputfileconn.h"
#include "outputconnectorstrategy.h"
#include <thread>
#include "utils/utils.hpp"

namespace dd
{

int my_hardware_concurrency()
{
std::ifstream cpuinfo("/proc/cpuinfo");

return std::count(std::istream_iterator<std::string>(cpuinfo),
std::istream_iterator<std::string>(),
std::string("processor"));
}


unsigned int hardware_concurrency()
{
unsigned int cores = std::thread::hardware_concurrency();
if (!cores)
cores = my_hardware_concurrency();
cores = dd_utils::my_hardware_concurrency();
return cores;
}

Expand Down
9 changes: 9 additions & 0 deletions src/utils/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ namespace dd
return false;
return true;
}

static int my_hardware_concurrency()
{
std::ifstream cpuinfo("/proc/cpuinfo");

return std::count(std::istream_iterator<std::string>(cpuinfo),
std::istream_iterator<std::string>(),
std::string("processor"));
}
};
}

Expand Down

0 comments on commit 20d5fe5

Please sign in to comment.