rusticl/context: add helper to get the max mem alloc size for all devices
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>
This commit is contained in:
@@ -247,10 +247,8 @@ pub fn create_buffer_with_properties(
|
||||
}
|
||||
|
||||
// ... 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)?;
|
||||
|
||||
@@ -141,6 +141,15 @@ impl Context {
|
||||
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user