-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathO2GBuild.script
executable file
·181 lines (164 loc) · 5.11 KB
/
O2GBuild.script
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#! /bin/bash
###########################################
# OpenARC Commandline Option: ompaccInter #
###########################################
#ompaccInter=${defaultOmpAccInter}
#Interchange OpenACC directives with OpenMP 3.0 or OpenMP 4.0 directives:
# =0 disable this option (default)
# =1 generate OpenACC directives from OpenMP 3.0 directives
# =2 generate OpenACC directives from OpenMP 4.0 directives
# =3 generate OpenMP 3.0 directives from OpenACC directives
# =4 generate OpenMP 4.0 directives from OpenACC directives
# =5 generate optimized OpenMP directives from OpenMP directives
###############################
# Default options for OpenACC #
###############################
defaultACCInputFile1="propagate-toz-test_OpenACC_sync.c"
defaultACCInputFile2="propagate-toz-test_OpenACC_async.c"
defaultACCInputFile3="propagate-toz-test_OpenACC_async_v4.c"
#defaultOmpAccInter=0
###############################
# Default options for OpenMP4 #
###############################
defaultOMP4InputFile1="propagate-toz-test_OpenMP4_sync.c"
defaultOMP4InputFile2="propagate-toz-test_OpenMP4_async.c"
defaultOMP4InputFile3="propagate-toz-test_OpenMP4_async_v4.c"
#defaultOmpAccInter=2
if [ $# -eq 4 ]; then
inputMode="$1"
numStreams=$2
niters=$3
include_data=$4
elif [ $# -eq 3 ]; then
inputMode="$1"
numStreams=$2
niters=$3
include_data=1
elif [ $# -eq 2 ]; then
inputMode="$1"
numStreams=$2
niters=10
include_data=1
elif [ $# -eq 1 ]; then
inputMode="$1"
numStreams=10
niters=10
include_data=1
else
inputMode="acccv3"
numStreams=10
niters=10
include_data=1
fi
if [ "$numStreams" = "0" ]; then
numStreams=10
fi
forceSyncOpt=""
if [ "$inputMode" == "accc" ]; then
inputFile="$defaultACCInputFile1"
ompaccInter=0
if [ "$include_data" == "0" ]; then
forceSyncOpt="-forceSyncKernelCall"
fi
elif [ "$inputMode" == "acccv3" ]; then
inputFile="$defaultACCInputFile2"
ompaccInter=0
elif [ "$inputMode" == "acccv4" ]; then
inputFile="$defaultACCInputFile3"
ompaccInter=0
elif [ "$inputMode" == "accccpu" ]; then
inputFile="$defaultACCInputFile1"
ompaccInter=3
if [ "$include_data" == "0" ]; then
forceSyncOpt="-forceSyncKernelCall"
fi
elif [ "$inputMode" == "acccv3cpu" ]; then
inputFile="$defaultACCInputFile2"
ompaccInter=3
elif [ "$inputMode" == "acccv4cpu" ]; then
inputFile="$defaultACCInputFile3"
ompaccInter=3
elif [ "$inputMode" == "omp4c" ]; then
inputFile="$defaultOMP4InputFile1"
ompaccInter=2
if [ "$include_data" == "0" ]; then
forceSyncOpt="-forceSyncKernelCall"
fi
elif [ "$inputMode" == "omp4cv3" ]; then
inputFile="$defaultOMP4InputFile2"
ompaccInter=2
elif [ "$inputMode" == "omp4cv4" ]; then
inputFile="$defaultOMP4InputFile3"
ompaccInter=2
fi
if [ ! -f "./src/$inputFile" ]; then
echo "input file, ./src/$inputFile does not exits; exit"
exit
fi
verLevel=0
if [ "$openarc" == "" ] || [ ! -d "${openarc}" ]; then
echo "Environment variable, openarc, should be set to use this script; exit"
exit
fi
openarcrt="${openarc}/openarcrt"
openarclib="${openarc}/lib"
#if [ ! -f "openarcConf.txt" ]; then
cp "openarcConf_NORMAL.txt" "openarcConf.txt"
#fi
if [ "$numStreams" != "" ]; then
mv "openarcConf.txt" "openarcConf.txt_tmp"
cat "openarcConf.txt_tmp" | sed "s|__numStreams__|${numStreams}|g" > "openarcConf.txt"
rm "openarcConf.txt_tmp"
fi
if [ "$niters" != "" ]; then
mv "openarcConf.txt" "openarcConf.txt_tmp"
cat "openarcConf.txt_tmp" | sed "s|__NITER__|${niters}|g" > "openarcConf.txt"
rm "openarcConf.txt_tmp"
fi
if [ "$include_data" != "" ]; then
mv "openarcConf.txt" "openarcConf.txt_tmp"
cat "openarcConf.txt_tmp" | sed "s|__INCLUDE_DATA__|${include_data}|g" > "openarcConf.txt"
rm "openarcConf.txt_tmp"
fi
if [ ! -d ./bin ]; then
mkdir bin
fi
if [ "$openarcrt" != "" ]; then
mv "openarcConf.txt" "openarcConf.txt_tmp"
cat "openarcConf.txt_tmp" | sed "s|__openarcrt__|${openarcrt}|g" > "openarcConf.txt"
rm "openarcConf.txt_tmp"
fi
java -classpath $openarclib/cetus.jar:$openarclib/antlr.jar openacc.exec.ACC2GPUDriver -verbosity=${verLevel} -ompaccInter=${ompaccInter} -gpuConfFile=openarcConf.txt ${forceSyncOpt} ./src/$inputFile
if [ "$inputMode" == "accc" ]; then
echo ""
echo "====> To compile the translated output file:"
echo "\$ make COMPILER=openarc MODE=accc"
echo ""
echo "====> To run the compiled binary:"
echo "\$ cd bin; propagate_openarc_accc"
echo ""
elif [ "$inputMode" == "acccv3" ]; then
echo ""
echo "====> To compile the translated output file:"
echo "\$ make COMPILER=openarc MODE=acccv3"
echo ""
echo "====> To run the compiled binary:"
echo "\$ cd bin; propagate_openarc_acccv3"
echo ""
elif [ "$inputMode" == "omp4c" ]; then
echo ""
echo "====> To compile the translated output file:"
echo "\$ make COMPILER=openarc MODE=omp4c"
echo ""
echo "====> To run the compiled binary:"
echo "\$ cd bin; propagate_openarc_omp4c"
echo ""
elif [ "$inputMode" == "omp4cv3" ]; then
echo ""
echo "====> To compile the translated output file:"
echo "\$ make COMPILER=openarc MODE=omp4cv3"
echo ""
echo "====> To run the compiled binary:"
echo "\$ cd bin; propagate_openarc_omp4cv3"
echo ""
fi