Skip to content

Commit fad170d

Browse files
authored
Merge pull request #928 from caic99/develop
CI: add performance test.
2 parents c2463c1 + 3fb8938 commit fad170d

File tree

4 files changed

+126
-96
lines changed

4 files changed

+126
-96
lines changed

.github/workflows/performance.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Performance test
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
test:
8+
name: Performance test
9+
runs-on: self-hosted
10+
strategy:
11+
matrix:
12+
tag: ["gnu", "intel"]
13+
if: github.repository_owner == 'deepmodeling'
14+
container: ghcr.io/${{ github.repository_owner }}/abacus-development-kit:${{ matrix.tag }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
- name: Build
19+
run: |
20+
cmake -B build -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON
21+
cmake --build build -j16
22+
cmake --install build
23+
- name: Test
24+
run: |
25+
cd examples/performance/ && bash run.sh
26+
- name: Show Result
27+
run: |
28+
echo sumall.dat

examples/performance/clean.sh

100644100755
File mode changed.

examples/performance/run.sh

100644100755
Lines changed: 98 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,42 @@
22

33
##############################
44
#RUNNING SET
5-
abacus=abacus #ABACUS running path
6-
thread=1 #Thread number
7-
ca=8 #accuracy for comparing energy, force, and stress
8-
#ncpu=8 #parallel core number in mpirun, or use the below value
9-
ncpu=`cat /proc/cpuinfo | grep "cpu cores" | uniq| awk '{print $NF}'` #the CPU cores in current mathine
10-
ForceRun=0 #if ForceRun = 0, before run a job, it will check the file result.log, and if this file
11-
#is normal end, this job will be skipped
5+
abacus=abacus #ABACUS running path
6+
thread=1 #Thread number
7+
ca=8 #accuracy for comparing energy, force, and stress
8+
#ncpu=8 #parallel core number in mpirun, or use the below value
9+
ncpu=$(cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}') #the CPU cores in current machine
10+
ForceRun=0 #if ForceRun = 0, before run a job, it will check the file result.log
11+
#and if this file has a normal ending, this job will be skipped
1212

13-
DoAllExampleRun=1 #if run allexample in allcase file or not, 0: not do, others: do
13+
DoAllExampleRun=1 #if run allexample in allcase file or not, 0: not do, others: do
1414

15-
DoNCpuTest=0 #if do CPU parallel test or not. 0: not do, others: do
15+
DoNCpuTest=0 #if do CPU parallel test or not. 0: not do, others: do
1616
CpuTestExample="P000_si16_pw " #the example used to do NCpu test
17-
NCpuList="2 4 8 16 32" #the ncore list used to do NCpu test, not run when it is larger than the maxcpucore
17+
NCpuList="2 4 8 16 32" #the ncore list used to do NCpu test, not run when it is larger than the maxcpucore
1818
maxcpucore=$ncpu
1919

20-
DoKParTest=0 #if do kpar test for PW method
20+
DoKParTest=0 #if do kpar test for PW method
2121
KParTestExample="P010_si2_pw" #do not modify
22-
KParList="2 4 8 16 32" #kpar setting list, not run when it is larger than maxkpar
23-
maxkpar=$ncpu #note: maxkpar should less than ncpu and also less than the total K-POINTS number
22+
KParList="2 4 8 16 32" #kpar setting list, not run when it is larger than maxkpar
23+
maxkpar=$ncpu #note: maxkpar should less than ncpu and also less than the total K-POINTS number
2424

25-
DoBxyzTest=0 #if modify bx=by=bz value, the default value is 2
25+
DoBxyzTest=0 #if modify bx=by=bz value, the default value is 2
2626
BxyzTestExample="P100_si16_lcao" #in this case the grid is 96 x 96 x96, only lcao case
27-
BxyzList="2 3 4 6 8" #the grid number shold be divisible by these values, and these value should also less than the sqrt of grid
27+
BxyzList="2 3 4 6 8" #the grid number shold be divisible by these values, and these value should also less than the sqrt of grid
2828
##############################
2929

3030
##############################
3131
#def function check_out
3232
#check_out result.dat
33-
check_out(){
33+
check_out() {
3434
outfile=$1
35-
properties=`awk '{print $1}' $outfile`
35+
properties=$(awk '{print $1}' $outfile)
3636
for key in $properties; do
37-
cal=`grep "$key" $outfile | awk '{printf "%.'$ca'f\n",$2}'`
38-
ref=`grep "$key" result.ref | awk '{printf "%.'$ca'f\n",$2}'`
39-
deviation=`awk 'BEGIN {x='$ref';y='$cal';if (x<y) {a=y-x} else {a=x-y};printf "%.'$ca'f\n",a}'`
40-
deviation1=`awk 'BEGIN{print '$deviation'*(10**'$ca')}'`
37+
cal=$(grep "$key" $outfile | awk '{printf "%.'$ca'f\n",$2}')
38+
ref=$(grep "$key" result.ref | awk '{printf "%.'$ca'f\n",$2}')
39+
deviation=$(awk 'BEGIN {x='$ref';y='$cal';if (x<y) {a=y-x} else {a=x-y};printf "%.'$ca'f\n",a}')
40+
deviation1=$(awk 'BEGIN{print '$deviation'*(10**'$ca')}')
4141

4242
if [ $key == "totaltimeref" ]; then
4343
break
@@ -46,15 +46,15 @@ check_out(){
4646
if [ ! -n "$deviation" ]; then
4747
echo " Error: Fatal Error!"
4848
let failed++
49-
currentfolder=`pwd| awk -F '/' '{print $NF}'`
50-
failedfile="${failedfile}${currentfolder}\n"
49+
currentfolder=$(pwd | awk -F '/' '{print $NF}')
50+
failedfile="${failedfile}${currentfolder}\n"
5151
break
5252
else
53-
if [ $(echo "$deviation1 < 1"|bc) = 0 ]; then
53+
if [ $(echo "$deviation1 < 1" | bc) = 0 ]; then
5454
echo " Error: FAILED!"
5555
echo " Error:$key cal=$cal ref=$ref deviation=$deviation"
5656
let failed++
57-
currentfolder=`pwd| awk -F '/' '{print $NF}'`
57+
currentfolder=$(pwd | awk -F '/' '{print $NF}')
5858
failedfile="${failedfile}${currentfolder}\n"
5959
break
6060
fi
@@ -67,54 +67,54 @@ check_out(){
6767
##############################
6868
#run abacus function
6969
#run_abacus $ncpu $threads $abacuspath $workfolder
70-
run_abacus(){
70+
run_abacus() {
7171
cd $3
7272
printf "Running %-20s: " "$3"
7373

74-
starttime=`date +'%Y-%m-%d %H:%M:%S'`
74+
starttime=$(date +'%Y-%m-%d %H:%M:%S')
7575
#if there has result.log file, assign lastword="the first word of last line of result.log"
76-
#and if lastword is equal to "SEE", we think this job is normal end, and it will be
76+
#and if lastword is equal to "SEE", we think this job is normal end, and it will be
7777
#skipped when ForceRun is set to be 0
7878
lastword=""
79-
if [[ $ForceRun == 0 && -f result.log ]];then
80-
lastword=`tail -1 result.log | awk '{print $1}'`
79+
if [[ $ForceRun == 0 && -f result.log ]]; then
80+
lastword=$(tail -1 result.log | awk '{print $1}')
8181
fi
82-
if [[ $lastword != "SEE" ]];then
83-
/usr/bin/time -v mpirun -n $1 -env OMP_NUM_THREADS=$2 $abacus > result.log 2>time.log
82+
if [[ $lastword != "SEE" ]]; then
83+
/usr/bin/time -v mpirun -n $1 -env OMP_NUM_THREADS=$2 $abacus >result.log 2>time.log
8484
else
8585
printf "**result.log is normal end, skip this job** "
8686
fi
87-
endtime=`date +'%Y-%m-%d %H:%M:%S'`
87+
endtime=$(date +'%Y-%m-%d %H:%M:%S')
8888
start_seconds=$(date --date="$starttime" +%s)
8989
end_seconds=$(date --date="$endtime" +%s)
90-
echo "Use time "$((end_seconds-start_seconds))"s"
90+
echo "Use time "$((end_seconds - start_seconds))"s"
9191

92-
#runing catch_properties.sh script to collect energy, force and stress to file result.out
92+
#running catch_properties.sh script to collect energy, force and stress to file result.out
9393
#Then use function "check_out" to compare the results in result.out and result.ref
94-
bash ../catch_properties.sh result.out
94+
bash ../catch_properties.sh result.out
9595
check_out result.out
9696
cd ..
9797
}
9898
##############################
9999

100100
##############################
101101
#Begin to RUN
102-
test -e allcase || echo "Plese specify tests"
103-
test -e allcase || exit 0
104-
which $abacus > /dev/null || echo "Error! ABACUS path was wrong!!"
105-
which $abacus > /dev/null || exit 0
102+
test -e allcase || echo "Please specify tests in file 'allcase'."
103+
test -e allcase || exit 1
104+
which $abacus >/dev/null || echo "Error: ABACUS executable not found. Please check ABACUS installation or \$PATH."
105+
which $abacus >/dev/null || exit 1
106106

107-
test -f sumall.dat && mv sumall.dat sumall.dat.old
108-
cat version >> sumall.dat
109-
date >> sumall.dat
110-
cat /proc/version >> sumall.dat
111-
cat /proc/cpuinfo | grep "model name"| tail -1| cut -d ':' -f 2 >> sumall.dat
112-
echo "ABACUS path: $abacus" >> sumall.dat
113-
echo "Number of Cores: $ncpu" >> sumall.dat
114-
echo "Accuracy: $ca" >> sumall.dat
115-
echo >> sumall.dat
116-
echo "!!!all data will be summarized in file sumall.dat" >> sumall.dat
117-
echo "" >> sumall.dat
107+
test -f sumall.dat && mv sumall.dat sumall.old.dat
108+
cat version >>sumall.dat
109+
date >>sumall.dat
110+
cat /proc/version >>sumall.dat
111+
cat /proc/cpuinfo | grep "model name" | tail -1 | cut -d ':' -f 2 >>sumall.dat
112+
echo "ABACUS path: $abacus" >>sumall.dat
113+
echo "Number of Cores: $ncpu" >>sumall.dat
114+
echo "Accuracy: $ca" >>sumall.dat
115+
echo >>sumall.dat
116+
echo "!!!all data will be summarized in file sumall.dat" >>sumall.dat
117+
echo "" >>sumall.dat
118118
cat sumall.dat
119119

120120
failed=0
@@ -123,135 +123,137 @@ ok=0
123123

124124
##############################
125125
#run all examples in allcase
126-
if [[ $DoAllExampleRun != 0 ]];then
126+
if [[ $DoAllExampleRun != 0 ]]; then
127127
echo "run all examples in allcase"
128-
for i in `cat allcase`;do
128+
for i in $(cat allcase); do
129129
test -d $i || continue
130130
run_abacus $ncpu $thread $i
131131
done
132132

133133
#sum the critical timing information
134134
bash sumdat.sh allcase sum.dat
135-
echo "##AllExampleRun" >> sumall.dat
136-
cat sum.dat >> sumall.dat
137-
echo "" >> sumall.dat
135+
echo "##AllExampleRun" >>sumall.dat
136+
cat sum.dat >>sumall.dat
137+
echo "" >>sumall.dat
138138
echo !!!all data are summarized in sum.dat
139139
echo
140140
fi
141141
##############################
142142
#do NCpu test
143-
if [[ $DoNCpuTest != 0 ]];then
143+
if [[ $DoNCpuTest != 0 ]]; then
144144
echo "do N CPU test"
145145
cpucore=$maxcpucore
146146
test -f allcase.ncpu && rm allcase.ncpu
147-
for case in $CpuTestExample;do
148-
if [[ ! -d $case ]];then
147+
for case in $CpuTestExample; do
148+
if [[ ! -d $case ]]; then
149149
echo "Error: do NCpu test, can not find $case"
150150
continue
151151
fi
152152

153-
for i in $NCpuList;do
154-
if [[ $i -lt $cpucore ]];then
155-
echo ${case}_${i}cpu >> allcase.ncpu
153+
for i in $NCpuList; do
154+
if [[ $i -lt $cpucore ]]; then
155+
echo ${case}_${i}cpu >>allcase.ncpu
156156
test -d ${case}_${i}cpu || mkdir ${case}_${i}cpu
157157
cp ${case}/INPUT ${case}/STRU ${case}/KPT ${case}/result.ref ${case}_${i}cpu
158158

159-
run_abacus $i $thread ${case}_${i}cpu
159+
run_abacus $i $thread ${case}_${i}cpu
160160
fi
161161
done
162162

163-
echo $case >> allcase.ncpu
164-
if [[ ! -f $case/result.log ]];then
163+
echo $case >>allcase.ncpu
164+
if [[ ! -f $case/result.log ]]; then
165165
run_abacus $ncpu $thread ${case}
166166
fi
167167
done
168168

169169
#sum the critical timing information
170170
bash sumdat.sh allcase.ncpu sum.dat.ncpu
171-
echo "##NCpuTest" >> sumall.dat
172-
cat sum.dat.ncpu >> sumall.dat
173-
echo "" >> sumall.dat
171+
echo "##NCpuTest" >>sumall.dat
172+
cat sum.dat.ncpu >>sumall.dat
173+
echo "" >>sumall.dat
174174
echo "!!!all data are summarized in sum.dat.ncpu"
175-
echo
175+
echo
176176
fi
177177

178178
##############################
179179
#do KPar test
180-
if [[ $DoKParTest != 0 ]];then
180+
if [[ $DoKParTest != 0 ]]; then
181181
echo "do N KPar test"
182182
test -f allcase.kpar && rm allcase.kpar
183-
for case in $KParTestExample;do
184-
if [[ ! -d $case ]];then
183+
for case in $KParTestExample; do
184+
if [[ ! -d $case ]]; then
185185
echo "Error: do KPar test, can not find $case"
186186
continue
187187
fi
188188

189-
echo $case >> allcase.kpar
190-
if [[ ! -f $case/result.log ]];then
189+
echo $case >>allcase.kpar
190+
if [[ ! -f $case/result.log ]]; then
191191
run_abacus $ncpu $thread ${case}
192192
fi
193193

194-
for i in $KParList;do
195-
if [[ $i -le $maxkpar ]];then
196-
echo ${case}_${i}kpar >> allcase.kpar
194+
for i in $KParList; do
195+
if [[ $i -le $maxkpar ]]; then
196+
echo ${case}_${i}kpar >>allcase.kpar
197197
test -d ${case}_${i}kpar || mkdir ${case}_${i}kpar
198198
cp ${case}/INPUT ${case}/STRU ${case}/KPT ${case}/result.ref ${case}_${i}kpar
199-
echo "kpar $i" >> ${case}_${i}kpar/INPUT
199+
echo "kpar $i" >>${case}_${i}kpar/INPUT
200200

201201
run_abacus $ncpu $thread ${case}_${i}kpar
202202
fi
203203
done
204204
done
205205
#sum the critical timing information
206206
bash sumdat.sh allcase.kpar sum.dat.kpar
207-
echo "##KParTest" >> sumall.dat
208-
cat sum.dat.kpar >> sumall.dat
209-
echo "" >> sumall.dat
207+
echo "##KParTest" >>sumall.dat
208+
cat sum.dat.kpar >>sumall.dat
209+
echo "" >>sumall.dat
210210
echo "!!!all data are summarized in sum.dat.kpar"
211211
echo
212212
fi
213213

214214
##############################
215215
#do Bxyz test
216-
if [[ $DoBxyzTest != 0 ]];then
216+
if [[ $DoBxyzTest != 0 ]]; then
217217
echo "do bx by bz test"
218218
test -f allcase.bxyz && rm allcase.bxyz
219-
for case in $BxyzTestExample;do
220-
if [[ ! -d $case ]];then
219+
for case in $BxyzTestExample; do
220+
if [[ ! -d $case ]]; then
221221
echo "Error: do BxByBz test, can not find $case"
222222
continue
223223
fi
224224

225-
echo $case >> allcase.bxyz
226-
if [[ ! -f $case/result.log ]];then
225+
echo $case >>allcase.bxyz
226+
if [[ ! -f $case/result.log ]]; then
227227
run_abacus $ncpu $thread ${case}
228228
fi
229229

230-
for i in $BxyzList;do
231-
if [[ $i != 2 ]];then
232-
echo ${case}_${i}bxyz >> allcase.bxyz
230+
for i in $BxyzList; do
231+
if [[ $i != 2 ]]; then
232+
echo ${case}_${i}bxyz >>allcase.bxyz
233233
test -d ${case}_${i}bxyz || mkdir ${case}_${i}bxyz
234234
cp ${case}/INPUT ${case}/STRU ${case}/KPT ${case}/result.ref ${case}_${i}bxyz
235-
printf " bx $i \n by $i \n bz $i" >> ${case}_${i}bxyz/INPUT
235+
printf " bx $i \n by $i \n bz $i" >>${case}_${i}bxyz/INPUT
236236

237237
run_abacus $ncpu $thread ${case}_${i}bxyz
238238
fi
239239
done
240240
done
241241
#sum the critical timing information
242242
bash sumdat.sh allcase.bxyz sum.dat.bxyz
243-
echo "##BxyzTest" >> sumall.dat
244-
cat sum.dat.bxyz >> sumall.dat
245-
echo "" >> sumall.dat
243+
echo "##BxyzTest" >>sumall.dat
244+
cat sum.dat.bxyz >>sumall.dat
245+
echo "" >>sumall.dat
246246
echo "!!!all data are summarized in sum.dat.bxyz"
247247
echo
248248
fi
249249

250250
##############################
251251
#Final OUTPUT
252-
if [[ $failed -eq 0 ]];then
253-
echo "All jobs are finished !!!"
252+
if [[ $failed -eq 0 ]]; then
253+
echo "All jobs finished." | tee $GITHUB_STEP_SUMMARY
254+
exit 0
254255
else
255-
echo "Error: there has $failed jobs are failed!"
256+
echo "Error: $failed jobs failed." | tee $GITHUB_STEP_SUMMARY
256257
echo -e "$failedfile"
258+
exit 1
257259
fi

examples/performance/sumdat.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)