Skip to content

Commit

Permalink
Merge pull request #34 from filecoin-project/opencl3
Browse files Browse the repository at this point in the history
Switch from ocl to opencl3
  • Loading branch information
vmx authored Jul 6, 2021
2 parents 7ba9d9f + 996cea3 commit 2827a11
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 217 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ repository = "https://github.com/filecoin-project/rust-gpu-tools"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ocl = { version = "0.19.4", package = "fil-ocl" }
dirs = "2.0.2"
sha2 = "0.8.2"
thiserror = "1.0.10"
lazy_static = "1.2"
log = "0.4.11"
opencl3 = "0.2.3"
29 changes: 16 additions & 13 deletions src/opencl/error.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
use opencl3::{device::DeviceInfo, error_codes::ClError, program::ProgramInfo};

#[derive(thiserror::Error, Debug)]
#[allow(clippy::upper_case_acronyms)]
pub enum GPUError {
#[error("Ocl Error: {0}")]
Ocl(ocl::Error),
#[error("Opencl3 Error: {0}{}", match .1 {
Some(message) => format!(" {}", message),
None => "".to_string(),
})]
Opencl3(ClError, Option<String>),
#[error("Device not found!")]
DeviceNotFound,
#[error("Device info not available!")]
DeviceInfoNotAvailable(ocl::enums::DeviceInfo),
DeviceInfoNotAvailable(DeviceInfo),
#[error("Program info not available!")]
ProgramInfoNotAvailable(ocl::enums::ProgramInfo),
ProgramInfoNotAvailable(ProgramInfo),
#[error("Kernel with name {0} not found!")]
KernelNotFound(String),
#[error("IO Error: {0}")]
IO(#[from] std::io::Error),
#[error("Cannot get bus ID for device with vendor {0}")]
MissingBusId(String),
}

#[allow(clippy::upper_case_acronyms)]
#[allow(dead_code)]
pub type GPUResult<T> = std::result::Result<T, GPUError>;

impl From<ocl::Error> for GPUError {
fn from(error: ocl::Error) -> Self {
GPUError::Ocl(error)
}
}

impl From<ocl::core::Error> for GPUError {
fn from(error: ocl::core::Error) -> Self {
GPUError::Ocl(error.into())
impl From<ClError> for GPUError {
fn from(error: ClError) -> Self {
GPUError::Opencl3(error, None)
}
}
Loading

0 comments on commit 2827a11

Please sign in to comment.