You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

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

Now that the HSAIL backend has been committed to the Graal trunk, 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
  • 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 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
              @-Dkerneltester.logLevel=INFO
              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 @-Dkerneltester.logLevel=INFO is optional but can be used if you want to see the generated HSAIL code on stdout
  • By removing the specifier IntSquaredTest from the above command line, you can run all the junit tests in the hsail.test directory.  In this case you may need to add the option @-G:+InlineEverything
    • @-G:+InlineEverything is used because the HSAIL backend's support for function calls is still in progress.
  • You can experiment with different specific -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).  For example a heap of -Xmx31g will lead to compressed references that invove a shift and an add of a base.
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.

  • No labels