diff --git a/hipamd/src/hip_device_runtime.cpp b/hipamd/src/hip_device_runtime.cpp index 560821c033..d5a29aa047 100755 --- a/hipamd/src/hip_device_runtime.cpp +++ b/hipamd/src/hip_device_runtime.cpp @@ -429,7 +429,9 @@ hipError_t hipDeviceGetSharedMemConfig ( hipSharedMemConfig * pConfig ) { hipError_t hipDeviceReset ( void ) { HIP_INIT_API(hipDeviceReset); - /* FIXME */ + hip::Device* dev = hip::getCurrentDevice(); + hip::Stream::destroyAllStreams(dev->deviceId()); + amd::MemObjMap::Purge(dev->devices()[0]); HIP_RETURN(hipSuccess); } diff --git a/hipamd/src/hip_internal.hpp b/hipamd/src/hip_internal.hpp index 577039ded2..f1100e3f0d 100755 --- a/hipamd/src/hip_internal.hpp +++ b/hipamd/src/hip_internal.hpp @@ -211,6 +211,9 @@ namespace hip { /// Sync all non-blocking streams static void syncNonBlockingStreams(); + /// Destroy all streams on a given device + static void destroyAllStreams(int deviceId); + /// Returns capture status of the current stream hipStreamCaptureStatus GetCaptureStatus() const { return captureStatus_; } /// Returns capture mode of the current stream diff --git a/hipamd/src/hip_stream.cpp b/hipamd/src/hip_stream.cpp index f35467e075..726825ea8b 100755 --- a/hipamd/src/hip_stream.cpp +++ b/hipamd/src/hip_stream.cpp @@ -156,6 +156,21 @@ void Stream::syncNonBlockingStreams() { } } +void Stream::destroyAllStreams(int deviceId) { + std::vector toBeDeleted; + { + amd::ScopedLock lock(streamSetLock); + for (auto& it : streamSet) { + if (it->Null() == false && it->DeviceId() == deviceId) { + toBeDeleted.push_back(it); + } + } + } + for (auto& it : toBeDeleted) { + delete it; + } +} + // ================================================================================================ bool isValid(hipStream_t stream) { // NULL stream is always valid