SWDEV-276396 - Implement hipDeviceReset

Add a hip::Stream::destroyAllStreams static function to destroy all streams
Also call MemObjMap::Purge

Change-Id: I6ee7e3f26ab1f1870a9271c65e99fb818134482b


[ROCm/clr commit: bea4fa8700]
This commit is contained in:
Christophe Paquot
2021-06-10 08:28:34 -07:00
committed by Saleel Kudchadker
parent 1b23aa0d88
commit 96f580a267
3 changed files with 21 additions and 1 deletions
@@ -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);
}
+3
View File
@@ -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
+15
View File
@@ -156,6 +156,21 @@ void Stream::syncNonBlockingStreams() {
}
}
void Stream::destroyAllStreams(int deviceId) {
std::vector<Stream*> 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