Skip to content

Commit

Permalink
Merge pull request #7 from HSAFoundation/CLOC-0.9-ReleaseCandidate
Browse files Browse the repository at this point in the history
Cloc 0.9 release candidate - Compatible with 1.0F Runtime/Drivers
  • Loading branch information
alienanthill committed May 28, 2015
2 parents c874c02 + d4b7acb commit cf77785
Show file tree
Hide file tree
Showing 89 changed files with 934 additions and 5,800 deletions.
112 changes: 57 additions & 55 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Cloc Install Instructions 1.0P
==============================
Cloc 0.9 Install Instructions
=============================

Warning. These instructions are for HSA 1.0F .

The Cloc utility consists of three bash scripts with file names "cloc.sh" , "snack.sh" , and "snk_genw.sh" . These are found in the bin directory of this repository. Copy these files to a bin directory in your Linux environment PATH such as /usr/local/bin. To update to a new version of Cloc simply replace cloc.sh snack.sh, and snk_genw.sh in that directory.
The Cloc utility consists of three bash scripts with file names "cloc.sh" , "snack.sh" , and "snk_genw.sh" . These are found in the bin directory of this repository. Copy these files to /opt/amd/cloc/bin. To update to a new version of Cloc simply replace cloc.sh snack.sh, and snk_genw.sh in directory /opt/amd/cloc/bin.

In addition to the bash scripts, Cloc requires the HSA runtime and the HLC compiler. This set of instructions can be used to install a comprehensive HSA software stack and the Cloc utility for Ubuntu. In addition to Linux, you must have an HSA compatible system such as a Kaveri processor. There are four major steps to this process:

Expand All @@ -16,15 +18,15 @@ In addition to the bash scripts, Cloc requires the HSA runtime and the HLC compi

## Install Ubuntu 14.04 LTS

