Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19712>
}
// ... or if size is greater than CL_DEVICE_MAX_MEM_ALLOC_SIZE for all devices in context.
- for dev in &c.devs {
- if checked_compare(size, Ordering::Greater, dev.max_mem_alloc()) {
- return Err(CL_INVALID_BUFFER_SIZE);
- }
+ if checked_compare(size, Ordering::Greater, c.max_mem_alloc()) {
+ return Err(CL_INVALID_BUFFER_SIZE);
}
validate_host_ptr(host_ptr, flags)?;
Ok(res)
}
+
+ /// Returns the max allocation size supported by all devices
+ pub fn max_mem_alloc(&self) -> u64 {
+ self.devs
+ .iter()
+ .map(|dev| dev.max_mem_alloc())
+ .min()
+ .unwrap()
+ }
}
impl Drop for Context {