The FortCUDA project seeks to generate CUDA bindings in F95/2003 using the Fortran 2003 ISO_C_BINDINGS module.
It is intended to give near native call syntax to the CUDA SDK in Fortran 2003. Currently,
most Fortran compilers are supporting the ISO_C_BINDINGS module.
Contents:
- News
- Bindings and Status
- Miscellaneous Information
News
Use git!
Did you know that our develop branch in the repository has the latest (maybe not stable but almost always is)
version of the FortCUDA development? We just released a new version which is far more flexible
and far more useful than the original release on Sourceforge.
See this Sourceforge page to learn more about git'ing FortCUDA!
|
A new release is stirring
Content has been reorganized in the repository to more adequately
reflect our new capabilities --- automatic file parsing. Because the headers for a 32-bit and 64-bit system
are different we will eventually be totally separating the source and builds thereof. We apologize for the
current lack of documentation on the automatic parsing. Hopefully that will come up soon, but smart folks can
probably use the --help flag to scan through the arguments. There is also a Makefile in the project which should
show some examples.
|
What Bindings Exist?
The FortCUDA project mostly consists of a very basic module that contains appropriate bindings
for most of the CUDA function calls found in cuda.h and cuda_runtime.h. This is not necessarily
complete, but is quite comprehensive. The file parsing capability is provided as part of the
distribution and has been used to generate wrappers around functions from a few projects.
Specific to CUDA, wrappers have been generated for cuda.h and cuda_runtime.h and are included
in the FortCUDA library. In addition Fortran modules have been generated for cublas.h and cufft.h,
but are still being checked for accuracy. Theoretically the FortCUDA_File_Parser.py script can be
used on any C header file, and, providing our grammars are adequate, will produce a 90% solution to
wrapping the enums, strucs, and functions.
- We have developed a set of grammars (kept in the Blockit/PyF95++ project for reusability)
which can be used to parse out the cuda.h and cuda_runtime.h files. The results are not perfect,
but with a small file with near Fortran syntax we are able to automatically recitify many of the things that
simply cannot be parsed --- e.g. C does not have the notion of "intent" which makes it difficult for
the parser to determine if it needs the "value" attribute.
- Preliminary parsing of cublas.h and cufft.h has been accomplished and the interface looks "good". We need
to begin developing unit-tests which can ensure proper functionality of the interface. If anyone
has reasonably simple examples, we would love to translate/have/ensure proper working of them.
- Along a similar strain, we are building parsing capability to automatically generate
Fortran interfaces to kernels written in C.
- The parser has been fixed up a bit, and can now run on the CGNS project. The results
are not perfect mainly because of where CGNS has information (there are inconsistencies between
the C version of the header and the Fortran 77 version of the header). These issues are
being worked, and the result will no doubt be a better tool with more capabilities. It shall
also lead to a cleaner interface than the dastardly F77 interface that comes with the project
--- an interface which redefines "Integer" rendering it useless to programmers who use a
Fortran 90 or higher compiler (at least the one I use complains if I try to declare an integer
after inclusion of their header (and for good reason!)).
Miscellaneous
Twenty years after the introduction of the Fortran 90 standard, many in the scientific and
engineering communities still fear it. My word, not having to create crazy equivalences
and call C functions to allocate memory... preposterous!
Appearance of other sites in this section does not constitute endorsement by the authors
of FortCUDA. We do however, heartily appreciate their efforts to use standard methods to
integrate Fortran and C projects and we applaud them for not creating nightmarish, self-managed,
unmaintainable code bases just because people don't want to move from F77 to F2003/8.
Additional information on wrapping C calls with Fortran can be found at some of the following
sites. Because the Fortran 2003 standard supports interoperability with C, and especially because
all compilers now have very good support for this, it is inappropriate for programmers to hand-craft
their own interoperability code (i.e. preprocessing flags based on machine architectures and lots of
complicated code to manage).
|
|