Skip to content

Commit

Permalink
Merge pull request openvinotoolkit#35 from riverlijunjie/river/solve_…
Browse files Browse the repository at this point in the history
…4GB_issue

[TEST] Try to solve 4GB memory issue
  • Loading branch information
WeldonWangwang authored Sep 26, 2024
2 parents ae500b5 + 113acb5 commit 2edf7d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ allocation_type ocl_engine::detect_usm_allocation_type(const void* memory) const
bool ocl_engine::check_allocatable(const layout& layout, allocation_type type) {
OPENVINO_ASSERT(supports_allocation(type) || type == allocation_type::cl_mem, "[GPU] Unsupported allocation type: ", type);

bool exceed_allocatable_mem_size = (layout.bytes_count() > get_device_info().max_alloc_mem_size);
bool exceed_allocatable_mem_size = false;// (layout.bytes_count() > get_device_info().max_alloc_mem_size);

// When dynamic shape upper bound makes bigger buffer, then return false.
if (exceed_allocatable_mem_size && layout.is_dynamic()) {
Expand Down
12 changes: 9 additions & 3 deletions src/plugins/intel_gpu/src/runtime/ocl/ocl_ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#pragma once

#define CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL (1 << 23)
#define CL_MEM_FLAGS_INTEL 0x10001

#include <array>

#ifdef OV_GPU_USE_OPENCL_HPP
Expand Down Expand Up @@ -929,21 +932,24 @@ class UsmMemory {

void allocateHost(size_t size) {
cl_int error = CL_SUCCESS;
auto ptr = _usmHelper.allocate_host(nullptr, size, 0, &error);
cl_mem_properties_intel properties[] = {CL_MEM_FLAGS_INTEL, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL, 0};
auto ptr = _usmHelper.allocate_host(properties, size, 0, &error);
_check_error(size, ptr, error, "Host");
_allocate(ptr);
}

void allocateShared(size_t size) {
cl_int error = CL_SUCCESS;
auto ptr = _usmHelper.allocate_shared(nullptr, size, 0, &error);
cl_mem_properties_intel properties[] = {CL_MEM_FLAGS_INTEL, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL, 0};
auto ptr = _usmHelper.allocate_shared(properties, size, 0, &error);
_check_error(size, ptr, error, "Shared");
_allocate(ptr);
}

void allocateDevice(size_t size) {
cl_int error = CL_SUCCESS;
auto ptr = _usmHelper.allocate_device(nullptr, size, 0, &error);
cl_mem_properties_intel properties[] = {CL_MEM_FLAGS_INTEL, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL, 0};
auto ptr = _usmHelper.allocate_device(properties, size, 0, &error);
_check_error(size, ptr, error, "Device");
_allocate(ptr);
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_gpu/src/runtime/ocl/ocl_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int get_cl_map_type(mem_lock_type type) {
gpu_buffer::gpu_buffer(ocl_engine* engine,
const layout& layout)
: lockable_gpu_mem(), memory(engine, layout, allocation_type::cl_mem, nullptr)
, _buffer(engine->get_cl_context(), CL_MEM_READ_WRITE, size() < 8192 ? 8192 : size()) {
, _buffer(engine->get_cl_context(), CL_MEM_READ_WRITE | CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL, size() < 8192 ? 8192 : size()) {
m_mem_tracker = std::make_shared<MemoryTracker>(engine, _buffer.get(), layout.bytes_count(), allocation_type::cl_mem);
}

Expand Down

0 comments on commit 2edf7d2

Please sign in to comment.