Skip to content

Commit

Permalink
Merge pull request #49 from bluss/more-arches
Browse files Browse the repository at this point in the history
Fix test build for non-x86
  • Loading branch information
bluss committed Sep 22, 2019
2 parents 36f4375 + 75015d9 commit 4ac62c2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
18 changes: 12 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,19 @@ install:
# the main build
script:
- |
set -e &&
set -v &&
rustc --print cfg -Ctarget-cpu=native &&
cargo build --target=$TARGET &&
([ -n "$BUILD_ONLY" ] || (
cargo test --target=$TARGET &&
cargo test --release --target=$TARGET &&
cargo doc --target=$TARGET &&
cargo bench --target=$TARGET ))
cargo build -v --target=$TARGET && (
if [ -n "$BUILD_ONLY" ]; then
cargo check --tests -v --target=$TARGET &&
cargo doc -v --target=$TARGET
else
cargo test -v --target=$TARGET &&
cargo test -v --release --target=$TARGET &&
cargo doc -v --target=$TARGET &&
cargo bench -v --target=$TARGET
fi)
branches:
only:
Expand Down
11 changes: 7 additions & 4 deletions src/dgemm_kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,12 @@ mod tests {
use super::*;
use aligned_alloc::Alloc;

fn aligned_alloc<T>(elt: T, n: usize) -> Alloc<T> where T: Copy
fn aligned_alloc<K>(elt: K::Elem, n: usize) -> Alloc<K::Elem>
where K: GemmKernel,
K::Elem: Copy,
{
unsafe {
Alloc::new(n, KernelAvx::align_to()).init_with(elt)
Alloc::new(n, K::align_to()).init_with(elt)
}
}

Expand All @@ -827,8 +829,8 @@ mod tests {
const K: usize = 4;
let mr = K::MR;
let nr = K::NR;
let mut a = aligned_alloc(1., mr * K);
let mut b = aligned_alloc(0., nr * K);
let mut a = aligned_alloc::<K>(1., mr * K);
let mut b = aligned_alloc::<K>(0., nr * K);
for (i, x) in a.iter_mut().enumerate() {
*x = i as _;
}
Expand All @@ -850,6 +852,7 @@ mod tests {
}

#[test]
#[cfg(any(target_arch="x86", target_arch="x86_64"))]
fn test_loop_m_n() {
let mut m = [[0; 4]; KernelAvx::MR];
loop_m!(i, loop4!(j, m[i][j] += 1));
Expand Down
11 changes: 7 additions & 4 deletions src/sgemm_kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,12 @@ mod tests {
use super::*;
use aligned_alloc::Alloc;

fn aligned_alloc<T>(elt: T, n: usize) -> Alloc<T> where T: Copy
fn aligned_alloc<K>(elt: K::Elem, n: usize) -> Alloc<K::Elem>
where K: GemmKernel,
K::Elem: Copy,
{
unsafe {
Alloc::new(n, KernelAvx::align_to()).init_with(elt)
Alloc::new(n, K::align_to()).init_with(elt)
}
}

Expand All @@ -514,8 +516,8 @@ mod tests {
const K: usize = 4;
let mr = K::MR;
let nr = K::NR;
let mut a = aligned_alloc(1., mr * K);
let mut b = aligned_alloc(0., nr * K);
let mut a = aligned_alloc::<K>(1., mr * K);
let mut b = aligned_alloc::<K>(0., nr * K);
for (i, x) in a.iter_mut().enumerate() {
*x = i as _;
}
Expand All @@ -536,6 +538,7 @@ mod tests {
test_a_kernel::<KernelFallback>("kernel");
}

#[cfg(any(target_arch="x86", target_arch="x86_64"))]
#[test]
fn test_loop_m_n() {
let mut m = [[0; KernelAvx::NR]; KernelAvx::MR];
Expand Down

0 comments on commit 4ac62c2

Please sign in to comment.