From f8eb8b8d5270502b22bf5e1fa0aa1ed1cf0b3d2c Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 25 Sep 2024 10:20:55 +0200 Subject: [PATCH] Add rvb package --- overlay.nix | 3 ++ pkgs/rvb/Makefile | 79 +++++++++++++++++++++++++++++++++++++++++ pkgs/rvb/Makefile.in | 83 ++++++++++++++++++++++++++++++++++++++++++++ pkgs/rvb/default.nix | 35 +++++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 pkgs/rvb/Makefile create mode 100644 pkgs/rvb/Makefile.in create mode 100644 pkgs/rvb/default.nix diff --git a/overlay.nix b/overlay.nix index b7e9cc6..1c8c788 100644 --- a/overlay.nix +++ b/overlay.nix @@ -7,6 +7,9 @@ final: prev: clangEpiUnwrapped = final.callPackage ./pkgs/llvm-epi/clang.nix { }; stdenvClangEpi = final.stdenv.override { cc = final.buildPackages.clangEpi; allowedRequisites = null; }; + rvb = final.callPackage ./pkgs/rvb/default.nix { }; + rvb-clang = final.callPackage ./pkgs/rvb/default.nix { stdenv = final.stdenvClangEpi; }; + blis = ((prev.blis.override { blas64 = true; withArchitecture = "generic"; diff --git a/pkgs/rvb/Makefile b/pkgs/rvb/Makefile new file mode 100644 index 0000000..39a3524 --- /dev/null +++ b/pkgs/rvb/Makefile @@ -0,0 +1,79 @@ +include Makefile.in + +HPC_BENCHMARKS_DIRS=\ + axpy \ + jacobi-2d \ + somier \ +# Require submodules: +# fft \ +# fftp \ +# Require vehave: +# lulesh \ +# Missing compare_array_double: +# gemm \ +# Broken, not found: +# spmv + +DESKTOP_BENCHMARKS_DIRS=\ + blackscholes \ + canneal \ + particlefilter \ + streamcluster \ + swaptions + #pathfinder + +MICRO_BENCHMARKS_DIRS= + #BuffCopyUnit \ + #BuffCopyStrided \ + #BuffCopyIndexed \ + #FpuMicroKernel \ + #InstrNopBalance \ + #MemArithBalance \ + #LatencyVrgather + +.PHONY: default all clean $(HPC_BENCHMARKS_DIRS) $(MICRO_BENCHMARKS_DIRS) + +all: base + +default: + @cd common; make; cd .. + @$(foreach dir,$(HPC_BENCHMARKS_DIRS),${MAKE} -C hpc_benchmarks/$(dir);) + @$(foreach dir,$(DESKTOP_BENCHMARKS_DIRS),${MAKE} -C desktop_benchmarks/$(dir);) + @$(foreach dir,$(MICRO_BENCHMARKS_DIRS),${MAKE} -C micro_benchmarks/$(dir);) + +all-types: + @cd common; make all; cd .. + @$(foreach dir,$(HPC_BENCHMARKS_DIRS),${MAKE} -C hpc_benchmarks/$(dir) all ;) + @$(foreach dir,$(DESKTOP_BENCHMARKS_DIRS),${MAKE} -C desktop_benchmarks/$(dir) all ;) + @$(foreach dir,$(MICRO_BENCHMARKS_DIRS),${MAKE} -C micro_benchmarks/$(dir) all ;) + +base: + @cd common; make all; cd .. + @$(foreach dir,$(HPC_BENCHMARKS_DIRS),${MAKE} -C hpc_benchmarks/$(dir) base ;) + @$(foreach dir,$(DESKTOP_BENCHMARKS_DIRS),${MAKE} -C desktop_benchmarks/$(dir) base ;) + @$(foreach dir,$(MICRO_BENCHMARKS_DIRS),${MAKE} -C micro_benchmarks/$(dir) base ;) + +install: + @$(foreach dir,$(HPC_BENCHMARKS_DIRS),${MAKE} -C hpc_benchmarks/$(dir) install ;) + @$(foreach dir,$(DESKTOP_BENCHMARKS_DIRS),${MAKE} -C desktop_benchmarks/$(dir) install ;) + @$(foreach dir,$(MICRO_BENCHMARKS_DIRS),${MAKE} -C micro_benchmarks/$(dir) install ;) + +fftp: + ${MAKE} -C third_party fftw + ${MAKE} -C hpc_benchmarks/fftp all + ${MAKE} -C hpc_benchmarks/fftp/test all + +spmv-ellpack: + rm -rf hpc_benchmarks/spmv-ellpack/spmv/build + mkdir -p hpc_benchmarks/spmv-ellpack/spmv/build + cd hpc_benchmarks/spmv-ellpack/spmv/build;\ + ../configure riscv;\ + INDEX64=1 EPI_EXT=07 PATH=${EPI_LLVM_HOME}/bin:${PATH} make + +clean: + @cd common; make clean; cd .. + @$(foreach dir,$(HPC_BENCHMARKS_DIRS),${MAKE} -C hpc_benchmarks/$(dir) clean ;) + @$(foreach dir,$(DESKTOP_BENCHMARKS_DIRS),${MAKE} -C desktop_benchmarks/$(dir) clean ;) + @$(foreach dir,$(MICRO_BENCHMARKS_DIRS),${MAKE} -C micro_benchmarks/$(dir) clean ;) + @rm -rf hpc_benchmarks/spmv-ellpack/spmv/build + diff --git a/pkgs/rvb/Makefile.in b/pkgs/rvb/Makefile.in new file mode 100644 index 0000000..8c8b4dc --- /dev/null +++ b/pkgs/rvb/Makefile.in @@ -0,0 +1,83 @@ +#Compile all benchmarks with individual settings defined in their Makefiles + +_default-target: default + +# RVB_ROOT defined as argument + +# TODO: RVB_COMMON_DIR should substitute COMMON_DIR +COMMON_DIR=$(RVB_ROOT)/common +RVB_COMMON_DIR=$(RVB_ROOT)/common + +#CC=clang +#CXX=clang++ + +# Needs EPI clang +#MEPI=-mepi +MEPI= + +#VREPORT_FLAGS=-Rpass=loop-vectorize -Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize +#Available CFLAGS conditional compilation: +# -DUSE_MALLOC_HP, redefines the use of malloc and free + +#Makefile: General compiler flags: CFLAGS, CFLAGS_, CFLAGS_, ... +#CFLAGS=-B ${LLVM_BIN} -Wall -Wextra -march=rv64g -O2 -I${RVB_COMMON_DIR} +CFLAGS=-B ${LLVM_BIN} -Wall -Wextra -O2 -I${RVB_COMMON_DIR} +LDFLAGS= + +#Only scalar instructions +CFLAGS_SCALAR=${CFLAGS} -DRVB_USE_SCALAR +LDFLAGS_SCALAR= + +#NOVEC=-fno-vectorize +NOVEC= + +#Vector instructions using intrinsics +CFLAGS_VECTORIAL=${CFLAGS} ${NOVEC} $(MEPI) +LDFLAGS_VECTORIAL= + +# TODO: RVV should substitute VECTORIAL (?) +#Vector instructions using intrinsics +CFLAGS_RVV=${CFLAGS} -DRVB_USE_RVV ${NOVEC} $(MEPI) +LDFLAGS_RVV=${LDFLAGS} + +#Vector instructions only when code is annotate +CFLAGS_EXPLICIT_AUTOVECTORIZATION=${CFLAGS} -fopenmp-simd ${NOVEC} $(MEPI) ${VREPORT_FLAGS} +LDFLAGS_EXPLICIT_AUTOVECTORIZATION= + +# TODO: OMP substitutes EXPLICIT_AUTOVECTORIZATION +#Vector instructions only when code is annotate +CFLAGS_OMP=${CFLAGS} -DRVB_USE_OMP -fopenmp-simd $(MEPI) ${VREPORT_FLAGS} +LDFLAGS_OMP=${LDFLAGS} + +#Vector instructions when compiler decides +CFLAGS_AUTOVECTORIZATION=${CFLAGS} -fopenmp-simd $(MEPI) ${VREPORT_FLAGS} +LDFLAGS_AUTOVECTORIZATION= + +# TODO: AUTOVECT shoud substitue AUTOVECTORIZATION (?) +#Vector instructions when compiler decides +CFLAGS_AUTOVECT=${CFLAGS} -DRVB_USE_AUTOVECT -fopenmp-simd $(MEPI) ${VREPORT_FLAGS} +LDFLAGS_AUTOVECT=${LDFLAGS} + +# CBLAS library compile and link flags +CFLAGS_CBLAS=${CFLAGS} -DRVB_USE_CBLAS -I${CBLAS_INC} -I${LLVM_INC} +LDFLAGS_CBLAS=${LDFLAGS} -L${CBLAS_LIB} -lblis -Wl,-rpath,${CBLAS_LIB} -fopenmp + +# BARE-METAL compile and link flags +# You may consider to disable OpenPiton Stream: -DDISABLE_OPSTREAM +CFLAGS_BMETAL=${CFLAGS} -DRVB_USE_BMETAL -B ${RVB_BMETAL_DIR} \ + --target=riscv64-unknown-elf \ + -I../ \ + -I/apps/riscv/llvm/EPI-0.7/cross/development/riscv64-unknown-linux-gnu/sysroot/usr/include \ + -I/usr/include/riscv64-linux-gnu \ + -I/usr/include \ + -I${RVB_BMETAL_DIR}/env \ + -I${RVB_BMETAL_DIR} \ + -DPREALLOCATE=1 -mcmodel=medany \ + -static -std=gnu99 \ + -ffast-math \ + -fno-common \ + -fno-builtin-printf \ + ${RVB_BMETAL_DIR}/syscalls.c \ + ${RVB_BMETAL_DIR}/crt.S \ + -static -nostdlib -T \ + ${RVB_BMETAL_DIR}/test.ld diff --git a/pkgs/rvb/default.nix b/pkgs/rvb/default.nix new file mode 100644 index 0000000..bf93628 --- /dev/null +++ b/pkgs/rvb/default.nix @@ -0,0 +1,35 @@ +{ + stdenv +, blis +, gitBranch ? "nix-fixes" +, gitURL ? "git@gitlab-internal.bsc.es:rarias/risc-v-benchmarks.git" +, gitCommit ? "da202d6f818421b72e06c39b5417ad2f8f6ca23c" +}: + +stdenv.mkDerivation rec { + pname = "rvb"; + version = "${src.shortRev}"; + + src = builtins.fetchGit { + url = gitURL; + ref = gitBranch; + rev = gitCommit; + submodules = true; + }; + + buildInputs = [ blis ]; + configurePhase = '' + export RVB_ROOT=$(readlink -f .) + export CBLAS_HOME=${blis} + export CBLAS_INC=${blis}/include/blis + export CBLAS_LIB=${blis}/lib + rm Makefile.in + ln -s ${./Makefile.in} Makefile.in + rm Makefile + ln -s ${./Makefile} Makefile + ''; + enableParallelBuilding = false; + hardeningDisable = [ "all" ]; + installFlags = [ "DESTDIR=$(out)" ]; + dontStrip = true; +}