Package edu.rit.gpu

Package edu.rit.gpu contains classes for Parallel Java 2's graphics processing unit (GPU) programming capability.

See: Description

Package edu.rit.gpu Description

Package edu.rit.gpu contains classes for Parallel Java 2's graphics processing unit (GPU) programming capability. At present the package supports GPU kernels written using Nvidia Corporation's CUDA version 5.0.

A PJ2 GPU program's main program is written in Java using PJ2. The GPU kernels are written in C or C++ using CUDA. Classes in package edu.rit.gpu let the main program transfer data between the CPU's memory and the GPU's memory, execute kernel functions on the GPU, and do other GPU related operations.

Installation
Usage
Writing PJ2 GPU Programs


Installation

Do the following steps to install PJ2's GPU capability. These steps are not needed if PJ2's GPU capability is not needed. Some familiarity with the Java Native Interface (JNI) would be helpful; see Sheng Liang, Java Native Interface: Programmer's Guide and Specification (Addison-Wesley, 1999).

  1. Install CUDA.

  2. Install the PJ2 source distribution as described in the Overview.

  3. Change to the lib/ directory in the source distribution and run the ccompile shell script. On a Linux system, this compiles the edu_rit_gpu_Cuda.c source file and creates the libEduRitGpuCuda.so native code library file. You might need to modify the shell script to create the proper native code library file for your system.

  4. Move the native code library file to a directory on the load library path, where the Java Virtual Machine can find it. See "Usage" below.

  5. Change to the lib/edu/rit/gpu/example/ directory in the source distribution and run the ccompile shell script. This compiles the CUDA module files needed by the Java classes in package edu.rit.gpu.example. You might need to modify the shell script for your system.

  6. Change to the lib/edu/rit/gpu/test/ directory and run the ccompile shell script. This compiles the CUDA module files needed by the Java classes in package edu.rit.gpu.test. You might need to modify the shell script for your system.

  7. If you are installing the PJ2 executable distribution as described in the Overview, the compiled CUDA module files must be added to the PJ2 JAR file. Change to the lib/ directory in the source distribution and run this command:
        jar uf <jarfile> edu/rit/gpu/*/*.cubin edu/rit/gpu/*/*.ptx
    replacing <jarfile> with the pathname of the PJ2 JAR file.


Usage

When compiling and executing Java programs that use PJ2's GPU capability, in addition to setting the Java class path as described in the Overview, you must also set your load library path to include the directory where the PJ2 native code library file resides. Here is an example of a command for the bash shell to add an appropriate directory to the front of the load library path:

export LD_LIBRARY_PATH=/var/tmp/parajava/pj2:$LD_LIBRARY_PATH

Here is an example of a command for the csh shell to add an appropriate directory to the front of the load library path:

setenv LD_LIBRARY_PATH /var/tmp/parajava/pj2:$LD_LIBRARY_PATH


Writing PJ2 GPU Programs

Use class Gpu to configure GPU devices, load compiled GPU module files, and set up dynamically allocated variables in GPU memory.

Use class Module to get statically allocated GPU variables and GPU kernel functions from a compiled GPU module.

Use interface Kernel to configure and execute GPU kernel functions.

For further information, study and run the example programs in package edu.rit.gpu.example.

Copyright © 2013–2018 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.