-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[umf] replace memory tracker with a critnib-based impl
This implementation is lock-free and does not require C++ runtime.
- Loading branch information
Showing
6 changed files
with
115 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
source/common/unified_malloc_framework/src/memory_tracker_windows.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* | ||
* Copyright (C) 2023 Intel Corporation | ||
* | ||
* Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. | ||
* See LICENSE.TXT | ||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
* | ||
*/ | ||
|
||
#include <windows.h> | ||
|
||
#if defined(UMF_SHARED_LIBRARY) | ||
critnib *TRACKER = NULL; | ||
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { | ||
if (fdwReason == DLL_PROCESS_DETACH) { | ||
critnib_delete(TRACKER); | ||
} else if (fdwReason == DLL_PROCESS_ATTACH) { | ||
TRACKER = critnib_new(); | ||
} | ||
return TRUE; | ||
} | ||
#else | ||
struct tracker_t { | ||
tracker_t() { map = critnib_new(); } | ||
~tracker_t() { critnib_remove(map); } | ||
critnib *map; | ||
}; | ||
tracker_t TRACKER_INSTANCE; | ||
critnib *TRACKER = TRACKER_INSTANCE.map; | ||
#endif | ||
|
||
umf_memory_tracker_handle_t umfMemoryTrackerGet(void) { | ||
return (umf_memory_tracker_handle_t)TRACKER; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters