Skip to content

Commit f1da64a

Browse files
committed
updated scipts to correctly run all the executables and install necessary tool programs
1 parent 6eaaa2d commit f1da64a

4 files changed

Lines changed: 35 additions & 18 deletions

File tree

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ SHELL ["/bin/bash", "-c"]
99
# Update packages, install build dependencies, and the specified version of CMake
1010
RUN apt-get update && \
1111
apt-get upgrade -y && \
12-
apt-get install -y wget make git gfortran libomp-18-dev libboost-all-dev clang-18 clang-tools-18 && \
12+
apt-get install -y wget make git gfortran libomp-18-dev libboost-all-dev clang-18 clang-tools-18 unzip && \
1313
wget https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0-linux-x86_64.sh && \
1414
chmod +x cmake-3.28.0-linux-x86_64.sh && \
1515
./cmake-3.28.0-linux-x86_64.sh --skip-license --prefix=/usr/local && \
1616
rm cmake-3.28.0-linux-x86_64.sh
1717

18+
# setup alternative names for the compiler
19+
RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100 && \
20+
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-18 100 && \
21+
update-alternatives --install /usr/bin/llvm-cxxfilt llvm-cxxfilt /usr/bin/llvm-cxxfilt-18 100
22+
1823

1924
# Set the working directory
2025
WORKDIR /gpu-flopbench

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ For checking the build process, we include the following Github Action in the `.
4646
This sets up a Docker container with all the necessary programs and code to build all the HecBench codes with our CMakeLists approach.
4747
We also provide a `Dockerfile` so you can set up and run our code on your own system with a GPU.
4848

49-
[![Build ALL CUDA/OMP Codes](https://github.com/gregbolet/HeCBench-roofline/actions/workflows/buildAllCodesGithubAction.yml/badge.svg)](https://github.com/gregbolet/HeCBench-roofline/actions/workflows/buildAllCodesGithubAction.yml)
49+
[![Build ALL CUDA/OMP Codes](https://github.com/gregbolet/gpu-flopbench/actions/workflows/buildAllCodesGithubAction.yml/badge.svg)](https://github.com/gregbolet/gpu-flopbench/actions/workflows/buildAllCodesGithubAction.yml)
5050

5151
## Building
5252

5353
Execute the following command to get the Makefile generated and to start the build process.
5454
This will automatically `make` all the programs, **you'll NEED to edit the `runBuild.sh` script to properly set any compilers/options for the codes to build**.
55+
NOTE: If you're running this from a Docker container generated from our Dockerfile, it should work out-of-the-box.
5556
By default, we have everything building with `clang++` and `clang`, this should mostly work out-of-the-box but some include paths may need to be set/overriden. (SEE BELOW)
5657
```
5758
source ./runBuild.sh
@@ -79,10 +80,11 @@ Here's a list of other common build issues that might help if you're encounterin
7980
We used Python3 (v3.11.11) for executing our Python scripts.
8081
The `requirements.txt` file contains all the necessary packages and their versions that should be installed prior to using any of our Python scripts.
8182
It is strongly advised to set up a new Conda environment to not mess up the base Python installation on your system.
83+
NOTE: This is already done for you if you're using the supplied Dockerfile.
8284

8385
```
84-
conda create --name "hecbench-roofline" python=3.11.11
85-
conda activate hecbench-roofline
86+
conda create --name "gpu-flopbench" python=3.11.11
87+
conda activate gpu-flopbench
8688
pip install -r ./requirements.txt
8789
```
8890

@@ -91,12 +93,12 @@ pip install -r ./requirements.txt
9193
Once all the codes are built, we can start the data collection process. We have our own script called `gatherData.py` which can be invoked to gather the roofline benchmarking data of each of the built programs.
9294

9395
```
94-
LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH DATAPATH=/home/gbolet/hecbench-roofline/src/prna-cuda/data_tables python3 ./gatherData.py --outfile=roofline-data.csv 2>&1 | tee runlog.txt
96+
LD_LIBRARY_PATH=/usr/lib/llvm-18/lib:$LD_LIBRARY_PATH DATAPATH=$PWD/src/prna-cuda/data_tables python3 ./gatherData.py --outfile=roofline-data.csv 2>&1 | tee runlog.txt
9597
```
9698

