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
40
namespace
apollo
{
41
namespace
perception {
42
namespace
inference {
43
44
class
CudaUtil
{
45
public
:
46
static
bool
set_device_id
(
int
device_id);
47
static
cublasHandle_t&
get_handler
();
48
~CudaUtil
();
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
apollo::perception::inference::CudaUtil
Definition
cuda_util.h:44
apollo::perception::inference::CudaUtil::~CudaUtil
~CudaUtil()
apollo::perception::inference::CudaUtil::get_handler
static cublasHandle_t & get_handler()
apollo::perception::inference::CudaUtil::set_device_id
static bool set_device_id(int device_id)
apollo
class register implement
Definition
arena_queue.h:37
modules
perception
common
inference
utils
cuda_util.h