Skip to content

Commit add4dae

Browse files
committed
Get CPU model in ggml_backend_cpu_device_context on FreeBSD
1 parent 578754b commit add4dae

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ggml/src/ggml-cpu/ggml-cpu.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
#include <sys/sysctl.h>
2424
#endif
2525

26+
#if defined(__FreeBSD__)
27+
#include <sys/types.h>
28+
#include <sys/sysctl.h>
29+
#include <string.h>
30+
#include <iostream>
31+
#endif
32+
2633
#if defined(_WIN32)
2734
#define WIN32_LEAN_AND_MEAN
2835
#ifndef NOMINMAX
@@ -285,6 +292,14 @@ struct ggml_backend_cpu_device_context {
285292
}
286293
fclose(f);
287294
}
295+
#elif defined(__FreeBSD__)
296+
char buf[1024];
297+
size_t size = sizeof(buf);
298+
int rc = sysctlbyname("hw.model", buf, &size, nullptr, 0);
299+
if (rc == 0)
300+
description = buf;
301+
else
302+
std::cerr << "error: sysctlbyname(hw.model) failed: " << strerror(errno) << std::endl;
288303
#elif defined(_WIN32)
289304
HKEY hKey;
290305
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,

0 commit comments

Comments
 (0)