From d7bd0361cb36587c07f1edf973672fd24e67e720 Mon Sep 17 00:00:00 2001 From: Wu Yi Date: Mon, 19 Nov 2018 09:56:06 +0800 Subject: [PATCH] fix dist deps (#14471) * fix dist deps test=develop * update test=develop * update test=develop * update test=develop * update test=develop --- cmake/operators.cmake | 9 +++++++-- paddle/fluid/operators/distributed_ops/CMakeLists.txt | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/operators.cmake b/cmake/operators.cmake index c9d0f80da..3d8a6aa23 100644 --- a/cmake/operators.cmake +++ b/cmake/operators.cmake @@ -196,7 +196,7 @@ endfunction() function(register_operators) set(options "") set(oneValueArgs "") - set(multiValueArgs EXCLUDES) + set(multiValueArgs EXCLUDES DEPS) cmake_parse_arguments(register_operators "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -204,11 +204,16 @@ function(register_operators) string(REPLACE "_mkldnn" "" OPS "${OPS}") string(REPLACE ".cc" "" OPS "${OPS}") list(REMOVE_DUPLICATES OPS) + list(LENGTH register_operators_DEPS register_operators_DEPS_len) foreach(src ${OPS}) list(FIND register_operators_EXCLUDES ${src} _index) if (${_index} EQUAL -1) - op_library(${src}) + if (${register_operators_DEPS_len} GREATER 0) + op_library(${src} DEPS ${register_operators_DEPS}) + else() + op_library(${src}) + endif() endif() endforeach() endfunction() diff --git a/paddle/fluid/operators/distributed_ops/CMakeLists.txt b/paddle/fluid/operators/distributed_ops/CMakeLists.txt index a071babc8..28bb90af5 100644 --- a/paddle/fluid/operators/distributed_ops/CMakeLists.txt +++ b/paddle/fluid/operators/distributed_ops/CMakeLists.txt @@ -29,11 +29,11 @@ foreach(src ${OPS}) set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS}) endforeach() -register_operators(EXCLUDES gen_nccl_id_op) +register_operators(EXCLUDES gen_nccl_id_op DEPS ${DISTRIBUTE_DEPS}) if(WITH_GPU AND NOT WIN32) set(DISTRIBUTE_DEPS ${DISTRIBUTE_DEPS} nccl_common) - op_library(gen_nccl_id_op) + op_library(gen_nccl_id_op ${DISTRIBUTE_DEPS} nccl_common) endif() set(OPERATOR_DEPS ${OPERATOR_DEPS} ${DISTRIBUTE_DEPS} PARENT_SCOPE) -- GitLab