Q3Map3 - Discussion and Development
Re: Q3Map3 - Discussion and Development
what new features do you plan on implementing? or do you just plan on rewriting the code so its smoother?
Im actually confused, what are you intentions with q3map3? :>
Im actually confused, what are you intentions with q3map3? :>
[url=http://gotdelirium.com/][img]http://www.gotdelirium.com/stuff/gdd.png[/img][/url]
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
I'm building on the existing q3map2 code to add the ability to compile using an OpenCL Device (this can be a GPU, CPU, PhysX chip, etc.. or any combination of).
This will allow compile times to be decreased (hopefully) by quite a bit.
This will allow compile times to be decreased (hopefully) by quite a bit.
Re: Q3Map3 - Discussion and Development
Sweet
I'll be following progress for sure

I'll be following progress for sure

[url=http://gotdelirium.com/][img]http://www.gotdelirium.com/stuff/gdd.png[/img][/url]
Re: Q3Map3 - Discussion and Development
Yeah, keep on working on that, I believe that could turn out really sweet (even if most of what the screenshots above show went way over my head
)!

If you are caught on a golf course during a storm and are afraid of lightning, hold up a 1-iron. Not even God can hit a 1-iron.
-Lee Trevino, golfer who actually has been struck by lightning.
-Lee Trevino, golfer who actually has been struck by lightning.
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
Working on getting a test function working. Should have it done before my next class.
In a nutshell, the above screenshots are a -light compile with q3map2 with verbose information giving me status reports on the following:
- Does an OpenCL-enabled device exist?
- Can we use the device if it does exist?
- Can we get some memory to load the opencl functions in to?
- Are the functions we're reading to memory being read correctly?
Everything's checking out ok. Now it's getting the functions working with some of the data and creating the right results that I need to work on
Then the task of porting q3map2 code over to the gpu begins. Things'll start gettin' nasty at that point for sure.
My main issue right now is that a lot of the algorithms ("method for solving a problem" for the non-mathematically inclined) are recursive (meaning they use themselves in calculating results (ie. a factorial equation such as function(number) = number * function(number - 1) ))
The problem with this is OpenCL doesn't allow recursion. At all. So I need to rewrite the algorithms to be non-recursive which is going to take some thinking.
Disclaimer: The "factorial" recursive equation example isn't a true factorial equation and will give you gas if you try to run it.
In a nutshell, the above screenshots are a -light compile with q3map2 with verbose information giving me status reports on the following:
- Does an OpenCL-enabled device exist?
- Can we use the device if it does exist?
- Can we get some memory to load the opencl functions in to?
- Are the functions we're reading to memory being read correctly?
Everything's checking out ok. Now it's getting the functions working with some of the data and creating the right results that I need to work on

Then the task of porting q3map2 code over to the gpu begins. Things'll start gettin' nasty at that point for sure.
My main issue right now is that a lot of the algorithms ("method for solving a problem" for the non-mathematically inclined) are recursive (meaning they use themselves in calculating results (ie. a factorial equation such as function(number) = number * function(number - 1) ))
The problem with this is OpenCL doesn't allow recursion. At all. So I need to rewrite the algorithms to be non-recursive which is going to take some thinking.
Disclaimer: The "factorial" recursive equation example isn't a true factorial equation and will give you gas if you try to run it.
Last edited by Silicone_Milk on Mon Aug 30, 2010 6:41 pm, edited 1 time in total.
- roughrider
- Posts: 355
- Joined: Mon Jul 22, 2002 7:00 am
Re: Q3Map3 - Discussion and Development
Gl. I hope to be able to use this before I turn 50 

Team *A51* Q3 & QL
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
Added in error reporting. Bad OpenCL kernels will cause q3map3 to fall back to using the old cpu-based code and print the build errors out to a log file.
[lvlshot]http://www.siliconemilk.com/music/error_report.jpg[/lvlshot]
[lvlshot]http://www.siliconemilk.com/music/error_report.jpg[/lvlshot]
Re: Q3Map3 - Discussion and Development
Sounds like you're about to embark on a journey into the lands of HurtSilicone_Milk wrote:The problem with this is OpenCL doesn't allow recursion. At all. So I need to rewrite the algorithms to be non-recursive which is going to take some thinking.

-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Q3Map3 - Discussion and Development
What if f() calls g() and g() calls f()? Does the compiler see that as recursion?
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
That's an excellent question, misantropia.
I will have to see. But first, I must find out why the OpenCL build log is suddenly spewing nonsense as if I'm outputting random locations in memory and not from the buffer I've *been* outputting from.
The thing that's making me scratch my head is that rolling back a revision to when the code produced the above screenshot doesn't fix the problem.
We'll see what Valgrind has to say about these shenanigans.
EDIT: Rather embarassing, but I figured it out without valgrind (too lazy to add the new ocl libraries to scons to build a linux version of the program....). It turns out the error was a rather stupid one - double-dereferencing
Fixed that minor issue and the error logs work once more. I just wonder when I added that in to the program
Anyways, I have a new goal for tonight/tomorrow morning - .cl file parser to automatically allocate memory for kernel arguments.
When you write a kernel for OpenCL you also need to allocate a buffer of memory for EACH argument you want to pass in to the function. It's a tedious task to have to do it every time you write a new function so I'm going to make the program do it for me.... after I upload an image of a test kernel running in q3map3 using hard-coded arguments
Progress is good at least!
I will have to see. But first, I must find out why the OpenCL build log is suddenly spewing nonsense as if I'm outputting random locations in memory and not from the buffer I've *been* outputting from.
The thing that's making me scratch my head is that rolling back a revision to when the code produced the above screenshot doesn't fix the problem.
We'll see what Valgrind has to say about these shenanigans.
EDIT: Rather embarassing, but I figured it out without valgrind (too lazy to add the new ocl libraries to scons to build a linux version of the program....). It turns out the error was a rather stupid one - double-dereferencing

Fixed that minor issue and the error logs work once more. I just wonder when I added that in to the program

Anyways, I have a new goal for tonight/tomorrow morning - .cl file parser to automatically allocate memory for kernel arguments.
When you write a kernel for OpenCL you also need to allocate a buffer of memory for EACH argument you want to pass in to the function. It's a tedious task to have to do it every time you write a new function so I'm going to make the program do it for me.... after I upload an image of a test kernel running in q3map3 using hard-coded arguments

Progress is good at least!

Re: Q3Map3 - Discussion and Development
If recursion isn't allowed, I'm sure the compiler or runtime environment will throw an exception when one function appears twice in the call stack.^misantropia^ wrote:What if f() calls g() and g() calls f()? Does the compiler see that as recursion?
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Q3Map3 - Discussion and Development
Depends, probably.
Compilers have a hard time optimizing tail recursion and that's the easiest, most obvious special case of recursion. I suppose the only way to reliably detect it, is to inline all function calls and wait until you hit a limit. I wouldn't put it past the OpenCL compiler to actually do that.
Compilers have a hard time optimizing tail recursion and that's the easiest, most obvious special case of recursion. I suppose the only way to reliably detect it, is to inline all function calls and wait until you hit a limit. I wouldn't put it past the OpenCL compiler to actually do that.
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
Small hiccup in kernel loading code fixed. The OCL compiler should be happy with the changes now and stop ignoring the other .cl files.
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
Results of the first test kernel are in!
At first I was worried because the GPU seemed slower than the CPU in this simple calculation but it turns out I totally spaced out and forgot to increase the workload for the CPU when I increased the work for the GPU :P
Here's a shot of the results of adding 4096 pairs of floating point numbers.
[lvlshot]http://www.siliconemilk.com/music/success.jpg[/lvlshot]
Notice how the GPU is around 2x faster on such a simple operation. This is reading and writing to global memory which is an extremely slow process for the videocard to do.
For more complicated functions, I'll be able to make use of local memory to cache data to limit the number of global memory accesses so performance should increase quite a bit!
EDIT:
Doubling the amount of floats being added from 4096 to 8192 results in the GPU being 3.8x faster as opposed to only 2x faster with half the data.
[lvlshot]http://www.siliconemilk.com/music/success2.jpg[/lvlshot]
For giggles, I doubled the data once again to 16384 pairs of floats and saw the GPU end up being ~7x faster. It's good because that behavior was expected
Didn't come anywhere close to my "1000x performance increase!" claim (which was totally pulled out of my ass) but then again, can you argue with 7x faster compilation times?
Edited the numbers for Eraser. He's right, those rounding issues are just too severe to ignore
I'll continue thinking it's a 14x increase in my head though 
At first I was worried because the GPU seemed slower than the CPU in this simple calculation but it turns out I totally spaced out and forgot to increase the workload for the CPU when I increased the work for the GPU :P
Here's a shot of the results of adding 4096 pairs of floating point numbers.
[lvlshot]http://www.siliconemilk.com/music/success.jpg[/lvlshot]
Notice how the GPU is around 2x faster on such a simple operation. This is reading and writing to global memory which is an extremely slow process for the videocard to do.
For more complicated functions, I'll be able to make use of local memory to cache data to limit the number of global memory accesses so performance should increase quite a bit!
EDIT:
Doubling the amount of floats being added from 4096 to 8192 results in the GPU being 3.8x faster as opposed to only 2x faster with half the data.
[lvlshot]http://www.siliconemilk.com/music/success2.jpg[/lvlshot]
For giggles, I doubled the data once again to 16384 pairs of floats and saw the GPU end up being ~7x faster. It's good because that behavior was expected

Didn't come anywhere close to my "1000x performance increase!" claim (which was totally pulled out of my ass) but then again, can you argue with 7x faster compilation times?

Edited the numbers for Eraser. He's right, those rounding issues are just too severe to ignore


Last edited by Silicone_Milk on Fri Sep 03, 2010 7:52 am, edited 1 time in total.
Re: Q3Map3 - Discussion and Development
Nice, but your statistics are off.
The set of 4096 numbers is only 2.04 times faster and the set of 8192 numbers is 3.86 faster. You're comparing 0.01 to 0.07 which is a rather large rounding error
The set of 4096 numbers is only 2.04 times faster and the set of 8192 numbers is 3.86 faster. You're comparing 0.01 to 0.07 which is a rather large rounding error

-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
*waves Eraser off*
Let me dream, Eraser, let me dream.
Funny side story, I failed Chemistry due to my habit of rounding.
Let me dream, Eraser, let me dream.
Funny side story, I failed Chemistry due to my habit of rounding.
Re: Q3Map3 - Discussion and Development
Okay, okay, 7 times it is 
Good job nonetheless. Every bit of speed increase is welcome.

Good job nonetheless. Every bit of speed increase is welcome.
Re: Q3Map3 - Discussion and Development
I hate significant figures in Chemistry as well.
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
Re: Q3Map3 - Discussion and Development
Sig figs make me happy. Chem ftw.
[url=http://www.xfire.com/profile/vlnoheaven/][img]http://i105.photobucket.com/albums/m231/Lowerboy444/xfire.png[/img][/url]
[url=http://teameventhorizon.com/]Team Event -O- Horizon[/url]
[url=http://mapping.maverickservers.com/]NoGhost Map Making Competition 2 (June 2010)[/url]
[url=http://teameventhorizon.com/]Team Event -O- Horizon[/url]
[url=http://mapping.maverickservers.com/]NoGhost Map Making Competition 2 (June 2010)[/url]
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
Refactoring some code so the gpu demonstration isn't hard-coded.
Also made my server upset and raped the permission settings on it resulting in being locked out on all accounts. This meant I couldn't fix the mistake from the account I made it in
(Never ever ever EVER execute 'sudo chmod o-rwx /')
It was an easy fix though. Just had to be creative.
Also made my server upset and raped the permission settings on it resulting in being locked out on all accounts. This meant I couldn't fix the mistake from the account I made it in

(Never ever ever EVER execute 'sudo chmod o-rwx /')
It was an easy fix though. Just had to be creative.
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Q3Map3 - Discussion and Development
What in the world made you do that?
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
Was locking down some permissions on the "public" account for my server and wasn't thinking clearly about what I was doing.
By the way, ^misantropia^ are you able to establish an ssh connection to my server or does it time you out?
By the way, ^misantropia^ are you able to establish an ssh connection to my server or does it time you out?
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Q3Map3 - Discussion and Development
It times out (and has for a couple of days now). nmap says the port is filtered.
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
That's odd. A couple people have reported time-outs and others have gotten in with no problems.
I need to look in to that more. Thanks
I need to look in to that more. Thanks

-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Q3Map3 - Discussion and Development
Switching web hosts at the moment.
Working on fixing broken image links.
Working on fixing broken image links.