Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HACKATHON 6th] Support compiling PaddlePaddle with Clang. #62565

Merged
merged 29 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
15a5834
[HACKATHON 6th][CMake Optimization] fix variable type inconsistent
silverling Mar 7, 2024
3d07f95
[HACKATHON 6th][CMake Optimization] fix uninitialized but used variable
silverling Mar 7, 2024
e5b09ec
[HACKATHON 6th][CMake Optimization] add flags "-Wno-defaulted-functio…
silverling Mar 7, 2024
db64b59
[HACKATHON 6th][CMake Optimization] fix copy elision
silverling Mar 7, 2024
9ee4752
[HACKATHON 6th][CMake Optimization] fix struct and class tag mismatch
silverling Mar 7, 2024
e4ec35b
[HACKATHON 6th][CMake Optimization] add copy or copy assignment const…
silverling Mar 7, 2024
6c53752
[HACKATHON 6th][CMake Optimization] fix operator+ infinite recursion
silverling Mar 7, 2024
a94437a
[HACKATHON 6th][CMake Optimization] remove unused lambda captures
silverling Mar 8, 2024
7fa668c
[HACKATHON 6th][CMake Optimization] fix overlapping comparisons
silverling Mar 8, 2024
35cd66d
[HACKATHON 6th][CMake Optimization] add final keyword for final subclass
silverling Mar 8, 2024
b86ad32
[HACKATHON 6th][CMake Optimization] comment out unused local variable…
silverling Mar 8, 2024
9ef4946
[HACKATHON 6th][CMake Optimization] fix C-compatible declaration for …
silverling Mar 8, 2024
0ca8772
[HACKATHON 6th][CMake Optimization] add override keyword
silverling Mar 8, 2024
d0bd6cd
[HACKATHON 6th][CMake Optimization] add macro check for custom device
silverling Mar 8, 2024
f6984df
[HACKATHON 6th][CMake Optimization] fix rocksdb compatibility with clang
silverling Mar 8, 2024
732178f
[HACKATHON 6th][CMake Optimization] use C++17 pack arguments expansion
silverling Mar 8, 2024
dc0c331
[HACKATHON 6th][CMake Optimization] suppress several warning
silverling Mar 8, 2024
a506b76
[HACKATHON 6th][CMake Optimization] comment out unused local variable…
silverling Mar 8, 2024
aa51c2f
[HACKATHON 6th][CMake Optimization] make some flags to be clang-specific
silverling Mar 8, 2024
2245efc
[HACKATHON 6th][CMake Optimization] refactor gloo.cmake
silverling Mar 8, 2024
99d0269
[HACKATHON 6th][CMake Optimization] separate clang flags
silverling Mar 9, 2024
f7795ca
[HACKATHON 6th][CMake Optimization] adjust clang flags to keep warning
silverling Mar 10, 2024
0b10438
revert [HACKATHON 6th][CMake Optimization] add macro check for custom…
silverling Mar 12, 2024
a803dd2
Merge branch 'develop' into fix_clang_compatibility
silverling Mar 12, 2024
7f1ae23
resolve conflicts in op_infermeta_gen.py
silverling Mar 12, 2024
5834d9e
Merge branch 'develop' into fix_clang_compatibility
silverling Mar 14, 2024
2604b33
fix custom_optional unit test
silverling Mar 14, 2024
5568d5f
remove all commented out unused variables
silverling Mar 14, 2024
cfb69e9
add compiler flag for GLOO header file
silverling Mar 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 30 additions & 47 deletions cmake/external/gloo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,74 +16,57 @@ include(ExternalProject)

