-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/computation: add basic design for backend-agnostic computation
Pull request: #2 Approved by: MichaelHirn
- Loading branch information
Showing
17 changed files
with
263 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//! Provides a binary on native CPU. | ||
|
||
use binary::IBinary; | ||
use frameworks::native::Function; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
/// Defines a host CPU binary. | ||
pub struct Binary { | ||
id: isize, | ||
/// The initialized Blas Dot Operation. | ||
pub blas_dot: Function, | ||
} | ||
|
||
impl Binary { | ||
/// Initializes a native CPU hardware. | ||
pub fn new(id: isize) -> Binary { | ||
Binary { | ||
id: id, | ||
blas_dot: Function::new(1) | ||
} | ||
} | ||
} | ||
|
||
impl IBinary for Binary {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//! 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. | ||
pub struct Function { | ||
id: isize, | ||
} | ||
|
||
impl Function { | ||
/// Initializes a native CPU hardware. | ||
pub fn new(id: isize) -> Function { | ||
Function { id: id } | ||
} | ||
} | ||
|
||
impl IOperation for Function {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//! Provides BLAS for a Native backend. | ||
|
||
use frameworks::Native; | ||
use frameworks::native::{Function, Binary}; | ||
use binary::IBinary; | ||
use libraries::blas::*; | ||
|
||
impl IBlasBinary for Binary { | ||
type Dot = Function; | ||
|
||
fn dot(&self) -> Self::Dot { | ||
self.blas_dot | ||
} | ||
} | ||
|
||
impl IOperationDot for Function { | ||
fn compute(&self, a: i32) { | ||
println!("{}", format!("NATIVE")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! Provides support for various libraries for a Native backend. | ||
|
||
mod blas; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! 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 { | ||
type Dot = Kernel; | ||
|
||
fn dot(&self) -> Self::Dot { | ||
self.blas_dot | ||
} | ||
} | ||
|
||
impl IOperationDot for Kernel { | ||
fn compute(&self, a: i32) { | ||
println!("{}", format!("OPENCL")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
//! Provides support for various libraries for a OpenCL backend. | ||
|
||
mod blas; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//! Provides a Rust wrapper around OpenCL's Program. | ||
|
||
use binary::IBinary; | ||
use frameworks::opencl::{OpenCL, Kernel}; | ||
use super::api::types as cl; | ||
use super::api::API; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
/// Defines a OpenCL Program. | ||
/// | ||
/// A Program is OpenCL's version of Collenchyma's [binary][binary]. | ||
/// [binary]: ../../binary/index.html | ||
pub struct Program { | ||
id: isize, | ||
/// The initialized BLAS dot Operation. | ||
pub blas_dot: Kernel | ||
} | ||
|
||
impl Program { | ||
/// Initializes a new OpenCL device. | ||
pub fn from_isize(id: isize) -> Program { | ||
Program { | ||
id: id, | ||
blas_dot: Kernel::from_isize(1) | ||
} | ||
} | ||
|
||
/// Initializes a new OpenCL device from its C type. | ||
pub fn from_c(id: cl::kernel_id) -> Program { | ||
unsafe { Program { | ||
id: id as isize, | ||
blas_dot: Kernel::from_isize(1) | ||
} } | ||
} | ||
|
||
/// Returns the id as its C type. | ||
pub fn id_c(&self) -> cl::kernel_id { | ||
self.id as cl::kernel_id | ||
} | ||
} | ||
|
||
impl IBinary for Program {} |
Oops, something went wrong.