diff src/share/vm/runtime/gpu.cpp @ 13819:49db2c1e3bee

added support for co-existing GPU backends (JBS:GRAAL-1)
author Doug Simon <doug.simon@oracle.com>
date Thu, 30 Jan 2014 00:52:33 +0100
parents f1a55428a8d7
children 66e3af78ea96
line wrap: on
line diff
--- a/src/share/vm/runtime/gpu.cpp	Thu Jan 30 00:48:41 2014 +0100
+++ b/src/share/vm/runtime/gpu.cpp	Thu Jan 30 00:52:33 2014 +0100
@@ -26,85 +26,11 @@
 #include "runtime/gpu.hpp"
 #include "runtime/handles.hpp"
 
-bool gpu::_available = false;    // does the hardware exist?
-bool gpu::_gpu_linkage = false;  // is the driver library to access the GPU installed
-bool gpu::_initialized = false;  // is the GPU device initialized
-gpu::TargetGPUIL gpu::_targetIL = gpu::NONE; // No GPU detected yet.
-
-void gpu::init() {
-#if defined(TARGET_OS_FAMILY_bsd) || defined(TARGET_OS_FAMILY_linux) || defined(TARGET_OS_FAMILY_windows)
-  gpu::probe_gpu();
-  if (gpu::get_target_il_type() == gpu::PTX) {
-    set_gpu_linkage(gpu::Ptx::probe_linkage());
-  } else if (gpu::get_target_il_type() == gpu::HSAIL) {
-    set_gpu_linkage(gpu::Hsail::probe_linkage());
-  } else {
-    set_gpu_linkage(false);
-  }
-#endif
-}
-
-void gpu::initialize_gpu() {
-  if (gpu::has_gpu_linkage()) {
-    if (gpu::get_target_il_type() == gpu::PTX) {
-      set_initialized(gpu::Ptx::initialize_gpu());
-    } else if (gpu::get_target_il_type() == gpu::HSAIL) {
-      set_initialized(gpu::Hsail::initialize_gpu());
-    }
-  }
-}
-
-void * gpu::generate_kernel(unsigned char *code, int code_len, const char *name) {
-  if (gpu::has_gpu_linkage()) {
-    if (gpu::get_target_il_type() == gpu::PTX) {
-      return (gpu::Ptx::generate_kernel(code, code_len, name));
-    } else if (gpu::get_target_il_type() == gpu::HSAIL) {
-      return (gpu::Hsail::generate_kernel(code, code_len, name));
-    }
-  }
-  return NULL;
-}
+int gpu::_initialized_gpus = 0;
 
-bool gpu::execute_kernel(address kernel, PTXKernelArguments & ptxka, JavaValue& ret) {
-    if (gpu::has_gpu_linkage()) {
-        if (gpu::get_target_il_type() == gpu::PTX) {
-            return (gpu::Ptx::execute_kernel(kernel, ptxka, ret));
-        }
-        // Add kernel execution functionality of other GPUs here
+void gpu::initialized_gpu(const char* name) {
+    _initialized_gpus++;
+    if (TraceGPUInteraction) {
+      tty->print_cr("[GPU] registered initialization of %s (total initialized: %d)", name, _initialized_gpus);
     }
-    return false;
-}
-
-// This is HSAIL specific to work with Sumatra JDK
-bool gpu::execute_kernel_void_1d(address kernel, int dimX, jobject args, methodHandle& mh) {
-    if (gpu::has_gpu_linkage()) {
-        if (gpu::get_target_il_type() == gpu::HSAIL) {
-            return (gpu::Hsail::execute_kernel_void_1d(kernel, dimX, args, mh));
-        }
-    }
-    return false;
-    
 }
-
-
-bool gpu::execute_warp(int dimX, int dimY, int dimZ,
-                       address kernel, PTXKernelArguments & ptxka, JavaValue& ret) {
-    if (gpu::has_gpu_linkage()) {
-        if (gpu::get_target_il_type() == gpu::PTX) {
-            return (gpu::Ptx::execute_warp(dimX, dimY, dimZ, kernel, ptxka, ret));
-        }
-        // Add kernel execution functionality of other GPUs here
-    }
-    return false;
-}
-
-int gpu::available_processors() {
-    if (gpu::has_gpu_linkage()) {
-        if (gpu::get_target_il_type() == gpu::PTX) {
-            return (gpu::Ptx::total_cores());
-        }
-        // Add kernel execution functionality of other GPUs here
-    }
-    return 0;
-}
-