Closed Cstandardlib closed 1 month ago
@Cstandardlib could you want to pull a PR to make some changes?
@WHUweiqingzhou Changes will be made later, along with kernel ops to make them more robust and clear. I find that some redundant MPI operations are included in GPU code. These issues will be discussed in depth and I expect to establish a good development standard on these Heterogeneous Operators.
The
delete_memory_op
struct does not have any logic to handle the case wherearr
isnullptr
. Maybe we can add a null check to avoid potential deallocation errors.
There's no need to do so
Describe the Code Quality Issue
Description
The provided code snippet contains two template specializations for memory management on a CPU device.
Error Checking After Allocation
There is no error checking after the
malloc
call. It's good practice to check if the allocation was successful and handle the case wheremalloc
returnsnullptr
.Error Checking Before Deallocation
The
delete_memory_op
struct does not have any logic to handle the case wherearr
isnullptr
. Maybe we can add a null check to avoid potential deallocation errors.By the way, is it safer to use
new[]
anddelete[]
for arrays in C++?