9799
This will automatically invoke each of the built executables, using `ncu` (NVIDIA Nsight Compute) to profile each of the kernels in the executable. Some of the codes require files to be downloaded proir, this script takes care of the downloading process and makes sure that all the requested files are in place.
98100
The `DATAPATH` environment variable is only needed by `frna-cuda` and `prna-cuda`, so if you're not running those, you can drop it.
99-
The `LD_LIBRARY_PATH` environment variable is for all the OMP codes, this is the path to the `libomptarget.so` library. One some machines CMake isn't adding the path, so we just manually add it. We should probably `rpath` this in in the future, but for now this is fine.
101+
The `LD_LIBRARY_PATH` environment variable is for all the OMP codes, this is the path to the `libomptarget.so` library. On some machines CMake isn't adding the path, so we just manually add it. We should probably `rpath` this in in the future, but for now this is fine.
100102

101103
The internal workflow at a high level looks like the following:
102104
1. Download rodinia dataset (skip if requested with `--skipRodiniaDownload`).

gatherData.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def has_rodinia_datasets():
6969
def download_rodinia_and_extract():
7070
print('Downloading Rodinia Data...')
7171

72-
command = f'wget http://www.cs.virginia.edu/~skadron/lava/Rodinia/Packages/rodinia_3.1.tar.bz2 && tar -xf ./rodinia_3.1.tar.bz2 rodinia_3.1/data && mv ./rodinia_3.1/data {SRC_DIR}/data'
72+
# http://www.cs.virginia.edu/~skadron/lava/rodinia/Packages/rodinia_3.1.tar.bz2
73+
command = f'wget http://www.cs.virginia.edu/~skadron/lava/rodinia/Packages/rodinia_3.1.tar.bz2 && tar -xf ./rodinia_3.1.tar.bz2 rodinia_3.1/data && mv ./rodinia_3.1/data {SRC_DIR}/data'
7374
print('executing command', command)
7475
result = subprocess.run(command, cwd=DOWNLOAD_DIR, shell=True)
7576

@@ -80,8 +81,12 @@ def download_rodinia_and_extract():
8081

8182
return
8283

83-
def run_setup_command_for_file(targetFile, command, targetDir=DOWNLOAD_DIR):
84+
def run_setup_command_for_file(targetFile, command, targetDir=None):
85+
if targetDir is None:
86+
targetDir = DOWNLOAD_DIR
8487
if not os.path.isfile(targetFile):
88+
print('running command: ', command)
89+
print('targetDir: ', targetDir)
8590
result = subprocess.run(args=command, cwd=targetDir, shell=True)
8691
assert result.returncode == 0
8792
return
@@ -166,7 +171,7 @@ def download_files_for_some_targets(targets):
166171
result = subprocess.run(command, cwd=DOWNLOAD_DIR, shell=True)
167172
assert result.returncode == 0
168173

169-
elif basename == 'opticalFlow-':
174+
elif 'opticalFlow-' in basename:
170175
if not os.path.isfile(f'{srcDir}/frame10.ppm'):
171176
command = f'wget --no-check-certificate https://github.com/NVIDIA/cuda-samples/raw/c94ff366aed18c797b8a85dfaac7817b0228b420/Samples/5_Domain_Specific/HSOpticalFlow/data/frame10.ppm && mv ./frame10.ppm {srcDir}/'
172177
result = subprocess.run(command, cwd=DOWNLOAD_DIR, shell=True)
@@ -176,13 +181,15 @@ def download_files_for_some_targets(targets):
176181
result = subprocess.run(command, cwd=DOWNLOAD_DIR, shell=True)
177182
assert result.returncode == 0
178183

179-
elif basename == 'tsne-':
184+
elif 'tsne-' in basename:
180185
if not os.path.isfile(f'{srcDir}/data/points.txt'):
181186
command = f'wget --no-check-certificate https://raw.githubusercontent.com/oneapi-src/Velocity-Bench/refs/heads/main/tsne/data/points.txt && mv ./points.txt {srcDir}/data/points.txt'
182187
result = subprocess.run(command, cwd=DOWNLOAD_DIR, shell=True)
183188
assert result.returncode == 0
184189

