Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/gpu.cpp @ 11606:4f69a5189e77
Create runtime object based on GPUIL type newly added to gpu class; some code refactoring.
author | bharadwaj |
---|---|
date | Wed, 11 Sep 2013 17:02:40 -0400 |
parents | d55f24eac4b1 |
children | 103795ab699d |
comparison
equal
deleted
inserted
replaced
11605:3676540f71cf | 11606:4f69a5189e77 |
---|---|
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "runtime/gpu.hpp" | 26 #include "runtime/gpu.hpp" |
27 | 27 |
28 bool gpu::_available = false; // does the hardware exist? | 28 bool gpu::_available = false; // does the hardware exist? |
29 bool gpu::_gpu_linkage = false; // is the driver library to access the GPU installed | 29 bool gpu::_gpu_linkage = false; // is the driver library to access the GPU installed |
30 bool gpu::_initialized = false; // is the GPU device initialized | 30 bool gpu::_initialized = false; // is the GPU device initialized |
31 gpu::TargetGPUIL gpu::_targetIL = gpu::NONE; // No GPU detected yet. | |
31 | 32 |
32 void gpu::init() { | 33 void gpu::init() { |
33 #if defined(TARGET_OS_FAMILY_bsd) || defined(TARGET_OS_FAMILY_linux) | 34 #if defined(TARGET_OS_FAMILY_bsd) || defined(TARGET_OS_FAMILY_linux) |
34 gpu::probe_gpu(); | 35 gpu::probe_gpu(); |
36 if (gpu::get_target_il_type() == gpu::PTX) { | |
37 set_gpu_linkage(gpu::Ptx::probe_linkage()); | |
38 } else { | |
39 set_gpu_linkage(false); | |
40 } | |
35 #endif | 41 #endif |
36 // need multi-gpu TARGET ifdef | |
37 gpu::probe_linkage(); | |
38 } | 42 } |
43 | |
44 void gpu::initialize_gpu() { | |
45 if (gpu::has_gpu_linkage()) { | |
46 if (gpu::get_target_il_type() == gpu::PTX) { | |
47 set_initialized(gpu::Ptx::initialize_gpu()); | |
48 } | |
49 // Add initialization of other GPUs here | |
50 } | |
51 } | |
52 | |
53 void * gpu::generate_kernel(unsigned char *code, int code_len, const char *name) { | |
54 if (gpu::has_gpu_linkage()) { | |
55 if (gpu::get_target_il_type() == gpu::PTX) { | |
56 return (gpu::Ptx::generate_kernel(code, code_len, name)); | |
57 } | |
58 } else { | |
59 // Add kernel generation functionality of other GPUs here | |
60 return NULL; | |
61 } | |
62 } | |
63 | |
64 bool gpu::execute_kernel(address kernel, PTXKernelArguments & ptxka, JavaValue& ret) { | |
65 if (gpu::has_gpu_linkage()) { | |
66 if (gpu::get_target_il_type() == gpu::PTX) { | |
67 return (gpu::Ptx::execute_kernel(kernel, ptxka, ret)); | |
68 } | |
69 } else { | |
70 // Add kernel execution functionality of other GPUs here | |
71 return false; | |
72 } | |
73 } | |
74 |