changeset 16533:d5c4bb0039d8

HSAIL: update simulator Contributed-by: Eric Caspole <eric.caspole@amd.com>
author Bernhard Urban <bernhard.urban@jku.at>
date Wed, 16 Jul 2014 11:32:34 +0200
parents 2dd966b157e8
children 4aaa97f42b92
files mx/projects src/gpu/hsail/vm/gpu_hsail.cpp src/gpu/hsail/vm/gpu_hsail.hpp src/gpu/hsail/vm/hsailKernelArguments.hpp
diffstat 4 files changed, 82 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/mx/projects	Tue Jul 15 21:26:34 2014 -0700
+++ b/mx/projects	Wed Jul 16 11:32:34 2014 +0200
@@ -43,19 +43,19 @@
 library@DACAPO_SCALA@urls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/dacapo-scala-0.1.0-20120216.jar,http://repo.scalabench.org/snapshots/org/scalabench/benchmarks/scala-benchmark-suite/0.1.0-SNAPSHOT/scala-benchmark-suite-0.1.0-20120216.103539-3.jar
 library@DACAPO_SCALA@sha1=59b64c974662b5cf9dbd3cf9045d293853dd7a51
 
-library@OKRA@path=lib/okra-1.9.jar
-library@OKRA@urls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/okra-1.9.jar,http://cr.openjdk.java.net/~tdeneau/okra-1.9.jar
-library@OKRA@sha1=df450b04882e6b5a365299e2cbf1622038ae880e
-library@OKRA@sourcePath=lib/okra-1.9-src.jar
-library@OKRA@sourceUrls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/okra-1.9-src.jar,http://cr.openjdk.java.net/~tdeneau/okra-1.9-src.jar
-library@OKRA@sourceSha1=41dcda5197ca4d87bc94e4d7b5a90e7f22667756
+library@OKRA@path=lib/okra-1.10.jar
+library@OKRA@urls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/okra-1.10.jar,http://cr.openjdk.java.net/~tdeneau/okra-1.10.jar
+library@OKRA@sha1=96eb3c0ec808ed944ba88d1eb9311058fe0f3d1e
+library@OKRA@sourcePath=lib/okra-1.10-src.jar
+library@OKRA@sourceUrls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/okra-1.10-src.jar,http://cr.openjdk.java.net/~tdeneau/okra-1.10-src.jar
+library@OKRA@sourceSha1=75751bb148fcebaba78ff590f883a114b2b09176
 
-library@OKRA_WITH_SIM@path=lib/okra-1.9-with-sim.jar
-library@OKRA_WITH_SIM@urls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/okra-1.9-with-sim.jar,http://cr.openjdk.java.net/~tdeneau/okra-1.9-with-sim.jar
-library@OKRA_WITH_SIM@sha1=816fa24814cf51c02f9c05477447bb55a152b388
-library@OKRA_WITH_SIM@sourcePath=lib/okra-1.9-with-sim-src.jar
-library@OKRA_WITH_SIM@sourceSha1=1628919457999a8479d9f39845865de527dbd523
-library@OKRA_WITH_SIM@sourceUrls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/okra-1.9-with-sim-src.jar,http://cr.openjdk.java.net/~tdeneau/okra-1.9-with-sim-src.jar
+library@OKRA_WITH_SIM@path=lib/okra-1.10-with-sim.jar
+library@OKRA_WITH_SIM@urls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/okra-1.10-with-sim.jar,http://cr.openjdk.java.net/~tdeneau/okra-1.10-with-sim.jar
+library@OKRA_WITH_SIM@sha1=7b8db879f1dbcf571290add78d9af24e15a2a50d
+library@OKRA_WITH_SIM@sourcePath=lib/okra-1.10-with-sim-src.jar
+library@OKRA_WITH_SIM@sourceSha1=7eefd94f16a3e3fd3b8f470cf91e265c6f5e7767
+library@OKRA_WITH_SIM@sourceUrls=http://lafo.ssw.uni-linz.ac.at/graal-external-deps/okra-1.10-with-sim-src.jar,http://cr.openjdk.java.net/~tdeneau/okra-1.10-with-sim-src.jar
 
 library@JAVA_ALLOCATION_INSTRUMENTER@path=lib/java-allocation-instrumenter.jar
 library@JAVA_ALLOCATION_INSTRUMENTER@sourcePath=lib/java-allocation-instrumenter.jar