185-
elif basename == 'tpacf-':
190+
elif 'tpacf-' in basename:
191+
result = subprocess.run(f'mkdir -p ./data/small', cwd=srcDir, shell=True)
192+
assert result.returncode == 0
186193
# this only downloads the two files necessary for the beginning of the program to hit the kernels for profiling
187194
if not os.path.isfile(f'{srcDir}/data/small/Datapnts.1'):
188195
command = f'wget --no-check-certificate https://raw.githubusercontent.com/fengzhangcs/CoRunBench/refs/heads/master/parboil/datasets/tpacf/small/input/Datapnts.1 && mv ./Datapnts.1 {srcDir}/data/small/Datapnts.1'
@@ -246,7 +253,7 @@ def download_files_for_some_targets(targets):
246253

247254
elif basename == 'mcpr-cuda':
248255
if not os.path.isfile(f'{srcDir}/alphas.csv'):
249-
command = f'bunzip2 alphas.csv.bz2'
256+
command = f'wget --no-check-certificate https://github.com/zjin-lcf/HeCBench/raw/refs/heads/master/src/mcpr-cuda/alphas.csv.bz2 && bunzip2 alphas.csv.bz2'
250257
result = subprocess.run(command, cwd=srcDir, shell=True)
251258
assert result.returncode == 0
252259

@@ -271,8 +278,10 @@ def download_files_for_some_targets(targets):
271278
# need to have python2 installed for this to work
272279
elif basename == 'heat2d-cuda':
273280
if not os.path.isfile(f'{srcDir}/data.txt'):
274-
command = f'python2 mkinit.py 4096 8192 data.txt'
275-
result = subprocess.run(command, cwd=srcDir, shell=True)
281+
command = f'python3 mkinit.py 4096 8192 data.txt'
282+
result = subprocess.run(command, cwd=srcDir, shell=True, capture_output=True)
283+
print(result.stdout)
284+
print(result.stderr)
276285
assert result.returncode == 0
277286

278287
elif (basename == 'frna-cuda') or (basename == 'prna-cuda'):
@@ -337,6 +346,7 @@ def get_runnable_targets():
337346

338347
# check we have the source code too
339348
assert os.path.isdir(execSrcDir)
349+
assert execSrcDir != ''
340350

341351
execDict = {'basename':basename,
342352
'exe':entry,
@@ -534,7 +544,7 @@ def search_and_extract_file(inFile):
534544
print('Extracted zip archive:', filename)
535545

536546
# now let's check that the file exists
537-
assert os.path.exists(inFile)
547+
assert os.path.exists(inFile), f'Could not find input file: {inFile} after extracting archives!'
538548

539549
return
540550

@@ -551,7 +561,7 @@ def check_and_unzip_input_files(targets:list):
551561
if len(inputFiles) > 0:
552562
for inFile in inputFiles:
553563
# if the word `output` is in the filename, we skip checking for it
554-
if not ('output' in inFile.lower()):
564+
if not ('output' in inFile.lower() or 'results' in inFile.lower()):
555565
print(f'looking for input file: {srcDir}/{inFile}')
556566
search_and_extract_file(f'{srcDir}/{inFile}')
557567

src/heat2d-cuda/mkinit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def main(argv=None):
1212
try:
1313
try:
1414
opts, args = getopt.getopt(argv[1:], "h", ["help"])
15-
except getopt.GetoptError, msg:
15+
except getopt.GetoptError as msg:
1616
raise Usage(msg)
1717

1818
for o, a in opts:
@@ -29,7 +29,7 @@ def main(argv=None):
2929
if len(args) != 3:
3030
raise Usage(" Usage: %s [OPTIONS] LX LY FILE_NAME" % argv[0])
3131

32-
except Usage, err:
32+
except Usage as err:
3333
print(err.msg)
3434
print(" for help use --help")
3535
return 2

0 commit comments

Comments
 (0)