diff --git a/README.md b/README.md index f72f48b92..daed866a1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ [![Build Status](https://travis-ci.com/vortexgpgpu/vortex.svg?branch=master)](https://travis-ci.com/vortexgpgpu/vortex) -[![codecov](https://codecov.io/gh/vortexgpgpu/vortex/branch/master/graph/badge.svg)](https://codecov.io/gh/vortexgpgpu/vortex) # Vortex GPGPU @@ -13,9 +12,9 @@ Vortex is a full-stack open-source RISC-V GPGPU. - configurable number of ALU, FPU, LSU, and SFU units per core. - configurable pipeline issue width. - optional local memory, L1, L2, and L3 caches. -- Software: +- Software: - OpenCL 1.2 Support. -- Supported FPGAs: +- Supported FPGAs: - Altera Arria 10 - Altera Stratix 10 - Xilinx Alveo U50, U250, U280 @@ -47,7 +46,7 @@ More detailed build instructions can be found [here](docs/install_vortex.md). - [Ramulator](https://github.com/CMU-SAFARI/ramulator.git) - [Yosys](https://github.com/YosysHQ/yosys) - [Sv2v](https://github.com/zachjs/sv2v) -### Install development tools +### Install development tools $ sudo apt-get install build-essential $ sudo apt-get install binutils $ sudo apt-get install python @@ -57,10 +56,10 @@ More detailed build instructions can be found [here](docs/install_vortex.md). $ git clone --depth=1 --recursive https://github.com/vortexgpgpu/vortex.git $ cd Vortex ### Configure your build folder - # By default, the toolchain default install location is the /opt folder and can be overridden by setting TOOLDIR. + # By default, the toolchain default install location is the /opt folder and can be overridden by setting --tooldir. $ mkdir build $ cd build - $ TOOLDIR=$HOME/tools ../configure + $ ../configure --xlen=32 --tooldir=$HOME/tools ### Install prebuilt toolchain $ ./ci/toolchain_install.sh --all ### set environment variables @@ -69,4 +68,4 @@ More detailed build instructions can be found [here](docs/install_vortex.md). ### Building Vortex $ make -s ### Quick demo running vecadd OpenCL kernel on 2 cores - $ ./ci/blackbox.sh --cores=2 --app=vecadd \ No newline at end of file + $ ./ci/blackbox.sh --cores=2 --app=vecadd \ No newline at end of file diff --git a/ci/toolchain_install.sh.in b/ci/toolchain_install.sh.in index 000b520f4..935568ff0 100755 --- a/ci/toolchain_install.sh.in +++ b/ci/toolchain_install.sh.in @@ -18,11 +18,11 @@ set -e REPOSITORY=https://github.com/vortexgpgpu/vortex-toolchain-prebuilt/raw/master TOOLDIR=${TOOLDIR:=@TOOLDIR@} -OSDIR=${OSDIR:=@OSDIR@} +OSVERSION=${OSVERSION:=@OSVERSION@} riscv32() { - case $OSDIR in + case $OSVERSION in "centos/7") parts=$(eval echo {a..h}) ;; "ubuntu/focal") parts=$(eval echo {a..k}) ;; *) parts=$(eval echo {a..j}) ;; @@ -30,7 +30,7 @@ riscv32() rm -f riscv32-gnu-toolchain.tar.bz2.parta* for x in $parts do - wget $REPOSITORY/riscv32-gnu-toolchain/$OSDIR/riscv32-gnu-toolchain.tar.bz2.parta$x + wget $REPOSITORY/riscv32-gnu-toolchain/$OSVERSION/riscv32-gnu-toolchain.tar.bz2.parta$x done cat riscv32-gnu-toolchain.tar.bz2.parta* > riscv32-gnu-toolchain.tar.bz2 tar -xvf riscv32-gnu-toolchain.tar.bz2 @@ -40,14 +40,14 @@ riscv32() riscv64() { - case $OSDIR in + case $OSVERSION in "centos/7") parts=$(eval echo {a..h}) ;; *) parts=$(eval echo {a..j}) ;; esac rm -f riscv64-gnu-toolchain.tar.bz2.parta* for x in $parts do - wget $REPOSITORY/riscv64-gnu-toolchain/$OSDIR/riscv64-gnu-toolchain.tar.bz2.parta$x + wget $REPOSITORY/riscv64-gnu-toolchain/$OSVERSION/riscv64-gnu-toolchain.tar.bz2.parta$x done cat riscv64-gnu-toolchain.tar.bz2.parta* > riscv64-gnu-toolchain.tar.bz2 tar -xvf riscv64-gnu-toolchain.tar.bz2 @@ -57,7 +57,7 @@ riscv64() llvm() { - case $OSDIR in + case $OSVERSION in "centos/7") parts=$(eval echo {a..b}) ;; *) parts=$(eval echo {a..b}) ;; esac @@ -65,7 +65,7 @@ llvm() rm -f llvm-vortex2.tar.bz2.parta* for x in $parts do - wget $REPOSITORY/llvm-vortex/$OSDIR/llvm-vortex2.tar.bz2.parta$x + wget $REPOSITORY/llvm-vortex/$OSVERSION/llvm-vortex2.tar.bz2.parta$x done cat llvm-vortex2.tar.bz2.parta* > llvm-vortex2.tar.bz2 tar -xvf llvm-vortex2.tar.bz2 @@ -107,7 +107,7 @@ libc64() pocl() { - wget $REPOSITORY/pocl/$OSDIR/pocl2.tar.bz2 + wget $REPOSITORY/pocl/$OSVERSION/pocl2.tar.bz2 tar -xvf pocl2.tar.bz2 mkdir -p $TOOLDIR && rm -rf $TOOLDIR/pocl && mv pocl $TOOLDIR rm -rf pocl2 pocl2.tar.bz2 @@ -115,7 +115,7 @@ pocl() verilator() { - wget $REPOSITORY/verilator/$OSDIR/verilator.tar.bz2 + wget $REPOSITORY/verilator/$OSVERSION/verilator.tar.bz2 tar -xvf verilator.tar.bz2 mkdir -p $TOOLDIR && rm -rf $TOOLDIR/verilator && mv verilator $TOOLDIR rm -rf verilator verilator.tar.bz2 @@ -123,7 +123,7 @@ verilator() sv2v() { - wget $REPOSITORY/sv2v/$OSDIR/sv2v.tar.bz2 + wget $REPOSITORY/sv2v/$OSVERSION/sv2v.tar.bz2 tar -xvf sv2v.tar.bz2 mkdir -p $TOOLDIR && rm -rf $TOOLDIR/sv2v && mv sv2v $TOOLDIR rm -rf sv2v sv2v.tar.bz2 @@ -131,7 +131,7 @@ sv2v() yosys() { - case $OSDIR in + case $OSVERSION in "centos/7") parts=$(eval echo {a..c}) ;; *) parts=$(eval echo {a..c}) ;; esac @@ -139,7 +139,7 @@ yosys() rm -f yosys.tar.bz2.parta* for x in $parts do - wget $REPOSITORY/yosys/$OSDIR/yosys.tar.bz2.parta$x + wget $REPOSITORY/yosys/$OSVERSION/yosys.tar.bz2.parta$x done cat yosys.tar.bz2.parta* > yosys.tar.bz2 tar -xvf yosys.tar.bz2 diff --git a/ci/toolchain_prebuilt.sh.in b/ci/toolchain_prebuilt.sh.in index f67cc0a1f..ba3617d6f 100755 --- a/ci/toolchain_prebuilt.sh.in +++ b/ci/toolchain_prebuilt.sh.in @@ -17,15 +17,15 @@ set -e TOOLDIR=${TOOLDIR:=@TOOLDIR@} -OSDIR=${OSDIR:=@OSDIR@} +OSVERSION=${OSVERSION:=@OSVERSION@} riscv32() { echo "prebuilt riscv32-gnu-toolchain..." tar -C $TOOLDIR -cvjf riscv32-gnu-toolchain.tar.bz2 riscv32-gnu-toolchain split -b 50M riscv32-gnu-toolchain.tar.bz2 "riscv32-gnu-toolchain.tar.bz2.part" - mkdir -p ./riscv32-gnu-toolchain/$OSDIR - mv riscv32-gnu-toolchain.tar.bz2.part* ./riscv32-gnu-toolchain/$OSDIR + mkdir -p ./riscv32-gnu-toolchain/$OSVERSION + mv riscv32-gnu-toolchain.tar.bz2.part* ./riscv32-gnu-toolchain/$OSVERSION rm riscv32-gnu-toolchain.tar.bz2 } @@ -34,8 +34,8 @@ riscv64() echo "prebuilt riscv64-gnu-toolchain..." tar -C $TOOLDIR -cvjf riscv64-gnu-toolchain.tar.bz2 riscv64-gnu-toolchain split -b 50M riscv64-gnu-toolchain.tar.bz2 "riscv64-gnu-toolchain.tar.bz2.part" - mkdir -p ./riscv64-gnu-toolchain/$OSDIR - mv riscv64-gnu-toolchain.tar.bz2.part* ./riscv64-gnu-toolchain/$OSDIR + mkdir -p ./riscv64-gnu-toolchain/$OSVERSION + mv riscv64-gnu-toolchain.tar.bz2.part* ./riscv64-gnu-toolchain/$OSVERSION rm riscv64-gnu-toolchain.tar.bz2 } @@ -44,8 +44,8 @@ llvm() echo "prebuilt llvm-vortex2..." tar -C $TOOLDIR -cvjf llvm-vortex2.tar.bz2 llvm-vortex split -b 50M llvm-vortex2.tar.bz2 "llvm-vortex2.tar.bz2.part" - mkdir -p ./llvm-vortex/$OSDIR - mv llvm-vortex2.tar.bz2.part* ./llvm-vortex/$OSDIR + mkdir -p ./llvm-vortex/$OSVERSION + mv llvm-vortex2.tar.bz2.part* ./llvm-vortex/$OSVERSION rm llvm-vortex2.tar.bz2 } @@ -85,24 +85,24 @@ pocl() { echo "prebuilt pocl..." tar -C $TOOLDIR -cvjf pocl2.tar.bz2 pocl - mkdir -p ./pocl/$OSDIR - mv pocl2.tar.bz2 ./pocl/$OSDIR + mkdir -p ./pocl/$OSVERSION + mv pocl2.tar.bz2 ./pocl/$OSVERSION } verilator() { echo "prebuilt verilator..." tar -C $TOOLDIR -cvjf verilator.tar.bz2 verilator - mkdir -p ./verilator/$OSDIR - mv verilator.tar.bz2 ./verilator/$OSDIR + mkdir -p ./verilator/$OSVERSION + mv verilator.tar.bz2 ./verilator/$OSVERSION } sv2v() { echo "prebuilt sv2v..." tar -C $TOOLDIR -cvjf sv2v.tar.bz2 sv2v - mkdir -p ./sv2v/$OSDIR - mv sv2v.tar.bz2 ./sv2v/$OSDIR + mkdir -p ./sv2v/$OSVERSION + mv sv2v.tar.bz2 ./sv2v/$OSVERSION } yosys() @@ -110,8 +110,8 @@ yosys() echo "prebuilt yosys..." tar -C $TOOLDIR -cvjf yosys.tar.bz2 yosys split -b 50M yosys.tar.bz2 "yosys.tar.bz2.part" - mkdir -p ./yosys/$OSDIR - mv yosys.tar.bz2.part* ./yosys/$OSDIR + mkdir -p ./yosys/$OSVERSION + mv yosys.tar.bz2.part* ./yosys/$OSVERSION rm yosys.tar.bz2 } diff --git a/config.mk.in b/config.mk.in index 270e46e2a..50fd7a523 100644 --- a/config.mk.in +++ b/config.mk.in @@ -17,6 +17,8 @@ XLEN ?= @XLEN@ TOOLDIR ?= @TOOLDIR@ +OSVERSION ?= @OSVERSION@ + LLVM_VORTEX ?= $(TOOLDIR)/llvm-vortex LIBC_VORTEX ?= $(TOOLDIR)/libc$(XLEN) diff --git a/configure b/configure index f464b6034..7afaacae6 100755 --- a/configure +++ b/configure @@ -1,12 +1,12 @@ #!/bin/bash # Copyright © 2019-2023 -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -14,27 +14,27 @@ # limitations under the License. # Function to detect current OS -detect_os() { - local osdir="unsupported" +detect_osversion() { + local osversion="unsupported" if [ -f /etc/os-release ]; then . /etc/os-release # Source the os-release file to get OS information case "$ID" in ubuntu) case "$VERSION_CODENAME" in - bionic) osdir="ubuntu/bionic";; - focal) osdir="ubuntu/focal";; + bionic) osversion="ubuntu/bionic";; + focal) osversion="ubuntu/focal";; # Add new versions as needed esac ;; centos) case "$VERSION_ID" in - 7) osdir="centos/7";; + 7) osversion="centos/7";; # Add new versions as needed esac ;; esac fi - echo "$osdir" + echo "$osversion" } # Function to recursively copy files, skipping the current directory @@ -46,21 +46,21 @@ copy_files() { local same_dir=0 if [ "$(realpath "$source_dir")" == "$(realpath "$target_dir")" ]; then same_dir=1 - fi - + fi + # Function to copy and update file copy_and_update() { local src_pattern="$1" local dest_dir="$2" for file in $src_pattern; do #echo "*** $file > $dest_dir" - if [ -f "$file" ]; then + if [ -f "$file" ]; then if [[ "$file" == *.in ]]; then filename=$(basename -- "$file") filename_no_ext="${filename%.in}" dest_file="$dest_dir/$filename_no_ext" mkdir -p "$dest_dir" - sed "s|@VORTEX_HOME@|$SCRIPT_DIR|g; s|@XLEN@|$XLEN|g; s|@TOOLDIR@|$TOOLDIR|g; s|@OSDIR@|$OSDIR|g" "$file" > "$dest_file" + sed "s|@VORTEX_HOME@|$SCRIPT_DIR|g; s|@XLEN@|$XLEN|g; s|@TOOLDIR@|$TOOLDIR|g; s|@OSVERSION@|$OSVERSION|g" "$file" > "$dest_file" # apply permissions to bash scripts read -r firstline < "$dest_file" if [[ "$firstline" =~ ^#!.*bash ]]; then @@ -75,7 +75,7 @@ copy_files() { fi done } - + for pattern in "${SUBDIRS[@]}"; do local full_copy=0 if [[ "$pattern" == !* ]]; then @@ -106,13 +106,49 @@ copy_files() { ############################################################################### -# options -XLEN=${XLEN:=32} -TOOLDIR=${TOOLDIR:=/opt} -OSDIR=${OSDIR:=$(detect_os)} +# default configuration parameters +default_xlen=32 +default_tooldir=/opt +default_osversion=$(detect_osversion) + +# load default configuration parameters from existing config.mk +if [ -f "config.mk" ]; then + while IFS='=' read -r key value; do + value=${value//[@]/} # Remove placeholder characters + case $key in + XLEN\ ?*) default_xlen=${value//\?=/} ;; + TOOLDIR\ ?*) default_tooldir=${value//\?=/} ;; + OSVERSION\ ?*) default_osversion=${value//\?=/} ;; + esac + done < config.mk +fi + +# set configuration parameters +XLEN=${XLEN:=$default_xlen} +TOOLDIR=${TOOLDIR:=$default_tooldir} +OSVERSION=${OSVERSION:=$default_osversion} + +# parse command line arguments +usage() { + echo "Usage: $0 [--xlen=] [--tooldir=] [--osversion=]" + echo " --xlen= Set the XLEN value (default: 32)" + echo " --tooldir= Set the TOOLDIR path (default: /opt)" + echo " --osversion= Set the OS Version (default: $(detect_os))" + exit 1 +} +while [[ "$#" -gt 0 ]]; do + case $1 in + --xlen=*) XLEN="${1#*=}" ;; + --tooldir=*) TOOLDIR="${1#*=}" ;; + --osversion=*) OSVERSION="${1#*=}" ;; + -h|--help) usage ;; + *) echo "Unknown parameter passed: $1"; usage ;; + esac + shift +done # check OS -if [ "$OSDIR" == "unsupported" ]; then +if [ "$OSVERSION" == "unsupported" ]; then echo "Error: Unsupported OS." exit -1 fi diff --git a/docs/install_vortex.md b/docs/install_vortex.md index 30cd6c707..130240caa 100644 --- a/docs/install_vortex.md +++ b/docs/install_vortex.md @@ -13,9 +13,9 @@ ``` sudo apt-get install gcc-11 g++-11 ``` - + Multiple gcc versions on Ubuntu can be managed with update-alternatives, e.g.: - + ``` sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9 @@ -34,7 +34,7 @@ $ cd vortex $ mkdir -p build $ cd build - $ TOOLDIR=$HOME/tools ../configure + $ ../configure --xlen=32 --tooldir=$HOME/tools $ ./ci/toolchain_install.sh --all $ source ./ci/toolchain_env.sh $ make -s @@ -55,7 +55,7 @@ Note: depending on the system, some of the toolchain may need to be recompiled f ``` sudo yum install gcc-toolset-11 ``` - + Multiple gcc versions on Red Hat can be managed with scl 3. Install MPFR 4.2.0: @@ -74,7 +74,7 @@ Note: depending on the system, some of the toolchain may need to be recompiled f $ cd vortex $ mkdir -p build $ cd build - $ TOOLDIR=$HOME/tools ../configure + $ ../configure --xlen=32 --tooldir=$HOME/tools $ ./ci/toolchain_install.sh --all $ source ./ci/toolchain_env.sh $ make -s