diff --git a/paddle/fluid/distributed/ps/service/graph_brpc_server.cc b/paddle/fluid/distributed/ps/service/graph_brpc_server.cc index e1914a3a8f1182012ef6e56b765cb6b35dc8b1c9..771d446b1e1ea1a4fae48f8d8e6c9e6fc70c174a 100644 --- a/paddle/fluid/distributed/ps/service/graph_brpc_server.cc +++ b/paddle/fluid/distributed/ps/service/graph_brpc_server.cc @@ -126,9 +126,10 @@ int32_t GraphBrpcService::clear_nodes(Table *table, const PsRequestMessage &request, PsResponseMessage &response, brpc::Controller *cntl) { - GraphTableType type_id = *(GraphTableType *)(request.params(0).c_str()); - int idx_ = *(int *)(request.params(1).c_str()); - ((GraphTable *)table)->clear_nodes(type_id, idx_); + GraphTableType type_id = + *(reinterpret_cast(request.params(0).c_str())); + int idx_ = *(reinterpret_cast(request.params(1).c_str())); + (reinterpret_cast(table))->clear_nodes(type_id, idx_); return 0; } @@ -380,11 +381,12 @@ int32_t GraphBrpcService::pull_graph_list(Table *table, response, -1, "pull_graph_list request requires at least 5 arguments"); return 0; } - GraphTableType type_id = *(GraphTableType *)(request.params(0).c_str()); - int idx = *(int *)(request.params(1).c_str()); - int start = *(int *)(request.params(2).c_str()); - int size = *(int *)(request.params(3).c_str()); - int step = *(int *)(request.params(4).c_str()); + GraphTableType type_id = + *(reinterpret_cast(request.params(0).c_str())); + int idx = *(reinterpret_cast(request.params(1).c_str())); + int start = *(reinterpret_cast(request.params(2).c_str())); + int size = *(reinterpret_cast(request.params(3).c_str())); + int step = *(reinterpret_cast(request.params(4).c_str())); std::unique_ptr buffer; int actual_size; (reinterpret_cast(table)) @@ -432,9 +434,11 @@ int32_t GraphBrpcService::graph_random_sample_nodes( const PsRequestMessage &request, PsResponseMessage &response, brpc::Controller *cntl) { - GraphTableType type_id = *(GraphTableType *)(request.params(0).c_str()); - int idx_ = *(int *)(request.params(1).c_str()); - size_t size = *(uint64_t *)(request.params(2).c_str()); + GraphTableType type_id = + *(reinterpret_cast(request.params(0).c_str())); + int idx_ = *(reinterpret_cast(request.params(1).c_str())); + size_t size = + *(reinterpret_cast(request.params(2).c_str())); // size_t size = *(int64_t *)(request.params(0).c_str()); std::unique_ptr buffer; int actual_size; diff --git a/paddle/fluid/distributed/ps/table/common_graph_table.cc b/paddle/fluid/distributed/ps/table/common_graph_table.cc index 458c10ff1ed3fceee61f01b51d688ab402211e8c..69a912e191c435043bedaf448cdc8aae6c4d5655 100644 --- a/paddle/fluid/distributed/ps/table/common_graph_table.cc +++ b/paddle/fluid/distributed/ps/table/common_graph_table.cc @@ -1917,7 +1917,7 @@ int32_t GraphTable::random_sample_nodes(GraphTableType table_type, int total_size = 0; auto &shards = table_type == GraphTableType::EDGE_TABLE ? edge_shards[idx] : feature_shards[idx]; - for (int i = 0; i < (int)shards.size(); i++) { + for (int i = 0; i < static_cast(shards.size()); i++) { total_size += shards[i]->get_size(); } if (sample_size > total_size) sample_size = total_size; @@ -2429,7 +2429,7 @@ int GraphTable::get_all_feature_ids( int GraphTable::get_node_embedding_ids( int slice_num, std::vector> *output) { - if (is_load_reverse_edge and !FLAGS_graph_get_neighbor_id) { + if (is_load_reverse_edge && !FLAGS_graph_get_neighbor_id) { return get_all_id(GraphTableType::EDGE_TABLE, slice_num, output); } else { get_all_id(GraphTableType::EDGE_TABLE, slice_num, output); diff --git a/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table_inl.cu b/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table_inl.cu index 3ee2c00f39c9f71e3d6c665b4198e4f00abf551f..e3b2fb1def809aa33da2739ee879ed44754d7aca 100644 --- a/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table_inl.cu +++ b/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table_inl.cu @@ -466,13 +466,13 @@ void GpuPsGraphTable::move_result_to_source_gpu(int start_index, void GpuPsGraphTable::move_degree_to_source_gpu( int start_index, int gpu_num, int* h_left, int* h_right, int* node_degree) { - int shard_len[gpu_num]; + std::vector shard_len(gpu_num, 0); for (int i = 0; i < gpu_num; i++) { if (h_left[i] == -1 || h_right[i] == -1) { continue; } shard_len[i] = h_right[i] - h_left[i] + 1; - int cur_step = (int)path_[start_index][i].nodes_.size() - 1; + int cur_step = static_cast(path_[start_index][i].nodes_.size()) - 1; for (int j = cur_step; j > 0; j--) { CUDA_CHECK( cudaMemcpyAsync(path_[start_index][i].nodes_[j - 1].val_storage, @@ -1566,8 +1566,12 @@ void GpuPsGraphTable::get_node_degree( len * sizeof(int), phi::Stream(reinterpret_cast(stream))); int* d_shard_degree_ptr = reinterpret_cast(d_shard_degree->ptr()); - split_input_to_shard( - (uint64_t*)(key), d_idx_ptr, len, d_left_ptr, d_right_ptr, gpu_id); + split_input_to_shard(reinterpret_cast(key), + d_idx_ptr, + len, + d_left_ptr, + d_right_ptr, + gpu_id); heter_comm_kernel_->fill_shard_key( d_shard_keys_ptr, key, d_idx_ptr, len, stream); CUDA_CHECK(cudaStreamSynchronize(stream)); @@ -1594,8 +1598,12 @@ void GpuPsGraphTable::get_node_degree( shard_len * sizeof(uint64_t), shard_len * sizeof(uint64_t) + sizeof(int) * shard_len + shard_len % 2); } - walk_to_dest( - gpu_id, total_gpu, h_left, h_right, (uint64_t*)(d_shard_keys_ptr), NULL); + walk_to_dest(gpu_id, + total_gpu, + h_left, + h_right, + reinterpret_cast(d_shard_keys_ptr), + NULL); for (int i = 0; i < total_gpu; ++i) { if (h_left[i] == -1) { continue; @@ -1610,11 +1618,11 @@ void GpuPsGraphTable::get_node_degree( get_table_offset(i, GraphTableType::EDGE_TABLE, edge_idx); tables_[table_offset]->get(reinterpret_cast(node.key_storage), reinterpret_cast(node.val_storage), - (size_t)(h_right[i] - h_left[i] + 1), + static_cast(h_right[i] - h_left[i] + 1), resource_->remote_stream(i, gpu_id)); GpuPsNodeInfo* node_info_list = reinterpret_cast(node.val_storage); - int* node_degree_array = (int*)(node_info_list + shard_len); + int* node_degree_array = reinterpret_cast(node_info_list + shard_len); int grid_size_ = (shard_len - 1) / block_size_ + 1; get_node_degree_kernel<<