Skip to content

Commit

Permalink
[cpu] Reuse VirtualMemoryAllocator for CPU ndarray memory allocation (#…
Browse files Browse the repository at this point in the history
…7128)

Fixes #7119

It seems unnecessary for CPU to use runtime jit memory allocation for
ndarray, let's see if anything breaks...
  • Loading branch information
ailzhang authored and lin-hitonami committed Jan 12, 2023
1 parent f84e564 commit 580dcab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
12 changes: 1 addition & 11 deletions taichi/rhi/cpu/cpu_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,7 @@ DeviceAllocation CpuDevice::allocate_memory(const AllocParams &params) {

DeviceAllocation CpuDevice::allocate_memory_runtime(
const LlvmRuntimeAllocParams &params) {
AllocInfo info;
info.ptr = allocate_llvm_runtime_memory_jit(params);
// TODO: Add caching allocator
info.size = params.size;
info.use_cached = params.use_cached;
DeviceAllocation alloc;
alloc.alloc_id = allocations_.size();
alloc.device = this;

allocations_.push_back(info);
return alloc;
return allocate_memory(params);
}

void CpuDevice::dealloc_memory(DeviceAllocation handle) {
Expand Down
4 changes: 1 addition & 3 deletions tests/python/test_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,8 @@ def test_ndarray_reset():
ti.reset()


# FIXME[#7119]: enable this test on CPU backend once caching allocator is used.
@pytest.mark.run_in_serial
@test_utils.test(arch=supported_archs_taichi_ndarray,
exclude=[ti.cpu, ti.metal])
@test_utils.test(arch=supported_archs_taichi_ndarray, exclude=ti.metal)
def test_ndarray_in_python_func():
def test():
z = ti.ndarray(float, (8192, 8192))
Expand Down

0 comments on commit 580dcab

Please sign in to comment.