Skip to content

Distribute and run LLMs with a single file.

Upgrade to cosmocc v3.3.4

Justine Tunney6c45e3eae953
diff --git a/build/config.mk b/build/config.mk
index 35acbf72..fc0297fc 100644
--- a/build/config.mk
+++ b/build/config.mk
@@ -2,7 +2,7 @@
#── vi: set noet ft=make ts=8 sw=8 fenc=utf-8 :vi ────────────────────┘
PREFIX = /usr/local
-COSMOCC = .cosmocc/3.3.3
+COSMOCC = .cosmocc/3.3.4
TOOLCHAIN = $(COSMOCC)/bin/cosmo
AR = $(TOOLCHAIN)ar
@@ -50,5 +50,5 @@ clean:; rm -rf o
.PHONY: distclean
distclean:; rm -rf o .cosmocc
-.cosmocc/3.3.3:
- build/download-cosmocc.sh $@ 3.3.3 e4d0fa63cd79cc3bfff6c2d015f1776db081409907625aea8ad40cefc1996d08
+.cosmocc/3.3.4:
+ build/download-cosmocc.sh $@ 3.3.4 98e5b361c525603f5296351e0c11820fd25908b52fe1ce8ff394d66b1537a259
diff --git a/llama.cpp/common.cpp b/llama.cpp/common.cpp
index 89db03a7..c3b7e698 100644
--- a/llama.cpp/common.cpp
+++ b/llama.cpp/common.cpp
@@ -95,6 +95,16 @@ int32_t get_num_physical_cores() {
return static_cast<int32_t>(siblings.size());
}
}
+ int32_t num_physical_cores;
+ size_t len = sizeof(num_physical_cores);
+ int result = sysctlbyname("hw.perflevel0.physicalcpu", &num_physical_cores, &len, NULL, 0);
+ if (result == 0) {
+ return num_physical_cores;
+ }
+ result = sysctlbyname("hw.physicalcpu", &num_physical_cores, &len, NULL, 0);
+ if (result == 0) {
+ return num_physical_cores;
+ }
unsigned int n_threads = std::thread::hardware_concurrency();
return n_threads > 0 ? (n_threads <= 4 ? n_threads : n_threads / 2) : 4;
}
diff --git a/llamafile/debug.cpp b/llamafile/debug.cpp
index c68788b0..a5c37a37 100644
--- a/llamafile/debug.cpp
+++ b/llamafile/debug.cpp
@@ -94,28 +94,6 @@ static void print_graph(FILE *f, const struct ggml_cgraph *g) {
}
}
-int feenableexcept(int excepts) {
- excepts &= FE_ALL_EXCEPT;
-#ifdef __x86_64__
- unsigned mxcsr;
- asm("stmxcsr\t%0" : "=m"(mxcsr));
- mxcsr &= ~(excepts << 7);
- asm("ldmxcsr\t%0" : /* no inputs */ : "m"(mxcsr));
-#endif
- return 0;
-}
-
-int fedisableexcept(int excepts) {
- excepts &= FE_ALL_EXCEPT;
-#ifdef __x86_64__
- unsigned mxcsr;
- asm("stmxcsr\t%0" : "=m"(mxcsr));
- mxcsr |= excepts << 7;
- asm("ldmxcsr\t%0" : /* no inputs */ : "m"(mxcsr));
-#endif
- return 0;
-}
-
// recover from trap so that execution may resume
// without this the same signal will just keep getting raised
static void recover(ucontext_t *ctx, int traps) {
diff --git a/llamafile/llamafile.h b/llamafile/llamafile.h
index e592d193..1745781e 100644
--- a/llamafile/llamafile.h
+++ b/llamafile/llamafile.h
@@ -2,15 +2,11 @@
#define LLAMAFILE_H_
#include <stdbool.h>
#include <stdio.h>
+#include <threads.h>
#ifdef __cplusplus
extern "C" {
#endif
-// TODO(jart): remove in favor of c11 threads.h
-#if !defined(__cplusplus) && !defined(thread_local)
-#define thread_local _Thread_local
-#endif
-
struct llamafile;
struct llamafile *llamafile_open_gguf(const char *, const char *);
void llamafile_close(struct llamafile *);