|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I have said several times, that "it should be quite easy to make a shell
script that automates the process of distributing the rendering to several
computers".
Well, I decided to try, not only to see how easy it is, but of course also
because it's very useful.
Here at school I have access to many UltraSparc computers that I can use
for the purpose. Specially the fact that I can rsh (or ssh) to any other
computer here at work and that every one sees the same file system makes it
easy.
I first tried thinking how to achieve the following method (which should be
the best): For each process take the next unrendered image block and render
it until there are no more free blocks.
The problem here is communication and mutual exclusion (two of the basic
problems in multithreading). How to get the next free block? How to avoid
two processes rendering the same block? It's harder than one could think,
specially when you only have the hard disk to communicate between processes
(I didn't even think about some network communication system).
So I decided to use a much simpler (but more inefficient) method: Each
process just renders it's own predefined blocks and that's it. So if
there are two processes, one renders the even blocks and the other
renders the odd blocks. This, of course, is not as efficient (the render
is exactly as long as the slowest process), but at least is better than
nothing and very easy to implement (although the render is as long as the
slowest process, each process has much less to render than the whole image).
Then I had another problem: After the computers have rendered their parts,
how to join them? After much searching of programs to join image parts, I
remembered one interesting thing: The raw targa format has 18 bytes of header
data and then the raw image after that. I got an idea: What if I just copy
the data after the 18th byte from all the other partial images to the end of
the first partial image? There's even a handy utility in Unix to make
this (cut). Well, I tried it and it worked like a marvel. Easy and fast.
So I made the script and tried with several block sizes with 8 machines.
At least with the test scene I used a block size of about 17 lines gave a
good result.
The test image with antialiasing 0.1 takes about 15.5 minutes to render
with one computer and 2.25 minutes to render with 8 computers. Without
antialiasing it takes 6 minutes with one computer and 55 seconds with 8.
If anyone is interested in the script, I can post it here. It has several
limitations (for example it's made for zsh), but someone can get good ideas
from it.
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Whats wrong with using an MPI version of POV-Ray? It has much better
load balancing abilities, handles animations, etc. I first used a
tweaked version of the PVM patch for 3.1e (it applied somewhat to 3.1g),
but then went to the MPI version. Sure, MPI is not small (7mb source
tarball), but it works, and uses rsh :)
Yann
Warp wrote:
>
> I have said several times, that "it should be quite easy to make a shell
> script that automates the process of distributing the rendering to several
> computers".
> Well, I decided to try, not only to see how easy it is, but of course also
> because it's very useful.
> Here at school I have access to many UltraSparc computers that I can use
> for the purpose. Specially the fact that I can rsh (or ssh) to any other
> computer here at work and that every one sees the same file system makes it
> easy.
> I first tried thinking how to achieve the following method (which should be
> the best): For each process take the next unrendered image block and render
> it until there are no more free blocks.
> The problem here is communication and mutual exclusion (two of the basic
> problems in multithreading). How to get the next free block? How to avoid
> two processes rendering the same block? It's harder than one could think,
> specially when you only have the hard disk to communicate between processes
> (I didn't even think about some network communication system).
> So I decided to use a much simpler (but more inefficient) method: Each
> process just renders it's own predefined blocks and that's it. So if
> there are two processes, one renders the even blocks and the other
> renders the odd blocks. This, of course, is not as efficient (the render
> is exactly as long as the slowest process), but at least is better than
> nothing and very easy to implement (although the render is as long as the
> slowest process, each process has much less to render than the whole image).
> Then I had another problem: After the computers have rendered their parts,
> how to join them? After much searching of programs to join image parts, I
> remembered one interesting thing: The raw targa format has 18 bytes of header
> data and then the raw image after that. I got an idea: What if I just copy
> the data after the 18th byte from all the other partial images to the end of
> the first partial image? There's even a handy utility in Unix to make
> this (cut). Well, I tried it and it worked like a marvel. Easy and fast.
>
> So I made the script and tried with several block sizes with 8 machines.
> At least with the test scene I used a block size of about 17 lines gave a
> good result.
> The test image with antialiasing 0.1 takes about 15.5 minutes to render
> with one computer and 2.25 minutes to render with 8 computers. Without
> antialiasing it takes 6 minutes with one computer and 55 seconds with 8.
>
> If anyone is interested in the script, I can post it here. It has several
> limitations (for example it's made for zsh), but someone can get good ideas
> from it.
>
> --
> main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
> ):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
--
--------------------------------------------------------------------
Yann Ramin atr### [at] atrustrivalieeuorg
Atrus Trivalie Productions www.redshift.com/~yramin
Monterey High IT www.montereyhigh.com
ICQ 46805627
AIM oddatrus
Marina, CA
IRM Developer Network Toaster Developer
SNTS Developer KLevel Developer
(yes, this .signature is way too big)
"All cats die. Socrates is dead. Therefore Socrates is a cat."
- The Logician
THE STORY OF CREATION
In the beginning there was data. The data was without form and null,
and darkness was upon the face of the console; and the Spirit of IBM
was moving over the face of the market. And DEC said, "Let there be
registers"; and there were registers. And DEC saw that they carried;
and DEC seperated the data from the instructions. DEC called the data
Stack, and the instructions they called Code. And there was evening
and there was a maorning, one interrupt...
-- Rico Tudor
William Safire's Rules for Writers:
Remembe
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Yann Ramin <atr### [at] atrustrivalieeuorg> wrote:
: Whats wrong with using an MPI version of POV-Ray?
I always download, compile and use regularly the latest version of megapov,
using its features. Thus, it's easier to make an external script to distribute
the rendering than trying to merge two different povray patches (which might
be impossible without weeks of hard work even knowing well povray source
code programming, which I don't).
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
... and exactly for the reason you explained about MegaPOV,
and in my case for other patches too !
I'd be glad if you post your work here.
What's the main differences between zsh and sh/csh ? Do you
make use of particular features of this shell I've never heard about ?
Thanks !
*** Nicolas Calimet
*** http://pov4grasp.free.fr
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Nicolas Calimet <pov### [at] freefr> wrote:
: What's the main differences between zsh and sh/csh ? Do you
: make use of particular features of this shell I've never heard about ?
Zsh (and other shells like bash) has many built-in features that makes
many things a lot easier to do. For example math:
% echo $[1+2*3]
7
% let A=1+2*3
% echo $A
7
You can achieve the same thing in sh using the bc program, but it's more
heavy and takes more resources (you have to start an external program instead
of just calculating it inside the shell itself).
Here is the script itself. It's not necessary that zsh is your default shell
since the script itself is started with zsh (as long as you have it installed
in /bin/zsh).
You will probably have to modify the 'POVEXEC=...' line to point at the
correct location, as well as the 'HOSTS=...' line (and 'HOSTCNT' accordingly).
Some requirements for the script to work:
- You can login to all the hosts mentioned in the HOSTS line with a simple
rsh (without prompting a password). This usually works only in a local
network (ie. you usually can't use this to spread the rendering around
the world). You can change rsh to ssh if you like, as long as it works
in the same way.
- All the hosts see the same file system. Again, this is usually only
possible in a local network system.
- The following programs are installed in the system:
grep, printf, rsh, sed, tail, test (named [), zsh.
And of course povray itself.
Most of those are "standard" unix programs (the only one I'm not sure of,
is printf).
Example usage (supposing that the script is named 'distribute'):
distribute test.pov 640 480 +a0.1
------8<-------8<---------8<---------8<--------8<----------8<-------8<-----
#!/bin/zsh
POVEXEC=$HOME/povray/xmegapov
ROWSPERHOST=17
HOSTSCNT=8
HOSTS=(sarakerttunen vuoripyy uppometso ukkometso peltokana karimetso preeriakana
nokikana)
### If this is a child process
if [ "$1" = "__SubProc__" ]
then
echo "### Subprocess at `uname -n` starting rendering. (`uptime | sed
's/^.*average: //'`)"
PART=$2
FILE=$3
WIDTH=$4
HEIGHT=$5
shift 5
let STARTROW=PART*ROWSPERHOST
while [ $STARTROW -le $HEIGHT ]
do
let ENDROW=STARTROW+ROWSPERHOST-1
echo `uname -n` rendering lines $STARTROW to $ENDROW
$POVEXEC -i $FILE $* -w$WIDTH -h$HEIGHT +sr$STARTROW +er$ENDROW -d -p -v +ft -o
ImagePart`printf "%05i" $STARTROW` >&/dev/null
let STARTROW+=ROWSPERHOST*HOSTSCNT
done
echo "### `uname -n` done."
exit
fi
### Else this is the main process
if [ "$3" = "" ]
then
echo "Usage: $0 <pov-file> <width> <height> [<additional pov options>]"
exit
fi
PART=0
for HOST in $HOSTS
do
rsh $HOST "cd `pwd`; $0 __SubProc__ $PART $*" &
PART=$[PART+1]
done
wait
echo "Joining image parts..."
if [ `echo $1 | grep -c '\.pov$'` = 1 ]
then
IMAGE=`echo $1 | sed 's/\.pov$/.tga/'`
else
IMAGE="$1".tga
fi
mv ImagePart00000.tga $IMAGE
for FILE in ImagePart?????.tga
do
tail +19c $FILE >> $IMAGE
done
rm ImagePart?????.tga
echo "Done."
------8<-------8<---------8<---------8<--------8<----------8<-------8<-----
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp wrote:
> % echo $[1+2*3]
> 7
>
> % let A=1+2*3
> % echo $A
> 7
>
> You can achieve the same thing in sh using the bc program, but it's more
> heavy and takes more resources (you have to start an external program instead
> of just calculating it inside the shell itself).
In ksh:
echo $((1+2*3))
7
A=$((1+2*3))
echo $A
7
K.K.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Kari Kivisalo <kar### [at] kivisalonet> wrote:
: In ksh:
: echo $((1+2*3))
: 7
: A=$((1+2*3))
: echo $A
: 7
Those seem to work in zsh as well :)
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp wrote:
> If anyone is interested in the script, I can post it here. It has several
> limitations (for example it's made for zsh), but someone can get good ideas
> from it.
>
I'd love to see it. I might try doing a bash version. Post 'er up!
--
Joseph Dunn <jdu### [at] gmxnet>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Joseph Dunn <jdu### [at] gmxnet> wrote:
: I'd love to see it. I might try doing a bash version. Post 'er up!
I posted it in a previous article in this same thread.
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|