Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
Upgrade to Cosmopolitan v3.7.1
Justine Tunneyd0b5e8f2ac1d
diff --git a/build/config.mk b/build/config.mkindex ad69bbd4..5b9f9ce6 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.6.2+COSMOCC = .cosmocc/3.7.1TOOLCHAIN = $(COSMOCC)/bin/cosmoCC = $(TOOLCHAIN)cc@@ -52,5 +52,5 @@ clean:; rm -rf o.PHONY: distcleandistclean:; rm -rf o .cosmocc-.cosmocc/3.6.2:- build/download-cosmocc.sh $@ 3.6.2 268aa82d9bfd774f76951b250f87b8edcefd5c754b8b409e1639641e8bd8d5bc+.cosmocc/3.7.1:+ build/download-cosmocc.sh $@ 3.7.1 13b65b0e659b493bd82f3d0a319d0265d66f849839e484aa2a54191024711e85diff --git a/llama.cpp/ggml.c b/llama.cpp/ggml.cindex 7a3ea652..70a427c3 100644--- a/llama.cpp/ggml.c+++ b/llama.cpp/ggml.c@@ -1810,60 +1810,26 @@ inline static void ggml_critical_section_start(void) {}}-#define GGML_BARRIER_IMPL \- if (params->shared->n_threads == 1) \- return; \- int n = params->shared->n_threads; \- atomic_int * count = ¶ms->shared->n_barrier; \- atomic_uint * phase = ¶ms->shared->n_barrier_passed[params->ith].i; \- unsigned i = atomic_load_explicit(phase, memory_order_relaxed); \- if (atomic_fetch_add_explicit(count, 1, memory_order_acq_rel) == n - 1) { \- atomic_store_explicit(count, 0, memory_order_relaxed); \- for (int j = 0; j < n; ++j) { \- atomic_store_explicit(¶ms->shared->n_barrier_passed[j].i, \- i + 1, memory_order_relaxed); \- } \- atomic_thread_fence(memory_order_release); \- } else { \- while (atomic_load_explicit(phase, memory_order_relaxed) == i) \- pthread_pause_np(); \- atomic_thread_fence(memory_order_acquire); \- }--#ifndef __aarch64__-void ggml_barrier(const struct ggml_compute_params * params) {- GGML_BARRIER_IMPL-}--#else--static void ggml_barrier_default(const struct ggml_compute_params * params) {- GGML_BARRIER_IMPL-}--#pragma GCC push_options-#pragma GCC target ("arch=armv8.1-a") // shaves microseconds per call on m2-static void ggml_barrier_armv81a(const struct ggml_compute_params * params) {- GGML_BARRIER_IMPL-}-#pragma GCC pop_options--void ggml_barrier(const struct ggml_compute_params * params) {- static void (*impl)(const struct ggml_compute_params *);- if (!impl) {- long hwcap = getauxval(AT_HWCAP);- if (hwcap & HWCAP_ATOMICS) {- impl = ggml_barrier_armv81a;- } else {- impl = ggml_barrier_default;- }+ if (params->shared->n_threads == 1)+ return;+ int n = params->shared->n_threads;+ atomic_int * count = ¶ms->shared->n_barrier;+ atomic_uint * phase = ¶ms->shared->n_barrier_passed[params->ith].i;+ unsigned i = atomic_load_explicit(phase, memory_order_relaxed);+ if (atomic_fetch_add_explicit(count, 1, memory_order_acq_rel) == n - 1) {+ atomic_store_explicit(count, 0, memory_order_relaxed);+ for (int j = 0; j < n; ++j)+ atomic_store_explicit(¶ms->shared->n_barrier_passed[j].i,+ i + 1, memory_order_relaxed);+ atomic_thread_fence(memory_order_release);+ } else {+ while (atomic_load_explicit(phase, memory_order_relaxed) == i)+ pthread_pause_np();+ atomic_thread_fence(memory_order_acquire);}- return impl(params);}-#endif // __aarch64__-// TODO: make this somehow automatically executed// some sort of "sentry" mechanisminline static void ggml_critical_section_end(void) {