Newbie CUDA and CFD Some questions about CDA programming

Hello everyone,

I am a student and very new to CUDA.

For my thesis I made some calculations with a CFD program written in Fortran.
I have read all the threads here about CUDA and Fortran and now I unsure what to do.

First, there are two versions of the programm, a single CPU version and a multi-cpu (mpi).
So the first question is, what version to choose to modify?

Would there be any speed advantage by using the original Fortran code?
Should I try to change the code to C?
Or would you say just wait until CUDA supports Fortran?

At the moment I am using the CUDA Wizard with VS2005, the program is called FDS from NIST. Source files can be found here:
[url=“GitHub - firemodels/fds: Fire Dynamics Simulator”]GitHub - firemodels/fds: Fire Dynamics Simulator

Thank you all

Mirko

The mpi version is of no help when porting to cuda. The cuda programming

model is very different from mpi.

You can keep your Fortran code for problem setup (e.g. setting up your

mass matrix, etc.). Then call the cuda code (in C) from Fortran to do the

time stepping.

Sounds good.

Are there any examples how to do that? Everytime I search for cuda and fortran I got thousands links, that cuda should support fortran soon but no example how to do it :(

I believe there is an example on the CUDA zone.
You can do now: call CUDA code (written in C) from Fortran
You can do in the (near) future: write CUDA code in C++ & Fortran

There is indeed an example of calling CUDA code from Fortran, but every call to the CUDA function involves allocating memory on the GPU, transferring the Fortran array to the GPU, calling the kernel, and then reading the results back. That’s a lot of back and forth transferring of data for a CFD simulation.

I’m just now finishing up porting a Fortran CFD simulation to CUDA. It’s quite a lot of effort to get everything from Fortran to C and CUDA and to verify that everything works as it should. Given the size of the codebase in the original post, I would estimate at least 4 months would be required to port it.

StickGuy, are you at TN? (I am working at delftechpark)

Anyhow, at NVISION a university announced a Fortran library for CUDA called Flagon. Maybe this helps in porting these kinds of code over: [url=“Flagon download | SourceForge.net”]http://sourceforge.net/projects/flagon/[/url]

After a quick peak at the FLAGON example code, it looks like it provides Fortran bindings for CUDA instead of just ways to call CUDA functions from Fortran. That would indeed make the process a lot easier, but it would still be quite a lot of effort to fully transition from a plain Fortran program to a CUDA accelerated one, especially since that simulation is 20,000+ lines of Fortran.

I’m in EWI actually, although the simulation I’m working with comes from the thermal and fluids group and TNW.

Hey, there is no such thing as a free lunch ;) But the impression I got at NVISION is that Flagon is indeed a fast way to get a first speedup when porting a lot of legacy fortran code. It will not let you get maximum possible performance, but still it is a lot easier than converting to C in a lot of cases.

Ah cool, I will tell my old vakgroep that there are now people doing CUDA at TUD.

Thank you all, four months seems a bit to long to me, and I assume this is when you are good at programming.

I’ll think I’ll try it in my free time but not for my thesis.

Flagon seems interesting, I’ll take a look at this.

I think being good at programming is of lesser importance. It all starts to work out when you start to understand parallel programming. Me for example, I make beginner mistakes in C, but I am now quite able to write a parallel program (don’t get scared, after almost a year of CUDA).

The challenge is not in programming, the challenge is in thinking parallel. Although, what I understood from Flagon, it is much less the case for that middleware layer.