Skip to content

Commit cf77785

Browse files
committed
Merge pull request #7 from HSAFoundation/CLOC-0.9-ReleaseCandidate
Cloc 0.9 release candidate - Compatible with 1.0F Runtime/Drivers
2 parents c874c02 + d4b7acb commit cf77785

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+934
-5800
lines changed

INSTALL.md

Lines changed: 57 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
Cloc Install Instructions 1.0P
2-
==============================
1+
Cloc 0.9 Install Instructions
2+
=============================
3+
4+
Warning. These instructions are for HSA 1.0F .
35

4-
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.
6+
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.
57

68
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:
79

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

1719
## Install Ubuntu 14.04 LTS
1820

19-
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:
21+
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:
2022
```
2123
sudo apt-get update
2224
sudo apt-get upgrade
2325
sudo apt-get install git
2426
sudo apt-get install make
2527
sudo apt-get install g++
2628
sudo apt-get install libstdc++-4.8-dev
27-
sudo apt-get install libelf-dev
29+
sudo apt-get install libelf
2830
sudo apt-get install libtinfo-dev
2931
sudo apt-get install re2c
3032
sudo apt-get install libbsd-dev
@@ -47,16 +49,16 @@ mount the appropriate MLNX_OFED iso
4749

4850
## Install HSA Linux Kernel Drivers
4951

50-
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.
52+
These instructions are for HSA1.0F.
5153

5254
Execute these commands:
5355

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

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

98-
## Install HSA Runtime
100+
## Install HSA 1.0F Runtime
99101

100102
```
101103
mkdir ~/git
102104
cd ~/git
103-
git clone -b release-v1.0 https://github.com/HSAfoundation/HSA-Runtime-AMD.git
105+
git clone https://github.com/HSAfoundation/HSA-Runtime-AMD.git
104106
cd HSA-Runtime-AMD/ubuntu
105107
sudo dpkg -i hsa-runtime_1.0_amd64.deb
106108
```
107109

108-
## Install HSAIL Compiler (HLC)
109-
110-
```
111-
cd ~/git
112-
git clone https://github.com/HSAfoundation/HSAIL-HLC-Stable.git
113-
cd HSAIL-HLC-Stable/ubuntu
114-
sudo dpkg -i hsail-hlc-stable_1.0_amd64.deb
115-
```
116-
117110
## Install and Test Cloc utility
118111

119-
As of Cloc version 0.8 the executable shell script names are changed to cloc.sh, snack.sh and snk_genw.sh.
120-
These scripts need to be copied to a directory that is in users PATH. For example /usr/local/bin is typically in PATH.
112+
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
121113
```
122114
cd ~/git
123-
git clone -b 0.8 https://github.com/HSAfoundation/CLOC.git
124-
sudo cp CLOC/bin/cloc.sh /usr/local/bin/.
125-
sudo cp CLOC/bin/snack.sh /usr/local/bin/.
126-
sudo cp CLOC/bin/snk_genw.sh /usr/local/bin/.
127-
cd
128-
cp -r git/CLOC/examples .
129-
cd examples/snack/helloworld
115+
git clone -b CLOC-0.9 https://github.com/HSAfoundation/CLOC.git
116+
# Install
117+
mkdir -p /opt/amd/cloc
118+
sudo cp -rp ~/git/CLOC/bin /opt/amd/cloc
119+
sudo cp -rp ~/git/CLOC/examples /opt/amd/cloc
120+
sudo ln -sf /opt/amd/cloc/bin/cloc.sh /usr/local/bin/cloc.sh
121+
sudo ln -sf /opt/amd/cloc/bin/snack.sh /usr/local/bin/snack.sh
122+
sudo ln -sf /opt/amd/cloc/bin/printhsail /usr/local/bin/printhsail
123+
# Test
124+
cp -r /opt/amd/cloc/examples ~
125+
cd ~/examples/snack/helloworld
130126
./buildrun.sh
127+
cd ~/examples/hsa/vector_copy
128+
make
129+
make test
131130
```
132131

133-
## Install Kalmar compiler
134-
135-
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.
132+
## Set HSA environment variables
136133

134+
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:
137135
```
138-
mkdir ~/git/deb
139-
cd ~/git/deb
140-
wget https://bitbucket.org/multicoreware/cppamp-driver-ng/downloads/clamp-0.5.0-hsa-milestone4-Linux.deb
141-
wget https://bitbucket.org/multicoreware/cppamp-driver-ng/downloads/libcxxamp-0.5.0-hsa-milestone4-Linux.deb
142-
wget https://bitbucket.org/multicoreware/cppamp-driver-ng/downloads/clamp-bolt-1.2.0-hsa-milestone4-Linux.deb
143-
wget https://bitbucket.org/multicoreware/cppamp-driver-ng/downloads/boost_1_55_0-hsa-milestone3.deb
144-
sudo dpkg -i *.deb
136+
export HSA_RUNTIME_PATH=/opt/hsa
137+
export LD_LIBRARY_PATH=$HSA_RUNTIME_PATH/lib
145138
```
146139

147-
## Install Okra
148-
149-
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.
140+
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:
150141
```
151-
cd ~/git
152-
git clone https://github.com/HSAfoundation/Okra-Interface-to-HSA-Device
153-
sudo mkdir /opt/amd/okra
154-
sudo cp -r Okra-Interface-to-HSA-Device/okra /opt/amd
155-
sudo cp Okra-Interface-to-HSA-Device/okra/dist/bin/libokra_x86_64.so /opt/hsa/lib/.
142+
#
143+
# Either put /opt/amd/cloc/bin in your PATH as follows
144+
export PATH=$PATH:/opt/amd/cloc/bin
145+
#
146+
# OR symbolic link cloc.sh and snack.sh to system path
147+
sudo ln -sf /opt/amd/cloc/bin/cloc.sh /usr/local/bin/cloc.sh
148+
sudo ln -sf /opt/amd/cloc/bin/snack.sh /usr/local/bin/snack.sh
149+
sudo ln -sf /opt/amd/cloc/bin/printhsail /usr/local/bin/printhsail
156150
```
157151

158-
## Set HSA environment variables
152+
Future package installers (.deb and .rpm) will symbolically link them.
159153

160-
```
161-
export HSA_LLVM_PATH=/opt/amd/bin
162-
export HSA_RUNTIME_PATH=/opt/hsa
163-
export HSA_OKRA_PATH=/opt/amd/okra
164-
export PATH=$PATH:/opt/amd/bin
165-
export LD_LIBRARY_PATH=/opt/hsa/lib
166-
```
154+
## Install Kalmar (C++AMP) HSA Compiler (OPTIONAL)
155+
156+
SKIP THIS STEP TILL KALMAR IS PORTED TO 1.0F
157+
158+
## Install gcc OpenMP for HSA Compiler (OPTIONAL)
159+
160+
SKIP THIS STEP TILL IT IS PORTED TO 1.0F
161+
162+
## Install Codeplay HSA Compiler (OPTIONAL)
163+
164+
SKIP THIS STEP TILL IT IS PORTED TO 1.0F
165+
166+
## Install Pathscale HSA Compiler (OPTIONAL)
167+
168+
SKIP THIS STEP TILL IT IS PORTED TO 1.0F
167169

168170

169171
<A Name="Infiniband">

README.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
CLOC - Version 0.8.0
2-
====================
1+
CLOC - V 0.9.0 (HSA 1.0F)
2+
=========================
33

44
CLOC: CL Offline Compiler
55
Generate HSAIL or brig from a cl (Kernel c Language) file.
@@ -81,19 +81,23 @@ Software License Agreement.
8181
-t <tdir> Default=/tmp/cloc$$, Temp dir for files
8282
-o <outfilename> Default=<filename>.<ft> ft=brig or hsail
8383
-opt <LLVM opt> Default=2, LLVM optimization level
84-
-p <path> Default=$HSA_LLVM_PATH or /opt/amd/bin
84+
-p <path> $HSA_LLVM_PATH or <cdir> if HSA_LLVM_PATH not set
85+
<cdir> is actual directory of cloc.sh
8586
-clopts <compiler opts> Default="-cl-std=CL2.0"
86-
-lkopts <LLVM link opts> Default="--prelink-opt -l $HSA_LLVM_PATH/builtins-hsail.bc"
87+
-lkopts <LLVM link opts> Default="-prelink-opt \
88+
-l <cdir>/builtins-hsail.bc -l <cdir>/builtins-gcn.bc \
89+
-l <cdir>/builtins-hsail-amd-ci.bc -l <cdir>/builtins-ocml.bc"
8790
8891
Examples:
89-
cloc my.cl /* create my.brig */
90-
cloc -hsail my.cl /* create my.hsail and my.brig */
92+
cloc.sh my.cl /* create my.brig */
93+
cloc.sh -hsail my.cl /* create my.hsail and my.brig */
9194
92-
You may set environment variables LLVMOPT, HSA_LLVM_PATH, CLOPTS, or
93-
LKOPTS instead of providing options -opt -p, -clopts, or -lkopts .
95+
You may set environment variables LLVMOPT, HSA_LLVM_PATH, CLOPTS,
96+
or LKOPTS instead of providing options -opt -p, -clopts, or -lkopts .
9497
Command line options will take precedence over environment variables.
9598
9699
Copyright (c) 2015 ADVANCED MICRO DEVICES, INC.
100+
97101
```
98102

