My DCOM and Multi-CPU enabled Fractal Generator v2.43
Description
This is a fractal Generator. It uses separate modules (servers) for the calculation of a particular kind of fractal. These servers are started via COM/DCOM -- they can run on the same machine or on other machines in the network. The servers are independent of the client using them. More servers with different kind of fractals may be added later.
Contained files
- fractal.exe
- The client application to be used to display fractals.
- mandelps.dll
- A proxy DLL needed to marshal interface calls to an object residing inside a different process not necessarily on the same machine.
- mandel.exe
- A server application to calculate an ordinary mandelbrot set.
- mandel4dim.exe
- A server application to calculate a slightly changed mandelbrot set. It is using 4-dim hypercomplex numbers instead of 2-dim ordinary complex numbers.
- mandel8dim.exe
- A server application to calculate a slightly changed mandelbrot set. It is using 8-dim hypercomplex numbers instead of 2-dim ordinary complex numbers.
- julia.exe
- A server application to calculate a julia-set.
- newton.exe
- A server application to calculate a different kind of fractal resulting out of applying the Newton method to the nonlinear equation z^3 + 1 = 0.
- expression.exe
- A server application to calculate a of fractal whose equation can be entered.
- register.bat
- Call to register the provided servers and proxy DLLs.
- unregister.bat
- Call to un-register the provided servers and proxy DLLs.
- readme.htm
- This file.
normal Installation for single machine use
copy/unpack the provided files into a directory of your choice
register the proxy DLL mandelps.dll by executing:
regsvr32 mandelps.dll
regsvr32.exe should be located inside your system directory.
register the servers by executing:
mandel /regserver
mandel4dim /regserver
mandel8dim /regserver
julia /regserver
newton /regserver
Of course one can also use the provided
register.bat
to do all this (except unpacking and copying).
Server installation -- enable others to exploit the unused CPU time of your machine
I tested this, using NT machines as servers and as clients. I did not test this using Windows9x.
To enable others to exploit the CPU power of your machine you have to perform the following additional tasks:
- all the points mentioned above in normal Installation for single machine use
- enabling DCOM on your machine -- I think this has to be done on the client machine as well
- start dcomcnfg
- select the "Default Properties" tab
- select "Enable Distributed COM on this computer"
- specifying who is enabled to use FractalEngine servers on your machine
- create a local group called e.g. fractal
- start user manager
- select in the main menu User-New Local Group
- give it a name (e.g. fractal)
- give it a description (e.g. members are allowed to use the fractal servers on my machine)
- add to this group the logins of the people you want to be able to use your machine -- ideally this are the people, which also allow you to use their machine in the same way. This should include you of course. Ideally this are network logins in contrary to local logins. I not test this using local logins.
- specify access permissions, launch permissions for all servers
- launch dcomcnfg
- select the applications tab
- doubleclick a FractalEngineFactory server (this has to be done for every single server)
- select the security tab
- select "Use custom access permissions" and press the matching edit button
- add the just created local group "fractal" to the access permissions
- select "Use custom launch permissions" and press the matching edit button
- add the just created local group "fractal" to the launch permissions
- repeat this for every single server
I'm sorry about all this clicking and selecting for every single server. If someone knows about a way on how to script the entire procedure, please let me know.
To use other machines, simply pass the names of these machines at the commandline to fractal.exe. As an example let's assume your network does contain 4 machines (including your own) called machine0, machine1, machine2 and machine3. Your machine is machine0. Then the commandline should look like this:
fractal.exe machine1 machine2 machine3
The servers are running with idle priority -- this means, that they only get CPU time if there is no process with normal priority which currently needs CPU time. Thus installing these servers and the usage of these servers by others does not degrade the responsiveness of your system. Most applications don't exploit idle priority, since it is erroneously considered as lowering performance. Since the servers are running with the very lowest priority in idle priority class, they even yield the CPU to processes started with "start /low" from the commandline. I think even screensaver run with higher priority and will block fractal servers.
If the one sitting in front of the machine is only using a well crafted editor, his machine is usually for more than 90% of the time idle.
The servers are not running all the time but only if someone is using them. Registration does not mean, that there is some server running all the time waiting until someone connects -- this task is done by DCOM for all DCOM applications. DCOM will startup the server is someone (with the matching permissions) tries to use them.
Uninstallation
Unregister all the servers and proxy dlls:
mandel /unregserver
mandel4dim /unregserver
mandel8dim /unregserver
julia /unregserver
newton /unregserver
unregister the proxy DLL:
regsvr32 /u mandelps.dll
delete the files
Of couse one can also use the provided
unregister.bat
to do all this (except deleting).
exploitation of Multi-CPU machines
The servers are calling some system call to get informed about the number of CPUs on your machine. They will start as many threads for every client as there are CPUs on your system.
How to use the client application
There is a single popup menu which appears when clicking with the right mouse button into the window. It provides menu items for
- Zoom In
Draw a zoom rectangle before. To draw a zoom rectangle press the left mouse button and keep it pressed while moving the mouse button. If you don't like the rectangle start again. This item will create a new window with the new fractal being calculated.
- Iteration methods
Shows all registered servers. Selecting one will create a new window with this iteration method being calculated.
- Iteration method parameters
Allows setting some parameter for the current selected iteration method. When the OK button is clicked a new window will be opened calculating the current fractal at the current coordinates with the new parameters. See parameters below.
- Save Bitmap ...
stores the calculated bitmap to disk.
- Save and Set as Current Wallpaper...
same "Save Bitmap", but also makes this the current wallpaper of your desktop.
- create new color set
creates a new color palette for the bitmap
- floating colors
toggles floating colors on or off
- bitmap size
changes the bitmap size for a new window and all its children. This is currently quite a hack, since I did not manage to set the maximum window size for bitmaps smaller than the screen size or to introduce scroll bars for bitmaps larger than the window size. Before entering a bitmap size please consider the amount of memory needed: 5byte/pixel (3 for bitmap and 2 for number of iterations -- to be able to change the color set). And please consider that doubling the number of pixels for both dimensions does result in 4times the amount of memory needed. There is definitely some compression needed (grin). But since during calculation the memory is only accessed in small pieces at a time, the swapping is only pretty strong at the beginning and one can quite easily keep working during a fractal is being calculated in the background.
- Color function
Allows the user to enter three functions for red, green, blue. The argument for every color function will be the color index (1…65535).
- About...
Fetches another bottle of beer.
- Things to be done
- The user should be able to save/load coordinates/parameters.
Usage of Idle priority
The servers are performing their calculation with priority idle. This means, that they don't get any CPU time if there is a different process with higher priority (and higher means here normal priority) which currently consumes CPU time. Thus it may happen, that the fractal calculation is not advancing at all if you're running another application which consumes much CPU time (like a compiler or a simulator or another fractal generator). I consider such applications as not cooperative, especially if they even use normal priority in case of their window does not own the focus.
Bugs fixed
Crash when creation of a Fractal Server object failed, e.g. because of invalid expression entered for the expression server -- fixed.
Multiple CPUs were not used -- fixed.
Crash when storing bitmap
Bitmap was not initialized to zero at the beginning. This may have caused pictures containing trash before being overwritten by the calculation. This bug did only occur on Windows9x as far as I know.
Problem on some Windows9x installations because of ATL.DLL was missing or a symbol in ATL.DLL was not available. Fixed by not using ATL anymore.
register.bat should now find regsvr32.exe also on Windows9x systems
zoom rectangle appeared on its own in a newly constructed window
In case of instantiation of a server on a remote machine fails, an error message is provided in the statusbar.
Servers will be only instantiated once in a process instead of for every window separately avoiding long waiting times for every window.
Window will only be made visible after all the initial stuff has been done.
Client should need considerable less CPU time. This is only important in case of using the server mode. The client should now be able to exploit some more servers.
Only 8 bits were used to pass the number of iterations resulting in images containing only 256 colors. Furthermore the color black may have been used as a normal color but not only to indicate no convergence.
Parameters
Mandel Fractal Method
Iteration boundary
This is the termination boundary to the power of 2. As you know the formula for mandelbrot is like that:
zn+1 = zn^2 + z0, with z = x + i*y.
Iteration is terminated if zn^2 is larger than this boundary. Larger boundary means higher number of iterations are necessary.
max. number of iterations
Maximum number of iterations. May be up to 65536-1. Useful numbers are in the range of 100..1000.
Julia
Uses the same parameters like Mandel and additionally
cx and cy
Formula used is
zn+1 = zn^2 + k, with k = cx + i*cy
Mandel4Dim
Uses the same parameters like Mandel and additionally
f and c. f and c are used to determine the mapping of the two dimensional start values into the other two dimensions. The hypercomplex number used is
z = a + i*b + j*(c + i*d), with i*i = - 1, and j*j = -i
a0 = x0
b0 = y0
c0 = f*x0 + c
d0 = f*y0 + c
Mandel8Dim
Uses the same parameters like Mandel and additionally
f and c. f and c are used to determine the mapping of the two dimensional start values into the other 6 dimensions. The hypercomplex number used is
z = a + i*b + j*(c + i*d) + k*{e + i*f + j*(g + i*h)}, with i*i = - 1, j*j = -i and k*k = -j
a0 = x0
b0 = y0
e0 = g0 = c0 = f*x0 + c
d0 = f0 = h0 = f*y0 + c
Newton
A smaller iteration boundary means higher number of iterations are necessary.
Expression
Calculates an expression to be entered by the user. The default expression matches a more complex mandelbrot. The expression entered gets passed two arguments: x[0] is the current complex iteration value. x[1] is the initial complex start value matching the coordinates of the point to be calculated. Currently it is not possible to use an equation, which is made up of more than one assignment. Means, intermediate results are not possible yet.
The expression engine used here will be featured in a separate page on my home page. It provides the following features:
- Calculation of complex and non-complex expressions of functions with multiple independent variables.
- Calculation of analytical derivatives vs. one of the independent variables. The analytical derivative is represented like an ordinary expression object, which in turn can be used like the one it derives from.
To be implemented:
- simplification of expressions
- Propagation of constant expressions.
- Common sub-expression elimination
- Intermediate results
- Multiple results (vector of functions)
- Compilation into machine code (sounds complicated but in fact is quite trivial)
About the hypercomplex numbers used
The hypercomplex number system used here is not a mathematically correct one. This is because of j*j == -i or k*k == -j does not create a new independent dimension, since the square root of -i (and the square root of the square root of -i) is well defined in the ordinary complex plane. But using this system does lead to interesting fractals and this is what we are looking for, isn't it?
Disclaimer
Use this software on your own risk! I cannot accept any responsibility for damages created directly or indirectly by the usage of this software.
Santa Clara, California, U.S.A, Sunday, February 27, 2000
Peter Foelsche