From 32d78198b697d22534f702bbd388b0983c011492 Mon Sep 17 00:00:00 2001 From: Fatih Cetinkaya <965295+devfacet@users.noreply.github.com> Date: Sat, 13 Apr 2024 17:31:06 -0400 Subject: [PATCH] Improve tests (#20) --- .github/workflows/test.yaml | 15 ++++++++++----- Makefile | 1 + scripts/docker/Dockerfile.amd64 | 16 ++++++++++++++++ ...erfile.generic => Dockerfile.amd64-generic} | 6 ++---- scripts/docker/Dockerfile.arm | 18 ++++++++++++++++++ scripts/docker/Dockerfile.arm-cmsis-dsp | 2 -- scripts/docker/Dockerfile.arm-neon | 2 -- scripts/docker/Dockerfile.armv7-neon | 2 -- scripts/docker/Dockerfile.armv8-neon | 2 -- 9 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 scripts/docker/Dockerfile.amd64 rename scripts/docker/{Dockerfile.generic => Dockerfile.amd64-generic} (50%) create mode 100644 scripts/docker/Dockerfile.arm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5ce7fc9..1dd84e9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,9 +32,9 @@ jobs: matrix: include: - platform: linux/amd64 - dockerfile: Dockerfile.generic - tag: nntbn:amd64 - test: generic + dockerfile: Dockerfile.amd64-generic + tag: nntbn:amd64-generic + test: amd64-generic - platform: linux/arm64 dockerfile: Dockerfile.arm-neon @@ -76,14 +76,19 @@ jobs: docker buildx create --name tests --use docker buildx inspect --bootstrap - - name: Build and Run Test + - name: Build images run: | + docker images docker buildx build --platform ${{ matrix.platform }} -f scripts/docker/${{ matrix.dockerfile }} -t ${{ matrix.tag }} . --load + docker images + + - name: Test + run: | if [ "${{ matrix.test }}" == "arm-neon" ]; then TESTS=arch/arm/neon/dot_product_perf,arch/arm/neon/neuron,arch/arm/neon/neuron_perf elif [ "${{ matrix.test }}" == "arm-cmsis-dsp" ]; then TESTS=arch/arm/cmsis-dsp/dot_product_perf,arch/arm/cmsis-dsp/neuron,arch/arm/cmsis-dsp/neuron_perf - elif [ "${{ matrix.test }}" == "generic" ]; then + elif [ "${{ matrix.test }}" == "amd64-generic" ]; then TESTS=arch/generic/dot_product,arch/generic/dot_product_perf,arch/generic/layer,arch/generic/layer_multi,arch/generic/neuron,arch/generic/neuron_perf else echo "unknown test" diff --git a/Makefile b/Makefile index fc18a09..2a5f7ab 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,7 @@ clean: test: @$(MAKE) build-tests ARCH=$(ARCH) TECH=$(TECH) @echo " " + @$(eval TECH_FILTER := $(if $(TECH),$(shell echo $(TECH) | tr ',' '|'),.*)) @$(eval TESTS := $(shell find tests/arch/$(ARCH) -type f -name 'main.c' | grep -E "$(TECH_FILTER)" | sed 's|/main.c||' | sed 's|tests/||')) @for test in $(TESTS); do \ $(MAKE) run-test ARCH=$(ARCH) TECH=$(TECH) TEST=$$test || exit 1; \ diff --git a/scripts/docker/Dockerfile.amd64 b/scripts/docker/Dockerfile.amd64 new file mode 100644 index 0000000..63a1802 --- /dev/null +++ b/scripts/docker/Dockerfile.amd64 @@ -0,0 +1,16 @@ +# Example usage: +# Build: +# docker buildx build --platform linux/amd64 -f scripts/docker/Dockerfile.amd64 -t nntbn:amd64 . --load +# Run: +# docker run --rm -it --platform linux/amd64 nntbn:amd64 make test ARCH=generic LDFLAGS="-lm" + +FROM ubuntu:latest +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + clang \ + lld +COPY . /nn +WORKDIR /nn + +ENTRYPOINT [] +CMD ["/bin/bash"] diff --git a/scripts/docker/Dockerfile.generic b/scripts/docker/Dockerfile.amd64-generic similarity index 50% rename from scripts/docker/Dockerfile.generic rename to scripts/docker/Dockerfile.amd64-generic index 72d5b06..c114445 100644 --- a/scripts/docker/Dockerfile.generic +++ b/scripts/docker/Dockerfile.amd64-generic @@ -1,9 +1,8 @@ # Example usage: # Build: -# docker buildx build --platform linux/arm64 -f scripts/docker/Dockerfile.generic -t nntbn:generic . --load +# docker buildx build --platform linux/amd64 -f scripts/docker/Dockerfile.amd64-generic -t nntbn:amd64-generic . --load # Run: -# docker run --rm -it --platform linux/arm64 nntbn:generic /nn/build/tests/arch/generic/neuron -# docker run --rm -it --platform linux/arm64 nntbn:generic /nn/build/examples/arch/generic/dot_product +# docker run --rm -it --platform linux/amd64 nntbn:amd64-generic /nn/build/tests/arch/generic/neuron # Build FROM ubuntu:latest as build @@ -13,7 +12,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ lld COPY . /nn WORKDIR /nn -RUN make build-examples ARCH=generic LDFLAGS="-lm" RUN make build-tests ARCH=generic LDFLAGS="-lm" # Runtime diff --git a/scripts/docker/Dockerfile.arm b/scripts/docker/Dockerfile.arm new file mode 100644 index 0000000..d54aef5 --- /dev/null +++ b/scripts/docker/Dockerfile.arm @@ -0,0 +1,18 @@ +# Example usage: +# Build: +# docker buildx build --platform linux/arm64 -f scripts/docker/Dockerfile.arm -t nntbn:arm . --load +# Run: +# docker run --rm -it --platform linux/arm64 nntbn:arm make test ARCH=arm TECH=cmsis-dsp LDFLAGS="-lm" + +FROM ubuntu:latest +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + clang \ + lld \ + gcc-arm-none-eabi \ + libnewlib-arm-none-eabi +COPY . /nn +WORKDIR /nn + +ENTRYPOINT [] +CMD ["/bin/bash"] diff --git a/scripts/docker/Dockerfile.arm-cmsis-dsp b/scripts/docker/Dockerfile.arm-cmsis-dsp index 5d49827..d30145c 100644 --- a/scripts/docker/Dockerfile.arm-cmsis-dsp +++ b/scripts/docker/Dockerfile.arm-cmsis-dsp @@ -3,7 +3,6 @@ # docker buildx build --platform linux/arm64 -f scripts/docker/Dockerfile.arm-cmsis-dsp -t nntbn:arm-cmsis-dsp . --load # Run: # docker run --rm -it --platform linux/arm64 nntbn:arm-cmsis-dsp /nn/build/tests/arch/arm/cmsis-dsp/neuron -# docker run --rm -it --platform linux/arm64 nntbn:arm-cmsis-dsp /nn/build/examples/arch/arm/cmsis-dsp/dot_product # Build FROM ubuntu:latest as build @@ -16,7 +15,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libnewlib-arm-none-eabi COPY . /nn WORKDIR /nn -RUN make build-examples ARCH=arm TECH=cmsis-dsp LDFLAGS="-lm" RUN make build-tests ARCH=arm TECH=cmsis-dsp LDFLAGS="-lm" # Runtime diff --git a/scripts/docker/Dockerfile.arm-neon b/scripts/docker/Dockerfile.arm-neon index f94f089..d6449be 100644 --- a/scripts/docker/Dockerfile.arm-neon +++ b/scripts/docker/Dockerfile.arm-neon @@ -3,7 +3,6 @@ # docker buildx build --platform linux/arm64 -f scripts/docker/Dockerfile.arm-neon -t nntbn:arm-neon . --load # Run: # docker run --rm -it --platform linux/arm64 nntbn:arm-neon /nn/build/tests/arch/arm/neon/neuron -# docker run --rm -it --platform linux/arm64 nntbn:arm-neon /nn/build/examples/arch/arm/neon/dot_product # Build FROM ubuntu:latest as build @@ -16,7 +15,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libnewlib-arm-none-eabi COPY . /nn WORKDIR /nn -RUN make build-examples ARCH=arm TECH=neon LDFLAGS="-lm" RUN make build-tests ARCH=arm TECH=neon LDFLAGS="-lm" # Runtime diff --git a/scripts/docker/Dockerfile.armv7-neon b/scripts/docker/Dockerfile.armv7-neon index 731a9b1..04da36d 100644 --- a/scripts/docker/Dockerfile.armv7-neon +++ b/scripts/docker/Dockerfile.armv7-neon @@ -3,7 +3,6 @@ # docker buildx build --platform linux/arm/v7 -f scripts/docker/Dockerfile.armv7-neon -t nntbn:armv7-neon . --load # Run: # docker run --rm -it --platform linux/arm/v7 nntbn:armv7-neon /nn/build/tests/arch/arm/neon/neuron -# docker run --rm -it --platform linux/arm/v7 nntbn:armv7-neon /nn/build/examples/arch/arm/neon/dot_product # Build FROM arm32v7/ubuntu:latest as build @@ -16,7 +15,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libnewlib-arm-none-eabi COPY . /nn WORKDIR /nn -RUN make build-examples ARCH=arm TECH=neon LDFLAGS="-lm" CFLAGS="-mfpu=neon-vfpv4" RUN make build-tests ARCH=arm TECH=neon LDFLAGS="-lm" CFLAGS="-mfpu=neon-vfpv4" # Runtime diff --git a/scripts/docker/Dockerfile.armv8-neon b/scripts/docker/Dockerfile.armv8-neon index 8b9c309..17749bb 100644 --- a/scripts/docker/Dockerfile.armv8-neon +++ b/scripts/docker/Dockerfile.armv8-neon @@ -3,7 +3,6 @@ # docker buildx build --platform linux/arm/v8 -f scripts/docker/Dockerfile.armv8-neon -t nntbn:armv8-neon . --load # Run: # docker run --rm -it --platform linux/arm/v8 nntbn:armv8-neon /nn/build/tests/arch/arm/neon/neuron -# docker run --rm -it --platform linux/arm/v8 nntbn:armv8-neon /nn/build/examples/arch/arm/neon/dot_product # Build FROM arm64v8/ubuntu:latest as build @@ -16,7 +15,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libnewlib-arm-none-eabi COPY . /nn WORKDIR /nn -RUN make build-examples ARCH=arm TECH=neon LDFLAGS="-lm" RUN make build-tests ARCH=arm TECH=neon LDFLAGS="-lm" # Runtime