Skip to content

Commit

Permalink
Fix uninitialized memory issue for the result buffer in kron (#2475)
Browse files Browse the repository at this point in the history
Signed-off-by: Thien Nguyen <[email protected]>
  • Loading branch information
1tnguyen authored Dec 12, 2024
1 parent 5785e44 commit e790a98
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion runtime/nvqir/custatevec/CuStateVecCircuitSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ class CuStateVecCircuitSimulator
void *newDeviceStateVector;
HANDLE_CUDA_ERROR(cudaMalloc((void **)&newDeviceStateVector,
stateDimension * sizeof(CudaDataType)));

HANDLE_CUDA_ERROR(cudaMemset(newDeviceStateVector, 0,
stateDimension * sizeof(CudaDataType)));
// Place the state data on device. Could be that
// we just need the zero state, or the user could have provided one
void *otherState;
Expand Down Expand Up @@ -283,6 +284,8 @@ class CuStateVecCircuitSimulator
void *newDeviceStateVector;
HANDLE_CUDA_ERROR(cudaMalloc((void **)&newDeviceStateVector,
stateDimension * sizeof(CudaDataType)));
HANDLE_CUDA_ERROR(cudaMemset(newDeviceStateVector, 0,
stateDimension * sizeof(CudaDataType)));
constexpr int32_t threads_per_block = 256;
uint32_t n_blocks =
(stateDimension + threads_per_block - 1) / threads_per_block;
Expand Down

0 comments on commit e790a98

Please sign in to comment.