From f27dc916dd999bf2f4a3ffd978671c3d2d225496 Mon Sep 17 00:00:00 2001 From: Bobby Bones Date: Fri, 4 Dec 2026 10:49:57 -0500 Subject: [PATCH] refactor(libfreetpu): rename libopenbuenos to libfreetpu and retire openbuenos CMake/header surface --- .github/assets/architecture-diagram.svg | 2 +- .github/workflows/ci.yml | 12 +- README.md | 28 +-- VISION.md | 2 +- docs/{libopenbuenos => libfreetpu}/README.md | 0 freetile/CMakeLists.txt | 26 +- freetile/Makefile | 10 +- freetile/src/twin.cpp | 2 +- freetile/tests/test_buenos_parity.cpp | 2 +- libfreetpu/CMakeLists.txt | 194 +++++++++++++++ {libopenbuenos => libfreetpu}/Makefile | 10 +- .../cmake/freetpuConfig.cmake.in | 0 .../include/freetpu.h | 14 +- .../src/ob_buffer_pool.cpp | 0 .../src/ob_device.cpp | 0 {libopenbuenos => libfreetpu}/src/ob_dgc0.cpp | 0 .../src/ob_freetile_bridge.cpp | 0 {libopenbuenos => libfreetpu}/src/ob_gemm.cpp | 0 .../src/ob_gemm_emitter.cpp | 0 .../src/ob_graph.cpp | 0 .../src/ob_internal.h | 2 +- .../src/ob_quant_unpack.cpp | 0 .../src/ob_quant_unpack.hpp | 2 +- .../src/ob_sha256.cpp | 0 .../src/ob_worker_pool.cpp | 0 .../tests/ob_quant_unpack_test.cpp | 2 +- .../tests/openbuenos_adversarial_test.cpp | 2 +- .../tests/openbuenos_host_test.cpp | 2 +- .../tests/openbuenos_pool_guards_test.cpp | 0 .../tests/openbuenos_selftest.cpp | 2 +- .../tests/tpu_soc_probe.cpp | 2 +- libopenbuenos/CMakeLists.txt | 234 ------------------ libopenbuenos/cmake/openbuenosConfig.cmake.in | 9 - libopenbuenos/include/freetpu.h | 16 -- llama-cpp-edgetpu/CMakeLists.txt | 118 ++++----- llama-cpp-edgetpu/build.sh | 12 +- llama-cpp-edgetpu/ggml-edgetpu.cpp | 2 +- llama-cpp-edgetpu/openbuenos_shim.c | 2 +- packaging/arch/PKGBUILD | 18 +- 39 files changed, 333 insertions(+), 394 deletions(-) rename docs/{libopenbuenos => libfreetpu}/README.md (100%) create mode 100644 libfreetpu/CMakeLists.txt rename {libopenbuenos => libfreetpu}/Makefile (94%) rename {libopenbuenos => libfreetpu}/cmake/freetpuConfig.cmake.in (100%) rename libopenbuenos/include/openbuenos.h => libfreetpu/include/freetpu.h (98%) rename {libopenbuenos => libfreetpu}/src/ob_buffer_pool.cpp (100%) rename {libopenbuenos => libfreetpu}/src/ob_device.cpp (100%) rename {libopenbuenos => libfreetpu}/src/ob_dgc0.cpp (100%) rename {libopenbuenos => libfreetpu}/src/ob_freetile_bridge.cpp (100%) rename {libopenbuenos => libfreetpu}/src/ob_gemm.cpp (100%) rename {libopenbuenos => libfreetpu}/src/ob_gemm_emitter.cpp (100%) rename {libopenbuenos => libfreetpu}/src/ob_graph.cpp (100%) rename {libopenbuenos => libfreetpu}/src/ob_internal.h (99%) rename {libopenbuenos => libfreetpu}/src/ob_quant_unpack.cpp (100%) rename {libopenbuenos => libfreetpu}/src/ob_quant_unpack.hpp (99%) rename {libopenbuenos => libfreetpu}/src/ob_sha256.cpp (100%) rename {libopenbuenos => libfreetpu}/src/ob_worker_pool.cpp (100%) rename {libopenbuenos => libfreetpu}/tests/ob_quant_unpack_test.cpp (99%) rename {libopenbuenos => libfreetpu}/tests/openbuenos_adversarial_test.cpp (99%) rename {libopenbuenos => libfreetpu}/tests/openbuenos_host_test.cpp (99%) rename {libopenbuenos => libfreetpu}/tests/openbuenos_pool_guards_test.cpp (100%) rename {libopenbuenos => libfreetpu}/tests/openbuenos_selftest.cpp (99%) rename {libopenbuenos => libfreetpu}/tests/tpu_soc_probe.cpp (99%) delete mode 100644 libopenbuenos/CMakeLists.txt delete mode 100644 libopenbuenos/cmake/openbuenosConfig.cmake.in delete mode 100644 libopenbuenos/include/freetpu.h diff --git a/.github/assets/architecture-diagram.svg b/.github/assets/architecture-diagram.svg index c35de2e3..308aeb16 100644 --- a/.github/assets/architecture-diagram.svg +++ b/.github/assets/architecture-diagram.svg @@ -18,7 +18,7 @@ - libopenbuenos + libfreetpu C++17 Open Runtime Tiled GEMM Emitter Probe-A Weight Swap diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62c4b088..df166a10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,9 +18,9 @@ jobs: sudo apt-get update sudo apt-get install -y clang cmake ninja-build python3-numpy - - name: Configure & build libopenbuenos (CMake) + - name: Configure & build libfreetpu (CMake) run: | - cmake -S libopenbuenos -B build-cmake -G Ninja -DCMAKE_BUILD_TYPE=Release + cmake -S libfreetpu -B build-cmake -G Ninja -DCMAKE_BUILD_TYPE=Release cmake --build build-cmake -j"$(nproc)" ctest --test-dir build-cmake --output-on-failure @@ -74,10 +74,10 @@ jobs: fi done - - name: Build & test libopenbuenos (Make) + - name: Build & test libfreetpu (Make) run: | - make -C libopenbuenos verify-header-host host test - make -C libopenbuenos clean + make -C libfreetpu verify-header-host host test + make -C libfreetpu clean - name: Build & test libopentpu (Make) run: | @@ -93,7 +93,7 @@ jobs: clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror docs/kernel-abi/gcip_uapi.h clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror docs/kernel-abi/edgetpu_buenos_uapi.h clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror docs/kernel-abi/gxp_laguna_uapi.h - clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror -Ilibopenbuenos/include llama-cpp-edgetpu/openbuenos_shim.c + clang -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror -Ilibfreetpu/include llama-cpp-edgetpu/openbuenos_shim.c - name: Run Python ISA & DGC0 tool self-tests run: | diff --git a/README.md b/README.md index e0043935..a099ec8f 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,13 @@ ## Architecture

- FreeTPU execution pipeline from ggml-edgetpu through libopenbuenos and Litebuf VII to /dev/edgetpu-soc and the 4x4 serpentine PE mesh + FreeTPU execution pipeline from ggml-edgetpu through libfreetpu and Litebuf VII to /dev/edgetpu-soc and the 4x4 serpentine PE mesh

