Multithreaded LIGHT & VIS

I decided to take a look at the LIGHT and VIS source today and see what would be involved with getting them to work multithreaded. I knew that id had put the code in there for their Alpha machines but that it was disabled for everyone else. It turns out the code was almost fine for OSX except for some function names I had to fix up and a tiny bit of code refactoring.

But the end result is awesome! It works!

Some sample timings I took:

DM4
Before:
LIGHT = 1 second
VIS = 8 seconds

After:
LIGHT= 1 second
VIS = 5 seconds

Cool, but not really all that exciting right? Look at this:

START
Before:
LIGHT = 14 seconds
VIS = 49 seconds

After:
LIGHT = 7 seconds
VIS = 35 seconds

That’s a 50% speed up for LIGHT and a 29% speed up for VIS!

Another one:

E1M2
Before:
LIGHT = 25 seconds
VIS = 37 seconds

After:
LIGHT = 13 seconds
VIS = 25 seconds

About the same gains. So it looks fairly linear in nature. Awesome!

One thing to note here is that this is with 2 threads. I have code in the utilities to detect how many CPUs or Cores you have and it uses that number of threads. Using more than that number would be inefficient and using less would be silly. For example, I have a dual core processor so I get 2 threads. If you had one of those new 8 core monstrosities, you would get 8 threads! I would love to see some numbers on those machines.

At any rate, this will be in the 0.8 release of ToeTag which will be along pretty soon. I want to add a few more things before I call it a new version.

You’ll know when you have the multithreaded tools because your output log will have some new lines in it:

==========================================
LIGHT
==========================================

—– LightFaces —-
extra sampling enabled
74 entities read
Using multithreading (2 threads)
lightdatasize: 60932
0 switchable light styles
1.0 seconds elapsed

==========================================
VIS
==========================================

—- vis —-
testlevel = 4
661 portalleafs
1900 numportals
Using multithreading (2 threads)
average leafs visible: 157
c_chains: 3088511
visdatasize:27319 compressed from 54863
30.0 seconds elapsed

Soon!

EDIT: Interested in the source code for these utilities? Click here!

6 Responses to “Multithreaded LIGHT & VIS”

  1. bambuz Says:

    Extremely good!
    (Remember folks, this is still no reason not to use vis blocking in your maps)

  2. Warren Says:

    Hell, if anything, this is reason to have better VIS blocking since it’ll compile quicker!

  3. [jimbo] Says:

    What source code did you use as a base for this?
    Can you send me the source code for the working threads light and vis?

  4. Warren Says:

    I just went off the base tool source that id released. Most of the problem was incorrect function names. I cleaned up the naming and the code a little bit and it worked.

    I’ll send you the source though, no problem.

  5. gm Says:

    Try doing 2 threads per core and see if you get any more speedup - a lot of processes consider this to be the optimum.

  6. Warren Says:

    Well, I experimented a lot, believe me. For LIGHT and VIS it makes no difference if you add additional threads. Maybe an additional savings of a second or so on a really large map but it’s not really worth it.

Leave a Reply