The HSA Foundation has open sourced the following repositories on github
The AMD Sumatra prototype (webrev under review) can run using the OKRA interface to the HSAIL simulator. Similarly, graal with the new HSAIL backend (webrev under review) can run using this OKRA interface.
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. Run the indicated OKRA sanity tests on that page to confirm a proper build.
The sanity tests above are small tests with hand-coded HSAIL. They test both the C++ interface and the Java JNI interface. The following are a few other client that can be run against the Java OKRA interface to the HSAIL Simulator.
Running the Graal Junit Tests on the Simulator
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 (for example jdk8-b94)
- add okra/dist/bin (from the simulator build above) to $PATH and to $LD_LIBRARY_PATH
- download the patch from the hsail backend webrev to graal which is under review http://cr.openjdk.java.net/~twisti/GRAAL-342/webrev/graal-hsail.patch
- hg clone http://hg.openjdk.java.net/graal/graal
- cd graal (or whatever you named the clone you just made)
- hg update -r a11e3d681eb1 (the version of the graal trunk that the HSAIL backend patch was derived from)
- apply the patch
- Build graal using the command "mx --vm server build product".
- 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, it has line breaks here for readability:
- mx --vm server unittest @-G:-RemoveNeverExecutedCode --J
@-Dsun.boot.library.path=$LD_LIBRARY_PATH
@-Xms1g @-Xmx1g @XX:-UseCompressedOops
hsail.test.IntSquaredTest- The -RemoveNeverExecutedCode directive is there because the current HSAIL backend cannot handle the deoptimization that would be required when a previously never executed path is then taken.
- The -UseCompressedOops is there because the support for compressed Oops in the HSAIL backend is still in progress.
- By removing the specifier IntSquaredTest from the above command line, you can run all the junit tests in the hsail.test directory.
A note about the Graal Junit Tests
Each graal junit test specifies a java method which takes a final int argument which is treated as a "workitemId". Also specified is a Range from 0 to N over which the workitemId will iterate. The method under test is dispatched twice:
- once using straight java on the host machine, sequentially, once for each workitemid in the Range.
- in a separate class instance, the method under test is compiled to HSAIL and the resulting kernel is dispatched using OKRA across the specified Range (with the library paths specified above this will be executed on the simulator).
The fields marked with @Result from the two dispatch instances are then compared for equality.
To be added: instructions for building and running Sumatra prototype thru Graal to the simulator.