Prevent ftrace from misaligning functions

This commit is contained in:
Justine Tunney 2023-06-06 06:00:31 -07:00
parent b8a6a989c0
commit b94b29d79c
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 4 additions and 1 deletions

View file

@ -471,7 +471,7 @@ ifeq ($(ARCH), x86_64)
# jmp -7 # 2 bytes # jmp -7 # 2 bytes
# ... # ...
# #
CONFIG_CCFLAGS += -fpatchable-function-entry=11,9 CONFIG_CCFLAGS += -fpatchable-function-entry=18,16
endif endif
ifeq ($(ARCH), aarch64) ifeq ($(ARCH), aarch64)
# this flag causes gcc to generate functions like this # this flag causes gcc to generate functions like this

View file

@ -26,6 +26,7 @@
*/ */
#include "third_party/ggml/fp16.h" #include "third_party/ggml/fp16.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h" #include "libc/str/str.h"
#include "third_party/ggml/fp16.internal.h" #include "third_party/ggml/fp16.internal.h"
#include "third_party/libcxx/math.h" #include "third_party/libcxx/math.h"
@ -124,6 +125,7 @@ inline static float ggml_silu_f32(float x) {
void ggml_fp16_init(void) { void ggml_fp16_init(void) {
ggml_fp16_t ii; ggml_fp16_t ii;
ftrace_enabled(-1);
for (int i = 0; i < (1 << 16); ++i) { for (int i = 0; i < (1 << 16); ++i) {
uint16_t ui = i; uint16_t ui = i;
memcpy(&ii, &ui, sizeof(ii)); 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_silu_f16[i] = GGML_FP32_TO_FP16(ggml_silu_f32(f));
table_exp_f16[i] = GGML_FP32_TO_FP16(expf(f)); table_exp_f16[i] = GGML_FP32_TO_FP16(expf(f));
} }
ftrace_enabled(+1);
} }