changeset 12490:4dba97fb1a6f

available GPUs are exposed to Graal only by the graal.gpu.isalist system property which is set up during command line argument parsing
author Doug Simon <doug.simon@oracle.com>
date Fri, 18 Oct 2013 23:55:35 +0200
parents 0c651af30cc8
children 1499d4d73eee
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToGPU.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToGPUImpl.java src/share/vm/graal/graalCompilerToGPU.cpp src/share/vm/runtime/arguments.cpp src/share/vm/runtime/arguments.hpp src/share/vm/runtime/globals.hpp
diffstat 7 files changed, 38 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Fri Oct 18 21:40:23 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Fri Oct 18 23:55:35 2013 +0200
@@ -252,16 +252,17 @@
     /**
      * Gets the names of the supported GPU architectures for the purpose of finding the
      * corresponding {@linkplain HotSpotBackendFactory backend} objects. This method first looks for
-     * a comma separated list of names in the {@value #GRAAL_GPU_ISALIST_PROPERTY_NAME} system
-     * property. If this property is not set, then the GPU native support code is queried.
+     * a comma or {@link java.io.File#pathSeparatorChar} separated list of names in the
+     * {@value #GRAAL_GPU_ISALIST_PROPERTY_NAME} system property. If this property is not set, then
+     * the GPU native support code is queried.
      */
