diff --git a/hipamd/src/hip_device.cpp b/hipamd/src/hip_device.cpp index a05c7b9bb5..aa6b684d02 100644 --- a/hipamd/src/hip_device.cpp +++ b/hipamd/src/hip_device.cpp @@ -36,6 +36,10 @@ hip::Stream* Device::NullStream(bool wait) { amd::ScopedLock lock(lock_); if (null_stream_ == nullptr) { null_stream_ = new Stream(this, Stream::Priority::Normal, 0, true); + // Stream creation might be failed from rcor and in that case, vdev is null. + if (null_stream_->vdev() == nullptr) { + Stream::Destroy(null_stream_); + } } } if (null_stream_ == nullptr) { diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index 0ad2f35ea1..6061f346aa 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -3328,6 +3328,7 @@ hipError_t ihipMemset(void* dst, int64_t value, size_t valueSize, size_t sizeByt } std::vector commands; hip::Stream* hip_stream = hip::getStream(stream); + if (hip_stream == nullptr) { return hipErrorOutOfMemory; } hip_error = ihipMemsetCommand(commands, dst, value, valueSize, sizeBytes, hip_stream); if (hip_error != hipSuccess) { break; diff --git a/hipamd/src/hip_stream.cpp b/hipamd/src/hip_stream.cpp index bfd1c965df..91f0472112 100644 --- a/hipamd/src/hip_stream.cpp +++ b/hipamd/src/hip_stream.cpp @@ -75,6 +75,7 @@ bool Stream::Create() { void Stream::Destroy(hip::Stream* stream) { stream->device_->RemoveStream(stream); stream->release(); + stream = nullptr; } // ================================================================================================ diff --git a/rocclr/device/rocm/rocvirtual.cpp b/rocclr/device/rocm/rocvirtual.cpp index dfea660d1c..e7d91dbf1a 100644 --- a/rocclr/device/rocm/rocvirtual.cpp +++ b/rocclr/device/rocm/rocvirtual.cpp @@ -1461,9 +1461,11 @@ bool VirtualGPU::initPool(size_t kernarg_pool_size) { roc_device_.info().largeBar_) { kernarg_pool_base_ = reinterpret_cast
(roc_device_.deviceLocalAlloc(kernarg_pool_size_)); - // @note Workaround first access penalty. - // KFD may update CPU page tables on the first CPU access - *kernarg_pool_base_ = 0; + if (kernarg_pool_base_ != nullptr) { + // @note Workaround first access penalty. + // KFD may update CPU page tables on the first CPU access + *kernarg_pool_base_ = 0; + } } else { kernarg_pool_base_ = reinterpret_cast
(roc_device_.hostAlloc(kernarg_pool_size_, 0, Device::MemorySegment::kKernArg));