The AMD Sumatra prototype can run using the OKRA interface to the HSAIL simulator. Similarly, graal with the new HSAIL backend can run using this OKRA interface. For graal, you can either
- use a pre-built OKRA and simulator that is part of the graal libraries (found in graal/lib/okra-1.x-with-sim.jar). This prebuilt simulator allows junit tests to be run against the simulator without any additional okra build steps or path setup.
- or you can build the simulator with its OKRA interface using the instructions below and then add the build ouput directory to your PATH and LD_LIBRARY_PATH. By setting up the PATH and LD_LIBRARY_PATH, you can control whether you use a simulator-based OKRA or a hardware-based OKRA. Note that if no okra library can be found in the PATH or LD_LIBRARY_PATH a pre-built simulator OKRA described above is used. While this option involves more setup, it will have to be used eventually when you move to a hardware based OKRA.
Building the Simulator OKRA from sources
The HSAIL simulator and associated OKRA interface are currently limited to Linux. The build process for the OKRA interface will build both the simulator and the assembler from libHSAIL which is used to create BRIG binaries for the simulator. To build the simulator with its OKRA interface, follow the directions at https://github.com/HSAFoundation/Okra-Interface-to-HSAIL-Simulator#okra-interface-to-hsail-simulator. This procedure will build the assembler, simulator and okra interface. Remember to add okra/dist/bin from this build to PATH and to LD_LIBRARY_PATH. Run the indicated OKRA sanity tests on that page to confirm a proper build.
The graal trunk supports an HSAIL backend. By setting up the PATH and LD_LIBRARY_PATH, you can control whether you use a simulator-based OKRA or a hardware-based OKRA. If no okra library can be found in the PATH or LD_LIBRARY_PATH a simulator OKRA which can be found in graal/lib/okra-1.x-with-sim.jar gets used. This prebuilt simulator allows junit tests to be run against the simulator without any additional path setup.
You can run junit tests in the graal HSAIL-enabled backend by doing the following steps. Your JAVA_HOME can be either JDK7 or a recent JDK8 binary.
- add okra/dist/bin (from the simulator build above) to PATH and to LD_LIBRARY_PATH
- hg clone http://hg.openjdk.java.net/graal/graal
- cd graal (or whatever you named the clone you just made)
- Build graal using the command "mx --vm server --vmbuild product build".
- The following command runs a single junit test (the one that is described in Vasanth's HSAIL compiler blog). The command should be run on a single line:
mx --vm server unittest -XX:+GPUOffload-UseGraalClassLoader -G:Log=CodeGen,~HostGraph,~Stub hsail.test.IntSquaredTest
- Note: the -G:Log=CodeGen is optional but can be used if you want to see the generated HSAIL code on stdout. Further debug logging is enabaled can be enabled with -XX:+TraceGPUInteraction
- By removing the specifier IntSquaredTest from the above command line, you can run all the junit tests in the hsail.test directory. You can experiment with different -Xmx heap sizes which will lead to different compressed reference encodings and see that these are handled in the HSAIL code. (You can also turn off compressed oops if desired).