-    private String[] getGPUArchitectureNames() {
+    private static String[] getGPUArchitectureNames() {
         String gpuList = System.getProperty(GRAAL_GPU_ISALIST_PROPERTY_NAME);
-        if (gpuList != null) {
-            String[] gpus = gpuList.split(",");
+        if (gpuList != null && !gpuList.isEmpty()) {
+            String[] gpus = gpuList.split("[,:]");
             return gpus;
         }
-        return compilerToGpu.getAvailableGPUArchitectures();
+        return new String[0];
     }
 
     private static void printConfig(HotSpotVMConfig config) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToGPU.java	Fri Oct 18 21:40:23 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToGPU.java	Fri Oct 18 23:55:35 2013 +0200
@@ -48,11 +48,6 @@
     int availableProcessors();
 
     /**
-     * Gets the architecture names of the available GPUs.
-     */
-    String[] getAvailableGPUArchitectures();
-
-    /**
      * Attempts to generate and return a bound function to the loaded method kernel on the GPU.
      * 
      * @param code the text or binary values for a method kernel
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToGPUImpl.java	Fri Oct 18 21:40:23 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToGPUImpl.java	Fri Oct 18 23:55:35 2013 +0200
@@ -39,8 +39,6 @@
 
     public native int availableProcessors();
 
-    public native String[] getAvailableGPUArchitectures();
-
     public native Object executeExternalMethodVarargs(Object[] args, HotSpotInstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException;
 
     public native Object executeParallelMethodVarargs(int dimX, int dimY, int dimZ, Object[] args, HotSpotInstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException;
--- a/src/share/vm/graal/graalCompilerToGPU.cpp	Fri Oct 18 21:40:23 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToGPU.cpp	Fri Oct 18 23:55:35 2013 +0200
@@ -190,29 +190,6 @@
   return gpu::available_processors();
 C2V_END
 
-static objArrayHandle newSingletonStringArray(const char* value, TRAPS) {
-  objArrayHandle nullRes;
-  objArrayOop res = oopFactory::new_objArray(SystemDictionary::String_klass(), 1, CHECK_(nullRes));
-  objArrayHandle res_h = objArrayHandle(THREAD, res);
-  Handle valueString = java_lang_String::create_from_str(value, CHECK_(nullRes));
-  res_h->obj_at_put(0, valueString());
-  return res_h;
-}
-
-C2V_VMENTRY(jobject, getAvailableGPUArchitectures, (JNIEnv *env, jobject))
-  if (UseGPU) {
-    if (gpu::is_available() && gpu::has_gpu_linkage()) {
-      if (gpu::get_target_il_type() == gpu::PTX) {
-        return JNIHandles::make_local(newSingletonStringArray("PTX", THREAD)());
-      }
-      if (gpu::get_target_il_type() == gpu::HSAIL) {
-        return JNIHandles::make_local(newSingletonStringArray("HSAIL", THREAD)());
-      }
-    }
-  }
-  return JNIHandles::make_local(oopFactory::new_objArray(SystemDictionary::String_klass(), 0, THREAD));
-C2V_END
-
 C2V_VMENTRY(jboolean, deviceDetach, (JNIEnv *env, jobject))
 return true;
 C2V_END
@@ -258,7 +235,6 @@
   {CC"deviceInit",                    CC"()Z",                                    FN_PTR(deviceInit)},
   {CC"deviceDetach",                  CC"()Z",                                    FN_PTR(deviceDetach)},
   {CC"availableProcessors",           CC"()I",                                    FN_PTR(availableProcessors)},
-  {CC"getAvailableGPUArchitectures",  CC"()["STRING,                              FN_PTR(getAvailableGPUArchitectures)},
   {CC"executeExternalMethodVarargs",  CC"(["OBJECT HS_INSTALLED_CODE")"OBJECT,    FN_PTR(executeExternalMethodVarargs)},
   {CC"executeParallelMethodVarargs",  CC"(III["OBJECT HS_INSTALLED_CODE")"OBJECT, FN_PTR(executeParallelMethodVarargs)},
 };
--- a/src/share/vm/runtime/arguments.cpp	Fri Oct 18 21:40:23 2013 +0200
+++ b/src/share/vm/runtime/arguments.cpp	Fri Oct 18 23:55:35 2013 +0200
@@ -35,6 +35,7 @@
 #include "prims/jvmtiExport.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/globals_extension.hpp"
+#include "runtime/gpu.hpp"
 #include "runtime/java.hpp"
 #include "services/management.hpp"
 #include "services/memTracker.hpp"
@@ -130,6 +131,9 @@
 SystemProperty *Arguments::_java_home = NULL;
 SystemProperty *Arguments::_java_class_path = NULL;
 SystemProperty *Arguments::_sun_boot_class_path = NULL;
+#ifdef GRAAL
+SystemProperty *Arguments::_graal_gpu_isalist = NULL;
+#endif
 
 char* Arguments::_meta_index_path = NULL;
 char* Arguments::_meta_index_dir = NULL;
@@ -193,6 +197,9 @@
   _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL,  true);
 
   _java_class_path = new SystemProperty("java.class.path", "",  true);
+#ifdef GRAAL
+  _graal_gpu_isalist = new SystemProperty("graal.gpu.isalist", NULL, true);
+#endif
 
   // Add to System Property list.
   PropertyList_add(&_system_properties, _java_ext_dirs);
@@ -202,6 +209,9 @@
   PropertyList_add(&_system_properties, _java_home);
   PropertyList_add(&_system_properties, _java_class_path);
   PropertyList_add(&_system_properties, _sun_boot_class_path);
+#ifdef GRAAL
+  PropertyList_add(&_system_properties, _graal_gpu_isalist);
+#endif
 
   // Set OS specific system properties values
   os::init_system_properties_values();
@@ -3801,6 +3811,24 @@
     }
   }
 
+#ifdef GRAAL
+  if (_graal_gpu_isalist->value() == NULL) {
+    // Initialize the graal.gpu.isalist system property if
+    // a) it was not explicitly defined by the user and
+    // b) at least one GPU is available.
+    // GPU offload can be disabled by setting the property
+    // to the empty string on the command line
+    if (gpu::is_available() && gpu::has_gpu_linkage()) {
+      if (gpu::get_target_il_type() == gpu::PTX) {
+        _graal_gpu_isalist->append_value("PTX");
+      }
+      if (gpu::get_target_il_type() == gpu::HSAIL) {
+        _graal_gpu_isalist->append_value("HSAIL");
+      }
+    }
+  }
+#endif
+
   return JNI_OK;
 }
 
--- a/src/share/vm/runtime/arguments.hpp	Fri Oct 18 21:40:23 2013 +0200
+++ b/src/share/vm/runtime/arguments.hpp	Fri Oct 18 23:55:35 2013 +0200
@@ -264,6 +264,9 @@
   static SystemProperty *_java_home;
   static SystemProperty *_java_class_path;
   static SystemProperty *_sun_boot_class_path;
+#ifdef GRAAL
+  static SystemProperty *_graal_gpu_isalist;
+#endif
 
   // Meta-index for knowing what packages are in the boot class path
   static char* _meta_index_path;
--- a/src/share/vm/runtime/globals.hpp	Fri Oct 18 21:40:23 2013 +0200
+++ b/src/share/vm/runtime/globals.hpp	Fri Oct 18 23:55:35 2013 +0200
@@ -3774,9 +3774,6 @@
   product(bool, TraceGPUInteraction, false,                                 \
           "Trace external GPU Interaction")                                 \
                                                                             \
-  product(bool, UseGPU, false,                                              \
-          "Run code on GPU")                                                \
-                                                                            \
   diagnostic(ccstr, SharedArchiveFile, NULL,                                \
           "Override the default location of the CDS archive file")          \
                                                                             \