From b34d9b745bd506f6057c4afee6d630e7d35090cf Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 4 Nov 2024 21:14:00 +0000 Subject: [PATCH] #14590: Move sfpi off LFS Remove tt_metal/third_party/sfpi submodule. Add smarts to tt_metal/hw to download sfpi release into runtome/sfpi --- .gitmodules | 3 --- tt_metal/hw/CMakeLists.txt | 12 ++++++++- tt_metal/hw/sfpi.md5 | 1 + tt_metal/hw/sfpi.sh | 50 ++++++++++++++++++++++++++++++++++++ tt_metal/hw/sfpi.version | 1 + tt_metal/jit_build/build.cpp | 6 ++--- tt_metal/third_party/sfpi | 1 - 7 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 tt_metal/hw/sfpi.md5 create mode 100755 tt_metal/hw/sfpi.sh create mode 100644 tt_metal/hw/sfpi.version delete mode 160000 tt_metal/third_party/sfpi diff --git a/.gitmodules b/.gitmodules index ab121e423f3..b2ca1e266db 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "src/ckernels/sfpi"] - path = tt_metal/third_party/sfpi - url = https://github.com/tenstorrent-metal/sfpi-rel-temp.git [submodule "third_party/pybind11"] path = tt_metal/third_party/pybind11 url = https://github.com/pybind/pybind11.git diff --git a/tt_metal/hw/CMakeLists.txt b/tt_metal/hw/CMakeLists.txt index 1b16ac15428..f5145f0cd76 100644 --- a/tt_metal/hw/CMakeLists.txt +++ b/tt_metal/hw/CMakeLists.txt @@ -18,6 +18,15 @@ set(TYPES kernel ) +add_custom_target( + sfpi + ${CMAKE_CURRENT_SOURCE_DIR}/sfpi.sh ${CMAKE_CURRENT_SOURCE_DIR}/sfpi.version ${CMAKE_CURRENT_SOURCE_DIR}/sfpi.md5 + ${PROJECT_SOURCE_DIR}/runtime/sfpi + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/sfpi.version + USES_TERMINAL +) + foreach(ARCH IN LISTS ARCHS) set(DEV_MEM_MAP "${PROJECT_SOURCE_DIR}/tt_metal/hw/inc/${ARCH}/dev_mem_map.h") set(HW_INCLUDES "${PROJECT_SOURCE_DIR}/tt_metal/hw/inc/${ARCH}") @@ -78,7 +87,7 @@ function(get_alias INPUT_STRING OUTPUT_VAR) endfunction() # Define the compiler command -set(GPP_CMD ${PROJECT_SOURCE_DIR}/tt_metal/third_party/sfpi/compiler/bin/riscv32-unknown-elf-g++) +set(GPP_CMD ${PROJECT_SOURCE_DIR}/runtime/sfpi/compiler/bin/riscv32-unknown-elf-g++) set(GPP_DEFINES -DTENSIX_FIRMWARE) @@ -189,6 +198,7 @@ foreach(ARCH IN LISTS ARCHS) ${GPP_CMD} ${GPP_FLAGS} ${GPP_DEFINES} ${GPP_INCLUDES} -c -o ${HW_LIB_DIR}/${HWLIB}.o ${${HWLIB}_SOURCE} DEPENDS ${${HWLIB}_SOURCE} + sfpi COMMENT "Building hw lib ${HWLIB}.o" VERBATIM ) diff --git a/tt_metal/hw/sfpi.md5 b/tt_metal/hw/sfpi.md5 new file mode 100644 index 00000000000..8b6fd7f598b --- /dev/null +++ b/tt_metal/hw/sfpi.md5 @@ -0,0 +1 @@ +3ffa5a871a6289f19617de7293c1dac0 sfpi-release.tgz diff --git a/tt_metal/hw/sfpi.sh b/tt_metal/hw/sfpi.sh new file mode 100755 index 00000000000..ee7887f260a --- /dev/null +++ b/tt_metal/hw/sfpi.sh @@ -0,0 +1,50 @@ +#! /bin/bash + +# Script to automatically get a specified release. Invoke from your build system providing: +# VERSION file containing desired version +# MD5 file containing md5sum checksum +# DST target directory +# The script is lazy and will not redownload an already-downloaded version + +set -eo pipefail + +if [[ "$#" != 3 ]] ; then + echo "Usage: $0 VERSIONFILE MD5FILE DSTDIR" 1>&2 + exit 1 +fi + +verfile="$1" +md5file="$2" +dstdir="${3%/sfpi}" + +if cmp -s "$verfile" "$dstdir/sfpi/sfpi.version" ; then + # We have this already + touch "$dstdir/sfpi/sfpi.version" + echo "Already have sfpi release $(cat "$verfile")" + exit 0 +fi + +if which curl >/dev/null ; then + fetcher="curl -L -o - --ftp-pasv --retry 10" +elif which wget > /dev/null ; then + fetcher="wget -O -" +else + echo "No downloader available" 1>&2 + exit 1 +fi + +url=https://github.com/tenstorrent/sfpi/releases/download +read hash tarball < "$md5file" +read ver < "$verfile" + +echo "Downloading new sfpi release: $ver/$tarball" +mkdir -p "$dstdir" +$fetcher "$url/$ver/$tarball" > "$dstdir/$tarball" +if ! (cd "$dstdir" ; md5sum -c -) < "$md5file" ; then + echo "MD5 hash mismatch on $dstdir/$tarball" 1>&2 + exit 1 +fi + +(cd "$dstdir" && rm -rf sfpi && tar xzf "$tarball") +echo "$ver" > "$dstdir/sfpi/sfpi.version" +rm -f "$dstdir/$tarball" diff --git a/tt_metal/hw/sfpi.version b/tt_metal/hw/sfpi.version new file mode 100644 index 00000000000..e22a62f2cff --- /dev/null +++ b/tt_metal/hw/sfpi.version @@ -0,0 +1 @@ +v0.0.0-lfsectomy diff --git a/tt_metal/jit_build/build.cpp b/tt_metal/jit_build/build.cpp index cc31cf419cf..19919964392 100644 --- a/tt_metal/jit_build/build.cpp +++ b/tt_metal/jit_build/build.cpp @@ -53,7 +53,7 @@ void JitBuildEnv::init(uint32_t build_key, tt::ARCH arch) { this->out_kernel_root_ = this->out_root_ + to_string(build_key) + "/kernels/"; // Tools - this->gpp_ = this->root_ + "tt_metal/third_party/sfpi/compiler/bin/riscv32-unknown-elf-g++ "; + this->gpp_ = this->root_ + "runtime/sfpi/compiler/bin/riscv32-unknown-elf-g++ "; // Flags string common_flags; @@ -291,8 +291,8 @@ JitBuildCompute::JitBuildCompute(const JitBuildEnv& env, const JitBuiltStateConf env_.root_ + "tt_metal/hw/ckernels/" + env.arch_name_ + "/metal/common " + "-I" + env_.root_ + "tt_metal/hw/ckernels/" + env.arch_name_ + "/metal/llk_io " + "-I" + env_.root_ + "tt_metal/hw/ckernels/" + env.arch_name_ + "/metal/llk_api " + "-I" + env_.root_ + - "tt_metal/hw/ckernels/" + env.arch_name_ + "/metal/llk_api/llk_sfpu " + "-I" + env_.root_ + - "tt_metal/third_party/sfpi/include " + "-I" + env_.root_ + "tt_metal/hw/firmware/src " + "-I" + + "tt_metal/hw/ckernels/" + env.arch_name_ + "/metal/llk_api/llk_sfpu " + "-I" + + env_.root_ + "runtime/sfpi/include " + "-I" + env_.root_ + "tt_metal/hw/firmware/src " + "-I" + env_.root_ + "tt_metal/third_party/tt_llk_" + env.arch_name_ + "/llk_lib "; if (this->is_fw_) { diff --git a/tt_metal/third_party/sfpi b/tt_metal/third_party/sfpi deleted file mode 160000 index 1aab81a8ddd..00000000000 --- a/tt_metal/third_party/sfpi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1aab81a8ddddf94702fad18efec0c1c163c96bab