From b94b29d79c55ed528cd956dc4a8dda643256e406 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Tue, 6 Jun 2023 06:00:31 -0700 Subject: [PATCH] Prevent ftrace from misaligning functions --- build/config.mk | 2 +- third_party/ggml/fp16.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build/config.mk b/build/config.mk index 8434920e2..c344533ad 100644 --- a/build/config.mk +++ b/build/config.mk @@ -471,7 +471,7 @@ ifeq ($(ARCH), x86_64) # jmp -7 # 2 bytes # ... # -CONFIG_CCFLAGS += -fpatchable-function-entry=11,9 +CONFIG_CCFLAGS += -fpatchable-function-entry=18,16 endif ifeq ($(ARCH), aarch64) # this flag causes gcc to generate functions like this diff --git a/third_party/ggml/fp16.c b/third_party/ggml/fp16.c index 71d46d09c..262047d65 100644 --- a/third_party/ggml/fp16.c +++ b/third_party/ggml/fp16.c @@ -26,6 +26,7 @@ │ │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "third_party/ggml/fp16.h" +#include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "third_party/ggml/fp16.internal.h" #include "third_party/libcxx/math.h" @@ -124,6 +125,7 @@ inline static float ggml_silu_f32(float x) { void ggml_fp16_init(void) { ggml_fp16_t ii; + ftrace_enabled(-1); for (int i = 0; i < (1 << 16); ++i) { uint16_t ui = i; memcpy(&ii, &ui, sizeof(ii)); @@ -132,4 +134,5 @@ void ggml_fp16_init(void) { table_silu_f16[i] = GGML_FP32_TO_FP16(ggml_silu_f32(f)); table_exp_f16[i] = GGML_FP32_TO_FP16(expf(f)); } + ftrace_enabled(+1); }