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
c6ba9545
Commit
c6ba9545
authored
Jan 07, 2025
by
Ville Pietilä
Browse files
Put static mempool logging behind a flag.
parent
359f5c78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
include/ck/utility/host_memory_allocator.hpp
include/ck/utility/host_memory_allocator.hpp
+10
-0
No files found.
include/ck/utility/host_memory_allocator.hpp
View file @
c6ba9545
...
@@ -219,21 +219,25 @@ namespace memory {
...
@@ -219,21 +219,25 @@ namespace memory {
if
(
memory_pool_
.
find
(
sizeInBytes
)
!=
memory_pool_
.
end
())
if
(
memory_pool_
.
find
(
sizeInBytes
)
!=
memory_pool_
.
end
())
{
{
memory_pool_
[
sizeInBytes
].
push
(
p
);
memory_pool_
[
sizeInBytes
].
push
(
p
);
#ifdef ENABLE_MEM_POOL_LOGGING
if
(
enableLogging_
)
if
(
enableLogging_
)
{
{
std
::
cout
<<
"[ StaticMemPool ] Deallocate: Added memory to back to pool for size "
<<
sizeInBytes
<<
std
::
cout
<<
"[ StaticMemPool ] Deallocate: Added memory to back to pool for size "
<<
sizeInBytes
<<
", pool has now "
<<
memory_pool_
[
sizeInBytes
].
size
()
<<
" elements."
<<
std
::
endl
;
", pool has now "
<<
memory_pool_
[
sizeInBytes
].
size
()
<<
" elements."
<<
std
::
endl
;
}
}
#endif
}
}
else
{
else
{
std
::
queue
<
void
*>
q
;
std
::
queue
<
void
*>
q
;
q
.
push
(
p
);
q
.
push
(
p
);
memory_pool_
[
sizeInBytes
]
=
std
::
move
(
q
);
memory_pool_
[
sizeInBytes
]
=
std
::
move
(
q
);
#ifdef ENABLE_MEM_POOL_LOGGING
if
(
enableLogging_
)
if
(
enableLogging_
)
{
{
std
::
cout
<<
"[ StaticMemPool ] Deallocate: Created new pool for size "
<<
sizeInBytes
<<
std
::
cout
<<
"[ StaticMemPool ] Deallocate: Created new pool for size "
<<
sizeInBytes
<<
", pool has now "
<<
memory_pool_
[
sizeInBytes
].
size
()
<<
" elements."
<<
std
::
endl
;
", pool has now "
<<
memory_pool_
[
sizeInBytes
].
size
()
<<
" elements."
<<
std
::
endl
;
}
}
#endif
}
}
}
}
...
@@ -285,12 +289,14 @@ namespace memory {
...
@@ -285,12 +289,14 @@ namespace memory {
// Return new memory from the preallocated block
// Return new memory from the preallocated block
void
*
p
=
pinnedMemoryBaseAddress_
.
top
()
+
offsetInBytes_
;
void
*
p
=
pinnedMemoryBaseAddress_
.
top
()
+
offsetInBytes_
;
offsetInBytes_
+=
sizeInBytes
;
offsetInBytes_
+=
sizeInBytes
;
#ifdef ENABLE_MEM_POOL_LOGGING
if
(
enableLogging_
)
if
(
enableLogging_
)
{
{
const
auto
pct
=
100.0
f
*
static_cast
<
float
>
(
offsetInBytes_
)
/
memoryPoolSizeInBytes_
;
const
auto
pct
=
100.0
f
*
static_cast
<
float
>
(
offsetInBytes_
)
/
memoryPoolSizeInBytes_
;
std
::
cout
<<
"[ StaticMemPool ] Allocation: Return new memory of "
<<
sizeInBytes
<<
std
::
cout
<<
"[ StaticMemPool ] Allocation: Return new memory of "
<<
sizeInBytes
<<
" bytes, pinned host memory usage: "
<<
pct
<<
"%."
<<
std
::
endl
;
" bytes, pinned host memory usage: "
<<
pct
<<
"%."
<<
std
::
endl
;
}
}
#endif
return
p
;
return
p
;
}
}
...
@@ -301,11 +307,13 @@ namespace memory {
...
@@ -301,11 +307,13 @@ namespace memory {
// If there is a memory pool for the requested size, return memory from the pool.
// If there is a memory pool for the requested size, return memory from the pool.
void
*
p
=
memory_pool_
[
sizeInBytes
].
front
();
void
*
p
=
memory_pool_
[
sizeInBytes
].
front
();
memory_pool_
[
sizeInBytes
].
pop
();
memory_pool_
[
sizeInBytes
].
pop
();
#ifdef ENABLE_MEM_POOL_LOGGING
if
(
enableLogging_
)
if
(
enableLogging_
)
{
{
std
::
cout
<<
"[ StaticMemPool ] Allocation: Reusing memory from pool for size "
<<
sizeInBytes
<<
std
::
cout
<<
"[ StaticMemPool ] Allocation: Reusing memory from pool for size "
<<
sizeInBytes
<<
", pool has now "
<<
memory_pool_
[
sizeInBytes
].
size
()
<<
" elements."
<<
std
::
endl
;
", pool has now "
<<
memory_pool_
[
sizeInBytes
].
size
()
<<
" elements."
<<
std
::
endl
;
}
}
#endif
return
p
;
return
p
;
}
}
...
@@ -323,12 +331,14 @@ namespace memory {
...
@@ -323,12 +331,14 @@ namespace memory {
{
{
void
*
p
=
memory_pool_
[
nearest_queue_size
].
front
();
void
*
p
=
memory_pool_
[
nearest_queue_size
].
front
();
memory_pool_
[
nearest_queue_size
].
pop
();
memory_pool_
[
nearest_queue_size
].
pop
();
#ifdef ENABLE_MEM_POOL_LOGGING
if
(
enableLogging_
)
if
(
enableLogging_
)
{
{
std
::
cout
<<
"[ StaticMemPool ] Allocation: Reusing memory from pool for size "
<<
nearest_queue_size
<<
std
::
cout
<<
"[ StaticMemPool ] Allocation: Reusing memory from pool for size "
<<
nearest_queue_size
<<
" to allocate "
<<
sizeInBytes
<<
" bytes, pool has "
<<
memory_pool_
[
nearest_queue_size
].
size
()
<<
" elements."
<<
" to allocate "
<<
sizeInBytes
<<
" bytes, pool has "
<<
memory_pool_
[
nearest_queue_size
].
size
()
<<
" elements."
<<
std
::
endl
;
std
::
endl
;
}
}
#endif
return
p
;
return
p
;
}
}
...
...
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