-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateHFFD.sh
executable file
·98 lines (73 loc) · 3.21 KB
/
generateHFFD.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
ORANGE='\033[0;33m'
NC='\033[0m'
declare chunk=10000
errorcounter=0
successcounter=0
declare TARGETPATH="."
declare -a arr=$HFFD_TABLES
declare RAWDATA_FILEEXT="TXT"
filepostfix="" # "-SHORT"$chunk
echo " " >> error.log
for table in $(echo $arr | sed "s/,/ /g")
do
blocksize=`java -jar ${SAXON} table-name="$table" ${DATA_MODEL} xslt/getRecordLength.xslt`
echo "java -jar ${SAXON} table-name="$table" ${DATA_MODEL} xslt/getRecordLength.xslt"
filesize=`stat -c %s ${RAWDATA}/${table}.${RAWDATA_FILEEXT}`
if [ "$filesize" -eq "0" ]; then
errorcounter=$((errorcounter+1))
echo "Error[$errorcounter]: filesize is zero for table $table" >> error.log
else
if [ -z "$blocksize" ]; then
errorcounter=$((errorcounter+1))
echo "Error[$errorcounter]: blocksize empty for table $table" >> error.log
else
re='^[0-9]+$'
if ! [[ $blocksize =~ $re ]] ; then
errorcounter=$((errorcounter+1))
# echo "Error[$errorcounter]: blocksize(${blocksize}) is not an int for $table" >> error.log
else
if [ $(( $filesize % $blocksize )) -eq 0 ]; then
echo "$filesize divisible by $blocksize."
echo -e "Resize data file of ${BLUE}"$table"${NC} to "$chunk" records with a blocksize of ${ORANGE}"$blocksize"${NC} each"
dd bs=$blocksize if=${RAWDATA}/$table.${RAWDATA_FILEEXT} of=${TARGETPATH}/rawdata/$table-$chunk.txt count=$chunk # 2> /dev/null
echo -e "Generate CUDA code at ${GREEN}src/cuda/record.cu${NC}"
realchunk=$chunk
newchunk=`echo $((filesize / blocksize))`
# echo "test $newchunk"
if [ "$newchunk" -lt "$realchunk" ]; then
echo "WARNING: less than $chunk ($newchunk for real) records available!" >> error.log
# echo "java -Xmx8192m -jar ${SAXON} table=$table numberofrecords=$newchunk ${DATA_MODEL} xslt/generateRecordCUDA.xslt > src/cuda/record.cu"
java -Xmx8192m -jar ${SAXON} table=$table numberofrecords=$newchunk ${DATA_MODEL} xslt/generateRecordCUDA.xslt > src/cuda/record.cu
else
# echo "java -Xmx8192m -jar ${SAXON} table=$table numberofrecords=$chunk ${DATA_MODEL} xslt/generateRecordCUDA.xslt > src/cuda/record.cu"
java -Xmx8192m -jar ${SAXON} table=$table numberofrecords=$chunk ${DATA_MODEL} xslt/generateRecordCUDA.xslt > src/cuda/record.cu
fi
echo -e "Compile CUDA code to ${GREEN}../hffd-$table.o${NC}"
nvcc -I${CUDA_HOME}/samples/common/inc -o ../hffd-$table.o src/hffd.cu
echo -e "Run program ${GREEN}../hffd-$table.o${NC}"
echo -e "${RED}"
../hffd-$table.o ${TARGETPATH}/rawdata/$table-$chunk.txt ${TARGETPATH}/decodeddata/$table-$chunk.csv
retVal=$?
if [ $retVal -ne 0 ]; then
errorcounter=$((errorcounter+1))
echo "Error[$errorcounter]: CUDA failed for $table" >> error.log
else
successcounter=$((successcounter+1))
echo "Success[$successcounter]: $table" >> error.log
fi
echo "Success $table"
echo -e "${NC}${BLUE}"
head ${TARGETPATH}/decodeddata/$table-$chunk.csv
echo -e "${NC}"
else
errorcounter=$((errorcounter+1))
echo "Error[$errorcounter]: unaligned size $table $filesize / $blocksize" >> error.log
fi
fi
fi
fi
done