Make sure Ubuntu 14.04 LTS 64-bit version has been installed. We recommend the server package set. The utica version of ubuntu (14.10) has not been tested with HSA. Then install these dependencies:
Make sure Ubuntu 14.04 LTS 64-bit version has been installed. Ubunutu 14.04 is also known as trusty. We recommend the server package set. The utica version of ubuntu (14.10) has not been tested with HSA. Then install these dependencies:
```
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git
sudo apt-get install make
sudo apt-get install g++
sudo apt-get install libstdc++-4.8-dev
sudo apt-get install libelf-dev
sudo apt-get install libelf
sudo apt-get install libtinfo-dev
sudo apt-get install re2c
sudo apt-get install libbsd-dev
Expand All @@ -47,16 +49,16 @@ mount the appropriate MLNX_OFED iso

## Install HSA Linux Kernel Drivers

Make sure you get the backlevel <b>kfd-v1.0.x</b> branch. This set of instructions is for the provisional HSA runtime. The software stack for the new <b>finalized v1.0F</b> is not yet complete. We will update these install instructions when that is complete. This should be sometime in June 2015.
These instructions are for HSA1.0F.

Execute these commands:

```
cd ~/git
git clone -b kfd-v1.0.x https://github.com/HSAfoundation/HSA-Drivers-Linux-AMD.git
sudo dpkg -i HSA-Drivers-Linux-AMD/kfd-1.0/ubuntu/*.deb
git clone https://github.com/HSAfoundation/HSA-Drivers-Linux-AMD.git
sudo dpkg -i HSA-Drivers-Linux-AMD/kfd-1.2/ubuntu/*.deb
echo "KERNEL==\"kfd\", MODE=\"0666\"" | sudo tee /etc/udev/rules.d/kfd.rules
sudo cp HSA-Drivers-Linux-AMD/kfd-1.0/libhsakmt/lnx64a/libhsakmt.so.1 /opt/hsa/lib
sudo cp HSA-Drivers-Linux-AMD/kfd-1.2/libhsakmt.so.1 /opt/hsa/lib
```

## Reboot System
Expand Down Expand Up @@ -95,75 +97,75 @@ If it does not detect a valid GPU ID (last two entries are NO), it is possible t
3. Install HSA Software
=======================

## Install HSA Runtime
## Install HSA 1.0F Runtime

```
mkdir ~/git
cd ~/git
git clone -b release-v1.0 https://github.com/HSAfoundation/HSA-Runtime-AMD.git
git clone https://github.com/HSAfoundation/HSA-Runtime-AMD.git
cd HSA-Runtime-AMD/ubuntu
sudo dpkg -i hsa-runtime_1.0_amd64.deb
```

## Install HSAIL Compiler (HLC)

```
cd ~/git
git clone https://github.com/HSAfoundation/HSAIL-HLC-Stable.git
cd HSAIL-HLC-Stable/ubuntu
sudo dpkg -i hsail-hlc-stable_1.0_amd64.deb
```

## Install and Test Cloc utility

As of Cloc version 0.8 the executable shell script names are changed to cloc.sh, snack.sh and snk_genw.sh.
These scripts need to be copied to a directory that is in users PATH. For example /usr/local/bin is typically in PATH.
As of Cloc version 0.9 the cl frontend clc2 and supporting LLVM 3.6 executables are stored in the same directory as the cloc.sh, snack.sh and snk_genw.sh shell scripts. These scripts need to be copied should be copied into /opt/amd/cloc/bin
```
cd ~/git
git clone -b 0.8 https://github.com/HSAfoundation/CLOC.git
sudo cp CLOC/bin/cloc.sh /usr/local/bin/.
sudo cp CLOC/bin/snack.sh /usr/local/bin/.
sudo cp CLOC/bin/snk_genw.sh /usr/local/bin/.
cd
cp -r git/CLOC/examples .
cd examples/snack/helloworld
git clone -b CLOC-0.9 https://github.com/HSAfoundation/CLOC.git
# Install
mkdir -p /opt/amd/cloc
sudo cp -rp ~/git/CLOC/bin /opt/amd/cloc
sudo cp -rp ~/git/CLOC/examples /opt/amd/cloc
sudo ln -sf /opt/amd/cloc/bin/cloc.sh /usr/local/bin/cloc.sh
sudo ln -sf /opt/amd/cloc/bin/snack.sh /usr/local/bin/snack.sh
sudo ln -sf /opt/amd/cloc/bin/printhsail /usr/local/bin/printhsail
# Test
cp -r /opt/amd/cloc/examples ~
cd ~/examples/snack/helloworld
./buildrun.sh
cd ~/examples/hsa/vector_copy
make
make test
```

## Install Kalmar compiler

This was formerly known as C++AMP. This step is optional because it is not needed for Cloc. However this is becoming a very good HSA compiler.
## Set HSA environment variables

As of Cloc version 0.9, HSA_LLVM_PATH is no longer required because cloc.sh and snack.sh expect the binaries to be in the same directory where cloc.sh and snack.sh are stored. For testing other compilers or versions of the HSA LLVM binaries, you may set HSA_LLVM_PATH or use the -p option as noted in the help. The snack.sh script assumes HSA_RUNTIME_PATH is /opt/hsa. However, we recommend using LD_LIBRARY_PATH to find the current version of he HSA runtime as follows:
```
mkdir ~/git/deb
cd ~/git/deb
wget https://bitbucket.org/multicoreware/cppamp-driver-ng/downloads/clamp-0.5.0-hsa-milestone4-Linux.deb
wget https://bitbucket.org/multicoreware/cppamp-driver-ng/downloads/libcxxamp-0.5.0-hsa-milestone4-Linux.deb
wget https://bitbucket.org/multicoreware/cppamp-driver-ng/downloads/clamp-bolt-1.2.0-hsa-milestone4-Linux.deb
wget https://bitbucket.org/multicoreware/cppamp-driver-ng/downloads/boost_1_55_0-hsa-milestone3.deb
sudo dpkg -i *.deb
export HSA_RUNTIME_PATH=/opt/hsa
export LD_LIBRARY_PATH=$HSA_RUNTIME_PATH/lib
```

## Install Okra

This step is also optional. It is not needed for Cloc. However, it is currently needed for the experimental version of gcc that supports OpenMP accelertion in HSA.
We recommend that cloc.sh, snack,sh, and printhsail be available in your path. You can symbolically link them or add to PATH as follows:
```
cd ~/git
git clone https://github.com/HSAfoundation/Okra-Interface-to-HSA-Device
sudo mkdir /opt/amd/okra
sudo cp -r Okra-Interface-to-HSA-Device/okra /opt/amd
sudo cp Okra-Interface-to-HSA-Device/okra/dist/bin/libokra_x86_64.so /opt/hsa/lib/.
#
# Either put /opt/amd/cloc/bin in your PATH as follows
export PATH=$PATH:/opt/amd/cloc/bin
#
# OR symbolic link cloc.sh and snack.sh to system path
sudo ln -sf /opt/amd/cloc/bin/cloc.sh /usr/local/bin/cloc.sh
sudo ln -sf /opt/amd/cloc/bin/snack.sh /usr/local/bin/snack.sh
sudo ln -sf /opt/amd/cloc/bin/printhsail /usr/local/bin/printhsail
```

## Set HSA environment variables
Future package installers (.deb and .rpm) will symbolically link them.

```
export HSA_LLVM_PATH=/opt/amd/bin
export HSA_RUNTIME_PATH=/opt/hsa
export HSA_OKRA_PATH=/opt/amd/okra
export PATH=$PATH:/opt/amd/bin
export LD_LIBRARY_PATH=/opt/hsa/lib
```
## Install Kalmar (C++AMP) HSA Compiler (OPTIONAL)

SKIP THIS STEP TILL KALMAR IS PORTED TO 1.0F

## Install gcc OpenMP for HSA Compiler (OPTIONAL)

SKIP THIS STEP TILL IT IS PORTED TO 1.0F

## Install Codeplay HSA Compiler (OPTIONAL)

SKIP THIS STEP TILL IT IS PORTED TO 1.0F

## Install Pathscale HSA Compiler (OPTIONAL)

SKIP THIS STEP TILL IT IS PORTED TO 1.0F


<A Name="Infiniband">
Expand Down
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CLOC - Version 0.8.0
====================
CLOC - V 0.9.0 (HSA 1.0F)
=========================

CLOC: CL Offline Compiler
Generate HSAIL or brig from a cl (Kernel c Language) file.
Expand Down Expand Up @@ -81,19 +81,23 @@ Software License Agreement.
-t <tdir> Default=/tmp/cloc$$, Temp dir for files
-o <outfilename> Default=<filename>.<ft> ft=brig or hsail
-opt <LLVM opt> Default=2, LLVM optimization level
-p <path> Default=$HSA_LLVM_PATH or /opt/amd/bin
-p <path> $HSA_LLVM_PATH or <cdir> if HSA_LLVM_PATH not set
<cdir> is actual directory of cloc.sh
-clopts <compiler opts> Default="-cl-std=CL2.0"
-lkopts <LLVM link opts> Default="--prelink-opt -l $HSA_LLVM_PATH/builtins-hsail.bc"
-lkopts <LLVM link opts> Default="-prelink-opt \
-l <cdir>/builtins-hsail.bc -l <cdir>/builtins-gcn.bc \
-l <cdir>/builtins-hsail-amd-ci.bc -l <cdir>/builtins-ocml.bc"
Examples:
cloc my.cl /* create my.brig */
cloc -hsail my.cl /* create my.hsail and my.brig */
cloc.sh my.cl /* create my.brig */
cloc.sh -hsail my.cl /* create my.hsail and my.brig */
You may set environment variables LLVMOPT, HSA_LLVM_PATH, CLOPTS, or
LKOPTS instead of providing options -opt -p, -clopts, or -lkopts .
You may set environment variables LLVMOPT, HSA_LLVM_PATH, CLOPTS,
or LKOPTS instead of providing options -opt -p, -clopts, or -lkopts .
Command line options will take precedence over environment variables.
Copyright (c) 2015 ADVANCED MICRO DEVICES, INC.
```


Expand Down Expand Up @@ -126,22 +130,24 @@ Software License Agreement.
-gccopt <gcc opt> Default=2, gcc optimization for snack wrapper
-t <tempdir> Default=/tmp/snk_$$, Temp dir for files
-s <symbolname> Default=filename
-p1 <path> Default=$HSA_LLVM_PATH or /opt/amd/bin
-p2 <path> Default=$HSA_RUNTIME_PATH or /opt/hsa
-p <path> $HSA_LLVM_PATH or <sdir> if HSA_LLVM_PATH not set
<sdir> is actual directory of snack.sh
-rp <HSA RT path> Default=$HSA_RUNTIME_PATH or /opt/hsa
-o <outfilename> Default=<filename>.<ft>
Examples:
snack my.cl /* create my.snackwrap.c and my.h */
snack -c my.cl /* gcc compile to create my.o */
snack -hsail my.cl /* create hsail and snackwrap.c */
snack -c -hsail my.cl /* create hsail snackwrap.c and .o */
snack -t /tmp/foo my.cl /* will automatically set -k */
snack.sh my.cl /* create my.snackwrap.c and my.h */
snack.sh -c my.cl /* gcc compile to create my.o */
snack.sh -hsail my.cl /* create hsail and snackwrap.c */
snack.sh -c -hsail my.cl /* create hsail snackwrap.c and .o */
snack.sh -t /tmp/foo my.cl /* will automatically set -k */
You may set environment variables HSA_LLVM_PATH, HSA_RUNTIME_PATH,
instead of providing options -p1, -p2.
instead of providing options -p, -rp.
Command line options will take precedence over environment variables.
Copyright (c) 2015 ADVANCED MICRO DEVICES, INC.
```

