-
Notifications
You must be signed in to change notification settings - Fork 243
Description
Question: Memory Initialization in CVCUDA Test Cases
Issue Description
I was reviewing the test cases in the CVCUDA repository and noticed a potential concern regarding memory initialization. I would like to better understand the design decision behind not explicitly clearing output memory in tests.
Background: CUDA Memory Behavior
As we know, CUDA's official documentation states that:
cudaAlloc does not initialize memory content - it allocates GPU memory with undefined values for performance optimization.
In practice, this means:
- Fresh GPU memory (after reset) might contain zeros
- Previously used memory contains residual "dirty data"
- The content is unpredictable and depends on previous allocations
Observed Code Pattern
In test files like tests/cvcuda/system/TestOpFlip.cpp and histogram operator tests, I noticed there's no explicit memory clearing:
// I was expecting to see something like:
// Clear output tensor memory to 0 on the device
ASSERT_EQ(cudaSuccess, cudaMemset(output->basePtr(), 0, outBufSize));Questions for Clarification
I have a few questions that I hope the community can help clarify:
-
Design Philosophy: Is the absence of explicit
cudaMemsetintentional to test the operators' robustness against uninitialized memory? -
Operator Behavior: Do CVCUDA operators guarantee that they'll write to every element in the output buffer, thus eliminating the need for initialization?
-
Edge Cases: Are there any scenarios where operators might not completely overwrite the output buffer, making memory initialization important?
-
Testing Strategy: Is this approach aimed at catching potential bugs where operators inadvertently rely on default memory values?