--- a/src/gpu/hsail/vm/gpu_hsail.cpp	Tue Jul 15 21:26:34 2014 -0700
+++ b/src/gpu/hsail/vm/gpu_hsail.cpp	Wed Jul 16 11:32:34 2014 +0200
@@ -72,18 +72,19 @@
 void* Hsail::_device_context = NULL;
 jint  Hsail::_notice_safepoints = false;
 
-Hsail::okra_create_context_func_t  Hsail::_okra_create_context;
+Hsail::okra_get_context_func_t     Hsail::_okra_get_context;
 Hsail::okra_create_kernel_func_t   Hsail::_okra_create_kernel;
-Hsail::okra_push_object_func_t     Hsail::_okra_push_object;
+Hsail::okra_push_pointer_func_t    Hsail::_okra_push_pointer;
 Hsail::okra_push_boolean_func_t    Hsail::_okra_push_boolean;
 Hsail::okra_push_byte_func_t       Hsail::_okra_push_byte;
 Hsail::okra_push_double_func_t     Hsail::_okra_push_double;
 Hsail::okra_push_float_func_t      Hsail::_okra_push_float;
 Hsail::okra_push_int_func_t        Hsail::_okra_push_int;
 Hsail::okra_push_long_func_t       Hsail::_okra_push_long;
-Hsail::okra_execute_with_range_func_t    Hsail::_okra_execute_with_range;
-Hsail::okra_clearargs_func_t       Hsail::_okra_clearargs;
-Hsail::okra_register_heap_func_t   Hsail::_okra_register_heap;
+Hsail::okra_execute_kernel_func_t  Hsail::_okra_execute_kernel;
+Hsail::okra_clear_args_func_t      Hsail::_okra_clear_args;
+Hsail::okra_dispose_kernel_func_t  Hsail::_okra_dispose_kernel;
+Hsail::okra_dispose_context_func_t Hsail::_okra_dispose_context;
 
 //static jint in_kernel = 0;
 
@@ -98,16 +99,6 @@
   _notice_safepoints = false;
 }
 
-void Hsail::register_heap() {
-  // After the okra functions are set up and the heap is initialized, register the java heap with HSA
-  guarantee(Universe::heap() != NULL, "heap should be there by now.");
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] heap=" PTR_FORMAT, Universe::heap());
-    tty->print_cr("[HSAIL] base=0x%08x, capacity=%ld", Universe::heap()->base(), Universe::heap()->capacity());
-  }
-  _okra_register_heap(Universe::heap()->base(), Universe::heap()->capacity());
-}
-
 GPU_VMENTRY(jboolean, Hsail::execute_kernel_void_1d, (JNIEnv* env, jclass, jobject kernel_handle, jint dimX, jobject args,
                                                       jobject donor_threads, jint allocBytesPerWorkitem, jobject oop_map_array))
 
@@ -156,7 +147,7 @@
   HSAILAllocationInfo* allocInfo = (donor_threads == NULL ? NULL : new HSAILAllocationInfo(donor_threads, dimX, allocBytesPerWorkitem));
   
   // Reset the kernel arguments
-  _okra_clearargs(kernel);
+  _okra_clear_args(kernel);
 
   JavaThread* thread = (JavaThread*)THREAD;
   HSAILDeoptimizationInfo* e;
@@ -197,10 +188,13 @@
   bool success = false;
   {
     TraceTime t("execute kernel", TraceGPUInteraction);
+    graal_okra_range_t kernel_range = {0};
 
     //in_kernel = 1;
     // Run the kernel
-    success = _okra_execute_with_range(kernel, dimX);
+    kernel_range.dimension = 1;
+    kernel_range.global_size[0] = dimX;
+    success = _okra_execute_kernel(_device_context, kernel, &kernel_range);
     //in_kernel = 0;
   }
 
@@ -347,14 +341,12 @@
   env->GetByteArrayRegion(code_handle, 0, code_len, (jbyte*) code);
   env->GetStringUTFRegion(name_handle, 0, name_len, name);
 
-  register_heap();
-
   // The kernel entrypoint is always run for the time being  
   const char* entryPointName = "&run";
-
-  _device_context = _okra_create_context();
-
-  return (jlong) _okra_create_kernel(_device_context, code, entryPointName);
+  jlong okra_kernel;
+  jint okra_status = _okra_create_kernel(_device_context, code, entryPointName, (void**)&okra_kernel);
+  guarantee(okra_status==0, "_okra_create_kernel failed");
+  return (jlong) okra_kernel;
 GPU_END
 
 #if defined(LINUX)
@@ -410,26 +402,31 @@
     return false;
   }
   