<A NAME="ReadmeExamples">
Expand Down Expand Up @@ -221,7 +227,7 @@ manual updates to HSAIL. This process has two steps.
The first step compiles the .cl file into the object code needed by a SNACK application.
For example, if your kernels are in the file myKernels.cl, then you can run step 1 as follows.
```
snack -c -hsail myKernels.cl
snack.sh -c -hsail myKernels.cl
```
When cloc sees the "-c" option and the "-hsail" option, it will save four files
in the same directory as myKernels.cl file. The first two files are always created
Expand Down
Binary file added bin/Dev
Binary file not shown.
Binary file added bin/HSAILTestGen
Binary file not shown.
Binary file added bin/builtins-gcn.bc
Binary file not shown.
Binary file added bin/builtins-hsail-amd-ci.bc
Binary file not shown.
Binary file added bin/builtins-hsail.bc
Binary file not shown.
Binary file added bin/clang-tblgen
Binary file not shown.
Binary file added bin/clc2
Binary file not shown.
44 changes: 21 additions & 23 deletions bin/cloc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Written by Greg Rodgers Gregory.Rodgers@amd.com
# Maintained by Shreyas Ramalingam Shreyas.Ramalingam@amd.com
#
PROGVERSION=0.8.0
PROGVERSION=0.9.0
#
# Copyright (c) 2014 ADVANCED MICRO DEVICES, INC.
#
Expand Down Expand Up @@ -67,16 +67,19 @@ function usage(){
-t <tdir> Default=/tmp/cloc$$, Temp dir for files
-o <outfilename> Default=<filename>.<ft> ft=brig or hsail
-opt <LLVM opt> Default=2, LLVM optimization level
-p <path> Default=$HSA_LLVM_PATH or /opt/amd/bin
-p <path> $HSA_LLVM_PATH or <cdir> if HSA_LLVM_PATH not set
<cdir> is actual directory of cloc.sh
-clopts <compiler opts> Default="-cl-std=CL2.0"
-lkopts <LLVM link opts> Default="--prelink-opt -l $HSA_LLVM_PATH/builtins-hsail.bc"
-lkopts <LLVM link opts> Default="-prelink-opt \
-l <cdir>/builtins-hsail.bc -l <cdir>/builtins-gcn.bc \
-l <cdir>/builtins-hsail-amd-ci.bc"
Examples:
cloc my.cl /* create my.brig */
cloc -hsail my.cl /* create my.hsail and my.brig */
cloc.sh my.cl /* create my.brig */
cloc.sh -hsail my.cl /* create my.hsail and my.brig */
You may set environment variables LLVMOPT, HSA_LLVM_PATH, CLOPTS, or
LKOPTS instead of providing options -opt -p, -clopts, or -lkopts .
You may set environment variables LLVMOPT, HSA_LLVM_PATH, CLOPTS,
or LKOPTS instead of providing options -opt -p, -clopts, or -lkopts .
Command line options will take precedence over environment variables.
Copyright (c) 2015 ADVANCED MICRO DEVICES, INC.
Expand Down Expand Up @@ -161,24 +164,26 @@ fi

if [ ! -z $1 ]; then
echo " "
echo "WARNING: Cloc can only process one .cl file at a time."
echo "WARNING: cloc.sh can only process one .cl file at a time."
echo " You can call cloc multiple times to get multiple outputs."
echo " Argument $LASTARG will be processed. "
echo " These args are ignored: $@"
echo " "
fi

# We no longer need CLOCPATH (no _genw).
# In future we expect cloc.sh to be in $HSA_LLVM_PATH
# CLOCPATH=$(getdname $0)
# All binaries and builtins are expected to be in the same directory as cloc.sh
# unless HSA_LLVM_PATH is set.
cdir=$(getdname $0)
[ ! -L "$cdir/cloc.sh" ] || cdir=$(getdname `readlink "$cdir/cloc.sh"`)
# If HSA_LLVM_PATH is set use it, else use cdir
HSA_LLVM_PATH=${HSA_LLVM_PATH:-$cdir}

# Set Default values, all CMD_ are started from $HSA_LLVM_PATH
LLVMOPT=${LLVMOPT:-2}
HSA_LLVM_PATH=${HSA_LLVM_PATH:-/opt/amd/bin}
# no default CLOPTS -cl-std=CL2.0 is a forced option to the clc2 command
CMD_CLC=${CMD_CLC:-clc2 -cl-std=CL2.0 $CLOPTS}
CMD_LLA=${CMD_LLA:-llvm-dis}
LKOPTS=${LKOPTS:--prelink-opt -l $HSA_LLVM_PATH/builtins-hsail.bc}
LKOPTS=${LKOPTS:--prelink-opt -l $HSA_LLVM_PATH/builtins-hsail.bc -l $HSA_LLVM_PATH/builtins-gcn.bc -l $HSA_LLVM_PATH/builtins-hsail-amd-ci.bc}
CMD_LLL=${CMD_LLL:-llvm-link $LKOPTS}
CMD_OPT=${CMD_OPT:-opt -O$LLVMOPT -gpu -whole}
CMD_LLC=${CMD_LLC:-llc -O$LLVMOPT -march=hsail-64 -filetype=obj}
Expand All @@ -196,11 +201,6 @@ if [ ! -e "$LASTARG" ] ; then
echo "ERROR: The file $LASTARG does not exist."
exit $DEADRC
fi
if [ ! -d $HSA_LLVM_PATH ] ; then
echo "ERROR: Missing directory $HSA_LLVM_PATH "
echo " Set env variable HSA_LLVM_PATH or use -p option"
exit $DEADRC
fi

# Parse LASTARG for directory, filename, and symbolname
INDIR=$(getdname $LASTARG)
Expand Down Expand Up @@ -241,8 +241,7 @@ if [ ! -d $TMPDIR ] && [ ! $DRYRUN ] ; then
exit $DEADRC
fi
if [ ! -e $HSA_LLVM_PATH/hsailasm ] ; then
echo "ERROR: Missing hsailasm in $HSA_LLVM_PATH"
echo " Set env variable HSA_LLVM_PATH or use -p option"
echo "ERROR: Missing binary hsailasm in $HSA_LLVM_PATH"
exit $DEADRC
fi
if [ ! -d $OUTDIR ] && [ ! $DRYRUN ] ; then
Expand Down Expand Up @@ -298,13 +297,12 @@ fi
if [ $DRYRUN ] ; then
echo $CMD_LLL -o $TMPDIR/$FNAME.lnkd.bc $TMPDIR/$FNAME.bc
else
# Hide the warnings for now
$HSA_LLVM_PATH/$CMD_LLL -o $TMPDIR/$FNAME.lnkd.bc $TMPDIR/$FNAME.bc 2>/dev/null
$HSA_LLVM_PATH/$CMD_LLL -o $TMPDIR/$FNAME.lnkd.bc $TMPDIR/$FNAME.bc
rc=$?
fi
if [ $rc != 0 ] ; then
echo "ERROR: The following command failed with return code $rc."
echo " $CMD_LLL -o $TMPDIR/$FNAME.lnkd.bc $TMPDIR/$FNAME.bc"
echo " $HSA_LLVM_PATH/$CMD_LLL -o $TMPDIR/$FNAME.lnkd.bc $TMPDIR/$FNAME.bc"
do_err $rc
fi

Expand Down
Binary file added bin/hsailasm
Binary file not shown.
Binary file added bin/inflate
Binary file not shown.
Binary file added bin/llc
Binary file not shown.
Binary file added bin/llvm-ar
Binary file not shown.
Binary file added bin/llvm-as
Binary file not shown.
Binary file added bin/llvm-dis
Binary file not shown.
Binary file added bin/llvm-dwarfdump
Binary file not shown.
Binary file added bin/llvm-extract
Binary file not shown.
Binary file added bin/llvm-link
Binary file not shown.
Binary file added bin/llvm-nm
Binary file not shown.
Binary file added bin/llvm-ranlib
Binary file not shown.
Binary file added bin/opt
Binary file not shown.
Loading

0 comments on commit cf77785

Please sign in to comment.