Files
compute-runtime/shared/source/os_interface/linux/os_memory_linux.cpp
kamdiedrich e072275ae6 Reorganization directory structure [3/n]
Change-Id: If3dfa3f6007f8810a6a1ae1a4f0c7da38544648d
2020-02-23 23:48:28 +01:00

33 lines
868 B
C++

/*
* Copyright (C) 2019-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "os_interface/linux/os_memory_linux.h"
namespace NEO {
std::unique_ptr<OSMemory> OSMemory::create() {
return std::make_unique<OSMemoryLinux>();
}
void *OSMemoryLinux::reserveCpuAddressRange(size_t sizeToReserve) {
return mmapWrapper(0, sizeToReserve, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_HUGETLB, -1, 0);
}
void OSMemoryLinux::releaseCpuAddressRange(void *reservedCpuAddressRange, size_t reservedSize) {
munmapWrapper(reservedCpuAddressRange, reservedSize);
}
void *OSMemoryLinux::mmapWrapper(void *addr, size_t size, int prot, int flags, int fd, off_t off) {
return mmap(addr, size, prot, flags, fd, off);
}
int OSMemoryLinux::munmapWrapper(void *addr, size_t size) {
return munmap(addr, size);
}
} // namespace NEO