| Layer | Component | Responsibility | | --- | --- | --- | | **LLM Inference** | [`llama-cpp-edgetpu/`](llama-cpp-edgetpu/README.md) | `EDGETPU` GGML `ACCEL` backend (`MUL_MAT` & MoE `MUL_MAT_ID` `Q8_0`/`Q4_0`/`F32`, chained SwiGLU, `ROPE`/`GLU`, QKV `3->1` horizontal fusion, 1D bias `ADD`) | -| **Open Runtime** | [`libopenbuenos/`](libopenbuenos/include/openbuenos.h) | C11/C++17 static library: `1,286.4 MHz` DVFS + FW WakeLock, perf-core-pinned SPSC async dequant, clean-room 7-chunk PT `W8A16(FP16)` (`FP32` acc), adaptive spin, 2-tier DMA-BUF pool & LMKD single-copy weight cache, `M=1`/`M=64` GEMM + 11-chunk chained SwiGLU emitter | +| **Open Runtime** | [`libfreetpu/`](libfreetpu/include/freetpu.h) | C11/C++17 static library: `1,286.4 MHz` DVFS + FW WakeLock, perf-core-pinned SPSC async dequant, clean-room 7-chunk PT `W8A16(FP16)` (`FP32` acc), adaptive spin, 2-tier DMA-BUF pool & LMKD single-copy weight cache, `M=1`/`M=64` GEMM + 11-chunk chained SwiGLU emitter | | **AOT Guard & SRAM** | [`aot-guard/`](aot-guard/README.md) | Zero-dep C11/C++17 5-input SHA-256 AOT cache key/container validator (`aot_cache_guard`) & `< 4 MiB` on-chip SRAM tail subgraph partitioner (`sram_partitioner`) | | **Kernel Transport** | [`runtime/`](runtime/src/tpu_baremetal_runner.cpp) | Standalone bare-metal runner & UAPI/Litebuf VII headers (`0x0008 -> 0x00fe`, `/dev/edgetpu-soc` `0xED`) | | **ISA Tooling** | [`tools/`](tools/emit_custom_gemm.py) | Pure-Python `DGC0` dissector/patcher, multi-tile `(M, K, N)` VLIW synthesizer, `0x640` minimax spline codec, `0xa40` chained fusion verifier, `INT4` packer | @@ -52,16 +52,16 @@ ## 60-Second Quickstart -Build `libopenbuenos`, verify strict C11/C++17 headers, and run the offline unit test suite (zero device or proprietary `.dgc0` files required): +Build `libfreetpu`, verify strict C11/C++17 headers, and run the offline unit test suite (zero device or proprietary `.dgc0` files required): ```bash git clone https://github.com/freesilicon/freetpu.git cd freetpu -# 1. Build & test libopenbuenos (CMake + host mock mode) -cmake -S libopenbuenos -B libopenbuenos/build/cmake-host -DCMAKE_BUILD_TYPE=Release -cmake --build libopenbuenos/build/cmake-host -j -ctest --test-dir libopenbuenos/build/cmake-host --output-on-failure +# 1. Build & test libfreetpu (CMake + host mock mode) +cmake -S libfreetpu -B libfreetpu/build/cmake-host -DCMAKE_BUILD_TYPE=Release +cmake --build libfreetpu/build/cmake-host -j +ctest --test-dir libfreetpu/build/cmake-host --output-on-failure # 2. Build & test aot-guard (5-input AOT cache guard & <4 MiB SRAM partitioner) make -C aot-guard test @@ -72,10 +72,10 @@ python3 tools/spline_0x640.py --self-test --no-emit python3 tools/pack_int4.py ``` -To cross-build `libopenbuenos.a`, `tpu_baremetal_runner`, and `llama.cpp` (`llama-cli` / `llama-bench` / `test-backend-ops`) for Android ARM64 (`android-34`): +To cross-build `libfreetpu.a`, `tpu_baremetal_runner`, and `llama.cpp` (`llama-cli` / `llama-bench` / `test-backend-ops`) for Android ARM64 (`android-34`): ```bash -make -C libopenbuenos verify-header android verify-android +make -C libfreetpu verify-header android verify-android make -C runtime verify-baremetal ``` @@ -113,15 +113,15 @@ See [docs/PHASE8_PERF_REPORT.md](docs/PHASE8_PERF_REPORT.md) (and [Phase 7](docs `freetpu` is strictly **clean-room source and specification only**: - **Zero vendor binaries**: No proprietary `.so`, `.ko`, `.img`, `.apk`, `.gguf`, `.tflite`, `.dgc0`, or firmware blobs are included in this repository. -- **Zero vendor userspace dependencies**: `libopenbuenos`, `tpu_baremetal_runner`, and `ggml-edgetpu` talk directly to the Linux kernel (`/dev/edgetpu-soc` and `/dev/dma_heap/system`). +- **Zero vendor userspace dependencies**: `libfreetpu`, `tpu_baremetal_runner`, and `ggml-edgetpu` talk directly to the Linux kernel (`/dev/edgetpu-soc` and `/dev/dma_heap/system`). - **Host mock mode**: Setting `ob_config_t::mock_mode = 1` (or `OPENBUENOS_MOCK=1`) runs the full buffer pool, graph LRU cache, 16-credit async ring, VLIW emitter, and quantized math suites offline on macOS/Linux without TPU hardware. ### Extracting `dive_interp_rv64.bin` On-Device -Running synthesized `.dgc0` microkernels on physical Tensor G5 hardware requires the `638,977 B` RV64GCV DIVE VM interpreter image (`ext[1]`) from the user's own device. **Do not redistribute this binary.** Extract it locally on an unlocked Pixel using `libopenbuenos`: +Running synthesized `.dgc0` microkernels on physical Tensor G5 hardware requires the `638,977 B` RV64GCV DIVE VM interpreter image (`ext[1]`) from the user's own device. **Do not redistribute this binary.** Extract it locally on an unlocked Pixel using `libfreetpu`: ```c -#include "openbuenos.h" +#include "freetpu.h" #include size_t interp_size = 0; @@ -130,7 +130,7 @@ uint8_t *buf = (uint8_t *)malloc(interp_size); ob_gemm_extract_dive_interp_from_dgc0("/path/to/local_compiled.dgc0", buf, interp_size, &interp_size); ``` -Or point `libopenbuenos` / `ggml-edgetpu` directly at your local extracted image (or a local `.dgc0` file) at runtime: +Or point `libfreetpu` / `ggml-edgetpu` directly at your local extracted image (or a local `.dgc0` file) at runtime: ```bash export OPENBUENOS_DIVE_INTERP_PATH=/data/local/tmp/tpu_open_stack/dive_interp_rv64.bin @@ -158,7 +158,7 @@ export OPENBUENOS_DIVE_INTERP_PATH=/data/local/tmp/tpu_open_stack/dive_interp_rv - [DMA & TTU Bitfields](docs/isa-dma/dma_ttu_bitfields.md) — `0xa40` / `0x9c0` / `0x940` / `0x980` DMA descriptors & SRAM ring setup - [Vector ALU ISA](docs/isa-vec/vector_alu_isa.md) — `stream125` FP32-RNE quantization & activation pipeline - [Kernel UAPI Headers](docs/kernel-abi/README.md) — Clean-room `/dev/edgetpu-soc`, `/dev/gxp`, and GCIP IIF headers -- [`libopenbuenos` Guide](docs/libopenbuenos/README.md) & [`ggml-edgetpu` Guide](docs/llama-cpp-edgetpu/README.md) +- [`libfreetpu` Guide](docs/libfreetpu/README.md) & [`ggml-edgetpu` Guide](docs/llama-cpp-edgetpu/README.md) - [Headless Colab TPU Tooling](docs/cloud-tpu/colab-headless-tooling.md) — Track B `v6e-1`/`v5e-1` headless harness (`tools/colab_tpu_bench.py`), Colab MCP/`v1beta` contract & Track C boundaries - [Cloud TPU Ops: Container CDI & Prometheus Telemetry](docs/cloud-tpu/ops-container-telemetry.md) — Zero-dep `tpu-exporter` (`:9400/metrics`) & `freetpu-cdi` CNCF CDI `v0.6.0` (`freetpu.dev/tpu=all`) Docker/K8s manifests - [FreeTPU Router v0 Guide](docs/router/README.md) — OpenAI-compatible router across Pixel Tensor G5 clusters, local hosts, and Cloud TPU slices diff --git a/VISION.md b/VISION.md index 82732665..323809e9 100644 --- a/VISION.md +++ b/VISION.md @@ -12,7 +12,7 @@ TPUs (`v5e`, `v6e`, `tpu7x`), and non-NVIDIA AI ASICs. - Clean-room native C++17 userspace runtimes, VLIW ISA specifications, and `llama.cpp` backends across edge and cloud TPUs: - - **Edge (`Pixel Tensor G5/G6`):** `libopenbuenos` + `ggml-edgetpu` directly + - **Edge (`Pixel Tensor G5/G6`):** `libfreetpu` + `ggml-edgetpu` directly over `/dev/edgetpu-soc` with zero proprietary vendor `.so` dependencies. - **Cloud native runtime (`v5e` / `v6e` / `tpu7x`):** `ggml-cloudtpu` over the open C `PJRT_Api` (zero Python, JAX, or `vllm-tpu` at runtime). diff --git a/docs/libopenbuenos/README.md b/docs/libfreetpu/README.md similarity index 100% rename from docs/libopenbuenos/README.md rename to docs/libfreetpu/README.md diff --git a/freetile/CMakeLists.txt b/freetile/CMakeLists.txt index 8d74cf1c..8fe9bca7 100644 --- a/freetile/CMakeLists.txt +++ b/freetile/CMakeLists.txt @@ -40,15 +40,15 @@ target_link_libraries(test_select_tree_lut PRIVATE freetile) target_compile_options(test_select_tree_lut PRIVATE -Wall -Wextra -Wpedantic -Werror) add_test(NAME freetile_select_tree_lut_tests COMMAND test_select_tree_lut) -option(FREETILE_BUILD_BUENOS_PARITY_TEST "Build bit-exact parity test against sibling libopenbuenos" ON) +option(FREETILE_BUILD_BUENOS_PARITY_TEST "Build bit-exact parity test against sibling libfreetpu" ON) option(FREETILE_BUILD_DIGITAL_TWIN "Build freetile-twin digital twin library, CLI, and tests" ON) if((FREETILE_BUILD_BUENOS_PARITY_TEST OR FREETILE_BUILD_DIGITAL_TWIN) - AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos/CMakeLists.txt") - set(OPENBUENOS_BUILD_TESTS OFF CACHE BOOL "" FORCE) + AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu/CMakeLists.txt") + set(FREETPU_BUILD_TESTS OFF CACHE BOOL "" FORCE) add_subdirectory( - "${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos" - "${CMAKE_CURRENT_BINARY_DIR}/openbuenos_ref" + "${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu" + "${CMAKE_CURRENT_BINARY_DIR}/freetpu_ref" EXCLUDE_FROM_ALL ) @@ -56,10 +56,10 @@ if((FREETILE_BUILD_BUENOS_PARITY_TEST OR FREETILE_BUILD_DIGITAL_TWIN) add_executable(test_buenos_parity tests/test_buenos_parity.cpp ) - target_link_libraries(test_buenos_parity PRIVATE freetile openbuenos) + target_link_libraries(test_buenos_parity PRIVATE freetile freetpu) target_include_directories(test_buenos_parity SYSTEM PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos/include" - "${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos/src" + "${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu/include" + "${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu/src" "${CMAKE_CURRENT_SOURCE_DIR}/../docs/baremetal-vii" "${CMAKE_CURRENT_SOURCE_DIR}/../docs/kernel-abi" ) @@ -71,13 +71,13 @@ if((FREETILE_BUILD_BUENOS_PARITY_TEST OR FREETILE_BUILD_DIGITAL_TWIN) add_library(freetile_twin STATIC src/twin.cpp ) - target_link_libraries(freetile_twin PUBLIC freetile PRIVATE openbuenos) + target_link_libraries(freetile_twin PUBLIC freetile PRIVATE freetpu) target_include_directories(freetile_twin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) target_include_directories(freetile_twin SYSTEM PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos/include" - "${CMAKE_CURRENT_SOURCE_DIR}/../libopenbuenos/src" + "${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu/include" + "${CMAKE_CURRENT_SOURCE_DIR}/../libfreetpu/src" "${CMAKE_CURRENT_SOURCE_DIR}/../docs/baremetal-vii" "${CMAKE_CURRENT_SOURCE_DIR}/../docs/kernel-abi" ) @@ -87,14 +87,14 @@ if((FREETILE_BUILD_BUENOS_PARITY_TEST OR FREETILE_BUILD_DIGITAL_TWIN) add_executable(freetile-twin tools/freetile_twin_cli.cpp ) - target_link_libraries(freetile-twin PRIVATE freetile_twin freetile openbuenos) + target_link_libraries(freetile-twin PRIVATE freetile_twin freetile freetpu) target_compile_options(freetile-twin PRIVATE -Wall -Wextra -Wpedantic -Werror -fno-exceptions -fno-rtti) add_executable(test_freetile_twin tests/test_freetile_twin.cpp ) - target_link_libraries(test_freetile_twin PRIVATE freetile_twin freetile openbuenos) + target_link_libraries(test_freetile_twin PRIVATE freetile_twin freetile freetpu) target_compile_options(test_freetile_twin PRIVATE -Wall -Wextra -Wpedantic -Werror -fno-exceptions -fno-rtti) add_test(NAME freetile_twin_tests COMMAND test_freetile_twin) diff --git a/freetile/Makefile b/freetile/Makefile index 437586c2..f3143e26 100644 --- a/freetile/Makefile +++ b/freetile/Makefile @@ -4,8 +4,8 @@ HOST_AR ?= ar THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) ROOT := $(abspath $(THIS_DIR)/..) -OB_DIR := $(ROOT)/libopenbuenos -OB_LIB := $(OB_DIR)/build/host/libopenbuenos.a +OB_DIR := $(ROOT)/libfreetpu +OB_LIB := $(OB_DIR)/build/host/libfreetpu.a BUILD_DIR := $(THIS_DIR)/build/host ROOT_BIN_DIR := $(ROOT)/build @@ -57,7 +57,7 @@ TEST_PARITY := $(BUILD_DIR)/test_buenos_parity TEST_TWIN := $(BUILD_DIR)/test_freetile_twin TEST_SELECT_TREE := $(BUILD_DIR)/test_select_tree_lut -.PHONY: all host twin test verify-header clean openbuenos-host +.PHONY: all host twin test verify-header clean freetpu-host all: host @@ -66,10 +66,10 @@ host: $(FREETILE_LIB) $(FREETILE_TWIN_LIB) $(TWIN_CLI) $(ROOT_TWIN_CLI) \ twin: $(TWIN_CLI) $(ROOT_TWIN_CLI) -openbuenos-host: +freetpu-host: $(MAKE) -C $(OB_DIR) host -$(OB_LIB): openbuenos-host +$(OB_LIB): freetpu-host $(BUILD_DIR)/obj/%.o: $(THIS_DIR)/src/%.cpp $(CORE_HDRS) @mkdir -p $(dir $@) diff --git a/freetile/src/twin.cpp b/freetile/src/twin.cpp index 2a4c0883..98abf344 100644 --- a/freetile/src/twin.cpp +++ b/freetile/src/twin.cpp @@ -19,7 +19,7 @@ #include "ob_internal.h" #include "ob_quant_unpack.hpp" -#include "openbuenos.h" +#include "freetpu.h" #include #include diff --git a/freetile/tests/test_buenos_parity.cpp b/freetile/tests/test_buenos_parity.cpp index ab528b63..0141e54f 100644 --- a/freetile/tests/test_buenos_parity.cpp +++ b/freetile/tests/test_buenos_parity.cpp @@ -3,7 +3,7 @@ #include "freetile/tile_ir.hpp" #include "ob_internal.h" -#include "openbuenos.h" +#include "freetpu.h" #include #include diff --git a/libfreetpu/CMakeLists.txt b/libfreetpu/CMakeLists.txt new file mode 100644 index 00000000..dc2e1b91 --- /dev/null +++ b/libfreetpu/CMakeLists.txt @@ -0,0 +1,194 @@ +cmake_minimum_required(VERSION 3.18) +project(freetpu VERSION 0.1.0 LANGUAGES C CXX) + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +option(FREETPU_BUILD_TESTS "Build libfreetpu self-test / host unit test binaries" ON) +option(FREETPU_INSTALL_SELFTEST "Install openbuenos_selftest and tpu_soc_probe utilities" ON) +option(FREETPU_WERROR "Treat compiler warnings as errors" ON) +option(FREETPU_ENABLE_FREETILE "Wire clean-room FreeTile BUENOS_A0 VLIW/DGC0 emitter into libfreetpu" ON) +option(FREETPU_FREETILE_DEFAULT_ON "Default OPENBUENOS_FREETILE to enabled unless overridden by env" OFF) + +set(FREETPU_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/..") +set(FREETPU_COMPILE_FLAGS -Wall -Wextra -Wpedantic -fno-exceptions -fno-rtti) +if (FREETPU_WERROR) + list(APPEND FREETPU_COMPILE_FLAGS -Werror) +endif() + +set(FREETPU_SOURCES + src/ob_sha256.cpp + src/ob_dgc0.cpp + src/ob_buffer_pool.cpp + src/ob_worker_pool.cpp + src/ob_device.cpp + src/ob_graph.cpp + src/ob_freetile_bridge.cpp + src/ob_quant_unpack.cpp + src/ob_gemm_emitter.cpp + src/ob_gemm.cpp +) + +set(_freetpu_use_freetile OFF) +if (FREETPU_ENABLE_FREETILE AND EXISTS "${FREETPU_ROOT}/freetile/include/freetile/buenos_emitter.hpp") + set(_freetpu_use_freetile ON) + if (NOT TARGET freetile) + list(APPEND FREETPU_SOURCES + ${FREETPU_ROOT}/freetile/src/tile_ir.cpp + ${FREETPU_ROOT}/freetile/src/buenos_emitter.cpp + ) + endif() +endif() + +add_library(freetpu STATIC ${FREETPU_SOURCES}) +add_library(freetpu::freetpu ALIAS freetpu) +set_target_properties(freetpu PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_compile_features(freetpu PUBLIC cxx_std_17) +target_compile_options(freetpu PRIVATE ${FREETPU_COMPILE_FLAGS}) + +if (_freetpu_use_freetile) + target_compile_definitions(freetpu PRIVATE OPENBUENOS_WITH_FREETILE=1) + if (FREETPU_FREETILE_DEFAULT_ON) + target_compile_definitions(freetpu PRIVATE OPENBUENOS_FREETILE_DEFAULT_ON_VAL=1) + else() + target_compile_definitions(freetpu PRIVATE OPENBUENOS_FREETILE_DEFAULT_ON_VAL=0) + endif() + if (TARGET freetile) + target_link_libraries(freetpu PRIVATE $) + endif() +else() + target_compile_definitions(freetpu PRIVATE OPENBUENOS_WITH_FREETILE=0 OPENBUENOS_FREETILE_DEFAULT_ON_VAL=0) +endif() + +target_include_directories(freetpu + PUBLIC + $ + $ + PRIVATE + $ + $ + $ + $ +) + +if (UNIX AND NOT APPLE) + target_link_libraries(freetpu PUBLIC m) + if (NOT ANDROID) + find_package(Threads REQUIRED) + target_link_libraries(freetpu PUBLIC Threads::Threads) + endif() +elseif (APPLE) + target_link_libraries(freetpu PUBLIC m) +endif() + +if (FREETPU_BUILD_TESTS) + add_executable(openbuenos_selftest tests/openbuenos_selftest.cpp) + target_link_libraries(openbuenos_selftest PRIVATE freetpu) + target_include_directories(openbuenos_selftest PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${FREETPU_ROOT}/docs/baremetal-vii + ${FREETPU_ROOT}/docs/kernel-abi + ) + target_compile_features(openbuenos_selftest PRIVATE cxx_std_17) + target_compile_options(openbuenos_selftest PRIVATE ${FREETPU_COMPILE_FLAGS}) + if (ANDROID) + target_compile_options(openbuenos_selftest PRIVATE -fPIE) + target_link_options(openbuenos_selftest PRIVATE -pie -static-libstdc++ -Wl,--as-needed) + elseif (UNIX AND NOT APPLE AND FREETPU_INSTALL_SELFTEST) + install(TARGETS openbuenos_selftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() + + add_executable(tpu_soc_probe tests/tpu_soc_probe.cpp) + target_link_libraries(tpu_soc_probe PRIVATE freetpu) + target_include_directories(tpu_soc_probe PRIVATE + ${FREETPU_ROOT}/docs/kernel-abi + ) + target_compile_features(tpu_soc_probe PRIVATE cxx_std_17) + target_compile_options(tpu_soc_probe PRIVATE ${FREETPU_COMPILE_FLAGS}) + if (ANDROID) + target_compile_options(tpu_soc_probe PRIVATE -fPIE) + target_link_options(tpu_soc_probe PRIVATE -pie -static-libstdc++ -Wl,--as-needed) + elseif (UNIX AND NOT APPLE AND FREETPU_INSTALL_SELFTEST) + install(TARGETS tpu_soc_probe RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif() + + if (NOT ANDROID) + add_executable(openbuenos_host_test tests/openbuenos_host_test.cpp) + target_link_libraries(openbuenos_host_test PRIVATE freetpu) + target_include_directories(openbuenos_host_test PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${FREETPU_ROOT}/docs/baremetal-vii + ${FREETPU_ROOT}/docs/kernel-abi + ) + target_compile_features(openbuenos_host_test PRIVATE cxx_std_17) + target_compile_options(openbuenos_host_test PRIVATE ${FREETPU_COMPILE_FLAGS}) + enable_testing() + add_test(NAME openbuenos_host_test COMMAND openbuenos_host_test) + add_test(NAME tpu_soc_probe_mock COMMAND tpu_soc_probe --mock) + + add_executable(openbuenos_adversarial_test tests/openbuenos_adversarial_test.cpp) + target_link_libraries(openbuenos_adversarial_test PRIVATE freetpu) + target_include_directories(openbuenos_adversarial_test PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${FREETPU_ROOT}/docs/baremetal-vii + ${FREETPU_ROOT}/docs/kernel-abi + ) + target_compile_features(openbuenos_adversarial_test PRIVATE cxx_std_17) + target_compile_options(openbuenos_adversarial_test PRIVATE ${FREETPU_COMPILE_FLAGS}) + add_test(NAME openbuenos_adversarial_test COMMAND openbuenos_adversarial_test) + + add_executable(ob_quant_unpack_test tests/ob_quant_unpack_test.cpp) + target_link_libraries(ob_quant_unpack_test PRIVATE freetpu) + target_include_directories(ob_quant_unpack_test PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${FREETPU_ROOT}/docs/baremetal-vii + ${FREETPU_ROOT}/docs/kernel-abi + ) + target_compile_features(ob_quant_unpack_test PRIVATE cxx_std_17) + target_compile_options(ob_quant_unpack_test PRIVATE ${FREETPU_COMPILE_FLAGS}) + add_test(NAME ob_quant_unpack_test COMMAND ob_quant_unpack_test) + + add_executable(openbuenos_pool_guards_test tests/openbuenos_pool_guards_test.cpp) + target_link_libraries(openbuenos_pool_guards_test PRIVATE freetpu) + target_include_directories(openbuenos_pool_guards_test PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${FREETPU_ROOT}/docs/baremetal-vii + ${FREETPU_ROOT}/docs/kernel-abi + ) + target_compile_features(openbuenos_pool_guards_test PRIVATE cxx_std_17) + target_compile_options(openbuenos_pool_guards_test PRIVATE ${FREETPU_COMPILE_FLAGS}) + add_test(NAME openbuenos_pool_guards_test COMMAND openbuenos_pool_guards_test) + endif() +endif() + +install(TARGETS freetpu + EXPORT freetpuTargets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install(FILES include/freetpu.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) +install(FILES ${FREETPU_ROOT}/docs/kernel-abi/edgetpu_buenos_uapi.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetpu +) +install(EXPORT freetpuTargets + FILE freetpuTargets.cmake + NAMESPACE freetpu:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetpu +) +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/freetpuConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/freetpuConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetpu +) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/freetpuConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/freetpuConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/freetpuConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetpu +) diff --git a/libopenbuenos/Makefile b/libfreetpu/Makefile similarity index 94% rename from libopenbuenos/Makefile rename to libfreetpu/Makefile index 4bac6fa1..358118a7 100644 --- a/libopenbuenos/Makefile +++ b/libfreetpu/Makefile @@ -36,7 +36,7 @@ FREETILE_SRCS := \ $(ROOT)/freetile/src/buenos_emitter.cpp HDRS := \ - $(THIS_DIR)/include/openbuenos.h \ + $(THIS_DIR)/include/freetpu.h \ $(THIS_DIR)/src/ob_internal.h \ $(THIS_DIR)/src/ob_quant_unpack.hpp \ $(ROOT)/freetile/include/freetile/tile_ir.hpp \ @@ -52,11 +52,11 @@ HOST_OBJS := $(patsubst $(THIS_DIR)/src/%.cpp,$(HOST_DIR)/obj/%.o,$(SRCS)) \ ANDROID_OBJS := $(patsubst $(THIS_DIR)/src/%.cpp,$(ANDROID_DIR)/obj/%.o,$(SRCS)) \ $(patsubst $(ROOT)/freetile/src/%.cpp,$(ANDROID_DIR)/obj/freetile_%.o,$(FREETILE_SRCS)) -HOST_LIB := $(HOST_DIR)/libopenbuenos.a +HOST_LIB := $(HOST_DIR)/libfreetpu.a HOST_TEST := $(HOST_DIR)/openbuenos_host_test QUANT_TEST := $(HOST_DIR)/ob_quant_unpack_test POOL_GUARDS_TEST := $(HOST_DIR)/openbuenos_pool_guards_test -ANDROID_LIB := $(ANDROID_DIR)/libopenbuenos.a +ANDROID_LIB := $(ANDROID_DIR)/libfreetpu.a ANDROID_TEST := $(ANDROID_DIR)/openbuenos_selftest .PHONY: all host android test verify-header verify-header-host verify-android verify clean @@ -112,11 +112,11 @@ test: $(HOST_TEST) $(QUANT_TEST) $(POOL_GUARDS_TEST) $(QUANT_TEST) $(POOL_GUARDS_TEST) -verify-header-host: $(THIS_DIR)/include/openbuenos.h +verify-header-host: $(THIS_DIR)/include/freetpu.h $(HOST_CC) -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror $< $(HOST_CXX) -x c++ -std=c++17 -fsyntax-only -Wall -Wextra -Werror $< -verify-header: $(THIS_DIR)/include/openbuenos.h verify-header-host +verify-header: $(THIS_DIR)/include/freetpu.h verify-header-host $(ANDROID_CC) -x c -std=c11 -fsyntax-only -Wall -Wextra -Werror $< $(ANDROID_CXX) -x c++ -std=c++17 -fsyntax-only -Wall -Wextra -Werror $< diff --git a/libopenbuenos/cmake/freetpuConfig.cmake.in b/libfreetpu/cmake/freetpuConfig.cmake.in similarity index 100% rename from libopenbuenos/cmake/freetpuConfig.cmake.in rename to libfreetpu/cmake/freetpuConfig.cmake.in diff --git a/libopenbuenos/include/openbuenos.h b/libfreetpu/include/freetpu.h similarity index 98% rename from libopenbuenos/include/openbuenos.h rename to libfreetpu/include/freetpu.h index b044db6c..f44caf7e 100644 --- a/libopenbuenos/include/openbuenos.h +++ b/libfreetpu/include/freetpu.h @@ -1,8 +1,8 @@ /* - * libopenbuenos - Zero-Google-.so Bare-Metal Tensor G5 (Buenos A0 / rango) TPU Runtime + * libfreetpu - Zero-Google-.so Bare-Metal Tensor G5 (Buenos A0 / rango) TPU Runtime * * Public C11 / C++17 ABI header. - * Designed for direct consumption by llama.cpp (ggml-edgetpu) and standalone C/C++ tools. + * Designed for direct consumption by llama.cpp (ggml-edgetpu / ggml-freetpu) and standalone C/C++ tools. * * Transport: * - Device node : /dev/edgetpu-soc (buenos.ko ioctl ABI 1.4, Litebuf VII) @@ -10,8 +10,8 @@ * - Concurrency : Up to 16 in-flight VII credits (credit_size=16) over eventfd * - Host testing: Set ob_config_t::mock_mode = 1 to run offline without /dev/edgetpu-soc */ -#ifndef OPENBUENOS_H_ -#define OPENBUENOS_H_ +#ifndef FREETPU_H_ +#define FREETPU_H_ #include #include @@ -813,8 +813,12 @@ ob_status_t ob_gemm_matmul_f32_w8a16_dmabuf(ob_context_t* ctx, size_t out_bytes, ob_invoke_stats_t* out_stats); +#define FREETPU_API_VERSION_MAJOR OB_API_VERSION_MAJOR +#define FREETPU_API_VERSION_MINOR OB_API_VERSION_MINOR +#define FREETPU_API_VERSION_PATCH OB_API_VERSION_PATCH + #ifdef __cplusplus } /* extern "C" */ #endif -#endif /* OPENBUENOS_H_ */ +#endif /* FREETPU_H_ */ diff --git a/libopenbuenos/src/ob_buffer_pool.cpp b/libfreetpu/src/ob_buffer_pool.cpp similarity index 100% rename from libopenbuenos/src/ob_buffer_pool.cpp rename to libfreetpu/src/ob_buffer_pool.cpp diff --git a/libopenbuenos/src/ob_device.cpp b/libfreetpu/src/ob_device.cpp similarity index 100% rename from libopenbuenos/src/ob_device.cpp rename to libfreetpu/src/ob_device.cpp diff --git a/libopenbuenos/src/ob_dgc0.cpp b/libfreetpu/src/ob_dgc0.cpp similarity index 100% rename from libopenbuenos/src/ob_dgc0.cpp rename to libfreetpu/src/ob_dgc0.cpp diff --git a/libopenbuenos/src/ob_freetile_bridge.cpp b/libfreetpu/src/ob_freetile_bridge.cpp similarity index 100% rename from libopenbuenos/src/ob_freetile_bridge.cpp rename to libfreetpu/src/ob_freetile_bridge.cpp diff --git a/libopenbuenos/src/ob_gemm.cpp b/libfreetpu/src/ob_gemm.cpp similarity index 100% rename from libopenbuenos/src/ob_gemm.cpp rename to libfreetpu/src/ob_gemm.cpp diff --git a/libopenbuenos/src/ob_gemm_emitter.cpp b/libfreetpu/src/ob_gemm_emitter.cpp similarity index 100% rename from libopenbuenos/src/ob_gemm_emitter.cpp rename to libfreetpu/src/ob_gemm_emitter.cpp diff --git a/libopenbuenos/src/ob_graph.cpp b/libfreetpu/src/ob_graph.cpp similarity index 100% rename from libopenbuenos/src/ob_graph.cpp rename to libfreetpu/src/ob_graph.cpp diff --git a/libopenbuenos/src/ob_internal.h b/libfreetpu/src/ob_internal.h similarity index 99% rename from libopenbuenos/src/ob_internal.h rename to libfreetpu/src/ob_internal.h index 733d2206..7575d874 100644 --- a/libopenbuenos/src/ob_internal.h +++ b/libfreetpu/src/ob_internal.h @@ -1,7 +1,7 @@ #ifndef OPENBUENOS_INTERNAL_H_ #define OPENBUENOS_INTERNAL_H_ -#include "openbuenos.h" +#include "freetpu.h" #include "litebuf_vii_wire.h" #include diff --git a/libopenbuenos/src/ob_quant_unpack.cpp b/libfreetpu/src/ob_quant_unpack.cpp similarity index 100% rename from libopenbuenos/src/ob_quant_unpack.cpp rename to libfreetpu/src/ob_quant_unpack.cpp diff --git a/libopenbuenos/src/ob_quant_unpack.hpp b/libfreetpu/src/ob_quant_unpack.hpp similarity index 99% rename from libopenbuenos/src/ob_quant_unpack.hpp rename to libfreetpu/src/ob_quant_unpack.hpp index 00548dfa..b5653824 100644 --- a/libopenbuenos/src/ob_quant_unpack.hpp +++ b/libfreetpu/src/ob_quant_unpack.hpp @@ -4,7 +4,7 @@ #ifndef OPENBUENOS_QUANT_UNPACK_HPP_ #define OPENBUENOS_QUANT_UNPACK_HPP_ -#include "openbuenos.h" +#include "freetpu.h" #include #include diff --git a/libopenbuenos/src/ob_sha256.cpp b/libfreetpu/src/ob_sha256.cpp similarity index 100% rename from libopenbuenos/src/ob_sha256.cpp rename to libfreetpu/src/ob_sha256.cpp diff --git a/libopenbuenos/src/ob_worker_pool.cpp b/libfreetpu/src/ob_worker_pool.cpp similarity index 100% rename from libopenbuenos/src/ob_worker_pool.cpp rename to libfreetpu/src/ob_worker_pool.cpp diff --git a/libopenbuenos/tests/ob_quant_unpack_test.cpp b/libfreetpu/tests/ob_quant_unpack_test.cpp similarity index 99% rename from libopenbuenos/tests/ob_quant_unpack_test.cpp rename to libfreetpu/tests/ob_quant_unpack_test.cpp index 8adc78ac..bf0a7f32 100644 --- a/libopenbuenos/tests/ob_quant_unpack_test.cpp +++ b/libfreetpu/tests/ob_quant_unpack_test.cpp @@ -2,7 +2,7 @@ // Dedicated unit & numerical accuracy test suite for modern GGUF quant formats // (Q4_K, Q6_K, IQ4_NL, IQ4_XS) + Q8_0/Q4_0 regression in libopenbuenos. -#include "openbuenos.h" +#include "freetpu.h" #include "ob_internal.h" #include "ob_quant_unpack.hpp" diff --git a/libopenbuenos/tests/openbuenos_adversarial_test.cpp b/libfreetpu/tests/openbuenos_adversarial_test.cpp similarity index 99% rename from libopenbuenos/tests/openbuenos_adversarial_test.cpp rename to libfreetpu/tests/openbuenos_adversarial_test.cpp index 9bcca422..5972fb23 100644 --- a/libopenbuenos/tests/openbuenos_adversarial_test.cpp +++ b/libfreetpu/tests/openbuenos_adversarial_test.cpp @@ -2,7 +2,7 @@ // Covers: extreme env vars, cap values, churn, shrink, concurrent access, // oversized tiles, SIZE_MAX/overflow guards. Built standalone with // ASan+UBSan (and TSan for the concurrency suite) against the host sources. -#include "openbuenos.h" +#include "freetpu.h" #include "ob_internal.h" #include "litebuf_vii_wire.h" diff --git a/libopenbuenos/tests/openbuenos_host_test.cpp b/libfreetpu/tests/openbuenos_host_test.cpp similarity index 99% rename from libopenbuenos/tests/openbuenos_host_test.cpp rename to libfreetpu/tests/openbuenos_host_test.cpp index 83ffb27b..fee8e04b 100644 --- a/libopenbuenos/tests/openbuenos_host_test.cpp +++ b/libfreetpu/tests/openbuenos_host_test.cpp @@ -1,5 +1,5 @@ // Comprehensive host unit test suite for libopenbuenos (100% offline, mock_mode=1). -#include "openbuenos.h" +#include "freetpu.h" #include "ob_internal.h" #include "litebuf_vii_wire.h" diff --git a/libopenbuenos/tests/openbuenos_pool_guards_test.cpp b/libfreetpu/tests/openbuenos_pool_guards_test.cpp similarity index 100% rename from libopenbuenos/tests/openbuenos_pool_guards_test.cpp rename to libfreetpu/tests/openbuenos_pool_guards_test.cpp diff --git a/libopenbuenos/tests/openbuenos_selftest.cpp b/libfreetpu/tests/openbuenos_selftest.cpp similarity index 99% rename from libopenbuenos/tests/openbuenos_selftest.cpp rename to libfreetpu/tests/openbuenos_selftest.cpp index 8824bace..4cfa425a 100644 --- a/libopenbuenos/tests/openbuenos_selftest.cpp +++ b/libfreetpu/tests/openbuenos_selftest.cpp @@ -1,6 +1,6 @@ // Standalone Android ARM64 PIE self-test binary for libopenbuenos. // Links ONLY against libopenbuenos.a + libc/libm (zero Google/vendor .so). -#include "openbuenos.h" +#include "freetpu.h" #include "ob_internal.h" #include diff --git a/libopenbuenos/tests/tpu_soc_probe.cpp b/libfreetpu/tests/tpu_soc_probe.cpp similarity index 99% rename from libopenbuenos/tests/tpu_soc_probe.cpp rename to libfreetpu/tests/tpu_soc_probe.cpp index 86318f6c..1d93f621 100644 --- a/libopenbuenos/tests/tpu_soc_probe.cpp +++ b/libfreetpu/tests/tpu_soc_probe.cpp @@ -1,6 +1,6 @@ // Clean-room /dev/edgetpu-soc live UAPI + SMMUv3 DMA-BUF + minimal INT8 GEMM probe. // Designed for standalone Linux ARM64 (OmaMobile / Arch Linux ARM) and host --mock CI. -#include "openbuenos.h" +#include "freetpu.h" #include #include diff --git a/libopenbuenos/CMakeLists.txt b/libopenbuenos/CMakeLists.txt deleted file mode 100644 index 251b5107..00000000 --- a/libopenbuenos/CMakeLists.txt +++ /dev/null @@ -1,234 +0,0 @@ -cmake_minimum_required(VERSION 3.18) -project(openbuenos VERSION 0.1.0 LANGUAGES C CXX) - -include(GNUInstallDirs) -include(CMakePackageConfigHelpers) - -option(OPENBUENOS_BUILD_TESTS "Build libopenbuenos self-test / host unit test binaries" ON) -option(OPENBUENOS_INSTALL_SELFTEST "Install openbuenos_selftest utility" ON) -option(OPENBUENOS_WERROR "Treat compiler warnings as errors" ON) -option(OPENBUENOS_ENABLE_FREETILE "Wire clean-room FreeTile BUENOS_A0 VLIW/DGC0 emitter into libopenbuenos" ON) -option(OPENBUENOS_FREETILE_DEFAULT_ON "Default OPENBUENOS_FREETILE to enabled unless overridden by env" OFF) - -set(OPENBUENOS_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/..") -set(OPENBUENOS_COMPILE_FLAGS -Wall -Wextra -Wpedantic -fno-exceptions -fno-rtti) -if (OPENBUENOS_WERROR) - list(APPEND OPENBUENOS_COMPILE_FLAGS -Werror) -endif() - -set(OPENBUENOS_SOURCES - src/ob_sha256.cpp - src/ob_dgc0.cpp - src/ob_buffer_pool.cpp - src/ob_worker_pool.cpp - src/ob_device.cpp - src/ob_graph.cpp - src/ob_freetile_bridge.cpp - src/ob_quant_unpack.cpp - src/ob_gemm_emitter.cpp - src/ob_gemm.cpp -) - -set(_ob_use_freetile OFF) -if (OPENBUENOS_ENABLE_FREETILE AND EXISTS "${OPENBUENOS_ROOT}/freetile/include/freetile/buenos_emitter.hpp") - set(_ob_use_freetile ON) - if (NOT TARGET freetile) - list(APPEND OPENBUENOS_SOURCES - ${OPENBUENOS_ROOT}/freetile/src/tile_ir.cpp - ${OPENBUENOS_ROOT}/freetile/src/buenos_emitter.cpp - ) - endif() -endif() - -add_library(openbuenos_obj OBJECT ${OPENBUENOS_SOURCES}) -set_target_properties(openbuenos_obj PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_compile_features(openbuenos_obj PUBLIC cxx_std_17) -target_compile_options(openbuenos_obj PRIVATE ${OPENBUENOS_COMPILE_FLAGS}) - -if (_ob_use_freetile) - target_compile_definitions(openbuenos_obj PRIVATE OPENBUENOS_WITH_FREETILE=1) - if (OPENBUENOS_FREETILE_DEFAULT_ON) - target_compile_definitions(openbuenos_obj PRIVATE OPENBUENOS_FREETILE_DEFAULT_ON_VAL=1) - else() - target_compile_definitions(openbuenos_obj PRIVATE OPENBUENOS_FREETILE_DEFAULT_ON_VAL=0) - endif() - if (TARGET freetile) - target_link_libraries(openbuenos_obj PRIVATE $) - endif() -else() - target_compile_definitions(openbuenos_obj PRIVATE OPENBUENOS_WITH_FREETILE=0 OPENBUENOS_FREETILE_DEFAULT_ON_VAL=0) -endif() - -target_include_directories(openbuenos_obj - PRIVATE - $ - $ - $ - $ - $ -) - -add_library(openbuenos STATIC $) -add_library(openbuenos::openbuenos ALIAS openbuenos) - -add_library(freetpu STATIC $) -add_library(freetpu::freetpu ALIAS freetpu) - -foreach(_ob_target IN ITEMS openbuenos freetpu) - set_target_properties(${_ob_target} PROPERTIES POSITION_INDEPENDENT_CODE ON) - target_compile_features(${_ob_target} PUBLIC cxx_std_17) - if (_ob_use_freetile AND TARGET freetile) - target_link_libraries(${_ob_target} PRIVATE $) - endif() - target_include_directories(${_ob_target} - PUBLIC - $ - $ - ) - if (UNIX AND NOT APPLE) - target_link_libraries(${_ob_target} PUBLIC m) - if (NOT ANDROID) - find_package(Threads REQUIRED) - target_link_libraries(${_ob_target} PUBLIC Threads::Threads) - endif() - elseif (APPLE) - target_link_libraries(${_ob_target} PUBLIC m) - endif() -endforeach() - -if (OPENBUENOS_BUILD_TESTS) - add_executable(openbuenos_selftest tests/openbuenos_selftest.cpp) - target_link_libraries(openbuenos_selftest PRIVATE openbuenos) - target_include_directories(openbuenos_selftest PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${OPENBUENOS_ROOT}/docs/baremetal-vii - ${OPENBUENOS_ROOT}/docs/kernel-abi - ) - target_compile_features(openbuenos_selftest PRIVATE cxx_std_17) - target_compile_options(openbuenos_selftest PRIVATE ${OPENBUENOS_COMPILE_FLAGS}) - if (ANDROID) - target_compile_options(openbuenos_selftest PRIVATE -fPIE) - target_link_options(openbuenos_selftest PRIVATE -pie -static-libstdc++ -Wl,--as-needed) - elseif (UNIX AND NOT APPLE AND OPENBUENOS_INSTALL_SELFTEST) - install(TARGETS openbuenos_selftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - endif() - - add_executable(tpu_soc_probe tests/tpu_soc_probe.cpp) - target_link_libraries(tpu_soc_probe PRIVATE openbuenos) - target_include_directories(tpu_soc_probe PRIVATE - ${OPENBUENOS_ROOT}/docs/kernel-abi - ) - target_compile_features(tpu_soc_probe PRIVATE cxx_std_17) - target_compile_options(tpu_soc_probe PRIVATE ${OPENBUENOS_COMPILE_FLAGS}) - if (ANDROID) - target_compile_options(tpu_soc_probe PRIVATE -fPIE) - target_link_options(tpu_soc_probe PRIVATE -pie -static-libstdc++ -Wl,--as-needed) - elseif (UNIX AND NOT APPLE AND OPENBUENOS_INSTALL_SELFTEST) - install(TARGETS tpu_soc_probe RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - endif() - - if (NOT ANDROID) - add_executable(openbuenos_host_test tests/openbuenos_host_test.cpp) - target_link_libraries(openbuenos_host_test PRIVATE openbuenos) - target_include_directories(openbuenos_host_test PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${OPENBUENOS_ROOT}/docs/baremetal-vii - ${OPENBUENOS_ROOT}/docs/kernel-abi - ) - target_compile_features(openbuenos_host_test PRIVATE cxx_std_17) - target_compile_options(openbuenos_host_test PRIVATE ${OPENBUENOS_COMPILE_FLAGS}) - enable_testing() - add_test(NAME openbuenos_host_test COMMAND openbuenos_host_test) - add_test(NAME tpu_soc_probe_mock COMMAND tpu_soc_probe --mock) - - add_executable(openbuenos_adversarial_test tests/openbuenos_adversarial_test.cpp) - target_link_libraries(openbuenos_adversarial_test PRIVATE openbuenos) - target_include_directories(openbuenos_adversarial_test PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${OPENBUENOS_ROOT}/docs/baremetal-vii - ${OPENBUENOS_ROOT}/docs/kernel-abi - ) - target_compile_features(openbuenos_adversarial_test PRIVATE cxx_std_17) - target_compile_options(openbuenos_adversarial_test PRIVATE ${OPENBUENOS_COMPILE_FLAGS}) - add_test(NAME openbuenos_adversarial_test COMMAND openbuenos_adversarial_test) - - add_executable(ob_quant_unpack_test tests/ob_quant_unpack_test.cpp) - target_link_libraries(ob_quant_unpack_test PRIVATE openbuenos) - target_include_directories(ob_quant_unpack_test PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${OPENBUENOS_ROOT}/docs/baremetal-vii - ${OPENBUENOS_ROOT}/docs/kernel-abi - ) - target_compile_features(ob_quant_unpack_test PRIVATE cxx_std_17) - target_compile_options(ob_quant_unpack_test PRIVATE ${OPENBUENOS_COMPILE_FLAGS}) - add_test(NAME ob_quant_unpack_test COMMAND ob_quant_unpack_test) - - add_executable(openbuenos_pool_guards_test tests/openbuenos_pool_guards_test.cpp) - target_link_libraries(openbuenos_pool_guards_test PRIVATE openbuenos) - target_include_directories(openbuenos_pool_guards_test PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${OPENBUENOS_ROOT}/docs/baremetal-vii - ${OPENBUENOS_ROOT}/docs/kernel-abi - ) - target_compile_features(openbuenos_pool_guards_test PRIVATE cxx_std_17) - target_compile_options(openbuenos_pool_guards_test PRIVATE ${OPENBUENOS_COMPILE_FLAGS}) - add_test(NAME openbuenos_pool_guards_test COMMAND openbuenos_pool_guards_test) - endif() -endif() - -install(TARGETS openbuenos - EXPORT openbuenosTargets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -) -install(TARGETS freetpu - EXPORT freetpuTargets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -) -install(FILES include/openbuenos.h include/freetpu.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) -install(FILES ${OPENBUENOS_ROOT}/docs/kernel-abi/edgetpu_buenos_uapi.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetpu -) -install(EXPORT openbuenosTargets - FILE openbuenosTargets.cmake - NAMESPACE openbuenos:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openbuenos -) -install(EXPORT freetpuTargets - FILE freetpuTargets.cmake - NAMESPACE freetpu:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetpu -) -configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/openbuenosConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/openbuenosConfig.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openbuenos -) -write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/openbuenosConfigVersion.cmake - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion -) -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/openbuenosConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/openbuenosConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openbuenos -) -configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/freetpuConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/freetpuConfig.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetpu -) -write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/freetpuConfigVersion.cmake - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion -) -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/freetpuConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/freetpuConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/freetpu -) diff --git a/libopenbuenos/cmake/openbuenosConfig.cmake.in b/libopenbuenos/cmake/openbuenosConfig.cmake.in deleted file mode 100644 index 7ec61d8f..00000000 --- a/libopenbuenos/cmake/openbuenosConfig.cmake.in +++ /dev/null @@ -1,9 +0,0 @@ -@PACKAGE_INIT@ - -include(CMakeFindDependencyMacro) -if(UNIX AND NOT APPLE AND NOT ANDROID) - find_dependency(Threads) -endif() - -include("${CMAKE_CURRENT_LIST_DIR}/openbuenosTargets.cmake") -check_required_components(openbuenos) diff --git a/libopenbuenos/include/freetpu.h b/libopenbuenos/include/freetpu.h deleted file mode 100644 index e553a19f..00000000 --- a/libopenbuenos/include/freetpu.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * libfreetpu - Public C11 / C++17 ABI header for FreeSilicon FreeTPU - * - * Canonical entry point for external consumers (e.g. llama.cpp ggml-freetpu). - * Re-exports the Tensor G5 (Buenos A0) userspace runtime ABI from openbuenos.h. - */ -#ifndef FREETPU_H_ -#define FREETPU_H_ - -#include "openbuenos.h" - -#define FREETPU_API_VERSION_MAJOR OB_API_VERSION_MAJOR -#define FREETPU_API_VERSION_MINOR OB_API_VERSION_MINOR -#define FREETPU_API_VERSION_PATCH OB_API_VERSION_PATCH - -#endif /* FREETPU_H_ */ diff --git a/llama-cpp-edgetpu/CMakeLists.txt b/llama-cpp-edgetpu/CMakeLists.txt index 9dc985ec..36122480 100644 --- a/llama-cpp-edgetpu/CMakeLists.txt +++ b/llama-cpp-edgetpu/CMakeLists.txt @@ -1,102 +1,102 @@ -set(OPENBUENOS_DIR "" CACHE PATH "ggml-edgetpu: path to libopenbuenos root or install prefix") -option(GGML_EDGETPU_ALLOW_MOCK_SHIM "Allow built-in mock shim when libopenbuenos is not found" OFF) +set(FREETPU_DIR "" CACHE PATH "ggml-edgetpu: path to libfreetpu root or install prefix") +option(GGML_EDGETPU_ALLOW_MOCK_SHIM "Allow built-in mock shim when libfreetpu is not found" OFF) -if (NOT OPENBUENOS_DIR) - if (DEFINED ENV{OPENBUENOS_DIR} AND NOT "$ENV{OPENBUENOS_DIR}" STREQUAL "") - set(OPENBUENOS_DIR "$ENV{OPENBUENOS_DIR}") +if (NOT FREETPU_DIR) + if (DEFINED ENV{FREETPU_DIR} AND NOT "$ENV{FREETPU_DIR}" STREQUAL "") + set(FREETPU_DIR "$ENV{FREETPU_DIR}") else() - get_filename_component(_ob_default "${CMAKE_CURRENT_LIST_DIR}/../../../../../libopenbuenos" ABSOLUTE) - get_filename_component(_ob_sibling "${CMAKE_CURRENT_LIST_DIR}/../libopenbuenos" ABSOLUTE) - if (EXISTS "${_ob_default}/include/openbuenos.h") - set(OPENBUENOS_DIR "${_ob_default}") - elseif (EXISTS "${_ob_sibling}/include/openbuenos.h") - set(OPENBUENOS_DIR "${_ob_sibling}") + get_filename_component(_freetpu_default "${CMAKE_CURRENT_LIST_DIR}/../../../../../libfreetpu" ABSOLUTE) + get_filename_component(_freetpu_sibling "${CMAKE_CURRENT_LIST_DIR}/../libfreetpu" ABSOLUTE) + if (EXISTS "${_freetpu_default}/include/freetpu.h") + set(FREETPU_DIR "${_freetpu_default}") + elseif (EXISTS "${_freetpu_sibling}/include/freetpu.h") + set(FREETPU_DIR "${_freetpu_sibling}") endif() endif() endif() -set(_ob_target "") -set(_ob_lib "") -set(_ob_inc "") +set(_freetpu_target "") +set(_freetpu_lib "") +set(_freetpu_inc "") -if (OPENBUENOS_DIR) +if (FREETPU_DIR) if (ANDROID) - set(_ob_candidates - "${OPENBUENOS_DIR}/build/android-arm64/libopenbuenos.a" - "${OPENBUENOS_DIR}/lib/android-arm64/libopenbuenos.a" - "${OPENBUENOS_DIR}/build/libopenbuenos.a") + set(_freetpu_candidates + "${FREETPU_DIR}/build/android-arm64/libfreetpu.a" + "${FREETPU_DIR}/lib/android-arm64/libfreetpu.a" + "${FREETPU_DIR}/build/libfreetpu.a") else() - set(_ob_candidates - "${OPENBUENOS_DIR}/build/linux-arm64/libopenbuenos.a" - "${OPENBUENOS_DIR}/build/host/libopenbuenos.a" - "${OPENBUENOS_DIR}/lib/linux-arm64/libopenbuenos.a" - "${OPENBUENOS_DIR}/lib/host/libopenbuenos.a" - "${OPENBUENOS_DIR}/lib/aarch64-linux-gnu/libopenbuenos.a" - "${OPENBUENOS_DIR}/lib/libopenbuenos.a" - "${OPENBUENOS_DIR}/lib64/libopenbuenos.a" - "${OPENBUENOS_DIR}/build/libopenbuenos.a") + set(_freetpu_candidates + "${FREETPU_DIR}/build/linux-arm64/libfreetpu.a" + "${FREETPU_DIR}/build/host/libfreetpu.a" + "${FREETPU_DIR}/lib/linux-arm64/libfreetpu.a" + "${FREETPU_DIR}/lib/host/libfreetpu.a" + "${FREETPU_DIR}/lib/aarch64-linux-gnu/libfreetpu.a" + "${FREETPU_DIR}/lib/libfreetpu.a" + "${FREETPU_DIR}/lib64/libfreetpu.a" + "${FREETPU_DIR}/build/libfreetpu.a") endif() - foreach(_cand IN LISTS _ob_candidates) + foreach(_cand IN LISTS _freetpu_candidates) if (EXISTS "${_cand}") - set(_ob_lib "${_cand}") + set(_freetpu_lib "${_cand}") break() endif() endforeach() - if (EXISTS "${OPENBUENOS_DIR}/include/openbuenos.h") - set(_ob_inc "${OPENBUENOS_DIR}/include") + if (EXISTS "${FREETPU_DIR}/include/freetpu.h") + set(_freetpu_inc "${FREETPU_DIR}/include") endif() endif() -if (NOT _ob_lib AND NOT ANDROID) - find_package(openbuenos CONFIG QUIET) - if (TARGET openbuenos::openbuenos) - set(_ob_target openbuenos::openbuenos) +if (NOT _freetpu_lib AND NOT ANDROID) + find_package(freetpu CONFIG QUIET) + if (TARGET freetpu::freetpu) + set(_freetpu_target freetpu::freetpu) else() - find_library(_ob_sys_lib NAMES openbuenos + find_library(_freetpu_sys_lib NAMES freetpu PATHS /usr /usr/local PATH_SUFFIXES lib lib64 lib/aarch64-linux-gnu) - find_path(_ob_sys_inc NAMES openbuenos.h + find_path(_freetpu_sys_inc NAMES freetpu.h PATHS /usr /usr/local PATH_SUFFIXES include) - if (_ob_sys_lib AND _ob_sys_inc) - set(_ob_lib "${_ob_sys_lib}") - set(_ob_inc "${_ob_sys_inc}") + if (_freetpu_sys_lib AND _freetpu_sys_inc) + set(_freetpu_lib "${_freetpu_sys_lib}") + set(_freetpu_inc "${_freetpu_sys_inc}") endif() endif() endif() set(GGML_EDGETPU_SOURCES ggml-edgetpu.cpp) -if (_ob_target) - message(STATUS "ggml-edgetpu: linking installed CMake target ${_ob_target}") -elseif (_ob_lib) - message(STATUS "ggml-edgetpu: linking libopenbuenos library: ${_ob_lib}") +if (_freetpu_target) + message(STATUS "ggml-edgetpu: linking installed CMake target ${_freetpu_target}") +elseif (_freetpu_lib) + message(STATUS "ggml-edgetpu: linking libfreetpu library: ${_freetpu_lib}") elseif (GGML_EDGETPU_ALLOW_MOCK_SHIM) - message(STATUS "ggml-edgetpu: libopenbuenos not found; compiling built-in mock shim (GGML_EDGETPU_ALLOW_MOCK_SHIM=ON)") + message(STATUS "ggml-edgetpu: libfreetpu not found; compiling built-in mock shim (GGML_EDGETPU_ALLOW_MOCK_SHIM=ON)") list(APPEND GGML_EDGETPU_SOURCES openbuenos_shim.c) else() - message(FATAL_ERROR "ggml-edgetpu: libopenbuenos not found (install omamobile-freetpu, set -DOPENBUENOS_DIR=, or pass -DGGML_EDGETPU_ALLOW_MOCK_SHIM=ON)") + message(FATAL_ERROR "ggml-edgetpu: libfreetpu not found (install omamobile-freetpu, set -DFREETPU_DIR=, or pass -DGGML_EDGETPU_ALLOW_MOCK_SHIM=ON)") endif() ggml_add_backend_library(ggml-edgetpu ${GGML_EDGETPU_SOURCES}) -if (_ob_target) - target_link_libraries(ggml-edgetpu PRIVATE ${_ob_target}) +if (_freetpu_target) + target_link_libraries(ggml-edgetpu PRIVATE ${_freetpu_target}) target_compile_definitions(ggml-edgetpu PRIVATE GGML_EDGETPU_LINKED_LIBOPENBUENOS=1) -elseif (_ob_lib) - if (NOT _ob_inc) - message(FATAL_ERROR "ggml-edgetpu: openbuenos.h not found alongside ${_ob_lib} (set -DOPENBUENOS_DIR=)") +elseif (_freetpu_lib) + if (NOT _freetpu_inc) + message(FATAL_ERROR "ggml-edgetpu: freetpu.h not found alongside ${_freetpu_lib} (set -DFREETPU_DIR=)") endif() - target_include_directories(ggml-edgetpu PRIVATE "${_ob_inc}") - target_link_libraries(ggml-edgetpu PRIVATE "${_ob_lib}") + target_include_directories(ggml-edgetpu PRIVATE "${_freetpu_inc}") + target_link_libraries(ggml-edgetpu PRIVATE "${_freetpu_lib}") target_compile_definitions(ggml-edgetpu PRIVATE GGML_EDGETPU_LINKED_LIBOPENBUENOS=1) else() - if (_ob_inc) - target_include_directories(ggml-edgetpu PRIVATE "${_ob_inc}") - elseif (OPENBUENOS_DIR AND EXISTS "${OPENBUENOS_DIR}/include/openbuenos.h") - target_include_directories(ggml-edgetpu PRIVATE "${OPENBUENOS_DIR}/include") + if (_freetpu_inc) + target_include_directories(ggml-edgetpu PRIVATE "${_freetpu_inc}") + elseif (FREETPU_DIR AND EXISTS "${FREETPU_DIR}/include/freetpu.h") + target_include_directories(ggml-edgetpu PRIVATE "${FREETPU_DIR}/include") else() - message(FATAL_ERROR "ggml-edgetpu: openbuenos.h not found for mock shim (set -DOPENBUENOS_DIR=)") + message(FATAL_ERROR "ggml-edgetpu: freetpu.h not found for mock shim (set -DFREETPU_DIR=)") endif() target_compile_definitions(ggml-edgetpu PRIVATE GGML_EDGETPU_LINKED_LIBOPENBUENOS=0) endif() diff --git a/llama-cpp-edgetpu/build.sh b/llama-cpp-edgetpu/build.sh index 4a98742c..e2ec6f5b 100755 --- a/llama-cpp-edgetpu/build.sh +++ b/llama-cpp-edgetpu/build.sh @@ -4,7 +4,7 @@ set -euo pipefail ROOT="$(cd "$(dirname "$0")" && pwd)" REPO_ROOT="$(cd "$ROOT/.." && pwd)" SRC="${LLAMA_CPP_DIR:-$ROOT/upstream/llama.cpp-b12608}" -OB="${OPENBUENOS_DIR:-$REPO_ROOT/libopenbuenos}" +OB="${FREETPU_DIR:-$REPO_ROOT/libfreetpu}" CMAKE="${CMAKE:-$(command -v cmake || echo /opt/homebrew/share/android-commandlinetools/cmake/3.22.1/bin/cmake)}" NINJA="${NINJA:-$(command -v ninja || echo /opt/homebrew/share/android-commandlinetools/cmake/3.22.1/bin/ninja)}" NDK="${NDK:-/opt/homebrew/share/android-commandlinetools/ndk/26.1.10909125}" @@ -50,7 +50,7 @@ build_host() { -DLLAMA_BUILD_TESTS=ON \ -DLLAMA_BUILD_TOOLS=ON \ -DLLAMA_OPENSSL=OFF \ - -DOPENBUENOS_DIR="$OB" + -DFREETPU_DIR="$OB" "$CMAKE" --build "$ROOT/build-host" --target test-backend-ops llama-cli llama-bench llama-completion ggml-rpc-server -j"$JOBS" } @@ -73,7 +73,7 @@ build_android() { -DLLAMA_BUILD_TESTS=ON \ -DLLAMA_BUILD_TOOLS=ON \ -DLLAMA_OPENSSL=OFF \ - -DOPENBUENOS_DIR="$OB" + -DFREETPU_DIR="$OB" "$CMAKE" --build "$ROOT/build-android-arm64" --target test-backend-ops llama-cli llama-bench llama-completion ggml-rpc-server -j"$JOBS" echo "=== Stripping & verifying zero-Google-.so Android ARM64 binaries ===" @@ -109,7 +109,7 @@ build_linux_arm64() { mkdir -p "$OB/build/linux-arm64" fi - echo "=== Building libopenbuenos (${ob_build#$OB/}) ===" + echo "=== Building libfreetpu (${ob_build#$OB/}) ===" "$CMAKE" -S "$OB" -B "$ob_build" -G Ninja \ -DCMAKE_MAKE_PROGRAM="$NINJA" \ -DCMAKE_BUILD_TYPE=Release \ @@ -117,7 +117,7 @@ build_linux_arm64() { ${static_flags[@]+"${static_flags[@]}"} "$CMAKE" --build "$ob_build" -j"$JOBS" if [[ "$is_static" == "1" ]]; then - cp "$ob_build/libopenbuenos.a" "$OB/build/linux-arm64/libopenbuenos.a" + cp "$ob_build/libfreetpu.a" "$OB/build/linux-arm64/libfreetpu.a" fi overlay_backend @@ -135,7 +135,7 @@ build_linux_arm64() { -DLLAMA_BUILD_TESTS=ON \ -DLLAMA_BUILD_TOOLS=ON \ -DLLAMA_OPENSSL=OFF \ - -DOPENBUENOS_DIR="$OB" + -DFREETPU_DIR="$OB" "$CMAKE" --build "$llama_build" --target test-backend-ops llama-cli llama-bench llama-completion ggml-rpc-server -j"$JOBS" if command -v readelf >/dev/null 2>&1; then diff --git a/llama-cpp-edgetpu/ggml-edgetpu.cpp b/llama-cpp-edgetpu/ggml-edgetpu.cpp index 661be270..73834673 100644 --- a/llama-cpp-edgetpu/ggml-edgetpu.cpp +++ b/llama-cpp-edgetpu/ggml-edgetpu.cpp @@ -6,7 +6,7 @@ #define GGML_COMMON_DECL_CPP #include "ggml-common.h" -#include "openbuenos.h" +#include "freetpu.h" #include #include diff --git a/llama-cpp-edgetpu/openbuenos_shim.c b/llama-cpp-edgetpu/openbuenos_shim.c index 46ffda34..39834e3a 100644 --- a/llama-cpp-edgetpu/openbuenos_shim.c +++ b/llama-cpp-edgetpu/openbuenos_shim.c @@ -7,7 +7,7 @@ #define _POSIX_C_SOURCE 200809L #endif -#include "openbuenos.h" +#include "freetpu.h" #include #include diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD index e9083e50..1b14f50d 100644 --- a/packaging/arch/PKGBUILD +++ b/packaging/arch/PKGBUILD @@ -2,14 +2,14 @@ # Maintainer: OmaMobile Contributors # # Clean-room userspace stack for Tensor G5 (laguna) EdgeTPU (/dev/edgetpu-soc): -# - libopenbuenos static library (built -fPIC, wired with FreeTile BUENOS_A0) + CMake package + headers +# - libfreetpu static library (built -fPIC, wired with FreeTile BUENOS_A0) + CMake package + headers # - tpu_soc_probe, openbuenos_selftest, and tpu_baremetal_runner CLI utilities # - udev rules for non-root access to /dev/edgetpu-soc and /dev/dma_heap/system # # Runtime emitter selection: # - OPENBUENOS_FREETILE=1 enables the zero-dep C++17 FreeTile BUENOS_A0 VLIW/DGC0 # emitter with automatic fallback to legacy ob_gemm_emitter for unsupported shapes/epilogues. -# - Set -DOPENBUENOS_FREETILE_DEFAULT_ON=ON at build time to make FreeTile default-on. +# - Set -DFREETPU_FREETILE_DEFAULT_ON=ON at build time to make FreeTile default-on. # # Proprietary firmware (google/edgetpu-buenos.fw) and the RV64 interpreter binary # (dive_interp_rv64.bin) are NOT packaged here; extract them from the device @@ -27,7 +27,7 @@ makedepends=(cmake ninja gcc) optdepends=( 'linux-omamobile: mainline Tensor G5 EdgeTPU kernel driver (/dev/edgetpu-soc)' ) -provides=(libopenbuenos freetpu freetile) +provides=(libfreetpu freetpu freetile) source=( "freetpu-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz" 99-edgetpu.rules @@ -35,15 +35,15 @@ source=( sha256sums=('SKIP' 'SKIP') build() { - cmake -S "freetpu-$pkgver/libopenbuenos" -B build-lib -G Ninja \ + cmake -S "freetpu-$pkgver/libfreetpu" -B build-lib -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DOPENBUENOS_ENABLE_FREETILE=ON \ - -DOPENBUENOS_FREETILE_DEFAULT_ON=OFF \ - -DOPENBUENOS_BUILD_TESTS=ON \ - -DOPENBUENOS_INSTALL_SELFTEST=ON \ - -DOPENBUENOS_WERROR=OFF + -DFREETPU_ENABLE_FREETILE=ON \ + -DFREETPU_FREETILE_DEFAULT_ON=OFF \ + -DFREETPU_BUILD_TESTS=ON \ + -DFREETPU_INSTALL_SELFTEST=ON \ + -DFREETPU_WERROR=OFF cmake --build build-lib cmake -S "freetpu-$pkgver/runtime" -B build-runtime -G Ninja \