Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform::list() return OclResult instead of panicking #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ocl-interop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn get_properties_list() -> ocl::builders::ContextProperties {
}

pub fn get_context() -> std::option::Option<ocl::Context> {
ocl::Platform::list()
ocl::Platform::list().unwrap()
.iter()
.map(|plat| {
//println!("Plat: {}",plat);
Expand Down
4 changes: 1 addition & 3 deletions ocl/examples/opencl_2_1/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn main() -> Result<(), ocl::Error> {
println!("Choosing platorm...");

#[cfg(feature = "opencl_version_2_1")]
let platform = Platform::list().into_iter().find(|plat| plat.name().unwrap() == PLATFORM_NAME)
let platform = Platform::list().unwrap().into_iter().find(|plat| plat.name().unwrap() == PLATFORM_NAME)
.unwrap_or(Platform::default());

#[cfg(not(feature = "opencl_version_2_1"))]
Expand Down Expand Up @@ -97,5 +97,3 @@ fn main() -> Result<(), ocl::Error> {
// println!("The value at index [{}] is now '{}'!", 200007, vec[200007]);
Ok(())
}


7 changes: 3 additions & 4 deletions ocl/src/standard/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ pub struct Platform(PlatformIdCore);

impl Platform {
/// Returns a list of all platforms avaliable on the host machine.
pub fn list() -> Vec<Platform> {
let list_core = core::get_platform_ids()
.expect("Platform::list: Error retrieving platform list");
pub fn list() -> OclResult<Vec<Platform>> {
let list_core = core::get_platform_ids()?;

list_core.into_iter().map(Platform::new).collect()
Ok(list_core.into_iter().map(Platform::new).collect())
}

/// Returns the first available platform.
Expand Down