99103

@@ -126,22 +130,24 @@ Software License Agreement.
126130
-gccopt <gcc opt> Default=2, gcc optimization for snack wrapper
127131
-t <tempdir> Default=/tmp/snk_$$, Temp dir for files
128132
-s <symbolname> Default=filename
129-
-p1 <path> Default=$HSA_LLVM_PATH or /opt/amd/bin
130-
-p2 <path> Default=$HSA_RUNTIME_PATH or /opt/hsa
133+
-p <path> $HSA_LLVM_PATH or <sdir> if HSA_LLVM_PATH not set
134+
<sdir> is actual directory of snack.sh
135+
-rp <HSA RT path> Default=$HSA_RUNTIME_PATH or /opt/hsa
131136
-o <outfilename> Default=<filename>.<ft>
132137
133138
Examples:
134-
snack my.cl /* create my.snackwrap.c and my.h */
135-
snack -c my.cl /* gcc compile to create my.o */
136-
snack -hsail my.cl /* create hsail and snackwrap.c */
137-
snack -c -hsail my.cl /* create hsail snackwrap.c and .o */
138-
snack -t /tmp/foo my.cl /* will automatically set -k */
139+
snack.sh my.cl /* create my.snackwrap.c and my.h */
140+
snack.sh -c my.cl /* gcc compile to create my.o */
141+
snack.sh -hsail my.cl /* create hsail and snackwrap.c */
142+
snack.sh -c -hsail my.cl /* create hsail snackwrap.c and .o */
143+
snack.sh -t /tmp/foo my.cl /* will automatically set -k */
139144
140145
You may set environment variables HSA_LLVM_PATH, HSA_RUNTIME_PATH,
141-
instead of providing options -p1, -p2.
146+
instead of providing options -p, -rp.
142147
Command line options will take precedence over environment variables.
143148
144149
Copyright (c) 2015 ADVANCED MICRO DEVICES, INC.
150+
145151
```
146152

147153
<A NAME="ReadmeExamples">
@@ -221,7 +227,7 @@ manual updates to HSAIL. This process has two steps.
221227
The first step compiles the .cl file into the object code needed by a SNACK application.
222228
For example, if your kernels are in the file myKernels.cl, then you can run step 1 as follows.
223229
```
224-
snack -c -hsail myKernels.cl
230+
snack.sh -c -hsail myKernels.cl
225231
```
226232
When cloc sees the "-c" option and the "-hsail" option, it will save four files
227233
in the same directory as myKernels.cl file. The first two files are always created

bin/Dev

10.7 MB
Binary file not shown.

bin/HSAILTestGen

2.74 MB
Binary file not shown.

bin/builtins-gcn.bc

1.15 KB
Binary file not shown.

bin/builtins-hsail-amd-ci.bc

3.08 KB
Binary file not shown.

bin/builtins-hsail.bc

639 KB
Binary file not shown.

bin/clang-tblgen

1.23 MB
Binary file not shown.

bin/clc2

18.3 MB
Binary file not shown.

bin/cloc.sh

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Written by Greg Rodgers [email protected]
77
# Maintained by Shreyas Ramalingam [email protected]
88
#
9-
PROGVERSION=0.8.0
9+
PROGVERSION=0.9.0
1010
#
1111
# Copyright (c) 2014 ADVANCED MICRO DEVICES, INC.
1212
#
@@ -67,16 +67,19 @@ function usage(){
6767
-t <tdir> Default=/tmp/cloc$$, Temp dir for files
6868
-o <outfilename> Default=<filename>.<ft> ft=brig or hsail
6969
-opt <LLVM opt> Default=2, LLVM optimization level
70-
-p <path> Default=$HSA_LLVM_PATH or /opt/amd/bin
70+
-p <path> $HSA_LLVM_PATH or <cdir> if HSA_LLVM_PATH not set
71+
<cdir> is actual directory of cloc.sh
7172
-clopts <compiler opts> Default="-cl-std=CL2.0"
72-
-lkopts <LLVM link opts> Default="--prelink-opt -l $HSA_LLVM_PATH/builtins-hsail.bc"
73+
-lkopts <LLVM link opts> Default="-prelink-opt \
74+
-l <cdir>/builtins-hsail.bc -l <cdir>/builtins-gcn.bc \
75+
-l <cdir>/builtins-hsail-amd-ci.bc"
7376
7477
Examples:
75-
cloc my.cl /* create my.brig */
76-
cloc -hsail my.cl /* create my.hsail and my.brig */
78+
cloc.sh my.cl /* create my.brig */
79+
cloc.sh -hsail my.cl /* create my.hsail and my.brig */
7780
78-
You may set environment variables LLVMOPT, HSA_LLVM_PATH, CLOPTS, or
79-
LKOPTS instead of providing options -opt -p, -clopts, or -lkopts .
81+
You may set environment variables LLVMOPT, HSA_LLVM_PATH, CLOPTS,
82+
or LKOPTS instead of providing options -opt -p, -clopts, or -lkopts .
8083
Command line options will take precedence over environment variables.
8184
8285
Copyright (c) 2015 ADVANCED MICRO DEVICES, INC.
@@ -161,24 +164,26 @@ fi
161164

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

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

175181
# Set Default values, all CMD_ are started from $HSA_LLVM_PATH
176182
LLVMOPT=${LLVMOPT:-2}
177-
HSA_LLVM_PATH=${HSA_LLVM_PATH:-/opt/amd/bin}
178183
# no default CLOPTS -cl-std=CL2.0 is a forced option to the clc2 command
179184
CMD_CLC=${CMD_CLC:-clc2 -cl-std=CL2.0 $CLOPTS}
180185
CMD_LLA=${CMD_LLA:-llvm-dis}
181-
LKOPTS=${LKOPTS:--prelink-opt -l $HSA_LLVM_PATH/builtins-hsail.bc}
186+
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}
182187
CMD_LLL=${CMD_LLL:-llvm-link $LKOPTS}
183188
CMD_OPT=${CMD_OPT:-opt -O$LLVMOPT -gpu -whole}
184189
CMD_LLC=${CMD_LLC:-llc -O$LLVMOPT -march=hsail-64 -filetype=obj}
@@ -196,11 +201,6 @@ if [ ! -e "$LASTARG" ] ; then
196201
echo "ERROR: The file $LASTARG does not exist."
197202
exit $DEADRC
198203
fi
199-
if [ ! -d $HSA_LLVM_PATH ] ; then
200-
echo "ERROR: Missing directory $HSA_LLVM_PATH "
201-
echo " Set env variable HSA_LLVM_PATH or use -p option"
202-
exit $DEADRC
203-
fi
204204

205205
# Parse LASTARG for directory, filename, and symbolname
206206
INDIR=$(getdname $LASTARG)
@@ -241,8 +241,7 @@ if [ ! -d $TMPDIR ] && [ ! $DRYRUN ] ; then
241241
exit $DEADRC
242242
fi
243243
if [ ! -e $HSA_LLVM_PATH/hsailasm ] ; then
244-
echo "ERROR: Missing hsailasm in $HSA_LLVM_PATH"
245-
echo " Set env variable HSA_LLVM_PATH or use -p option"
244+
echo "ERROR: Missing binary hsailasm in $HSA_LLVM_PATH"
246245
exit $DEADRC
247246
fi
248247
if [ ! -d $OUTDIR ] && [ ! $DRYRUN ] ; then
@@ -298,13 +297,12 @@ fi
298297
if [ $DRYRUN ] ; then
299298
echo $CMD_LLL -o $TMPDIR/$FNAME.lnkd.bc $TMPDIR/$FNAME.bc
300299
else
301-
# Hide the warnings for now
302-
$HSA_LLVM_PATH/$CMD_LLL -o $TMPDIR/$FNAME.lnkd.bc $TMPDIR/$FNAME.bc 2>/dev/null
300+
$HSA_LLVM_PATH/$CMD_LLL -o $TMPDIR/$FNAME.lnkd.bc $TMPDIR/$FNAME.bc
303301
rc=$?
304302
fi
305303
if [ $rc != 0 ] ; then
306304
echo "ERROR: The following command failed with return code $rc."
307-
echo " $CMD_LLL -o $TMPDIR/$FNAME.lnkd.bc $TMPDIR/$FNAME.bc"
305+
echo " $HSA_LLVM_PATH/$CMD_LLL -o $TMPDIR/$FNAME.lnkd.bc $TMPDIR/$FNAME.bc"
308306
do_err $rc
309307
fi
310308

0 commit comments

Comments
 (0)