Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
f2929057eThis file is pinned to the selected release. Download the original to open it in your design tool.
puts "=========="
puts "0032539: Modeling Algorithms - Parallelize BRepExtrema_DistShapeShape algorithm"
puts "=========="
puts ""
# prepare
pload XDE OCAF
cpulimit 1000
XOpen [locate_data_file bug32539_1.xbf] XB
XGetShape s1 XB 0:1:1:2
XGetShape s2 XB 0:1:1:4
Close XB
btranslate s1 0 0 60
brotate s2 0 0 0 0 0 1 90
# multi-thread
dchrono p reset; dchrono p start;
set pres [distmini res s1 s2 -parallel]
dchrono p stop;
regexp {Elapsed time: +([-0-9.+eE]+) Hours +([-0-9.+eE]+) Minutes +([-0-9.+eE]+) Seconds} [dchrono p show] full p_Hours p_Minutes p_Seconds
set p_Time [expr ${p_Hours}*60.*60. + ${p_Minutes}*60. + ${p_Seconds} ]
puts "multithreaded time: $p_Time"
set pdist [dval res_val]
vclear
vclose ALL
vinit v1/v1
vdisplay -dispMode 1 s1 s2 res res2 res3 res4
vfit
checkview -screenshot -3d -path ${imagedir}/${test_image}_multi.png
#single-thread
dchrono s reset; dchrono s start;
set cres [distmini res s1 s2]
dchrono s stop;
regexp {Elapsed time: +([-0-9.+eE]+) Hours +([-0-9.+eE]+) Minutes +([-0-9.+eE]+) Seconds} [dchrono s show] full s_Hours s_Minutes s_Seconds
set s_Time [expr ${s_Hours}*60.*60. + ${s_Minutes}*60. + ${s_Seconds} ]
puts "single-threaded time: $s_Time"
set sdist [dval res_val]
vclear
vclose ALL
vinit v2/v2
vdisplay -dispMode 1 s1 s2 res res2 res3 res4
vfit
checkview -screenshot -3d -path ${imagedir}/${test_image}_single.png
# compare
set ratio [expr ${s_Time}/${p_Time} ]
puts "acceleration in multi-threaded work: $ratio"
if {[string compare $cres $pres] != 0} {
puts "Error: different result between single-thread and multi-thread mode"
}
if {[expr abs(${sdist} - ${pdist})] > 1E-13} {
puts "Error: different distance between single-thread and multi-thread mode"
}