# Heat 2D example in Cuda by Example I can't change the speed parameter

Hello, I hope some folks can shed some light on what is going on. So I am going through the book Cuda by Example and in chapter 7 they have a code for a basic form of the 2D heat equation. So I run the code it seems fine but slow. So I decide to change the SPEED variable, which is set to .25f to something bigger to speed things up and I get craziness when I run it. I can’t even change it to .251f without some really weird things being displayed. I’ve attached the code I was running if anyone would be so kind as to try for themselves. I attached the entire cuda by example folder but the code I am running is in the chapter07 folder and it is the heat.cu code, not the heat2d.cu one as the title of this thread states(sorry). The SPEED variable is at the very beginning. Thanks a ton for the help. I was planning on using the code to demonstrate CUDA and maybe add somethings but this kind of spooked me. I thought it was really weird. Also my computer doesn’t have a GPU that will support double precision, is this the reason for the weirdness?
cuda_by_example.zip (450 KB)

It’s not weird at all, but as expected instead - you may wish to check on convergence criteria of explicit finite difference schemes.

Hello sagrailo, thanks for the reply. Could you elaborate on why you think it should be expected?

It looks like what the book uses is a iterative method to update each point for a time step, so it seemed weird to me that you would get that kind of output. I thought maybe it had to do with getting a negative number for a value since I raised the speed coefficient. But I’ll try to poke around about what you said.

So after looking into it, sagrailo you are absolutely right. I didn’t realize what the speed variable really was in their code(and btw, using speed to name it is a bit misleading). It is actually the value alpha*delta(t)/delta(x)^2 and by Von Neumann analysis, this must be less than or equal to 1/4. So there you have it. Thanks again.

Sorry to bring this back but I have another question.

When you compile and run the 2D heat example, you are not able to see the entire object. You only see the center area of it. When I changed the heat source to the upper right hand corner, it went completely off the screen. I tried to set the dimension DIM to 800 instead of 1024 but it just gave me a smaller window with portions still off the screen. Anybody know how to make the entire image visible? Thanks again!