"The CU2CL (CUDA-to-OpenCL) translator is implemented as a Clang Tool.
The tool interface allows a single invocation of CU2CL to translate all
the CUDA source files that make up a complete, fully-linked executable,
rather than performing a single invocation for each translation unit.
CU2CL utilizes Clang's CUDA front-end to perform preprocessing, parsing,
and abstract syntax tree (AST) generation. It then makes use of a
number of Clang's libraries throughout the translation process. These
libraries provide core functionalities to the translator like file
management (Basic), AST traversal and information retrieval (AST), the
tool interface (libTooling), preprocessor token access (Lex), and
rewriting mechanisms (Rewrite/Replacements). By utilizing these
libraries, a robust CUDA-to-OpenCL translator was realized in just over
4000 lines of code.
CU2CL performs a translation process we refer to as "AST-Driven, String
Based Translation". This process uses the AST generated by Clang to
identify sections of source code that contain CUDA structures that need
to be translated. Once such a structure is identified, the translator
recurses into each of the individual components of the structure to look
for further sub-structures that may need translation. Once all
sub-structures are checked, the translator performs highly-localized
string-based rewrites of the CUDA structures from the bottom up.
CU2CL is a work-in progress academic prototype translator that endeavors to provide translation of many of the most frequently used CUDA features. However, CUDA is a large, moving target and CU2CL may not support all syntax and API elements of the current CUDA specification.
Currently it targets OpenCL as the output standard. Further it aims to provide an easily-maintained translated source by preserving formatting and developer comments from the original CUDA, as well as injecting searchable comment tags for untranslated structures. (These are intended to aid manual post-translation intervention.)
The tool translated both host- and device-side code, generating separate families of output files suitable for a standard C++ compiler (*-cl.cpp/h files), as well as an OpenCL kernel compiler (*-cl.cl files). The majority of supported translations are focused on core Runtime API calls for memory, device, thread, stream, and event management as well as the CUDA C-style kernel invocation and full kernel function translation.
This bleeding-edge release currently has limited or no support for several features including (but not limited to):
CUDA Textures and Surfaces
CUDA/OpenGL Interoperability
C++ Templates in kernel code
CUDA Driver API
CUDA Runtime API features newer than 3.2
CUDA Kernel features newer than 3.2
Precompiled CUDA libraries
Many of these features are supportable in OpenCL but have not been necessitated by the applications of interest that CU2CL has been provisioned for. Pull requests to add or improve support for the one-to-one mappings that exist are always appreciated."
https://github.com/vtsynergy/CU2CL
http://chrec.cs.vt.edu/cu2cl/
No comments:
Post a Comment