1 | /******************************************************************************* |
2 | * Copyright 2020-2022 Intel Corporation |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | *******************************************************************************/ |
16 | |
17 | #include "gpu/ocl/ocl_gpu_hw_info.hpp" |
18 | |
19 | #include "gpu/jit/binary_format.hpp" |
20 | #include "gpu/jit/jit_generator.hpp" |
21 | #include "gpu/jit/utils/ngen_type_bridge.hpp" |
22 | |
23 | namespace dnnl { |
24 | namespace impl { |
25 | namespace gpu { |
26 | namespace ocl { |
27 | |
28 | void init_gpu_hw_info(engine_t *engine, cl_device_id device, cl_context context, |
29 | compute::gpu_arch_t &gpu_arch, int &stepping_id, |
30 | bool &mayiuse_ngen_kernels) { |
31 | using namespace ngen; |
32 | |
33 | HW hw = HW::Unknown; |
34 | jit::jit_generator<HW::Unknown>::detectHWInfo( |
35 | context, device, hw, stepping_id); |
36 | |
37 | gpu_arch = jit::convert_ngen_arch_to_dnnl(hw); |
38 | |
39 | auto status |
40 | = jit::gpu_supports_binary_format(&mayiuse_ngen_kernels, engine); |
41 | if (status != status::success) mayiuse_ngen_kernels = false; |
42 | } |
43 | |
44 | } // namespace ocl |
45 | } // namespace gpu |
46 | } // namespace impl |
47 | } // namespace dnnl |
48 | |