Add rvb package

This commit is contained in:
Rodrigo Arias 2024-09-25 10:20:55 +02:00
parent 8047a6a4eb
commit f8eb8b8d52
4 changed files with 200 additions and 0 deletions

View File

@ -7,6 +7,9 @@ final: prev:
clangEpiUnwrapped = final.callPackage ./pkgs/llvm-epi/clang.nix { }; clangEpiUnwrapped = final.callPackage ./pkgs/llvm-epi/clang.nix { };
stdenvClangEpi = final.stdenv.override { cc = final.buildPackages.clangEpi; allowedRequisites = null; }; 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 { blis = ((prev.blis.override {
blas64 = true; blas64 = true;
withArchitecture = "generic"; withArchitecture = "generic";

79
pkgs/rvb/Makefile Normal file
View File

@ -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

83
pkgs/rvb/Makefile.in Normal file
View File

@ -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_<VERSION_1>, CFLAGS_<VERSION_2>, ...
#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

35
pkgs/rvb/default.nix Normal file
View File

@ -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;
}