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

refactor errors #135

Merged
merged 2 commits into from
Mar 31, 2021
Merged
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
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#19c1ab",
"activityBar.activeBorder": "#af1ac6",
"activityBar.background": "#19c1ab",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#af1ac6",
"activityBarBadge.foreground": "#e7e7e7",
"statusBar.background": "#139483",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#19c1ab",
"titleBar.activeBackground": "#139483",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#13948399",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.remoteColor": "#139483"
}
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions coaster-blas/src/frameworks/cuda/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ macro_rules! iblas_asum_for_cuda {
let x_mem = read!(x, self);
let r_mem = write_only!(result, self);

let ctx : &cublas::Context = self.framework().cublas();
let ctx: &cublas::Context = self.framework().cublas();
exec!(
asum,
(*ctx).asum(trans!(x_mem, $t), trans!(r_mem, $t), n, None)
Expand Down Expand Up @@ -131,7 +131,7 @@ macro_rules! iblas_nrm2_for_cuda {
let x_mem = read!(x, self);
let r_mem = write_only!(result, self);

let ctx : &cublas::Context = self.framework().cublas();
let ctx: &cublas::Context = self.framework().cublas();

exec!(
nrm2,
Expand All @@ -155,7 +155,7 @@ macro_rules! iblas_dot_for_cuda {
let x_mem = read!(x, self);
let y_mem = read!(y, self);
let r_mem = write_only!(result, self);
let ctx : &cublas::Context = self.framework().cublas();
let ctx: &cublas::Context = self.framework().cublas();
exec!(
dot,
(*ctx).dot(
Expand Down Expand Up @@ -183,7 +183,7 @@ macro_rules! iblas_scal_for_cuda {
let n = x.desc().size() as i32;
let a_mem = read!(a, self);
let x_mem = read_write!(x, self);
let ctx : &cublas::Context = self.framework().cublas();
let ctx: &cublas::Context = self.framework().cublas();

exec!(
scal,
Expand All @@ -205,7 +205,7 @@ macro_rules! iblas_swap_for_cuda {
let n = x.desc().size() as i32;
let x_mem = read_write!(x, self);
let y_mem = read_write!(y, self);
let ctx : &cublas::Context = self.framework().cublas();
let ctx: &cublas::Context = self.framework().cublas();

exec!(
swap,
Expand Down Expand Up @@ -273,7 +273,7 @@ macro_rules! iblas_gemm_for_cuda {
let ldb = b_1;
let ldc = c_1;

let ctx : &cublas::Context = self.framework().cublas();
let ctx: &cublas::Context = self.framework().cublas();

exec!(
gemm,
Expand Down
1 change: 0 additions & 1 deletion coaster-blas/tests/blas_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ macro_rules! test_blas {
test_nrm2::<$t, _>($backend_getter());
}


#[test]
fn it_computes_correct_scal() {
test_scal::<$t, _>($backend_getter());
Expand Down
20 changes: 10 additions & 10 deletions coaster-nn/src/frameworks/cuda/helper.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
//! Provides useful macros for easier NN implementation for CUDA/cuDNN.

macro_rules! read {
($x:ident, $slf:ident) => (
($x:ident, $slf:ident) => {
$x.read($slf.device()).unwrap()
)
};
}

macro_rules! read_write {
($x:ident, $slf:ident) => (
($x:ident, $slf:ident) => {
$x.read_write($slf.device()).unwrap()
)
};
}

macro_rules! write_only {
($x:ident, $slf:ident) => (
($x:ident, $slf:ident) => {
$x.write_only($slf.device()).unwrap()
)
};
}

// trans! cannot be inlined into macros above, because `$mem` would become
// intermidiate variable and `*mut $t` will outlive it.
macro_rules! trans {
($mem:ident) => (
($mem:ident) => {
unsafe { ::std::mem::transmute::<u64, *const ::libc::c_void>(*$mem.id_c()) }
)
};
}

macro_rules! trans_mut {
($mem:ident) => (
($mem:ident) => {
unsafe { ::std::mem::transmute::<u64, *mut ::libc::c_void>(*$mem.id_c()) }
)
};
}
Loading