diff --git a/.github/workflows/release-prefab-aar.yml b/.github/workflows/release-prefab-aar.yml index c822ee0..f19fb98 100644 --- a/.github/workflows/release-prefab-aar.yml +++ b/.github/workflows/release-prefab-aar.yml @@ -24,7 +24,7 @@ jobs: - name: Install Linux build dependencies run: | sudo apt-get update - sudo apt-get install -y clang cmake ninja-build + sudo apt-get install -y clang cmake ninja-build zip - name: Set up JDK 17 uses: actions/setup-java@v4 @@ -63,7 +63,7 @@ jobs: export FREESCHED_VERSION gradle -p android-aar assembleRelease --no-daemon - - name: Publish AAR to Maven Central (when secrets configured) + - name: Stage & publish AAR bundle to Maven Central Portal (when secrets configured) env: EVENT_NAME: ${{ github.event_name }} INPUT_VERSION: ${{ inputs.version }} @@ -71,18 +71,52 @@ jobs: MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - GPG_KEY_ID: ${{ vars.GPG_KEY_ID }} run: | + set -euo pipefail if [ "${EVENT_NAME}" = "workflow_dispatch" ]; then FREESCHED_VERSION="${INPUT_VERSION:-0.2.0}" else FREESCHED_VERSION="${GITHUB_REF_NAME#v}" fi export FREESCHED_VERSION + + rm -rf android-aar/build/staging-repo android-aar/build/freesched-android-*.zip + gradle -p android-aar publishReleasePublicationToLocalStagingRepository --no-daemon + + STAGE_REL="io/github/freesilicon/freesched-android/${FREESCHED_VERSION}" + STAGE_DIR="android-aar/build/staging-repo/${STAGE_REL}" + for ext in aar pom; do + ls "${STAGE_DIR}/freesched-android-${FREESCHED_VERSION}.${ext}" >/dev/null + done + ls "${STAGE_DIR}/freesched-android-${FREESCHED_VERSION}-sources.jar" >/dev/null + ls "${STAGE_DIR}/freesched-android-${FREESCHED_VERSION}-javadoc.jar" >/dev/null + + find android-aar/build/staging-repo -name 'maven-metadata.xml*' -delete + for f in "${STAGE_DIR}"/*; do + [ -f "$f" ] || continue + case "$f" in + *.asc|*.md5|*.sha1|*.sha256|*.sha512) continue ;; + esac + [ -f "${f}.md5" ] || md5sum "$f" | awk '{print $1}' > "${f}.md5" + [ -f "${f}.sha1" ] || sha1sum "$f" | awk '{print $1}' > "${f}.sha1" + if [ -n "${GPG_PRIVATE_KEY:-}" ] && [ ! -f "${f}.asc" ]; then + echo "Missing signature for ${f}" >&2 + exit 1 + fi + done + + BUNDLE_ZIP="android-aar/build/freesched-android-${FREESCHED_VERSION}-bundle.zip" + (cd android-aar/build/staging-repo && zip -r "../freesched-android-${FREESCHED_VERSION}-bundle.zip" "${STAGE_REL}") + if [ -n "${MAVEN_CENTRAL_USERNAME:-}" ] && [ -n "${MAVEN_CENTRAL_PASSWORD:-}" ]; then - gradle -p android-aar publishReleasePublicationToMavenCentralRepository --no-daemon + CENTRAL_AUTH="$(printf '%s:%s' "${MAVEN_CENTRAL_USERNAME}" "${MAVEN_CENTRAL_PASSWORD}" | base64 | tr -d '\n')" + curl --fail-with-body -sS -X POST \ + "https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC&name=freesched-android-${FREESCHED_VERSION}" \ + -H "Authorization: Bearer ${CENTRAL_AUTH}" \ + -F "bundle=@${BUNDLE_ZIP}" + echo "" else - echo "Maven Central secrets not configured; skipping publish." + echo "Maven Central secrets not configured; skipping Central Portal upload." fi - name: Collect release artifacts diff --git a/CMakeLists.txt b/CMakeLists.txt index bf84d79..226e91f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,9 +7,12 @@ option(FREESCHED_BUILD_TOOLS "Build freesched CLI tools" ON) option(FS_GOV_EXPERIMENTAL "Enable experimental ADPF/ARR/LMKD/SVE2 governor modules" OFF) option(FS_MTE_OPT_IN_UNSAFE_THREAD_DISABLE "Compile in opt-in unsafe prctl(PR_SET_TAGGED_ADDR_CTRL, 0) helper" OFF) -set(FREESCHED_OPENBUENOS_DIR "" CACHE PATH "Optional libopenbuenos root for direct EdgeTPU/FreeTile linkage") -if (NOT FREESCHED_OPENBUENOS_DIR AND DEFINED OPENBUENOS_DIR AND NOT "${OPENBUENOS_DIR}" STREQUAL "") - set(FREESCHED_OPENBUENOS_DIR "${OPENBUENOS_DIR}") +set(FREESCHED_FREETPU_DIR "" CACHE PATH "Optional libfreetpu root (freesilicon/freetpu) for direct EdgeTPU/FreeTile linkage") +set(_FREESCHED_TPU_DIR "${FREESCHED_FREETPU_DIR}") +if (NOT _FREESCHED_TPU_DIR AND DEFINED FREETPU_ROOT AND NOT "${FREETPU_ROOT}" STREQUAL "") + set(_FREESCHED_TPU_DIR "${FREETPU_ROOT}") +elseif (NOT _FREESCHED_TPU_DIR AND DEFINED FREETPU_DIR AND NOT "${FREETPU_DIR}" STREQUAL "") + set(_FREESCHED_TPU_DIR "${FREETPU_DIR}") endif() add_library(freesched STATIC @@ -17,7 +20,7 @@ add_library(freesched STATIC src/fs_dmabuf.cpp src/fs_router.cpp src/fs_executor.cpp - src/fs_backend_openbuenos.cpp + src/fs_backend_freetpu.cpp src/fs_backend_vulkan_dmabuf.cpp src/fs_vk_adreno_caps.c src/fs_vk_adreno_spirv_embed.c @@ -87,32 +90,39 @@ elseif (APPLE) target_link_libraries(freesched PUBLIC m) endif() -if (FREESCHED_OPENBUENOS_DIR) - find_path(_FREESCHED_OB_INCLUDE openbuenos.h - PATHS "${FREESCHED_OPENBUENOS_DIR}/include" +if (_FREESCHED_TPU_DIR) + find_path(_FREESCHED_FREETPU_INCLUDE + NAMES freetpu.h + PATHS + "${_FREESCHED_TPU_DIR}/include" + "${_FREESCHED_TPU_DIR}/libfreetpu/include" + "${_FREESCHED_TPU_DIR}" NO_DEFAULT_PATH) if (APPLE) - set(_FREESCHED_OB_LIB_PATHS - "${FREESCHED_OPENBUENOS_DIR}/build/host" - "${FREESCHED_OPENBUENOS_DIR}/build" - "${FREESCHED_OPENBUENOS_DIR}") + set(_FREESCHED_FREETPU_LIB_PATHS + "${_FREESCHED_TPU_DIR}/lib" + "${_FREESCHED_TPU_DIR}/build/host" + "${_FREESCHED_TPU_DIR}/build" + "${_FREESCHED_TPU_DIR}") else() - set(_FREESCHED_OB_LIB_PATHS - "${FREESCHED_OPENBUENOS_DIR}/build/linux-arm64" - "${FREESCHED_OPENBUENOS_DIR}/build/host" - "${FREESCHED_OPENBUENOS_DIR}/build" - "${FREESCHED_OPENBUENOS_DIR}") + set(_FREESCHED_FREETPU_LIB_PATHS + "${_FREESCHED_TPU_DIR}/lib" + "${_FREESCHED_TPU_DIR}/build/linux-arm64" + "${_FREESCHED_TPU_DIR}/build/host" + "${_FREESCHED_TPU_DIR}/build" + "${_FREESCHED_TPU_DIR}") endif() - find_library(_FREESCHED_OB_LIB openbuenos - PATHS ${_FREESCHED_OB_LIB_PATHS} + find_library(_FREESCHED_FREETPU_LIB + NAMES freetpu + PATHS ${_FREESCHED_FREETPU_LIB_PATHS} NO_DEFAULT_PATH) - if (_FREESCHED_OB_INCLUDE AND _FREESCHED_OB_LIB) - message(STATUS "freesched: linking static libopenbuenos (${_FREESCHED_OB_LIB})") - target_compile_definitions(freesched PRIVATE FREESCHED_HAVE_LIBOPENBUENOS=1) - target_include_directories(freesched PRIVATE "${_FREESCHED_OB_INCLUDE}") - target_link_libraries(freesched PUBLIC "${_FREESCHED_OB_LIB}") + if (_FREESCHED_FREETPU_INCLUDE AND _FREESCHED_FREETPU_LIB) + message(STATUS "freesched: linking static libfreetpu (${_FREESCHED_FREETPU_LIB})") + target_compile_definitions(freesched PRIVATE FREESCHED_HAVE_LIBFREETPU=1) + target_include_directories(freesched PRIVATE "${_FREESCHED_FREETPU_INCLUDE}") + target_link_libraries(freesched PUBLIC "${_FREESCHED_FREETPU_LIB}") else() - message(FATAL_ERROR "FREESCHED_OPENBUENOS_DIR='${FREESCHED_OPENBUENOS_DIR}' missing openbuenos.h or libopenbuenos") + message(FATAL_ERROR "FREESCHED_FREETPU_DIR='${_FREESCHED_TPU_DIR}' missing freetpu.h or libfreetpu") endif() endif() @@ -126,9 +136,9 @@ add_executable(volcanic_tpu_dmabuf_bench tools/volcanic_tpu_dmabuf_bench.cpp) target_link_libraries(volcanic_tpu_dmabuf_bench PRIVATE freesched) target_compile_features(volcanic_tpu_dmabuf_bench PRIVATE cxx_std_17) target_compile_options(volcanic_tpu_dmabuf_bench PRIVATE -Wall -Wextra -Werror -fno-exceptions -fno-rtti) -if (_FREESCHED_OB_INCLUDE AND _FREESCHED_OB_LIB) - target_compile_definitions(volcanic_tpu_dmabuf_bench PRIVATE FREESCHED_HAVE_LIBOPENBUENOS=1) - target_include_directories(volcanic_tpu_dmabuf_bench PRIVATE "${_FREESCHED_OB_INCLUDE}") +if (_FREESCHED_FREETPU_INCLUDE AND _FREESCHED_FREETPU_LIB) + target_compile_definitions(volcanic_tpu_dmabuf_bench PRIVATE FREESCHED_HAVE_LIBFREETPU=1) + target_include_directories(volcanic_tpu_dmabuf_bench PRIVATE "${_FREESCHED_FREETPU_INCLUDE}") endif() add_executable(volcanic_tpu_token_loop_bench tools/volcanic_tpu_token_loop_bench.cpp) @@ -136,9 +146,9 @@ target_link_libraries(volcanic_tpu_token_loop_bench PRIVATE freesched) target_include_directories(volcanic_tpu_token_loop_bench PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools) target_compile_features(volcanic_tpu_token_loop_bench PRIVATE cxx_std_17) target_compile_options(volcanic_tpu_token_loop_bench PRIVATE -Wall -Wextra -Werror -fno-exceptions -fno-rtti) -if (_FREESCHED_OB_INCLUDE AND _FREESCHED_OB_LIB) - target_compile_definitions(volcanic_tpu_token_loop_bench PRIVATE FREESCHED_HAVE_LIBOPENBUENOS=1) - target_include_directories(volcanic_tpu_token_loop_bench PRIVATE "${_FREESCHED_OB_INCLUDE}") +if (_FREESCHED_FREETPU_INCLUDE AND _FREESCHED_FREETPU_LIB) + target_compile_definitions(volcanic_tpu_token_loop_bench PRIVATE FREESCHED_HAVE_LIBFREETPU=1) + target_include_directories(volcanic_tpu_token_loop_bench PRIVATE "${_FREESCHED_FREETPU_INCLUDE}") endif() if (ANDROID) target_link_options(volcanic_tpu_token_loop_bench PRIVATE -static-libstdc++ -Wl,-z,max-page-size=16384) diff --git a/Makefile b/Makefile index 3bad471..ce599ac 100644 --- a/Makefile +++ b/Makefile @@ -16,14 +16,16 @@ LDFLAGS += -ldl STB_POSIX_FLAGS := -D_POSIX_C_SOURCE=200809L endif -OPENBUENOS_DIR ?= -ifneq ($(OPENBUENOS_DIR),) -OB_LIB := $(firstword $(wildcard $(OPENBUENOS_DIR)/build/host/libopenbuenos.a $(OPENBUENOS_DIR)/build/linux-arm64/libopenbuenos.a $(OPENBUENOS_DIR)/build/libopenbuenos.a)) -ifeq ($(OB_LIB),) -$(error OPENBUENOS_DIR=$(OPENBUENOS_DIR) specified but libopenbuenos.a not found) +FREETPU_ROOT ?= +FREETPU_DIR ?= +TPU_DIR := $(or $(FREETPU_ROOT),$(FREETPU_DIR)) +ifneq ($(TPU_DIR),) +FREETPU_LIB := $(firstword $(wildcard $(TPU_DIR)/lib/libfreetpu.a $(TPU_DIR)/build/host/libfreetpu.a $(TPU_DIR)/build/linux-arm64/libfreetpu.a $(TPU_DIR)/build/libfreetpu.a $(TPU_DIR)/libfreetpu.a)) +ifeq ($(FREETPU_LIB),) +$(error FREETPU_ROOT=$(TPU_DIR) specified but libfreetpu.a not found) endif -CXXFLAGS += -DFREESCHED_HAVE_LIBOPENBUENOS=1 -I$(OPENBUENOS_DIR)/include -LDFLAGS := $(OB_LIB) $(LDFLAGS) +CXXFLAGS += -DFREESCHED_HAVE_LIBFREETPU=1 -I$(TPU_DIR)/include $(if $(wildcard $(TPU_DIR)/libfreetpu/include),-I$(TPU_DIR)/libfreetpu/include) +LDFLAGS := $(FREETPU_LIB) $(LDFLAGS) endif SRCS := \ @@ -31,7 +33,7 @@ SRCS := \ $(THIS_DIR)/src/fs_dmabuf.cpp \ $(THIS_DIR)/src/fs_router.cpp \ $(THIS_DIR)/src/fs_executor.cpp \ - $(THIS_DIR)/src/fs_backend_openbuenos.cpp \ + $(THIS_DIR)/src/fs_backend_freetpu.cpp \ $(THIS_DIR)/src/fs_backend_vulkan_dmabuf.cpp \ $(THIS_DIR)/src/ggml_freesilicon.cpp \ $(THIS_DIR)/src/pc_gguf.cpp \ diff --git a/android-aar/build.gradle.kts b/android-aar/build.gradle.kts index 64b18df..98a885e 100644 --- a/android-aar/build.gradle.kts +++ b/android-aar/build.gradle.kts @@ -10,6 +10,7 @@ val freeschedVersion = (System.getenv("FREESCHED_VERSION") ?: "0.2.0").removePre android { namespace = "io.github.freesilicon.freesched" compileSdk = 35 + ndkVersion = "27.0.12077973" defaultConfig { minSdk = 31 @@ -94,29 +95,18 @@ afterEvaluate { repositories { maven { - name = "MavenCentral" - val centralUrl = System.getenv("MAVEN_CENTRAL_URL") - ?: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - url = uri(centralUrl) - credentials { - username = System.getenv("MAVEN_CENTRAL_USERNAME") ?: "" - password = System.getenv("MAVEN_CENTRAL_PASSWORD") ?: "" - } + name = "LocalStaging" + url = uri(layout.buildDirectory.dir("staging-repo")) } } } signing { - val keyId = System.getenv("GPG_KEY_ID") val signingKey = System.getenv("GPG_PRIVATE_KEY") val signingPassword = System.getenv("GPG_PASSPHRASE") isRequired = !signingKey.isNullOrBlank() if (!signingKey.isNullOrBlank() && !signingPassword.isNullOrBlank()) { - if (!keyId.isNullOrBlank()) { - useInMemoryPgpKeys(keyId, signingKey, signingPassword) - } else { - useInMemoryPgpKeys(signingKey, signingPassword) - } + useInMemoryPgpKeys(signingKey, signingPassword) sign(publishing.publications["release"]) } } diff --git a/android/src/main/cpp/CMakeLists.txt b/android/src/main/cpp/CMakeLists.txt index 4e8c148..ef8a565 100644 --- a/android/src/main/cpp/CMakeLists.txt +++ b/android/src/main/cpp/CMakeLists.txt @@ -15,7 +15,7 @@ add_library(freesched SHARED ${FS_ROOT}/src/fs_governor.cpp ${FS_ROOT}/src/fs_router.cpp ${FS_ROOT}/src/fs_executor.cpp - ${FS_ROOT}/src/fs_backend_openbuenos.cpp + ${FS_ROOT}/src/fs_backend_freetpu.cpp ${FS_ROOT}/src/fs_backend_vulkan_dmabuf.cpp ${FS_ROOT}/src/fs_vk_adreno_caps.c ${FS_ROOT}/src/fs_vk_adreno_spirv_embed.c diff --git a/docs/ANDROID_PLAYBOOK.md b/docs/ANDROID_PLAYBOOK.md index 97ebd62..ef87f39 100644 --- a/docs/ANDROID_PLAYBOOK.md +++ b/docs/ANDROID_PLAYBOOK.md @@ -112,7 +112,7 @@ Still stock Android userspace (Termux/root shell) — root only opens the two de ### 3.1 Direct EdgeTPU (`/dev/edgetpu-soc`) -The clean-room backend is `freesilicon/freetpu` (`libopenbuenos` + FreeTile), bound in `src/fs_backend_openbuenos.cpp`: it probes `/dev/edgetpu-soc` (default `device_path`), maps DMA-BUFs with `EDGETPU_MAP_DMABUF` (36-bit IOVA), registers immutable weight regions with upfront quantized prepacking (zero runtime repack loop; weight-cache hits/evictions are counted, never silently repacked), enforces `fs_dmabuf_reconcile()` upfront, fails closed on tiled layouts, and falls back to exact host reference with `allow_mock_fallback == 1`. Link it statically on the host build with `OPENBUENOS_DIR= make verify` (expects `libopenbuenos.a` under that tree, defines `FREESCHED_HAVE_LIBOPENBUENOS=1`), or let it resolve dynamically via `dlopen`/`dlsym`. DSpark speculative decoding reuses the same cache discipline: `fs_moe_plan_dspark_union` (hit-first exact union, miss tiles of at most 8 experts), then `fs_moe_streamer_begin_speculative` / `commit_speculative` / `rollback_speculative` so rejected drafts never pollute committed LFU counts and accepted tokens reuse prepacked weights with no repack. +The clean-room backend is `freesilicon/freetpu` (`libfreetpu` + FreeTile), bound in `src/fs_backend_freetpu.cpp`: it probes `/dev/edgetpu-soc` (default `device_path`), maps DMA-BUFs with `EDGETPU_MAP_DMABUF` (36-bit IOVA), registers immutable weight regions with upfront quantized prepacking (zero runtime repack loop; weight-cache hits/evictions are counted, never silently repacked), enforces `fs_dmabuf_reconcile()` upfront, fails closed on tiled layouts, and falls back to exact host reference with `allow_mock_fallback == 1`. Link it statically on the host build with `FREETPU_ROOT= make verify` (expects `libfreetpu.a` under that tree, defines `FREESCHED_HAVE_LIBFREETPU=1`), or let it resolve dynamically via `dlopen`/`dlsym` (`libfreetpu.so`). DSpark speculative decoding reuses the same cache discipline: `fs_moe_plan_dspark_union` (hit-first exact union, miss tiles of at most 8 experts), then `fs_moe_streamer_begin_speculative` / `commit_speculative` / `rollback_speculative` so rejected drafts never pollute committed LFU counts and accepted tokens reuse prepacked weights with no repack. ### 3.2 Zero-copy EdgeTPU <-> Vulkan hybrid (`/dev/dma_heap/system`) diff --git a/include/freesched.h b/include/freesched.h index 8a65ad0..5fc75da 100644 --- a/include/freesched.h +++ b/include/freesched.h @@ -7,7 +7,7 @@ * Frozen Pure C11 / C++17 Public ABI Header. * * Coordinates heterogeneous unified-memory execution across: - * - EdgeTPU (freesilicon/freetpu -> libopenbuenos, EDGETPU_MAP_DMABUF) + * - EdgeTPU (freesilicon/freetpu -> libfreetpu, EDGETPU_MAP_DMABUF) * - Vulkan GPU (freesilicon/freepvr -> PowerVR Volcanic, VK_KHR_external_memory_fd) * - ARMv9 NEON / SME2 CPU (attention, RoPE, RMSNorm, control glue) * @@ -69,7 +69,7 @@ typedef enum fs_status { typedef enum fs_dev { FS_DEV_NONE = 0, - FS_DEV_TPU = 1, /* EdgeTPU (libopenbuenos / buenos_a0 / malibu) */ + FS_DEV_TPU = 1, /* EdgeTPU (libfreetpu / buenos_a0 / malibu) */ FS_DEV_GPU_VK = 2, /* Vulkan GPU (PowerVR Volcanic DXT / CXTP) */ FS_DEV_CPU_NEON = 3, /* ARMv9 NEON (or portable host CPU fallback) */ FS_DEV_CPU_SME2 = 4, /* ARMv9 SME2 matrix-tile CPU extension */ @@ -191,7 +191,7 @@ typedef struct fs_topology { } fs_topology_t; /* ========================================================================= - * Quantization Blocks & Data Types (1:1 ABI alignment with openbuenos & ggml) + * Quantization Blocks & Data Types (1:1 ABI alignment with freetpu.h & ggml) * ========================================================================= */ typedef enum fs_dtype { @@ -203,7 +203,7 @@ typedef enum fs_dtype { FS_DTYPE_I32 = 5 } fs_dtype_t; -/* Matches enum ob_activation in openbuenos.h */ +/* Matches enum ob_activation in freetpu.h */ typedef enum fs_activation { FS_ACT_NONE = 0, FS_ACT_RELU = 1, @@ -492,7 +492,7 @@ typedef struct fs_config { /* * Pluggable accelerator backend vtable. * - * Allows freesilicon/freetpu (libopenbuenos) and freesilicon/freepvr (Vulkan) + * Allows freesilicon/freetpu (libfreetpu) and freesilicon/freepvr (Vulkan) * to plug into freesched without introducing circular build dependencies. */ typedef struct fs_backend_ops { @@ -514,20 +514,20 @@ typedef struct fs_backend_ops { } fs_backend_ops_t; /* Optional real backend adapter configurations (zero hard vendor deps) */ -typedef struct fs_openbuenos_config { - uint32_t struct_size; /* Optional: sizeof(fs_openbuenos_config_t) or 0 */ - const char* library_path; /* NULL -> probe libopenbuenos.so / host fallback */ +typedef struct fs_freetpu_config { + uint32_t struct_size; /* Optional: sizeof(fs_freetpu_config_t) or 0 */ + const char* library_path; /* NULL -> probe libfreetpu.so / host fallback */ const char* device_path; /* NULL -> "/dev/edgetpu-soc" */ const char* dma_heap_path; /* NULL -> "/dev/dma_heap/system" */ int allow_mock_fallback; /* 1 = run exact host reference if TPU/lib absent */ uint8_t perf_mode; /* 0..5 DVFS tier matching ob_config_t::perf_mode */ uint8_t reserved[3]; - const char* dive_interp_path; /* NULL -> OPENBUENOS_DIVE_INTERP_PATH / firmware probe */ + const char* dive_interp_path; /* NULL -> FREETPU_DIVE_INTERP_PATH / firmware probe */ int enable_freetile; /* 1 = enable FreeTile BUENOS_A0 VLIW emitter (default 1) */ - uint32_t weight_cache_mb; /* 0 = auto / OPENBUENOS_WEIGHT_CACHE_MB env */ -} fs_openbuenos_config_t; + uint32_t weight_cache_mb; /* 0 = auto / FREETPU_WEIGHT_CACHE_MB env */ +} fs_freetpu_config_t; -typedef struct fs_openbuenos_profile { +typedef struct fs_freetpu_profile { int hw_active; int emitter_active; int freetile_active; @@ -543,7 +543,7 @@ typedef struct fs_openbuenos_profile { uint64_t weight_cache_bytes; uint64_t weight_cache_peak_bytes; uint64_t weight_cache_budget_bytes; -} fs_openbuenos_profile_t; +} fs_freetpu_profile_t; typedef struct fs_vulkan_dmabuf_config { uint32_t struct_size; /* Optional: sizeof(fs_vulkan_dmabuf_config_t) or 0 */ @@ -637,15 +637,15 @@ fs_status_t fs_context_register_backend(fs_context_t* ctx, const fs_backend_ops_t* ops); /* Optional hardware backend adapter seams (dynamic/zero hard vendor deps) */ -fs_openbuenos_config_t fs_openbuenos_config_default(void); +fs_freetpu_config_t fs_freetpu_config_default(void); fs_vulkan_dmabuf_config_t fs_vulkan_dmabuf_config_default(void); -fs_status_t fs_backend_register_openbuenos(fs_context_t* ctx, - const fs_openbuenos_config_t* cfg); -fs_status_t fs_backend_openbuenos_prepack_op(fs_context_t* ctx, - const fs_op_desc_t* op); -fs_status_t fs_backend_openbuenos_get_profile(const fs_context_t* ctx, - fs_openbuenos_profile_t* out_profile); +fs_status_t fs_backend_register_freetpu(fs_context_t* ctx, + const fs_freetpu_config_t* cfg); +fs_status_t fs_backend_freetpu_prepack_op(fs_context_t* ctx, + const fs_op_desc_t* op); +fs_status_t fs_backend_freetpu_get_profile(const fs_context_t* ctx, + fs_freetpu_profile_t* out_profile); fs_status_t fs_backend_register_vulkan_dmabuf(fs_context_t* ctx, const fs_vulkan_dmabuf_config_t* cfg); fs_status_t fs_backend_vulkan_dmabuf_get_profile(const fs_context_t* ctx, diff --git a/include/pocketcoder_runner.h b/include/pocketcoder_runner.h index 28fc5f1..228ace1 100644 --- a/include/pocketcoder_runner.h +++ b/include/pocketcoder_runner.h @@ -8,7 +8,7 @@ * 1. Direct mmap-backed GGUF reader with strict bounds & inkling2_loop checks * 2. 1024-token sliding-window KV ring buffer (40/48 looped visits) * 3. 16-byte SoA expert repacker (Q4_0, IQ4_NL, IQ4_XS) + ARM64 NEON/sdot GEMV - * 4. Pre-baked zero-copy DMA-BUF execution graph + openbuenos & DSpark dedup + * 4. Pre-baked zero-copy DMA-BUF execution graph + libfreetpu & DSpark dedup */ #ifndef POCKETCODER_RUNNER_H_ #define POCKETCODER_RUNNER_H_ @@ -363,7 +363,7 @@ fs_status_t pc_graph_step_bound(pc_graph_t* graph, /* * Executes one pre-baked heterogeneous layer step: * RMSNorm (CPU_NEON/SME2) -> zero-copy DMA-BUF handoff -> - * DECODE_GEMV (EdgeTPU/openbuenos) -> Parity check vs reference + * DECODE_GEMV (EdgeTPU/libfreetpu) -> Parity check vs reference */ fs_status_t pc_graph_run_prebaked_step(pc_graph_t* graph, const float* x_in, diff --git a/scripts/token_loop_receipt.py b/scripts/token_loop_receipt.py index c16a796..2448157 100644 --- a/scripts/token_loop_receipt.py +++ b/scripts/token_loop_receipt.py @@ -1096,17 +1096,17 @@ def verify_arm64_build_dir(bdir: str, want_openbuenos: bool, ndk: str, repo: str ndk_refs = [cache.get(k, "") for k in ("ANDROID_NDK", "CMAKE_TOOLCHAIN_FILE", "CMAKE_CXX_COMPILER")] if not any(r and (os.path.realpath(r).startswith(ndk_real) or ndk_base in r) for r in ndk_refs): return False, f"FAIL: build dir {bdir} does not reference NDK {ndk_base!r}", None - ob_dir = cache.get("FREESCHED_OPENBUENOS_DIR", "") - ob_inc = cache.get("_FREESCHED_OB_INCLUDE", "") - ob_lib = cache.get("_FREESCHED_OB_LIB", "") + ob_dir = cache.get("FREESCHED_FREETPU_DIR", "") + ob_inc = cache.get("_FREESCHED_FREETPU_INCLUDE", "") + ob_lib = cache.get("_FREESCHED_FREETPU_LIB", "") has_ob = (bool(ob_dir) and bool(ob_inc) and not ob_inc.endswith("-NOTFOUND") and bool(ob_lib) and not ob_lib.endswith("-NOTFOUND")) if want_openbuenos and not has_ob: - return False, (f"FAIL: expected libopenbuenos enabled (FREESCHED_OPENBUENOS_DIR={ob_dir!r}, " - f"_FREESCHED_OB_LIB={ob_lib!r})"), None + return False, (f"FAIL: expected libfreetpu enabled (FREESCHED_FREETPU_DIR={ob_dir!r}, " + f"_FREESCHED_FREETPU_LIB={ob_lib!r})"), None if not want_openbuenos and (ob_dir or has_ob): - return False, (f"FAIL: expected libopenbuenos disabled, but FREESCHED_OPENBUENOS_DIR={ob_dir!r} " - f"_FREESCHED_OB_LIB={ob_lib!r}"), None + return False, (f"FAIL: expected libfreetpu disabled, but FREESCHED_FREETPU_DIR={ob_dir!r} " + f"_FREESCHED_FREETPU_LIB={ob_lib!r}"), None rc, out = _run(["cmake", "--build", bdir, "--target", "volcanic_tpu_token_loop_bench", "test_token_loop_riif"]) if rc != 0: return False, "FAIL: cmake --build failed: " + out.strip()[-200:], None @@ -1127,7 +1127,7 @@ def verify_arm64_matrix(a64_ob: str, a64_noob: str, ndk: str, repo: str) -> list ok_ob, res_ob, sha_ob = verify_arm64_build_dir(a64_ob, True, ndk, repo) ok_no, res_no, sha_no = verify_arm64_build_dir(a64_noob, False, ndk, repo) if ok_ob and ok_no and sha_ob == sha_no: - msg = f"FAIL: with/without libopenbuenos produced identical bench SHA-256 {sha_ob}" + msg = f"FAIL: with/without libfreetpu produced identical bench SHA-256 {sha_ob}" return [("with", msg), ("without", msg)] return [("with", res_ob), ("without", res_no)] @@ -1301,7 +1301,7 @@ def cmd_host_verify(a): "result": f"{'PASS' if rc == 0 else 'FAIL'}, {m.group(1) if m else '?'} errors"}) a64_results = verify_arm64_matrix(a.a64_ob, a.a64_noob, a.ndk, repo) for label, result in a64_results: - checks.append({"check": f"`arm64-v8a` CMake build {label} `libopenbuenos` (NDK `{os.path.basename(a.ndk)}`, " + checks.append({"check": f"`arm64-v8a` CMake build {label} `libfreetpu` (NDK `{os.path.basename(a.ndk)}`, " "`-Wall -Wextra -Werror`)", "result": result}) try: @@ -1313,8 +1313,8 @@ def cmd_host_verify(a): "-Wextra", "-Werror", "-Wunused-parameter", "-Wunused-variable", "-Wunused-but-set-variable", "-fno-exceptions", "-fno-rtti", f"-I{repo}/include", f"-I{repo}/tools"] variants = [("bench", [], "tools/volcanic_tpu_token_loop_bench.cpp"), - ("bench + `FREESCHED_HAVE_LIBOPENBUENOS`", ["-DFREESCHED_HAVE_LIBOPENBUENOS=1", - f"-I{a.ob_include}"], "tools/volcanic_tpu_token_loop_bench.cpp"), + ("bench + `FREESCHED_HAVE_LIBFREETPU`", ["-DFREESCHED_HAVE_LIBFREETPU=1", + f"-I{a.ob_include}"], "tools/volcanic_tpu_token_loop_bench.cpp"), ("unit test", [], "tests/test_token_loop_riif.cpp")] for label, extra, src in variants: rc, out = _run([*base, *extra, os.path.join(repo, src)]) diff --git a/scripts/verify-android-playbook-smoke.sh b/scripts/verify-android-playbook-smoke.sh index 9cb8920..b587a33 100755 --- a/scripts/verify-android-playbook-smoke.sh +++ b/scripts/verify-android-playbook-smoke.sh @@ -28,7 +28,7 @@ for needle in \ "AThermal_getThermalHeadroom" "getThermalHeadroom" "getThermalStatus" "fs_thermal_calendar.h" \ "spinlock" "FS_IO_PREAD_BUFFERED" \ "/dev/edgetpu-soc" "/dev/dma_heap/system" "EDGETPU_MAP_DMABUF" \ - "libopenbuenos" "DSpark" "SELinux" "lmkd" "FUSE" \ + "libfreetpu" "DSpark" "SELinux" "lmkd" "FUSE" \ "max-page-size=16384" "verify-android-16k-aar.sh" "audit-no-async-ring.sh" \ "proof/sm8850-v81-hmx/PROOF.md" "proof/sm8850-v81-tiled-vla/PROOF.md" \ "readelf -l" "readelf -d" "DT_NEEDED" \ diff --git a/src/fs_backend_openbuenos.cpp b/src/fs_backend_freetpu.cpp similarity index 87% rename from src/fs_backend_openbuenos.cpp rename to src/fs_backend_freetpu.cpp index 5dffe54..c72df99 100644 --- a/src/fs_backend_openbuenos.cpp +++ b/src/fs_backend_freetpu.cpp @@ -1,12 +1,13 @@ /* - * freesched optional OpenBuenos EdgeTPU backend adapter seam. + * freesched optional FreeTPU EdgeTPU backend adapter seam. * * Copyright 2026 FreeSilicon Contributors * SPDX-License-Identifier: Apache-2.0 * - * Clean-room freetpu (libopenbuenos + FreeTile) adapter: - * - Supports direct static libopenbuenos linkage (FREESCHED_HAVE_LIBOPENBUENOS=1, - * ideal for static ARM64 binaries) as well as dynamic dlopen/dlsym lookup. + * Clean-room freesilicon/freetpu (libfreetpu + FreeTile) adapter: + * - Supports direct static libfreetpu linkage (FREESCHED_HAVE_LIBFREETPU=1, + * ideal for static ARM64 binaries) as well as dynamic dlopen/dlsym lookup + * (libfreetpu.so). * - Probes /dev/edgetpu-soc + EDGETPU_MAP_DMABUF (36-bit IOVA) on Linux. * - Registers the clean-room DGC0/FreeTile emitter, immutable weight regions, * and upfront quantized weight prepacking (zero runtime repack/eviction loop). @@ -25,8 +26,8 @@ #include #include -#ifdef FREESCHED_HAVE_LIBOPENBUENOS -#include "openbuenos.h" +#ifdef FREESCHED_HAVE_LIBFREETPU +#include "freetpu.h" #endif #ifdef __linux__ @@ -54,7 +55,7 @@ static_assert(sizeof(fs_edgetpu_map_dmabuf_ioctl) == 40u, "edgetpu_map_dmabuf_io #define FS_EDGETPU_MAP_36BIT_IOVA (1u << 3) #endif /* __linux__ */ -/* 1:1 ABI-compatible mirrors of libopenbuenos/include/openbuenos.h */ +/* 1:1 ABI-compatible mirrors of libfreetpu/include/freetpu.h */ struct fs_ob_config { uint32_t struct_size; int mock_mode; @@ -146,7 +147,7 @@ struct fs_ob_gemm_swiglu_quant_desc { uint8_t reserved; }; -#ifdef FREESCHED_HAVE_LIBOPENBUENOS +#ifdef FREESCHED_HAVE_LIBFREETPU static_assert(sizeof(fs_ob_config) == sizeof(ob_config_t), "ob_config_t ABI mismatch"); static_assert(sizeof(fs_ob_invoke_stats) == sizeof(ob_invoke_stats_t), "ob_invoke_stats_t ABI mismatch"); static_assert(sizeof(fs_ob_profile_stats) == sizeof(ob_profile_stats_t), "ob_profile_stats_t ABI mismatch"); @@ -175,7 +176,7 @@ struct fs_ob_api { int (*dmabuf_unmap)(void*, uint64_t); }; -#ifdef FREESCHED_HAVE_LIBOPENBUENOS +#ifdef FREESCHED_HAVE_LIBFREETPU static int fs_wrap_ob_ctx_create(const fs_ob_config* c, void** out) { return static_cast(ob_context_create(reinterpret_cast(c), reinterpret_cast(out))); @@ -253,7 +254,7 @@ static int fs_wrap_ob_dmabuf_map(void* ctx, static int fs_wrap_ob_dmabuf_unmap(void* ctx, uint64_t iova) { return static_cast(ob_dmabuf_unmap(static_cast(ctx), iova)); } -#endif /* FREESCHED_HAVE_LIBOPENBUENOS */ +#endif /* FREESCHED_HAVE_LIBFREETPU */ struct fs_ob_immutable_reg { const void* base; @@ -261,8 +262,8 @@ struct fs_ob_immutable_reg { uint64_t version; }; -struct fs_openbuenos_state { - fs_openbuenos_config_t cfg; +struct fs_freetpu_state { + fs_freetpu_config_t cfg; int tpu_dev_fd; void* dl_handle; void* ob_ctx; @@ -274,25 +275,25 @@ struct fs_openbuenos_state { std::vector imm_regs; }; -static fs_openbuenos_config_t fs_normalize_ob_cfg(const fs_openbuenos_config_t* cfg) { - fs_openbuenos_config_t out = fs_openbuenos_config_default(); +static fs_freetpu_config_t fs_normalize_freetpu_cfg(const fs_freetpu_config_t* cfg) { + fs_freetpu_config_t out = fs_freetpu_config_default(); if (!cfg) { return out; } - if (cfg->struct_size == 0u || cfg->struct_size >= sizeof(fs_openbuenos_config_t)) { + if (cfg->struct_size == 0u || cfg->struct_size >= sizeof(fs_freetpu_config_t)) { out = *cfg; - out.struct_size = static_cast(sizeof(fs_openbuenos_config_t)); + out.struct_size = static_cast(sizeof(fs_freetpu_config_t)); if (out.perf_mode == 0u) out.perf_mode = 5u; return out; } - const size_t copy_n = std::min(cfg->struct_size, sizeof(fs_openbuenos_config_t)); + const size_t copy_n = std::min(cfg->struct_size, sizeof(fs_freetpu_config_t)); std::memcpy(&out, cfg, copy_n); - out.struct_size = static_cast(sizeof(fs_openbuenos_config_t)); + out.struct_size = static_cast(sizeof(fs_freetpu_config_t)); if (out.perf_mode == 0u) out.perf_mode = 5u; return out; } -static int fs_openbuenos_check_buf_compatible(const fs_dmabuf_t* buf) { +static int fs_freetpu_check_buf_compatible(const fs_dmabuf_t* buf) { if (!buf) { return 1; } @@ -315,9 +316,9 @@ static int fs_openbuenos_check_buf_compatible(const fs_dmabuf_t* buf) { return zc_ok; } -static void fs_ob_resolve_api(fs_openbuenos_state* st, int allow_dlopen) { +static void fs_freetpu_resolve_api(fs_freetpu_state* st, int allow_dlopen) { std::memset(&st->api, 0, sizeof(st->api)); -#ifdef FREESCHED_HAVE_LIBOPENBUENOS +#ifdef FREESCHED_HAVE_LIBFREETPU (void)allow_dlopen; st->api.ctx_create = fs_wrap_ob_ctx_create; st->api.ctx_destroy = fs_wrap_ob_ctx_destroy; @@ -338,7 +339,7 @@ static void fs_ob_resolve_api(fs_openbuenos_state* st, int allow_dlopen) { void* sym_handle = nullptr; if (allow_dlopen) { const char* lib_path = - (st->cfg.library_path && st->cfg.library_path[0] != '\0') ? st->cfg.library_path : "libopenbuenos.so"; + (st->cfg.library_path && st->cfg.library_path[0] != '\0') ? st->cfg.library_path : "libfreetpu.so"; st->dl_handle = dlopen(lib_path, RTLD_LAZY | RTLD_LOCAL); sym_handle = st->dl_handle ? st->dl_handle : RTLD_DEFAULT; } else { @@ -369,7 +370,7 @@ static void fs_ob_resolve_api(fs_openbuenos_state* st, int allow_dlopen) { #endif } -static void fs_ob_ensure_immutable_locked(fs_openbuenos_state* st, const fs_dmabuf_t* buf) { +static void fs_ob_ensure_immutable_locked(fs_freetpu_state* st, const fs_dmabuf_t* buf) { if (!st || !buf || !st->ob_ctx || !st->api.reg_immutable || (buf->flags & FS_BUF_IMMUTABLE_WEIGHT) == 0u || !buf->host_ptr || buf->size == 0u) { return; @@ -393,7 +394,7 @@ static void fs_ob_ensure_immutable_locked(fs_openbuenos_state* st, const fs_dmab } } -static void fs_ob_unreg_immutable_locked(fs_openbuenos_state* st, const fs_dmabuf_t* buf) { +static void fs_ob_unreg_immutable_locked(fs_freetpu_state* st, const fs_dmabuf_t* buf) { if (!st || !buf || !st->ob_ctx || !st->api.unreg_immutable || !buf->host_ptr) { return; } @@ -408,25 +409,25 @@ static void fs_ob_unreg_immutable_locked(fs_openbuenos_state* st, const fs_dmabu } } -static fs_status_t fs_openbuenos_init(void* user_data, const fs_topology_t* topo) { - auto* st = static_cast(user_data); +static fs_status_t fs_freetpu_init(void* user_data, const fs_topology_t* topo) { + auto* st = static_cast(user_data); if (!st) { return FS_ERR_INVALID_ARG; } - const char* ob_mock_env = std::getenv("OPENBUENOS_MOCK"); - const int env_mock = (ob_mock_env && std::strcmp(ob_mock_env, "1") == 0) ? 1 : 0; + const char* ft_mock_env = std::getenv("FREETPU_MOCK"); + const int env_mock = (ft_mock_env && std::strcmp(ft_mock_env, "1") == 0) ? 1 : 0; const int is_mock_topo = ((topo && (topo->global_caps & FS_CAP_MOCK) != 0u) || env_mock) ? 1 : 0; const char* dev_path = (st->cfg.device_path && st->cfg.device_path[0] != '\0') ? st->cfg.device_path : "/dev/edgetpu-soc"; - fs_ob_resolve_api(st, !is_mock_topo); + fs_freetpu_resolve_api(st, !is_mock_topo); const char* dive_path = (st->cfg.dive_interp_path && st->cfg.dive_interp_path[0] != '\0') ? st->cfg.dive_interp_path - : std::getenv("OPENBUENOS_DIVE_INTERP_PATH"); + : std::getenv("FREETPU_DIVE_INTERP_PATH"); const int has_explicit_dive = (dive_path && dive_path[0] != '\0') ? 1 : 0; if (st->api.ctx_create && st->api.ctx_destroy) { @@ -462,7 +463,7 @@ static fs_status_t fs_openbuenos_init(void* user_data, const fs_topology_t* topo } int ft_req = st->cfg.enable_freetile ? 1 : 0; - if (const char* ft_env = std::getenv("OPENBUENOS_FREETILE"); ft_env && ft_env[0] != '\0') { + if (const char* ft_env = std::getenv("FREETPU_FREETILE"); ft_env && ft_env[0] != '\0') { ft_req = (std::atoi(ft_env) != 0) ? 1 : 0; } if (st->api.set_freetile) { @@ -507,8 +508,8 @@ static fs_status_t fs_openbuenos_init(void* user_data, const fs_topology_t* topo return FS_OK; } -static void fs_openbuenos_shutdown(void* user_data) { - auto* st = static_cast(user_data); +static void fs_freetpu_shutdown(void* user_data) { + auto* st = static_cast(user_data); if (!st) { return; } @@ -538,7 +539,7 @@ static void fs_openbuenos_shutdown(void* user_data) { delete st; } -static int fs_openbuenos_supports(void* user_data, const fs_op_desc_t* op) { +static int fs_freetpu_supports(void* user_data, const fs_op_desc_t* op) { (void)user_data; if (!op) { return 0; @@ -560,14 +561,14 @@ static int fs_openbuenos_supports(void* user_data, const fs_op_desc_t* op) { } } -static fs_status_t fs_openbuenos_import_dmabuf(void* user_data, fs_dmabuf_t* buf) { - auto* st = static_cast(user_data); +static fs_status_t fs_freetpu_import_dmabuf(void* user_data, fs_dmabuf_t* buf) { + auto* st = static_cast(user_data); if (!st || !buf) { return FS_ERR_INVALID_ARG; } /* Fail closed on incompatible tiled layouts (TPU requires linear DMA-BUF) */ - if (!fs_openbuenos_check_buf_compatible(buf)) { + if (!fs_freetpu_check_buf_compatible(buf)) { return FS_ERR_UNSUPPORTED; } @@ -628,8 +629,8 @@ static fs_status_t fs_openbuenos_import_dmabuf(void* user_data, fs_dmabuf_t* buf return FS_OK; } -static void fs_openbuenos_release_dmabuf(void* user_data, fs_dmabuf_t* buf) { - auto* st = static_cast(user_data); +static void fs_freetpu_release_dmabuf(void* user_data, fs_dmabuf_t* buf) { + auto* st = static_cast(user_data); if (!st || !buf) { return; } @@ -658,12 +659,12 @@ static void fs_openbuenos_release_dmabuf(void* user_data, fs_dmabuf_t* buf) { buf->tpu_iova = 0u; } -static fs_status_t fs_openbuenos_execute(void* user_data, - const fs_op_desc_t* op, - const fs_fence_t* wait_fence, - fs_fence_t* out_signal_fence, - uint64_t* out_hw_us) { - auto* st = static_cast(user_data); +static fs_status_t fs_freetpu_execute(void* user_data, + const fs_op_desc_t* op, + const fs_fence_t* wait_fence, + fs_fence_t* out_signal_fence, + uint64_t* out_hw_us) { + auto* st = static_cast(user_data); if (!st || !op) { return FS_ERR_INVALID_ARG; } @@ -676,8 +677,8 @@ static fs_status_t fs_openbuenos_execute(void* user_data, } /* Fail closed if any active buffer is tiled */ - if (!fs_openbuenos_check_buf_compatible(op->input_a) || - !fs_openbuenos_check_buf_compatible(op->output)) { + if (!fs_freetpu_check_buf_compatible(op->input_a) || + !fs_freetpu_check_buf_compatible(op->output)) { return FS_ERR_UNSUPPORTED; } @@ -774,24 +775,24 @@ static fs_status_t fs_openbuenos_execute(void* user_data, return FS_OK; } -static fs_openbuenos_state* fs_lookup_openbuenos_state(const fs_context_t* ctx) { +static fs_freetpu_state* fs_lookup_freetpu_state(const fs_context_t* ctx) { if (!ctx) { return nullptr; } const fs_backend_slot& slot = ctx->backends[FS_DEV_TPU]; if (!slot.registered || !slot.ops.name || - std::strcmp(slot.ops.name, "openbuenos_dmabuf") != 0) { + std::strcmp(slot.ops.name, "freetpu_dmabuf") != 0) { return nullptr; } - return static_cast(slot.ops.user_data); + return static_cast(slot.ops.user_data); } extern "C" { -fs_openbuenos_config_t fs_openbuenos_config_default(void) { - fs_openbuenos_config_t cfg; +fs_freetpu_config_t fs_freetpu_config_default(void) { + fs_freetpu_config_t cfg; std::memset(&cfg, 0, sizeof(cfg)); - cfg.struct_size = static_cast(sizeof(fs_openbuenos_config_t)); + cfg.struct_size = static_cast(sizeof(fs_freetpu_config_t)); cfg.library_path = nullptr; cfg.device_path = nullptr; cfg.dma_heap_path = nullptr; @@ -803,16 +804,16 @@ fs_openbuenos_config_t fs_openbuenos_config_default(void) { return cfg; } -fs_status_t fs_backend_register_openbuenos(fs_context_t* ctx, - const fs_openbuenos_config_t* cfg) { +fs_status_t fs_backend_register_freetpu(fs_context_t* ctx, + const fs_freetpu_config_t* cfg) { if (!ctx) { return FS_ERR_INVALID_ARG; } - auto* st = new (std::nothrow) fs_openbuenos_state(); + auto* st = new (std::nothrow) fs_freetpu_state(); if (!st) { return FS_ERR_NO_MEMORY; } - st->cfg = fs_normalize_ob_cfg(cfg); + st->cfg = fs_normalize_freetpu_cfg(cfg); st->tpu_dev_fd = -1; st->dl_handle = nullptr; st->ob_ctx = nullptr; @@ -825,27 +826,27 @@ fs_status_t fs_backend_register_openbuenos(fs_context_t* ctx, std::memset(&ops, 0, sizeof(ops)); ops.struct_size = static_cast(sizeof(fs_backend_ops_t)); ops.dev = FS_DEV_TPU; - ops.name = "openbuenos_dmabuf"; + ops.name = "freetpu_dmabuf"; ops.user_data = st; - ops.init = fs_openbuenos_init; - ops.shutdown = fs_openbuenos_shutdown; - ops.supports_op = fs_openbuenos_supports; - ops.import_dmabuf = fs_openbuenos_import_dmabuf; - ops.release_dmabuf = fs_openbuenos_release_dmabuf; - ops.execute_op = fs_openbuenos_execute; + ops.init = fs_freetpu_init; + ops.shutdown = fs_freetpu_shutdown; + ops.supports_op = fs_freetpu_supports; + ops.import_dmabuf = fs_freetpu_import_dmabuf; + ops.release_dmabuf = fs_freetpu_release_dmabuf; + ops.execute_op = fs_freetpu_execute; fs_status_t rc = fs_context_register_backend(ctx, &ops); if (rc != FS_OK) { - fs_openbuenos_shutdown(st); + fs_freetpu_shutdown(st); } return rc; } -fs_status_t fs_backend_openbuenos_prepack_op(fs_context_t* ctx, const fs_op_desc_t* op) { +fs_status_t fs_backend_freetpu_prepack_op(fs_context_t* ctx, const fs_op_desc_t* op) { if (!ctx || !op) { return FS_ERR_INVALID_ARG; } - fs_openbuenos_state* st = fs_lookup_openbuenos_state(ctx); + fs_freetpu_state* st = fs_lookup_freetpu_state(ctx); if (!st) { return FS_OK; } @@ -880,13 +881,13 @@ fs_status_t fs_backend_openbuenos_prepack_op(fs_context_t* ctx, const fs_op_desc return (rc == 0) ? FS_OK : FS_ERR_DEVICE; } -fs_status_t fs_backend_openbuenos_get_profile(const fs_context_t* ctx, - fs_openbuenos_profile_t* out_profile) { +fs_status_t fs_backend_freetpu_get_profile(const fs_context_t* ctx, + fs_freetpu_profile_t* out_profile) { if (!ctx || !out_profile) { return FS_ERR_INVALID_ARG; } std::memset(out_profile, 0, sizeof(*out_profile)); - fs_openbuenos_state* st = fs_lookup_openbuenos_state(ctx); + fs_freetpu_state* st = fs_lookup_freetpu_state(ctx); if (!st) { return FS_ERR_NOT_FOUND; } diff --git a/src/fs_executor.cpp b/src/fs_executor.cpp index 573552c..eca26da 100644 --- a/src/fs_executor.cpp +++ b/src/fs_executor.cpp @@ -14,7 +14,7 @@ #include /* ========================================================================= - * IEEE-754 FP16 <-> FP32 & Quantized Block Math (1:1 with openbuenos / ggml) + * IEEE-754 FP16 <-> FP32 & Quantized Block Math (1:1 with freetpu.h / ggml) * ========================================================================= */ static float fs_f16_to_f32_impl(uint16_t h) { diff --git a/src/pc_dmabuf_graph.cpp b/src/pc_dmabuf_graph.cpp index bfb5ac9..4aa6664 100644 --- a/src/pc_dmabuf_graph.cpp +++ b/src/pc_dmabuf_graph.cpp @@ -1,5 +1,5 @@ /* - * Pre-baked zero-copy DMA-BUF graph + openbuenos EdgeTPU adapter wiring + + * Pre-baked zero-copy DMA-BUF graph + libfreetpu EdgeTPU adapter wiring + * DSpark (MAX_DUP=3/4) speculative expert deduplication planner. * * Copyright 2026 FreeSilicon Contributors @@ -187,13 +187,13 @@ fs_status_t pc_graph_create(const pc_graph_config_t* cfg, pc_graph_t** out_graph return rc; } - /* Wire freesched's optional openbuenos EdgeTPU adapter (DIVE + FreeTile + mock fallback) */ - fs_openbuenos_config_t ob_cfg = fs_openbuenos_config_default(); - ob_cfg.allow_mock_fallback = eff.require_tpu_hw ? 0 : 1; - ob_cfg.dive_interp_path = eff.dive_interp_path; - ob_cfg.enable_freetile = 1; - ob_cfg.perf_mode = (eff.perf_mode <= 5u) ? eff.perf_mode : 5u; - rc = fs_backend_register_openbuenos(ctx, &ob_cfg); + /* Wire freesched's optional libfreetpu EdgeTPU adapter (DIVE + FreeTile + mock fallback) */ + fs_freetpu_config_t ob_cfg = fs_freetpu_config_default(); + ob_cfg.allow_mock_fallback = eff.require_tpu_hw ? 0 : 1; + ob_cfg.dive_interp_path = eff.dive_interp_path; + ob_cfg.enable_freetile = 1; + ob_cfg.perf_mode = (eff.perf_mode <= 5u) ? eff.perf_mode : 5u; + rc = fs_backend_register_freetpu(ctx, &ob_cfg); if (rc != FS_OK) { fs_context_destroy(ctx); return rc; @@ -238,7 +238,7 @@ fs_status_t pc_graph_create(const pc_graph_config_t* cfg, pc_graph_t** out_graph return FS_ERR_NO_MEMORY; } - /* Pre-bake heterogeneous execution plan: RMSNorm (CPU) -> Q4_0 GEMV (EdgeTPU/openbuenos) */ + /* Pre-bake heterogeneous execution plan: RMSNorm (CPU) -> Q4_0 GEMV (EdgeTPU/libfreetpu) */ std::memset(g->ops, 0, sizeof(g->ops)); g->ops[0].op_id = 0u; g->ops[0].type = FS_OP_RMS_NORM; @@ -328,9 +328,9 @@ static fs_status_t pc_fill_graph_stats(const pc_graph_t* graph, fs_telemetry_t tel; fs_context_get_telemetry(graph->ctx, &tel); - fs_openbuenos_profile_t ob_prof; + fs_freetpu_profile_t ob_prof; std::memset(&ob_prof, 0, sizeof(ob_prof)); - (void)fs_backend_openbuenos_get_profile(graph->ctx, &ob_prof); + (void)fs_backend_freetpu_get_profile(graph->ctx, &ob_prof); std::memset(out_stats, 0, sizeof(*out_stats)); out_stats->reconciled_zero_copy = graph->reconciled.zero_copy_compatible; @@ -382,7 +382,7 @@ fs_status_t pc_graph_bind_weights(pc_graph_t* graph, } /* Register immutable region + prepack EdgeTPU ext[2] tiles & DIVE graphs upfront */ - rc = fs_backend_openbuenos_prepack_op(graph->ctx, &graph->ops[1]); + rc = fs_backend_freetpu_prepack_op(graph->ctx, &graph->ops[1]); if (rc != FS_OK) { return rc; } diff --git a/tests/test_c11_abi.c b/tests/test_c11_abi.c index bc7f561..35c119c 100644 --- a/tests/test_c11_abi.c +++ b/tests/test_c11_abi.c @@ -21,8 +21,8 @@ _Static_assert(sizeof(fs_block_q8_0_t) == 34u, "fs_block_q8_0_t must be 34 bytes"); _Static_assert(sizeof(fs_block_q4_0_t) == 18u, "fs_block_q4_0_t must be 18 bytes"); -_Static_assert(FS_ACT_SILU == 4, "FS_ACT_SILU must match openbuenos OB_ACT_SILU"); -_Static_assert(FS_ACT_GELU == 5, "FS_ACT_GELU must match openbuenos OB_ACT_GELU"); +_Static_assert(FS_ACT_SILU == 4, "FS_ACT_SILU must match libfreetpu OB_ACT_SILU"); +_Static_assert(FS_ACT_GELU == 5, "FS_ACT_GELU must match libfreetpu OB_ACT_GELU"); #define CHECK(cond) \ do { \ @@ -177,13 +177,13 @@ int main(void) { fs_buffer_release(ctx, rec_buf); /* Verify C11 optional backend adapter registration & telemetry APIs */ - fs_openbuenos_config_t ob_cfg = fs_openbuenos_config_default(); + fs_freetpu_config_t ob_cfg = fs_freetpu_config_default(); CHECK(ob_cfg.enable_freetile == 1); CHECK(ob_cfg.perf_mode == 5u); fs_vulkan_dmabuf_config_t vk_cfg = fs_vulkan_dmabuf_config_default(); - CHECK(fs_backend_register_openbuenos(ctx, &ob_cfg) == FS_OK); - fs_openbuenos_profile_t ob_prof; - CHECK(fs_backend_openbuenos_get_profile(ctx, &ob_prof) == FS_OK); + CHECK(fs_backend_register_freetpu(ctx, &ob_cfg) == FS_OK); + fs_freetpu_profile_t ob_prof; + CHECK(fs_backend_freetpu_get_profile(ctx, &ob_prof) == FS_OK); CHECK(fs_backend_register_vulkan_dmabuf(ctx, &vk_cfg) == FS_OK); fs_context_destroy(ctx); diff --git a/tests/test_freesched.cpp b/tests/test_freesched.cpp index 4bd9d89..025fda9 100644 --- a/tests/test_freesched.cpp +++ b/tests/test_freesched.cpp @@ -746,7 +746,7 @@ static fs_status_t custom_tpu_exec(void* ud, const fs_op_desc_t* op, const fs_fe } static bool test_custom_vtable_and_ggml_seam() { - /* 5a: Custom pluggable backend vtable (simulates libopenbuenos drop-in) */ + /* 5a: Custom pluggable backend vtable (simulates libfreetpu drop-in) */ fs_config_t cfg = fs_config_default(); cfg.mock_mode = 1; cfg.profile = FS_PROFILE_PIXEL11_MALIBU; @@ -759,7 +759,7 @@ static bool test_custom_vtable_and_ggml_seam() { std::memset(&ops, 0, sizeof(ops)); ops.struct_size = static_cast(sizeof(fs_backend_ops_t)); ops.dev = FS_DEV_TPU; - ops.name = "custom_openbuenos_plugin"; + ops.name = "custom_freetpu_plugin"; ops.user_data = &st; ops.supports_op = custom_tpu_supports; ops.import_dmabuf = custom_tpu_import; @@ -1014,7 +1014,7 @@ static bool test_dmabuf_reconcile_and_router_pricing() { } /* ========================================================================= - * Test 7: Real Linux DMA-BUF Sync/Fence Engine + OpenBuenos & Vulkan Adapters + * Test 7: Real Linux DMA-BUF Sync/Fence Engine + FreeTPU & Vulkan Adapters * ========================================================================= */ static bool test_real_backend_adapters_and_dmabuf_sync() { fs_config_t cfg = fs_config_default(); @@ -1025,9 +1025,9 @@ static bool test_real_backend_adapters_and_dmabuf_sync() { CHECK(fs_context_create(&cfg, &ctx) == FS_OK); /* Register optional real backend adapters (with host fallback for offline CI) */ - fs_openbuenos_config_t ob_cfg = fs_openbuenos_config_default(); - ob_cfg.allow_mock_fallback = 1; - CHECK(fs_backend_register_openbuenos(ctx, &ob_cfg) == FS_OK); + fs_freetpu_config_t ob_cfg = fs_freetpu_config_default(); + ob_cfg.allow_mock_fallback = 1; + CHECK(fs_backend_register_freetpu(ctx, &ob_cfg) == FS_OK); fs_vulkan_dmabuf_config_t vk_cfg = fs_vulkan_dmabuf_config_default(); vk_cfg.allow_mock_fallback = 1; diff --git a/tests/test_pocketcoder.cpp b/tests/test_pocketcoder.cpp index c8e45ba..c29eed8 100644 --- a/tests/test_pocketcoder.cpp +++ b/tests/test_pocketcoder.cpp @@ -5,7 +5,7 @@ * 1. mmap GGUF reader + inkling2_loop 24->48 visit parsing & strict bounds checks * 2. 1024-token sliding-window KV ring buffer (40/48 visits, wraparound, 32K/128K RAM math) * 3. 16-byte SoA repacker (Q4_0, IQ4_NL, IQ4_XS) + ARM64 NEON/sdot vs FP32 parity - * 4. Pre-baked DMA-BUF graph + openbuenos adapter + DSpark MAX_DUP=3/4 dedup parity + * 4. Pre-baked DMA-BUF graph + libfreetpu adapter + DSpark MAX_DUP=3/4 dedup parity * * Copyright 2026 FreeSilicon Contributors * SPDX-License-Identifier: Apache-2.0 @@ -461,7 +461,7 @@ bool test_dspark_dedup_and_dmabuf_graph() { for (uint32_t e = 0; e < num_experts; ++e) pc_soa_free(&experts[e]); - /* 2. Pre-baked DMA-BUF graph + openbuenos contract verification */ + /* 2. Pre-baked DMA-BUF graph + libfreetpu contract verification */ pc_graph_config_t gcfg = pc_graph_config_default(); gcfg.hidden_dim = 128u; gcfg.expert_ffn_dim = 64u; diff --git a/tests/token_loop_json_check.py b/tests/token_loop_json_check.py index 14a33e4..38d0f07 100644 --- a/tests/token_loop_json_check.py +++ b/tests/token_loop_json_check.py @@ -833,9 +833,9 @@ def mk_build(name: str, with_ob: bool, abi: str = "arm64-v8a", bench_tag: bytes ] if with_ob: lines.extend([ - f"FREESCHED_OPENBUENOS_DIR:PATH={td}/ob", - f"_FREESCHED_OB_INCLUDE:PATH={td}/ob/include", - f"_FREESCHED_OB_LIB:FILEPATH={td}/ob/libopenbuenos.a", + f"FREESCHED_FREETPU_DIR:PATH={td}/ft", + f"_FREESCHED_FREETPU_INCLUDE:PATH={td}/ft/include", + f"_FREESCHED_FREETPU_LIB:FILEPATH={td}/ft/libfreetpu.a", ]) with open(os.path.join(bdir, "CMakeCache.txt"), "w", encoding="utf-8") as f: f.write("\n".join(lines) + "\n") @@ -848,13 +848,13 @@ def mk_build(name: str, with_ob: bool, abi: str = "arm64-v8a", bench_tag: bytes ob_dir = mk_build("a64-ob", True, bench_tag=b"with-ob") noob_dir = mk_build("a64-noob", False, bench_tag=b"without-ob") with mock.patch.object(rec, "_run", return_value=(0, "ok")): - # 1. Valid distinct dirs with opposite libopenbuenos settings PASS. + # 1. Valid distinct dirs with opposite libfreetpu settings PASS. rows = rec.verify_arm64_matrix(ob_dir, noob_dir, ndk_dir, repo_dir) self.assertTrue(all(r.startswith("PASS:") for _, r in rows), rows) # 2. Passing the same dir for both MUST FAIL. rows = rec.verify_arm64_matrix(ob_dir, ob_dir, ndk_dir, repo_dir) self.assertTrue(all(r.startswith("FAIL:") for _, r in rows), rows) - # 3. Swapped dirs (wrong libopenbuenos config in each) MUST FAIL. + # 3. Swapped dirs (wrong libfreetpu config in each) MUST FAIL. rows = rec.verify_arm64_matrix(noob_dir, ob_dir, ndk_dir, repo_dir) self.assertTrue(all(r.startswith("FAIL:") for _, r in rows), rows) # 4. Identical bench SHA-256 across with/without MUST FAIL. diff --git a/tools/freesched_dmabuf_smoke.cpp b/tools/freesched_dmabuf_smoke.cpp index 971f08d..16a6188 100644 --- a/tools/freesched_dmabuf_smoke.cpp +++ b/tools/freesched_dmabuf_smoke.cpp @@ -114,11 +114,11 @@ int main(int argc, char** argv) { } if (!is_iq9075) { - fs_openbuenos_config_t ob_cfg = fs_openbuenos_config_default(); - ob_cfg.dma_heap_path = heap_path; - ob_cfg.allow_mock_fallback = 1; - if (fs_backend_register_openbuenos(ctx, &ob_cfg) != FS_OK) { - std::fprintf(stderr, "fs_backend_register_openbuenos failed: %s\n", fs_context_last_error(ctx)); + fs_freetpu_config_t ob_cfg = fs_freetpu_config_default(); + ob_cfg.dma_heap_path = heap_path; + ob_cfg.allow_mock_fallback = 1; + if (fs_backend_register_freetpu(ctx, &ob_cfg) != FS_OK) { + std::fprintf(stderr, "fs_backend_register_freetpu failed: %s\n", fs_context_last_error(ctx)); fs_context_destroy(ctx); return 1; } diff --git a/tools/pocketcoder_run.cpp b/tools/pocketcoder_run.cpp index 44c243a..d1a187d 100644 --- a/tools/pocketcoder_run.cpp +++ b/tools/pocketcoder_run.cpp @@ -262,7 +262,7 @@ int run_bench(const pc_run_options& opts) { pc_dspark_dedup_plan_t dplan{}; pc_dspark_plan_experts(routed_dup4, 4u, 8u, 64u, mat.scales_bytes + mat.qs_bytes, &dplan); - /* Pre-baked DMA-BUF graph step check (uses Q4_0 payload for EdgeTPU/openbuenos contract) */ + /* Pre-baked DMA-BUF graph step check (uses Q4_0 payload for EdgeTPU/libfreetpu contract) */ pc_graph_config_t gcfg = pc_graph_config_default(); gcfg.hidden_dim = k_dim; gcfg.expert_ffn_dim = n_dim; diff --git a/tools/volcanic_tpu_dmabuf_bench.cpp b/tools/volcanic_tpu_dmabuf_bench.cpp index 23bd0e6..8eefe84 100644 --- a/tools/volcanic_tpu_dmabuf_bench.cpp +++ b/tools/volcanic_tpu_dmabuf_bench.cpp @@ -9,7 +9,7 @@ * Volcanic GPU, EdgeTPU, and CPU (linear layout, 128-byte aligned). * 2. Imports the EXACT SAME DMA-BUF file descriptors into BOTH: * - PowerVR Volcanic Vulkan via VK_EXT_external_memory_dma_buf (dup CLOEXEC fd) - * - Tensor G5 EdgeTPU via libopenbuenos ob_dmabuf_map (36-bit IOVA, pinned once) + * - Tensor G5 EdgeTPU via libfreetpu ob_dmabuf_map (36-bit IOVA, pinned once) * 3. Executes a 3-stage round-trip with 0 host copies and 0 hot-loop IOVA maps: * Stage 1 (Volcanic GPU SPIR-V) : Prefill GEMM H[M, K] = X @ W_gpu^T -> DecodeIn[K] * Stage 2 (EdgeTPU W8A16 IOVA) : Decode MUL_MAT Y_raw[N] = FP16(DecodeIn) @ W_tpu^T @@ -20,8 +20,8 @@ #include "freesched.h" #include "volcanic_tpu_spirv.h" -#ifdef FREESCHED_HAVE_LIBOPENBUENOS -#include "openbuenos.h" +#ifdef FREESCHED_HAVE_LIBFREETPU +#include "freetpu.h" #endif #include @@ -52,7 +52,7 @@ namespace { -#if FS_HAVE_VULKAN_HEADERS && defined(FREESCHED_HAVE_LIBOPENBUENOS) +#if FS_HAVE_VULKAN_HEADERS && defined(FREESCHED_HAVE_LIBFREETPU) uint64_t now_ns() { const auto t = std::chrono::steady_clock::now().time_since_epoch(); return static_cast(std::chrono::duration_cast(t).count()); @@ -157,7 +157,7 @@ ParityMetrics compute_parity(const float* got, const float* ref, size_t n) { return m; } -#if FS_HAVE_VULKAN_HEADERS && defined(FREESCHED_HAVE_LIBOPENBUENOS) +#if FS_HAVE_VULKAN_HEADERS && defined(FREESCHED_HAVE_LIBFREETPU) struct LatencyStats { double min_us; double p50_us; @@ -1100,13 +1100,13 @@ int main(int argc, char** argv) { return pass ? 0 : 1; } -#if !FS_HAVE_VULKAN_HEADERS || !defined(FREESCHED_HAVE_LIBOPENBUENOS) +#if !FS_HAVE_VULKAN_HEADERS || !defined(FREESCHED_HAVE_LIBFREETPU) (void)vk_only; (void)dive_path; (void)preferred_driver; (void)warmup; (void)cpu_bracket_sync; - std::fprintf(stderr, "ERROR: --live requires Linux Vulkan headers AND FREESCHED_HAVE_LIBOPENBUENOS=1\n"); + std::fprintf(stderr, "ERROR: --live requires Linux Vulkan headers AND FREESCHED_HAVE_LIBFREETPU=1\n"); fs_context_destroy(fctx); return 1; #else @@ -1263,7 +1263,7 @@ int main(int argc, char** argv) { return ok ? 0 : 1; } - /* 3. Initialize libopenbuenos EdgeTPU and map the EXACT SAME b_mid & b_tpu_out FDs ONCE! */ + /* 3. Initialize libfreetpu EdgeTPU and map the EXACT SAME b_mid & b_tpu_out FDs ONCE! */ ob_config_t ob_cfg = ob_config_default(); ob_cfg.mock_mode = 0; ob_cfg.dma_heap_path = heap_path; diff --git a/tools/volcanic_tpu_token_loop_bench.cpp b/tools/volcanic_tpu_token_loop_bench.cpp index 422ef46..4abbfb6 100644 --- a/tools/volcanic_tpu_token_loop_bench.cpp +++ b/tools/volcanic_tpu_token_loop_bench.cpp @@ -15,7 +15,7 @@ * Volcanic GPU : x = RMSNorm(Y[l] * Scale[l] + x) * Gamma[l] (dequant + residual + norm) * * EdgeTPU stage backends (--tpu-backend, default auto): - * openbuenos : libopenbuenos W8A16 over pinned DMA-BUF IOVAs (Tensor G5 node). + * freetpu : libfreetpu W8A16 over pinned DMA-BUF IOVAs (Tensor G5 node). * nnapi : selected automatically when no Tensor G5 node opens (e.g. Tensor * G6): one NNAPI TENSOR_QUANT8_ASYMM NHWC 1x1 CONV_2D per layer * compiled for the google-edgetpu ACCELERATOR (same lowering as @@ -30,19 +30,19 @@ * hot-loop mode active so any dynamic pool map/unmap fails closed * (hot_loop_map_count == 0 && hot_loop_unmap_count == 0 is asserted for the * pool slots). External backend resources (NNAPI AHardwareBuffers, or - * libopenbuenos packed weight caches) are prepared/pre-warmed across all L + * libfreetpu packed weight caches) are prepared/pre-warmed across all L * layers before hot-loop entry, and iova_observation_scope reports what the * pool counters observe. * * Synchronization arms for each of the 2*L inter-IP handoffs per token: * host_staged : CPU blocks on the producer (vkWaitForFences / synchronous - * NNAPI or libopenbuenos compute) and bounces every tensor + * NNAPI or libfreetpu compute) and bounces every tensor * through host memory (2L host copies per token). * sync_file_poll : zero-copy. Each asynchronous hop exports a sync_file * (Vulkan SYNC_FD semaphore / NNAPI output sync fence) that * a waiter thread poll()s before waking the submitting * thread. NNAPI: 2L polls + wakeups per token. - * --tpu-backend openbuenos (ob_gemm_matmul_f32_w8a16_dmabuf + * --tpu-backend freetpu (ob_gemm_matmul_f32_w8a16_dmabuf * waits synchronously before returning) and --tpu-backend * cpu: L wakeups (only the GPU -> TPU/CPU Vulkan SYNC_FD; * the synchronous output hop is counted in @@ -114,8 +114,8 @@ #define FS_TL_HAVE_VULKAN 0 #endif -#ifdef FREESCHED_HAVE_LIBOPENBUENOS -#include "openbuenos.h" +#ifdef FREESCHED_HAVE_LIBFREETPU +#include "freetpu.h" #endif namespace { @@ -409,7 +409,7 @@ struct TokenCounters { uint64_t sync_files_imported = 0u; uint64_t iif_fences = 0u; /* - * tpu_hw_us is hardware EdgeTPU execution time only (libopenbuenos + * tpu_hw_us is hardware EdgeTPU execution time only (libfreetpu * hw_execution_us). NNAPI, including synchronous ANeuralNetworksExecution_compute, * does not measure it: the JSON emits null unless tpu_hw_measured is set. * nnapi_sync_call_us is the host-side compute() duration and is null on fenced arms. @@ -438,7 +438,7 @@ struct TokenCounters { /* * Hops whose producer finished synchronously on the decode thread before the * handoff: --tpu-backend cpu W8A16 output writes (synchronous_cpu_hops) and - * --tpu-backend openbuenos ob_gemm_matmul_f32_w8a16_dmabuf completions + * --tpu-backend freetpu ob_gemm_matmul_f32_w8a16_dmabuf completions * (synchronous_tpu_hops). No asynchronous producer fence exists, so neither * is exported/polled or counted in fence_handoffs. */ @@ -499,7 +499,7 @@ class Executor { * device work still queued and with fs_iova_pool submissions INFLIGHT (e.g. * a rejected GPU fence short-circuits the slot retire). Reusing the executor * is safe only once every engine is proven idle, so: - * 1. quiesce(): vkDeviceWaitIdle (live), ob_graph_wait_all (libopenbuenos), + * 1. quiesce(): vkDeviceWaitIdle (live), ob_graph_wait_all (libfreetpu), * and no NNAPI execution/event or IIF fence may still be outstanding; * 2. only if (1) holds, retire every submission still in the ledger * (its device work is proven finished) and require every pool slot to @@ -830,7 +830,7 @@ class MockExecutor : public Executor { }; /* ------------------------------------------------------------------------- - * Live executor: Volcanic Vulkan + EdgeTPU (libopenbuenos | NNAPI accelerator | CPU) + * Live executor: Volcanic Vulkan + EdgeTPU (libfreetpu | NNAPI accelerator | CPU) * ------------------------------------------------------------------------- */ #if FS_TL_HAVE_VULKAN @@ -1137,7 +1137,7 @@ struct VkRunner { * VK_QUEUE_FAMILY_FOREIGN_EXT (VK_EXT_queue_family_foreign) can represent. * VK_QUEUE_FAMILY_EXTERNAL is limited to the same physical device and driver, * so it is NOT a valid fallback: without the extension the accelerator - * backends (openbuenos, nnapi) report themselves unavailable in select_tpu(). + * backends (freetpu, nnapi) report themselves unavailable in select_tpu(). */ if (has_qf_foreign) dev_exts.push_back("VK_EXT_queue_family_foreign"); const float prio = 1.0f; @@ -1720,9 +1720,9 @@ class LiveExecutor : public Executor { ~LiveExecutor() override { shutdown(); } const char* name() const override { - return tpu_ == TPU_NNAPI ? "live_vulkan_nnapi" : (tpu_ == TPU_OB ? "live_vulkan_openbuenos" : "live_vulkan_cpu_tpu"); + return tpu_ == TPU_NNAPI ? "live_vulkan_nnapi" : (tpu_ == TPU_OB ? "live_vulkan_freetpu" : "live_vulkan_cpu_tpu"); } - const char* tpu_name() const { return tpu_ == TPU_NNAPI ? "nnapi" : (tpu_ == TPU_OB ? "openbuenos" : "cpu"); } + const char* tpu_name() const { return tpu_ == TPU_NNAPI ? "nnapi" : (tpu_ == TPU_OB ? "freetpu" : "cpu"); } bool quant() const { return tpu_ == TPU_NNAPI; } const std::string& fallback_reason() const { return fallback_reason_; } const char* nn_device() const { return nn_.device_name(); } @@ -1989,7 +1989,7 @@ class LiveExecutor : public Executor { c->synchronous_cpu_hops += 1u; } else { /* - * --tpu-backend openbuenos: ob_gemm_matmul_f32_w8a16_dmabuf() waits + * --tpu-backend freetpu: ob_gemm_matmul_f32_w8a16_dmabuf() waits * synchronously for EdgeTPU completion before returning. Do not export or * poll a DMA-BUF fence or create a no-op CPU-proxy IIF after synchronous * completion; count the TPU -> GPU hop as synchronous (L per token) and @@ -2036,10 +2036,10 @@ class LiveExecutor : public Executor { return; } vk_.wait_idle(); -#ifdef FREESCHED_HAVE_LIBOPENBUENOS +#ifdef FREESCHED_HAVE_LIBFREETPU shutdown_ob(); #endif - (void)ones_.size(); /* host-staged EdgeTPU tile scale vector (libopenbuenos builds) */ + (void)ones_.size(); /* host-staged EdgeTPU tile scale vector (libfreetpu builds) */ nn_.free_layers(); release_qbufs(); nn_.shutdown(); @@ -2060,7 +2060,7 @@ class LiveExecutor : public Executor { uint32_t nn_ahb_registrations() const { return nn_ahb_registrations_; } private: - /* ---- TPU backend auto-selection: openbuenos (Tensor G5 node) -> NNAPI accelerator -> error ---- */ + /* ---- TPU backend auto-selection: freetpu (Tensor G5 node) -> NNAPI accelerator -> error ---- */ bool select_tpu(const char* heap, const char* dive, std::string* err) { if (req_ == "cpu") { tpu_ = TPU_CPU; @@ -2078,9 +2078,9 @@ class LiveExecutor : public Executor { "': GPU<->EdgeTPU zero-copy accelerator path unavailable (try --tpu-backend cpu)"; return false; } - if (req_ == "openbuenos" || req_ == "auto") { + if (req_ == "freetpu" || req_ == "auto") { std::string ob_err; -#ifdef FREESCHED_HAVE_LIBOPENBUENOS +#ifdef FREESCHED_HAVE_LIBFREETPU if (init_ob(heap, dive, &ob_err)) { tpu_ = TPU_OB; return true; @@ -2089,13 +2089,13 @@ class LiveExecutor : public Executor { #else (void)heap; (void)dive; - ob_err = "built without FREESCHED_HAVE_LIBOPENBUENOS"; + ob_err = "built without FREESCHED_HAVE_LIBFREETPU"; #endif - if (req_ == "openbuenos") { + if (req_ == "freetpu") { *err = ob_err + " (try --tpu-backend nnapi or cpu)"; return false; } - fallback_reason_ = "openbuenos: " + ob_err; + fallback_reason_ = "freetpu: " + ob_err; } else { (void)heap; (void)dive; @@ -2110,7 +2110,7 @@ class LiveExecutor : public Executor { return false; } -#ifdef FREESCHED_HAVE_LIBOPENBUENOS +#ifdef FREESCHED_HAVE_LIBFREETPU static std::string sanitize_ob_error(std::string s) { const std::string needle = std::string("/data") + "/local" + "/tmp/"; size_t pos = 0u; @@ -2142,7 +2142,7 @@ class LiveExecutor : public Executor { } } /* - * Pre-warm every layer's libopenbuenos packed weight cache strictly BEFORE + * Pre-warm every layer's libfreetpu packed weight cache strictly BEFORE * fs_iova_pool_enter_hot_loop() (even when --warmup 0): ob_gemm_matmul_f32_w8a16_dmabuf * lazily packs and IOVA-maps per-layer weight buffers inside ob_context_t on * first use, so one full pass across all L layers keeps those allocations and @@ -2152,7 +2152,7 @@ class LiveExecutor : public Executor { std::vector zeros(d, 0.0f); uint64_t dummy_sync = 0u; if (!cpu_write(p_->ctx, p_->sbuf(p_->mid_slot(0u)), zeros.data(), d * sizeof(float), &dummy_sync)) { - *err = "libopenbuenos weight pre-warm zero-fill failed"; + *err = "libfreetpu weight pre-warm zero-fill failed"; return false; } ob_prewarmed_layers_ = 0u; @@ -2162,7 +2162,7 @@ class LiveExecutor : public Executor { const ob_status_t rc = ob_gemm_matmul_f32_w8a16_dmabuf(ob_, mid_iova_[0u], d * sizeof(float), wf, d, d, out_iova_[0u], d * sizeof(float), &st); if (rc != OB_OK) { - *err = sanitize_ob_error(std::string("libopenbuenos weight pre-warm failed at layer ") + std::to_string(l) + + *err = sanitize_ob_error(std::string("libfreetpu weight pre-warm failed at layer ") + std::to_string(l) + ": " + ob_status_string(rc) + " (" + ob_context_last_error(ob_) + ")"); return false; } @@ -2830,7 +2830,7 @@ class LiveExecutor : public Executor { /* * Failure-recovery drain. Release any imported IIF gate first. vkDeviceWaitIdle * must return VK_SUCCESS (a lost or hung device cannot prove buffer reuse safe), - * any active libopenbuenos context must drain all in-flight jobs + * any active libfreetpu context must drain all in-flight jobs * (ob_graph_wait_all == OB_OK), every NNAPI hop must have been waited and * released, and no IIF fence may still be open (an unsignaled gate is * intentionally leaked rather than closed, which also fails here). When the @@ -2861,7 +2861,7 @@ class LiveExecutor : public Executor { *why = "vkDeviceWaitIdle returned " + std::to_string(static_cast(vr)); ok = false; } -#ifdef FREESCHED_HAVE_LIBOPENBUENOS +#ifdef FREESCHED_HAVE_LIBFREETPU if (ob_ != nullptr) { const ob_status_t orc = ob_graph_wait_all(ob_, 0u); if (orc != OB_OK) { @@ -2888,7 +2888,7 @@ class LiveExecutor : public Executor { bool run_tpu(bool staged, const int8_t* wf, uint32_t pp, fs_dmabuf_t* mid, fs_dmabuf_t* out, TokenCounters* c, std::string* err) { const uint32_t d = m_.d; -#ifdef FREESCHED_HAVE_LIBOPENBUENOS +#ifdef FREESCHED_HAVE_LIBFREETPU if (tpu_ == TPU_OB) { ob_invoke_stats_t st{}; ob_status_t rc; @@ -2909,7 +2909,7 @@ class LiveExecutor : public Executor { } #endif (void)pp; - (void)c; /* only the libopenbuenos path and the fenced CPU path below use the counters */ + (void)c; /* only the libfreetpu path and the fenced CPU path below use the counters */ if (staged) { /* host_staged: the caller already counted the stage_in_ / stage_out_ copies. */ cpu_tpu_w8a16(wf, stage_in_.data(), stage_out_.data(), d, &scratch_); @@ -2965,7 +2965,7 @@ class LiveExecutor : public Executor { bool allow_edgetpu_dmabuf_probe_ = false; bool nn_zero_copy_bound_ = true; /* false: dmabuf_fd blocked from NNAPI (EdgeTPU) */ uint64_t nn_outstanding_ = 0u; /* started NNAPI hops not yet released */ -#ifdef FREESCHED_HAVE_LIBOPENBUENOS +#ifdef FREESCHED_HAVE_LIBFREETPU ob_context_t* ob_ = nullptr; uint64_t mid_iova_[2] = {0u, 0u}; uint64_t out_iova_[2] = {0u, 0u}; @@ -3133,10 +3133,10 @@ void print_usage(const char* argv0) { " --odpm-root IIO root (default /sys/bus/iio/devices)\n" " --odpm-unit-j Joules per energy_value unit (finite, > 0; default 1e-6)\n" " --heap DMA-BUF heap (default /dev/dma_heap/system)\n" - " --dive Optional RV64 DIVE interpreter for libopenbuenos\n" + " --dive Optional RV64 DIVE interpreter for libfreetpu\n" " --preferred-driver Vulkan device name filter (default PowerVR)\n" - " --tpu-backend EdgeTPU stage backend (default auto:\n" - " libopenbuenos if a Tensor G5 node opens, else the NNAPI\n" + " --tpu-backend EdgeTPU stage backend (default auto:\n" + " libfreetpu if a Tensor G5 node opens, else the NNAPI\n" " accelerator; mock: nnapi selects the QUANT8 emulation)\n" " --nnapi-device NNAPI accelerator name substring (default auto, google-edgetpu first)\n" " --nnapi-mem Shared QUANT8 tensor memory (default auto: AHB BLOB\n" @@ -3313,7 +3313,7 @@ int main(int argc, char** argv) { const bool d_ok = (d == 512u || d == 1024u || d == 1536u || d == 2048u); const std::string req(tpu_backend); - const bool backend_ok = (req == "auto" || req == "openbuenos" || req == "nnapi" || req == "cpu"); + const bool backend_ok = (req == "auto" || req == "freetpu" || req == "nnapi" || req == "cpu"); const std::string mem_req(nn_mem); const bool mem_ok = (mem_req == "auto" || mem_req == "ahb" || mem_req == "dmabuf"); if (!d_ok || layers == 0u || layers > 64u || rc.tokens == 0u || rc.tokens > 4096u || rc.warmup > 64u || @@ -3477,11 +3477,11 @@ int main(int argc, char** argv) { * observable from userspace, so hot_loop_map_count == 0 covers only the pool * (Vulkan-imported) buffers. ahb_hot_loop_allocs counts AHardwareBuffer_allocate * calls made by this process while the arms ran. - * - In libopenbuenos mode every layer's packed weight cache is pre-warmed via + * - In libfreetpu mode every layer's packed weight cache is pre-warmed via * ob_gemm_matmul_f32_w8a16_dmabuf before fs_iova_pool_enter_hot_loop() - * (ob_prewarmed_layers == L), but libopenbuenos manages those internal weight + * (ob_prewarmed_layers == L), but libfreetpu manages those internal weight * buffers outside fs_iova_pool so pool counters cannot directly observe them - * (vulkan_pool_only_openbuenos_weights_external). + * (vulkan_pool_only_freetpu_weights_external). */ uint64_t ahb_hot_allocs = 0u; uint32_t nn_ahb_regs = 0u; @@ -3495,7 +3495,7 @@ int main(int argc, char** argv) { } #endif const char* iova_scope = !live ? "full_pool_mock" - : (tpu_selected == "openbuenos") ? "vulkan_pool_only_openbuenos_weights_external" + : (tpu_selected == "freetpu") ? "vulkan_pool_only_freetpu_weights_external" : (quant && nn_mem_mode != "dmabuf_fd") ? "vulkan_pool_only_nnapi_ahb_external" : "full_pool_dmabuf"; fs_iova_pool_stats_t ps_small{}, ps_w{}; @@ -3691,7 +3691,7 @@ int main(int argc, char** argv) { if (live && ex->tainted()) { /* * Intentionally preserve the tainted live executor (and its in-flight - * Vulkan/NNAPI/libopenbuenos/DMA-BUF objects) through process exit so no + * Vulkan/NNAPI/libfreetpu/DMA-BUF objects) through process exit so no * member destructor tears down live hardware resources whose completion * could not be proved. */