Created
June 2, 2018 16:47
-
-
Save alxmjo/50ee37c1bd6dc4d0e42fbafa9efcc0cb to your computer and use it in GitHub Desktop.
Compiles a program with a particular set of inputs, runs multiple times, and then outputs the average of each run. The program should submit a single integer to stdout. In this example, the outer loop passes the values 1, 2, 4, 8, etc. (as WORKGROUPSIZE) and the inner loop passes the values 1024, 2048, 4096, etc. (as ARRAYSIZE). The data is aver…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create or clear output file | |
> data.csv | |
# Run for multiple tries and compute average | |
TRIES=10 | |
WORKGROUPCOUNTER=1 | |
while [ $WORKGROUPCOUNTER -le 256 ] | |
do | |
WORKGROUPSIZE=$(( WORKGROUPCOUNTER * 1 )) | |
ARRAYCOUNTER=1 | |
while [ $ARRAYCOUNTER -le 8192 ] | |
do | |
SUM=0 | |
ARRAYSIZE=$(( $ARRAYCOUNTER * 1024 )) | |
g++ main.cpp -DGLOBAL=${ARRAYSIZE} -DLOCAL=${WORKGROUPSIZE} -o main -lm -fopenmp | |
for TRY in $(seq ${TRIES}) | |
do | |
OUTPUT=$(./main) | |
SUM=$(( (SUM + OUTPUT) )) | |
done | |
AVG=$(( SUM / TRIES )) | |
printf "$AVG" >> data.csv | |
printf ',' >> data.csv | |
ARRAYCOUNTER=$(( $ARRAYCOUNTER * 2 )) | |
done | |
echo >> data.csv | |
WORKGROUPCOUNTER=$(( $WORKGROUPCOUNTER * 2 )) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment