Metal validation (#432)

* tests clear metal validation

* add cpp test with metal validation to circleci

* nit
This commit is contained in:
Awni Hannun
2024-01-11 11:57:24 -08:00
committed by GitHub
parent 975e265f74
commit c9934fe8a4
10 changed files with 142 additions and 35 deletions

View File

@@ -153,6 +153,11 @@ MetalAllocator::MetalAllocator()
gc_limit_(0.95 * device_->recommendedMaxWorkingSetSize()) {}
Buffer MetalAllocator::malloc(size_t size, bool allow_swap /* = false */) {
// Metal doesn't like empty buffers
if (size == 0) {
return Buffer{nullptr};
}
// Align up memory
if (size > vm_page_size) {
size = vm_page_size * ((size + vm_page_size - 1) / vm_page_size);