set(GLOO_PROJECT "extern_gloo")
set(GLOO_PREFIX_DIR ${THIRD_PARTY_PATH}/gloo)
set(GLOO_SOURCE_DIR ${THIRD_PARTY_PATH}/gloo/src/extern_gloo)
set(GLOO_SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/gloo)
set(GLOO_INSTALL_DIR ${THIRD_PARTY_PATH}/install/gloo)
set(GLOO_INCLUDE_DIR
"${GLOO_INSTALL_DIR}/include"
${GLOO_INSTALL_DIR}/include
CACHE PATH "gloo include directory." FORCE)
set(GLOO_LIBRARY_DIR
"${GLOO_INSTALL_DIR}/lib"
${GLOO_INSTALL_DIR}/lib
CACHE PATH "gloo library directory." FORCE)

# As we add extra features for gloo, we use the non-official repo
set(GLOO_TAG v0.0.3)
set(GLOO_LIBRARIES
"${GLOO_INSTALL_DIR}/lib/libgloo.a"
${GLOO_INSTALL_DIR}/lib/libgloo.a
CACHE FILEPATH "gloo library." FORCE)
set(SOURCE_DIR ${PADDLE_SOURCE_DIR}/third_party/gloo)
set(GLOO_PATCH_COMMAND "")
if(WITH_GPU)
if(${CMAKE_CUDA_COMPILER_VERSION} LESS 12.0 AND ${CMAKE_CXX_COMPILER_VERSION}
VERSION_GREATER 12.0)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/device.cc.patch
native_dst)
set(GLOO_PATCH_COMMAND
git checkout -- . && git checkout ${GLOO_TAG} && patch -Nd
${SOURCE_DIR}/gloo/transport/tcp < ${native_dst})
endif()
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/device.cc.patch
native_dst)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/types.h.patch
types_header)
# See: [Why calling some `git` commands before `patch`?]
set(GLOO_PATCH_COMMAND
git checkout -- . && git checkout ${GLOO_TAG} && patch -Nd
${SOURCE_DIR}/gloo/transport/tcp < ${native_dst} && patch -Nd
${SOURCE_DIR}/gloo/ < ${types_header})
endif()
# Setup gloo patch command
set(GLOO_PATCH_COMMAND git checkout -- . && git checkout ${GLOO_TAG})

file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/device.cc.patch
native_dst)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/types.h.patch
types_header)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/gloo/linux.cc.patch
linux_cc_ethtool)
if(GLOO_PATCH_COMMAND STREQUAL "")
set(GLOO_PATCH_COMMAND git checkout -- . && git checkout ${GLOO_TAG} && patch
-Nd ${SOURCE_DIR}/gloo/common/ < ${linux_cc_ethtool})
else()
set(GLOO_PATCH_COMMAND ${GLOO_PATCH_COMMAND} && patch -Nd
${SOURCE_DIR}/gloo/common/ < ${linux_cc_ethtool})
endif()

include_directories(${GLOO_INCLUDE_DIR})
# cmake-format: off
list(APPEND GLOO_PATCH_COMMAND
&& patch -Nd ${GLOO_SOURCE_DIR}/gloo/transport/tcp < ${native_dst}
&& patch -Nd ${GLOO_SOURCE_DIR}/gloo/ < ${types_header}
&& patch -Nd ${GLOO_SOURCE_DIR}/gloo/common/ < ${linux_cc_ethtool})
# cmake-format: on

set(GLOO_CMAKE_C_FLAGS "-O3 -fPIC")
set(GLOO_CMAKE_CXX_FLAGS "-O3 -fPIC")

