Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
composable_kernel_ROCM
Commits
4c5ebf64
Commit
4c5ebf64
authored
Jan 21, 2025
by
Ville Pietilä
Browse files
Set clean-up thread sleep time to be configurable.
parent
bf0eab0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
include/ck/utility/host_memory_allocator.hpp
include/ck/utility/host_memory_allocator.hpp
+14
-3
No files found.
include/ck/utility/host_memory_allocator.hpp
View file @
4c5ebf64
...
...
@@ -16,7 +16,7 @@
#include "unistd.h"
CK_DECLARE_ENV_VAR_UINT64
(
CK_PINNED_HOST_MEM_POOL_SIZE_KB
)
CK_DECLARE_ENV_VAR_UINT64
(
CK_PINNED_HOST_MEM_POOL_GC_INTERVAL_MS
)
namespace
ck
{
namespace
memory
{
...
...
@@ -235,11 +235,20 @@ namespace memory {
class
MemoryCleanupThread
{
public:
MemoryCleanupThread
(
std
::
function
<
void
()
>
cleanup_function
)
:
cleanup_callback_
(
cleanup_function
)
MemoryCleanupThread
(
std
::
function
<
void
()
>
cleanup_function
)
:
cleanup_callback_
(
cleanup_function
)
,
cleanup_interval_ms_
(
defaultCleanupIntervalMs_
)
{
if
(
!
ck
::
EnvIsUnset
(
CK_ENV
(
CK_PINNED_HOST_MEM_POOL_GC_INTERVAL_MS
)))
{
cleanup_interval_ms_
=
ck
::
EnvValue
(
CK_ENV
(
CK_PINNED_HOST_MEM_POOL_GC_INTERVAL_MS
));
if
(
enableLogging_
)
{
std
::
cout
<<
"[ StaticMemPool ] Override of clean-up thread sleep time to "
<<
cleanup_interval_ms_
<<
" ms."
<<
std
::
endl
;
}
}
cleanup_thread_
=
std
::
thread
([
this
]()
{
while
(
!
should_stop_
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
50
));
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
cleanup_interval_ms_
));
try
{
cleanup_callback_
();
...
...
@@ -271,9 +280,11 @@ namespace memory {
MemoryCleanupThread
(
MemoryCleanupThread
&&
)
noexcept
=
default
;
MemoryCleanupThread
&
operator
=
(
MemoryCleanupThread
&&
)
noexcept
=
default
;
private:
constexpr
static
size_t
defaultCleanupIntervalMs_
=
50
;
std
::
function
<
void
()
>
cleanup_callback_
;
std
::
thread
cleanup_thread_
;
bool
should_stop_
{
false
};
size_t
cleanup_interval_ms_
;
};
class
PinnedHostMemoryDeallocator
:
public
PinnedHostMemoryAllocatorBase
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment