Apollo
10.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
#include <vector>
18
19
#if GPU_PLATFORM == NVIDIA
20
#include <cuda_runtime_api.h>
21
#include <cublas_v2.h>
22
#elif GPU_PLATFORM == AMD
23
#include <hip/hip_runtime.h>
24
#include <hip/hip_runtime_api.h>
25
#include <hipblas.h>
26
#define cudaError_t hipError_t
27
#define cudaFree hipFree
28
#define cudaMalloc hipMalloc
29
#define cudaMemcpy hipMemcpy
30
#define cudaMemcpyHostToDevice hipMemcpyHostToDevice
31
#define cudaSuccess hipSuccess
32
#define CUBLAS_STATUS_SUCCESS HIPBLAS_STATUS_SUCCESS
33
#define cublasCreate hipblasCreate
34
#define cublasHandle_t hipblasHandle_t
35
#define cublasIdamin hipblasIdamin
36
#define cublasStatus_t hipblasStatus_t
37
#endif
38
39
#include "
modules/common/math/line_segment2d.h
"
40
#include "
modules/common/math/vec2d.h
"
41
42
namespace
apollo
{
43
namespace
pnc_map {
44
45
struct
CudaLineSegment2d
{
46
double
x1
;
47
double
y1
;
48
double
x2
;
49
double
y2
;
50
};
51
52
class
CudaNearestSegment
{
53
public
:
54
CudaNearestSegment
();
55
56
bool
UpdateLineSegment
(
57
const
std::vector<apollo::common::math::LineSegment2d>& segments);
58
59
int
FindNearestSegment
(
double
x,
double
y);
60
61
~CudaNearestSegment
();
62
63
private
:
64
std::size_t size_ = 0;
65
CudaLineSegment2d
* host_seg_;
66
double
* dev_dist_;
67
CudaLineSegment2d
* dev_seg_;
68
cublasHandle_t handle_;
69
};
70
71
}
// namespace pnc_map
72
}
// namespace apollo
apollo::pnc_map::CudaNearestSegment
Definition
cuda_util.h:52
apollo::pnc_map::CudaNearestSegment::UpdateLineSegment
bool UpdateLineSegment(const std::vector< apollo::common::math::LineSegment2d > &segments)
apollo::pnc_map::CudaNearestSegment::CudaNearestSegment
CudaNearestSegment()
apollo::pnc_map::CudaNearestSegment::FindNearestSegment
int FindNearestSegment(double x, double y)
apollo::pnc_map::CudaNearestSegment::~CudaNearestSegment
~CudaNearestSegment()
line_segment2d.h
Define the LineSegment2d class.
apollo
class register implement
Definition
arena_queue.h:37
apollo::pnc_map::CudaLineSegment2d
Definition
cuda_util.h:45
apollo::pnc_map::CudaLineSegment2d::x1
double x1
Definition
cuda_util.h:46
apollo::pnc_map::CudaLineSegment2d::y1
double y1
Definition
cuda_util.h:47
apollo::pnc_map::CudaLineSegment2d::y2
double y2
Definition
cuda_util.h:49
apollo::pnc_map::CudaLineSegment2d::x2
double x2
Definition
cuda_util.h:48
vec2d.h
Defines the Vec2d class.
modules
map
pnc_map
cuda_util.h