ExternalProject_Add(
${GLOO_PROJECT}
${EXTERNAL_PROJECT_LOG_ARGS}
SOURCE_DIR ${SOURCE_DIR}
PREFIX "${GLOO_PREFIX_DIR}"
UPDATE_COMMAND ""
SOURCE_DIR ${GLOO_SOURCE_DIR}
PREFIX ${GLOO_PREFIX_DIR}
PATCH_COMMAND ${GLOO_PATCH_COMMAND}
CONFIGURE_COMMAND ""
BUILD_COMMAND
mkdir -p ${GLOO_SOURCE_DIR}/build && cd ${GLOO_SOURCE_DIR}/build && cmake
${SOURCE_DIR} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} && ${CMAKE_COMMAND}
--build . && mkdir -p ${GLOO_LIBRARY_DIR} ${GLOO_INCLUDE_DIR}/glo
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy
${GLOO_SOURCE_DIR}/build/gloo/libgloo.a ${GLOO_LIBRARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory "${SOURCE_DIR}/gloo/"
"${GLOO_INCLUDE_DIR}/gloo"
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${GLOO_INSTALL_DIR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_FLAGS=${GLOO_CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${GLOO_CMAKE_CXX_FLAGS}
BUILD_BYPRODUCTS ${GLOO_LIBRARIES})

add_library(gloo STATIC IMPORTED GLOBAL)
set_property(TARGET gloo PROPERTY IMPORTED_LOCATION ${GLOO_LIBRARIES})
add_dependencies(gloo ${GLOO_PROJECT})

include_directories(${GLOO_INCLUDE_DIR})
14 changes: 9 additions & 5 deletions cmake/external/rocksdb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ set(ROCKSDB_FLAGS
"-DNDEBUG -DROCKSDB_JEMALLOC -DJEMALLOC_NO_DEMANGLE -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -DROCKSDB_FALLOCATE_PRESENT -DHAVE_PCLMUL -DZLIB -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX -DROCKSDB_BACKTRACE -DROCKSDB_SUPPORT_THREAD_LOCAL -DROCKSDB_USE_RTTI -DROCKSDB_SCHED_GETCPU_PRESENT -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_AUXV_GETAUXVAL_PRESENT"
)
set(ROCKSDB_CMAKE_CXX_FLAGS
"${ROCKSDB_COMMON_FLAGS} -DROCKSDB_LIBAIO_PRESENT ${ROCKSDB_FLAGS} -fPIC -I${JEMALLOC_INCLUDE_DIR} -Wl,--no-as-needed -lz -ldl"
"${ROCKSDB_COMMON_FLAGS} -DROCKSDB_LIBAIO_PRESENT ${ROCKSDB_FLAGS} -fPIC -I${JEMALLOC_INCLUDE_DIR}"
)
if(NOT WITH_ARM)
set(ROCKSDB_FLAGS "${ROCKSDB_FLAGS} -DHAVE_SSE42")
set(ROCKSDB_CMAKE_CXX_FLAGS
"${ROCKSDB_CMAKE_CXX_FLAGS} -msse -msse4.2 -mpclmul")
endif()
set(ROCKSDB_CMAKE_C_FLAGS
"${ROCKSDB_COMMON_FLAGS} ${ROCKSDB_FLAGS} -DROCKSDB_LIBAIO_PRESENT -fPIC -I${JEMALLOC_INCLUDE_DIR}"
"${ROCKSDB_COMMON_FLAGS} ${ROCKSDB_FLAGS} -DROCKSDB_LIBAIO_PRESENT -fPIC -I${JEMALLOC_INCLUDE_DIR}"
)
include_directories(${ROCKSDB_INCLUDE_DIR})

set(CMAKE_CXX_LINK_EXECUTABLE
"${CMAKE_CXX_LINK_EXECUTABLE} -pthread -Wl,--no-as-needed -ldl -lrt -lz")
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -pthread")

set(ROCKSDB_CMAKE_SHARED_LINKER_FLAGS "-ldl -lrt -lz")

if(WITH_ARM)
file(TO_NATIVE_PATH ${PADDLE_SOURCE_DIR}/patches/rocksdb/libaio.h.patch
native_src)
Expand All @@ -75,10 +77,12 @@ ExternalProject_Add(
-DWITH_TESTS=OFF
-DWITH_JEMALLOC=ON
-DWITH_BENCHMARK_TOOLS=OFF
-DFAIL_ON_WARNINGS=OFF # For Clang compatibility
-DJeMalloc_LIBRARIES=${JEMALLOC_LIBRARIES}
-DJeMalloc_INCLUDE_DIRS=${JEMALLOC_INCLUDE_DIR}
-DCMAKE_CXX_FLAGS=${ROCKSDB_CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_C_FLAGS=${ROCKSDB_CMAKE_C_FLAGS}
-DCMAKE_SHARED_LINKER_FLAGS=${ROCKSDB_CMAKE_SHARED_LINKER_FLAGS}
INSTALL_COMMAND
mkdir -p ${ROCKSDB_INSTALL_DIR}/lib/ && cp
${ROCKSDB_PREFIX_DIR}/src/extern_rocksdb-build/librocksdb.a
Expand Down
28 changes: 24 additions & 4 deletions cmake/flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include(CheckCCompilerFlag)
include(CheckCXXSymbolExists)
include(CheckTypeSize)

function(CheckCompilerCXX14Flag)
function(check_compiler_cxx14_flag)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 5.4)
message(FATAL_ERROR "Unsupported GCC version. GCC >= 5.4 required.")
Expand All @@ -14,8 +14,7 @@ function(CheckCompilerCXX14Flag)
"Found GCC ${CMAKE_CXX_COMPILER_VERSION} which is too high, recommended to use GCC 8.2"
)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID
STREQUAL "Clang")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang|Clang")
# cmake >= 3.0 compiler id "AppleClang" on Mac OS X, otherwise "Clang"
# Apple Clang is a different compiler than upstream Clang which has different version numbers.
# https://gist.github.com/yamaya/2924292
Expand All @@ -33,7 +32,8 @@ function(CheckCompilerCXX14Flag)
endif()
endfunction()

checkcompilercxx14flag()
check_compiler_cxx14_flag()

if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
else()
Expand Down Expand Up @@ -158,6 +158,26 @@ if(NOT WIN32)
-Wimplicit-fallthrough=0 # Warning in tinyformat.h
${fsanitize})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上边加的几个编译器选项gcc和clang都有这个问题吗?是不是也加一些判断比较好?如果是clang编译器再加?然后如果是第三方库的问题,放在第三方库的.CMAKE里

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
set(COMMON_FLAGS ${COMMON_FLAGS} -Wno-error=deprecated-copy)
endif()
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(COMMON_FLAGS
${COMMON_FLAGS}
-Wno-error=unused-private-field
-Wno-error=unused-const-variable
-Wno-error=deprecated-copy-with-user-provided-copy # For three/five/zeros rule, clang
-Wno-error=deprecated-copy # Same above
-Wno-error=inconsistent-missing-override # For lots of warnings when not using override for virtual functions, clang
-Wno-error=bitwise-instead-of-logical # Warning in "unsupported/Eigen/CXX11/Tensor"
-Wno-error=overloaded-virtual # For some inconsistent virtual function signature, clang
-Wno-error=defaulted-function-deleted # header file from GLOO, clang
)
endif()