-  guarantee(_okra_create_context == NULL, "cannot repeat GPU initialization");
+  guarantee(_okra_get_context == NULL, "cannot repeat GPU initialization");
 
   // At this point we know  okra_lib_handle is valid whether we loaded
   // here or earlier.  In either case, we can lookup the functions.
-  LOOKUP_OKRA_FUNCTION(okra_create_context, okra_create_context);
+  LOOKUP_OKRA_FUNCTION(okra_get_context, okra_get_context);
   LOOKUP_OKRA_FUNCTION(okra_create_kernel, okra_create_kernel);
-  LOOKUP_OKRA_FUNCTION(okra_push_object, okra_push_object);
+  LOOKUP_OKRA_FUNCTION(okra_push_pointer, okra_push_pointer);
   LOOKUP_OKRA_FUNCTION(okra_push_boolean, okra_push_boolean);
   LOOKUP_OKRA_FUNCTION(okra_push_byte, okra_push_byte);
   LOOKUP_OKRA_FUNCTION(okra_push_double, okra_push_double);
   LOOKUP_OKRA_FUNCTION(okra_push_float, okra_push_float);
   LOOKUP_OKRA_FUNCTION(okra_push_int, okra_push_int);
   LOOKUP_OKRA_FUNCTION(okra_push_long, okra_push_long);
-  LOOKUP_OKRA_FUNCTION(okra_execute_with_range, okra_execute_with_range);
-  LOOKUP_OKRA_FUNCTION(okra_clearargs, okra_clearargs);
-  LOOKUP_OKRA_FUNCTION(okra_register_heap, okra_register_heap);
+  LOOKUP_OKRA_FUNCTION(okra_execute_kernel, okra_execute_kernel);
+  LOOKUP_OKRA_FUNCTION(okra_clear_args, okra_clear_args);
+  LOOKUP_OKRA_FUNCTION(okra_dispose_kernel, okra_dispose_kernel);
+  LOOKUP_OKRA_FUNCTION(okra_dispose_context, okra_dispose_context);
   // if we made it this far, real success
 
   Gpu::initialized_gpu(new Hsail());
 
+    // There is 1 context per process
+  jint result = _okra_get_context(&_device_context);
+  guarantee(result==0, "get context failed");
+
   return true;
 GPU_END
 
--- a/src/gpu/hsail/vm/gpu_hsail.hpp	Tue Jul 15 21:26:34 2014 -0700
+++ b/src/gpu/hsail/vm/gpu_hsail.hpp	Wed Jul 16 11:32:34 2014 +0200
@@ -190,8 +190,6 @@
   static jboolean execute_kernel_void_1d_internal(address kernel, int dimX, jobject args, methodHandle& mh, nmethod* nm,
                                                   jobject donorThreads, int allocBytesPerWorkitem, jobject oop_map_array, TRAPS);
 
-  static void register_heap();
-
   static GraalEnv::CodeInstallResult install_code(Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations);
 
 public:
@@ -211,32 +209,45 @@
 #endif
 
 private:
-  typedef void* (*okra_create_context_func_t)();
-  typedef void* (*okra_create_kernel_func_t)(void*, unsigned char*, const char*);
-  typedef bool (*okra_push_object_func_t)(void*, void*);
-  typedef bool (*okra_push_boolean_func_t)(void*, jboolean);
-  typedef bool (*okra_push_byte_func_t)(void*, jbyte);
-  typedef bool (*okra_push_double_func_t)(void*, jdouble);
-  typedef bool (*okra_push_float_func_t)(void*, jfloat);
-  typedef bool (*okra_push_int_func_t)(void*, jint);
-  typedef bool (*okra_push_long_func_t)(void*, jlong);
-  typedef bool (*okra_execute_with_range_func_t)(void*, jint);
-  typedef bool (*okra_clearargs_func_t)(void*);
-  typedef bool (*okra_register_heap_func_t)(void*, size_t);
+
+  /*
+   * Kernel launch options from okra.h
+   */
+  typedef struct graal_okra_range_s {
+    uint32_t dimension; //max value is 3
+    uint32_t global_size[3];
+    uint32_t group_size[3];
+    uint32_t reserved; //For future use
+  } graal_okra_range_t;
+
+  typedef jint (*okra_get_context_func_t)(void**);
+  typedef jint (*okra_create_kernel_func_t)(void*, unsigned char*, const char*, void**);
+  typedef jint (*okra_push_pointer_func_t)(void*, void*);
+  typedef jint (*okra_push_boolean_func_t)(void*, jboolean);
+  typedef jint (*okra_push_byte_func_t)(void*, jbyte);
+  typedef jint (*okra_push_double_func_t)(void*, jdouble);
+  typedef jint (*okra_push_float_func_t)(void*, jfloat);
+  typedef jint (*okra_push_int_func_t)(void*, jint);
+  typedef jint (*okra_push_long_func_t)(void*, jlong);
+  typedef jint (*okra_execute_kernel_func_t)(void*, void*, graal_okra_range_t*);
+  typedef jint (*okra_clear_args_func_t)(void*);
+  typedef jint (*okra_dispose_kernel_func_t)(void*);
+  typedef jint (*okra_dispose_context_func_t)(void*);
 
 public:
-  static okra_create_context_func_t             _okra_create_context;
+  static okra_get_context_func_t                _okra_get_context;
   static okra_create_kernel_func_t              _okra_create_kernel;
-  static okra_push_object_func_t                _okra_push_object;
+  static okra_push_pointer_func_t               _okra_push_pointer;
   static okra_push_boolean_func_t               _okra_push_boolean;
   static okra_push_byte_func_t                  _okra_push_byte;
   static okra_push_double_func_t                _okra_push_double;
   static okra_push_float_func_t                 _okra_push_float;
   static okra_push_int_func_t                   _okra_push_int;
   static okra_push_long_func_t                  _okra_push_long;
-  static okra_execute_with_range_func_t         _okra_execute_with_range;
-  static okra_clearargs_func_t                  _okra_clearargs;
-  static okra_register_heap_func_t              _okra_register_heap;
+  static okra_execute_kernel_func_t             _okra_execute_kernel;
+  static okra_clear_args_func_t                 _okra_clear_args;
+  static okra_dispose_kernel_func_t             _okra_dispose_kernel;
+  static okra_dispose_context_func_t            _okra_dispose_context;
   
 protected:
   static void* _device_context;
--- a/src/gpu/hsail/vm/hsailKernelArguments.hpp	Tue Jul 15 21:26:34 2014 -0700
+++ b/src/gpu/hsail/vm/hsailKernelArguments.hpp	Wed Jul 16 11:32:34 2014 +0200
@@ -47,36 +47,36 @@
     }
     virtual char* argsBuilderName() {return (char*)"HSAILKernelArguments";}
     virtual void pushObject(void* obj) {
-        bool pushed = Hsail::_okra_push_object(_kernel, obj);
-        assert(pushed == true, "arg push failed");
+        jint status = Hsail::_okra_push_pointer(_kernel, obj);
+        assert(status == 0, "arg push failed");
     }
     virtual void pushBool(jboolean z) {
-        bool pushed = Hsail::_okra_push_boolean(_kernel, z);
-        assert(pushed == true, "arg push failed");
+        jint status = Hsail::_okra_push_boolean(_kernel, z);
+        assert(status == 0, "arg push failed");
     }
     virtual void pushByte(jbyte b) {
-        bool pushed = Hsail::_okra_push_byte(_kernel, b);
-        assert(pushed == true, "arg push failed");
+        jint status = Hsail::_okra_push_byte(_kernel, b);
+        assert(status == 0, "arg push failed");
     }
 
     virtual void pushDouble(jdouble d) {
-        bool pushed = Hsail::_okra_push_double(_kernel, d);
-        assert(pushed == true, "arg push failed");
+        jint status = Hsail::_okra_push_double(_kernel, d);
+        assert(status == 0, "arg push failed");
     }
 
     virtual void pushFloat(jfloat f) {
-        bool pushed = Hsail::_okra_push_float(_kernel, f);
-        assert(pushed == true, "arg push failed");
+        jint status = Hsail::_okra_push_float(_kernel, f);
+        assert(status == 0, "arg push failed");
     }
 
     virtual void pushInt(jint i) {
-        bool pushed = Hsail::_okra_push_int(_kernel, i);
-        assert(pushed == true, "arg push failed");
+        jint status = Hsail::_okra_push_int(_kernel, i);
+        assert(status == 0, "arg push failed");
     }
 
     virtual void pushLong(jlong j) {
-        bool pushed = Hsail::_okra_push_long(_kernel, j);
-        assert(pushed == true, "arg push failed");
+        jint status = Hsail::_okra_push_long(_kernel, j);
+        assert(status == 0, "arg push failed");
     }
     virtual void pushTrailingArgs() {
         if (UseHSAILDeoptimization) {