diff --git a/cubool/sources/cuda/cuda_matrix_multiply.cu b/cubool/sources/cuda/cuda_matrix_multiply.cu index 5401108..ec54cd0 100644 --- a/cubool/sources/cuda/cuda_matrix_multiply.cu +++ b/cubool/sources/cuda/cuda_matrix_multiply.cu @@ -40,6 +40,14 @@ namespace cubool { assert(this->getNrows() == M); assert(this->getNcols() == N); + if (!accumulate && (this == a || this == b)) { + // Keep both operands intact until the product is ready. + CudaMatrix temporary(M, N, mInstance); + temporary.multiply(aBase, bBase, false, checkTime); + mMatrixImpl = std::move(temporary.mMatrixImpl); + return; + } + if (!accumulate) { // Clear all values this->clearAndResizeStorageToDim(); @@ -63,4 +71,4 @@ namespace cubool { this->mMatrixImpl = std::move(result); } -}// namespace cubool \ No newline at end of file +}// namespace cubool