# HG changeset patch # User Doug Simon # Date 1385147665 -3600 # Node ID 0267afb6816ba2978f3acece4f037092bd6ada9c # Parent 166ed1584f30afdf30d9aa1f2ce92cdba0c57257# Parent e2933e3d4fb03588ff323a3879385b96a1921176 Merge. diff -r e2933e3d4fb0 -r 0267afb6816b src/gpu/hsail/vm/gpu_hsail.cpp --- a/src/gpu/hsail/vm/gpu_hsail.cpp Thu Nov 21 16:52:14 2013 -0800 +++ b/src/gpu/hsail/vm/gpu_hsail.cpp Fri Nov 22 20:14:25 2013 +0100 @@ -33,8 +33,8 @@ void * gpu::Hsail::_device_context; -gpu::Hsail::okra_ctx_create_func_t gpu::Hsail::_okra_ctx_create; -gpu::Hsail::okra_kernel_create_func_t gpu::Hsail::_okra_kernel_create; +gpu::Hsail::okra_create_context_func_t gpu::Hsail::_okra_create_context; +gpu::Hsail::okra_create_kernel_func_t gpu::Hsail::_okra_create_kernel; gpu::Hsail::okra_push_object_func_t gpu::Hsail::_okra_push_object; gpu::Hsail::okra_push_boolean_func_t gpu::Hsail::_okra_push_boolean; gpu::Hsail::okra_push_byte_func_t gpu::Hsail::_okra_push_byte; @@ -92,13 +92,13 @@ // The kernel entrypoint is always run for the time being const char* entryPointName = "&run"; - _device_context = _okra_ctx_create(); + _device_context = _okra_create_context(); // code is not null terminated, must be a better way to do this unsigned char* nullTerminatedCodeBuffer = (unsigned char*) malloc(code_len + 1); memcpy(nullTerminatedCodeBuffer, code, code_len); nullTerminatedCodeBuffer[code_len] = 0; - void* kernel = _okra_kernel_create(_device_context, nullTerminatedCodeBuffer, entryPointName); + void* kernel = _okra_create_kernel(_device_context, nullTerminatedCodeBuffer, entryPointName); free(nullTerminatedCodeBuffer); return kernel; } @@ -113,6 +113,16 @@ #define STD_BUFFER_SIZE 1024 +#define STRINGIFY(x) #x + +#define LOOKUP_OKRA_FUNCTION(name, alias) \ + _##alias = \ + CAST_TO_FN_PTR(alias##_func_t, os::dll_lookup(handle, STRINGIFY(name))); \ + if (_##alias == NULL) { \ + tty->print_cr("[HSAIL] ***** Error: Failed to lookup %s in %s, wrong version of OKRA?", STRINGIFY(name), okra_library_name); \ + return 0; \ + } \ + bool gpu::Hsail::probe_linkage() { if (okra_library_name != NULL) { char *buffer = (char*)malloc(STD_BUFFER_SIZE); @@ -123,34 +133,19 @@ free(buffer); if (handle != NULL) { - _okra_ctx_create = - CAST_TO_FN_PTR(okra_ctx_create_func_t, os::dll_lookup(handle, "okra_create_context")); - _okra_kernel_create = - CAST_TO_FN_PTR(okra_kernel_create_func_t, os::dll_lookup(handle, "okra_create_kernel")); - _okra_push_object = - CAST_TO_FN_PTR(okra_push_object_func_t, os::dll_lookup(handle, "okra_push_object")); - _okra_push_boolean = - CAST_TO_FN_PTR(okra_push_boolean_func_t, os::dll_lookup(handle, "okra_push_boolean")); - _okra_push_byte = - CAST_TO_FN_PTR(okra_push_byte_func_t, os::dll_lookup(handle, "okra_push_byte")); - _okra_push_double = - CAST_TO_FN_PTR(okra_push_double_func_t, os::dll_lookup(handle, "okra_push_double")); - _okra_push_float = - CAST_TO_FN_PTR(okra_push_float_func_t, os::dll_lookup(handle, "okra_push_float")); - _okra_push_int = - CAST_TO_FN_PTR(okra_push_int_func_t, os::dll_lookup(handle, "okra_push_int")); - _okra_push_long = - CAST_TO_FN_PTR(okra_push_long_func_t, os::dll_lookup(handle, "okra_push_long")); - _okra_execute_with_range = - CAST_TO_FN_PTR(okra_execute_with_range_func_t, os::dll_lookup(handle, "okra_execute_with_range")); - _okra_clearargs = - CAST_TO_FN_PTR(okra_clearargs_func_t, os::dll_lookup(handle, "okra_clearargs")); - _okra_register_heap = - CAST_TO_FN_PTR(okra_register_heap_func_t, os::dll_lookup(handle, "okra_register_heap")); + LOOKUP_OKRA_FUNCTION(okra_create_context, okra_create_context); + LOOKUP_OKRA_FUNCTION(okra_create_kernel, okra_create_kernel); + LOOKUP_OKRA_FUNCTION(okra_push_object, okra_push_object); + 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); - if (TraceGPUInteraction) { - tty->print_cr("[HSAIL] Success: library linkage _okra_clearargs=0x%08x", _okra_clearargs); - } return true; } else { // Unable to dlopen okra diff -r e2933e3d4fb0 -r 0267afb6816b src/gpu/hsail/vm/gpu_hsail.hpp --- a/src/gpu/hsail/vm/gpu_hsail.hpp Thu Nov 21 16:52:14 2013 -0800 +++ b/src/gpu/hsail/vm/gpu_hsail.hpp Fri Nov 22 20:14:25 2013 +0100 @@ -44,8 +44,8 @@ #endif private: - typedef void* (*okra_ctx_create_func_t)(); - typedef void* (*okra_kernel_create_func_t)(void*, unsigned char *, const char *); + 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); @@ -58,8 +58,8 @@ typedef bool (*okra_register_heap_func_t)(void*, size_t); public: - static okra_ctx_create_func_t _okra_ctx_create; - static okra_kernel_create_func_t _okra_kernel_create; + static okra_create_context_func_t _okra_create_context; + static okra_create_kernel_func_t _okra_create_kernel; static okra_push_object_func_t _okra_push_object; static okra_push_boolean_func_t _okra_push_boolean; static okra_push_byte_func_t _okra_push_byte; diff -r e2933e3d4fb0 -r 0267afb6816b src/os_gpu/linux_ptx/vm/gpu_linux.cpp --- a/src/os_gpu/linux_ptx/vm/gpu_linux.cpp Thu Nov 21 16:52:14 2013 -0800 +++ b/src/os_gpu/linux_ptx/vm/gpu_linux.cpp Fri Nov 22 20:14:25 2013 +0100 @@ -81,13 +81,19 @@ tty->print_cr("Found supported nVidia GPU device vendor : 0x%04x device 0x%04x", vendor, device); } break; - } else if (vendor == amd_vendor_id) { - gpu_device_exists = true; - set_target_il_type(gpu::HSAIL); - if (TraceGPUInteraction) { - tty->print_cr("Found supported AMD GPU device vendor : 0x%04x device 0x%04x", vendor, device); - } - break; + /* + * Remove AMD detection until we decide how to detect real HSA hardware. + * In the current form this check does not work correctly on AMD CPU system with + * Nvidia GPU. + * + * } else if (vendor == amd_vendor_id) { + * gpu_device_exists = true; + * set_target_il_type(gpu::HSAIL); + * if (TraceGPUInteraction) { + * tty->print_cr("Found supported AMD GPU device vendor : 0x%04x device 0x%04x", vendor, device); + * } + * break; + */ } } diff -r e2933e3d4fb0 -r 0267afb6816b src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Thu Nov 21 16:52:14 2013 -0800 +++ b/src/share/vm/runtime/thread.cpp Fri Nov 22 20:14:25 2013 +0100 @@ -3378,10 +3378,6 @@ // Initialize the os module before using TLS os::init(); - // Probe for existance of supported GPU and initialize it if one - // exists. - gpu::init(); - // Initialize system properties. Arguments::init_system_properties(); @@ -3395,6 +3391,10 @@ jint parse_result = Arguments::parse(args); if (parse_result != JNI_OK) return parse_result; + // Probe for existance of supported GPU and initialize it if one + // exists. + gpu::init(); + os::init_before_ergo(); jint ergo_result = Arguments::apply_ergo();