Apollo 11.0
自动驾驶开放平台
cuda_util.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
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#pragma once
18
19#if GPU_PLATFORM == NVIDIA
20 #include <cublas_v2.h>
21 #include <cuda_runtime_api.h>
22#elif GPU_PLATFORM == AMD
23 #include <hipblas.h>
24 #include <hip/hip_runtime_api.h>
25 #define CUBLAS_STATUS_SUCCESS HIPBLAS_STATUS_SUCCESS
26 #define CUBLAS_OP_N HIPBLAS_OP_N
27 #define CUBLAS_OP_T HIPBLAS_OP_T
28 #define cublasCreate hipblasCreate
29 #define cublasDestroy hipblasDestroy
30 #define cublasHandle_t hipblasHandle_t
31 #define cublasOperation_t hipblasOperation_t
32 #define cublasSgemm hipblasSgemm
33 #define cublasStatus_t hipblasStatus_t
34 #define cudaGetDevice hipGetDevice
35 #define cudaGetErrorString hipGetErrorString
36 #define cudaSetDevice hipSetDevice
37 #define cudaSuccess hipSuccess
38#endif
39
40namespace apollo {
41namespace perception {
42namespace inference {
43
44class CudaUtil {
45 public:
46 static bool set_device_id(int device_id);
47 static cublasHandle_t& get_handler();
49
50 private:
51 CudaUtil();
52 static CudaUtil& get();
53 cublasHandle_t cublas_handle_;
54};
55
56} // namespace inference
57} // namespace perception
58} // namespace apollo
static cublasHandle_t & get_handler()
static bool set_device_id(int device_id)
class register implement
Definition arena_queue.h:37