Skip to content

Commit c9172c1

Browse files
authored
Make enforce target (#5889)
* make enforce a target and dependent on nccl when gpu is enabled * add some more dependency
1 parent 50d670e commit c9172c1

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

paddle/memory/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_subdirectory(detail)
22

3-
cc_library(memory SRCS memory.cc DEPS place)
3+
cc_library(memory SRCS memory.cc DEPS place enforce)
44
cc_library(memcpy SRCS memcpy.cc)
55

66
cc_library(paddle_memory

paddle/platform/CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
cc_library(cpu_info SRCS cpu_info.cc DEPS gflags glog)
1+
if(WITH_GPU)
2+
cc_library(enforce SRCS enforce.cc DEPS nccl)
3+
else()
4+
cc_library(enforce SRCS enforce.cc)
5+
endif()
6+
cc_test(enforce_test SRCS enforce_test.cc DEPS stringpiece enforce)
7+
8+
cc_library(cpu_info SRCS cpu_info.cc DEPS gflags glog enforce)
29
cc_test(cpu_info_test SRCS cpu_info_test.cc DEPS cpu_info)
310

4-
nv_library(gpu_info SRCS gpu_info.cc DEPS gflags glog)
11+
nv_library(gpu_info SRCS gpu_info.cc DEPS gflags glog enforce)
512

6-
cc_library(place SRCS place.cc)
13+
cc_library(place SRCS place.cc DEPS enforce)
714
cc_test(place_test SRCS place_test.cc DEPS place glog gflags)
815

916
add_subdirectory(dynload)
1017

11-
cc_test(enforce_test SRCS enforce_test.cc DEPS stringpiece)
12-
1318
IF(WITH_GPU)
1419
set(GPU_CTX_DEPS dynload_cuda dynamic_loader)
1520
ELSE()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
cc_library(dynamic_loader SRCS dynamic_loader.cc DEPS glog gflags)
1+
cc_library(dynamic_loader SRCS dynamic_loader.cc DEPS glog gflags enforce)
22
nv_library(dynload_cuda SRCS cublas.cc cudnn.cc curand.cc nccl.cc
33
DEPS dynamic_loader nccl)

paddle/platform/enforce.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License. */
14+
15+
#include "paddle/platform/enforce.h"
16+
17+
namespace paddle {
18+
namespace platform {} // namespace platform
19+
} // namespace paddle

paddle/platform/enforce.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ limitations under the License. */
4949
namespace paddle {
5050
namespace platform {
5151

52-
namespace {
5352
#ifdef __GNUC__
5453
inline std::string demangle(std::string name) {
5554
int status = -4; // some arbitrary value to eliminate the compiler warning
@@ -60,7 +59,6 @@ inline std::string demangle(std::string name) {
6059
#else
6160
inline std::string demangle(std::string name) { return name; }
6261
#endif
63-
}
6462

6563
struct EnforceNotMet : public std::exception {
6664
std::exception_ptr exp_;

0 commit comments

Comments
 (0)