Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
099ba7b6
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
099ba7b6
编写于
8月 28, 2020
作者:
S
storypku
提交者:
Xiangquan Xiao
8月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Build: unified usage of macros USE_GPU and CPU_ONLY as USE_GPU
上级
50e863d1
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
48 addition
and
64 deletion
+48
-64
modules/perception/base/blob_test.cc
modules/perception/base/blob_test.cc
+1
-1
modules/perception/base/common.h
modules/perception/base/common.h
+4
-2
modules/perception/base/common_test.cc
modules/perception/base/common_test.cc
+1
-1
modules/perception/base/options_define.h
modules/perception/base/options_define.h
+0
-22
modules/perception/base/syncedmem.cc
modules/perception/base/syncedmem.cc
+11
-11
modules/perception/base/syncedmem.h
modules/perception/base/syncedmem.h
+3
-3
modules/perception/base/syncedmem_test.cc
modules/perception/base/syncedmem_test.cc
+3
-3
modules/perception/base/test/test_helper.h
modules/perception/base/test/test_helper.h
+1
-1
modules/perception/camera/common/data_provider.cc
modules/perception/camera/common/data_provider.cc
+3
-1
modules/perception/camera/common/undistortion_handler.cc
modules/perception/camera/common/undistortion_handler.cc
+4
-1
modules/perception/camera/test/camera_lib_traffic_light_detector_detection_test.cc
.../test/camera_lib_traffic_light_detector_detection_test.cc
+3
-3
modules/perception/camera/test/camera_lib_traffic_light_detector_recognition_test.cc
...est/camera_lib_traffic_light_detector_recognition_test.cc
+8
-8
modules/perception/lidar/lib/segmentation/cnnseg/feature_generator.cc
...eption/lidar/lib/segmentation/cnnseg/feature_generator.cc
+2
-2
modules/perception/lidar/lib/segmentation/cnnseg/feature_generator.h
...ception/lidar/lib/segmentation/cnnseg/feature_generator.h
+4
-4
modules/planning/open_space/trajectory_smoother/planning_block.h
.../planning/open_space/trajectory_smoother/planning_block.h
+0
-1
未找到文件。
modules/perception/base/blob_test.cc
浏览文件 @
099ba7b6
...
...
@@ -116,7 +116,7 @@ TEST(BlobTest, source_test) {
blob_4d
.
Reshape
({
1
,
3
,
4
,
5
});
blob_4d
.
set_cpu_data
(
cpu_data
);
#if
ndef CPU_ONLY
#if
USE_GPU == 1
blob_4d
.
Reshape
({
2
,
3
,
4
,
5
});
float
*
gpu_data
=
nullptr
;
BASE_CUDA_CHECK
(
cudaMalloc
(
&
gpu_data
,
blob_4d
.
count
()
*
sizeof
(
float
)));
...
...
modules/perception/base/common.h
浏览文件 @
099ba7b6
...
...
@@ -16,7 +16,9 @@
#pragma once
#ifndef CPU_ONLY
#include <cassert>
#if USE_GPU == 1
#include <cublas_v2.h>
#include <cuda_runtime.h>
...
...
@@ -31,7 +33,7 @@ namespace base {
#define NO_GPU assert(false)
#endif
#if
ndef CPU_ONLY
#if
USE_GPU == 1
#define BASE_CUDA_CHECK(condition) \
{ apollo::perception::base::GPUAssert((condition), __FILE__, __LINE__); }
...
...
modules/perception/base/common_test.cc
浏览文件 @
099ba7b6
...
...
@@ -22,7 +22,7 @@ namespace perception {
namespace
base
{
TEST
(
CommonTest
,
GPUAssertTest
)
{
#if
ndef CPU_ONLY
#if
USE_GPU == 1
GPUAssert
(
cudaSetDevice
(
-
1
),
__FILE__
,
__LINE__
,
false
);
#endif
}
...
...
modules/perception/base/options_define.h
已删除
100644 → 0
浏览文件 @
50e863d1
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
// build perception with cpu or gpu
/* #undef CPU_ONLY */
// build perception with using cyber log lib or glog lib
/* #undef PERCEPTION_USE_CYBER */
modules/perception/base/syncedmem.cc
浏览文件 @
099ba7b6
...
...
@@ -75,7 +75,7 @@ SyncedMemory::SyncedMemory(bool use_cuda)
cpu_malloc_use_cuda_
(
use_cuda
),
own_gpu_data_
(
false
),
device_
(
-
1
)
{
#if
ndef CPU_ONLY
#if
USE_GPU == 1
#ifdef PERCEPTION_DEBUG
BASE_CUDA_CHECK
(
cudaGetDevice
(
&
device_
));
#endif
...
...
@@ -91,7 +91,7 @@ SyncedMemory::SyncedMemory(size_t size, bool use_cuda)
cpu_malloc_use_cuda_
(
use_cuda
),
own_gpu_data_
(
false
),
device_
(
-
1
)
{
#if
ndef CPU_ONLY
#if
USE_GPU == 1
#ifdef PERCEPTION_DEBUG
BASE_CUDA_CHECK
(
cudaGetDevice
(
&
device_
));
#endif
...
...
@@ -104,11 +104,11 @@ SyncedMemory::~SyncedMemory() {
PerceptionFreeHost
(
cpu_ptr_
,
cpu_malloc_use_cuda_
);
}
#if
ndef CPU_ONLY
#if
USE_GPU == 1
if
(
gpu_ptr_
&&
own_gpu_data_
)
{
BASE_CUDA_CHECK
(
cudaFree
(
gpu_ptr_
));
}
#endif //
CPU_ONLY
#endif //
USE_GPU
}
inline
void
SyncedMemory
::
to_cpu
()
{
...
...
@@ -125,7 +125,7 @@ inline void SyncedMemory::to_cpu() {
own_cpu_data_
=
true
;
break
;
case
HEAD_AT_GPU
:
#if
ndef CPU_ONLY
#if
USE_GPU == 1
if
(
cpu_ptr_
==
nullptr
)
{
PerceptionMallocHost
(
&
cpu_ptr_
,
size_
,
cpu_malloc_use_cuda_
);
own_cpu_data_
=
true
;
...
...
@@ -144,7 +144,7 @@ inline void SyncedMemory::to_cpu() {
inline
void
SyncedMemory
::
to_gpu
()
{
check_device
();
#if
ndef CPU_ONLY
#if
USE_GPU == 1
switch
(
head_
)
{
case
UNINITIALIZED
:
BASE_CUDA_CHECK
(
cudaMalloc
(
&
gpu_ptr_
,
size_
));
...
...
@@ -188,7 +188,7 @@ void SyncedMemory::set_cpu_data(void* data) {
const
void
*
SyncedMemory
::
gpu_data
()
{
check_device
();
#if
ndef CPU_ONLY
#if
USE_GPU == 1
to_gpu
();
return
(
const
void
*
)
gpu_ptr_
;
#else
...
...
@@ -199,7 +199,7 @@ const void* SyncedMemory::gpu_data() {
void
SyncedMemory
::
set_gpu_data
(
void
*
data
)
{
check_device
();
#if
ndef CPU_ONLY
#if
USE_GPU == 1
ACHECK
(
data
);
if
(
own_gpu_data_
)
{
BASE_CUDA_CHECK
(
cudaFree
(
gpu_ptr_
));
...
...
@@ -221,7 +221,7 @@ void* SyncedMemory::mutable_cpu_data() {
void
*
SyncedMemory
::
mutable_gpu_data
()
{
check_device
();
#if
ndef CPU_ONLY
#if
USE_GPU == 1
to_gpu
();
head_
=
HEAD_AT_GPU
;
return
gpu_ptr_
;
...
...
@@ -231,7 +231,7 @@ void* SyncedMemory::mutable_gpu_data() {
#endif
}
#if
ndef CPU_ONLY
#if
USE_GPU == 1
void
SyncedMemory
::
async_gpu_push
(
const
cudaStream_t
&
stream
)
{
check_device
();
CHECK_EQ
(
head_
,
HEAD_AT_CPU
);
...
...
@@ -247,7 +247,7 @@ void SyncedMemory::async_gpu_push(const cudaStream_t& stream) {
#endif
void
SyncedMemory
::
check_device
()
{
#if
ndef CPU_ONLY
#if
USE_GPU == 1
#ifdef PERCEPTION_DEBUG
int
device
;
cudaGetDevice
(
&
device
);
...
...
modules/perception/base/syncedmem.h
浏览文件 @
099ba7b6
...
...
@@ -70,7 +70,7 @@ namespace perception {
namespace
base
{
inline
void
PerceptionMallocHost
(
void
**
ptr
,
size_t
size
,
bool
use_cuda
)
{
#if
ndef CPU_ONLY
#if
USE_GPU == 1
if
(
use_cuda
)
{
BASE_CUDA_CHECK
(
cudaMallocHost
(
ptr
,
size
));
return
;
...
...
@@ -81,7 +81,7 @@ inline void PerceptionMallocHost(void** ptr, size_t size, bool use_cuda) {
}
inline
void
PerceptionFreeHost
(
void
*
ptr
,
bool
use_cuda
)
{
#if
ndef CPU_ONLY
#if
USE_GPU == 1
if
(
use_cuda
)
{
BASE_CUDA_CHECK
(
cudaFreeHost
(
ptr
));
return
;
...
...
@@ -119,7 +119,7 @@ class SyncedMemory {
void
set_head_cpu
()
{
set_head
(
HEAD_AT_CPU
);
}
size_t
size
()
{
return
size_
;
}
#if
ndef CPU_ONLY
#if
USE_GPU == 1
void
async_gpu_push
(
const
cudaStream_t
&
stream
);
#endif
...
...
modules/perception/base/syncedmem_test.cc
浏览文件 @
099ba7b6
...
...
@@ -100,7 +100,7 @@ TEST_F(SyncedMemoryTest, TestInitialization) {
delete
p_mem
;
}
#if
ndef CPU_ONLY
// GPU test
#if
USE_GPU == 1
// GPU test
TEST_F
(
SyncedMemoryTest
,
TestAllocationCPUGPU
)
{
SyncedMemory
mem
(
10
,
true
);
...
...
@@ -118,7 +118,7 @@ TEST_F(SyncedMemoryTest, TestAllocationCPU) {
EXPECT_TRUE
(
mem
.
mutable_cpu_data
());
}
#if
ndef CPU_ONLY
// GPU test
#if
USE_GPU == 1
// GPU test
TEST_F
(
SyncedMemoryTest
,
TestAllocationGPU
)
{
SyncedMemory
mem
(
10
,
true
);
...
...
@@ -145,7 +145,7 @@ TEST_F(SyncedMemoryTest, TestCPUWrite) {
}
}
#if
ndef CPU_ONLY
// GPU test
#if
USE_GPU == 1
// GPU test
TEST_F
(
SyncedMemoryTest
,
TestGPURead
)
{
SyncedMemory
mem
(
10
,
true
);
...
...
modules/perception/base/test/test_helper.h
浏览文件 @
099ba7b6
...
...
@@ -46,7 +46,7 @@ struct CPUDevice {
template
<
typename
Dtype
>
class
CPUDeviceTest
:
public
MultiDeviceTest
<
CPUDevice
<
Dtype
>>
{};
#if
def CPU_ONLY
#if
USE_GPU == 0
typedef
::
testing
::
Types
<
CPUDevice
<
float
>
,
CPUDevice
<
double
>>
TestDtypesAndDevices
;
...
...
modules/perception/camera/common/data_provider.cc
浏览文件 @
099ba7b6
...
...
@@ -15,7 +15,9 @@
*****************************************************************************/
#include "modules/perception/camera/common/data_provider.h"
#if USE_GPU == 1
#include <nppi.h>
#endif
#include "cyber/common/log.h"
...
...
@@ -124,7 +126,7 @@ bool DataProvider::FillImageData(int rows, int cols, const uint8_t *data,
bool
success
=
false
;
#if
def CPU_ONLY
// copy to host memory
#if
USE_GPU == 0
// copy to host memory
AINFO
<<
"Fill in CPU mode ..."
;
if
(
handler_
!=
nullptr
)
{
AERROR
<<
"Undistortion DO NOT support CPU mode!"
;
...
...
modules/perception/camera/common/undistortion_handler.cc
浏览文件 @
099ba7b6
...
...
@@ -17,7 +17,10 @@
#include <vector>
#include "cuda/include/npp.h"
#if USE_GPU == 1
#include <npp.h>
#endif
#include "Eigen/Dense"
#include "cyber/common/log.h"
...
...
modules/perception/camera/test/camera_lib_traffic_light_detector_detection_test.cc
浏览文件 @
099ba7b6
...
...
@@ -116,7 +116,7 @@ TEST(DetectionTest, all) {
gt_lights
.
push_back
(
light2
);
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
EXPECT_TRUE
(
detector
->
Detect
(
detetor_options
,
&
frame
));
EXPECT_EQ
(
lights
.
size
(),
gt_lights
.
size
());
...
...
@@ -185,7 +185,7 @@ TEST(DetectionTest, no_light) {
lights
.
clear
();
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
EXPECT_TRUE
(
detector
->
Detect
(
detetor_options
,
&
frame
));
#endif
}
...
...
@@ -255,7 +255,7 @@ TEST(DetectionTest, out_of_img_light) {
gt_lights
.
push_back
(
light2
);
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
EXPECT_TRUE
(
detector
->
Detect
(
detetor_options
,
&
frame
));
EXPECT_FALSE
(
lights
[
0
]
->
region
.
is_detected
);
...
...
modules/perception/camera/test/camera_lib_traffic_light_detector_recognition_test.cc
浏览文件 @
099ba7b6
...
...
@@ -69,7 +69,7 @@ TEST(RecognizeTest, yellow) {
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
ASSERT_TRUE
(
recognition
->
Detect
(
recognition_options
,
&
frame
));
AINFO
<<
"COLOR "
<<
static_cast
<
int
>
(
lights
[
0
]
->
status
.
color
);
ASSERT_TRUE
(
base
::
TLColor
::
TL_YELLOW
==
lights
[
0
]
->
status
.
color
);
...
...
@@ -125,7 +125,7 @@ TEST(RecognizeTest, red) {
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
ASSERT_TRUE
(
recognition
->
Detect
(
recognition_options
,
&
frame
));
AINFO
<<
"COLOR "
<<
static_cast
<
int
>
(
lights
[
0
]
->
status
.
color
);
ASSERT_TRUE
(
base
::
TLColor
::
TL_RED
==
lights
[
0
]
->
status
.
color
);
...
...
@@ -233,7 +233,7 @@ TEST(RecognizeTest, black) {
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
ASSERT_TRUE
(
recognition
->
Detect
(
recognition_options
,
&
frame
));
AINFO
<<
"COLOR "
<<
static_cast
<
int
>
(
lights
[
0
]
->
status
.
color
);
ASSERT_TRUE
(
base
::
TLColor
::
TL_BLACK
==
lights
[
0
]
->
status
.
color
);
...
...
@@ -285,7 +285,7 @@ TEST(RecognizeTest, no_detection) {
lights
[
0
]
->
region
.
is_detected
=
false
;
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
ASSERT_TRUE
(
recognition
->
Detect
(
recognition_options
,
&
frame
));
AINFO
<<
"COLOR "
<<
static_cast
<
int
>
(
lights
[
0
]
->
status
.
color
);
ASSERT_TRUE
(
base
::
TLColor
::
TL_UNKNOWN_COLOR
==
lights
[
0
]
->
status
.
color
);
...
...
@@ -341,7 +341,7 @@ TEST(RecognizeTest, unknown_class) {
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
ASSERT_FALSE
(
recognition
->
Detect
(
recognition_options
,
&
frame
));
#endif
}
...
...
@@ -395,7 +395,7 @@ TEST(RecognizeTest, quadrate) {
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
ASSERT_TRUE
(
recognition
->
Detect
(
recognition_options
,
&
frame
));
AINFO
<<
"COLOR "
<<
static_cast
<
int
>
(
lights
[
0
]
->
status
.
color
);
ASSERT_TRUE
(
base
::
TLColor
::
TL_GREEN
==
lights
[
0
]
->
status
.
color
);
...
...
@@ -457,7 +457,7 @@ TEST(RecognizeTest, horizontal) {
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
ASSERT_TRUE
(
recognition
->
Detect
(
recognition_options
,
&
frame
));
AINFO
<<
"COLOR "
<<
static_cast
<
int
>
(
lights
[
0
]
->
status
.
color
);
ASSERT_TRUE
(
base
::
TLColor
::
TL_GREEN
==
lights
[
0
]
->
status
.
color
);
...
...
@@ -507,7 +507,7 @@ TEST(RecognizeTest, no_light) {
lights
.
clear
();
frame
.
traffic_lights
=
lights
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
ASSERT_TRUE
(
recognition
->
Detect
(
recognition_options
,
&
frame
));
EXPECT_EQ
(
lights
.
size
(),
0
);
#endif
...
...
modules/perception/lidar/lib/segmentation/cnnseg/feature_generator.cc
浏览文件 @
099ba7b6
...
...
@@ -46,7 +46,7 @@ bool FeatureGenerator::Init(const FeatureParam& feature_param,
// set output feature blob data
float
*
out_blob_data
=
nullptr
;
#if
ndef CPU_ONLY
#if
USE_GPU == 1
log_blob_
.
reset
(
new
base
::
Blob
<
float
>
(
1
,
1
,
1
,
static_cast
<
int
>
(
log_table_
.
size
())));
float
*
log_table
=
log_blob_
->
mutable_gpu_data
();
...
...
@@ -95,7 +95,7 @@ bool FeatureGenerator::Init(const FeatureParam& feature_param,
}
// memory copy direction and distance features
#if
ndef CPU_ONLY
#if
USE_GPU == 1
cudaMemcpy
(
direction_data_
,
direction_data
.
data
(),
direction_data
.
size
()
*
sizeof
(
float
),
cudaMemcpyHostToDevice
);
cudaMemcpy
(
distance_data_
,
distance_data
.
data
(),
...
...
modules/perception/lidar/lib/segmentation/cnnseg/feature_generator.h
浏览文件 @
099ba7b6
...
...
@@ -33,7 +33,7 @@ namespace lidar {
class
FeatureGenerator
{
public:
FeatureGenerator
()
{
#if
ndef CPU_ONLY
#if
USE_GPU == 1
pc_gpu_size_
=
kMaxPointCloudGPUSize
;
BASE_CUDA_CHECK
(
cudaMalloc
(
reinterpret_cast
<
void
**>
(
&
pc_gpu_
),
pc_gpu_size_
*
sizeof
(
base
::
PointF
)));
...
...
@@ -43,7 +43,7 @@ class FeatureGenerator {
}
virtual
~
FeatureGenerator
()
{
#if
ndef CPU_ONLY
#if
USE_GPU == 1
ReleaseGPUMemory
();
#endif
}
...
...
@@ -52,7 +52,7 @@ class FeatureGenerator {
void
Generate
(
const
base
::
PointFCloudPtr
&
pc_ptr
,
const
std
::
vector
<
int
>&
point2grid
)
{
#if
ndef CPU_ONLY
#if
USE_GPU == 1
GenerateGPU
(
pc_ptr
,
point2grid
);
#else
GenerateCPU
(
pc_ptr
,
point2grid
);
...
...
@@ -62,7 +62,7 @@ class FeatureGenerator {
inline
std
::
string
Name
()
const
{
return
"FeatureGenerator"
;
}
private:
#if
ndef CPU_ONLY
#if
USE_GPU == 1
void
GenerateGPU
(
const
base
::
PointFCloudPtr
&
pc_ptr
,
const
std
::
vector
<
int
>&
point2grid
);
void
ReleaseGPUMemory
();
...
...
modules/planning/open_space/trajectory_smoother/planning_block.h
浏览文件 @
099ba7b6
...
...
@@ -16,7 +16,6 @@
#pragma once
#include <cuda.h>
#include <cuda_runtime.h>
namespace
apollo
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录