Skip to content

Commit

Permalink
[GpuGraph] add enforce in alloc and free (PaddlePaddle#27)
Browse files Browse the repository at this point in the history
* solve int overflow

* enforce for alloc and free
  • Loading branch information
Thunderbrook authored Jun 13, 2022
1 parent ba5d709 commit 77b007e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions paddle/fluid/framework/fleet/heter_ps/heter_comm_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ void HeterComm<KeyType, ValType, GradType>::create_storage(int start_index,
auto& nodes = path_[start_index][end_index].nodes_;
for (size_t i = 0; i < nodes.size(); ++i) {
platform::CUDADeviceGuard guard(resource_->dev_id(nodes[i].dev_num));
allocator->DeviceAllocate(
PADDLE_ENFORCE_GPU_SUCCESS(allocator->DeviceAllocate(
resource_->dev_id(nodes[i].dev_num),
(void**)&(nodes[i].key_storage), // NOLINT
keylen, resource_->remote_stream(nodes[i].dev_num, start_index));
allocator->DeviceAllocate(
keylen, resource_->remote_stream(nodes[i].dev_num, start_index)));
PADDLE_ENFORCE_GPU_SUCCESS(allocator->DeviceAllocate(
resource_->dev_id(nodes[i].dev_num),
(void**)&(nodes[i].val_storage), // NOLINT
vallen, resource_->remote_stream(nodes[i].dev_num, start_index));
vallen, resource_->remote_stream(nodes[i].dev_num, start_index)));
nodes[i].key_bytes_len = keylen;
nodes[i].val_bytes_len = vallen;
}
Expand Down Expand Up @@ -170,10 +170,10 @@ void HeterComm<KeyType, ValType, GradType>::destroy_storage(int start_index,
for (size_t i = 0; i < nodes.size(); ++i) {
platform::CUDADeviceGuard guard(resource_->dev_id(nodes[i].dev_num));

allocator->DeviceFree(resource_->dev_id(nodes[i].dev_num),
nodes[i].key_storage);
allocator->DeviceFree(resource_->dev_id(nodes[i].dev_num),
nodes[i].val_storage);
PADDLE_ENFORCE_GPU_SUCCESS(allocator->DeviceFree(
resource_->dev_id(nodes[i].dev_num), nodes[i].key_storage));
PADDLE_ENFORCE_GPU_SUCCESS(allocator->DeviceFree(
resource_->dev_id(nodes[i].dev_num), nodes[i].val_storage));
}
#endif
}
Expand Down

0 comments on commit 77b007e

Please sign in to comment.