Skip to content

Commit

Permalink
updated configure script usage
Browse files Browse the repository at this point in the history
  • Loading branch information
tinebp committed May 13, 2024
1 parent 0fbe22d commit 15ca829
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 57 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
$ ./ci/blackbox.sh --cores=2 --app=vecadd
24 changes: 12 additions & 12 deletions ci/toolchain_install.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ 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}) ;;
esac
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
Expand All @@ -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
Expand All @@ -57,15 +57,15 @@ riscv64()

llvm()
{
case $OSDIR in
case $OSVERSION in
"centos/7") parts=$(eval echo {a..b}) ;;
*) parts=$(eval echo {a..b}) ;;
esac
echo $parts
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
Expand Down Expand Up @@ -107,39 +107,39 @@ 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
}

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
}

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
}

yosys()
{
case $OSDIR in
case $OSVERSION in
"centos/7") parts=$(eval echo {a..c}) ;;
*) parts=$(eval echo {a..c}) ;;
esac
echo $parts
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
Expand Down
30 changes: 15 additions & 15 deletions ci/toolchain_prebuilt.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -85,33 +85,33 @@ 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()
{
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
}

Expand Down
2 changes: 2 additions & 0 deletions config.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ XLEN ?= @XLEN@

TOOLDIR ?= @TOOLDIR@

OSVERSION ?= @OSVERSION@

LLVM_VORTEX ?= $(TOOLDIR)/llvm-vortex

LIBC_VORTEX ?= $(TOOLDIR)/libc$(XLEN)
Expand Down
72 changes: 54 additions & 18 deletions configure
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
#!/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.
# See the License for the specific language governing permissions and
# 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
Expand All @@ -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
Expand All @@ -75,7 +75,7 @@ copy_files() {
fi
done
}

for pattern in "${SUBDIRS[@]}"; do
local full_copy=0
if [[ "$pattern" == !* ]]; then
Expand Down Expand Up @@ -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=<value>] [--tooldir=<path>] [--osversion=<version>]"
echo " --xlen=<value> Set the XLEN value (default: 32)"
echo " --tooldir=<path> Set the TOOLDIR path (default: /opt)"
echo " --osversion=<version> 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
Expand Down
Loading

0 comments on commit 15ca829

Please sign in to comment.