Mercurial > hg > truffle
annotate src/gpu/ptx/gpu_ptx.hpp @ 10435:89c15a40ef35
Align foreign call descriptors
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Thu, 20 Jun 2013 17:30:39 +0200 |
parents | 147162b27799 |
children | 7a3499bf5e2c |
rev | line source |
---|---|
9430
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
1 /* |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
4 * |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
8 * |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
14 * |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
18 * |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
21 * questions. |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
22 * |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
23 */ |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
24 |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
25 #ifndef GPU_PTX_HPP |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
26 #define GPU_PTX_HPP |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
27 |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
28 class Ptx { |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
29 friend class gpu; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
30 |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
31 protected: |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
32 static void probe_linkage(); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
33 #ifdef __APPLE__ |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
34 static bool probe_linkage_apple(); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
35 #endif |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
36 static bool initialize_gpu(); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
37 static void generate_kernel(unsigned char *code, int code_len, const char *name); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
38 |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
39 private: |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
40 typedef int (*cuda_cu_init_func_t)(unsigned int, int); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
41 typedef int (*cuda_cu_ctx_create_func_t)(void *, int, int); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
42 typedef int (*cuda_cu_ctx_detach_func_t)(int *); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
43 typedef int (*cuda_cu_ctx_synchronize_func_t)(int *); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
44 typedef int (*cuda_cu_device_get_count_func_t)(int *); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
45 typedef int (*cuda_cu_device_get_name_func_t)(char *, int, int); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
46 typedef int (*cuda_cu_device_get_func_t)(int *, int); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
47 typedef int (*cuda_cu_device_compute_capability_func_t)(int *, int *, int); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
48 typedef int (*cuda_cu_launch_kernel_func_t)(int *, int *, int); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
49 typedef int (*cuda_cu_module_get_function_func_t)(void *, void *, const char *); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
50 typedef int (*cuda_cu_module_load_data_ex_func_t)(void *, void *, unsigned int, int *, void **); |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
51 |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
52 static cuda_cu_init_func_t _cuda_cu_init; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
53 static cuda_cu_ctx_create_func_t _cuda_cu_ctx_create; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
54 static cuda_cu_ctx_detach_func_t _cuda_cu_ctx_detach; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
55 static cuda_cu_ctx_synchronize_func_t _cuda_cu_ctx_synchronize; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
56 static cuda_cu_device_get_count_func_t _cuda_cu_device_get_count; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
57 static cuda_cu_device_get_name_func_t _cuda_cu_device_get_name; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
58 static cuda_cu_device_get_func_t _cuda_cu_device_get; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
59 static cuda_cu_device_compute_capability_func_t _cuda_cu_device_compute_capability; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
60 static cuda_cu_launch_kernel_func_t _cuda_cu_launch_kernel; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
61 static cuda_cu_module_get_function_func_t _cuda_cu_module_get_function; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
62 static cuda_cu_module_load_data_ex_func_t _cuda_cu_module_load_data_ex; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
63 |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
64 protected: |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
65 static void * _device_context; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
66 }; |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
67 |
147162b27799
GRAAL-234 - PTX code loading
Morris Meyer <morris.meyer@oracle.com>
parents:
diff
changeset
|
68 #endif // GPU_PTX_HPP |