Mercurial > hg > truffle
comparison src/gpu/hsail/vm/gpu_hsail.cpp @ 13119:124860fac470
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 22 Nov 2013 21:09:36 +0100 |
parents | 166ed1584f30 |
children | bfd61161d752 |
comparison
equal
deleted
inserted
replaced
13118:d511d688b782 | 13119:124860fac470 |
---|---|
31 #include "memory/allocation.inline.hpp" | 31 #include "memory/allocation.inline.hpp" |
32 #include "hsailKernelArguments.hpp" | 32 #include "hsailKernelArguments.hpp" |
33 | 33 |
34 void * gpu::Hsail::_device_context; | 34 void * gpu::Hsail::_device_context; |
35 | 35 |
36 gpu::Hsail::okra_ctx_create_func_t gpu::Hsail::_okra_ctx_create; | 36 gpu::Hsail::okra_create_context_func_t gpu::Hsail::_okra_create_context; |
37 gpu::Hsail::okra_kernel_create_func_t gpu::Hsail::_okra_kernel_create; | 37 gpu::Hsail::okra_create_kernel_func_t gpu::Hsail::_okra_create_kernel; |
38 gpu::Hsail::okra_push_object_func_t gpu::Hsail::_okra_push_object; | 38 gpu::Hsail::okra_push_object_func_t gpu::Hsail::_okra_push_object; |
39 gpu::Hsail::okra_push_boolean_func_t gpu::Hsail::_okra_push_boolean; | 39 gpu::Hsail::okra_push_boolean_func_t gpu::Hsail::_okra_push_boolean; |
40 gpu::Hsail::okra_push_byte_func_t gpu::Hsail::_okra_push_byte; | 40 gpu::Hsail::okra_push_byte_func_t gpu::Hsail::_okra_push_byte; |
41 gpu::Hsail::okra_push_double_func_t gpu::Hsail::_okra_push_double; | 41 gpu::Hsail::okra_push_double_func_t gpu::Hsail::_okra_push_double; |
42 gpu::Hsail::okra_push_float_func_t gpu::Hsail::_okra_push_float; | 42 gpu::Hsail::okra_push_float_func_t gpu::Hsail::_okra_push_float; |
90 gpu::Hsail::register_heap(); | 90 gpu::Hsail::register_heap(); |
91 | 91 |
92 // The kernel entrypoint is always run for the time being | 92 // The kernel entrypoint is always run for the time being |
93 const char* entryPointName = "&run"; | 93 const char* entryPointName = "&run"; |
94 | 94 |
95 _device_context = _okra_ctx_create(); | 95 _device_context = _okra_create_context(); |
96 | 96 |
97 // code is not null terminated, must be a better way to do this | 97 // code is not null terminated, must be a better way to do this |
98 unsigned char* nullTerminatedCodeBuffer = (unsigned char*) malloc(code_len + 1); | 98 unsigned char* nullTerminatedCodeBuffer = (unsigned char*) malloc(code_len + 1); |
99 memcpy(nullTerminatedCodeBuffer, code, code_len); | 99 memcpy(nullTerminatedCodeBuffer, code, code_len); |
100 nullTerminatedCodeBuffer[code_len] = 0; | 100 nullTerminatedCodeBuffer[code_len] = 0; |
101 void* kernel = _okra_kernel_create(_device_context, nullTerminatedCodeBuffer, entryPointName); | 101 void* kernel = _okra_create_kernel(_device_context, nullTerminatedCodeBuffer, entryPointName); |
102 free(nullTerminatedCodeBuffer); | 102 free(nullTerminatedCodeBuffer); |
103 return kernel; | 103 return kernel; |
104 } | 104 } |
105 | 105 |
106 #if defined(LINUX) | 106 #if defined(LINUX) |
111 static char const okra_library_name[] = ""; | 111 static char const okra_library_name[] = ""; |
112 #endif | 112 #endif |
113 | 113 |
114 #define STD_BUFFER_SIZE 1024 | 114 #define STD_BUFFER_SIZE 1024 |
115 | 115 |
116 #define STRINGIFY(x) #x | |
117 | |
118 #define LOOKUP_OKRA_FUNCTION(name, alias) \ | |
119 _##alias = \ | |
120 CAST_TO_FN_PTR(alias##_func_t, os::dll_lookup(handle, STRINGIFY(name))); \ | |
121 if (_##alias == NULL) { \ | |
122 tty->print_cr("[HSAIL] ***** Error: Failed to lookup %s in %s, wrong version of OKRA?", STRINGIFY(name), okra_library_name); \ | |
123 return 0; \ | |
124 } \ | |
125 | |
116 bool gpu::Hsail::probe_linkage() { | 126 bool gpu::Hsail::probe_linkage() { |
117 if (okra_library_name != NULL) { | 127 if (okra_library_name != NULL) { |
118 char *buffer = (char*)malloc(STD_BUFFER_SIZE); | 128 char *buffer = (char*)malloc(STD_BUFFER_SIZE); |
119 if (TraceGPUInteraction) { | 129 if (TraceGPUInteraction) { |
120 tty->print_cr("[HSAIL] library is %s", okra_library_name); | 130 tty->print_cr("[HSAIL] library is %s", okra_library_name); |
121 } | 131 } |
122 void *handle = os::dll_load(okra_library_name, buffer, STD_BUFFER_SIZE); | 132 void *handle = os::dll_load(okra_library_name, buffer, STD_BUFFER_SIZE); |
123 free(buffer); | 133 free(buffer); |
124 if (handle != NULL) { | 134 if (handle != NULL) { |
125 | 135 |
126 _okra_ctx_create = | 136 LOOKUP_OKRA_FUNCTION(okra_create_context, okra_create_context); |
127 CAST_TO_FN_PTR(okra_ctx_create_func_t, os::dll_lookup(handle, "okra_create_context")); | 137 LOOKUP_OKRA_FUNCTION(okra_create_kernel, okra_create_kernel); |
128 _okra_kernel_create = | 138 LOOKUP_OKRA_FUNCTION(okra_push_object, okra_push_object); |
129 CAST_TO_FN_PTR(okra_kernel_create_func_t, os::dll_lookup(handle, "okra_create_kernel")); | 139 LOOKUP_OKRA_FUNCTION(okra_push_boolean, okra_push_boolean); |
130 _okra_push_object = | 140 LOOKUP_OKRA_FUNCTION(okra_push_byte, okra_push_byte); |
131 CAST_TO_FN_PTR(okra_push_object_func_t, os::dll_lookup(handle, "okra_push_object")); | 141 LOOKUP_OKRA_FUNCTION(okra_push_double, okra_push_double); |
132 _okra_push_boolean = | 142 LOOKUP_OKRA_FUNCTION(okra_push_float, okra_push_float); |
133 CAST_TO_FN_PTR(okra_push_boolean_func_t, os::dll_lookup(handle, "okra_push_boolean")); | 143 LOOKUP_OKRA_FUNCTION(okra_push_int, okra_push_int); |
134 _okra_push_byte = | 144 LOOKUP_OKRA_FUNCTION(okra_push_long, okra_push_long); |
135 CAST_TO_FN_PTR(okra_push_byte_func_t, os::dll_lookup(handle, "okra_push_byte")); | 145 LOOKUP_OKRA_FUNCTION(okra_execute_with_range, okra_execute_with_range); |
136 _okra_push_double = | 146 LOOKUP_OKRA_FUNCTION(okra_clearargs, okra_clearargs); |
137 CAST_TO_FN_PTR(okra_push_double_func_t, os::dll_lookup(handle, "okra_push_double")); | 147 LOOKUP_OKRA_FUNCTION(okra_register_heap, okra_register_heap); |
138 _okra_push_float = | |
139 CAST_TO_FN_PTR(okra_push_float_func_t, os::dll_lookup(handle, "okra_push_float")); | |
140 _okra_push_int = | |
141 CAST_TO_FN_PTR(okra_push_int_func_t, os::dll_lookup(handle, "okra_push_int")); | |
142 _okra_push_long = | |
143 CAST_TO_FN_PTR(okra_push_long_func_t, os::dll_lookup(handle, "okra_push_long")); | |
144 _okra_execute_with_range = | |
145 CAST_TO_FN_PTR(okra_execute_with_range_func_t, os::dll_lookup(handle, "okra_execute_with_range")); | |
146 _okra_clearargs = | |
147 CAST_TO_FN_PTR(okra_clearargs_func_t, os::dll_lookup(handle, "okra_clearargs")); | |
148 _okra_register_heap = | |
149 CAST_TO_FN_PTR(okra_register_heap_func_t, os::dll_lookup(handle, "okra_register_heap")); | |
150 | 148 |
151 if (TraceGPUInteraction) { | |
152 tty->print_cr("[HSAIL] Success: library linkage _okra_clearargs=0x%08x", _okra_clearargs); | |
153 } | |
154 return true; | 149 return true; |
155 } else { | 150 } else { |
156 // Unable to dlopen okra | 151 // Unable to dlopen okra |
157 if (TraceGPUInteraction) { | 152 if (TraceGPUInteraction) { |
158 tty->print_cr("[HSAIL] library load failed."); | 153 tty->print_cr("[HSAIL] library load failed."); |