Comments (7)
This occurs whenever ocl::core:: get_device_ids
does not receive CL_SUCCESS
as a result of the ffi call to clGetDeviceIDs
.
I see two options, either to change the return type to Result<Vec<Device>>
or to replace the expect
with unwrap_or(vec![])
from ocl.
I agree. Try out the device_result branch and let me know how that looks to you two.
from ocl.
I'm hesitant to add too many convenience functions but would the following be a useful Device
method?:
/// Returns a list of devices exactly as `::list` does but unwraps any
/// error and returns an empty `Vec` in the event that the error is a
/// `CL_DEVICE_NOT_FOUND` variant.
///
/// This is a convenience function.
///
///
/// ### Panics
///
/// Panics upon any OpenCL error other than `CL_DEVICE_NOT_FOUND` or any
/// other type of error.
///
pub fn list_or_empty(platform: &Platform, device_types: Option<DeviceType>)
-> Vec<Device> {
match Device::list(platform, device_types) {
Ok(vec) => vec,
Err(err) => match err.status() {
Some(s) => match s {
Status::CL_DEVICE_NOT_FOUND => Vec::with_capacity(0),
_ => panic!("{}", err),
},
None => panic!("{}", err),
},
}
}
from ocl.
Thanks for the fast fix. I don't think list_or_empty
is particularly necessary (for my use case at least). Using result as you did in #40 is 👍
from ocl.
Alright. If @yongqli is satisfied I'll merge and close this.
from ocl.
@c0gent Thanks, but I don't feel the convenience function is particularly necessary either.
from ocl.
Good enough. Thanks guys.
from ocl.
Related Issues (20)
- Concurrent device listing HOT 5
- KernelBuilder is not cloneable
- OpenCL 2.2 and 3.0 support in cl-sys
- double drop may happen upon panic in `EventList as std::convert::From<[E; n]>>::from` HOT 1
- Issues with cl_h.rs in the cl-sys crate
- EventList::From for Into<Event> slices can cause double-drop HOT 1
- Remove dependency without license HOT 1
- rustc_version below 0.2 is no longer available, which breaks building this crate HOT 1
- error: failed to select a version for the requirement `rustc_version = "^0.1"` HOT 1
- Documentation - unclear what use_host_slice does/how to use it HOT 2
- The test program on Ubuntu 21.10 may not be using the GPU HOT 1
- Lifetime bounds in as_slice and as_slice_mut in MemMap HOT 1
- Struct with #[repr(C)] are not necessarily compatible with OpenCL layouts HOT 6
- Result in example file change when removing assert_eq!() HOT 2
- Shared Virtual Memory (SVM) support? HOT 2
- Currently event's future does not work with the new version of tokio
- error: getting `STATUS_ACCESS_VIOLATION` in `Device::list()` HOT 9
- unmet dependencies HOT 1
- How to resolve "fatal error LNK1181: cannot open input file 'OpenCL.lib'" HOT 2
- Couldn't compile : "Couldn't find 'write' in core" after some update. HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ocl.