⬆️ ⬇️

Development in Java and OpenCL: The Road to the Clouds





This article discusses the use of the Java platform for development with OpenCL, the advantages and disadvantages of this approach. The combination of these technologies in software development in the future will allow to use the full power of cloud computing and OpenCL



Recently, the development of software for mass-produced computing devices with a high degree of parallelism is gaining popularity. These are modern multi-core processors with SIMD commands and video accelerators with support for GPGPU (General-purpose computations on GPU), devices combining a central and graphics co-processor on a single AMD Fusion crystal, as well as specialized coprocessors. Almost every type of device has its own command system, architectural features, and application development previously required the developer to know several programming languages ​​and APIs (application programming interfaces). All this made programming much more complicated, and also made it impossible or economically inexpedient to change the platform (vendor lock-in). The Alliance of hardware and software manufacturers has developed and standardized the OpenCL language, which solves these problems. This is an open standard and there are several implementations from different manufacturers of hardware from AMD, Intel, Nvidia, IBM, etc. under Windows, Linux and MacOS operating systems.



Under Windows for VisualStudio, there are NVIDIA plug-ins - Parallel Nsight and gDEBugger from AMD. And if with OpenCL compiler and runtime runtime for the operating systems listed earlier there are no problems, then AMD / Nvidia is much more complicated with the Linux development environment.

')

When host code is part of OpenCL code that prepares data and coordinates the work of OpenCL cores, is written in Java, debugging problems occur in Linux / Windows OS. If you recall the success of the Java platform in the cross-platform server software development market, it is unclear why hardware vendors still do not develop OpenCL development tools - debugging and profiling built into Eclipse IDE, Netbeans IDE, IntelliJ Idea. In the meantime, these development environments do not include ready-made tools that simplify working with the technology in question, we will try to solve the development problems with the means available today. This will allow us to get a competitive industrial solution optimized for work on modern computing devices.



Advantages and disadvantages of sharing Java and OpenCL



So why use the Java platform to develop host code for OpenCL? I will give several reasons for this choice:





When not to use Java to write OpenCL host code:



So, we decided that our task is suitable for OpenCL and cannot be implemented as effectively using only the Java language. At the same time, we want to take advantage of the JVM. Let's move from idea to implementation.



Technology



I recommend for the development of OpenCL in the implementation of AMD , if in the future it is planned to switch to using the server processor APU Opteron instead of a desktop solution based on AMD + Radeon HD 5000/6000 CPU or AMD Fusion CPU. JavaCL as an API for working with OpenCL. Using bridJ to call the native code of the OpenCL API dynamic library, we get a performance boost over JNA.



Debug Toolkit: gdb with text user interface or ddd as gdb frontend



For code profiling, I recommend using the AMD APP Profiler from the AMD Accelerated Parallel Processing (APP) SDK, Ubuntu 11.04 OS with the AMD proprietary FGLRX graphics driver installed for development. Development can be carried out in any Java IDE supporting maven projects. But support for syntax highlighting and compilation of OpenCL functions while writing code currently only supports the plugin for netbeans . The work of this plug-in was extremely unstable.



Creating an infrastructure for development and the development process is no different from working with other java technologies.



The debugging tools are more complicated, but there is a solution to this problem. AMD's OpenCL runtime allows you to debug kernels when running on a CPU: set breakpoints and display the values ​​of variables, including float4, int4 vector types, etc. In this case, the GPU functions are emulated on the central processor, for example, for working with textures. For those interested in debugging details, there is an article on debugging JavaCL and OpenCL under linux . Also, the project author has created a wiki page about debugging kernel code from Java. Details of supported gdb extensions for OpenCL



You can use the AMD APP Profiler to profile an application. When launched in Linux, it allows you to collect statistics on the operation of OpenCL functions in the application and save it to a CSV file for later analysis of data in a table processor LibreOffice Calc. To understand how optimally your code works, you need to interpret the values ​​of the parameters measured by the profiler .



Conclusion



The article examined the advantages and disadvantages of software development using the Java platform and OpenCL technology. Due to the prospects for the development of computing devices along the path of increasing parallelism, this approach in software development claims to be one of the main in the development of high-performance enterprise and cloud presentations on the JVM.

Source: https://habr.com/ru/post/134500/



All Articles