SWDEV-460242 - Add system memory suballocator

Switch commands creation to the new suballocator to avoid
frequent expensive OS calls

Change-Id: I3597c811820e577c15708bad8b8a41aa53acc400


[ROCm/clr commit: 5b0bfdcbad]
This commit is contained in:
German Andryeyev
2024-05-03 17:06:10 -04:00
committed by Maneesh Gupta
parent 3ca0dbc4d7
commit 68344576d3
3 changed files with 130 additions and 18 deletions
+40 -8
View File
@@ -1,4 +1,4 @@
/* Copyright (c) 2010 - 2021 Advanced Micro Devices, Inc.
/* Copyright (c) 2010 - 2024 Advanced Micro Devices, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -18,13 +18,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */
/*! \file command.hpp
* \brief Declarations for Event, Command and HostQueue objects.
*
* \author Laurent Morichetti
* \date October 2008
*/
#ifndef COMMAND_HPP_
#define COMMAND_HPP_
@@ -62,6 +55,7 @@ namespace amd {
class Command;
class HostQueue;
union ComputeCommand;
/*! \brief Encapsulates the status of a command.
*
@@ -254,6 +248,7 @@ union CopyMetadata {
*/
class Command : public Event {
private:
static SysmemPool<ComputeCommand> command_pool_; //!< Pool of active commands
HostQueue* queue_; //!< The command queue this command is enqueue into
Command* next_; //!< Next GPU command in the queue list
Command* batch_head_ = nullptr; //!< The head of the batch commands
@@ -297,6 +292,10 @@ class Command : public Event {
}
public:
//! Overload new/delete for fast commands allocation/destruction
void* operator new(size_t size);
void operator delete(void* ptr);
//! Return the queue this command is enqueued into.
HostQueue* queue() const { return queue_; }
@@ -1787,6 +1786,39 @@ public:
const void* ptr() const { return ptr_; }
};
//! Union used in memory suballocator, must be updated with the new commands
union ComputeCommand {
ReadMemoryCommand cmd0;
WriteMemoryCommand cmd1;
FillMemoryCommand cmd2;
CopyMemoryCommand cmd3;
MapMemoryCommand cmd4;
UnmapMemoryCommand cmd5;
MigrateMemObjectsCommand cmd6;
NDRangeKernelCommand cmd7;
NativeFnCommand cmd8;
ExternalSemaphoreCmd cmd9;
Marker cmd10;
AccumulateCommand cmd11;
AcquireExtObjectsCommand cmd13;
ReleaseExtObjectsCommand cmd14;
PerfCounterCommand cmd15;
ThreadTraceMemObjectsCommand cmd16;
ThreadTraceCommand cmd17;
SignalCommand cmd18;
MakeBuffersResidentCommand cmd19;
SvmFreeMemoryCommand cmd20;
SvmCopyMemoryCommand cmd21;
SvmFillMemoryCommand cmd22;
SvmMapMemoryCommand cmd23;
SvmUnmapMemoryCommand cmd24;
CopyMemoryP2PCommand cmd25;
SvmPrefetchAsyncCommand cmd26;
VirtualMapCommand cmd27;
ComputeCommand() {}
~ComputeCommand() {}
};
/*! @}
* @}
*/