if(WITH_IPU)
set(COMMON_FLAGS ${COMMON_FLAGS} -Wno-sign-compare # Warnings in Popart
-Wno-non-virtual-dtor # Warnings in Popart
Expand Down
8 changes: 4 additions & 4 deletions paddle/fluid/distributed/collective/reducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -850,8 +850,8 @@ void EagerReducer::MarkVarReady(const size_t var_index,
auto dense_tensor =
std::dynamic_pointer_cast<phi::DenseTensor>(tensor_impl);
if (!dense_tensor->meta().is_contiguous()) {
grad_tensor.set_impl(std::make_shared<phi::DenseTensor>(std::move(
paddle::experimental::Trans2Contiguous(*dense_tensor))));
grad_tensor.set_impl(std::make_shared<phi::DenseTensor>(
paddle::experimental::Trans2Contiguous(*dense_tensor)));
}
}

Expand Down Expand Up @@ -884,8 +884,8 @@ void EagerReducer::MarkVarReady(const size_t var_index,
auto dense_tensor =
std::dynamic_pointer_cast<phi::DenseTensor>(tensor_impl);
if (!dense_tensor->meta().is_contiguous()) {
grad_tensor->set_impl(std::make_shared<phi::DenseTensor>(std::move(
paddle::experimental::Trans2Contiguous(*dense_tensor))));
grad_tensor->set_impl(std::make_shared<phi::DenseTensor>(
paddle::experimental::Trans2Contiguous(*dense_tensor)));
}
}

Expand Down
8 changes: 5 additions & 3 deletions paddle/fluid/distributed/common/registerer.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,17 @@ typedef std::map<std::string, FactoryMap> PsCoreClassMap;
extern "C" {
#endif

inline PsCoreClassMap &global_factory_map() {
inline PsCoreClassMap *global_factory_map() {
static PsCoreClassMap *base_class = new PsCoreClassMap();
return *base_class;
return base_class;
}
#ifdef __cplusplus
}
#endif

inline PsCoreClassMap &global_factory_map_cpp() { return global_factory_map(); }
inline PsCoreClassMap &global_factory_map_cpp() {
return *global_factory_map();
}

// typedef pa::Any Any;
// typedef ::FactoryMap FactoryMap;
Expand Down
9 changes: 3 additions & 6 deletions paddle/fluid/distributed/ps/service/brpc_ps_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1634,8 +1634,7 @@ void BrpcPsClient::PushSparseTaskConsume() {

task_list.reserve(cur_merge_size + 1);

task_list.push_back(
std::move(std::shared_ptr<SparseAsyncTask>(async_task)));
task_list.push_back(std::shared_ptr<SparseAsyncTask>(async_task));

while (!task_queue->Empty() && merge_count < cur_merge_size) {
++merge_count;
Expand Down Expand Up @@ -1667,8 +1666,7 @@ void BrpcPsClient::PushSparseTaskConsume() {

for_each(task_list.begin() + 1,
task_list.end(),
[&request_kv_num, request_call_num, closure](
std::shared_ptr<SparseAsyncTask> &task) {
[closure](std::shared_ptr<SparseAsyncTask> &task) {
closure->add_timer(task->timer());
closure->add_promise(task->promise());
});
Expand Down Expand Up @@ -1978,8 +1976,7 @@ void BrpcPsClient::PushDenseTaskConsume() {
closure->add_timer(async_task->timer());
closure->add_promise(async_task->promise());
merge_status[merge_count] =
async_merge_dense_threads.enqueue([closure,
accessor,
async_merge_dense_threads.enqueue([accessor,
&total_send_data,
total_send_data_size,
async_task]() -> int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ void Communicator::RpcSendSparseParam(const std::string &varname,
push_g_vec.push_back(tensor->data<float>() + i * dim);
}

DownpourBrpcClosure *closure = new DownpourBrpcClosure(
request_call_num, [this, request_call_num](void *done) {
DownpourBrpcClosure *closure =
new DownpourBrpcClosure(request_call_num, [request_call_num](void *done) {
int ret = 0;
auto *closure = (DownpourBrpcClosure *)done; // NOLINT
for (size_t i = 0; i < request_call_num; ++i) {
Expand Down Expand Up @@ -422,8 +422,8 @@ void Communicator::SendGlobalStep(const CommContext &ctx,
auto *data = out_t->mutable_data<int64_t>({1}, platform::CPUPlace());
data[0] = static_cast<int64_t>(batches);
VLOG(3) << "Communicator::SendGlobalStep send: " << batches;
DownpourBrpcClosure *closure = new DownpourBrpcClosure(
request_call_num, [this, request_call_num](void *done) {
DownpourBrpcClosure *closure =
new DownpourBrpcClosure(request_call_num, [request_call_num](void *done) {
int ret = 0;
auto *closure = (DownpourBrpcClosure *)done; // NOLINT
for (size_t i = 0; i < request_call_num; ++i) {
Expand Down
6 changes: 2 additions & 4 deletions paddle/fluid/distributed/ps/service/graph_brpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,8 @@ int32_t GraphBrpcService::sample_neighbors_across_multi_servers(
auto local_promise = std::make_shared<std::promise<int32_t>>();
std::future<int> local_fut = local_promise->get_future();
std::vector<bool> failed(server_size, false);
std::function<void(void *)> func = [&,
node_id_buckets,
query_idx_buckets,
request_call_num](void *done) {
std::function<void(void *)> func = [&, node_id_buckets, query_idx_buckets](
void *done) {
local_fut.get();
std::vector<int> actual_size;
auto *closure = reinterpret_cast<DownpourBrpcClosure *>(done);
Expand Down
32 changes: 14 additions & 18 deletions paddle/fluid/distributed/ps/table/common_graph_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1621,11 +1621,10 @@ void GraphTable::clear_edge_shard() {
std::vector<std::future<int>> tasks;
for (auto &type_shards : edge_shards) {
for (auto &shard : type_shards) {
tasks.push_back(
load_node_edge_task_pool->enqueue([&shard, this]() -> int {
delete shard;
return 0;
}));
tasks.push_back(load_node_edge_task_pool->enqueue([&shard]() -> int {
delete shard;
return 0;
}));
}
}
for (auto &task : tasks) task.get();
Expand All @@ -1643,11 +1642,10 @@ void GraphTable::clear_feature_shard() {
std::vector<std::future<int>> tasks;
for (auto &type_shards : feature_shards) {
for (auto &shard : type_shards) {
tasks.push_back(
load_node_edge_task_pool->enqueue([&shard, this]() -> int {
delete shard;
return 0;
}));
tasks.push_back(load_node_edge_task_pool->enqueue([&shard]() -> int {
delete shard;
return 0;
}));
}
}
for (auto &task : tasks) task.get();
Expand All @@ -1665,11 +1663,10 @@ void GraphTable::clear_node_shard() {
std::vector<std::future<int>> tasks;
for (auto &type_shards : node_shards) {
for (auto &shard : type_shards) {
tasks.push_back(
load_node_edge_task_pool->enqueue([&shard, this]() -> int {
delete shard;
return 0;
}));
tasks.push_back(load_node_edge_task_pool->enqueue([&shard]() -> int {
delete shard;
return 0;
}));
}
}
for (size_t i = 0; i < tasks.size(); i++) tasks[i].get();
Expand Down Expand Up @@ -2898,7 +2895,7 @@ int32_t GraphTable::get_nodes_ids_by_ranges(
first -= total_size;
second -= total_size;
tasks.push_back(_shards_task_pool[i % task_pool_size_]->enqueue(
[&shards, this, first, second, i, &res, &mutex]() -> size_t {
[&shards, first, second, i, &res, &mutex]() -> size_t {
std::vector<uint64_t> keys;
shards[i]->get_ids_by_range(first, second, &keys);

Expand Down Expand Up @@ -3322,8 +3319,7 @@ int32_t GraphTable::pull_graph_list(GraphTableType table_type,
int count = std::min(1 + (size + cur_size - start - 1) / step, total_size);
int end = start + (count - 1) * step + 1;
tasks.push_back(_shards_task_pool[i % task_pool_size_]->enqueue(
[&search_shards, this, i, start, end, step, size]()
-> std::vector<Node *> {
[&search_shards, i, start, end, step, size]() -> std::vector<Node *> {
return search_shards[i]->get_batch(start - size, end - size, step);
}));
start += count * step;
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/distributed/ps/table/memory_dense_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ int32_t MemoryDenseTable::Save(const std::string &path,
os << " ";
os << values_[param_col_ids_[x]][y];
}
result_buffer_param.emplace_back(std::move(os.str()));
result_buffer_param.emplace_back(os.str());
}
} else {
std::ostringstream os;
Expand All @@ -368,7 +368,7 @@ int32_t MemoryDenseTable::Save(const std::string &path,
os << " ";
os << values_[param_col_ids_[x]][y];
}
result_buffer_param.emplace_back(std::move(os.str()));
result_buffer_param.emplace_back(os.str());
}
}

Expand Down
Loading