Skip to content

Commit

Permalink
Upgrade to cosmocc v3.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed May 3, 2024
1 parent bbae0f6 commit 6c45e3e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 30 deletions.
6 changes: 3 additions & 3 deletions build/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
10 changes: 10 additions & 0 deletions llama.cpp/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
22 changes: 0 additions & 22 deletions llamafile/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 1 addition & 5 deletions llamafile/llamafile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down

0 comments on commit 6c45e3e

Please sign in to comment.