Merge 'origin/master' into hipblas

This commit is contained in:
Henri Vasserman 2023-05-16 17:08:29 +03:00
commit a0b2d5f291
No known key found for this signature in database
GPG key ID: 2995FC0F58B1A986
2 changed files with 16 additions and 15 deletions

View file

@ -115,7 +115,7 @@ ifndef LLAMA_NO_ACCELERATE
endif endif
endif endif
ifdef LLAMA_OPENBLAS ifdef LLAMA_OPENBLAS
CFLAGS += -DGGML_USE_OPENBLAS -I/usr/local/include/openblas CFLAGS += -DGGML_USE_OPENBLAS -I/usr/local/include/openblas -I/usr/include/openblas
ifneq ($(shell grep -e "Arch Linux" -e "ID_LIKE=arch" /etc/os-release 2>/dev/null),) ifneq ($(shell grep -e "Arch Linux" -e "ID_LIKE=arch" /etc/os-release 2>/dev/null),)
LDFLAGS += -lopenblas -lcblas LDFLAGS += -lopenblas -lcblas
else else

View file

@ -8,6 +8,7 @@
#include <iterator> #include <iterator>
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
#include <unordered_set>
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
#include <sys/types.h> #include <sys/types.h>
@ -28,21 +29,21 @@
int32_t get_num_physical_cores() { int32_t get_num_physical_cores() {
#ifdef __linux__ #ifdef __linux__
std::ifstream cpuinfo("/proc/cpuinfo"); // enumerate the set of thread siblings, num entries is num cores
std::unordered_set<std::string> siblings;
for (uint32_t cpu=0; cpu < UINT32_MAX; ++cpu) {
std::ifstream thread_siblings("/sys/devices/system/cpu"
+ std::to_string(cpu) + "/topology/thread_siblings");
if (!thread_siblings.is_open()) {
break; // no more cpus
}
std::string line; std::string line;
while (std::getline(cpuinfo, line)) { if (std::getline(thread_siblings, line)) {
std::size_t pos = line.find("cpu cores"); siblings.insert(line);
if (pos != std::string::npos) {
pos = line.find(": ", pos);
if (pos != std::string::npos) {
try {
// Extract the number and return it
return static_cast<int32_t>(std::stoul(line.substr(pos + 2)));
} catch (const std::invalid_argument &) {
// Ignore if we could not parse
}
} }
} }
if (siblings.size() > 0) {
return static_cast<int32_t>(siblings.size());
} }
#elif defined(__APPLE__) && defined(__MACH__) #elif defined(__APPLE__) && defined(__MACH__)
int32_t num_physical_cores; int32_t num_physical_cores;