* start of C++ docs

* fix stream doc

* only include ops for now
This commit is contained in:
Awni Hannun
2024-04-26 12:56:05 -07:00
committed by GitHub
parent 82463e9938
commit 5bfe89bdb1
9 changed files with 87 additions and 20 deletions

View File

@@ -165,6 +165,15 @@ Buffer MetalAllocator::malloc(size_t size, bool allow_swap /* = false */) {
return Buffer{nullptr};
}
// More helpful message if maximum buffer length is exceeded
if (size > device_->maxBufferLength()) {
std::ostringstream msg;
msg << "Attempting to allocate " << size << " bytes which is greater than"
<< " the maximum allowed buffer size of " << device_->maxBufferLength()
<< " bytes.";
throw std::runtime_error(msg.str());
}
// Align up memory
if (size > vm_page_size) {
size = vm_page_size * ((size + vm_page_size - 1) / vm_page_size);