10879
|
1 /*
|
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 *
|
|
5 * This code is free software; you can redistribute it and/or modify it
|
|
6 * under the terms of the GNU General Public License version 2 only, as
|
|
7 * published by the Free Software Foundation.
|
|
8 *
|
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 * version 2 for more details (a copy is included in the LICENSE file that
|
|
13 * accompanied this code).
|
|
14 *
|
|
15 * You should have received a copy of the GNU General Public License version
|
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 *
|
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 * or visit www.oracle.com if you need additional information or have any
|
|
21 * questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 #ifndef GPU_PTX_HPP
|
|
26 #define GPU_PTX_HPP
|
|
27
|
|
28 /*
|
|
29 * Some useful macro definitions from publicly available cuda.h.
|
|
30 * These definitions are for convenience.
|
|
31 */
|
|
32 #define GRAAL_CUDA_SUCCESS 0
|
|
33 #define GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR 75
|
|
34 #define GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR 76
|
|
35 #define GRAAL_CU_JIT_MAX_REGISTERS 0
|
|
36 #define GRAAL_CU_JIT_THREADS_PER_BLOCK 1
|
|
37 #define GRAAL_CU_JIT_INFO_LOG_BUFFER 3
|
|
38 #define GRAAL_CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES 4
|
|
39 #define GRAAL_CUDA_ERROR_NO_BINARY_FOR_GPU 209
|
|
40
|
|
41 class Ptx {
|
|
42 friend class gpu;
|
|
43
|
|
44 protected:
|
|
45 static bool probe_linkage();
|
|
46 static bool initialize_gpu();
|
|
47 static void * generate_kernel(unsigned char *code, int code_len, const char *name);
|
|
48 static bool execute_kernel(address kernel);
|
|
49
|
|
50 private:
|
|
51 typedef int (*cuda_cu_init_func_t)(unsigned int);
|
|
52 typedef int (*cuda_cu_ctx_create_func_t)(void *, int, int);
|
|
53 typedef int (*cuda_cu_ctx_detach_func_t)(int *);
|
|
54 typedef int (*cuda_cu_ctx_synchronize_func_t)(int *);
|
|
55 typedef int (*cuda_cu_device_get_count_func_t)(int *);
|
|
56 typedef int (*cuda_cu_device_get_name_func_t)(char *, int, int);
|
|
57 typedef int (*cuda_cu_device_get_func_t)(int *, int);
|
|
58 typedef int (*cuda_cu_device_compute_capability_func_t)(int *, int *, int);
|
|
59 typedef int (*cuda_cu_device_get_attribute_func_t)(int *, int, int);
|
|
60 typedef int (*cuda_cu_launch_kernel_func_t)(void *,
|
|
61 unsigned int, unsigned int, unsigned int,
|
|
62 unsigned int, unsigned int, unsigned int,
|
|
63 unsigned int, void *, void **, void **);
|
|
64 typedef int (*cuda_cu_module_get_function_func_t)(void *, void *, const char *);
|
|
65 typedef int (*cuda_cu_module_load_data_ex_func_t)(void *, void *, unsigned int, void *, void **);
|
|
66
|
|
67 static cuda_cu_init_func_t _cuda_cu_init;
|
|
68 static cuda_cu_ctx_create_func_t _cuda_cu_ctx_create;
|
|
69 static cuda_cu_ctx_detach_func_t _cuda_cu_ctx_detach;
|
|
70 static cuda_cu_ctx_synchronize_func_t _cuda_cu_ctx_synchronize;
|
|
71 static cuda_cu_device_get_count_func_t _cuda_cu_device_get_count;
|
|
72 static cuda_cu_device_get_name_func_t _cuda_cu_device_get_name;
|
|
73 static cuda_cu_device_get_func_t _cuda_cu_device_get;
|
|
74 static cuda_cu_device_compute_capability_func_t _cuda_cu_device_compute_capability; /* Deprecated as of CUDA 5.0 */
|
|
75 static cuda_cu_device_get_attribute_func_t _cuda_cu_device_get_attribute;
|
|
76 static cuda_cu_launch_kernel_func_t _cuda_cu_launch_kernel;
|
|
77 static cuda_cu_module_get_function_func_t _cuda_cu_module_get_function;
|
|
78 static cuda_cu_module_load_data_ex_func_t _cuda_cu_module_load_data_ex;
|
|
79
|
|
80 protected:
|
|
81 static void * _device_context;
|
|
82 };
|
|
83 #endif // GPU_PTX_HPP
|