stringify_ocl_krnls.sh 2.04 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

# kernel-header files
HEADER_DIR="./common"
IN_HEADER1=$HEADER_DIR/"defines.h"
IN_HEADER2=$HEADER_DIR/"calcenergy_basic.h"

echo " "
echo "Stringified input header-files: "
echo $IN_HEADER1
echo $IN_HEADER2

# kernel files
KERNEL_DIR="./device"
IN_KERNELm=$KERNEL_DIR/"calcenergy.cl"
IN_KERNEL1=$KERNEL_DIR/"kernel1.cl"
IN_KERNEL2=$KERNEL_DIR/"kernel2.cl"
IN_KERNELa=$KERNEL_DIR/"auxiliary_genetic.cl"
IN_KERNEL3=$KERNEL_DIR/"kernel3.cl"
IN_KERNEL4=$KERNEL_DIR/"kernel4.cl"
21
IN_KERNELb=$KERNEL_DIR/"calcgradient.cl"
lvs's avatar
lvs committed
22
IN_KERNEL5=$KERNEL_DIR/"kernel_sd.cl"
lvs's avatar
lvs committed
23
IN_KERNEL6=$KERNEL_DIR/"kernel_fire.cl"
lvs's avatar
lvs committed
24
IN_KERNEL7=$KERNEL_DIR/"kernel_ad.cl"
25
26
27
28
29
30
31
32
33

echo " "
echo "Stringified input kernel-files: "
echo $IN_KERNELm
echo $IN_KERNEL1
echo $IN_KERNEL2
echo $IN_KERNELa
echo $IN_KERNEL3
echo $IN_KERNEL4
34
35
echo $IN_KERNELb
echo $IN_KERNEL5
lvs's avatar
lvs committed
36
echo $IN_KERNEL6
lvs's avatar
lvs committed
37
echo $IN_KERNEL7
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

# output file
OUT=host/inc/stringify.h

echo " "
echo "Stringified output file: "
echo $OUT
echo " "

# temporal file
TMP=$KERNEL_DIR/stringify_tmp

echo "// OCLADOCK: AUTOMATICALLY GENERATED FILE, DO NOT EDIT" >$TMP
echo "#ifndef STRINGIFY_H" >>$TMP
echo "#define STRINGIFY_H" >>$TMP

echo "const char *calcenergy_ocl =" >>$TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_HEADER1 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_HEADER2 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNELm >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL1 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL2 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNELa >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL3 >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL4 >> $TMP
63
64
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNELb >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL5 >> $TMP
lvs's avatar
lvs committed
65
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL6 >> $TMP
lvs's avatar
lvs committed
66
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL7 >> $TMP
67
68
69
70
71
72
echo ";" >>$TMP

echo "#endif // End of STRINGIFY_H" >>$TMP

# remove "#include" lines
grep -v '#include' $TMP > $OUT