Use non-paged memory for IPC signals
Non-paged memory can be IPC-shared even when HSA_USERPTR_FOR_PAGED_MEM is enabled. Change-Id: I8b1fa6d7a4a9327c78a77b3679697fbf55397093 Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Este commit está contenido en:
cometido por
Kent Russell
padre
1251842900
commit
0c6b9532d4
@@ -71,8 +71,8 @@ class BaseShared {
|
||||
/// @brief Default Allocator for Shared. Ensures allocations are whole pages.
|
||||
template <typename T> class PageAllocator : private BaseShared {
|
||||
public:
|
||||
__forceinline static T* alloc() {
|
||||
T* ret = reinterpret_cast<T*>(allocate_(AlignUp(sizeof(T), 4096), 4096, 0));
|
||||
__forceinline static T* alloc(int flags = 0) {
|
||||
T* ret = reinterpret_cast<T*>(allocate_(AlignUp(sizeof(T), 4096), 4096, flags));
|
||||
if (ret == nullptr) throw std::bad_alloc();
|
||||
|
||||
MAKE_NAMED_SCOPE_GUARD(throwGuard, [&]() { free_(ret); });
|
||||
@@ -96,14 +96,14 @@ template <typename T> class PageAllocator : private BaseShared {
|
||||
template <typename T, typename Allocator = PageAllocator<T>>
|
||||
class Shared final : private BaseShared {
|
||||
public:
|
||||
explicit Shared(Allocator* pool = nullptr) : pool_(pool) {
|
||||
explicit Shared(Allocator* pool = nullptr, int flags = 0) : pool_(pool) {
|
||||
assert(allocate_ != nullptr && free_ != nullptr &&
|
||||
"Shared object allocator is not set");
|
||||
|
||||
if (pool_)
|
||||
shared_object_ = pool_->alloc();
|
||||
else
|
||||
shared_object_ = PageAllocator<T>::alloc();
|
||||
shared_object_ = PageAllocator<T>::alloc(flags);
|
||||
}
|
||||
|
||||
~Shared() {
|
||||
|
||||
@@ -86,6 +86,7 @@ class MemoryRegion : public Checked<0x9C961F19EE175BB3> {
|
||||
AllocateExecutable = (1 << 1), // Set executable permission
|
||||
AllocateDoubleMap = (1 << 2), // Map twice VA allocation to backing store
|
||||
AllocateDirect = (1 << 3), // Bypass fragment cache.
|
||||
AllocateIPC = (1 << 4), // System memory that can be IPC-shared
|
||||
};
|
||||
|
||||
typedef uint32_t AllocateFlags;
|
||||
|
||||
@@ -158,6 +158,8 @@ hsa_status_t MemoryRegion::Allocate(size_t& size, AllocateFlags alloc_flags, voi
|
||||
(alloc_flags & AllocateExecutable ? 1 : 0);
|
||||
kmt_alloc_flags.ui32.AQLQueueMemory =
|
||||
(alloc_flags & AllocateDoubleMap ? 1 : 0);
|
||||
if (IsSystem() && (alloc_flags & AllocateIPC))
|
||||
kmt_alloc_flags.ui32.NonPaged = 1;
|
||||
|
||||
// Only allow using the suballocator for ordinary VRAM.
|
||||
if (IsLocalMemory()) {
|
||||
|
||||
@@ -121,7 +121,8 @@ void SharedSignalPool_t::free(SharedSignal* ptr) {
|
||||
|
||||
LocalSignal::LocalSignal(hsa_signal_value_t initial_value, bool exportable)
|
||||
: local_signal_(exportable ? nullptr
|
||||
: core::Runtime::runtime_singleton_->GetSharedSignalPool()) {
|
||||
: core::Runtime::runtime_singleton_->GetSharedSignalPool(),
|
||||
exportable ? core::MemoryRegion::AllocateIPC : 0) {
|
||||
local_signal_.shared_object()->amd_signal.value = initial_value;
|
||||
}
|
||||
|
||||
|
||||
Referencia en una nueva incidencia
Block a user