1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Main Page

From fortcuda

(Difference between revisions)
Jump to: navigation, search
(Getting started)
 
(16 intermediate revisions not shown)
Line 1: Line 1:
 +
Welcome to the FortCUDA project wiki. This page will help you get started using CUDA directly from Fortran with calls that look like native C and CUDA-C!
 +
 +
The purpose of this project is to provide automatically parsed and generated wrappers for Fortran 2003 that allow a user to call all necessary CUDA functionality from the comfort of Fortran. For now this does not eliminate the necessity to produce kernels in C, but it does allow interoperability with Fortran in a native, STANDARD fashion. As the project progresses, utilities will be developed to assist in automatically wrapping those kernels, and maybe one day translating Fortran code! (Note: As I am not paid for this activity you should not hold your breath, have detailed dreams about application performance improvement with no work, or quit your job thinking you'll use FortCUDA to be the next software guru. If that is what you want, check into the only Fortran compiler with built-in CUDA support.)
 +
 +
== Installing ==
 +
The original release was simply a directory with an example and a CUDA.F90 file which contained the interface definitions (v1.0.0). We've become slightly more complex, as we do intend to grow the project and so have transitioned on our develop branch to building a library. If you've downloaded version 1.0.0, you need simply untar the file. If you are working with a later version you should be able to quickly build and install the library.
 +
 +
In the main directory there is a Makefile which specifies most of the pertinent variables for you, including some compiler flags. You will need to override some variables on the command line if you are not satisfied with the default values. If you are building on a 32-bit machine, you should simply be able to execute
 +
  make library
 +
or on a 64-bit machine
 +
  make ARCH=64 library
 +
  make COMPATIBILITY=-m32 library
 +
Note that the ARCH variable is used really only to separate the 32-bit from the 64-bit libraries right now. It is mostly used in the example for linking and ensuring the appropriate libraries are included. If you want to build a 32-bit library on a 64-bit machine, it is necessary to use the -m32 flag with the compiler and with nvcc (again, used in the example).
 +
 +
== Examples ==
 +
We will be posting examples as available and will also include them in the distribution release. [[:Category:Examples|Click here to go to the examples page]]
 +
 +
== More about the Parser ==
 +
The FortCUDA library is developed by parsing some of the headers in the CUDA distribution.  The parser uses PyParsing grammars developed for the [http://blockit.sourceforge.net BlockIt/PyF95++ project] and therefore requires the latest version of [https://sourceforge.net/projects/blockit/develop BlockIt from the repository].  Items parsed include very simple #defines, typedefs, structs, enums, and function prototypes.  After things are parsed and matches are stored in an ordered list, a resolution dictionary is built which indicates how specific C types will be translated into Fortran types.  Finally, the information is then translated into Fortran ISO C bindings and dumped into modules.  Nearly everything can be handled automatically, but we have found a few issues which are detailed below.
 +
 +
* The parser gets us 95% of the way to a solution.  As such, if you find any problems, PLEASE let us know by posting in the bug tracker.  Unless we have call to use a function, it will not be guaranteed to be parsed or tested (and if it is tested, it may be quite poorly) because there are far too many.
 +
* Grammar writing is tough.  Very tough.  With a language like C it doesn't take a rocket scientist to figure out that it's a pain in the rear.  So if you try to parse something and it doesn't work -- LET US KNOW.  We are getting a little better.
 +
* Since C does not have the notion of "intent" on function arguments, it is impossible to know what is coming in and what is going out.  This is especially painful when dealing with Memcpy functions, which have arguments of void pointers but actually expect pointers to pointers.  To combat this we have a system which allows us to specify additional declaration attributes on various arguments of functions.  It is quite rudimentary right now, but does what we need it to do.
 +
 +
<!--
<big>'''MediaWiki has been successfully installed.'''</big>
<big>'''MediaWiki has been successfully installed.'''</big>
Line 8: Line 33:
* [http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]
* [http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]
-
* Project Logo
+
== Project Logo ==
-
To set your project logo simply click on the following Logo image and replace with your own project PNG image.
+
Click on the following image to upload a new version of the PNG logo image for your project:
 +
 
 +
[[Image:MediaWikiSidebarLogo.png]]
 +
 
-
[[Image:Logo.png]]
+
-->

Current revision as of 04:14, 19 December 2010

Welcome to the FortCUDA project wiki. This page will help you get started using CUDA directly from Fortran with calls that look like native C and CUDA-C!

The purpose of this project is to provide automatically parsed and generated wrappers for Fortran 2003 that allow a user to call all necessary CUDA functionality from the comfort of Fortran. For now this does not eliminate the necessity to produce kernels in C, but it does allow interoperability with Fortran in a native, STANDARD fashion. As the project progresses, utilities will be developed to assist in automatically wrapping those kernels, and maybe one day translating Fortran code! (Note: As I am not paid for this activity you should not hold your breath, have detailed dreams about application performance improvement with no work, or quit your job thinking you'll use FortCUDA to be the next software guru. If that is what you want, check into the only Fortran compiler with built-in CUDA support.)

Installing

The original release was simply a directory with an example and a CUDA.F90 file which contained the interface definitions (v1.0.0). We've become slightly more complex, as we do intend to grow the project and so have transitioned on our develop branch to building a library. If you've downloaded version 1.0.0, you need simply untar the file. If you are working with a later version you should be able to quickly build and install the library.

In the main directory there is a Makefile which specifies most of the pertinent variables for you, including some compiler flags. You will need to override some variables on the command line if you are not satisfied with the default values. If you are building on a 32-bit machine, you should simply be able to execute

 make library

or on a 64-bit machine

 make ARCH=64 library
 make COMPATIBILITY=-m32 library

Note that the ARCH variable is used really only to separate the 32-bit from the 64-bit libraries right now. It is mostly used in the example for linking and ensuring the appropriate libraries are included. If you want to build a 32-bit library on a 64-bit machine, it is necessary to use the -m32 flag with the compiler and with nvcc (again, used in the example).

Examples

We will be posting examples as available and will also include them in the distribution release. Click here to go to the examples page

More about the Parser

The FortCUDA library is developed by parsing some of the headers in the CUDA distribution. The parser uses PyParsing grammars developed for the BlockIt/PyF95++ project and therefore requires the latest version of BlockIt from the repository. Items parsed include very simple #defines, typedefs, structs, enums, and function prototypes. After things are parsed and matches are stored in an ordered list, a resolution dictionary is built which indicates how specific C types will be translated into Fortran types. Finally, the information is then translated into Fortran ISO C bindings and dumped into modules. Nearly everything can be handled automatically, but we have found a few issues which are detailed below.

  • The parser gets us 95% of the way to a solution. As such, if you find any problems, PLEASE let us know by posting in the bug tracker. Unless we have call to use a function, it will not be guaranteed to be parsed or tested (and if it is tested, it may be quite poorly) because there are far too many.
  • Grammar writing is tough. Very tough. With a language like C it doesn't take a rocket scientist to figure out that it's a pain in the rear. So if you try to parse something and it doesn't work -- LET US KNOW. We are getting a little better.
  • Since C does not have the notion of "intent" on function arguments, it is impossible to know what is coming in and what is going out. This is especially painful when dealing with Memcpy functions, which have arguments of void pointers but actually expect pointers to pointers. To combat this we have a system which allows us to specify additional declaration attributes on various arguments of functions. It is quite rudimentary right now, but does what we need it to do.


Personal tools