Apollo
10.0
自动驾驶开放平台
common.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
#include <cassert>
20
21
#if USE_GPU == 1
22
#if GPU_PLATFORM == NVIDIA
23
#include <cublas_v2.h>
24
#include <cuda_runtime.h>
25
#include <cuda_runtime_api.h>
26
#elif GPU_PLATFORM == AMD
27
#include <hipblas.h>
28
#include <hip/hip_runtime.h>
29
#include <hip/hip_runtime_api.h>
30
#define cublasCreate hipblasCreate
31
#define cublasDestroy hipblasDestroy
32
#define cublasHandle_t hipblasHandle_t
33
#define cudaDeviceProp hipDeviceProp_t
34
#define cudaDeviceSynchronize hipDeviceSynchronize
35
#define cudaError_t hipError_t
36
#define cudaFree hipFree
37
#define cudaFreeHost hipHostFree
38
#define cudaGetDevice hipGetDevice
39
#define cudaGetDeviceCount hipGetDeviceCount
40
#define cudaGetDeviceProperties hipGetDeviceProperties
41
#define cudaGetErrorString hipGetErrorString
42
#define cudaMalloc hipMalloc
43
#define cudaMallocHost hipMallocHost
44
#define cudaMemcpy hipMemcpy
45
#define cudaMemcpyAsync hipMemcpyAsync
46
#define cudaMemcpyDefault hipMemcpyDefault
47
#define cudaMemcpyDeviceToDevice hipMemcpyDeviceToDevice
48
#define cudaMemcpyDeviceToHost hipMemcpyDeviceToHost
49
#define cudaMemcpyHostToDevice hipMemcpyHostToDevice
50
#define cudaMemcpyKind hipMemcpyKind
51
#define cudaMemset hipMemset
52
#define cudaMemsetAsync hipMemsetAsync
53
#define cudaPointerAttributes hipPointerAttribute_t
54
#define cudaPointerGetAttributes hipPointerGetAttributes
55
#define cudaSetDevice hipSetDevice
56
#define cudaStream_t hipStream_t
57
#define cudaStreamCreate hipStreamCreate
58
#define cudaStreamDestroy hipStreamDestroy
59
#define cudaStreamSynchronize hipStreamSynchronize
60
#define cudaSuccess hipSuccess
61
#endif
62
#endif
63
64
namespace
apollo
{
65
namespace
perception {
66
namespace
base {
67
68
#ifndef NO_GPU
69
#define NO_GPU assert(false)
70
#endif
71
72
#if USE_GPU == 1
73
74
#define BASE_GPU_CHECK(condition) \
75
{ apollo::perception::base::GPUAssert((condition), __FILE__, __LINE__); }
76
77
inline
void
GPUAssert(cudaError_t code,
const
char
*file,
int
line,
78
bool
abort =
true
) {
79
if
(code != cudaSuccess) {
80
fprintf(stderr,
"GPUassert: %s %s %d\n"
, cudaGetErrorString(code), file,
81
line);
82
if
(abort) {
83
exit(code);
84
}
85
}
86
}
87
88
#endif
89
90
}
// namespace base
91
}
// namespace perception
92
}
// namespace apollo
apollo
class register implement
Definition
arena_queue.h:37
modules
perception
common
base
common.h