MCPcopy Create free account
hub / github.com/ROCm/clr / GetUniqueFileHandle

Method GetUniqueFileHandle

hipamd/src/hip_platform.cpp:1056–1071  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1054}
1055
1056std::shared_ptr<UniqueFD> PlatformState::GetUniqueFileHandle(const std::string& file_path) {
1057 amd::ScopedLock lock(ufd_lock_);
1058
1059 if (ufd_map_.cend() == ufd_map_.find(file_path)) {
1060 // Get the file desc and file size from amd::Os API
1061 amd::Os::FileDesc fdesc;
1062 size_t fsize = 0;
1063 if (!amd::Os::GetFileHandle(file_path.c_str(), &fdesc, &fsize)) {
1064 return nullptr;
1065 }
1066 ufd_map_.insert(std::make_pair(file_path, std::make_shared<UniqueFD>(file_path, fdesc, fsize)));
1067 }
1068
1069 // we should have an entry at this time.
1070 return ufd_map_[file_path];
1071}
1072
1073bool PlatformState::CloseUniqueFileHandle(const std::shared_ptr<UniqueFD>& ufd) {
1074 amd::ScopedLock lock(ufd_lock_);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected