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 clients that can be run against the Java OKRA interface to the HSAIL Simulator.
The graal trunk supports an HSAIL backend. 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
mx --vm server unittest -G:Log=CodeGen hsail.test.IntSquaredTest
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:
The fields marked with @Result from the two dispatch instances are then compared for equality.
Internally, the junit tests force a few graal options to needed values using graal's "scoped options" feature:
The HSAIL simulator supports debugging of the HSAIL source with gdb. For more details see the section "GDB-Based Debugging Interface" in the HSAIL Simulator README. In the particular context of debugging HSAIL generated for the graal junit tests, note that the kernel entry point is always called &run, so a kernel entry breakpoint can be set with "break run". The hsail source file will always be temp_hsa.hsail, which is a temporary file created by the OKRA interface. You will be able to step by HSAIL instructions, and inspect HSAIL registers as described in the README. Be sure to set the environment variables SIMNOOPT=1 and SIMTHREADS=1 as described there.
To be added: instructions for building and running Sumatra prototype thru Graal to the simulator.