SWDEV-276396 - Implement hipDeviceReset

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

Change-Id: I6ee7e3f26ab1f1870a9271c65e99fb818134482b
This commit is contained in:
Christophe Paquot
2021-06-10 08:28:34 -07:00
committed by Saleel Kudchadker
orang tua 2223a508f5
melakukan bea4fa8700
3 mengubah file dengan 21 tambahan dan 1 penghapusan
+3 -1
Melihat File
@@ -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
Melihat 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
Melihat 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