diff src/gpu/ptx/vm/gpu_ptx.cpp @ 11283:1cd1f8ff70a1

CR-20: PTX kernel invocation with arguments - from Bharadwaj
author Morris Meyer <morris.meyer@oracle.com>
date Sat, 10 Aug 2013 14:38:30 -0400
parents fe49e5121768
children d876002b98e6
line wrap: on
line diff
--- a/src/gpu/ptx/vm/gpu_ptx.cpp	Sat Aug 10 10:08:56 2013 +0200
+++ b/src/gpu/ptx/vm/gpu_ptx.cpp	Sat Aug 10 14:38:30 2013 -0400
@@ -66,9 +66,9 @@
   }
 }
 
-bool gpu::execute_kernel(address kernel) {
+bool gpu::execute_kernel(address kernel, JavaCallArguments * jca) {
   if (gpu::has_gpu_linkage()) {
-    return (gpu::Ptx::execute_kernel(kernel));
+    return (gpu::Ptx::execute_kernel(kernel, jca));
   } else {
     return false;
   }
@@ -120,7 +120,7 @@
   }
 
   /* Get device attributes */
-  int minor, major;
+  int minor, major, unified_addressing;
   status = _cuda_cu_device_get_attribute(&minor, GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, cu_device);
 
   if (status != GRAAL_CUDA_SUCCESS) {
@@ -139,6 +139,18 @@
     tty->print_cr("[CUDA] Compatibility version of device %d: %d.%d", cu_device, major, minor);
   }
 
+  status = _cuda_cu_device_get_attribute(&unified_addressing, GRAAL_CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING, cu_device);
+
+  if (status != GRAAL_CUDA_SUCCESS) {
+    tty->print_cr("[CUDA] Failed to query unified addressing mode of device: %d", cu_device);
+    return false;
+  }
+
+  if (TraceGPUInteraction) {
+    tty->print_cr("[CUDA] Unified addressing support on device %d: %d", cu_device, unified_addressing);
+  }
+
+
   /* Get device name */
   char device_name[256];
   status = _cuda_cu_device_get_name(device_name, 256, cu_device);
@@ -218,7 +230,7 @@
   status = _cuda_cu_module_get_function(&cu_function, cu_module, name);
 
   if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] Failed to get function %s", name);
+    tty->print_cr("[CUDA] *** Error: Failed to get function %s", name);
     return NULL;
   }
 
@@ -228,7 +240,7 @@
   return cu_function;
 }
 
-bool gpu::Ptx::execute_kernel(address kernel) {
+bool gpu::Ptx::execute_kernel(address kernel, JavaCallArguments * jca) {
   // grid dimensionality
   unsigned int gridX = 1;
   unsigned int gridY = 1;
@@ -241,6 +253,15 @@
   
   int *cu_function = (int *)kernel;
 
+  char * paramBuffer = (char *) jca->parameters();
+  size_t paramBufferSz = (size_t) jca->size_of_parameters();
+
+  void * config[] = {
+    GRAAL_CU_LAUNCH_PARAM_BUFFER_POINTER, paramBuffer,
+    GRAAL_CU_LAUNCH_PARAM_BUFFER_SIZE, &paramBufferSz,
+    GRAAL_CU_LAUNCH_PARAM_END
+  };
+
   if (kernel == NULL) {
     return false;
   }
@@ -251,7 +272,7 @@
   int status = _cuda_cu_launch_kernel(cu_function,
                                       gridX, gridY, gridZ,
                                       blockX, blockY, blockZ,
-                                      0, NULL, NULL, NULL);
+                                      0, NULL, NULL, config);
   if (status != GRAAL_CUDA_SUCCESS) {
     tty->print_cr("[CUDA] Failed to launch kernel");
     return false;