stringify_ocl_krnls.sh 1.82 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
22
IN_KERNELb=$KERNEL_DIR/"auxiliary_gradient.cl"
IN_KERNEL5=$KERNEL_DIR/"kernel_gradient.cl"
23
24
25
26
27
28
29
30
31

echo " "
echo "Stringified input kernel-files: "
echo $IN_KERNELm
echo $IN_KERNEL1
echo $IN_KERNEL2
echo $IN_KERNELa
echo $IN_KERNEL3
echo $IN_KERNEL4
32
33
echo $IN_KERNELb
echo $IN_KERNEL5
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

# 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
59
60
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNELb >> $TMP
sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/\\n"/' $IN_KERNEL5 >> $TMP
61
62
63
64
65
66
echo ";" >>$TMP

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

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