Skip to content

Commit

Permalink
style/warnings: remove most warnings
Browse files Browse the repository at this point in the history
Pull request: #2
Approved by: MichaelHirn
  • Loading branch information
MichaelHirn authored and homu committed Nov 27, 2015
1 parent a31dd49 commit 9f6fc44
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 77 deletions.
4 changes: 1 addition & 3 deletions src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@
//! ```
use framework::{IFramework, FrameworkError};
use frameworks::{Native, OpenCL};
use device::IDevice;
use libraries::blas::IBlas;
use frameworks::{Native, OpenCL};
use operation::IOperation;
use std::collections::HashMap;

#[derive(Debug, Clone)]
/// Defines the main and highest struct of Collenchyma.
Expand Down
3 changes: 0 additions & 3 deletions src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
//!
//! [blas]: ../libraries/blas/index.html
use operation::IOperation;
use std::collections::HashMap;

/// Defines the functionality for turning a library into backend-specific, executable operations.
pub trait IBinary {
// Returns the unique identifier of the Binary.
Expand Down
2 changes: 0 additions & 2 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use hardware::IHardware;
use memory::{IMemory, MemoryType};
use operation::IOperation;
use std::hash::{Hash, Hasher};
use frameworks::native::device::Cpu;
use frameworks::opencl::context::Context;

Expand Down
2 changes: 1 addition & 1 deletion src/frameworks/native/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl IDevice for Cpu {
fn sync_memory_to(&self, source: &FlatBox, dest: &mut MemoryType, dest_device: &DeviceType) {
match dest_device.clone() {
DeviceType::Native(_) => {},
DeviceType::OpenCL(ctx) => {
DeviceType::OpenCL(_) => {
unimplemented!();
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/frameworks/native/function.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Provides a operation on native CPU.
use hardware::{IHardware, HardwareType};
use operation::IOperation;
use shared_memory::SharedMemory;

#[derive(Debug, Copy, Clone)]
/// Defines a host CPU operation.
Expand Down
2 changes: 0 additions & 2 deletions src/frameworks/native/libraries/blas.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Provides BLAS for a Native backend.
use frameworks::Native;
use frameworks::native::{Function, Binary};
use binary::IBinary;
use libraries::blas::*;

impl IBlasBinary for Binary {
Expand Down
40 changes: 20 additions & 20 deletions src/frameworks/opencl/api/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,26 @@ impl error::Error for Error {

fn cause(&self) -> Option<&error::Error> {
match *self {
Error::InvalidPlatform(ref err) => None,
Error::InvalidDevice(ref err) => None,
Error::InvalidDeviceType(ref err) => None,
Error::InvalidContext(ref err) => None,
Error::InvalidMemObject(ref err) => None,
Error::InvalidCommandQueue(ref err) => None,
Error::InvalidEventWaitList(ref err) => None,
Error::InvalidValue(ref err) => None,
Error::InvalidProperty(ref err) => None,
Error::InvalidOperation(ref err) => None,
Error::InvalidBufferSize(ref err) => None,
Error::InvalidHostPtr(ref err) => None,
Error::DeviceNotFound(ref err) => None,
Error::DeviceNotAvailable(ref err) => None,
Error::MemObjectAllocationFailure(ref err) => None,
Error::MisalignedSubBufferOffset(ref err) => None,
Error::ExecStatusErrorForEventsInWaitList(ref err) => None,
Error::OutOfResources(ref err) => None,
Error::OutOfHostMemory(ref err) => None,
Error::Other(ref err) => None,
Error::InvalidPlatform(_) => None,
Error::InvalidDevice(_) => None,
Error::InvalidDeviceType(_) => None,
Error::InvalidContext(_) => None,
Error::InvalidMemObject(_) => None,
Error::InvalidCommandQueue(_) => None,
Error::InvalidEventWaitList(_) => None,
Error::InvalidValue(_) => None,
Error::InvalidProperty(_) => None,
Error::InvalidOperation(_) => None,
Error::InvalidBufferSize(_) => None,
Error::InvalidHostPtr(_) => None,
Error::DeviceNotFound(_) => None,
Error::DeviceNotAvailable(_) => None,
Error::MemObjectAllocationFailure(_) => None,
Error::MisalignedSubBufferOffset(_) => None,
Error::ExecStatusErrorForEventsInWaitList(_) => None,
Error::OutOfResources(_) => None,
Error::OutOfHostMemory(_) => None,
Error::Other(_) => None,
}
}
}
2 changes: 1 addition & 1 deletion src/frameworks/opencl/api/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use frameworks::opencl::{API, Error};
use frameworks::opencl::Platform;
use super::types as cl;
use super::ffi::*;
use std::{ptr, mem};
use std::ptr;
use std::iter::repeat;
use std::sync::{StaticMutex, MUTEX_INIT};

Expand Down
22 changes: 11 additions & 11 deletions src/frameworks/opencl/api/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use libc;
use std::fmt;
use num::FromPrimitive;

/* Opaque types */
pub type platform_id = *mut libc::c_void;
Expand Down Expand Up @@ -62,6 +61,7 @@ pub type event_info = uint;
pub type command_type = uint;
pub type profiling_info = uint;

#[repr(C)]
pub struct image_format {
image_channel_order: channel_order,
image_channel_data_type: channel_type
Expand Down Expand Up @@ -163,13 +163,13 @@ pub enum DeviceType {
ALL(bitfield),
}
pub static DEVICE_TYPE: [DeviceType; 5] = [
DeviceType::DEFAULT(1<<0),
DeviceType::DEFAULT(1),
DeviceType::CPU(1<<1),
DeviceType::GPU(1<<2),
DeviceType::ACCELERATOR(1<<3),
DeviceType::ALL(0xFFFFFFFF)
];
pub const CL_DEVICE_TYPE_DEFAULT: bitfield = 1 << 0;
pub const CL_DEVICE_TYPE_DEFAULT: bitfield = 1;
pub const CL_DEVICE_TYPE_CPU: bitfield = 1 << 1;
pub const CL_DEVICE_TYPE_GPU: bitfield = 1 << 2;
pub const CL_DEVICE_TYPE_ACCELERATOR: bitfield = 1 << 3;
Expand Down Expand Up @@ -241,7 +241,7 @@ pub static CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF: uint = 0x103C;
pub static CL_DEVICE_OPENCL_C_VERSION: uint = 0x103D;

/* cl_device_fp_config - bitfield */
pub static CL_FP_DENORM: bitfield = 1 << 0;
pub static CL_FP_DENORM: bitfield = 1;
pub static CL_FP_INF_NAN: bitfield = 1 << 1;
pub static CL_FP_ROUND_TO_NEAREST: bitfield = 1 << 2;
pub static CL_FP_ROUND_TO_ZERO: bitfield = 1 << 3;
Expand All @@ -259,11 +259,11 @@ pub static CL_LOCAL: uint = 0x1;
pub static CL_GLOBAL: uint = 0x2;

/* cl_device_exec_capabilities - bitfield */
pub static CL_EXEC_KERNEL: bitfield = 1 << 0;
pub static CL_EXEC_KERNEL: bitfield = 1;
pub static CL_EXEC_NATIVE_KERNEL: bitfield = 1 << 1;

/* cl_command_queue_properties - bitfield */
pub static CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE: bitfield = 1 << 0;
pub static CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE: bitfield = 1;
pub static CL_QUEUE_PROFILING_ENABLE: bitfield = 1 << 1;

/* cl_context_info */
Expand All @@ -282,7 +282,7 @@ pub static CL_QUEUE_REFERENCE_COUNT: uint = 0x1092;
pub static CL_QUEUE_PROPERTIES: uint = 0x1093;

/* cl_mem_flags - bitfield */
pub static CL_MEM_READ_WRITE: bitfield = 1 << 0;
pub static CL_MEM_READ_WRITE: bitfield = 1;
pub static CL_MEM_WRITE_ONLY: bitfield = 1 << 1;
pub static CL_MEM_READ_ONLY: bitfield = 1 << 2;
pub static CL_MEM_USE_HOST_PTR: bitfield = 1 << 3;
Expand All @@ -300,9 +300,9 @@ pub static CL_BGRA: uint = 0x10B6;
pub static CL_ARGB: uint = 0x10B7;
pub static CL_INTENSITY: uint = 0x10B8;
pub static CL_LUMINANCE: uint = 0x10B9;
pub static CL_Rx: uint = 0x10BA;
pub static CL_RGx: uint = 0x10BB;
pub static CL_RGBx: uint = 0x10BC;
pub static CL_RX: uint = 0x10BA;
pub static CL_RGX: uint = 0x10BB;
pub static CL_RGBX: uint = 0x10BC;

/* cl_channel_type */
pub static CL_SNORM_INT8: uint = 0x10D0;
Expand Down Expand Up @@ -365,7 +365,7 @@ pub static CL_SAMPLER_ADDRESSING_MODE: uint = 0x1153;
pub static CL_SAMPLER_FILTER_MODE: uint = 0x1154;

/* cl_map_flags - bitfield */
pub static CL_MAP_READ: bitfield = 1 << 0;
pub static CL_MAP_READ: bitfield = 1;
pub static CL_MAP_WRITE: bitfield = 1 << 1;

/* cl_program_info */
Expand Down
4 changes: 2 additions & 2 deletions src/frameworks/opencl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ impl Context {
let callback = unsafe { mem::transmute(ptr::null::<fn()>()) };
Ok(
Context::from_c(
try!(unsafe {API::create_context(devices.clone(), ptr::null(), callback, ptr::null_mut())}),
try!(API::create_context(devices.clone(), ptr::null(), callback, ptr::null_mut())),
devices.clone()
)
)
}

/// Initializes a new OpenCL platform from its C type.
pub fn from_c(id: cl::context_id, devices: Vec<Device>) -> Context {
unsafe { Context { id: id as isize, devices: devices } }
Context { id: id as isize, devices: devices }
}

/// Returns the id as isize.
Expand Down
15 changes: 7 additions & 8 deletions src/frameworks/opencl/device.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Provides a Rust wrapper around OpenCL's device.
use hardware::{IHardware, HardwareType};
use frameworks::opencl::OpenCL;
use super::api::types as cl;
use super::api::API;
use std::io::Cursor;
Expand Down Expand Up @@ -38,7 +37,7 @@ impl Device {

/// Initializes a new OpenCL device from its C type.
pub fn from_c(id: cl::device_id) -> Device {
unsafe { Device { id: id as isize, ..Device::default() } }
Device { id: id as isize, ..Device::default() }
}

/// Returns the id as its C type.
Expand All @@ -48,16 +47,16 @@ impl Device {

/// Loads the name of the device via a foreign OpenCL call.
pub fn load_name(&mut self) -> Self {
self.name = match unsafe { API::load_device_info(self, cl::CL_DEVICE_NAME) } {
self.name = match API::load_device_info(self, cl::CL_DEVICE_NAME) {
Ok(result) => Some(result.to_string()),
Err(err) => None
Err(_) => None
};
self.clone()
}

/// Loads the device type via a foreign OpenCL call.
pub fn load_device_type(&mut self) -> Self {
self.device_type = match unsafe { API::load_device_info(self, cl::CL_DEVICE_TYPE) } {
self.device_type = match API::load_device_info(self, cl::CL_DEVICE_TYPE) {
Ok(result) => {
let device_type = result.to_device_type();
match device_type {
Expand All @@ -69,16 +68,16 @@ impl Device {
_ => None
}
},
Err(err) => None
Err(_) => None
};
self.clone()
}

/// Loads the compute units of the device via a foreign OpenCL call.
pub fn load_compute_units(&mut self) -> Self {
self.compute_units = match unsafe { API::load_device_info(self, cl::CL_DEVICE_MAX_COMPUTE_UNITS) } {
self.compute_units = match API::load_device_info(self, cl::CL_DEVICE_MAX_COMPUTE_UNITS) {
Ok(result) => Some(result.to_isize()),
Err(err) => None
Err(_) => None
};
self.clone()
}
Expand Down
3 changes: 1 addition & 2 deletions src/frameworks/opencl/kernel.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Provides a Rust wrapper around OpenCL's Kernel.
use operation::IOperation;
use frameworks::opencl::OpenCL;
use super::api::types as cl;
use super::api::API;

Expand All @@ -22,7 +21,7 @@ impl Kernel {

/// Initializes a new OpenCL device from its C type.
pub fn from_c(id: cl::kernel_id) -> Kernel {
unsafe { Kernel { id: id as isize } }
Kernel { id: id as isize }
}

/// Returns the id as its C type.
Expand Down
2 changes: 0 additions & 2 deletions src/frameworks/opencl/libraries/blas.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! Provides BLAS for a OpenCL backend.
use frameworks::OpenCL;
use frameworks::opencl::Kernel;
use frameworks::opencl::Program;
use binary::IBinary;
use libraries::blas::*;

impl IBlasBinary for Program {
Expand Down
7 changes: 2 additions & 5 deletions src/frameworks/opencl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
extern { }

use framework::{IFramework, FrameworkError};
use hardware::{HardwareType, IHardware};
pub use self::platform::Platform;
pub use self::context::Context;
pub use self::memory::Memory;
Expand All @@ -21,7 +20,6 @@ pub use self::kernel::Kernel;
pub use self::program::Program;
pub use self::device::{Device, DeviceInfo};
pub use self::api::{API, Error};
use self::api::types as cl;

pub mod device;
pub mod platform;
Expand Down Expand Up @@ -73,9 +71,8 @@ impl IFramework for OpenCL {

let mut hardware_container: Vec<Device> = vec!();
for platform in &platforms {
match API::load_devices(platform) {
Ok(hardwares) => hardware_container.append(&mut hardwares.clone()),
_ => ()
if let Ok(hardwares) = API::load_devices(platform) {
hardware_container.append(&mut hardwares.clone())
}
}
Ok(hardware_container)
Expand Down
2 changes: 1 addition & 1 deletion src/frameworks/opencl/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Platform {

/// Initializes a new OpenCL platform from its C type.
pub fn from_c(id: cl::platform_id) -> Platform {
unsafe { Platform { id: id as isize } }
Platform { id: id as isize }
}

/// Returns the id as isize.
Expand Down
6 changes: 3 additions & 3 deletions src/frameworks/opencl/program.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Provides a Rust wrapper around OpenCL's Program.
use binary::IBinary;
use frameworks::opencl::{OpenCL, Kernel};
use frameworks::opencl::Kernel;
use super::api::types as cl;
use super::api::API;

Expand All @@ -27,10 +27,10 @@ impl Program {

/// Initializes a new OpenCL device from its C type.
pub fn from_c(id: cl::kernel_id) -> Program {
unsafe { Program {
Program {
id: id as isize,
blas_dot: Kernel::from_isize(1)
} }
}
}

/// Returns the id as its C type.
Expand Down
2 changes: 1 addition & 1 deletion src/frameworks/opencl/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Queue {

/// Initializes a new OpenCL command queue from its C type.
pub fn from_c(id: cl::queue_id) -> Queue {
unsafe { Queue { id: id as isize } }
Queue { id: id as isize }
}

/// Returns the id as isize.
Expand Down
8 changes: 0 additions & 8 deletions src/libraries/blas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,8 @@
//!
//! [blas-source]: https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms
use backend::Backend;
use hardware::IHardware;
use device::IDevice;
use framework::IFramework;
use operation::IOperation;
use binary::IBinary;
use frameworks::Native;
use frameworks::OpenCL;
use shared_memory::SharedMemory;
use blas::Vector;

/// Provides the functionality for a backend to support Basic Linear Algebra Subprograms.
pub trait IBlas {
Expand Down

0 comments on commit 9f6fc44

Please sign in to comment.