166 |
|
# Get sampling rate and subdivide task |
167 |
|
my $ns2 = $ns; |
168 |
|
$ns2 /= 2 if ( $tensortree == 3 ); |
169 |
< |
@pdiv = (0, int($ns2/$nproc)); |
170 |
< |
my $nrem = $ns2 % $nproc; |
171 |
< |
for (my $i = 1; $i < $nproc; $i++) { |
169 |
> |
my $nsplice = $nproc; |
170 |
> |
$nsplice *= 10 if ($nproc > 1); |
171 |
> |
$nsplice = $ns2 if ($nsplice > $ns2); |
172 |
> |
$nsplice = 999 if ($nsplice > 999); |
173 |
> |
@pdiv = (0, int($ns2/$nsplice)); |
174 |
> |
my $nrem = $ns2 % $nsplice; |
175 |
> |
for (my $i = 1; $i < $nsplice; $i++) { |
176 |
|
my $nv = $pdiv[$i] + $pdiv[1]; |
177 |
|
++$nv if ( $nrem-- > 0 ); |
178 |
|
push @pdiv, $nv; |
221 |
|
print "\t\t<IncidentDataStructure>TensorTree$tensortree</IncidentDataStructure>\n"; |
222 |
|
print "\t</DataDefinition>\n"; |
223 |
|
# Fork parallel rtcontrib processes to compute each side |
224 |
+ |
my $npleft = $nproc; |
225 |
|
if ( $doback ) { |
226 |
< |
for (my $proc = 0; $proc < $nproc; $proc++) { |
227 |
< |
bg_tree_rtcontrib(0, $proc); |
226 |
> |
for (my $splice = 0; $splice < $nsplice; $splice++) { |
227 |
> |
if (! $npleft ) { |
228 |
> |
wait(); |
229 |
> |
die "rtcontrib process reported error" if ( $? ); |
230 |
> |
$npleft++; |
231 |
> |
} |
232 |
> |
bg_tree_rtcontrib(0, $splice); |
233 |
> |
$npleft--; |
234 |
|
} |
235 |
|
while (wait() >= 0) { |
236 |
|
die "rtcontrib process reported error" if ( $? ); |
237 |
+ |
$npleft++; |
238 |
|
} |
239 |
|
ttree_out(0); |
240 |
|
} |
241 |
|
if ( $doforw ) { |
242 |
< |
for (my $proc = 0; $proc < $nproc; $proc++) { |
243 |
< |
bg_tree_rtcontrib(1, $proc); |
242 |
> |
for (my $splice = 0; $splice < $nsplice; $splice++) { |
243 |
> |
if (! $npleft ) { |
244 |
> |
wait(); |
245 |
> |
die "rtcontrib process reported error" if ( $? ); |
246 |
> |
$npleft++; |
247 |
> |
} |
248 |
> |
bg_tree_rtcontrib(1, $splice); |
249 |
> |
$npleft--; |
250 |
|
} |
251 |
|
while (wait() >= 0) { |
252 |
|
die "rtcontrib process reported error" if ( $? ); |
253 |
+ |
$npleft++; |
254 |
|
} |
255 |
|
ttree_out(1); |
256 |
|
} |
257 |
|
} # end of sub do_tree_bsdf() |
258 |
|
|
259 |
< |
# Run i'th rtcontrib process for generating tensor tree samples |
259 |
> |
# Run rtcontrib process in background to generate tensor tree samples |
260 |
|
sub bg_tree_rtcontrib { |
261 |
|
my $pid = fork(); |
262 |
|
die "Cannot fork new process" unless defined $pid; |